-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multi client sim tests
- Loading branch information
1 parent
9559c74
commit 3f58406
Showing
9 changed files
with
187 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import path from "node:path"; | ||
import {SimulationEnvironment} from "../utils/simulation/SimulationEnvironment.js"; | ||
import {nodeAssertion} from "../utils/simulation/assertions/nodeAssertion.js"; | ||
import {CLIQUE_SEALING_PERIOD, SIM_TESTS_SECONDS_PER_SLOT} from "../utils/simulation/constants.js"; | ||
import {AssertionMatch, CLClient, ELClient} from "../utils/simulation/interfaces.js"; | ||
import {getEstimatedTTD, getEstimatedTimeInSecForRun, logFilesDir} from "../utils/simulation/utils/index.js"; | ||
import {connectAllNodes, waitForSlot} from "../utils/simulation/utils/network.js"; | ||
|
||
const genesisDelaySeconds = 20 * SIM_TESTS_SECONDS_PER_SLOT; | ||
const altairForkEpoch = 2; | ||
const bellatrixForkEpoch = 4; | ||
const capellaForkEpoch = 6; | ||
// Make sure bellatrix started before TTD reach | ||
const additionalSlotsForTTD = 2; | ||
const runTillEpoch = 8; | ||
const syncWaitEpoch = 2; | ||
|
||
const runTimeoutMs = | ||
getEstimatedTimeInSecForRun({ | ||
genesisDelaySeconds, | ||
secondsPerSlot: SIM_TESTS_SECONDS_PER_SLOT, | ||
runTill: runTillEpoch + syncWaitEpoch, | ||
// After adding Nethermind its took longer to complete | ||
graceExtraTimeFraction: 0.3, | ||
}) * 1000; | ||
|
||
const ttd = getEstimatedTTD({ | ||
genesisDelaySeconds, | ||
bellatrixForkEpoch, | ||
secondsPerSlot: SIM_TESTS_SECONDS_PER_SLOT, | ||
cliqueSealingPeriod: CLIQUE_SEALING_PERIOD, | ||
additionalSlots: additionalSlotsForTTD, | ||
}); | ||
|
||
const env = await SimulationEnvironment.initWithDefaults( | ||
{ | ||
id: "multi-clients", | ||
logsDir: path.join(logFilesDir, "multi-clients"), | ||
chainConfig: { | ||
ALTAIR_FORK_EPOCH: altairForkEpoch, | ||
BELLATRIX_FORK_EPOCH: bellatrixForkEpoch, | ||
CAPELLA_FORK_EPOCH: capellaForkEpoch, | ||
GENESIS_DELAY: genesisDelaySeconds, | ||
TERMINAL_TOTAL_DIFFICULTY: ttd, | ||
}, | ||
}, | ||
[ | ||
{ | ||
id: "node-1", | ||
el: ELClient.Geth, | ||
keysCount: 32, | ||
mining: true, | ||
cl: {beacon: CLClient.Lodestar, validator: CLClient.Lighthouse}, | ||
}, | ||
{ | ||
id: "node-2", | ||
el: ELClient.Geth, | ||
keysCount: 32, | ||
remote: true, | ||
cl: {beacon: CLClient.Lighthouse, validator: CLClient.Lodestar}, | ||
}, | ||
] | ||
); | ||
|
||
env.tracker.register({ | ||
...nodeAssertion, | ||
match: ({slot}) => { | ||
return slot === 1 ? AssertionMatch.Assert | AssertionMatch.Capture | AssertionMatch.Remove : AssertionMatch.None; | ||
}, | ||
}); | ||
|
||
await env.start({runTimeoutMs}); | ||
await connectAllNodes(env.nodes); | ||
|
||
await waitForSlot(env.clock.getLastSlotOfEpoch(capellaForkEpoch + 1), env.nodes, {env, silent: true}); | ||
|
||
await env.stop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.