create local testnet mode for eth2_network (#1494)

This commit is contained in:
tersec 2020-08-12 14:16:59 +00:00 committed by GitHub
parent 711f1f88ee
commit af3355e0f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 9 deletions

View File

@ -214,9 +214,13 @@ const
ConcurrentConnections* = 4
## Maximum number of active concurrent connection requests.
SeenTableTimeTimeout* = 5.minutes
SeenTableTimeTimeout* =
when not defined(local_testnet): 5.minutes else: 10.seconds
## Seen period of time for timeout connections
SeenTableTimeDeadPeer* = 5.minutes
SeenTableTimeDeadPeer* =
when not defined(local_testnet): 5.minutes else: 10.seconds
## Period of time for dead peers.
SeenTableTimeIrrelevantNetwork* = 24.hours
## Period of time for `IrrelevantNetwork` error reason.
@ -890,8 +894,12 @@ proc init*(T: type Eth2Node, conf: BeaconNodeConf, enrForkId: ENRForkID,
result.switch = switch
result.wantedPeers = conf.maxPeers
result.peerPool = newPeerPool[Peer, PeerID](maxPeers = conf.maxPeers)
result.connectTimeout = 1.minutes
result.seenThreshold = 5.minutes
when not defined(local_testnet):
result.connectTimeout = 1.minutes
result.seenThreshold = 5.minutes
else:
result.connectTimeout = 10.seconds
result.seenThreshold = 10.seconds
result.seenTable = initTable[PeerID, SeenItem]()
result.connTable = initHashSet[PeerID]()
result.connQueue = newAsyncQueue[PeerAddr](ConcurrentConnections)

View File

@ -143,9 +143,9 @@ proc process_justification_and_finalization*(state: var BeaconState,
# testnet0 and testnet1 have 8 non-attesting validators each, by default
if missing_all_validators.len > 15:
fatal "Missing too many attesters from previous epoch in verifyFinalization mode",
missing_all_validators
doAssert false
info "Missing too many attesters from previous epoch in verifyFinalization mode",
missing_all_validators,
epoch = get_current_epoch(state)
# This epoch processing is the last time these previous attestations can
# matter -- in the next epoch, they'll be 2 epochs old, when BeaconState

View File

@ -160,7 +160,7 @@ else
fi
NETWORK_NIM_FLAGS=$(scripts/load-testnet-nim-flags.sh ${NETWORK})
$MAKE -j2 LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="-d:insecure -d:testnet_servers_image ${NETWORK_NIM_FLAGS}" beacon_node deposit_contract
$MAKE -j2 LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="-d:insecure -d:testnet_servers_image -d:local_testnet ${NETWORK_NIM_FLAGS}" beacon_node deposit_contract
PIDS=""
WEB3_ARG=""

View File

@ -49,7 +49,7 @@ mkdir -p "$SECRETS_DIR"
cd "$GIT_ROOT"
CUSTOM_NIMFLAGS="${NIMFLAGS} -d:useSysAsserts -d:chronicles_sinks:textlines,json[file] -d:const_preset=mainnet -d:insecure"
CUSTOM_NIMFLAGS="${NIMFLAGS} -d:useSysAsserts -d:chronicles_sinks:textlines,json[file] -d:const_preset=mainnet -d:insecure -d:local_testnet"
GANACHE_BLOCK_TIME=5
# Run with "SLOTS_PER_EPOCH=8 ./start.sh" to change these