@@ -11,15 +11,17 @@ import (
11
11
"time"
12
12
13
13
"github.com/ethereum/go-ethereum/core/rawdb"
14
+ "github.com/ethereum/go-ethereum/log"
15
+ "github.com/ethereum/go-ethereum/params"
14
16
15
17
"github.com/offchainlabs/nitro/arbnode"
16
18
"github.com/offchainlabs/nitro/arbutil"
17
19
"github.com/offchainlabs/nitro/util/testhelpers/github"
18
20
"github.com/offchainlabs/nitro/validator/client/redis"
19
21
)
20
22
21
- func generateBlocks (t * testing.T , ctx context.Context , builder * NodeBuilder , testClient2ndNode * TestClient , n int ) {
22
- for i := 0 ; i < n ; i ++ {
23
+ func generateBlocks (t * testing.T , ctx context.Context , builder * NodeBuilder , testClient2ndNode * TestClient , transactions int ) {
24
+ for i := 0 ; i < transactions ; i ++ {
23
25
tx := builder .L2Info .PrepareTx ("Owner" , "User2" , builder .L2Info .TransferGas , big .NewInt (1e12 ), nil )
24
26
err := builder .L2 .Client .SendTransaction (ctx , tx )
25
27
Require (t , err )
@@ -37,10 +39,11 @@ func TestFinalizedBlocksMovedToAncients(t *testing.T) {
37
39
defer cancel ()
38
40
39
41
builder := NewNodeBuilder (ctx ).DefaultConfig (t , true )
40
- // The procedure that periodically pushes finality data from consensus to execution
42
+ // The procedure that periodically pushes finality data, from consensus to execution,
41
43
// will not be able to get the finalized block number since UseFinalityData is false.
42
- // Therefore, with UseFinalityData set to false, ExecutionEngine will not be able to move data to ancients,
43
- // at least for blocks with numbers smaller than FullImmutabilityThreshold const defined in go-ethereum.
44
+ // Therefore, with UseFinalityData set to false, ExecutionEngine will not be able to move data to ancients by itself,
45
+ // at least while HEAD is smaller than the params.FullImmutabilityThreshold const defined in go-ethereum.
46
+ // In that way we can control in this test which blocks are moved to ancients by calling ExecEngine.SetFinalized.
44
47
builder .nodeConfig .ParentChainReader .UseFinalityData = false
45
48
46
49
cleanup := builder .Build (t )
@@ -53,6 +56,11 @@ func TestFinalizedBlocksMovedToAncients(t *testing.T) {
53
56
builder .L2Info .GenerateAccount ("User2" )
54
57
generateBlocks (t , ctx , builder , testClient2ndNode , 20 )
55
58
59
+ headOfTheChain := builder .L2 .ExecNode .Backend .BlockChain ().CurrentBlock ().Number .Uint64 ()
60
+ if headOfTheChain >= params .FullImmutabilityThreshold {
61
+ t .Fatalf ("Test should be adjusted to generate less blocks. Current head: %d" , headOfTheChain )
62
+ }
63
+
56
64
ancients , err := builder .L2 .ExecNode .ChainDB .Ancients ()
57
65
Require (t , err )
58
66
if ancients != 0 {
0 commit comments