a
This commit is contained in:
parent
6094319ddf
commit
4d7171f4bf
9 changed files with 89 additions and 46 deletions
11
CLAUDE.md
Normal file
11
CLAUDE.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# INSTRUCTIONS TO FOLLOW
|
||||||
|
|
||||||
|
## ALWAYS DO
|
||||||
|
|
||||||
|
1. Build/deploy changes to Docker Desktop, for all kinds of development environments, for debugging, for testing. Deploy on Docker Desktop, then use the assigned PORTS for the works/needs.
|
||||||
|
2. Use a unique reserved set of ports for this project.
|
||||||
|
|
||||||
|
## NEVER DO
|
||||||
|
|
||||||
|
1. Never build anything on localhost (local machine) directly without deploying the builds on Docker Desktop.
|
||||||
|
2. Never use default/varying ports.
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Stage 1: Build Environment
|
# Stage 1: Build Environment
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
FROM rust:1.75-bookworm AS builder
|
FROM rust:1.85-bookworm AS builder
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
|
|
@ -48,9 +48,6 @@ RUN mkdir -p /data/synor && chown -R synor:synor /data
|
||||||
# Copy binary from builder
|
# Copy binary from builder
|
||||||
COPY --from=builder /app/target/release/synord /usr/local/bin/synord
|
COPY --from=builder /app/target/release/synord /usr/local/bin/synord
|
||||||
|
|
||||||
# Copy default configuration
|
|
||||||
COPY --from=builder /app/apps/synord/config/ /etc/synor/
|
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER synor
|
USER synor
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
# Synor Block Explorer Backend Dockerfile
|
# Synor Block Explorer Dockerfile
|
||||||
# Placeholder for future implementation
|
# Multi-stage build for backend API and frontend
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Stage 1: Build Environment
|
# Stage 1: Build Rust Backend
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
FROM rust:1.75-bookworm AS builder
|
FROM rust:1.85-bookworm AS backend-builder
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
|
|
@ -22,11 +22,25 @@ COPY Cargo.toml Cargo.lock ./
|
||||||
COPY crates/ crates/
|
COPY crates/ crates/
|
||||||
COPY apps/ apps/
|
COPY apps/ apps/
|
||||||
|
|
||||||
# Build (placeholder - explorer app not yet implemented)
|
# Build explorer backend
|
||||||
# RUN cargo build --release --bin synor-explorer
|
RUN cargo build --release -p synor-explorer
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Stage 2: Runtime Environment (placeholder)
|
# Stage 2: Build Frontend
|
||||||
|
# =============================================================================
|
||||||
|
FROM node:20-alpine AS frontend-builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy frontend source
|
||||||
|
COPY apps/explorer-web/package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY apps/explorer-web/ ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Stage 3: Runtime Environment
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
FROM debian:bookworm-slim AS runtime
|
FROM debian:bookworm-slim AS runtime
|
||||||
|
|
||||||
|
|
@ -40,11 +54,31 @@ RUN apt-get update && apt-get install -y \
|
||||||
# Create non-root user
|
# Create non-root user
|
||||||
RUN useradd --create-home --shell /bin/bash explorer
|
RUN useradd --create-home --shell /bin/bash explorer
|
||||||
|
|
||||||
|
# Copy backend binary
|
||||||
|
COPY --from=backend-builder /app/target/release/synor-explorer /usr/local/bin/synor-explorer
|
||||||
|
|
||||||
|
# Copy frontend build
|
||||||
|
COPY --from=frontend-builder /app/dist /var/www/explorer
|
||||||
|
|
||||||
|
# Set ownership
|
||||||
|
RUN chown -R explorer:explorer /var/www/explorer
|
||||||
|
|
||||||
USER explorer
|
USER explorer
|
||||||
WORKDIR /home/explorer
|
WORKDIR /home/explorer
|
||||||
|
|
||||||
|
# Expose ports
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Placeholder - the explorer backend is not yet implemented
|
# Health check
|
||||||
# This Dockerfile serves as a template for future development
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||||
CMD ["echo", "Explorer backend not yet implemented. See apps/explorer for implementation details."]
|
CMD curl -f http://localhost:3000/health || exit 1
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
ENV SYNOR_RPC_URL=http://localhost:17110
|
||||||
|
ENV SYNOR_WS_URL=ws://localhost:17111
|
||||||
|
ENV EXPLORER_LISTEN_ADDR=0.0.0.0:3000
|
||||||
|
ENV EXPLORER_STATIC_DIR=/var/www/explorer
|
||||||
|
ENV RUST_LOG=info
|
||||||
|
|
||||||
|
# Default command
|
||||||
|
ENTRYPOINT ["synor-explorer"]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Stage 1: Build Environment
|
# Stage 1: Build Environment
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
FROM rust:1.75-bookworm AS builder
|
FROM rust:1.85-bookworm AS builder
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ async fn import_blocks(
|
||||||
errors += 1;
|
errors += 1;
|
||||||
} else {
|
} else {
|
||||||
imported += 1;
|
imported += 1;
|
||||||
if imported.is_multiple_of(1000) {
|
if imported % 1000 == 0 {
|
||||||
info!("Imported {} blocks...", imported);
|
info!("Imported {} blocks...", imported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -586,7 +586,7 @@ async fn export_blocks(
|
||||||
writer.write_all(&serialized)?;
|
writer.write_all(&serialized)?;
|
||||||
|
|
||||||
exported += 1;
|
exported += 1;
|
||||||
if exported.is_multiple_of(1000) {
|
if exported % 1000 == 0 {
|
||||||
info!("Exported {} blocks...", exported);
|
info!("Exported {} blocks...", exported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ impl KHeavyHash {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report progress every 10000 hashes
|
// Report progress every 10000 hashes
|
||||||
if tried.is_multiple_of(10000) && !callback(tried, nonce) {
|
if tried % 10000 == 0 && !callback(tried, nonce) {
|
||||||
return None; // Cancelled
|
return None; // Cancelled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ impl BlockMiner {
|
||||||
nonce = nonce.wrapping_add(1);
|
nonce = nonce.wrapping_add(1);
|
||||||
|
|
||||||
// Update stats periodically
|
// Update stats periodically
|
||||||
if hashes.is_multiple_of(10000) {
|
if hashes % 10000 == 0 {
|
||||||
self.hash_counter.fetch_add(10000, Ordering::Relaxed);
|
self.hash_counter.fetch_add(10000, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ fn make_utxo(n: u64) -> StoredUtxo {
|
||||||
amount: 1_000_000_000 + n * 1000,
|
amount: 1_000_000_000 + n * 1000,
|
||||||
script_pubkey,
|
script_pubkey,
|
||||||
block_daa_score: n * 10,
|
block_daa_score: n * 10,
|
||||||
is_coinbase: n.is_multiple_of(10),
|
is_coinbase: n % 10 == 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
# Synor Testnet Docker Compose Configuration
|
# Synor Testnet Docker Compose Configuration
|
||||||
# Deploys 3 seed nodes for initial testnet bootstrap
|
# Deploys 3 seed nodes for initial testnet bootstrap
|
||||||
|
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
# Seed Node 1 (Primary Bootstrap)
|
# Seed Node 1 (Primary Bootstrap)
|
||||||
|
|
@ -15,13 +13,13 @@ services:
|
||||||
hostname: seed1
|
hostname: seed1
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command:
|
command:
|
||||||
- "--data-dir=/data/synor"
|
- "run"
|
||||||
- "--network=testnet"
|
- "--p2p-host=0.0.0.0"
|
||||||
- "--p2p-addr=0.0.0.0:17511"
|
- "--p2p-port=17511"
|
||||||
- "--rpc-http-addr=0.0.0.0:17110"
|
- "--rpc-host=0.0.0.0"
|
||||||
- "--rpc-ws-addr=0.0.0.0:17111"
|
- "--rpc-port=17110"
|
||||||
- "--mining-enabled"
|
- "--ws-port=17111"
|
||||||
- "--log-level=info"
|
- "--mine"
|
||||||
ports:
|
ports:
|
||||||
- "17511:17511" # P2P
|
- "17511:17511" # P2P
|
||||||
- "17110:17110" # HTTP RPC
|
- "17110:17110" # HTTP RPC
|
||||||
|
|
@ -33,9 +31,10 @@ services:
|
||||||
ipv4_address: 172.20.0.10
|
ipv4_address: 172.20.0.10
|
||||||
environment:
|
environment:
|
||||||
- RUST_LOG=info
|
- RUST_LOG=info
|
||||||
|
- SYNOR_DATA_DIR=/data/synor
|
||||||
- SYNOR_NETWORK=testnet
|
- SYNOR_NETWORK=testnet
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:17110/health"]
|
test: ["CMD", "synord", "version"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
@ -52,14 +51,14 @@ services:
|
||||||
hostname: seed2
|
hostname: seed2
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command:
|
command:
|
||||||
- "--data-dir=/data/synor"
|
- "run"
|
||||||
- "--network=testnet"
|
- "--p2p-host=0.0.0.0"
|
||||||
- "--p2p-addr=0.0.0.0:17511"
|
- "--p2p-port=17511"
|
||||||
- "--rpc-http-addr=0.0.0.0:17110"
|
- "--rpc-host=0.0.0.0"
|
||||||
- "--rpc-ws-addr=0.0.0.0:17111"
|
- "--rpc-port=17110"
|
||||||
- "--bootstrap-peers=/ip4/172.20.0.10/tcp/17511"
|
- "--ws-port=17111"
|
||||||
- "--mining-enabled"
|
- "--seeds=172.20.0.10:17511"
|
||||||
- "--log-level=info"
|
- "--mine"
|
||||||
ports:
|
ports:
|
||||||
- "17521:17511" # P2P (offset port)
|
- "17521:17511" # P2P (offset port)
|
||||||
- "17120:17110" # HTTP RPC
|
- "17120:17110" # HTTP RPC
|
||||||
|
|
@ -71,6 +70,7 @@ services:
|
||||||
ipv4_address: 172.20.0.11
|
ipv4_address: 172.20.0.11
|
||||||
environment:
|
environment:
|
||||||
- RUST_LOG=info
|
- RUST_LOG=info
|
||||||
|
- SYNOR_DATA_DIR=/data/synor
|
||||||
- SYNOR_NETWORK=testnet
|
- SYNOR_NETWORK=testnet
|
||||||
depends_on:
|
depends_on:
|
||||||
seed1:
|
seed1:
|
||||||
|
|
@ -87,14 +87,14 @@ services:
|
||||||
hostname: seed3
|
hostname: seed3
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command:
|
command:
|
||||||
- "--data-dir=/data/synor"
|
- "run"
|
||||||
- "--network=testnet"
|
- "--p2p-host=0.0.0.0"
|
||||||
- "--p2p-addr=0.0.0.0:17511"
|
- "--p2p-port=17511"
|
||||||
- "--rpc-http-addr=0.0.0.0:17110"
|
- "--rpc-host=0.0.0.0"
|
||||||
- "--rpc-ws-addr=0.0.0.0:17111"
|
- "--rpc-port=17110"
|
||||||
- "--bootstrap-peers=/ip4/172.20.0.10/tcp/17511,/ip4/172.20.0.11/tcp/17511"
|
- "--ws-port=17111"
|
||||||
- "--mining-enabled"
|
- "--seeds=172.20.0.10:17511,172.20.0.11:17511"
|
||||||
- "--log-level=info"
|
- "--mine"
|
||||||
ports:
|
ports:
|
||||||
- "17531:17511" # P2P (offset port)
|
- "17531:17511" # P2P (offset port)
|
||||||
- "17130:17110" # HTTP RPC
|
- "17130:17110" # HTTP RPC
|
||||||
|
|
@ -106,6 +106,7 @@ services:
|
||||||
ipv4_address: 172.20.0.12
|
ipv4_address: 172.20.0.12
|
||||||
environment:
|
environment:
|
||||||
- RUST_LOG=info
|
- RUST_LOG=info
|
||||||
|
- SYNOR_DATA_DIR=/data/synor
|
||||||
- SYNOR_NETWORK=testnet
|
- SYNOR_NETWORK=testnet
|
||||||
depends_on:
|
depends_on:
|
||||||
seed1:
|
seed1:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue