@@ -18,9 +18,10 @@ import
1818 ../ beacon_chain/ gossip_processing/ block_processor,
1919 ../ beacon_chain/ consensus_object_pools/ [
2020 attestation_pool, blockchain_dag, blob_quarantine, block_quarantine,
21- block_clearance, consensus_manager],
21+ block_clearance, consensus_manager,
22+ ],
2223 ../ beacon_chain/ el/ el_manager,
23- ./ testutil, ./ testdbutil, ./ testblockutil
24+ ./ [testblockutil, testdbutil, testutil]
2425
2526from chronos/ unittest2/ asynctests import asyncTest
2627from ../ beacon_chain/ spec/ eth2_apis/ dynamic_fee_recipients import
@@ -40,43 +41,57 @@ suite "Block processor" & preset():
4041 var res = defaultRuntimeConfig
4142 res.ALTAIR_FORK_EPOCH = GENESIS_EPOCH
4243 res.BELLATRIX_FORK_EPOCH = GENESIS_EPOCH
44+ res.CAPELLA_FORK_EPOCH = Epoch (1 )
45+ res.DENEB_FORK_EPOCH = Epoch (2 )
46+ res.ELECTRA_FORK_EPOCH = Epoch (3 )
47+ res.FULU_FORK_EPOCH = Epoch (4 )
4348 res
4449 db = cfg.makeTestDB (SLOTS_PER_EPOCH )
4550 validatorMonitor = newClone (ValidatorMonitor .init (cfg.timeParams))
4651 dag = init (ChainDAGRef , cfg, db, validatorMonitor, {})
47- var
4852 taskpool = Taskpool .new ()
4953 quarantine = newClone (Quarantine .init (cfg))
5054 blobQuarantine = newClone (BlobQuarantine ())
5155 dataColumnQuarantine = newClone (ColumnQuarantine ())
5256 attestationPool = newClone (AttestationPool .init (dag, quarantine))
5357 elManager = new ELManager # TODO : initialise this properly
54- actionTracker: ActionTracker
58+ actionTracker = default ( ActionTracker )
5559 consensusManager = ConsensusManager .new (
56- dag, attestationPool, quarantine, elManager, actionTracker,
57- newClone (DynamicFeeRecipientsStore .init ()), " " ,
58- Opt .some default (Eth1Address ), defaultGasLimit)
60+ dag,
61+ attestationPool,
62+ quarantine,
63+ elManager,
64+ actionTracker,
65+ newClone (DynamicFeeRecipientsStore .init ()),
66+ " " ,
67+ Opt .some default (Eth1Address ),
68+ defaultGasLimit,
69+ )
5970 state = newClone (dag.headState)
60- cache: StateCache
61- info: ForkedEpochInfo
62- cfg.process_slots (
63- state[], cfg.lastPremergeSlotInTestCfg, cache, info, {}).expect (" OK" )
64- var
65- b1 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
66- b2 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
6771 getTimeFn = proc (): BeaconTime =
68- b2.message. slot.start_beacon_time (cfg.timeParams)
72+ getStateField (state[], slot) .start_beacon_time (cfg.timeParams)
6973 batchVerifier = BatchVerifier .new (rng, taskpool)
70- processor = BlockProcessor .new (
71- false , " " , " " , batchVerifier, consensusManager,
72- validatorMonitor, blobQuarantine, dataColumnQuarantine, getTimeFn)
74+ var
75+ cache: StateCache
76+ info: ForkedEpochInfo
77+
78+ cfg.process_slots (state[], cfg.lastPremergeSlotInTestCfg, cache, info, {}).expect (
79+ " OK"
80+ )
7381
7482 asyncTest " Reverse order block add & get" & preset ():
75- let missing = await processor.addBlock (MsgSource .gossip, b2, noSidecars)
83+ let
84+ processor = BlockProcessor .new (
85+ false , " " , " " , batchVerifier, consensusManager, validatorMonitor,
86+ blobQuarantine, dataColumnQuarantine, getTimeFn,
87+ )
88+ b1 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
89+ b2 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
7690
77- check: missing.error == VerifierError . MissingParent
91+ missing = await processor. addBlock ( MsgSource .gossip, b2, noSidecars)
7892
7993 check:
94+ missing.error == VerifierError .MissingParent
8095 not dag.containsForkBlock (b2.root) # Unresolved, shouldn't show up
8196
8297 FetchRecord (root: b1.root) in quarantine[].checkMissing (32 )
@@ -94,8 +109,7 @@ suite "Block processor" & preset():
94109 while processor[].hasBlocks ():
95110 poll ()
96111
97- let
98- b2Get = dag.getBlockRef (b2.root)
112+ let b2Get = dag.getBlockRef (b2.root)
99113
100114 check:
101115 b2Get.isSome ()
@@ -126,6 +140,8 @@ suite "Block processor" & preset():
126140
127141 asyncTest " Invalidate block root" & preset ():
128142 let
143+ b1 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
144+ b2 = addTestBlock (state[], cache, cfg = cfg).bellatrixData
129145 processor = BlockProcessor .new (
130146 false , " " , " " , batchVerifier, consensusManager,
131147 validatorMonitor, blobQuarantine, dataColumnQuarantine,
@@ -156,3 +172,30 @@ suite "Block processor" & preset():
156172 res == Result [void , VerifierError ].err VerifierError .Invalid
157173 dag.containsForkBlock (b1.root)
158174 not dag.containsForkBlock (b2.root)
175+
176+ asyncTest " Process a block from each fork (without blobs)" & preset ():
177+ let processor = BlockProcessor .new (
178+ false , " " , " " , batchVerifier, consensusManager, validatorMonitor, blobQuarantine,
179+ dataColumnQuarantine, getTimeFn,
180+ )
181+
182+ debugGloasComment " TODO testing"
183+ for consensusFork in ConsensusFork .Bellatrix .. ConsensusFork .Fulu :
184+ process_slots (
185+ cfg,
186+ state[],
187+ max (
188+ getStateField (state[], slot) + 1 ,
189+ cfg.consensusForkEpoch (consensusFork).start_slot,
190+ ),
191+ cache,
192+ info,
193+ {},
194+ )
195+ .expect (" OK" )
196+
197+ withState (state[]):
198+ let b0 = addTestEngineBlock (cfg, consensusFork, forkyState, cache)
199+ discard await processor.addBlock (
200+ MsgSource .gossip, b0.blck, b0.blobsBundle.toSidecarsOpt (consensusFork)
201+ )
0 commit comments