Skip to content

Commit cbf4755

Browse files
magicxyyzKolbyMLjoshuacolvin0
authored
update geth pin to include pathdb rpc changes + enabling pathdb archival mode for tests + added tests (#3945)
* allow enabling archive mode for path scheme * simplify state scheme config options * warn when state-history not zero and archive mode enabled * remove TestInvalidArchiveConfig as we now allow pathdb archive * update geth pin to include pathdb rpc changes * Add a system_test for fix for "missing trie node error on pathdb nodes" * Add test for PathDB Archival Mode * update geth pin * update geth pin * fix warning + make hashdb tests not run pathdb * restrain more tests * Update triedb_race_test.go --------- Co-authored-by: Kolby Moroz Liebl <[email protected]> Co-authored-by: Joshua Colvin <[email protected]>
1 parent 7764292 commit cbf4755

File tree

6 files changed

+106
-9
lines changed

6 files changed

+106
-9
lines changed

execution/gethexec/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (c *CachingConfig) validateStateScheme() error {
131131
switch c.StateScheme {
132132
case rawdb.HashScheme:
133133
case rawdb.PathScheme:
134-
if c.StateHistory != 0 {
134+
if c.Archive && c.StateHistory != 0 {
135135
log.Warn("Path scheme archive mode enabled, but state-history is not zero - the persisted state history will be limited to recent blocks", "StateHistory", c.StateHistory)
136136
}
137137
default:
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package arbtest
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"math/big"
7+
"testing"
8+
9+
"github.com/stretchr/testify/require"
10+
11+
"github.com/ethereum/go-ethereum/core/rawdb"
12+
)
13+
14+
func TestAccessingPathSchemeState(t *testing.T) {
15+
ctx, cancel := context.WithCancel(context.Background())
16+
defer cancel()
17+
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
18+
19+
// This test is PathScheme specific, it shouldn't be run with HashScheme
20+
builder.RequireScheme(t, rawdb.PathScheme)
21+
22+
// Build a node with history past the 128 block diff threshold
23+
cancelNode := buildWithHistory(t, ctx, builder, 150)
24+
execNode, l2client := builder.L2.ExecNode, builder.L2.Client
25+
defer cancelNode()
26+
bc := execNode.Backend.ArbInterface().BlockChain()
27+
28+
header := bc.CurrentBlock()
29+
if header == nil {
30+
Fatal(t, "failed to get current block header")
31+
}
32+
33+
head := header.Number.Uint64()
34+
if head < 129 {
35+
t.Fatalf("chain height (%d) too low — need at least 129 blocks to check last 128", head)
36+
}
37+
start := head - 128
38+
39+
for height := head; height > start; height-- {
40+
_, err := l2client.BalanceAt(ctx, GetTestAddressForAccountName(t, "User2"), new(big.Int).SetUint64(height))
41+
Require(t, err, "Failed to get balance at height", height)
42+
}
43+
44+
// Now try to access state older than 128 blocks ago, which should be missing
45+
//
46+
// We don't want to see the error
47+
// `missing trie node X (path ) state Y is not available, not found`
48+
// because that indicates a failure to find data that should exist. Implying our state backend has a bug.
49+
heightWhereStateShouldBeMissing := head - 129
50+
_, err := l2client.BalanceAt(ctx, GetTestAddressForAccountName(t, "User2"), new(big.Int).SetUint64(heightWhereStateShouldBeMissing))
51+
require.Error(t, err, "expected BalanceAt to fail for missing historical state")
52+
require.Contains(t, err.Error(), "historical state", "unexpected error message: %v", err)
53+
require.Contains(t, err.Error(), "is not available", "unexpected error message: %v", err)
54+
}
55+
56+
func TestAccessingPathSchemeArchivalState(t *testing.T) {
57+
ctx, cancel := context.WithCancel(context.Background())
58+
defer cancel()
59+
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
60+
builder.execConfig.Caching.Archive = true
61+
builder.execConfig.Caching.StateHistory = 2
62+
63+
// This test is PathScheme specific, it shouldn't be run with HashScheme
64+
builder.RequireScheme(t, rawdb.PathScheme)
65+
66+
// Build a node with history past the 128 block diff threshold
67+
cancelNode := buildWithHistory(t, ctx, builder, 150)
68+
fmt.Println("bluebird 5-3", builder.execConfig.Caching.StateScheme)
69+
execNode, l2client := builder.L2.ExecNode, builder.L2.Client
70+
defer cancelNode()
71+
bc := execNode.Backend.ArbInterface().BlockChain()
72+
73+
header := bc.CurrentBlock()
74+
if header == nil {
75+
Fatal(t, "failed to get current block header")
76+
}
77+
78+
head := header.Number.Uint64()
79+
if head < 132 {
80+
t.Fatalf("chain height (%d) too low — need at least 129 blocks to check last 128", head)
81+
}
82+
start := head - 131
83+
84+
for height := head; height > start; height-- {
85+
_, err := l2client.BalanceAt(ctx, GetTestAddressForAccountName(t, "User2"), new(big.Int).SetUint64(height))
86+
Require(t, err, "Failed to get balance at height", height)
87+
}
88+
89+
// Now try to access state older than 131 blocks ago, which should be missing
90+
heightWhereStateShouldBeMissing := head - 132
91+
_, err := l2client.BalanceAt(ctx, GetTestAddressForAccountName(t, "User2"), new(big.Int).SetUint64(heightWhereStateShouldBeMissing))
92+
require.Error(t, err, "expected BalanceAt to fail for missing historical state")
93+
// `metadata is not found` is the error returned when archival data is pruned for some reason
94+
require.Contains(t, err.Error(), "metadata is not found", "unexpected error message: %v", err)
95+
}

system_tests/common_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,6 @@ func (b *NodeBuilder) CheckConfig(t *testing.T) {
569569
if b.execConfig == nil {
570570
b.execConfig = b.ExecConfigDefaultTest(t, true)
571571
}
572-
if b.execConfig.Caching.Archive {
573-
// archive currently requires hash
574-
b.RequireScheme(t, rawdb.HashScheme)
575-
}
576572
if b.L1Info == nil {
577573
b.L1Info = NewL1TestInfo(t)
578574
}

system_tests/recreatestate_rpc_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func TestRecreateStateForRPCNoDepthLimit(t *testing.T) {
9797
ctx, cancel := context.WithCancel(context.Background())
9898
defer cancel()
9999
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
100+
builder.RequireScheme(t, rawdb.HashScheme)
100101
builder.execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth
101102
builder.execConfig.Sequencer.MaxBlockSpeed = 0
102103
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110
@@ -134,6 +135,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) {
134135
// #nosec G115
135136
depthGasLimit := int64(256 * util.NormalizeL2GasForL1GasInitial(800_000, params.GWei))
136137
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
138+
builder.RequireScheme(t, rawdb.HashScheme)
137139
builder.execConfig.RPC.MaxRecreateStateDepth = depthGasLimit
138140
builder.execConfig.Sequencer.MaxBlockSpeed = 0
139141
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110
@@ -169,6 +171,7 @@ func TestRecreateStateForRPCDepthLimitExceeded(t *testing.T) {
169171
ctx, cancel := context.WithCancel(context.Background())
170172
defer cancel()
171173
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
174+
builder.RequireScheme(t, rawdb.HashScheme)
172175
builder.execConfig.RPC.MaxRecreateStateDepth = int64(200)
173176
builder.execConfig.Sequencer.MaxBlockSpeed = 0
174177
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110
@@ -204,7 +207,7 @@ func TestRecreateStateForRPCMissingBlockParent(t *testing.T) {
204207
ctx, cancel := context.WithCancel(context.Background())
205208
defer cancel()
206209
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
207-
210+
builder.RequireScheme(t, rawdb.HashScheme)
208211
builder.execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth
209212
builder.execConfig.Sequencer.MaxBlockSpeed = 0
210213
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110
@@ -250,7 +253,7 @@ func TestRecreateStateForRPCBeyondGenesis(t *testing.T) {
250253
ctx, cancel := context.WithCancel(context.Background())
251254
defer cancel()
252255
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
253-
256+
builder.RequireScheme(t, rawdb.HashScheme)
254257
builder.execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth
255258
builder.execConfig.Sequencer.MaxBlockSpeed = 0
256259
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110
@@ -287,7 +290,7 @@ func TestRecreateStateForRPCBlockNotFoundWhileRecreating(t *testing.T) {
287290
ctx, cancel := context.WithCancel(context.Background())
288291
defer cancel()
289292
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
290-
293+
builder.RequireScheme(t, rawdb.HashScheme)
291294
builder.execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth
292295
builder.execConfig.Sequencer.MaxBlockSpeed = 0
293296
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110

system_tests/staterecovery_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import (
1616
"github.com/offchainlabs/nitro/execution/gethexec"
1717
)
1818

19-
func TestRectreateMissingStates(t *testing.T) {
19+
func TestRecreateMissingStates(t *testing.T) {
2020
ctx, cancel := context.WithCancel(context.Background())
2121
defer cancel()
2222
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
23+
builder.RequireScheme(t, rawdb.HashScheme)
2324
builder.execConfig.Caching.Archive = true
2425
builder.execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 16
2526
builder.execConfig.Caching.SnapshotCache = 0 // disable snapshots

system_tests/triedb_race_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/ethereum/go-ethereum/arbitrum"
1010
"github.com/ethereum/go-ethereum/common"
11+
"github.com/ethereum/go-ethereum/core/rawdb"
1112
"github.com/ethereum/go-ethereum/log"
1213
"github.com/ethereum/go-ethereum/rpc"
1314

@@ -20,6 +21,7 @@ func TestTrieDBCommitRace(t *testing.T) {
2021
defer cancel()
2122

2223
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
24+
builder.RequireScheme(t, rawdb.HashScheme)
2325
builder.execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth
2426
builder.execConfig.Sequencer.MaxBlockSpeed = 0
2527
builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110

0 commit comments

Comments
 (0)