Skip to content

Commit ae7793c

Browse files
committed
TestFinalizedBlocksMovedToAncients adjustments
1 parent 6135cab commit ae7793c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

system_tests/ancients_finalized_test.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import (
1111
"time"
1212

1313
"github.com/ethereum/go-ethereum/core/rawdb"
14+
"github.com/ethereum/go-ethereum/log"
15+
"github.com/ethereum/go-ethereum/params"
1416

1517
"github.com/offchainlabs/nitro/arbnode"
1618
"github.com/offchainlabs/nitro/arbutil"
1719
"github.com/offchainlabs/nitro/util/testhelpers/github"
1820
"github.com/offchainlabs/nitro/validator/client/redis"
1921
)
2022

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++ {
2325
tx := builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil)
2426
err := builder.L2.Client.SendTransaction(ctx, tx)
2527
Require(t, err)
@@ -37,10 +39,11 @@ func TestFinalizedBlocksMovedToAncients(t *testing.T) {
3739
defer cancel()
3840

3941
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,
4143
// 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.
4447
builder.nodeConfig.ParentChainReader.UseFinalityData = false
4548

4649
cleanup := builder.Build(t)
@@ -53,6 +56,11 @@ func TestFinalizedBlocksMovedToAncients(t *testing.T) {
5356
builder.L2Info.GenerateAccount("User2")
5457
generateBlocks(t, ctx, builder, testClient2ndNode, 20)
5558

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+
5664
ancients, err := builder.L2.ExecNode.ChainDB.Ancients()
5765
Require(t, err)
5866
if ancients != 0 {

0 commit comments

Comments
 (0)