mirror of
https://github.com/luxfi/netrunner.git
synced 2026-07-27 00:04:23 +00:00
ci: migrate to shared docker-build workflow (native multi-arch, semver)
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
GHCR_REGISTRY: ghcr.io
|
||||
DOCKERHUB_REGISTRY: docker.io
|
||||
IMAGE_NAME: luxfi/netrunner
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.GHCR_REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.DOCKERHUB_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASS }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha,prefix=sha-
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
platforms: linux/amd64,linux/arm64
|
||||
@@ -0,0 +1,15 @@
|
||||
name: Docker
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [main, dev, test]
|
||||
tags: ['v*']
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
jobs:
|
||||
docker:
|
||||
uses: hanzoai/.github/.github/workflows/docker-build.yml@main
|
||||
with:
|
||||
image: ghcr.io/luxfi/netrunner
|
||||
secrets: inherit
|
||||
@@ -129,7 +129,7 @@ curl -X POST -k http://localhost:8081/v1/control/start -d '{"execPath":"'${LUXD_
|
||||
netrunner control start \
|
||||
--log-level debug \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH}
|
||||
```
|
||||
|
||||
@@ -598,7 +598,7 @@ find ${HOME}/go/src/github.com/luxfi/sdk/node/build
|
||||
|
||||
# generate the genesis for the custom chain
|
||||
export CHAIN_ID=99999
|
||||
export GENESIS_ADDRESS="0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
|
||||
export GENESIS_ADDRESS="0x9011E888251AB053B7bD1cdB598Db4f9DEd94714"
|
||||
cat <<EOF > /tmp/subnet-evm.genesis.json
|
||||
{
|
||||
"config": {
|
||||
@@ -981,17 +981,8 @@ The helper function `NewDefaultNetwork` returns a network using a pre-defined co
|
||||
```go
|
||||
// NewDefaultNetwork returns a new network using a pre-defined
|
||||
// network configuration.
|
||||
// The following addresses are pre-funded:
|
||||
// X-Chain Address 1: X-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p
|
||||
// X-Chain Address 1 Key: PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
|
||||
// X-Chain Address 2: X-custom16045mxr3s2cjycqe2xfluk304xv3ezhkhsvkpr
|
||||
// X-Chain Address 2 Key: PrivateKey-2fzYBh3bbWemKxQmMfX6DSuL2BFmDSLQWTvma57xwjQjtf8gFq
|
||||
// P-Chain Address 1: P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p
|
||||
// P-Chain Address 1 Key: PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN
|
||||
// P-Chain Address 2: P-custom16045mxr3s2cjycqe2xfluk304xv3ezhkhsvkpr
|
||||
// P-Chain Address 2 Key: PrivateKey-2fzYBh3bbWemKxQmMfX6DSuL2BFmDSLQWTvma57xwjQjtf8gFq
|
||||
// C-Chain Address: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
|
||||
// C-Chain Address Key: 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027
|
||||
// The following treasury address is pre-funded:
|
||||
// C-Chain Address: 0x9011E888251AB053B7bD1cdB598Db4f9DEd94714
|
||||
// The following nodes are validators:
|
||||
// * NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg
|
||||
// * NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ
|
||||
|
||||
@@ -238,7 +238,7 @@ type BlockchainSpec struct {
|
||||
"allowFeeRecipients": false
|
||||
},
|
||||
"alloc": {
|
||||
"0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
|
||||
"0x9011E888251AB053B7bD1cdB598Db4f9DEd94714": {
|
||||
"balance": "0x52B7D2DCC80CD2E4000000"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -93,10 +93,10 @@ netrunner server \
|
||||
--port=":8080" \
|
||||
--grpc-gateway-port=":8081"
|
||||
|
||||
# In another terminal, start a 5-node network
|
||||
# In another terminal, start a 3-node network
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path /path/to/luxd
|
||||
|
||||
# Check network health
|
||||
@@ -184,7 +184,7 @@ Netrunner supports multiple blockchain engines:
|
||||
```bash
|
||||
curl -X POST -k http://localhost:8081/v1/control/start -d '{
|
||||
"execPath": "/path/to/luxd",
|
||||
"numNodes": 5,
|
||||
"numNodes": 3,
|
||||
"logLevel": "INFO"
|
||||
}'
|
||||
```
|
||||
|
||||
@@ -72,7 +72,7 @@ A simple chain of nodes where each node connects to the next:
|
||||
|
||||
```bash
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path /path/to/luxd \
|
||||
--topology linear
|
||||
```
|
||||
@@ -83,7 +83,7 @@ Every node connects to every other node:
|
||||
|
||||
```bash
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path /path/to/luxd \
|
||||
--topology mesh
|
||||
```
|
||||
@@ -94,7 +94,7 @@ All nodes connect to a central bootstrap node:
|
||||
|
||||
```bash
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path /path/to/luxd \
|
||||
--topology star
|
||||
```
|
||||
@@ -358,10 +358,10 @@ netrunner server \
|
||||
# Wait for server
|
||||
sleep 2
|
||||
|
||||
# Start a 5-node network
|
||||
# Start a 3-node network
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path /path/to/luxd \
|
||||
--global-node-config '{
|
||||
"network-peer-list-gossip-frequency": "250ms",
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestTransactionThroughput(t *testing.T) {
|
||||
|
||||
# Start network with fast block production
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_PATH} \
|
||||
--global-node-config '{
|
||||
"proposervm-use-current-height": true,
|
||||
|
||||
@@ -66,7 +66,7 @@ Keep this running in a separate terminal.
|
||||
|
||||
### 2. Start a Basic Network
|
||||
|
||||
Create a 5-node network:
|
||||
Create a 3-node network:
|
||||
|
||||
```bash
|
||||
# Set the path to your Lux binary
|
||||
@@ -76,7 +76,7 @@ LUXD_EXEC_PATH="${HOME}/go/src/github.com/luxfi/sdk/node/build/node"
|
||||
netrunner control start \
|
||||
--log-level debug \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH}
|
||||
```
|
||||
|
||||
@@ -114,12 +114,12 @@ netrunner control start \
|
||||
|
||||
### Multi-Node Network
|
||||
|
||||
Standard 5-node test network:
|
||||
Standard 3-node test network:
|
||||
|
||||
```bash
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--global-node-config '{
|
||||
"network-peer-list-gossip-frequency": "250ms",
|
||||
@@ -154,7 +154,7 @@ netrunner control start \
|
||||
# Start the network
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH}
|
||||
|
||||
# Wait for health
|
||||
@@ -239,7 +239,7 @@ cat > /tmp/subnet-evm.genesis.json <<EOF
|
||||
}
|
||||
},
|
||||
"alloc": {
|
||||
"0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
|
||||
"0x9011E888251AB053B7bD1cdB598Db4f9DEd94714": {
|
||||
"balance": "0x52B7D2DCC80CD2E4000000"
|
||||
}
|
||||
},
|
||||
@@ -253,7 +253,7 @@ EOF
|
||||
# Start network with subnet-evm
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--plugin-dir ${LUXD_PLUGIN_PATH} \
|
||||
--blockchain-specs '[{
|
||||
@@ -268,7 +268,7 @@ netrunner control start \
|
||||
# Start network with QuantumVM
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--plugin-dir ${LUXD_PLUGIN_PATH} \
|
||||
--blockchain-specs '[{
|
||||
@@ -314,7 +314,7 @@ netrunner control stop
|
||||
# Create network with validators
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--global-node-config '{
|
||||
"staking-enabled": true,
|
||||
@@ -360,7 +360,7 @@ EOF
|
||||
# Start network with multiple chains
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--plugin-dir ${LUXD_PLUGIN_PATH} \
|
||||
--blockchain-specs-file blockchains.json
|
||||
@@ -376,7 +376,7 @@ Test network resilience:
|
||||
# Start network
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH}
|
||||
|
||||
# Pause node (simulate failure)
|
||||
@@ -423,7 +423,7 @@ netrunner control stream-status \
|
||||
# Start and configure network
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH}
|
||||
|
||||
# Create networks (validator sets) and blockchains
|
||||
@@ -468,10 +468,10 @@ cleanup() {
|
||||
trap cleanup EXIT
|
||||
|
||||
# Test 1: Basic network
|
||||
echo "Test 1: Basic 5-node network"
|
||||
echo "Test 1: Basic 3-node network"
|
||||
netrunner control start \
|
||||
--endpoint=${ENDPOINT} \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_PATH}
|
||||
|
||||
netrunner control health --endpoint=${ENDPOINT}
|
||||
@@ -537,7 +537,7 @@ If you encounter port conflicts:
|
||||
# Use custom ports
|
||||
netrunner control start \
|
||||
--endpoint="0.0.0.0:8080" \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_EXEC_PATH} \
|
||||
--custom-node-configs '{
|
||||
"node1": {"http-port": 19630, "staking-port": 19631},
|
||||
|
||||
@@ -244,7 +244,7 @@ EOF
|
||||
|
||||
# Start network with custom VM
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_PATH} \
|
||||
--plugin-dir ${PLUGIN_PATH} \
|
||||
--blockchain-specs '[{
|
||||
@@ -410,7 +410,7 @@ simulate_failures() {
|
||||
|
||||
# Start network
|
||||
netrunner control start \
|
||||
--number-of-nodes=5 \
|
||||
--number-of-nodes=3 \
|
||||
--node-path ${LUXD_PATH}
|
||||
|
||||
# Start failure simulation in background
|
||||
|
||||
@@ -1360,9 +1360,6 @@ func newWallet(
|
||||
}
|
||||
kc := secp256k1fx.NewKeychain(privKey)
|
||||
|
||||
// Debug: print addresses being queried
|
||||
fmt.Printf("🔍 Wallet querying for addresses: %v\n", kc.Addrs)
|
||||
|
||||
// Use dedicated timeout context for FetchState to avoid parent context cancellation propagation
|
||||
fetchCtx, fetchCancel := createDefaultCtx(ctx)
|
||||
luxState, err := primary.FetchState(fetchCtx, uri, kc.Addrs)
|
||||
@@ -1371,15 +1368,6 @@ func newWallet(
|
||||
return nil, fmt.Errorf("failed to fetch state from %s: %w", uri, err)
|
||||
}
|
||||
|
||||
// Debug: print network context and UTXOs
|
||||
xChainIDForDebug := luxState.XCTX.BlockchainID
|
||||
fmt.Printf("🔍 Network ID: %d, X-chain ID: %s\n", luxState.XCTX.NetworkID, xChainIDForDebug)
|
||||
fmt.Printf("🔍 LUX Asset ID: %s\n", luxState.XCTX.XAssetID)
|
||||
xUtxos, _ := luxState.UTXOs.UTXOs(ctx, xChainIDForDebug, xChainIDForDebug)
|
||||
fmt.Printf("🔍 Fetched %d X-chain UTXOs\n", len(xUtxos))
|
||||
for i, utxo := range xUtxos {
|
||||
fmt.Printf(" UTXO[%d]: ID=%s, AssetID=%s\n", i, utxo.UTXOID.TxID, utxo.AssetID())
|
||||
}
|
||||
pClient := platformvm.NewClient(uri)
|
||||
pTXs := make(map[ids.ID]*txs.Tx)
|
||||
for _, id := range preloadTXs {
|
||||
@@ -1448,15 +1436,8 @@ func (ln *localNetwork) addPrimaryValidators(
|
||||
for _, v := range vdrs {
|
||||
curValidators.Add(v.NodeID)
|
||||
}
|
||||
// Debug: log current validators from genesis
|
||||
fmt.Printf("🔍 GetCurrentValidators returned %d validators:\n", len(vdrs))
|
||||
for _, v := range vdrs {
|
||||
fmt.Printf(" - %s (weight: %d)\n", v.NodeID.String(), v.Weight)
|
||||
}
|
||||
for nodeName, node := range ln.nodes {
|
||||
nodeID := node.GetNodeID()
|
||||
fmt.Printf("🔍 Checking node %s (ID: %s) - in curValidators: %v\n", nodeName, nodeID.String(), curValidators.Contains(nodeID))
|
||||
|
||||
if curValidators.Contains(nodeID) {
|
||||
continue
|
||||
}
|
||||
@@ -1586,42 +1567,19 @@ func fundPChainFromXChain(ctx context.Context, w *wallet, logger log.Logger) err
|
||||
// Amount needed for chain operations (1 LUX should be plenty for fees)
|
||||
const requiredAmount = uint64(1_000_000_000) // 1 LUX in nLUX
|
||||
|
||||
// Debug: print wallet address for verification against genesis
|
||||
fmt.Printf("🔍 DEBUG: Wallet address (short): %s\n", w.addr.String())
|
||||
fmt.Printf("🔍 DEBUG: Wallet P-chain address: P-lux1%s (bech32 would differ)\n", w.addr.String())
|
||||
fmt.Printf("🔍 DEBUG: LUX asset ID: %s\n", w.luxAssetID.String())
|
||||
|
||||
// First check if P-chain already has sufficient funds
|
||||
balances, err := w.pBuilder.GetBalance()
|
||||
if err != nil {
|
||||
log.Warn("failed to check P-chain balance, will try X->P transfer", "error", err.Error())
|
||||
fmt.Printf("⚠️ DEBUG: P-chain balance check failed: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("🔍 DEBUG: P-chain balances map has %d entries\n", len(balances))
|
||||
for assetID, bal := range balances {
|
||||
fmt.Printf(" - Asset %s: %d nLUX\n", assetID.String(), bal)
|
||||
}
|
||||
pBalance := balances[w.luxAssetID]
|
||||
log.Info("P-chain balance check", "balance", pBalance, "required", requiredAmount)
|
||||
fmt.Printf("💰 P-chain balance: %d nLUX (need %d)\n", pBalance, requiredAmount)
|
||||
if pBalance >= requiredAmount {
|
||||
log.Info(log.Green.Wrap("P-chain already has sufficient funds, skipping X->P transfer"))
|
||||
fmt.Printf("✅ P-chain already funded, no transfer needed\n")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Also check X-chain balance for debugging
|
||||
xBalances, xErr := w.xWallet.Builder().GetFTBalance()
|
||||
if xErr != nil {
|
||||
fmt.Printf("⚠️ DEBUG: X-chain balance check failed: %v\n", xErr)
|
||||
} else {
|
||||
fmt.Printf("🔍 DEBUG: X-chain balances:\n")
|
||||
for assetID, bal := range xBalances {
|
||||
fmt.Printf(" - Asset %s: %d nLUX\n", assetID.String(), bal)
|
||||
}
|
||||
}
|
||||
|
||||
// P-chain doesn't have enough, try to export from X-chain
|
||||
owner := &secp256k1fx.OutputOwners{
|
||||
Threshold: 1,
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
"sybil-protection-enabled": true,
|
||||
"network-health-min-conn-peers": 0,
|
||||
|
||||
"consensus-sample-size": 5,
|
||||
"consensus-preference-quorum-size": 4,
|
||||
"consensus-confidence-quorum-size": 4,
|
||||
"consensus-commit-threshold": 4,
|
||||
"consensus-sample-size": 3,
|
||||
"consensus-preference-quorum-size": 2,
|
||||
"consensus-confidence-quorum-size": 2,
|
||||
"consensus-commit-threshold": 2,
|
||||
"consensus-concurrent-repolls": 8,
|
||||
"consensus-optimal-processing": 50,
|
||||
"consensus-max-processing": 256,
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
"sybil-protection-enabled": true,
|
||||
"network-health-min-conn-peers": 0,
|
||||
"track-all-chains": true,
|
||||
"consensus-sample-size": 5,
|
||||
"consensus-preference-quorum-size": 4,
|
||||
"consensus-confidence-quorum-size": 4,
|
||||
"consensus-commit-threshold": 4
|
||||
"consensus-sample-size": 3,
|
||||
"consensus-preference-quorum-size": 2,
|
||||
"consensus-confidence-quorum-size": 2,
|
||||
"consensus-commit-threshold": 2
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"profile-name": "turbo-3of5",
|
||||
"notes": "Aggressive 5-node local perf profile. 3/5 quorum for faster polls. Not for public networks.",
|
||||
"profile-name": "turbo-2of3",
|
||||
"notes": "Aggressive 3-node local perf profile. 2/3 quorum for faster polls. Not for public networks.",
|
||||
|
||||
"log-display-level": "ERROR",
|
||||
"log-level": "ERROR",
|
||||
@@ -45,11 +45,11 @@
|
||||
"bootstrap-ancestors-max-containers-sent": 50000,
|
||||
"bootstrap-ancestors-max-containers-received": 50000,
|
||||
|
||||
"consensus-sample-size": 5,
|
||||
"consensus-preference-quorum-size": 3,
|
||||
"consensus-confidence-quorum-size": 3,
|
||||
"consensus-sample-size": 3,
|
||||
"consensus-preference-quorum-size": 2,
|
||||
"consensus-confidence-quorum-size": 2,
|
||||
|
||||
"consensus-commit-threshold": 4,
|
||||
"consensus-commit-threshold": 2,
|
||||
"consensus-concurrent-repolls": 64,
|
||||
|
||||
"consensus-optimal-processing": 4096,
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
"sybil-protection-enabled": true,
|
||||
"network-health-min-conn-peers": 0,
|
||||
|
||||
"consensus-sample-size": 5,
|
||||
"consensus-preference-quorum-size": 4,
|
||||
"consensus-confidence-quorum-size": 4,
|
||||
"consensus-commit-threshold": 4,
|
||||
"consensus-sample-size": 3,
|
||||
"consensus-preference-quorum-size": 2,
|
||||
"consensus-confidence-quorum-size": 2,
|
||||
"consensus-commit-threshold": 2,
|
||||
|
||||
"consensus-concurrent-repolls": 32,
|
||||
"consensus-optimal-processing": 2048,
|
||||
|
||||
+19
-10
@@ -32,6 +32,18 @@ import (
|
||||
luxtls "github.com/luxfi/tls"
|
||||
)
|
||||
|
||||
// getMnemonic returns the mnemonic from environment variables.
|
||||
// Priority: MNEMONIC > LUX_MNEMONIC > LIGHT_MNEMONIC
|
||||
func getMnemonic() string {
|
||||
if v := os.Getenv("MNEMONIC"); v != "" {
|
||||
return v
|
||||
}
|
||||
if v := getMnemonic(); v != "" {
|
||||
return v
|
||||
}
|
||||
return os.Getenv("LIGHT_MNEMONIC")
|
||||
}
|
||||
|
||||
// patchGenesisPreservingRaw patches a top-level genesis JSON document while guaranteeing that
|
||||
// selected keys are preserved byte-for-byte as raw JSON values (including quotes/escapes for strings).
|
||||
//
|
||||
@@ -202,7 +214,7 @@ func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (
|
||||
var newAllocations []map[string]interface{}
|
||||
|
||||
// If LUX_MNEMONIC is set, create allocations for mnemonic-derived key
|
||||
if mnemonic := os.Getenv("LUX_MNEMONIC"); mnemonic != "" {
|
||||
if mnemonic := getMnemonic(); mnemonic != "" {
|
||||
validatorKeys, err := keys.DeriveValidatorsFromMnemonic(mnemonic, 1)
|
||||
if err == nil && len(validatorKeys) > 0 {
|
||||
vk := validatorKeys[0]
|
||||
@@ -210,7 +222,7 @@ func NewConfigForNetwork(binaryPath string, numNodes uint32, networkID uint32) (
|
||||
xLuxAddr, errX := address.Format("X", hrp, addr[:])
|
||||
pLuxAddr, errP := address.Format("P", hrp, addr[:])
|
||||
if errX == nil && errP == nil {
|
||||
fmt.Printf("🔑 Setting X+P allocations for LUX_MNEMONIC: X=%s, P=%s (1B each)\n", xLuxAddr, pLuxAddr)
|
||||
fmt.Printf("🔑 Setting X+P allocations for mnemonic: X=%s, P=%s (1B each)\n", xLuxAddr, pLuxAddr)
|
||||
// X-chain allocation
|
||||
newAllocations = append(newAllocations, map[string]interface{}{
|
||||
"ethAddr": vk.CChainAddrHex(),
|
||||
@@ -760,8 +772,8 @@ func NewConfigWithPreExistingKeys(binaryPath string, networkID uint32, keysDir s
|
||||
}
|
||||
|
||||
// Add mnemonic allocation if set
|
||||
if mnemonic := os.Getenv("LUX_MNEMONIC"); mnemonic != "" {
|
||||
fmt.Printf("🔑 LUX_MNEMONIC is set, adding mnemonic allocation to genesis\n")
|
||||
if mnemonic := getMnemonic(); mnemonic != "" {
|
||||
fmt.Printf("🔑 Mnemonic set, adding mnemonic allocation to genesis\n")
|
||||
allocations = append(allocations, map[string]interface{}{
|
||||
"ethAddr": "0x0406d56943a38ad8398a738527f27e2cf01731a8",
|
||||
"luxAddr": "P-lux1qsrd262r5w9dswv2wwzj0un79ncpwvdgkpqzqu",
|
||||
@@ -889,10 +901,9 @@ func validatorKeysDir() string {
|
||||
// - TLS staking certs (for NodeID) - generated once, then persisted
|
||||
// - BLS keys (for consensus) - deterministic from mnemonic
|
||||
func NewConfigFromMnemonic(binaryPath string, networkID uint32, numNodes uint32) (network.Config, error) {
|
||||
fmt.Println(">>> ENTERED NewConfigFromMnemonic <<<")
|
||||
mnemonic := os.Getenv("LUX_MNEMONIC")
|
||||
mnemonic := getMnemonic()
|
||||
if mnemonic == "" {
|
||||
return network.Config{}, fmt.Errorf("LUX_MNEMONIC environment variable not set")
|
||||
return network.Config{}, fmt.Errorf("mnemonic not set (set LIGHT_MNEMONIC, LUX_MNEMONIC, or MNEMONIC)")
|
||||
}
|
||||
|
||||
// Check if persisted validator keys exist
|
||||
@@ -926,14 +937,13 @@ func NewConfigFromMnemonic(binaryPath string, networkID uint32, numNodes uint32)
|
||||
}
|
||||
|
||||
if allExist {
|
||||
fmt.Printf("🔴 DEBUG_MARKER: allExist=true\n")
|
||||
fmt.Printf("🔑 Loading %d validators from %s (stable NodeIDs)...\n", numNodes, keysDir)
|
||||
for i, vk := range validatorKeys {
|
||||
fmt.Printf(" node%d: %s\n", i, vk.NodeID.String())
|
||||
}
|
||||
} else {
|
||||
// No existing keys - derive from mnemonic and persist
|
||||
fmt.Printf("🔑 Deriving %d validators from LUX_MNEMONIC (first run)...\n", numNodes)
|
||||
fmt.Printf("🔑 Deriving %d validators from mnemonic (first run)...\n", numNodes)
|
||||
|
||||
validatorKeys, err = keys.DeriveValidatorsFromMnemonic(mnemonic, int(numNodes))
|
||||
if err != nil {
|
||||
@@ -951,7 +961,6 @@ func NewConfigFromMnemonic(binaryPath string, networkID uint32, numNodes uint32)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("🔍 DEBUG: About to derive wallet key from mnemonic...")
|
||||
// CRITICAL: Always derive the wallet key from mnemonic and ensure it has allocations.
|
||||
// The wallet (used by deploy, fundPChainFromXChain, etc.) uses keys.DeriveValidatorFromMnemonic(mnemonic, 0),
|
||||
// which may differ from validators loaded from ~/.lux/keys.
|
||||
|
||||
@@ -242,15 +242,12 @@ func getPort(
|
||||
switch gotPort := portIntf.(type) {
|
||||
case int:
|
||||
port = uint16(gotPort)
|
||||
fmt.Printf("🔍 getPort: %s found in flags as int=%d\n", portKey, port)
|
||||
case float64:
|
||||
port = uint16(gotPort)
|
||||
fmt.Printf("🔍 getPort: %s found in flags as float64=%d\n", portKey, port)
|
||||
default:
|
||||
return 0, fmt.Errorf("expected flag %q to be int/float64 but got %T", portKey, portIntf)
|
||||
}
|
||||
} else if portIntf, ok := configFile[portKey]; ok {
|
||||
fmt.Printf("🔍 getPort: %s NOT in flags, checking configFile\n", portKey)
|
||||
portFromConfigFile, ok := portIntf.(float64)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("expected flag %q to be float64 but got %T", portKey, portIntf)
|
||||
@@ -259,14 +256,12 @@ func getPort(
|
||||
} else {
|
||||
// Use a random free port.
|
||||
// Note: it is possible but unlikely for getFreePort to return the same port multiple times.
|
||||
fmt.Printf("🔍 getPort: %s NOT in flags or configFile, using random port\n", portKey)
|
||||
port, err = getFreePort()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("couldn't get free port: %w", err)
|
||||
}
|
||||
}
|
||||
if reassignIfUsed && isFreePort(port) != nil {
|
||||
fmt.Printf("🔍 getPort: %s port %d NOT free, reassigning to random\n", portKey, port)
|
||||
port, err = getFreePort()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("couldn't get free port: %w", err)
|
||||
|
||||
+1
-4
@@ -57,7 +57,7 @@ const (
|
||||
stopTimeout = 30 * time.Second
|
||||
// healthCheckFreq reduced from 3s to 100ms for ultra-fast health polling
|
||||
healthCheckFreq = 100 * time.Millisecond
|
||||
DefaultNumNodes = 5
|
||||
DefaultNumNodes = 3
|
||||
snapshotPrefix = "lux-snapshot-"
|
||||
networkRootDirPrefix = "network"
|
||||
defaultDBSubdir = "db"
|
||||
@@ -463,7 +463,6 @@ func NewDefaultConfigNNodes(binaryPath string, numNodes uint32) (network.Config,
|
||||
|
||||
// If LUX_MNEMONIC is set, add allocations for mnemonic-derived address
|
||||
mnemonic := os.Getenv("LUX_MNEMONIC")
|
||||
fmt.Printf("🔍 DEBUG: NewDefaultConfigNNodes called, LUX_MNEMONIC set=%v\n", mnemonic != "")
|
||||
if mnemonic != "" {
|
||||
vk, err := keys.DeriveValidatorFromMnemonic(mnemonic, 0)
|
||||
if err != nil {
|
||||
@@ -479,8 +478,6 @@ func NewDefaultConfigNNodes(binaryPath string, numNodes uint32) (network.Config,
|
||||
// Create X-chain and P-chain addresses
|
||||
// Network ID 1337 uses "local" HRP (per constants.NetworkIDToHRP)
|
||||
const hrp = "local"
|
||||
fmt.Printf("🔍 DEBUG: vk.PChainAddr (base58): %s\n", vk.PChainAddr.String())
|
||||
fmt.Printf("🔍 DEBUG: vk.PChainAddr (hex): %x\n", vk.PChainAddr[:])
|
||||
xLuxAddr, err := address.Format("X", hrp, vk.PChainAddr[:])
|
||||
if err != nil {
|
||||
return netConfig, fmt.Errorf("failed to format X-chain address: %w", err)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
badger "github.com/luxfi/zapdb/v4"
|
||||
"github.com/luxfi/ids"
|
||||
log "github.com/luxfi/log"
|
||||
"github.com/luxfi/netrunner/network"
|
||||
|
||||
@@ -77,11 +77,11 @@ var (
|
||||
"node6": `{"api-admin-enabled":false}`,
|
||||
"node7": `{"api-admin-enabled":false}`,
|
||||
}
|
||||
numNodes = uint32(5)
|
||||
numNodes = uint32(3)
|
||||
networkParticipants = []string{"node1", "node2", "node3"}
|
||||
newParticipantNode = "new_participant_node"
|
||||
networkParticipants2 = []string{"node1", "node2", newParticipantNode}
|
||||
existingNodes = []string{"node1", "node2", "node3", "node4", "node5"}
|
||||
existingNodes = []string{"node1", "node2", "node3"}
|
||||
disjointNewNetworkParticipants = [][]string{
|
||||
{"new_node1", "new_node2"},
|
||||
{"new_node3", "new_node4"},
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"0x323e83bb2ce09bb19088ad11d3012b39738212bc": {
|
||||
"balance": "0x52B7D2DCC80CD2E4000000"
|
||||
},
|
||||
"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
|
||||
"9011E888251AB053B7bD1cdB598Db4f9DEd94714": {
|
||||
"balance": "0x52B7D2DCC80CD2E4000000"
|
||||
},
|
||||
"Ab5801a7D398351b8bE11C439e05C5B3259aeC9B": {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ var genesis = []byte(
|
||||
"delegationFee": 1000000
|
||||
}
|
||||
],
|
||||
"cChainGenesis": "{\"config\":{\"chainId\":43112,\"homesteadBlock\":0,\"daoForkBlock\":0,\"daoForkSupport\":true,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"apricotPhase1BlockTimestamp\":0,\"apricotPhase2BlockTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC\":{\"balance\":\"0x295BE96E64066972000000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}",
|
||||
"cChainGenesis": "{\"config\":{\"chainId\":43112,\"homesteadBlock\":0,\"daoForkBlock\":0,\"daoForkSupport\":true,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"apricotPhase1BlockTimestamp\":0,\"apricotPhase2BlockTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"9011E888251AB053B7bD1cdB598Db4f9DEd94714\":{\"balance\":\"0x295BE96E64066972000000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}",
|
||||
"message": "{{ fun_quote }}"
|
||||
}`,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user