From 6acb87ad531f37163fc22beaf98904b865f92baa Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 16 Jul 2024 19:00:32 +0530 Subject: [PATCH 001/210] Merge v1.13.14 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 7c6e05f753..227dc3fa1e 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 7c6e05f75337d59562a6e2b8e1bdf1e445ad14fb +Subproject commit 227dc3fa1e31889a0ac2126dc407a46ec5f8e409 From 826b230f19567cfdd96254786187d17e4678bea5 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 16 Jul 2024 19:42:10 +0530 Subject: [PATCH 002/210] Merge v1.13.15 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 227dc3fa1e..41caa90e92 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 227dc3fa1e31889a0ac2126dc407a46ec5f8e409 +Subproject commit 41caa90e923312bf7b39f8de4b8e9534724cd4cd From b042b2a078c25fbcf4193aab5ac34fb85dca9357 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 18 Jul 2024 17:25:07 +0530 Subject: [PATCH 003/210] Merge v1.14.0 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 41caa90e92..30a31796f4 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 41caa90e923312bf7b39f8de4b8e9534724cd4cd +Subproject commit 30a31796f41fb14fb52b123b0896f14f35208ee6 From 5dc1096b2993175bf73bb2dbd0b69bc976baf8e3 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 18 Jul 2024 17:29:04 +0530 Subject: [PATCH 004/210] fix ci --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 30a31796f4..112bf69280 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 30a31796f41fb14fb52b123b0896f14f35208ee6 +Subproject commit 112bf69280b5a6954eb1ae80447a86cc71ab519a From cedf55bfe82ff15acb5cf98f177f6c8bcdd91b3a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 18 Jul 2024 19:07:09 +0530 Subject: [PATCH 005/210] Fix --- arbos/arbosState/initialize.go | 7 +- arbos/engine.go | 11 +- arbos/l1pricing_test.go | 3 +- arbos/programs/api.go | 8 +- arbos/tx_processor.go | 4 +- arbos/util/tracing.go | 19 +- arbos/util/transfer.go | 9 +- blsSignatures/blsSignatures.go | 22 +-- cmd/genericconf/config.go | 2 +- cmd/genericconf/loglevel.go | 2 +- execution/nodeInterface/NodeInterface.go | 8 +- go-ethereum | 2 +- go.mod | 35 ++-- go.sum | 228 ++++------------------- precompiles/ArbOwner_test.go | 3 +- system_tests/common_test.go | 13 +- system_tests/das_test.go | 2 +- util/blobs/blobs.go | 4 +- util/headerreader/blob_client.go | 2 +- util/testhelpers/testhelpers.go | 2 +- 20 files changed, 120 insertions(+), 266 deletions(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 486c6ae33a..796f959c73 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -5,6 +5,7 @@ package arbosState import ( "errors" + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "sort" @@ -143,7 +144,7 @@ func InitializeArbosInDatabase(db ethdb.Database, initData statetransfer.InitDat if err != nil { return common.Hash{}, err } - statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance)) + statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance), tracing.BalanceChangeUnspecified) statedb.SetNonce(account.Addr, account.Nonce) if account.ContractInfo != nil { statedb.SetCode(account.Addr, account.ContractInfo.Code) @@ -174,7 +175,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, return err } if r.Timeout <= currentTimestamp { - statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue)) + statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified) continue } retryablesList = append(retryablesList, r) @@ -193,7 +194,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, addr := r.To to = &addr } - statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue)) + statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified) _, err := rs.CreateRetryable(r.Id, r.Timeout, r.From, to, r.Callvalue, r.Beneficiary, r.Calldata) if err != nil { return err diff --git a/arbos/engine.go b/arbos/engine.go index 0014e8ab96..a4aa9c46a9 100644 --- a/arbos/engine.go +++ b/arbos/engine.go @@ -48,16 +48,15 @@ func (e Engine) Prepare(chain consensus.ChainHeaderReader, header *types.Header) return nil } -func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { - FinalizeBlock(header, txs, state, chain.Config()) +func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) { + FinalizeBlock(header, body.Transactions, state, chain.Config()) } -func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, - uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { +func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) { - e.Finalize(chain, header, state, txs, uncles, withdrawals) + e.Finalize(chain, header, state, body) - block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(header, body.Transactions, nil, receipts, trie.NewStackTrie(nil)) return block, nil } diff --git a/arbos/l1pricing_test.go b/arbos/l1pricing_test.go index 6e2b1b7eec..c8851bee8c 100644 --- a/arbos/l1pricing_test.go +++ b/arbos/l1pricing_test.go @@ -4,6 +4,7 @@ package arbos import ( + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "testing" @@ -172,7 +173,7 @@ func _testL1PricingFundsDue(t *testing.T, testParams *l1PricingTest, expectedRes // create some fake collection balanceAdded := big.NewInt(int64(testParams.fundsCollectedPerSecond * 3)) unitsAdded := testParams.unitsPerSecond * 3 - evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded)) + evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded), tracing.BalanceChangeUnspecified) err = l1p.SetL1FeesAvailable(balanceAdded) Require(t, err) err = l1p.SetUnitsSinceUpdate(unitsAdded) diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 65a58a47c2..d44d14098c 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -139,7 +139,7 @@ func newApiClosures( // Tracing: emit the call (value transfer is done later in evm.Call) if tracingInfo != nil { - tracingInfo.Tracer.CaptureState(0, opcode, startGas, baseCost+gas, scope, []byte{}, depth, nil) + tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) } // EVM rule: calls that pay get a stipend (opCall) @@ -204,7 +204,7 @@ func newApiClosures( // Tracing: emit the create if tracingInfo != nil { - tracingInfo.Tracer.CaptureState(0, opcode, startGas, baseCost+gas, scope, []byte{}, depth, nil) + tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) } var res []byte @@ -270,8 +270,8 @@ func newApiClosures( captureHostio := func(name string, args, outs []byte, startInk, endInk uint64) { tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) if name == "evm_gas_left" || name == "evm_ink_left" { - tracingInfo.Tracer.CaptureState(0, vm.GAS, 0, 0, scope, []byte{}, depth, nil) - tracingInfo.Tracer.CaptureState(0, vm.POP, 0, 0, scope, []byte{}, depth, nil) + tracingInfo.Tracer.OnOpcode(0, byte(vm.GAS), 0, 0, scope, []byte{}, depth, nil) + tracingInfo.Tracer.OnOpcode(0, byte(vm.POP), 0, 0, scope, []byte{}, depth, nil) } } diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index b08c7c5d30..a7abbed6d5 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -153,13 +153,13 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r } evm.IncrementDepth() // fake a call from := p.msg.From - tracer.CaptureStart(evm, from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value) + tracer.OnEnter(evm.Depth(), byte(vm.CALL), from, *p.msg.To, p.msg.Data, p.msg.GasLimit, p.msg.Value) tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingDuringEVM) p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false) return func() { - tracer.CaptureEnd(nil, p.state.Burner.Burned(), nil) + tracer.OnExit(evm.Depth(), nil, p.state.Burner.Burned(), nil, false) evm.DecrementDepth() // fake the return to the first faked call tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingAfterEVM) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index f0f101bc20..e4cf2aa08c 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -5,6 +5,7 @@ package util import ( "fmt" + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "github.com/ethereum/go-ethereum/common" @@ -21,7 +22,7 @@ const ( ) type TracingInfo struct { - Tracer vm.EVMLogger + Tracer *tracing.Hooks Scenario TracingScenario Contract *vm.Contract Depth int @@ -65,7 +66,7 @@ func (info *TracingInfo) RecordEmitLog(topics []common.Hash, data []byte) { Contract: info.Contract, } logType := fmt.Sprintf("LOG%d", len(topics)) - info.Tracer.CaptureState(0, vm.StringToOp(logType), 0, 0, scope, []byte{}, info.Depth, nil) + info.Tracer.OnOpcode(0, byte(vm.StringToOp(logType)), 0, 0, scope, []byte{}, info.Depth, nil) } func (info *TracingInfo) RecordStorageGet(key common.Hash) { @@ -76,7 +77,7 @@ func (info *TracingInfo) RecordStorageGet(key common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key)), Contract: info.Contract, } - tracer.CaptureState(0, vm.SLOAD, 0, 0, scope, []byte{}, info.Depth, nil) + tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil) } else { tracer.CaptureArbitrumStorageGet(key, info.Depth, info.Scenario == TracingBeforeEVM) } @@ -90,7 +91,7 @@ func (info *TracingInfo) RecordStorageSet(key, value common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key), HashToUint256(value)), Contract: info.Contract, } - tracer.CaptureState(0, vm.SSTORE, 0, 0, scope, []byte{}, info.Depth, nil) + tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil) } else { tracer.CaptureArbitrumStorageSet(key, value, info.Depth, info.Scenario == TracingBeforeEVM) } @@ -115,8 +116,8 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.CALL, 0, 0, scope, []byte{}, depth, nil) - tracer.CaptureEnter(vm.INVALID, from, to, input, 0, amount) + tracer.OnOpcode(0, byte(vm.CALL), 0, 0, scope, []byte{}, depth, nil) + tracer.OnEnter(depth, byte(vm.INVALID), from, to, input, 0, amount) retScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -126,8 +127,8 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.RETURN, 0, 0, retScope, []byte{}, depth+1, nil) - tracer.CaptureExit(nil, 0, nil) + tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil) + tracer.OnExit(depth+1, nil, 0, nil, false) popScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -136,7 +137,7 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.POP, 0, 0, popScope, []byte{}, depth, nil) + tracer.OnOpcode(0, byte(vm.POP), 0, 0, popScope, []byte{}, depth, nil) } func HashToUint256(hash common.Hash) uint256.Int { diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index e293ef13c3..1240928eb6 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -7,6 +7,7 @@ package util import ( "errors" "fmt" + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "github.com/ethereum/go-ethereum/common" @@ -33,14 +34,14 @@ func TransferBalance( if arbmath.BigLessThan(balance.ToBig(), amount) { return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) } - evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount)) + evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) if evm.Context.ArbOSVersion >= 30 { // ensure the from account is "touched" for EIP-161 - evm.StateDB.AddBalance(*from, &uint256.Int{}) + evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer) } } if to != nil { - evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount)) + evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) } if tracer := evm.Config.Tracer; tracer != nil { if evm.Depth() != 0 && scenario != TracingDuringEVM { @@ -50,7 +51,7 @@ func TransferBalance( } if scenario != TracingDuringEVM { - tracer.CaptureArbitrumTransfer(evm, from, to, amount, scenario == TracingBeforeEVM, purpose) + tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) return nil } diff --git a/blsSignatures/blsSignatures.go b/blsSignatures/blsSignatures.go index b597d6a07e..cfcbc34d80 100644 --- a/blsSignatures/blsSignatures.go +++ b/blsSignatures/blsSignatures.go @@ -7,10 +7,8 @@ import ( cryptorand "crypto/rand" "encoding/base64" "errors" - "math/big" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/crypto/bls12381" + bls12381 "github.com/kilic/bls12-381" ) type PublicKey struct { @@ -18,13 +16,13 @@ type PublicKey struct { validityProof *bls12381.PointG1 // if this is nil, key came from a trusted source } -type PrivateKey *big.Int +type PrivateKey *bls12381.Fr type Signature *bls12381.PointG1 func GeneratePrivKeyString() (string, error) { - g2 := bls12381.NewG2() - privKey, err := cryptorand.Int(cryptorand.Reader, g2.Q()) + fr := bls12381.NewFr() + privKey, err := fr.Rand(cryptorand.Reader) if err != nil { return "", err } @@ -35,8 +33,8 @@ func GeneratePrivKeyString() (string, error) { } func GenerateKeys() (PublicKey, PrivateKey, error) { - g2 := bls12381.NewG2() - privateKey, err := cryptorand.Int(cryptorand.Reader, g2.Q()) + fr := bls12381.NewFr() + privateKey, err := fr.Rand(cryptorand.Reader) if err != nil { return PublicKey{}, nil, err } @@ -120,7 +118,7 @@ func verifySignature2(sig Signature, message []byte, publicKey PublicKey, keyVal return false, err } - engine := bls12381.NewPairingEngine() + engine := bls12381.NewEngine() engine.Reset() engine.AddPair(pointOnCurve, publicKey.key) leftSide := engine.Result() @@ -156,7 +154,7 @@ func VerifyAggregatedSignatureDifferentMessages(sig Signature, messages [][]byte if len(messages) != len(pubKeys) { return false, errors.New("len(messages) does not match (len(pub keys) in verification") } - engine := bls12381.NewPairingEngine() + engine := bls12381.NewEngine() engine.Reset() for i, msg := range messages { pointOnCurve, err := hashToG1Curve(msg, false) @@ -242,11 +240,11 @@ func PublicKeyFromBytes(in []byte, trustedSource bool) (PublicKey, error) { } func PrivateKeyToBytes(priv PrivateKey) []byte { - return ((*big.Int)(priv)).Bytes() + return bls12381.NewFr().Set(priv).ToBytes() } func PrivateKeyFromBytes(in []byte) (PrivateKey, error) { - return new(big.Int).SetBytes(in), nil + return bls12381.NewFr().FromBytes(in), nil } func SignatureToBytes(sig Signature) []byte { diff --git a/cmd/genericconf/config.go b/cmd/genericconf/config.go index 06e1fcd12d..7c0c5034b3 100644 --- a/cmd/genericconf/config.go +++ b/cmd/genericconf/config.go @@ -6,12 +6,12 @@ package genericconf import ( "errors" "io" + "log/slog" "time" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" flag "github.com/spf13/pflag" - "golang.org/x/exp/slog" ) type ConfConfig struct { diff --git a/cmd/genericconf/loglevel.go b/cmd/genericconf/loglevel.go index f7ad05a2cc..79cba22439 100644 --- a/cmd/genericconf/loglevel.go +++ b/cmd/genericconf/loglevel.go @@ -5,11 +5,11 @@ package genericconf import ( "errors" + "log/slog" "strconv" "strings" "github.com/ethereum/go-ethereum/log" - "golang.org/x/exp/slog" ) func ToSlogLevel(str string) (slog.Level, error) { diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 9179a52718..6fe1b2ef99 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -516,10 +516,10 @@ func (n NodeInterface) GasEstimateL1Component( args.Gas = (*hexutil.Uint64)(&randomGas) // We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate - msg, err := args.ToMessage(randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) - if err != nil { + if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, nil, nil, err } + msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) pricing := c.State.L1PricingState() l1BaseFeeEstimate, err := pricing.PricePerUnit() @@ -572,10 +572,10 @@ func (n NodeInterface) GasEstimateComponents( // Setting the gas currently doesn't affect the PosterDataCost, // but we do it anyways for accuracy with potential future changes. args.Gas = &totalRaw - msg, err := args.ToMessage(gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) - if err != nil { + if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, 0, nil, nil, err } + msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) brotliCompressionLevel, err := c.State.BrotliCompressionLevel() if err != nil { return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err) diff --git a/go-ethereum b/go-ethereum index 112bf69280..3ec24bb403 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 112bf69280b5a6954eb1ae80447a86cc71ab519a +Subproject commit 3ec24bb40398be604e7d122a83039bba1a2fc41b diff --git a/go.mod b/go.mod index d0c8d5e719..78acfc8162 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.10 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.9 github.com/cavaliergopher/grab/v3 v3.0.1 - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 + github.com/cockroachdb/pebble v1.1.0 github.com/codeclysm/extract/v3 v3.0.2 github.com/dgraph-io/badger/v4 v4.2.0 github.com/enescakir/emoji v1.0.0 @@ -32,6 +32,7 @@ require ( github.com/google/uuid v1.3.0 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/holiman/uint256 v1.2.4 + github.com/kilic/bls12-381 v0.1.0 github.com/knadh/koanf v1.4.0 github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f github.com/mitchellh/mapstructure v1.4.1 @@ -42,11 +43,11 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/wasmerio/wasmer-go v1.0.4 github.com/wealdtech/go-merkletree v1.0.0 - golang.org/x/crypto v0.21.0 + golang.org/x/crypto v0.22.0 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - golang.org/x/sys v0.18.0 - golang.org/x/term v0.18.0 - golang.org/x/tools v0.16.0 + golang.org/x/sys v0.19.0 + golang.org/x/term v0.19.0 + golang.org/x/tools v0.20.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) @@ -76,15 +77,15 @@ require ( github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/errors v1.9.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect - github.com/cockroachdb/redact v1.1.3 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect - github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -93,14 +94,14 @@ require ( github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/fjl/memsize v0.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gammazero/deque v0.2.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect github.com/gdamore/encoding v1.0.0 // indirect - github.com/getsentry/sentry-go v0.12.0 // indirect + github.com/getsentry/sentry-go v0.18.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/gobwas/pool v0.2.1 // indirect @@ -109,7 +110,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/flatbuffers v1.12.1 // indirect github.com/google/go-github/v62 v62.0.0 @@ -160,11 +161,11 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yuin/gopher-lua v1.1.1 // indirect go.opencensus.io v0.22.5 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.5.0 + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.7.0 golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.3.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + golang.org/x/time v0.5.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index ff4726b22f..44125e1bd1 100644 --- a/go.sum +++ b/go.sum @@ -31,26 +31,20 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -66,7 +60,6 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/arduino/go-paths-helper v1.2.0 h1:qDW93PR5IZUN/jzO4rCtexiwF8P4OIcOmcSgAYLZfY4= github.com/arduino/go-paths-helper v1.2.0/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= @@ -128,7 +121,6 @@ github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAm github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/aws/smithy-go v1.15.0 h1:PS/durmlzvAFpQHDs4wi4sNNP9ExsqZh6IlfdHXgKK8= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -157,37 +149,30 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f h1:6jduT9Hfc0njg5jJ1DdKCFPdMBrp/mdZfCpa5h+WM74= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codeclysm/extract/v3 v3.0.2 h1:sB4LcE3Php7LkhZwN0n2p8GCwZe92PEQutdbGURf5xc= github.com/codeclysm/extract/v3 v3.0.2/go.mod h1:NKsw+hqua9H+Rlwy/w/3Qgt9jDonYEgB6wJu+25eOKw= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= -github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -198,7 +183,6 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= @@ -217,18 +201,14 @@ github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/enescakir/emoji v1.0.0 h1:W+HsNql8swfCQFtioDGDHCHri8nudlK1n5p2rHCJoog= github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkKp+WKFD0= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= -github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= @@ -241,7 +221,6 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= @@ -250,13 +229,10 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.7.1 h1:TiCcmpWHiAU7F0rA2I3S2Y4mmLmO9KHxJ7E1QhYzQbc= github.com/gdamore/tcell/v2 v2.7.1/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg= -github.com/getsentry/sentry-go v0.12.0 h1:era7g0re5iY13bHSdN/xMkyV+5zZppjRVQhZrXCaEIk= -github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= +github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -269,7 +245,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= @@ -279,27 +254,19 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyL github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gobwas/ws v1.2.1 h1:F2aeBZrm2NDsc7vbovKrWSogd4wvfAxg0FQ89/iqOTk= github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= github.com/gobwas/ws-examples v0.0.0-20190625122829-a9e8908d9484 h1:XC9N1eiAyO1zg62dpOU8bex8emB/zluUtKcbLNjJxGI= github.com/gobwas/ws-examples v0.0.0-20190625122829-a9e8908d9484/go.mod h1:5nDZF4afNA1S7ZKcBXCMvDo4nuCTp1931DND7/W4aXo= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -332,13 +299,12 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= @@ -360,7 +326,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v62 v62.0.0 h1:/6mGCaRywZz9MuHyw9gD1CwsbmBX8GWsbFkwMmHdhl4= github.com/google/go-github/v62 v62.0.0/go.mod h1:EMxeUqGJq2xRu9DYBMwel/mr7kZrzUOfQmmpYrZn2a4= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -380,13 +345,10 @@ github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b h1:RMpPgZTSApbPf7xaVe github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY41SORZyNJ0= @@ -409,7 +371,6 @@ github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjG github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= @@ -429,16 +390,8 @@ github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXei github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= -github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -449,13 +402,11 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/clock v0.0.0-20180524022203-d293bb356ca4/go.mod h1:nD0vlnrUjcjJhqN5WuCWZyzfd5AHZAC9/ajvbSx69xA= github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= @@ -470,19 +421,12 @@ github.com/juju/utils v0.0.0-20180808125547-9dfc6dbfb02b/go.mod h1:6/KLg8Wz/y2KV github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= -github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= -github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= -github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= -github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= +github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= +github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -499,39 +443,25 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f h1:4+gHs0jJFJ06bfN8PshnM6cHcxGjRUVRLo5jndDiKRQ= github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f/go.mod h1:tHCZHV8b2A90ObojrEAzY0Lb03gxUxjDHr5IJyAh4ew= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -556,13 +486,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -572,7 +497,6 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= @@ -584,7 +508,6 @@ github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5h github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -636,34 +559,21 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -671,7 +581,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -686,18 +595,8 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -706,21 +605,12 @@ github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmx github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk= github.com/wealdtech/go-merkletree v1.0.0 h1:DsF1xMzj5rK3pSQM6mPv8jlyJyHXhFxpnA2bwEjMMBY= github.com/wealdtech/go-merkletree v1.0.0/go.mod h1:cdil512d/8ZC7Kx3bfrDvGMQXB25NTKbsm0rFrmDax4= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= @@ -733,18 +623,14 @@ go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -769,7 +655,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -778,21 +663,18 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -801,7 +683,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -820,15 +701,13 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -849,18 +728,16 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -869,9 +746,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -881,7 +756,6 @@ golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -899,21 +773,15 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -926,21 +794,20 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= @@ -950,18 +817,14 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -998,11 +861,10 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1029,7 +891,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1060,8 +921,6 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1076,7 +935,6 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1089,8 +947,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1102,12 +960,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4 h1:hILp2hNrRnYjZpmIbx70psAHbBSEcQ1NIzDcUbJ1b6g= gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= @@ -1122,9 +976,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index 1f8c7ae4cd..456c26fa3d 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -6,6 +6,7 @@ package precompiles import ( "bytes" "encoding/json" + "github.com/ethereum/go-ethereum/core/tracing" "math/big" "testing" @@ -114,7 +115,7 @@ func TestArbOwner(t *testing.T) { Fail(t, avail) } deposited := big.NewInt(1000000) - evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(deposited)) + evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(deposited), tracing.BalanceChangeUnspecified) avail, err = gasInfo.GetL1FeesAvailable(callCtx, evm) Require(t, err) if avail.Sign() != 0 { diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 16d6b2f131..120f45dd34 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -9,6 +9,7 @@ import ( "encoding/hex" "encoding/json" "io" + "log/slog" "math/big" "net" "net/http" @@ -76,7 +77,6 @@ import ( "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/github" - "golang.org/x/exp/slog" ) type info = *BlockchainTestInfo @@ -665,6 +665,7 @@ func createTestL1BlockChainWithConfig(t *testing.T, l1info info, stackConfig *no l1Genesis.BaseFee = big.NewInt(50 * params.GWei) nodeConf.Genesis = l1Genesis nodeConf.Miner.Etherbase = l1info.GetAddress("Faucet") + nodeConf.Miner.PendingFeeRecipient = l1info.GetAddress("Faucet") nodeConf.SyncMode = downloader.FullSync l1backend, err := eth.New(stack, &nodeConf) @@ -675,26 +676,24 @@ func createTestL1BlockChainWithConfig(t *testing.T, l1info info, stackConfig *no catalyst.RegisterSimulatedBeaconAPIs(stack, simBeacon) stack.RegisterLifecycle(simBeacon) - tempKeyStore := keystore.NewPlaintextKeyStore(t.TempDir()) + tempKeyStore := keystore.NewKeyStore(t.TempDir(), keystore.LightScryptN, keystore.LightScryptP) faucetAccount, err := tempKeyStore.ImportECDSA(l1info.Accounts["Faucet"].PrivateKey, "passphrase") Require(t, err) Require(t, tempKeyStore.Unlock(faucetAccount, "passphrase")) l1backend.AccountManager().AddBackend(tempKeyStore) - l1backend.SetEtherbase(l1info.GetAddress("Faucet")) stack.RegisterLifecycle(&lifecycle{stop: func() error { - l1backend.StopMining() - return nil + return l1backend.Stop() }}) stack.RegisterAPIs([]rpc.API{{ Namespace: "eth", - Service: filters.NewFilterAPI(filters.NewFilterSystem(l1backend.APIBackend, filters.Config{}), false), + Service: filters.NewFilterAPI(filters.NewFilterSystem(l1backend.APIBackend, filters.Config{})), }}) stack.RegisterAPIs(tracers.APIs(l1backend.APIBackend)) Require(t, stack.Start()) - Require(t, l1backend.StartMining()) + Require(t, l1backend.Start()) rpcClient := stack.Attach() diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 2332f4ee9e..12b81d9d12 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -7,6 +7,7 @@ import ( "context" "encoding/base64" "io" + "log/slog" "math/big" "net" "net/http" @@ -35,7 +36,6 @@ import ( "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" - "golang.org/x/exp/slog" ) func startLocalDASServer( diff --git a/util/blobs/blobs.go b/util/blobs/blobs.go index 405c776bad..5c06aa7c3d 100644 --- a/util/blobs/blobs.go +++ b/util/blobs/blobs.go @@ -116,7 +116,7 @@ func ComputeCommitmentsAndHashes(blobs []kzg4844.Blob) ([]kzg4844.Commitment, [] for i := range blobs { var err error - commitments[i], err = kzg4844.BlobToCommitment(blobs[i]) + commitments[i], err = kzg4844.BlobToCommitment(&blobs[i]) if err != nil { return nil, nil, err } @@ -133,7 +133,7 @@ func ComputeBlobProofs(blobs []kzg4844.Blob, commitments []kzg4844.Commitment) ( proofs := make([]kzg4844.Proof, len(blobs)) for i := range blobs { var err error - proofs[i], err = kzg4844.ComputeBlobProof(blobs[i], commitments[i]) + proofs[i], err = kzg4844.ComputeBlobProof(&blobs[i], commitments[i]) if err != nil { return nil, err } diff --git a/util/headerreader/blob_client.go b/util/headerreader/blob_client.go index 2b47a940c3..215a03d9d9 100644 --- a/util/headerreader/blob_client.go +++ b/util/headerreader/blob_client.go @@ -247,7 +247,7 @@ func (b *BlobClient) blobSidecars(ctx context.Context, slot uint64, versionedHas var proof kzg4844.Proof copy(proof[:], blobItem.KzgProof) - err = kzg4844.VerifyBlobProof(output[outputIdx], commitment, proof) + err = kzg4844.VerifyBlobProof(&output[outputIdx], commitment, proof) if err != nil { return nil, fmt.Errorf("failed to verify blob proof for blob at slot(%d) at index(%d), blob(%s)", slot, blobItem.Index, pretty.FirstFewChars(blobItem.Blob.String())) } diff --git a/util/testhelpers/testhelpers.go b/util/testhelpers/testhelpers.go index 071429879e..46a456387e 100644 --- a/util/testhelpers/testhelpers.go +++ b/util/testhelpers/testhelpers.go @@ -7,6 +7,7 @@ import ( "context" crypto "crypto/rand" "io" + "log/slog" "math/big" "math/rand" "os" @@ -17,7 +18,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/util/colors" - "golang.org/x/exp/slog" ) // Fail a test should an error occur From ac6e0e7846598dbcf1c3635fbe067c7877aa4b27 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 22 Jul 2024 16:25:31 +0530 Subject: [PATCH 006/210] update submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 41caa90e92..f802673ea6 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 41caa90e923312bf7b39f8de4b8e9534724cd4cd +Subproject commit f802673ea6499c14f567b28836bfeaeae31faf8d From 89c65f8607f2ae4800921e9e49676d8cc7f390fe Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 24 Jul 2024 17:20:24 +0530 Subject: [PATCH 007/210] update submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 84fe1c5ee2..725aecd9bb 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 84fe1c5ee2b681fa6cfc81e60d57720d1717758e +Subproject commit 725aecd9bb4de8eda8a9ab1305c72d3567d2b1fc From 1ca29cf433c6e1e415765072e8212af301854701 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 25 Jul 2024 17:18:38 +0530 Subject: [PATCH 008/210] fix build --- arbos/arbosState/initialization_test.go | 5 +++-- arbos/arbosState/initialize.go | 6 +++++- arbos/programs/api.go | 2 +- system_tests/state_fuzz_test.go | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 34802392fe..e3de93f4ce 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -66,8 +66,9 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - - triedbConfig := cacheConfig.TriedbConfig() + number, err := initReader.GetNextBlockNumber() + Require(t, err) + triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), 0)) stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil) Require(t, err) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 3ccc4d3d96..f9f31ed5bd 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -54,7 +54,11 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint } func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { - triedbConfig := cacheConfig.TriedbConfig() + number, err := initData.GetNextBlockNumber() + if err != nil { + return common.Hash{}, err + } + triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), timestamp)) triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) defer func() { diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 231ec2c816..6e136affe9 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -164,7 +164,7 @@ func newApiClosures( Stack: util.TracingStackFromArgs(args...), Contract: scope.Contract, } - tracingInfo.Tracer.CaptureState(0, opcode, startGas, baseCost+gas, s, []byte{}, depth, nil) + tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, s, []byte{}, depth, nil) } var ret []byte diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 713aefcfba..1714478046 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -151,7 +151,7 @@ func FuzzStateTransition(f *testing.F) { if err != nil { panic(err) } - trieDBConfig := cacheConfig.TriedbConfig() + trieDBConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int), 0)) statedb, err := state.New(stateRoot, state.NewDatabaseWithConfig(chainDb, trieDBConfig), nil) if err != nil { panic(err) From e5be704010a6afa5654cb5d9f734c06eafdb7c90 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 29 Jul 2024 16:28:51 +0530 Subject: [PATCH 009/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 725aecd9bb..660c03975d 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 725aecd9bb4de8eda8a9ab1305c72d3567d2b1fc +Subproject commit 660c03975dedc4ec3e36c3f5835db00165b6fc59 From 203e767c3454c601e447bc82b57a5dfb1ffc0ac5 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 29 Jul 2024 16:36:43 +0530 Subject: [PATCH 010/210] fix lint --- system_tests/das_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 41a0ce62b1..7670803b3e 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -31,7 +31,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/testhelpers" - "golang.org/x/exp/slog" ) func startLocalDASServer( From be0a4bb1aba764c195d65fc3d2d1bbb6a1f5c98d Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 29 Jul 2024 17:22:36 +0530 Subject: [PATCH 011/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 660c03975d..dd1701edf4 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 660c03975dedc4ec3e36c3f5835db00165b6fc59 +Subproject commit dd1701edf4f000e534eed76965f01f4413b3edc5 From ab6b652ab642313867a163ae98c6354c661b5c19 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 31 Jul 2024 18:18:12 +0530 Subject: [PATCH 012/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index dd1701edf4..42a71d88fb 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit dd1701edf4f000e534eed76965f01f4413b3edc5 +Subproject commit 42a71d88fb341c9614fd8348b05a56bf5297ccec From d9739f2f63d741439ceb815fcffb8e0e305c2cb3 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 31 Jul 2024 19:53:21 +0530 Subject: [PATCH 013/210] fix batch poster --- arbnode/batch_poster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 965f6c2695..1c26e13be4 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -1077,7 +1077,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error) } var use4844 bool config := b.config() - if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && latestHeader.BlobGasUsed != nil { + if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && *latestHeader.ExcessBlobGas != 0 && latestHeader.BlobGasUsed != nil && *latestHeader.BlobGasUsed != 0 { arbOSVersion, err := b.arbOSVersionGetter.ArbOSVersionForMessageNumber(arbutil.MessageIndex(arbmath.SaturatingUSub(uint64(batchPosition.MessageCount), 1))) if err != nil { return false, err From bc4b8761fca016a7d042c39daa680cc464e0a944 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 31 Jul 2024 20:22:44 +0530 Subject: [PATCH 014/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 42a71d88fb..4d6cd19f7f 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 42a71d88fb341c9614fd8348b05a56bf5297ccec +Subproject commit 4d6cd19f7f74f18686826bb6c5fbd0d029742f32 From 16a11eaa805470d66745718fc8e2146587065a6f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 31 Jul 2024 20:36:04 +0530 Subject: [PATCH 015/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 4d6cd19f7f..43fe8c893f 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 4d6cd19f7f74f18686826bb6c5fbd0d029742f32 +Subproject commit 43fe8c893f649e161d668d78ec93eb56c3f14a7c From 24560120d2bb78c1451ed00917a9c1581c14b163 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 31 Jul 2024 21:50:14 +0530 Subject: [PATCH 016/210] fix null reference --- arbos/programs/api.go | 10 ++++++---- arbos/tx_processor.go | 8 ++++++-- arbos/util/tracing.go | 32 ++++++++++++++++++++++++-------- go-ethereum | 2 +- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 6e136affe9..161789ece6 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -138,7 +138,7 @@ func newApiClosures( gas := am.MinInt(startGas, gasReq) // Tracing: emit the call (value transfer is done later in evm.Call) - if tracingInfo != nil { + if tracingInfo != nil && tracingInfo.Tracer.OnOpcode != nil { tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) } @@ -164,7 +164,9 @@ func newApiClosures( Stack: util.TracingStackFromArgs(args...), Contract: scope.Contract, } - tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, s, []byte{}, depth, nil) + if tracingInfo.Tracer.OnOpcode != nil { + tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, s, []byte{}, depth, nil) + } } var ret []byte @@ -223,7 +225,7 @@ func newApiClosures( gas -= one64th // Tracing: emit the create - if tracingInfo != nil { + if tracingInfo != nil && tracingInfo.Tracer.OnOpcode != nil { tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) } @@ -289,7 +291,7 @@ func newApiClosures( } captureHostio := func(name string, args, outs []byte, startInk, endInk uint64) { tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) - if name == "evm_gas_left" || name == "evm_ink_left" { + if (name == "evm_gas_left" || name == "evm_ink_left") && tracingInfo.Tracer.OnOpcode != nil { tracingInfo.Tracer.OnOpcode(0, byte(vm.GAS), 0, 0, scope, []byte{}, depth, nil) tracingInfo.Tracer.OnOpcode(0, byte(vm.POP), 0, 0, scope, []byte{}, depth, nil) } diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index a7abbed6d5..1708291db8 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -153,13 +153,17 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r } evm.IncrementDepth() // fake a call from := p.msg.From - tracer.OnEnter(evm.Depth(), byte(vm.CALL), from, *p.msg.To, p.msg.Data, p.msg.GasLimit, p.msg.Value) + if tracer.OnEnter != nil { + tracer.OnEnter(evm.Depth(), byte(vm.CALL), from, *p.msg.To, p.msg.Data, p.msg.GasLimit, p.msg.Value) + } tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingDuringEVM) p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false) return func() { - tracer.OnExit(evm.Depth(), nil, p.state.Burner.Burned(), nil, false) + if tracer.OnExit != nil { + tracer.OnExit(evm.Depth(), nil, p.state.Burner.Burned(), nil, false) + } evm.DecrementDepth() // fake the return to the first faked call tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingAfterEVM) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index 4801cc57d2..b62a55b8bc 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -63,7 +63,9 @@ func (info *TracingInfo) RecordEmitLog(topics []common.Hash, data []byte) { Contract: info.Contract, } logType := fmt.Sprintf("LOG%d", len(topics)) - info.Tracer.OnOpcode(0, byte(vm.StringToOp(logType)), 0, 0, scope, []byte{}, info.Depth, nil) + if info.Tracer.OnOpcode != nil { + info.Tracer.OnOpcode(0, byte(vm.StringToOp(logType)), 0, 0, scope, []byte{}, info.Depth, nil) + } } func (info *TracingInfo) RecordStorageGet(key common.Hash) { @@ -74,7 +76,9 @@ func (info *TracingInfo) RecordStorageGet(key common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key)), Contract: info.Contract, } - tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil) + } } else { tracer.CaptureArbitrumStorageGet(key, info.Depth, info.Scenario == TracingBeforeEVM) } @@ -88,7 +92,9 @@ func (info *TracingInfo) RecordStorageSet(key, value common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key), HashToUint256(value)), Contract: info.Contract, } - tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil) + } } else { tracer.CaptureArbitrumStorageSet(key, value, info.Depth, info.Scenario == TracingBeforeEVM) } @@ -113,8 +119,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.OnOpcode(0, byte(vm.CALL), 0, 0, scope, []byte{}, depth, nil) - tracer.OnEnter(depth, byte(vm.INVALID), from, to, input, 0, amount) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.CALL), 0, 0, scope, []byte{}, depth, nil) + } + if tracer.OnEnter != nil { + tracer.OnEnter(depth, byte(vm.CALL), from, to, input, gas, amount) + } retScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -124,8 +134,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil) - tracer.OnExit(depth+1, nil, 0, nil, false) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil) + } + if tracer.OnExit != nil { + tracer.OnExit(depth+1, nil, 0, nil, false) + } popScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -134,7 +148,9 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.OnOpcode(0, byte(vm.POP), 0, 0, popScope, []byte{}, depth, nil) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.POP), 0, 0, popScope, []byte{}, depth, nil) + } } func HashToUint256(hash common.Hash) uint256.Int { diff --git a/go-ethereum b/go-ethereum index 43fe8c893f..dd1701edf4 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 43fe8c893f649e161d668d78ec93eb56c3f14a7c +Subproject commit dd1701edf4f000e534eed76965f01f4413b3edc5 From 15834ae164b5d999a9daf8f6a326796aafc0dcfc Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 1 Aug 2024 15:47:38 +0530 Subject: [PATCH 017/210] fix test --- execution/nodeInterface/NodeInterface.go | 10 ++++++---- go-ethereum | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 6fe1b2ef99..33a2abe670 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -516,10 +516,11 @@ func (n NodeInterface) GasEstimateL1Component( args.Gas = (*hexutil.Uint64)(&randomGas) // We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate - if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { + gasLimitNotSetByUser := args.Gas == nil + if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil { return 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) + msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser) pricing := c.State.L1PricingState() l1BaseFeeEstimate, err := pricing.PricePerUnit() @@ -572,10 +573,11 @@ func (n NodeInterface) GasEstimateComponents( // Setting the gas currently doesn't affect the PosterDataCost, // but we do it anyways for accuracy with potential future changes. args.Gas = &totalRaw - if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { + gasLimitNotSetByUser := args.Gas == nil + if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil { return 0, 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) + msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser) brotliCompressionLevel, err := c.State.BrotliCompressionLevel() if err != nil { return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err) diff --git a/go-ethereum b/go-ethereum index dd1701edf4..1793a3be33 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit dd1701edf4f000e534eed76965f01f4413b3edc5 +Subproject commit 1793a3be33cacd8610055a982d82bd062737a64b From c6ad8fabd220fc175ded93870ef39ed8014cbc49 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 1 Aug 2024 16:17:34 +0530 Subject: [PATCH 018/210] fix test --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 1793a3be33..cbecc2f9ee 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 1793a3be33cacd8610055a982d82bd062737a64b +Subproject commit cbecc2f9eeeade5d31bd6846ab24ae7f8b21d0f7 From 49d28d81fb2465ae3ac2cb676413deb5731ea8fc Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 5 Aug 2024 07:38:11 +0530 Subject: [PATCH 019/210] update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index cbecc2f9ee..4b4742a134 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit cbecc2f9eeeade5d31bd6846ab24ae7f8b21d0f7 +Subproject commit 4b4742a13481b7e22c86b1258115d565e5d237ca From 0eea86add99934fb4b8a0dbc2202d2ade5e66612 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 5 Aug 2024 08:24:10 +0530 Subject: [PATCH 020/210] Update geth and fix build --- arbos/arbosState/initialize.go | 2 +- arbos/block_processor.go | 4 ++-- arbos/engine.go | 2 +- go-ethereum | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index f9f31ed5bd..f8f5623abd 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -50,7 +50,7 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint } genesisHeaderInfo.UpdateHeaderWithInfo(head) - return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) + return types.NewBlock(head, nil, nil, trie.NewStackTrie(nil)) } func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { diff --git a/arbos/block_processor.go b/arbos/block_processor.go index b180405c43..184d87d248 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -457,7 +457,7 @@ func ProduceBlockAdvanced( FinalizeBlock(header, complete, statedb, chainConfig) // Touch up the block hashes in receipts - tmpBlock := types.NewBlock(header, complete, nil, receipts, trie.NewStackTrie(nil)) + tmpBlock := types.NewBlock(header, &types.Body{Transactions: complete}, receipts, trie.NewStackTrie(nil)) blockHash := tmpBlock.Hash() for _, receipt := range receipts { @@ -467,7 +467,7 @@ func ProduceBlockAdvanced( } } - block := types.NewBlock(header, complete, nil, receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(header, &types.Body{Transactions: complete}, receipts, trie.NewStackTrie(nil)) if len(block.Transactions()) != len(receipts) { return nil, nil, fmt.Errorf("block has %d txes but %d receipts", len(block.Transactions()), len(receipts)) diff --git a/arbos/engine.go b/arbos/engine.go index a4aa9c46a9..a812e5486b 100644 --- a/arbos/engine.go +++ b/arbos/engine.go @@ -56,7 +56,7 @@ func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *t e.Finalize(chain, header, state, body) - block := types.NewBlock(header, body.Transactions, nil, receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(header, &types.Body{Transactions: body.Transactions}, receipts, trie.NewStackTrie(nil)) return block, nil } diff --git a/go-ethereum b/go-ethereum index 4b4742a134..25b12e8998 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 4b4742a13481b7e22c86b1258115d565e5d237ca +Subproject commit 25b12e89986ee91c7a49cf3afb414b0e8b3b0653 From 00a564bf133aa1a7d30bfaf320cfa08628a70259 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 8 Aug 2024 20:26:59 +0530 Subject: [PATCH 021/210] =?UTF-8?q?Don=E2=80=99t=20print=20redis=20errors?= =?UTF-8?q?=20when=20sequencer=20coordinator=20enabled=20node=20is=20synci?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arbnode/seq_coordinator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/seq_coordinator.go b/arbnode/seq_coordinator.go index 98c19ce361..85299ddc63 100644 --- a/arbnode/seq_coordinator.go +++ b/arbnode/seq_coordinator.go @@ -537,7 +537,7 @@ func (c *SeqCoordinator) update(ctx context.Context) time.Duration { for msgToRead < readUntil { var resString string resString, msgReadErr = c.Client.Get(ctx, redisutil.MessageKeyFor(msgToRead)).Result() - if msgReadErr != nil { + if msgReadErr != nil && c.sequencer.Synced() { log.Warn("coordinator failed reading message", "pos", msgToRead, "err", msgReadErr) break } From 04413ab92e1eff8b92675ecd3bab9b3aef9bba5a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 22 Aug 2024 09:14:09 +0530 Subject: [PATCH 022/210] minor fix --- arbos/programs/api.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arbos/programs/api.go b/arbos/programs/api.go index f520317cf0..504289322f 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -63,7 +63,6 @@ func newApiClosures( actingAddress := contract.Address() // not necessarily WASM readOnly := interpreter.ReadOnly() evm := interpreter.Evm() - depth := evm.Depth() db := evm.StateDB chainConfig := evm.ChainConfig() @@ -129,11 +128,6 @@ func newApiClosures( startGas := am.SaturatingUSub(gasLeft, baseCost) * 63 / 64 gas := am.MinInt(startGas, gasReq) - // Tracing: emit the call (value transfer is done later in evm.Call) - if tracingInfo != nil && tracingInfo.Tracer.OnOpcode != nil { - tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) - } - // EVM rule: calls that pay get a stipend (opCall) if value.Sign() != 0 { gas = am.SaturatingUAdd(gas, params.CallStipend) @@ -199,11 +193,6 @@ func newApiClosures( one64th := gas / 64 gas -= one64th - // Tracing: emit the create - if tracingInfo != nil && tracingInfo.Tracer.OnOpcode != nil { - tracingInfo.Tracer.OnOpcode(0, byte(opcode), startGas, baseCost+gas, scope, []byte{}, depth, nil) - } - var res []byte var addr common.Address // zero on failure var returnGas uint64 From 282d73c99fd4c00a00f4cfc400ae5819ff7b30a1 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 22 Aug 2024 09:17:30 +0530 Subject: [PATCH 023/210] Changes based on PR comments --- arbos/util/transfer.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index 1240928eb6..98ba0ea0bc 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -8,13 +8,13 @@ import ( "errors" "fmt" "github.com/ethereum/go-ethereum/core/tracing" + "github.com/offchainlabs/nitro/util/arbmath" "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/holiman/uint256" - "github.com/offchainlabs/nitro/util/arbmath" ) // TransferBalance represents a balance change occurring aside from a call. @@ -29,20 +29,6 @@ func TransferBalance( if amount.Sign() < 0 { panic(fmt.Sprintf("Tried to transfer negative amount %v from %v to %v", amount, from, to)) } - if from != nil { - balance := evm.StateDB.GetBalance(*from) - if arbmath.BigLessThan(balance.ToBig(), amount) { - return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) - } - evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) - if evm.Context.ArbOSVersion >= 30 { - // ensure the from account is "touched" for EIP-161 - evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer) - } - } - if to != nil { - evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) - } if tracer := evm.Config.Tracer; tracer != nil { if evm.Depth() != 0 && scenario != TracingDuringEVM { // A non-zero depth implies this transfer is occurring inside EVM execution @@ -70,6 +56,20 @@ func TransferBalance( } info.MockCall([]byte{}, 0, *from, *to, amount) } + if from != nil { + balance := evm.StateDB.GetBalance(*from) + if arbmath.BigLessThan(balance.ToBig(), amount) { + return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) + } + evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) + if evm.Context.ArbOSVersion >= 30 { + // ensure the from account is "touched" for EIP-161 + evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer) + } + } + if to != nil { + evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) + } return nil } From 605a137414289a02111fd4c66e4a3696e0744cfd Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 22 Aug 2024 16:23:08 +0530 Subject: [PATCH 024/210] Changes based on PR comments --- arbos/util/transfer.go | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index 98ba0ea0bc..32ef4d1bd0 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -7,14 +7,14 @@ package util import ( "errors" "fmt" - "github.com/ethereum/go-ethereum/core/tracing" - "github.com/offchainlabs/nitro/util/arbmath" "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/util/arbmath" ) // TransferBalance represents a balance change occurring aside from a call. @@ -38,23 +38,24 @@ func TransferBalance( if scenario != TracingDuringEVM { tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) - return nil - } - - if from == nil { - from = &common.Address{} - } - if to == nil { - to = &common.Address{} - } + } else { + fromCopy := from + toCopy := to + if fromCopy == nil { + fromCopy = &common.Address{} + } + if toCopy == nil { + toCopy = &common.Address{} + } - info := &TracingInfo{ - Tracer: evm.Config.Tracer, - Scenario: scenario, - Contract: vm.NewContract(addressHolder{*to}, addressHolder{*from}, uint256.NewInt(0), 0), - Depth: evm.Depth(), + info := &TracingInfo{ + Tracer: evm.Config.Tracer, + Scenario: scenario, + Contract: vm.NewContract(addressHolder{*toCopy}, addressHolder{*fromCopy}, uint256.NewInt(0), 0), + Depth: evm.Depth(), + } + info.MockCall([]byte{}, 0, *fromCopy, *toCopy, amount) } - info.MockCall([]byte{}, 0, *from, *to, amount) } if from != nil { balance := evm.StateDB.GetBalance(*from) From 8da1eb7e1908a21e12cd0b4dee6d7b2dae6e2094 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 2 Sep 2024 11:41:49 -0500 Subject: [PATCH 025/210] Fix spurious "failed to re-send transaction" error logs --- arbnode/dataposter/data_poster.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 6a483929b2..cc62bbd9d9 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/misc/eip4844" + "github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/ethdb" @@ -1087,7 +1088,7 @@ func (p *DataPoster) updateBalance(ctx context.Context) error { return nil } -const maxConsecutiveIntermittentErrors = 10 +const maxConsecutiveIntermittentErrors = 20 func (p *DataPoster) maybeLogError(err error, tx *storage.QueuedTransaction, msg string) { nonce := tx.FullTx.Nonce() @@ -1096,10 +1097,17 @@ func (p *DataPoster) maybeLogError(err error, tx *storage.QueuedTransaction, msg return } logLevel := log.Error - if errors.Is(err, storage.ErrStorageRace) { + isStorageRace := errors.Is(err, storage.ErrStorageRace) + if isStorageRace || strings.Contains(err.Error(), txpool.ErrFutureReplacePending.Error()) { p.errorCount[nonce]++ if p.errorCount[nonce] <= maxConsecutiveIntermittentErrors { - logLevel = log.Debug + if isStorageRace { + logLevel = log.Debug + } else { + logLevel = log.Info + } + } else if isStorageRace { + logLevel = log.Warn } } else { delete(p.errorCount, nonce) From b553f8c3cb172b1b4e627cea59119e8e205600ef Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 3 Sep 2024 19:32:01 +0530 Subject: [PATCH 026/210] update submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index d251082ca3..3aaaa0470d 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit d251082ca3311dc72b6fdb188988fa8d94e2b0bf +Subproject commit 3aaaa0470d7fbb0af61958ff543b123d4c7ee496 From 48a50164c378dc16131bcaab82b573793990922e Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 3 Sep 2024 19:45:21 +0530 Subject: [PATCH 027/210] update submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 3aaaa0470d..cf49bca3cd 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 3aaaa0470d7fbb0af61958ff543b123d4c7ee496 +Subproject commit cf49bca3cd28fb3525eca9e7db2c33bd34acf125 From 236884f6ccf5e383ea654295d9b0a4f14d665cff Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 3 Sep 2024 20:13:24 +0530 Subject: [PATCH 028/210] fix stylus build --- execution/gethexec/stylus_tracer.go | 42 ++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/execution/gethexec/stylus_tracer.go b/execution/gethexec/stylus_tracer.go index 4c18bb2ebe..f054c5cb0b 100644 --- a/execution/gethexec/stylus_tracer.go +++ b/execution/gethexec/stylus_tracer.go @@ -13,6 +13,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/log" @@ -67,10 +69,27 @@ var nestsHostios = map[string]bool{ "static_call_contract": true, } -func newStylusTracer(ctx *tracers.Context, _ json.RawMessage) (tracers.Tracer, error) { - return &stylusTracer{ +func newStylusTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) { + t := &stylusTracer{ open: containers.NewStack[HostioTraceInfo](), stack: containers.NewStack[*containers.Stack[HostioTraceInfo]](), + } + + return &tracers.Tracer{ + Hooks: &tracing.Hooks{ + OnExit: t.OnExit, + OnEnter: t.OnEnter, + OnOpcode: t.OnOpcode, + OnFault: t.OnFault, + OnTxStart: t.OnTxStart, + OnTxEnd: t.OnTxEnd, + CaptureArbitrumTransfer: t.CaptureArbitrumTransfer, + CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet, + CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet, + CaptureStylusHostio: t.CaptureStylusHostio, + }, + GetResult: t.GetResult, + Stop: t.Stop, }, nil } @@ -104,8 +123,7 @@ func (t *stylusTracer) CaptureStylusHostio(name string, args, outs []byte, start } t.open.Push(info) } - -func (t *stylusTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { +func (t *stylusTracer) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { if t.interrupt.Load() { return } @@ -113,7 +131,7 @@ func (t *stylusTracer) CaptureEnter(typ vm.OpCode, from common.Address, to commo // This function adds the prefix evm_ because it assumes the opcode came from the EVM. // If the opcode comes from WASM, the CaptureStylusHostio function will remove the evm prefix. var name string - switch typ { + switch vm.OpCode(typ) { case vm.CALL: name = "evm_call_contract" case vm.DELEGATECALL: @@ -139,7 +157,7 @@ func (t *stylusTracer) CaptureEnter(typ vm.OpCode, from common.Address, to commo t.open = inner } -func (t *stylusTracer) CaptureExit(output []byte, gasUsed uint64, _ error) { +func (t *stylusTracer) OnExit(depth int, output []byte, gasUsed uint64, _ error, reverted bool) { if t.interrupt.Load() { return } @@ -184,16 +202,14 @@ func (t *stylusTracer) Stop(err error) { // Unimplemented EVMLogger interface methods -func (t *stylusTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { +func (t *stylusTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) { } func (t *stylusTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} func (t *stylusTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (t *stylusTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { +func (t *stylusTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) { } -func (t *stylusTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {} -func (t *stylusTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) { +func (t *stylusTracer) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) { } -func (t *stylusTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) { +func (t *stylusTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) { } -func (t *stylusTracer) CaptureTxStart(gasLimit uint64) {} -func (t *stylusTracer) CaptureTxEnd(restGas uint64) {} +func (t *stylusTracer) OnTxEnd(receipt *types.Receipt, err error) {} From 42319ee7f6f38cc73ea40819626e7f8f72a4b936 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 11 Sep 2024 16:31:51 +0530 Subject: [PATCH 029/210] Get rid of the hardcoded list of chains in config_arbitrum.go (geth) instead use arbitrum_chain_info.json (nitro) --- arbnode/inbox_test.go | 3 +- arbos/addressSet/addressSet_test.go | 8 +- arbos/arbosState/arbosstate.go | 3 +- arbos/arbosState/initialization_test.go | 4 +- arbos/arbostypes/incomingmessage.go | 3 +- arbos/l1pricing/l1pricing.go | 3 +- arbos/l1pricing_test.go | 3 +- cmd/chaininfo/chain_defaults.go | 141 ++++++++++++++++++++++++ cmd/chaininfo/chain_info.go | 4 +- execution/gethexec/executionengine.go | 4 +- gethhook/geth_test.go | 3 +- go-ethereum | 2 +- precompiles/ArbAddressTable_test.go | 4 +- precompiles/ArbOwner_test.go | 4 +- system_tests/common_test.go | 12 +- system_tests/contract_tx_test.go | 4 +- system_tests/das_test.go | 4 +- system_tests/initialization_test.go | 4 +- system_tests/precompile_fuzz_test.go | 4 +- system_tests/precompile_test.go | 4 +- system_tests/retryable_test.go | 3 +- system_tests/state_fuzz_test.go | 5 +- 22 files changed, 189 insertions(+), 40 deletions(-) create mode 100644 cmd/chaininfo/chain_defaults.go diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index d579b7c278..0441a9a8d4 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -14,6 +14,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/statetransfer" @@ -45,7 +46,7 @@ func (w *execClientWrapper) FullSyncProgressMap() map[string]interface{} { } func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (*gethexec.ExecutionEngine, *TransactionStreamer, ethdb.Database, *core.BlockChain) { - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() initData := statetransfer.ArbosInitializationInfo{ Accounts: []statetransfer.AccountInitializationInfo{ diff --git a/arbos/addressSet/addressSet_test.go b/arbos/addressSet/addressSet_test.go index d32e07a546..7cb93a2fb7 100644 --- a/arbos/addressSet/addressSet_test.go +++ b/arbos/addressSet/addressSet_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/params" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -18,6 +17,7 @@ import ( "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -26,7 +26,7 @@ func TestEmptyAddressSet(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Require(t, Initialize(sto)) aset := OpenAddressSet(sto) - version := params.ArbitrumDevTestParams().InitialArbOSVersion + version := chaininfo.ArbitrumDevTestParams().InitialArbOSVersion if size(t, aset) != 0 { Fail(t) @@ -49,7 +49,7 @@ func TestAddressSet(t *testing.T) { sto := storage.NewGeth(db, burn.NewSystemBurner(nil, false)) Require(t, Initialize(sto)) aset := OpenAddressSet(sto) - version := params.ArbitrumDevTestParams().InitialArbOSVersion + version := chaininfo.ArbitrumDevTestParams().InitialArbOSVersion statedb, _ := (db).(*state.StateDB) stateHashBeforeChanges := statedb.IntermediateRoot(false) @@ -144,7 +144,7 @@ func TestAddressSetAllMembers(t *testing.T) { sto := storage.NewGeth(db, burn.NewSystemBurner(nil, false)) Require(t, Initialize(sto)) aset := OpenAddressSet(sto) - version := params.ArbitrumDevTestParams().InitialArbOSVersion + version := chaininfo.ArbitrumDevTestParams().InitialArbOSVersion addr1 := testhelpers.RandomAddress() addr2 := testhelpers.RandomAddress() diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index 91c2207aae..fcecee1850 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -32,6 +32,7 @@ import ( "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/testhelpers/env" ) @@ -129,7 +130,7 @@ func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { log.Crit("failed to init empty statedb", "error", err) } burner := burn.NewSystemBurner(nil, false) - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() newState, err := InitializeArbosState(statedb, burner, chainConfig, arbostypes.TestInitMessage) if err != nil { log.Crit("failed to open the ArbOS state", "error", err) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 5e605b8bd2..f58123e7ca 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -13,9 +13,9 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/env" @@ -61,7 +61,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin raw := rawdb.NewMemoryDatabase() initReader := statetransfer.NewMemoryInitDataReader(&initData) - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) diff --git a/arbos/arbostypes/incomingmessage.go b/arbos/arbostypes/incomingmessage.go index 04ce8ebe2e..bf1d5f6018 100644 --- a/arbos/arbostypes/incomingmessage.go +++ b/arbos/arbostypes/incomingmessage.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/arbmath" ) @@ -254,7 +255,7 @@ type ParsedInitMessage struct { var DefaultInitialL1BaseFee = big.NewInt(50 * params.GWei) var TestInitMessage = &ParsedInitMessage{ - ChainId: params.ArbitrumDevTestChainConfig().ChainID, + ChainId: chaininfo.ArbitrumDevTestChainConfig().ChainID, InitialL1BaseFee: DefaultInitialL1BaseFee, } diff --git a/arbos/l1pricing/l1pricing.go b/arbos/l1pricing/l1pricing.go index 392bf36d37..168bb1ad69 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbcompress" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/arbmath" am "github.com/offchainlabs/nitro/util/arbmath" @@ -540,7 +541,7 @@ var randomNonce = binary.BigEndian.Uint64(crypto.Keccak256([]byte("Nonce"))[:8]) var randomGasTipCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasTipCap"))[:4]) var randomGasFeeCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasFeeCap"))[:4]) var RandomGas = uint64(binary.BigEndian.Uint32(crypto.Keccak256([]byte("Gas"))[:4])) -var randV = arbmath.BigMulByUint(params.ArbitrumOneChainConfig().ChainID, 3) +var randV = arbmath.BigMulByUint(chaininfo.ArbitrumOneChainConfig().ChainID, 3) var randR = crypto.Keccak256Hash([]byte("R")).Big() var randS = crypto.Keccak256Hash([]byte("S")).Big() diff --git a/arbos/l1pricing_test.go b/arbos/l1pricing_test.go index 6f9e3ecb35..f081c8151d 100644 --- a/arbos/l1pricing_test.go +++ b/arbos/l1pricing_test.go @@ -15,6 +15,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/arbmath" "github.com/ethereum/go-ethereum/params" @@ -315,7 +316,7 @@ func _withinOnePercent(v1, v2 *big.Int) bool { } func newMockEVMForTesting() *vm.EVM { - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() _, statedb := arbosState.NewArbosMemoryBackedArbOSState() context := vm.BlockContext{ BlockNumber: big.NewInt(0), diff --git a/cmd/chaininfo/chain_defaults.go b/cmd/chaininfo/chain_defaults.go new file mode 100644 index 0000000000..1f4cc5060b --- /dev/null +++ b/cmd/chaininfo/chain_defaults.go @@ -0,0 +1,141 @@ +// Copyright 2021-2022, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package chaininfo + +import ( + "encoding/json" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/params" +) + +var DefaultChainConfigs map[string]*params.ChainConfig + +func init() { + var chainsInfo []ChainInfo + err := json.Unmarshal(DefaultChainsInfoBytes, &chainsInfo) + if err != nil { + panic(fmt.Errorf("error initializing default chainsInfo: %w", err)) + } + if len(chainsInfo) == 0 { + panic("Default chainsInfo is empty") + } + DefaultChainConfigs = make(map[string]*params.ChainConfig) + for _, chainInfo := range chainsInfo { + DefaultChainConfigs[chainInfo.ChainName] = chainInfo.ChainConfig + } +} + +func CopyArbitrumChainParams(arbChainParams params.ArbitrumChainParams) params.ArbitrumChainParams { + return params.ArbitrumChainParams{ + EnableArbOS: arbChainParams.EnableArbOS, + AllowDebugPrecompiles: arbChainParams.AllowDebugPrecompiles, + DataAvailabilityCommittee: arbChainParams.DataAvailabilityCommittee, + InitialArbOSVersion: arbChainParams.InitialArbOSVersion, + InitialChainOwner: arbChainParams.InitialChainOwner, + GenesisBlockNum: arbChainParams.GenesisBlockNum, + MaxCodeSize: arbChainParams.MaxCodeSize, + MaxInitCodeSize: arbChainParams.MaxInitCodeSize, + } +} + +func CopyChainConfig(chainConfig *params.ChainConfig) *params.ChainConfig { + copy := ¶ms.ChainConfig{ + DAOForkSupport: chainConfig.DAOForkSupport, + ArbitrumChainParams: CopyArbitrumChainParams(chainConfig.ArbitrumChainParams), + Clique: ¶ms.CliqueConfig{ + Period: chainConfig.Clique.Period, + Epoch: chainConfig.Clique.Epoch, + }, + } + if chainConfig.ChainID != nil { + copy.ChainID = new(big.Int).Set(chainConfig.ChainID) + } + if chainConfig.HomesteadBlock != nil { + copy.HomesteadBlock = new(big.Int).Set(chainConfig.HomesteadBlock) + } + if chainConfig.DAOForkBlock != nil { + copy.DAOForkBlock = new(big.Int).Set(chainConfig.DAOForkBlock) + } + if chainConfig.EIP150Block != nil { + copy.EIP150Block = new(big.Int).Set(chainConfig.EIP150Block) + } + if chainConfig.EIP155Block != nil { + copy.EIP155Block = new(big.Int).Set(chainConfig.EIP155Block) + } + if chainConfig.EIP158Block != nil { + copy.EIP158Block = new(big.Int).Set(chainConfig.EIP158Block) + } + if chainConfig.ByzantiumBlock != nil { + copy.ByzantiumBlock = new(big.Int).Set(chainConfig.ByzantiumBlock) + } + if chainConfig.ConstantinopleBlock != nil { + copy.ConstantinopleBlock = new(big.Int).Set(chainConfig.ConstantinopleBlock) + } + if chainConfig.PetersburgBlock != nil { + copy.PetersburgBlock = new(big.Int).Set(chainConfig.PetersburgBlock) + } + if chainConfig.IstanbulBlock != nil { + copy.IstanbulBlock = new(big.Int).Set(chainConfig.IstanbulBlock) + } + if chainConfig.MuirGlacierBlock != nil { + copy.MuirGlacierBlock = new(big.Int).Set(chainConfig.MuirGlacierBlock) + } + if chainConfig.BerlinBlock != nil { + copy.BerlinBlock = new(big.Int).Set(chainConfig.BerlinBlock) + } + if chainConfig.LondonBlock != nil { + copy.LondonBlock = new(big.Int).Set(chainConfig.LondonBlock) + } + return copy +} + +func fetchArbitrumChainParams(chainName string) params.ArbitrumChainParams { + originalConfig, ok := DefaultChainConfigs[chainName] + if !ok { + panic(fmt.Sprintf("%s chain config not found in DefaultChainConfigs", chainName)) + } + return CopyArbitrumChainParams(originalConfig.ArbitrumChainParams) +} + +func ArbitrumOneParams() params.ArbitrumChainParams { + return fetchArbitrumChainParams("arb1") +} +func ArbitrumNovaParams() params.ArbitrumChainParams { + return fetchArbitrumChainParams("nova") +} +func ArbitrumRollupGoerliTestnetParams() params.ArbitrumChainParams { + return fetchArbitrumChainParams("goerli-rollup") +} +func ArbitrumDevTestParams() params.ArbitrumChainParams { + return fetchArbitrumChainParams("arb-dev-test") +} +func ArbitrumDevTestDASParams() params.ArbitrumChainParams { + return fetchArbitrumChainParams("anytrust-dev-test") +} + +func fetchChainConfig(chainName string) *params.ChainConfig { + originalConfig, ok := DefaultChainConfigs[chainName] + if !ok { + panic(fmt.Sprintf("%s chain config not found in DefaultChainConfigs", chainName)) + } + return CopyChainConfig(originalConfig) +} + +func ArbitrumOneChainConfig() *params.ChainConfig { + return fetchChainConfig("arb1") +} +func ArbitrumNovaChainConfig() *params.ChainConfig { + return fetchChainConfig("nova") +} +func ArbitrumRollupGoerliTestnetChainConfig() *params.ChainConfig { + return fetchChainConfig("goerli-rollup") +} +func ArbitrumDevTestChainConfig() *params.ChainConfig { + return fetchChainConfig("arb-dev-test") +} +func ArbitrumDevTestDASChainConfig() *params.ChainConfig { + return fetchChainConfig("anytrust-dev-test") +} diff --git a/cmd/chaininfo/chain_info.go b/cmd/chaininfo/chain_info.go index 13e586ced2..aa40d6514f 100644 --- a/cmd/chaininfo/chain_info.go +++ b/cmd/chaininfo/chain_info.go @@ -16,7 +16,7 @@ import ( ) //go:embed arbitrum_chain_info.json -var DefaultChainInfo []byte +var DefaultChainsInfoBytes []byte type ChainInfo struct { ChainName string `json:"chain-name"` @@ -80,7 +80,7 @@ func ProcessChainInfo(chainId uint64, chainName string, l2ChainInfoFiles []strin } } - chainInfo, err := findChainInfo(chainId, chainName, DefaultChainInfo) + chainInfo, err := findChainInfo(chainId, chainName, DefaultChainsInfoBytes) if err != nil || chainInfo != nil { return chainInfo, err } diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index 8594d5867d..d3bb407aa4 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -32,7 +32,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/params" "github.com/google/uuid" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" @@ -40,6 +39,7 @@ import ( "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/sharedmetrics" @@ -883,7 +883,7 @@ func (s *ExecutionEngine) digestMessageWithBlockMutex(num arbutil.MessageIndex, timestamp = time.Unix(int64(timestampInt), 0) timeUntilUpgrade = time.Until(timestamp) } - maxSupportedVersion := params.ArbitrumDevTestChainConfig().ArbitrumChainParams.InitialArbOSVersion + maxSupportedVersion := chaininfo.ArbitrumDevTestChainConfig().ArbitrumChainParams.InitialArbOSVersion logLevel := log.Warn if timeUntilUpgrade < time.Hour*24 { logLevel = log.Error diff --git a/gethhook/geth_test.go b/gethhook/geth_test.go index 57ce2ddec0..381c128071 100644 --- a/gethhook/geth_test.go +++ b/gethhook/geth_test.go @@ -20,6 +20,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -49,7 +50,7 @@ var testChainConfig = ¶ms.ChainConfig{ MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ArbitrumChainParams: params.ArbitrumDevTestParams(), + ArbitrumChainParams: chaininfo.ArbitrumDevTestParams(), } func TestEthDepositMessage(t *testing.T) { diff --git a/go-ethereum b/go-ethereum index 81114dde8a..797bfd608d 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 81114dde8a26bae90c188605c4a36d5919a4a265 +Subproject commit 797bfd608d932751152e4f3d227ad5aaddf73eda diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index b01a460636..2784757bd7 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -12,9 +12,9 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -161,7 +161,7 @@ func newMockEVMForTestingWithVersionAndRunMode(version *uint64, runMode core.Mes } func newMockEVMForTestingWithVersion(version *uint64) *vm.EVM { - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() if version != nil { chainConfig.ArbitrumChainParams.InitialArbOSVersion = *version } diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index 1f8c7ae4cd..3f82124495 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -13,13 +13,13 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -163,7 +163,7 @@ func TestArbOwnerSetChainConfig(t *testing.T) { prec := &ArbOwner{} callCtx := testContext(caller, evm) - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() chainConfig.ArbitrumChainParams.AllowDebugPrecompiles = false serializedChainConfig, err := json.Marshal(chainConfig) Require(t, err) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 7a78cee309..6cffcde5a0 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -264,7 +264,7 @@ func (b *NodeBuilder) DefaultConfig(t *testing.T, withL1 bool) *NodeBuilder { b.takeOwnership = true b.nodeConfig = arbnode.ConfigDefaultL2Test() } - b.chainConfig = params.ArbitrumDevTestChainConfig() + b.chainConfig = chaininfo.ArbitrumDevTestChainConfig() b.L1Info = NewL1TestInfo(t) b.L2Info = NewArbTestInfo(t, b.chainConfig.ChainID) b.dataDir = t.TempDir() @@ -309,7 +309,7 @@ func (b *NodeBuilder) Build(t *testing.T) func() { func (b *NodeBuilder) CheckConfig(t *testing.T) { if b.chainConfig == nil { - b.chainConfig = params.ArbitrumDevTestChainConfig() + b.chainConfig = chaininfo.ArbitrumDevTestChainConfig() } if b.nodeConfig == nil { b.nodeConfig = arbnode.ConfigDefaultL1Test() @@ -934,7 +934,7 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client, stackConfig := testhelpers.CreateStackConfigForTest(t.TempDir()) l1info.GenerateAccount("Faucet") - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() chainConfig.ArbitrumChainParams = params.ArbitrumChainParams{} stack, err := node.New(stackConfig) @@ -1257,7 +1257,7 @@ func setupConfigWithDAS( t *testing.T, ctx context.Context, dasModeString string, ) (*params.ChainConfig, *arbnode.Config, *das.LifecycleManager, string, *blsSignatures.PublicKey) { l1NodeConfigA := arbnode.ConfigDefaultL1Test() - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() var dbPath string var err error @@ -1265,10 +1265,10 @@ func setupConfigWithDAS( switch dasModeString { case "db": enableDbStorage = true - chainConfig = params.ArbitrumDevTestDASChainConfig() + chainConfig = chaininfo.ArbitrumDevTestDASChainConfig() case "files": enableFileStorage = true - chainConfig = params.ArbitrumDevTestDASChainConfig() + chainConfig = chaininfo.ArbitrumDevTestDASChainConfig() case "onchain": enableDas = false default: diff --git a/system_tests/contract_tx_test.go b/system_tests/contract_tx_test.go index c1ef840c43..efbb765bf2 100644 --- a/system_tests/contract_tx_test.go +++ b/system_tests/contract_tx_test.go @@ -14,9 +14,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/arbmath" ) @@ -54,7 +54,7 @@ func TestContractTxDeploy(t *testing.T) { // #nosec G115 requestId[0] = uint8(stateNonce) contractTx := &types.ArbitrumContractTx{ - ChainId: params.ArbitrumDevTestChainConfig().ChainID, + ChainId: chaininfo.ArbitrumDevTestChainConfig().ChainID, RequestId: requestId, From: from, GasFeeCap: big.NewInt(1e9), diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 9f4d153b6f..c4ae9f6848 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -19,11 +19,11 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/blsSignatures" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/das" "github.com/offchainlabs/nitro/solgen/go/bridgegen" @@ -206,7 +206,7 @@ func TestDASComplexConfigAndRestMirror(t *testing.T) { // Setup L1 chain and contracts builder := NewNodeBuilder(ctx).DefaultConfig(t, true) - builder.chainConfig = params.ArbitrumDevTestDASChainConfig() + builder.chainConfig = chaininfo.ArbitrumDevTestDASChainConfig() builder.BuildL1(t) arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, builder.L1.Client) diff --git a/system_tests/initialization_test.go b/system_tests/initialization_test.go index 17e020e6ab..d70d8c32d0 100644 --- a/system_tests/initialization_test.go +++ b/system_tests/initialization_test.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -50,7 +50,7 @@ func TestInitContract(t *testing.T) { defer cancel() expectedSums := make(map[common.Address]*big.Int) prand := testhelpers.NewPseudoRandomDataSource(t, 1) - l2info := NewArbTestInfo(t, params.ArbitrumDevTestChainConfig().ChainID) + l2info := NewArbTestInfo(t, chaininfo.ArbitrumDevTestChainConfig().ChainID) for i := 0; i < 50; i++ { contractData, sum := InitOneContract(prand) accountAddress := prand.GetAddress() diff --git a/system_tests/precompile_fuzz_test.go b/system_tests/precompile_fuzz_test.go index 8ab133cf58..2eef435966 100644 --- a/system_tests/precompile_fuzz_test.go +++ b/system_tests/precompile_fuzz_test.go @@ -12,10 +12,10 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/precompiles" ) @@ -32,7 +32,7 @@ func FuzzPrecompiles(f *testing.F) { panic(err) } burner := burn.NewSystemBurner(nil, false) - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() _, err = arbosState.InitializeArbosState(sdb, burner, chainConfig, arbostypes.TestInitMessage) if err != nil { panic(err) diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 9e829124ee..066ea97ed4 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" @@ -30,7 +30,7 @@ func TestPurePrecompileMethodCalls(t *testing.T) { Require(t, err, "could not deploy ArbSys contract") chainId, err := arbSys.ArbChainID(&bind.CallOpts{}) Require(t, err, "failed to get the ChainID") - if chainId.Uint64() != params.ArbitrumDevTestChainConfig().ChainID.Uint64() { + if chainId.Uint64() != chaininfo.ArbitrumDevTestChainConfig().ChainID.Uint64() { Fatal(t, "Wrong ChainID", chainId.Uint64()) } } diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index aa9fbfd72e..6c1841b654 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -22,6 +22,7 @@ import ( "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -75,7 +76,7 @@ func retryableSetup(t *testing.T, modifyNodeConfig ...func(*NodeBuilder)) ( if !msgTypes[message.Message.Header.Kind] { continue } - txs, err := arbos.ParseL2Transactions(message.Message, params.ArbitrumDevTestChainConfig().ChainID) + txs, err := arbos.ParseL2Transactions(message.Message, chaininfo.ArbitrumDevTestChainConfig().ChainID) Require(t, err) for _, tx := range txs { if txTypes[tx.Type()] { diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 24140e480d..c9af4214e2 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -27,6 +27,7 @@ import ( "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbstate" "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers/env" ) @@ -132,7 +133,7 @@ func FuzzStateTransition(f *testing.F) { return } chainDb := rawdb.NewMemoryDatabase() - chainConfig := params.ArbitrumRollupGoerliTestnetChainConfig() + chainConfig := chaininfo.ArbitrumRollupGoerliTestnetChainConfig() serializedChainConfig, err := json.Marshal(chainConfig) if err != nil { panic(err) @@ -201,7 +202,7 @@ func FuzzStateTransition(f *testing.F) { positionWithinMessage: 0, delayedMessages: delayedMessages, } - _, err = BuildBlock(statedb, genesis, noopChainContext{}, params.ArbitrumOneChainConfig(), inbox, seqBatch) + _, err = BuildBlock(statedb, genesis, noopChainContext{}, chaininfo.ArbitrumOneChainConfig(), inbox, seqBatch) if err != nil { // With the fixed header it shouldn't be possible to read a delayed message, // and no other type of error should be possible. From 206bd8da1d605ffbd6e6dce160bc75007d1521d6 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 11 Sep 2024 21:33:25 +0530 Subject: [PATCH 030/210] add test to make sure copy functions are updated if the json file is changed --- cmd/chaininfo/chain_defaults.go | 2 +- cmd/chaininfo/chain_defaults_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 cmd/chaininfo/chain_defaults_test.go diff --git a/cmd/chaininfo/chain_defaults.go b/cmd/chaininfo/chain_defaults.go index 1f4cc5060b..a69472cafc 100644 --- a/cmd/chaininfo/chain_defaults.go +++ b/cmd/chaininfo/chain_defaults.go @@ -1,4 +1,4 @@ -// Copyright 2021-2022, Offchain Labs, Inc. +// Copyright 2021-2024, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE package chaininfo diff --git a/cmd/chaininfo/chain_defaults_test.go b/cmd/chaininfo/chain_defaults_test.go new file mode 100644 index 0000000000..743758029d --- /dev/null +++ b/cmd/chaininfo/chain_defaults_test.go @@ -0,0 +1,27 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package chaininfo + +import ( + "reflect" + "testing" +) + +func TestDefaultChainConfigsCopyCorrectly(t *testing.T) { + if !reflect.DeepEqual(DefaultChainConfigs["arb1"], ArbitrumOneChainConfig()) { + t.Fatal("copy of arb1 default chain config mismatch") + } + if !reflect.DeepEqual(DefaultChainConfigs["nova"], ArbitrumNovaChainConfig()) { + t.Fatal("copy of nova default chain config mismatch") + } + if !reflect.DeepEqual(DefaultChainConfigs["goerli-rollup"], ArbitrumRollupGoerliTestnetChainConfig()) { + t.Fatal("copy of goerli-rollup default chain config mismatch") + } + if !reflect.DeepEqual(DefaultChainConfigs["arb-dev-test"], ArbitrumDevTestChainConfig()) { + t.Fatal("copy of arb-dev-test default chain config mismatch") + } + if !reflect.DeepEqual(DefaultChainConfigs["anytrust-dev-test"], ArbitrumDevTestDASChainConfig()) { + t.Fatal("copy of anytrust-dev-test default chain config mismatch") + } +} From 015285614f2df69b6b342c183199405d1be38cff Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 11 Sep 2024 21:40:48 +0530 Subject: [PATCH 031/210] modify test --- cmd/chaininfo/chain_defaults_test.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/cmd/chaininfo/chain_defaults_test.go b/cmd/chaininfo/chain_defaults_test.go index 743758029d..a19e5849a6 100644 --- a/cmd/chaininfo/chain_defaults_test.go +++ b/cmd/chaininfo/chain_defaults_test.go @@ -9,19 +9,9 @@ import ( ) func TestDefaultChainConfigsCopyCorrectly(t *testing.T) { - if !reflect.DeepEqual(DefaultChainConfigs["arb1"], ArbitrumOneChainConfig()) { - t.Fatal("copy of arb1 default chain config mismatch") - } - if !reflect.DeepEqual(DefaultChainConfigs["nova"], ArbitrumNovaChainConfig()) { - t.Fatal("copy of nova default chain config mismatch") - } - if !reflect.DeepEqual(DefaultChainConfigs["goerli-rollup"], ArbitrumRollupGoerliTestnetChainConfig()) { - t.Fatal("copy of goerli-rollup default chain config mismatch") - } - if !reflect.DeepEqual(DefaultChainConfigs["arb-dev-test"], ArbitrumDevTestChainConfig()) { - t.Fatal("copy of arb-dev-test default chain config mismatch") - } - if !reflect.DeepEqual(DefaultChainConfigs["anytrust-dev-test"], ArbitrumDevTestDASChainConfig()) { - t.Fatal("copy of anytrust-dev-test default chain config mismatch") + for _, chainName := range []string{"arb1", "nova", "goerli-rollup", "arb-dev-test", "anytrust-dev-test"} { + if !reflect.DeepEqual(DefaultChainConfigs[chainName], fetchChainConfig(chainName)) { + t.Fatalf("copy of %s default chain config mismatch", chainName) + } } } From e84264be43d9c9a8c584548f2df3c17af18324b0 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 13 Sep 2024 00:00:31 -0500 Subject: [PATCH 032/210] Fix inbox reading window after a reorg --- arbnode/inbox_reader.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index c596cfa9b0..835aef18b8 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -534,14 +534,6 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { storeSeenBatchCount() } } - if reorgingDelayed || reorgingSequencer { - from, err = r.getPrevBlockForReorg(from) - if err != nil { - return err - } - } else { - from = arbmath.BigAddByUint(to, 1) - } // #nosec G115 haveMessages := uint64(len(delayedMessages) + len(sequencerBatches)) if haveMessages <= (config.TargetMessagesRead / 2) { @@ -555,6 +547,14 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if blocksToFetch > config.MaxBlocksToRead { blocksToFetch = config.MaxBlocksToRead } + if reorgingDelayed || reorgingSequencer { + from, err = r.getPrevBlockForReorg(from, blocksToFetch) + if err != nil { + return err + } + } else { + from = arbmath.BigAddByUint(to, 1) + } } if !readAnyBatches { @@ -578,11 +578,11 @@ func (r *InboxReader) addMessages(ctx context.Context, sequencerBatches []*Seque return false, nil } -func (r *InboxReader) getPrevBlockForReorg(from *big.Int) (*big.Int, error) { +func (r *InboxReader) getPrevBlockForReorg(from *big.Int, maxBlocksBackwards uint64) (*big.Int, error) { if from.Cmp(r.firstMessageBlock) <= 0 { return nil, errors.New("can't get older messages") } - newFrom := arbmath.BigSub(from, big.NewInt(10)) + newFrom := arbmath.BigSub(from, new(big.Int).SetUint64(maxBlocksBackwards)) if newFrom.Cmp(r.firstMessageBlock) < 0 { newFrom = new(big.Int).Set(r.firstMessageBlock) } From f8bbc3804e6e9f67850de1d6ba2c4f6b80a701e9 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 13 Sep 2024 11:15:07 -0500 Subject: [PATCH 033/210] Add a bunch of trace logging --- arbnode/inbox_reader.go | 42 +++++++++++++++++++++++++++++++++++++++- arbnode/inbox_tracker.go | 20 +++++++++++-------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 835aef18b8..295f0acf4c 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -333,6 +333,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestDelayedCount < checkingDelayedCount { + log.Trace("Expecting to find delayed messages", "checkingDelayedCount", checkingDelayedCount, "ourLatestDelayedCount", ourLatestDelayedCount, "currentHeight", currentHeight) checkingDelayedCount = ourLatestDelayedCount missingDelayed = true } else if ourLatestDelayedCount > checkingDelayedCount { @@ -353,6 +354,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbDelayedAcc != l1DelayedAcc { + log.Trace("Latest delayed accumulator mismatch", "delayedSeqNum", checkingDelayedSeqNum, "dbDelayedAcc", dbDelayedAcc, "l1DelayedAcc", l1DelayedAcc) reorgingDelayed = true } } @@ -370,6 +372,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestBatchCount < checkingBatchCount { + log.Trace("Expecting to find sequencer batches", "checkingBatchCount", checkingBatchCount, "ourLatestBatchCount", ourLatestBatchCount, "currentHeight", currentHeight) checkingBatchCount = ourLatestBatchCount missingSequencer = true } else if ourLatestBatchCount > checkingBatchCount && config.HardReorg { @@ -389,6 +392,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbBatchAcc != l1BatchAcc { + log.Trace("Latest sequencer batch accumulator mismatch", "batchSeqNum", checkingBatchSeqNum, "dbBatchAcc", dbBatchAcc, "l1BatchAcc", l1BatchAcc) reorgingSequencer = true } } @@ -431,6 +435,15 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if to.Cmp(currentHeight) > 0 { to.Set(currentHeight) } + log.Trace( + "Looking up messages", + "from", from.String(), + "to", to.String(), + "missingDelayed", missingDelayed, + "missingSequencer", missingSequencer, + "reorgingDelayed", reorgingDelayed, + "reorgingSequencer", reorgingSequencer, + ) sequencerBatches, err := r.sequencerInbox.LookupBatchesInRange(ctx, from, to) if err != nil { return err @@ -456,6 +469,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if len(sequencerBatches) > 0 { missingSequencer = false reorgingSequencer = false + var havePrevAcc common.Hash firstBatch := sequencerBatches[0] if firstBatch.SequenceNumber > 0 { haveAcc, err := r.tracker.GetBatchAcc(firstBatch.SequenceNumber - 1) @@ -466,7 +480,10 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc != firstBatch.BeforeInboxAcc { reorgingSequencer = true } + havePrevAcc = haveAcc } + readLastAcc := sequencerBatches[len(sequencerBatches)-1].AfterInboxAcc + var duplicateBatches int if !reorgingSequencer { // Skip any batches we already have in the database for len(sequencerBatches) > 0 { @@ -481,6 +498,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc == batch.AfterInboxAcc { // Skip this batch, as we already have it in the database sequencerBatches = sequencerBatches[1:] + duplicateBatches++ } else { // The first batch AfterInboxAcc matches, but this batch doesn't, // so we'll successfully reorg it when we hit the addMessages @@ -488,7 +506,18 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } } } + log.Trace( + "Found sequencer batches", + "newBatchesCount", len(sequencerBatches), + "duplicateBatches", duplicateBatches, + "firstSequenceNumber", firstBatch.SequenceNumber, + "reorgingSequencer", reorgingSequencer, + "readBeforeAcc", firstBatch.BeforeInboxAcc, + "haveBeforeAcc", havePrevAcc, + "readLastAcc", readLastAcc, + ) } else if missingSequencer && to.Cmp(currentHeight) >= 0 { + log.Trace("Didn't find expected sequencer batches", "from", from, "to", to, "currentHeight", currentHeight) // We were missing sequencer batches but didn't find any. // This must mean that the sequencer batches are in the past. reorgingSequencer = true @@ -503,6 +532,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if err != nil { return err } + var havePrevAcc common.Hash if beforeCount > 0 { haveAcc, err := r.tracker.GetDelayedAcc(beforeCount - 1) if errors.Is(err, AccumulatorNotFoundErr) { @@ -512,14 +542,24 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc != beforeAcc { reorgingDelayed = true } + havePrevAcc = haveAcc } + log.Trace( + "Found delayed messages", + "count", len(delayedMessages), + "firstSequenceNumber", beforeCount, + "reorgingDelayed", reorgingDelayed, + "readBeforeAcc", beforeAcc, + "haveBeforeAcc", havePrevAcc, + "readLastAcc", delayedMessages[len(delayedMessages)-1].AfterInboxAcc, + ) } else if missingDelayed && to.Cmp(currentHeight) >= 0 { + log.Trace("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight) // We were missing delayed messages but didn't find any. // This must mean that the delayed messages are in the past. reorgingDelayed = true } - log.Trace("looking up messages", "from", from.String(), "to", to.String(), "missingDelayed", missingDelayed, "missingSequencer", missingSequencer, "reorgingDelayed", reorgingDelayed, "reorgingSequencer", reorgingSequencer) if !reorgingDelayed && !reorgingSequencer && (len(delayedMessages) != 0 || len(sequencerBatches) != 0) { delayedMismatch, err := r.addMessages(ctx, sequencerBatches, delayedMessages) if err != nil { diff --git a/arbnode/inbox_tracker.go b/arbnode/inbox_tracker.go index fe4149c80e..862610100c 100644 --- a/arbnode/inbox_tracker.go +++ b/arbnode/inbox_tracker.go @@ -696,22 +696,26 @@ func (t *InboxTracker) AddSequencerBatches(ctx context.Context, client arbutil.L for _, batch := range batches { if batch.SequenceNumber != pos { - return errors.New("unexpected batch sequence number") + return fmt.Errorf("unexpected batch sequence number %v expected %v", batch.SequenceNumber, pos) } if nextAcc != batch.BeforeInboxAcc { - return errors.New("previous batch accumulator mismatch") + return fmt.Errorf("previous batch accumulator %v mismatch expected %v", batch.BeforeInboxAcc, nextAcc) } if batch.AfterDelayedCount > 0 { haveDelayedAcc, err := t.GetDelayedAcc(batch.AfterDelayedCount - 1) - if errors.Is(err, AccumulatorNotFoundErr) { - // We somehow missed a referenced delayed message; go back and look for it - return delayedMessagesMismatch - } - if err != nil { + notFound := errors.Is(err, AccumulatorNotFoundErr) + if err != nil && !notFound { return err } - if haveDelayedAcc != batch.AfterDelayedAcc { + if notFound || haveDelayedAcc != batch.AfterDelayedAcc { + log.Trace( + "Delayed message accumulator doesn't match sequencer batch", + "batch", batch.SequenceNumber, + "delayedPosition", batch.AfterDelayedCount-1, + "haveDelayedAcc", haveDelayedAcc, + "batchDelayedAcc", batch.AfterDelayedAcc, + ) // We somehow missed a delayed message reorg; go back and look for it return delayedMessagesMismatch } From ff4802e66cda9d5f88423aa1164401fe0375f753 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 13 Sep 2024 14:11:59 -0500 Subject: [PATCH 034/210] Fix delayed message readLastAcc logging --- arbnode/inbox_reader.go | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 295f0acf4c..42e99fad66 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -228,6 +228,26 @@ func (r *InboxReader) CaughtUp() chan struct{} { return r.caughtUpChan } +type lazyHashLogging struct { + f func() common.Hash +} + +func (l lazyHashLogging) String() string { + return l.f().String() +} + +func (l lazyHashLogging) TerminalString() string { + return l.f().TerminalString() +} + +func (l lazyHashLogging) MarshalText() ([]byte, error) { + return l.f().MarshalText() +} + +func (l lazyHashLogging) Format(s fmt.State, c rune) { + l.f().Format(s, c) +} + func (r *InboxReader) run(ctx context.Context, hadError bool) error { readMode := r.config().ReadMode from, err := r.getNextBlockToRead(ctx) @@ -508,9 +528,9 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } log.Trace( "Found sequencer batches", + "firstSequenceNumber", firstBatch.SequenceNumber, "newBatchesCount", len(sequencerBatches), "duplicateBatches", duplicateBatches, - "firstSequenceNumber", firstBatch.SequenceNumber, "reorgingSequencer", reorgingSequencer, "readBeforeAcc", firstBatch.BeforeInboxAcc, "haveBeforeAcc", havePrevAcc, @@ -546,12 +566,15 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } log.Trace( "Found delayed messages", - "count", len(delayedMessages), "firstSequenceNumber", beforeCount, + "count", len(delayedMessages), "reorgingDelayed", reorgingDelayed, "readBeforeAcc", beforeAcc, "haveBeforeAcc", havePrevAcc, - "readLastAcc", delayedMessages[len(delayedMessages)-1].AfterInboxAcc, + "readLastAcc", lazyHashLogging{func() common.Hash { + // Only compute this if we need to log it, as it's expensive + return delayedMessages[len(delayedMessages)-1].AfterInboxAcc() + }}, ) } else if missingDelayed && to.Cmp(currentHeight) >= 0 { log.Trace("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight) From e64daf6d833f33699ac85f078cd280bfacf9338c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 13 Sep 2024 14:12:07 -0500 Subject: [PATCH 035/210] Don't prune the last delayed message --- arbnode/message_pruner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arbnode/message_pruner.go b/arbnode/message_pruner.go index e1bc72632b..b249bd886c 100644 --- a/arbnode/message_pruner.go +++ b/arbnode/message_pruner.go @@ -112,6 +112,10 @@ func (m *MessagePruner) prune(ctx context.Context, count arbutil.MessageIndex, g } msgCount := endBatchMetadata.MessageCount delayedCount := endBatchMetadata.DelayedMessageCount + if delayedCount > 0 { + // keep an extra delayed message for the inbox reader to use + delayedCount-- + } return m.deleteOldMessagesFromDB(ctx, msgCount, delayedCount) } From 3fc1f8818e94162eef827d22ad6926ec1f8576ee Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Mon, 16 Sep 2024 16:38:06 +0530 Subject: [PATCH 036/210] resolve conflict --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 797bfd608d..368b438d6c 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 797bfd608d932751152e4f3d227ad5aaddf73eda +Subproject commit 368b438d6c5194438bbb52965107bbd1939e8cf4 From 9968d4c9a7c620ac156516e2fd3ae0aed1738cbd Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 1 Oct 2024 16:50:55 +0530 Subject: [PATCH 037/210] [config change] Improve BlocksReExecutor implementation --- blocks_reexecutor/blocks_reexecutor.go | 153 ++++++++++++++++++------- cmd/nitro/nitro.go | 6 +- system_tests/blocks_reexecutor_test.go | 8 +- 3 files changed, 120 insertions(+), 47 deletions(-) diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index b43999a7db..e5d2fdb2b2 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -9,22 +9,27 @@ import ( "strings" "github.com/ethereum/go-ethereum/arbitrum" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/triedb" + "github.com/ethereum/go-ethereum/triedb/hashdb" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/stopwaiter" flag "github.com/spf13/pflag" ) type Config struct { - Enable bool `koanf:"enable"` - Mode string `koanf:"mode"` - StartBlock uint64 `koanf:"start-block"` - EndBlock uint64 `koanf:"end-block"` - Room int `koanf:"room"` - BlocksPerThread uint64 `koanf:"blocks-per-thread"` + Enable bool `koanf:"enable"` + Mode string `koanf:"mode"` + StartBlock uint64 `koanf:"start-block"` + EndBlock uint64 `koanf:"end-block"` + Room int `koanf:"room"` + MinBlocksPerThread uint64 `koanf:"min-blocks-per-thread"` } func (c *Config) Validate() error { @@ -48,10 +53,10 @@ var DefaultConfig = Config{ } var TestConfig = Config{ - Enable: true, - Mode: "full", - Room: runtime.NumCPU(), - BlocksPerThread: 10, + Enable: true, + Mode: "full", + Room: runtime.NumCPU(), + MinBlocksPerThread: 10, } func ConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -60,22 +65,26 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".start-block", DefaultConfig.StartBlock, "first block number of the block range for re-execution") f.Uint64(prefix+".end-block", DefaultConfig.EndBlock, "last block number of the block range for re-execution") f.Int(prefix+".room", DefaultConfig.Room, "number of threads to parallelize blocks re-execution") - f.Uint64(prefix+".blocks-per-thread", DefaultConfig.BlocksPerThread, "minimum number of blocks to execute per thread. When mode is random this acts as the size of random block range sample") + f.Uint64(prefix+".min-blocks-per-thread", DefaultConfig.MinBlocksPerThread, "minimum number of blocks to execute per thread. When mode is random this acts as the size of random block range sample") } type BlocksReExecutor struct { stopwaiter.StopWaiter - config *Config - blockchain *core.BlockChain - stateFor arbitrum.StateForHeaderFunction - done chan struct{} - fatalErrChan chan error - startBlock uint64 - currentBlock uint64 - blocksPerThread uint64 + config *Config + db state.Database + blockchain *core.BlockChain + stateFor arbitrum.StateForHeaderFunction + done chan struct{} + fatalErrChan chan error + startBlock uint64 + currentBlock uint64 + minBlocksPerThread uint64 } -func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *BlocksReExecutor { +func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrChan chan error) (*BlocksReExecutor, error) { + if blockchain.TrieDB().Scheme() == rawdb.PathScheme { + return nil, errors.New("blocksReExecutor not supported on pathdb") + } start := c.StartBlock end := c.EndBlock chainStart := blockchain.Config().ArbitrumChainParams.GenesisBlockNum @@ -92,13 +101,13 @@ func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *Block log.Warn("invalid state reexecutor's end block number, resetting to latest", "end", end, "latest", chainEnd) end = chainEnd } - blocksPerThread := uint64(10000) - if c.BlocksPerThread != 0 { - blocksPerThread = c.BlocksPerThread + minBlocksPerThread := uint64(10000) + if c.MinBlocksPerThread != 0 { + minBlocksPerThread = c.MinBlocksPerThread } if c.Mode == "random" && end != start { - // Reexecute a range of 10000 or (non-zero) c.BlocksPerThread number of blocks between start to end picked randomly - rng := blocksPerThread + // Reexecute a range of 10000 or (non-zero) c.MinBlocksPerThread number of blocks between start to end picked randomly + rng := minBlocksPerThread if rng > end-start { rng = end - start } @@ -111,32 +120,41 @@ func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *Block if start > 0 && start != chainStart { start-- } - // Divide work equally among available threads when BlocksPerThread is zero - if c.BlocksPerThread == 0 { + // Divide work equally among available threads when MinBlocksPerThread is zero + if c.MinBlocksPerThread == 0 { // #nosec G115 work := (end - start) / uint64(c.Room) if work > 0 { - blocksPerThread = work + minBlocksPerThread = work } } - return &BlocksReExecutor{ - config: c, - blockchain: blockchain, - currentBlock: end, - startBlock: start, - blocksPerThread: blocksPerThread, - done: make(chan struct{}, c.Room), - fatalErrChan: fatalErrChan, - stateFor: func(header *types.Header) (*state.StateDB, arbitrum.StateReleaseFunc, error) { - state, err := blockchain.StateAt(header.Root) - return state, arbitrum.NoopStateRelease, err - }, + trieConfig := triedb.Config{ + Preimages: false, + HashDB: hashdb.Defaults, + } + blocksReExecutor := &BlocksReExecutor{ + config: c, + db: state.NewDatabaseWithConfig(ethDb, &trieConfig), + blockchain: blockchain, + currentBlock: end, + startBlock: start, + minBlocksPerThread: minBlocksPerThread, + done: make(chan struct{}, c.Room), + fatalErrChan: fatalErrChan, } + blocksReExecutor.stateFor = func(header *types.Header) (*state.StateDB, arbitrum.StateReleaseFunc, error) { + sdb, err := state.NewDeterministic(header.Root, blocksReExecutor.db) + if err == nil { + _ = blocksReExecutor.db.TrieDB().Reference(header.Root, common.Hash{}) // Will be dereferenced later in advanceStateUpToBlock + } + return sdb, arbitrum.NoopStateRelease, err + } + return blocksReExecutor, nil } -// LaunchBlocksReExecution launches the thread to apply blocks of range [currentBlock-s.config.BlocksPerThread, currentBlock] to the last available valid state +// LaunchBlocksReExecution launches the thread to apply blocks of range [currentBlock-s.config.MinBlocksPerThread, currentBlock] to the last available valid state func (s *BlocksReExecutor) LaunchBlocksReExecution(ctx context.Context, currentBlock uint64) uint64 { - start := arbmath.SaturatingUSub(currentBlock, s.blocksPerThread) + start := arbmath.SaturatingUSub(currentBlock, s.minBlocksPerThread) if start < s.startBlock { start = s.startBlock } @@ -149,8 +167,8 @@ func (s *BlocksReExecutor) LaunchBlocksReExecution(ctx context.Context, currentB defer release() start = startHeader.Number.Uint64() s.LaunchThread(func(ctx context.Context) { - _, err := arbitrum.AdvanceStateUpToBlock(ctx, s.blockchain, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader, nil) - if err != nil { + log.Info("Starting reexecution of blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) + if err := s.advanceStateUpToBlock(ctx, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader); err != nil { s.fatalErrChan <- fmt.Errorf("blocksReExecutor errored advancing state from block %d to block %d, err: %w", start, currentBlock, err) } else { log.Info("Successfully reexecuted blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) @@ -199,3 +217,50 @@ func (s *BlocksReExecutor) Start(ctx context.Context, done chan struct{}) { func (s *BlocksReExecutor) StopAndWait() { s.StopWaiter.StopAndWait() } + +func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected common.Hash, blockNumber uint64) (*state.StateDB, error) { + result, err := statedb.Commit(blockNumber, true) + if err != nil { + return nil, err + } + if result != expected { + return nil, fmt.Errorf("bad root hash expected: %v got: %v", expected, result) + } + _ = s.db.TrieDB().Reference(result, common.Hash{}) + return state.New(result, statedb.Database(), nil) +} + +func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *state.StateDB, targetHeader *types.Header, lastAvailableHeader *types.Header) error { + targetBlockNumber := targetHeader.Number.Uint64() + blockToRecreate := lastAvailableHeader.Number.Uint64() + 1 + prevHash := lastAvailableHeader.Hash() + lastRoot := lastAvailableHeader.Root + defer func() { + if (lastRoot != common.Hash{}) { + _ = s.db.TrieDB().Dereference(lastRoot) + } + }() + var block *types.Block + var err error + for ctx.Err() == nil { + state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, targetHeader, blockToRecreate, prevHash, nil) + if err != nil { + return err + } + prevHash = block.Hash() + state, err = s.commitStateAndVerify(state, block.Root(), block.NumberU64()) + if err != nil { + return fmt.Errorf("failed committing state for block %d : %w", blockToRecreate, err) + } + _ = s.db.TrieDB().Dereference(lastRoot) + lastRoot = block.Root() + if blockToRecreate >= targetBlockNumber { + if block.Hash() != targetHeader.Hash() { + return fmt.Errorf("blockHash doesn't match when recreating number: %d expected: %v got: %v", blockToRecreate, targetHeader.Hash(), block.Hash()) + } + return nil + } + blockToRecreate++ + } + return ctx.Err() +} diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index bc2155a475..4fa49d4187 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -470,7 +470,11 @@ func mainImpl() int { var blocksReExecutor *blocksreexecutor.BlocksReExecutor if nodeConfig.BlocksReExecutor.Enable && l2BlockChain != nil { - blocksReExecutor = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, fatalErrChan) + blocksReExecutor, err = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, chainDb, fatalErrChan) + if err != nil { + log.Error("error initializing blocksReExecutor", "err", err) + return 1 + } if nodeConfig.Init.ThenQuit { if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil { log.Error("error populating stylus target cache", "err", err) diff --git a/system_tests/blocks_reexecutor_test.go b/system_tests/blocks_reexecutor_test.go index c6a7181c46..1a97919e66 100644 --- a/system_tests/blocks_reexecutor_test.go +++ b/system_tests/blocks_reexecutor_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" blocksreexecutor "github.com/offchainlabs/nitro/blocks_reexecutor" ) @@ -13,6 +14,7 @@ func TestBlocksReExecutorModes(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, false) + builder.execConfig.Caching.StateScheme = rawdb.HashScheme cleanup := builder.Build(t) defer cleanup() @@ -37,7 +39,8 @@ func TestBlocksReExecutorModes(t *testing.T) { // Reexecute blocks at mode full success := make(chan struct{}) - executorFull := blocksreexecutor.New(&blocksreexecutor.TestConfig, blockchain, feedErrChan) + executorFull, err := blocksreexecutor.New(&blocksreexecutor.TestConfig, blockchain, builder.L2.ExecNode.ChainDB, feedErrChan) + Require(t, err) executorFull.Start(ctx, success) select { case err := <-feedErrChan: @@ -49,7 +52,8 @@ func TestBlocksReExecutorModes(t *testing.T) { success = make(chan struct{}) c := &blocksreexecutor.TestConfig c.Mode = "random" - executorRandom := blocksreexecutor.New(c, blockchain, feedErrChan) + executorRandom, err := blocksreexecutor.New(c, blockchain, builder.L2.ExecNode.ChainDB, feedErrChan) + Require(t, err) executorRandom.Start(ctx, success) select { case err := <-feedErrChan: From b550510b7a93406f954b30dd8e6d9596ba53ec08 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 2 Oct 2024 11:33:38 +0530 Subject: [PATCH 038/210] address PR comments --- blocks_reexecutor/blocks_reexecutor.go | 46 ++++++++++++++++---------- go-ethereum | 2 +- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index e5d2fdb2b2..c71c5b194e 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -30,6 +30,7 @@ type Config struct { EndBlock uint64 `koanf:"end-block"` Room int `koanf:"room"` MinBlocksPerThread uint64 `koanf:"min-blocks-per-thread"` + TrieCleanLimit int `koanf:"trie-clean-limit"` } func (c *Config) Validate() error { @@ -57,6 +58,7 @@ var TestConfig = Config{ Mode: "full", Room: runtime.NumCPU(), MinBlocksPerThread: 10, + TrieCleanLimit: 600, } func ConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -66,6 +68,7 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".end-block", DefaultConfig.EndBlock, "last block number of the block range for re-execution") f.Int(prefix+".room", DefaultConfig.Room, "number of threads to parallelize blocks re-execution") f.Uint64(prefix+".min-blocks-per-thread", DefaultConfig.MinBlocksPerThread, "minimum number of blocks to execute per thread. When mode is random this acts as the size of random block range sample") + f.Int(prefix+".trie-clean-limit", DefaultConfig.TrieCleanLimit, "memory allowance (MB) to use for caching trie nodes in memory") } type BlocksReExecutor struct { @@ -128,9 +131,11 @@ func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrC minBlocksPerThread = work } } + hashConfig := *hashdb.Defaults + hashConfig.CleanCacheSize = c.TrieCleanLimit * 1024 * 1024 trieConfig := triedb.Config{ Preimages: false, - HashDB: hashdb.Defaults, + HashDB: &hashConfig, } blocksReExecutor := &BlocksReExecutor{ config: c, @@ -146,6 +151,10 @@ func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrC sdb, err := state.NewDeterministic(header.Root, blocksReExecutor.db) if err == nil { _ = blocksReExecutor.db.TrieDB().Reference(header.Root, common.Hash{}) // Will be dereferenced later in advanceStateUpToBlock + stateReleaseFunc := func() { + _ = blocksReExecutor.db.TrieDB().Dereference(header.Root) + } + return sdb, stateReleaseFunc, err } return sdb, arbitrum.NoopStateRelease, err } @@ -163,12 +172,10 @@ func (s *BlocksReExecutor) LaunchBlocksReExecution(ctx context.Context, currentB s.fatalErrChan <- fmt.Errorf("blocksReExecutor failed to get last available state while searching for state at %d, err: %w", start, err) return s.startBlock } - // NoOp - defer release() start = startHeader.Number.Uint64() s.LaunchThread(func(ctx context.Context) { log.Info("Starting reexecution of blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) - if err := s.advanceStateUpToBlock(ctx, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader); err != nil { + if err := s.advanceStateUpToBlock(ctx, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader, release); err != nil { s.fatalErrChan <- fmt.Errorf("blocksReExecutor errored advancing state from block %d to block %d, err: %w", start, currentBlock, err) } else { log.Info("Successfully reexecuted blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) @@ -218,27 +225,32 @@ func (s *BlocksReExecutor) StopAndWait() { s.StopWaiter.StopAndWait() } -func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected common.Hash, blockNumber uint64) (*state.StateDB, error) { +func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected common.Hash, blockNumber uint64) (*state.StateDB, arbitrum.StateReleaseFunc, error) { result, err := statedb.Commit(blockNumber, true) if err != nil { - return nil, err + return nil, arbitrum.NoopStateRelease, err } if result != expected { - return nil, fmt.Errorf("bad root hash expected: %v got: %v", expected, result) + return nil, arbitrum.NoopStateRelease, fmt.Errorf("bad root hash expected: %v got: %v", expected, result) + } + sdb, err := state.New(result, statedb.Database(), nil) + if err == nil { + _ = s.db.TrieDB().Reference(result, common.Hash{}) + stateReleaseFunc := func() { + _ = s.db.TrieDB().Dereference(result) + } + return sdb, stateReleaseFunc, nil } - _ = s.db.TrieDB().Reference(result, common.Hash{}) - return state.New(result, statedb.Database(), nil) + return sdb, arbitrum.NoopStateRelease, err } -func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *state.StateDB, targetHeader *types.Header, lastAvailableHeader *types.Header) error { +func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *state.StateDB, targetHeader *types.Header, lastAvailableHeader *types.Header, lastRelease arbitrum.StateReleaseFunc) error { targetBlockNumber := targetHeader.Number.Uint64() blockToRecreate := lastAvailableHeader.Number.Uint64() + 1 prevHash := lastAvailableHeader.Hash() - lastRoot := lastAvailableHeader.Root + var stateRelease arbitrum.StateReleaseFunc defer func() { - if (lastRoot != common.Hash{}) { - _ = s.db.TrieDB().Dereference(lastRoot) - } + lastRelease() }() var block *types.Block var err error @@ -248,12 +260,12 @@ func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *sta return err } prevHash = block.Hash() - state, err = s.commitStateAndVerify(state, block.Root(), block.NumberU64()) + state, stateRelease, err = s.commitStateAndVerify(state, block.Root(), block.NumberU64()) if err != nil { return fmt.Errorf("failed committing state for block %d : %w", blockToRecreate, err) } - _ = s.db.TrieDB().Dereference(lastRoot) - lastRoot = block.Root() + lastRelease() + lastRelease = stateRelease if blockToRecreate >= targetBlockNumber { if block.Hash() != targetHeader.Hash() { return fmt.Errorf("blockHash doesn't match when recreating number: %d expected: %v got: %v", blockToRecreate, targetHeader.Hash(), block.Hash()) diff --git a/go-ethereum b/go-ethereum index b068464bf5..fece13e75a 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit b068464bf59ab5414f72c2d4aba855b8af5edc17 +Subproject commit fece13e75a3448d5ef53e72a7d46ebb6118575ad From 5c4967db0712146f143f2e800562f26db633931f Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Wed, 2 Oct 2024 14:07:27 +0530 Subject: [PATCH 039/210] fix lint error --- blocks_reexecutor/blocks_reexecutor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index c71c5b194e..c6083a9ad5 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -154,7 +154,7 @@ func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrC stateReleaseFunc := func() { _ = blocksReExecutor.db.TrieDB().Dereference(header.Root) } - return sdb, stateReleaseFunc, err + return sdb, stateReleaseFunc, nil } return sdb, arbitrum.NoopStateRelease, err } From edeaf8856d0ea0a5f2a98366f3a79707b0822d84 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 7 Oct 2024 12:28:13 -0300 Subject: [PATCH 040/210] Adjusts benchbin's args to have the same names as prover's args --- arbitrator/bench/src/bin.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 60a7036e2b..f9bd85ce53 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -18,13 +18,13 @@ use prover::prepare::prepare_machine; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { - /// Path to a preimages text file + /// Path to a preimages json file #[arg(short, long)] - preimages_path: PathBuf, + json_inputs: PathBuf, /// Path to a machine.wavm.br #[arg(short, long)] - machine_path: PathBuf, + binary: PathBuf, } fn main() -> eyre::Result<()> { @@ -33,7 +33,7 @@ fn main() -> eyre::Result<()> { println!("Running benchmark with always merkleize feature on"); for step_size in step_sizes { - let mut machine = prepare_machine(args.preimages_path.clone(), args.machine_path.clone())?; + let mut machine = prepare_machine(args.json_inputs.clone(), args.binary.clone())?; let _ = machine.hash(); let mut hash_times = vec![]; let mut step_times = vec![]; From 10436295450ca68103cd0c8a6bc51a2c0f3ceccc Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 14:34:20 -0300 Subject: [PATCH 041/210] Bump go-ethereum --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 3686062434..72e4db5d66 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 3686062434f9030e5fccf9bdd9329b8d0f2a86a5 +Subproject commit 72e4db5d667da17ccb8b10e38e2e99e5b6b4c3d5 From 0e32d6b704a52f6f82e3cbd7e44a1b632fa81429 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 15:10:19 -0300 Subject: [PATCH 042/210] Add nil-checks to arbitrum tracing hooks --- arbos/programs/api.go | 4 +++- arbos/util/tracing.go | 4 ++-- arbos/util/transfer.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 3e59031b2d..5ec8c97207 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -254,7 +254,9 @@ func newApiClosures( return memoryModel.GasCost(pages, open, ever) } captureHostio := func(name string, args, outs []byte, startInk, endInk uint64) { - tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) + if tracingInfo.Tracer != nil && tracingInfo.Tracer.CaptureStylusHostio != nil { + tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) + } tracingInfo.CaptureEVMTraceForHostio(name, args, outs, startInk, endInk) } diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index 64a8bcd6a2..8effee256c 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -63,7 +63,7 @@ func (info *TracingInfo) RecordStorageGet(key common.Hash) { if tracer.OnOpcode != nil { tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil) } - } else { + } else if tracer.CaptureArbitrumStorageGet != nil { tracer.CaptureArbitrumStorageGet(key, info.Depth, info.Scenario == TracingBeforeEVM) } } @@ -79,7 +79,7 @@ func (info *TracingInfo) RecordStorageSet(key, value common.Hash) { if tracer.OnOpcode != nil { tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil) } - } else { + } else if tracer.CaptureArbitrumStorageSet != nil { tracer.CaptureArbitrumStorageSet(key, value, info.Depth, info.Scenario == TracingBeforeEVM) } } diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index 32ef4d1bd0..e186dee0fa 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -36,7 +36,7 @@ func TransferBalance( return errors.New("tracing scenario mismatch") } - if scenario != TracingDuringEVM { + if scenario != TracingDuringEVM && tracer.CaptureArbitrumTransfer != nil { tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) } else { fromCopy := from From e7139f5786bbd01a4415ab8fda2e15387558339f Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 15:10:43 -0300 Subject: [PATCH 043/210] Fix OnExit tracing call --- arbos/util/tracing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index 8effee256c..fb39460d44 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -122,7 +122,7 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil) } if tracer.OnExit != nil { - tracer.OnExit(depth+1, nil, 0, nil, false) + tracer.OnExit(depth, nil, 0, nil, false) } popScope := &vm.ScopeContext{ From b06c136898556870cf59921ad7fbc182dcfbb8ce Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 15:11:02 -0300 Subject: [PATCH 044/210] Fix stylus tracer --- execution/gethexec/stylus_tracer.go | 33 ++++++++--------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/execution/gethexec/stylus_tracer.go b/execution/gethexec/stylus_tracer.go index f054c5cb0b..dc7e5ae0a4 100644 --- a/execution/gethexec/stylus_tracer.go +++ b/execution/gethexec/stylus_tracer.go @@ -77,16 +77,9 @@ func newStylusTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, return &tracers.Tracer{ Hooks: &tracing.Hooks{ - OnExit: t.OnExit, - OnEnter: t.OnEnter, - OnOpcode: t.OnOpcode, - OnFault: t.OnFault, - OnTxStart: t.OnTxStart, - OnTxEnd: t.OnTxEnd, - CaptureArbitrumTransfer: t.CaptureArbitrumTransfer, - CaptureArbitrumStorageGet: t.CaptureArbitrumStorageGet, - CaptureArbitrumStorageSet: t.CaptureArbitrumStorageSet, - CaptureStylusHostio: t.CaptureStylusHostio, + OnEnter: t.OnEnter, + OnExit: t.OnExit, + CaptureStylusHostio: t.CaptureStylusHostio, }, GetResult: t.GetResult, Stop: t.Stop, @@ -127,6 +120,9 @@ func (t *stylusTracer) OnEnter(depth int, typ byte, from common.Address, to comm if t.interrupt.Load() { return } + if depth == 0 { + return + } // This function adds the prefix evm_ because it assumes the opcode came from the EVM. // If the opcode comes from WASM, the CaptureStylusHostio function will remove the evm prefix. @@ -161,6 +157,9 @@ func (t *stylusTracer) OnExit(depth int, output []byte, gasUsed uint64, _ error, if t.interrupt.Load() { return } + if depth == 0 { + return + } var err error t.open, err = t.stack.Pop() if err != nil { @@ -199,17 +198,3 @@ func (t *stylusTracer) Stop(err error) { t.reason = err t.interrupt.Store(true) } - -// Unimplemented EVMLogger interface methods - -func (t *stylusTracer) CaptureArbitrumTransfer(from, to *common.Address, value *big.Int, before bool, purpose string) { -} -func (t *stylusTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} -func (t *stylusTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (t *stylusTracer) OnOpcode(pc uint64, opcode byte, gas, cost uint64, scope tracing.OpContext, rData []byte, depth int, err error) { -} -func (t *stylusTracer) OnFault(pc uint64, op byte, gas, cost uint64, _ tracing.OpContext, depth int, err error) { -} -func (t *stylusTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction, from common.Address) { -} -func (t *stylusTracer) OnTxEnd(receipt *types.Receipt, err error) {} From 3a61eb3efc7bab2d64062c3504df571d32b47535 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 15:13:14 -0300 Subject: [PATCH 045/210] Remove unused import --- execution/gethexec/stylus_tracer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/execution/gethexec/stylus_tracer.go b/execution/gethexec/stylus_tracer.go index dc7e5ae0a4..cb4e858048 100644 --- a/execution/gethexec/stylus_tracer.go +++ b/execution/gethexec/stylus_tracer.go @@ -14,7 +14,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/tracing" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/log" From 74c82fe7d2a8782bd91550b91a9c45c54fd6614f Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 15:26:28 -0300 Subject: [PATCH 046/210] Fix program gas tests --- system_tests/program_gas_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 119897cbfe..5fdbb147f5 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -400,14 +400,15 @@ func evmOpcodesGasUsage(ctx context.Context, rpcClient rpc.ClientInterface, tx * // in the caller's depth. Then, we subtract the gas before the call by the // gas after the call returned. var gasAfterCall uint64 + var found bool for j := i + 1; j < len(result.StructLogs); j++ { if result.StructLogs[j].Depth == result.StructLogs[i].Depth { // back to the original call gasAfterCall = result.StructLogs[j].Gas + result.StructLogs[j].GasCost - break + found = true } } - if gasAfterCall == 0 { + if !found { return nil, fmt.Errorf("malformed log: didn't get back to call original depth") } if i == 0 { From 8dce92c331f6267e3337ca65adb62217bfcd3102 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 17:59:44 -0300 Subject: [PATCH 047/210] Fix sum gas comparison --- system_tests/program_gas_test.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 5fdbb147f5..64d2585f89 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -122,20 +122,23 @@ func TestProgramStorageCost(t *testing.T) { writeZeroData = multicallAppendStore(writeZeroData, slot, common.Hash{}, false) } + writePair := compareGasPair{vm.SSTORE, "storage_flush_cache"} + readPair := compareGasPair{vm.SLOAD, "storage_load_bytes32"} + for _, tc := range []struct { name string data []byte + pair compareGasPair }{ - {"initialWrite", writeRandAData}, - {"read", readData}, - {"writeAgain", writeRandBData}, - {"delete", writeZeroData}, - {"readZeros", readData}, - {"writeAgainAgain", writeRandAData}, + {"initialWrite", writeRandAData, writePair}, + {"read", readData, readPair}, + {"writeAgain", writeRandBData, writePair}, + {"delete", writeZeroData, writePair}, + {"readZeros", readData, readPair}, + {"writeAgainAgain", writeRandAData, writePair}, } { t.Run(tc.name, func(t *testing.T) { - compareGasUsage(t, builder, evmMulticall, stylusMulticall, tc.data, nil, compareGasSum, 0, - compareGasPair{vm.SSTORE, "storage_flush_cache"}, compareGasPair{vm.SLOAD, "storage_load_bytes32"}) + compareGasUsage(t, builder, evmMulticall, stylusMulticall, tc.data, nil, compareGasSum, 0, tc.pair) }) } } @@ -360,10 +363,12 @@ func compareGasUsage( } case compareGasSum: evmSum := float64(0) + for _, v := range evmGasUsage[opcode] { + evmSum += float64(v) + } stylusSum := float64(0) - for i := range evmGasUsage[opcode] { - evmSum += float64(evmGasUsage[opcode][i]) - stylusSum += stylusGasUsage[hostio][i] + for _, v := range stylusGasUsage[hostio] { + stylusSum += v } t.Logf("evm %v usage: %v - stylus %v usage: %v", opcode, evmSum, hostio, stylusSum) checkPercentDiff(t, evmSum, stylusSum, maxAllowedDifference) From 9e6cdc77de4f4adeea0f4f83fdd1a4731c8d400a Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Mon, 7 Oct 2024 18:39:35 -0300 Subject: [PATCH 048/210] Fix call program gas-cost tests --- system_tests/program_gas_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 64d2585f89..03f63ff39e 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -390,6 +390,10 @@ func evmOpcodesGasUsage(ctx context.Context, rpcClient rpc.ClientInterface, tx * op := vm.StringToOp(result.StructLogs[i].Op) gasUsed := uint64(0) if op == vm.CALL || op == vm.STATICCALL || op == vm.DELEGATECALL || op == vm.CREATE || op == vm.CREATE2 { + if result.StructLogs[i].GasCost == 0 { + // ignore mock call emitted by arbos + continue + } // For the CALL* opcodes, the GasCost in the tracer represents the gas sent // to the callee contract, which is 63/64 of the remaining gas. This happens // because the tracer is evaluated before the call is executed, so the EVM @@ -411,6 +415,7 @@ func evmOpcodesGasUsage(ctx context.Context, rpcClient rpc.ClientInterface, tx * // back to the original call gasAfterCall = result.StructLogs[j].Gas + result.StructLogs[j].GasCost found = true + break } } if !found { From d989410fc6c33faa7d6b2ad5777323edc2c792f7 Mon Sep 17 00:00:00 2001 From: cuiweixie <523516579@qq.com> Date: Tue, 8 Oct 2024 22:23:31 +0800 Subject: [PATCH 049/210] refactor: using maps.Clone --- das/reader_aggregator_strategies.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/das/reader_aggregator_strategies.go b/das/reader_aggregator_strategies.go index 8e10d52c16..e072fdd85c 100644 --- a/das/reader_aggregator_strategies.go +++ b/das/reader_aggregator_strategies.go @@ -5,6 +5,7 @@ package das import ( "errors" + "maps" "math/rand" "sort" "sync" @@ -33,10 +34,7 @@ func (s *abstractAggregatorStrategy) update(readers []daprovider.DASReader, stat s.readers = make([]daprovider.DASReader, len(readers)) copy(s.readers, readers) - s.stats = make(map[daprovider.DASReader]readerStats) - for k, v := range stats { - s.stats[k] = v - } + s.stats = maps.Clone(stats) } // Exponentially growing Explore Exploit Strategy From a5ed6d0d1d9d52268f89dd4bc616eef8675a9d06 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 9 Oct 2024 22:42:55 -0500 Subject: [PATCH 050/210] Explicitly create zombies for geth v1.14.2 --- arbos/util/transfer.go | 10 +++++----- go-ethereum | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index 1240928eb6..d7951383e0 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -7,9 +7,10 @@ package util import ( "errors" "fmt" - "github.com/ethereum/go-ethereum/core/tracing" "math/big" + "github.com/ethereum/go-ethereum/core/tracing" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" @@ -34,11 +35,10 @@ func TransferBalance( if arbmath.BigLessThan(balance.ToBig(), amount) { return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) } - evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) - if evm.Context.ArbOSVersion >= 30 { - // ensure the from account is "touched" for EIP-161 - evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer) + if evm.Context.ArbOSVersion < 30 && amount.Sign() == 0 { + evm.StateDB.CreateZombieIfDeleted(*from) } + evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) } if to != nil { evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) diff --git a/go-ethereum b/go-ethereum index 25b12e8998..0adf3d1a79 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 25b12e89986ee91c7a49cf3afb414b0e8b3b0653 +Subproject commit 0adf3d1a797e12f43b6d257827bd75a9d08e4ac5 From a0be0412986c75f5f3a53bb24d34a9fa2867fb4a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 11 Oct 2024 18:43:03 +0530 Subject: [PATCH 051/210] update submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 72e4db5d66..64718d37c1 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 72e4db5d667da17ccb8b10e38e2e99e5b6b4c3d5 +Subproject commit 64718d37c11aee14a85a6cda740e094a6ceaea6c From 16cdbeb4d6d698ade4cf8d3627e0b2baf234d49d Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 11 Oct 2024 18:54:17 +0530 Subject: [PATCH 052/210] Trigger Build From af4c7b53ade34583190961649d1922db8607497f Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 15 Oct 2024 11:31:33 +0530 Subject: [PATCH 053/210] Test precompile methods related to stylus --- system_tests/program_test.go | 128 +++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 4755096b26..61a157e5f8 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1242,6 +1242,134 @@ func testSdkStorage(t *testing.T, jit bool) { check() } +func TestStylusPrecompileMethodsSimple(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + cleanup := builder.Build(t) + defer cleanup() + + arbOwner, err := pgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) + Require(t, err) + arbDebug, err := pgen.NewArbDebug(types.ArbDebugAddress, builder.L2.Client) + Require(t, err) + arbWasm, err := pgen.NewArbWasm(types.ArbWasmAddress, builder.L2.Client) + Require(t, err) + + ensure := func(tx *types.Transaction, err error) *types.Receipt { + t.Helper() + Require(t, err) + receipt, err := EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + return receipt + } + + ownerAuth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + ensure(arbDebug.BecomeChainOwner(&ownerAuth)) + + // ArbOwner precompile methods + testConst := uint16(10) + ensure(arbOwner.SetInkPrice(&ownerAuth, uint32(testConst))) + ensure(arbOwner.SetWasmMaxStackDepth(&ownerAuth, uint32(testConst))) + ensure(arbOwner.SetWasmFreePages(&ownerAuth, testConst)) + ensure(arbOwner.SetWasmPageGas(&ownerAuth, testConst)) + ensure(arbOwner.SetWasmPageLimit(&ownerAuth, testConst)) + // Setting low values of gas and cached parameters ensures when MinInitGas is called on ArbWasm precompile, + // the returned values would be programs.MinInitGasUnits and programs.MinCachedGasUnits + ensure(arbOwner.SetWasmMinInitGas(&ownerAuth, 1, 1)) + ensure(arbOwner.SetWasmInitCostScalar(&ownerAuth, uint64(testConst))) + expectedExpiryDays := uint16(1) + ensure(arbOwner.SetWasmExpiryDays(&ownerAuth, expectedExpiryDays)) + ensure(arbOwner.SetWasmKeepaliveDays(&ownerAuth, 0)) + ensure(arbOwner.SetWasmBlockCacheSize(&ownerAuth, testConst)) + + // ArbWasm precompile methods + wasm, _ := readWasmFile(t, rustFile("keccak")) + codehash := crypto.Keccak256Hash(wasm) + programAddress := deployContract(t, ctx, ownerAuth, builder.L2.Client, wasm) + + activateAuth := ownerAuth + activateAuth.Value = oneEth + ensure(arbWasm.ActivateProgram(&activateAuth, programAddress)) + + bcs, err := arbWasm.BlockCacheSize(nil) + Require(t, err) + if bcs != testConst { + t.Errorf("BlockCacheSize from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", bcs, testConst) + } + ed, err := arbWasm.ExpiryDays(nil) + Require(t, err) + if ed != expectedExpiryDays { + t.Errorf("ExpiryDays from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ed, expectedExpiryDays) + } + fp, err := arbWasm.FreePages(nil) + Require(t, err) + if fp != testConst { + t.Errorf("FreePages from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", fp, testConst) + } + ics, err := arbWasm.InitCostScalar(nil) + Require(t, err) + if ics != uint64(testConst) { + t.Errorf("InitCostScalar from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ics, testConst) + } + ip, err := arbWasm.InkPrice(nil) + Require(t, err) + if ip != uint32(testConst) { + t.Errorf("InkPrice from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ip, testConst) + } + kad, err := arbWasm.KeepaliveDays(nil) + Require(t, err) + if kad != 0 { + t.Errorf("KeepaliveDays from arbWasm precompile didnt match the value set by arbowner. have: %d, want: 0", kad) + } + msd, err := arbWasm.MaxStackDepth(nil) + Require(t, err) + if msd != uint32(testConst) { + t.Errorf("MaxStackDepth from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", msd, testConst) + } + mig, err := arbWasm.MinInitGas(nil) + Require(t, err) + if mig.Gas != programs.MinInitGasUnits { + t.Errorf("MinInitGas from arbWasm precompile didnt match the Gas value set by arbowner. have: %d, want: %d", mig.Gas, programs.MinInitGasUnits) + } + if mig.Cached != programs.MinCachedGasUnits { + t.Errorf("MinInitGas from arbWasm precompile didnt match the Cached value set by arbowner. have: %d, want: %d", mig.Cached, programs.MinCachedGasUnits) + } + pg, err := arbWasm.PageGas(nil) + Require(t, err) + if pg != testConst { + t.Errorf("PageGas from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pg, testConst) + } + pl, err := arbWasm.PageLimit(nil) + Require(t, err) + if pl != testConst { + t.Errorf("PageLimit from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pl, testConst) + } + // pageramp currently is initialPageRamp = 620674314 value in programs package + _, err = arbWasm.PageRamp(nil) + Require(t, err) + + cas, err := arbWasm.CodehashAsmSize(nil, codehash) + Require(t, err) + if cas == 0 { + t.Error("CodehashAsmSize from arbWasm precompile returned 0 value") + } + ptl, err := arbWasm.ProgramTimeLeft(nil, programAddress) + Require(t, err) + expectedExpirySeconds := (uint64(expectedExpiryDays) * 24 * 3600) + // ProgramTimeLeft returns time in seconds to expiry and the current ExpiryDays is set to 1 day + // We expect the lag of 3600 seconds to exist because program.activatedAt uses hoursSinceArbitrum that + // rounds down (the current time since ArbitrumStartTime in hours)/3600 + if expectedExpirySeconds-ptl > 3600 { + t.Errorf("ProgramTimeLeft from arbWasm precompile returned value lesser than expected. %d <= want <= %d, have: %d", expectedExpirySeconds-3600, expectedExpirySeconds, ptl) + } + // Since ArbOwner has set wasm KeepaliveDays to 0, it enables us to do this, though this shouldn't have any effect + codehashKeepaliveAuth := ownerAuth + codehashKeepaliveAuth.Value = oneEth + ensure(arbWasm.CodehashKeepalive(&codehashKeepaliveAuth, codehash)) +} + func TestProgramActivationLogs(t *testing.T) { t.Parallel() builder, auth, cleanup := setupProgramTest(t, true) From b151dca8f76830ddf9500dc815fdf40ab4271cee Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 15 Oct 2024 11:54:52 +0530 Subject: [PATCH 054/210] Add redis sentinel support --- util/redisutil/redisutil.go | 231 +++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 4 deletions(-) diff --git a/util/redisutil/redisutil.go b/util/redisutil/redisutil.go index 01ba836d5b..1587f97937 100644 --- a/util/redisutil/redisutil.go +++ b/util/redisutil/redisutil.go @@ -1,14 +1,237 @@ package redisutil -import "github.com/redis/go-redis/v9" +import ( + "fmt" + "net" + "net/url" + "sort" + "strconv" + "strings" + "time" -func RedisClientFromURL(url string) (redis.UniversalClient, error) { - if url == "" { + "github.com/redis/go-redis/v9" +) + +// RedisClientFromURL creates a new Redis client based on the provided URL. +// The URL scheme can be either `redis` or `redis+sentinel`. +func RedisClientFromURL(redisUrl string) (redis.UniversalClient, error) { + if redisUrl == "" { return nil, nil } - redisOptions, err := redis.ParseURL(url) + u, err := url.Parse(redisUrl) + if err != nil { + return nil, err + } + if u.Scheme == "redis+sentinel" { + redisOptions, err := parseFailoverRedisUrl(redisUrl) + if err != nil { + return nil, err + } + return redis.NewFailoverClient(redisOptions), nil + } + redisOptions, err := redis.ParseURL(redisUrl) if err != nil { return nil, err } return redis.NewClient(redisOptions), nil } + +// Designed using https://github.com/redis/go-redis/blob/a8590e987945b7ba050569cc3b94b8ece49e99e3/options.go#L283 as reference +// Example Usage : +// +// redis+sentinel://:@:,:,:/?dial_timeout=3&db=1&read_timeout=6s&max_retries=2 +func parseFailoverRedisUrl(redisUrl string) (*redis.FailoverOptions, error) { + u, err := url.Parse(redisUrl) + if err != nil { + return nil, err + } + o := &redis.FailoverOptions{} + o.SentinelUsername, o.SentinelPassword = getUserPassword(u) + o.SentinelAddrs = getAddressesWithDefaults(u) + f := strings.FieldsFunc(u.Path, func(r rune) bool { + return r == '/' + }) + switch len(f) { + case 0: + return nil, fmt.Errorf("redis: master name is required") + case 1: + o.DB = 0 + o.MasterName = f[0] + case 2: + o.MasterName = f[0] + var err error + if o.DB, err = strconv.Atoi(f[1]); err != nil { + return nil, fmt.Errorf("redis: invalid database number: %q", f[0]) + } + default: + return nil, fmt.Errorf("redis: invalid URL path: %s", u.Path) + } + + return setupConnParams(u, o) +} + +func getUserPassword(u *url.URL) (string, string) { + var user, password string + if u.User != nil { + user = u.User.Username() + if p, ok := u.User.Password(); ok { + password = p + } + } + return user, password +} + +func getAddressesWithDefaults(u *url.URL) []string { + urlHosts := strings.Split(u.Host, ",") + var addresses []string + for _, urlHost := range urlHosts { + host, port, err := net.SplitHostPort(urlHost) + if err != nil { + host = u.Host + } + if host == "" { + host = "localhost" + } + if port == "" { + port = "6379" + } + addresses = append(addresses, net.JoinHostPort(host, port)) + } + return addresses +} + +type queryOptions struct { + q url.Values + err error +} + +func (o *queryOptions) has(name string) bool { + return len(o.q[name]) > 0 +} + +func (o *queryOptions) string(name string) string { + vs := o.q[name] + if len(vs) == 0 { + return "" + } + delete(o.q, name) // enable detection of unknown parameters + return vs[len(vs)-1] +} + +func (o *queryOptions) strings(name string) []string { + vs := o.q[name] + delete(o.q, name) + return vs +} + +func (o *queryOptions) int(name string) int { + s := o.string(name) + if s == "" { + return 0 + } + i, err := strconv.Atoi(s) + if err == nil { + return i + } + if o.err == nil { + o.err = fmt.Errorf("redis: invalid %s number: %s", name, err) + } + return 0 +} + +func (o *queryOptions) duration(name string) time.Duration { + s := o.string(name) + if s == "" { + return 0 + } + // try plain number first + if i, err := strconv.Atoi(s); err == nil { + if i <= 0 { + // disable timeouts + return -1 + } + return time.Duration(i) * time.Second + } + dur, err := time.ParseDuration(s) + if err == nil { + return dur + } + if o.err == nil { + o.err = fmt.Errorf("redis: invalid %s duration: %w", name, err) + } + return 0 +} + +func (o *queryOptions) bool(name string) bool { + switch s := o.string(name); s { + case "true", "1": + return true + case "false", "0", "": + return false + default: + if o.err == nil { + o.err = fmt.Errorf("redis: invalid %s boolean: expected true/false/1/0 or an empty string, got %q", name, s) + } + return false + } +} + +func (o *queryOptions) remaining() []string { + if len(o.q) == 0 { + return nil + } + keys := make([]string, 0, len(o.q)) + for k := range o.q { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} + +func setupConnParams(u *url.URL, o *redis.FailoverOptions) (*redis.FailoverOptions, error) { + q := queryOptions{q: u.Query()} + + // compat: a future major release may use q.int("db") + if tmp := q.string("db"); tmp != "" { + db, err := strconv.Atoi(tmp) + if err != nil { + return nil, fmt.Errorf("redis: invalid database number: %w", err) + } + o.DB = db + } + + o.Protocol = q.int("protocol") + o.ClientName = q.string("client_name") + o.MaxRetries = q.int("max_retries") + o.MinRetryBackoff = q.duration("min_retry_backoff") + o.MaxRetryBackoff = q.duration("max_retry_backoff") + o.DialTimeout = q.duration("dial_timeout") + o.ReadTimeout = q.duration("read_timeout") + o.WriteTimeout = q.duration("write_timeout") + o.PoolFIFO = q.bool("pool_fifo") + o.PoolSize = q.int("pool_size") + o.PoolTimeout = q.duration("pool_timeout") + o.MinIdleConns = q.int("min_idle_conns") + o.MaxIdleConns = q.int("max_idle_conns") + o.MaxActiveConns = q.int("max_active_conns") + if q.has("conn_max_idle_time") { + o.ConnMaxIdleTime = q.duration("conn_max_idle_time") + } else { + o.ConnMaxIdleTime = q.duration("idle_timeout") + } + if q.has("conn_max_lifetime") { + o.ConnMaxLifetime = q.duration("conn_max_lifetime") + } else { + o.ConnMaxLifetime = q.duration("max_conn_age") + } + if q.err != nil { + return nil, q.err + } + + // any parameters left? + if r := q.remaining(); len(r) > 0 { + return nil, fmt.Errorf("redis: unexpected option: %s", strings.Join(r, ", ")) + } + + return o, nil +} From 0f7883726ef6b71a9440db323dc05cb1de066d40 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 15 Oct 2024 12:09:00 +0530 Subject: [PATCH 055/210] lint --- util/redisutil/redisutil.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/util/redisutil/redisutil.go b/util/redisutil/redisutil.go index 1587f97937..fafb816b8a 100644 --- a/util/redisutil/redisutil.go +++ b/util/redisutil/redisutil.go @@ -118,12 +118,6 @@ func (o *queryOptions) string(name string) string { return vs[len(vs)-1] } -func (o *queryOptions) strings(name string) []string { - vs := o.q[name] - delete(o.q, name) - return vs -} - func (o *queryOptions) int(name string) int { s := o.string(name) if s == "" { @@ -134,7 +128,7 @@ func (o *queryOptions) int(name string) int { return i } if o.err == nil { - o.err = fmt.Errorf("redis: invalid %s number: %s", name, err) + o.err = fmt.Errorf("redis: invalid %s number: %w", name, err) } return 0 } From 38ff8272a67acdcd8edbf34e0ba55695d365ea7e Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Fri, 18 Oct 2024 11:46:47 -0700 Subject: [PATCH 056/210] More check-build tweaks * remove last usage of `sudo` * improve version tag messaging * cleanup informational messages --- scripts/check-build.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/check-build.sh b/scripts/check-build.sh index d654405c49..518d12fbc2 100755 --- a/scripts/check-build.sh +++ b/scripts/check-build.sh @@ -21,7 +21,6 @@ EXIT_CODE=0 # Detect operating system OS=$(uname -s) echo -e "${BLUE}Detected OS: $OS${NC}" -echo -e "${BLUE}Checking prerequisites for building Nitro locally...${NC}" # Step 1: Check Docker Installation if command_exists docker; then @@ -32,7 +31,7 @@ else fi # Step 2: Check if Docker service is running -if [[ "$OS" == "Linux" ]] && ! sudo service docker status >/dev/null; then +if [[ "$OS" == "Linux" ]] && ! pidof dockerd >/dev/null; then echo -e "${YELLOW}Docker service is not running on Linux. Start it with: sudo service docker start${NC}" EXIT_CODE=1 elif [[ "$OS" == "Darwin" ]] && ! docker info >/dev/null 2>&1; then @@ -43,8 +42,12 @@ else fi # Step 3: Check the version tag -VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "dev") -echo -e "${YELLOW}You are on the version tag: $VERSION_TAG${NC}" +VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "") +if [[ -z "${VAR}" ]]; then + echo -e "${YELLOW}Untagged version of Nitro checked out, not guaranteed to build successfully.${NC}" +else + echo -e "${GREEN}You are on Nitro version tag: $VERSION_TAG${NC}" +fi # Check if submodules are properly initialized and updated if git submodule status | grep -qE '^-|\+'; then @@ -62,7 +65,6 @@ else fi # Step 5: Check prerequisites for building binaries -echo -e "${BLUE}Checking prerequisites for building Nitro's binaries...${NC}" if [[ "$OS" == "Linux" ]]; then prerequisites=(git curl make cmake npm golang clang make gotestsum wasm2wat wasm-ld python3 yarn) else @@ -128,10 +130,11 @@ else EXIT_CODE=1 fi -echo -e "${BLUE}Verification complete.${NC}" if [ $EXIT_CODE != 0 ]; then echo -e "${RED}One or more dependencies missing. $INSTALLATION_DOCS_URL${NC}" +else + echo -e "${BLUE}Build readiness check passed.${NC}" fi exit $EXIT_CODE From 2ba9a55756b0215de2ef39371dd676c0703e49a6 Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Fri, 18 Oct 2024 11:50:57 -0700 Subject: [PATCH 057/210] Improve message for untagged version --- scripts/check-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-build.sh b/scripts/check-build.sh index 518d12fbc2..ee79d12b8b 100755 --- a/scripts/check-build.sh +++ b/scripts/check-build.sh @@ -44,7 +44,7 @@ fi # Step 3: Check the version tag VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "") if [[ -z "${VAR}" ]]; then - echo -e "${YELLOW}Untagged version of Nitro checked out, not guaranteed to build successfully.${NC}" + echo -e "${YELLOW}Untagged version of Nitro checked out, may not be fully tested.${NC}" else echo -e "${GREEN}You are on Nitro version tag: $VERSION_TAG${NC}" fi From 044f70bd6312d0e71fe1dff386d9325db71f02db Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 22 Oct 2024 12:52:24 +0530 Subject: [PATCH 058/210] address PR comments --- system_tests/program_test.go | 94 +++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 9c8fe949ab..c240aaad6b 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1268,66 +1268,75 @@ func TestStylusPrecompileMethodsSimple(t *testing.T) { ownerAuth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) ensure(arbDebug.BecomeChainOwner(&ownerAuth)) - // ArbOwner precompile methods - testConst := uint16(10) - ensure(arbOwner.SetInkPrice(&ownerAuth, uint32(testConst))) - ensure(arbOwner.SetWasmMaxStackDepth(&ownerAuth, uint32(testConst))) - ensure(arbOwner.SetWasmFreePages(&ownerAuth, testConst)) - ensure(arbOwner.SetWasmPageGas(&ownerAuth, testConst)) - ensure(arbOwner.SetWasmPageLimit(&ownerAuth, testConst)) - // Setting low values of gas and cached parameters ensures when MinInitGas is called on ArbWasm precompile, - // the returned values would be programs.MinInitGasUnits and programs.MinCachedGasUnits - ensure(arbOwner.SetWasmMinInitGas(&ownerAuth, 1, 1)) - ensure(arbOwner.SetWasmInitCostScalar(&ownerAuth, uint64(testConst))) - expectedExpiryDays := uint16(1) - ensure(arbOwner.SetWasmExpiryDays(&ownerAuth, expectedExpiryDays)) - ensure(arbOwner.SetWasmKeepaliveDays(&ownerAuth, 0)) - ensure(arbOwner.SetWasmBlockCacheSize(&ownerAuth, testConst)) - - // ArbWasm precompile methods wasm, _ := readWasmFile(t, rustFile("keccak")) - codehash := crypto.Keccak256Hash(wasm) programAddress := deployContract(t, ctx, ownerAuth, builder.L2.Client, wasm) activateAuth := ownerAuth activateAuth.Value = oneEth ensure(arbWasm.ActivateProgram(&activateAuth, programAddress)) - bcs, err := arbWasm.BlockCacheSize(nil) - Require(t, err) - if bcs != testConst { - t.Errorf("BlockCacheSize from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", bcs, testConst) - } + expectedExpiryDays := uint16(1) + ensure(arbOwner.SetWasmExpiryDays(&ownerAuth, expectedExpiryDays)) ed, err := arbWasm.ExpiryDays(nil) Require(t, err) if ed != expectedExpiryDays { t.Errorf("ExpiryDays from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ed, expectedExpiryDays) } + ptl, err := arbWasm.ProgramTimeLeft(nil, programAddress) + Require(t, err) + expectedExpirySeconds := (uint64(expectedExpiryDays) * 24 * 3600) + // ProgramTimeLeft returns time in seconds to expiry and the current ExpiryDays is set to 1 day + // We expect the lag of 3600 seconds to exist because program.activatedAt uses hoursSinceArbitrum that + // rounds down (the current time since ArbitrumStartTime in hours)/3600 + if expectedExpirySeconds-ptl > 3600 { + t.Errorf("ProgramTimeLeft from arbWasm precompile returned value lesser than expected. %d <= want <= %d, have: %d", expectedExpirySeconds-3600, expectedExpirySeconds, ptl) + } + + ensure(arbOwner.SetWasmBlockCacheSize(&ownerAuth, 100)) + bcs, err := arbWasm.BlockCacheSize(nil) + Require(t, err) + if bcs != 100 { + t.Errorf("BlockCacheSize from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", bcs, 100) + } + + ensure(arbOwner.SetWasmFreePages(&ownerAuth, 3)) fp, err := arbWasm.FreePages(nil) Require(t, err) - if fp != testConst { - t.Errorf("FreePages from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", fp, testConst) + if fp != 3 { + t.Errorf("FreePages from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", fp, 3) } + + ensure(arbOwner.SetWasmInitCostScalar(&ownerAuth, uint64(4))) ics, err := arbWasm.InitCostScalar(nil) Require(t, err) - if ics != uint64(testConst) { - t.Errorf("InitCostScalar from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ics, testConst) + if ics != uint64(4) { + t.Errorf("InitCostScalar from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ics, 4) } + + ensure(arbOwner.SetInkPrice(&ownerAuth, uint32(5))) ip, err := arbWasm.InkPrice(nil) Require(t, err) - if ip != uint32(testConst) { - t.Errorf("InkPrice from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ip, testConst) + if ip != uint32(5) { + t.Errorf("InkPrice from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", ip, 5) } + + ensure(arbOwner.SetWasmKeepaliveDays(&ownerAuth, 0)) kad, err := arbWasm.KeepaliveDays(nil) Require(t, err) if kad != 0 { t.Errorf("KeepaliveDays from arbWasm precompile didnt match the value set by arbowner. have: %d, want: 0", kad) } + + ensure(arbOwner.SetWasmMaxStackDepth(&ownerAuth, uint32(6))) msd, err := arbWasm.MaxStackDepth(nil) Require(t, err) - if msd != uint32(testConst) { - t.Errorf("MaxStackDepth from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", msd, testConst) + if msd != uint32(6) { + t.Errorf("MaxStackDepth from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", msd, 6) } + + // Setting low values of gas and cached parameters ensures when MinInitGas is called on ArbWasm precompile, + // the returned values would be programs.MinInitGasUnits and programs.MinCachedGasUnits + ensure(arbOwner.SetWasmMinInitGas(&ownerAuth, 1, 1)) mig, err := arbWasm.MinInitGas(nil) Require(t, err) if mig.Gas != programs.MinInitGasUnits { @@ -1336,34 +1345,31 @@ func TestStylusPrecompileMethodsSimple(t *testing.T) { if mig.Cached != programs.MinCachedGasUnits { t.Errorf("MinInitGas from arbWasm precompile didnt match the Cached value set by arbowner. have: %d, want: %d", mig.Cached, programs.MinCachedGasUnits) } + + ensure(arbOwner.SetWasmPageGas(&ownerAuth, 7)) pg, err := arbWasm.PageGas(nil) Require(t, err) - if pg != testConst { - t.Errorf("PageGas from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pg, testConst) + if pg != 7 { + t.Errorf("PageGas from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pg, 7) } + + ensure(arbOwner.SetWasmPageLimit(&ownerAuth, 8)) pl, err := arbWasm.PageLimit(nil) Require(t, err) - if pl != testConst { - t.Errorf("PageLimit from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pl, testConst) + if pl != 8 { + t.Errorf("PageLimit from arbWasm precompile didnt match the value set by arbowner. have: %d, want: %d", pl, 8) } + // pageramp currently is initialPageRamp = 620674314 value in programs package _, err = arbWasm.PageRamp(nil) Require(t, err) + codehash := crypto.Keccak256Hash(wasm) cas, err := arbWasm.CodehashAsmSize(nil, codehash) Require(t, err) if cas == 0 { t.Error("CodehashAsmSize from arbWasm precompile returned 0 value") } - ptl, err := arbWasm.ProgramTimeLeft(nil, programAddress) - Require(t, err) - expectedExpirySeconds := (uint64(expectedExpiryDays) * 24 * 3600) - // ProgramTimeLeft returns time in seconds to expiry and the current ExpiryDays is set to 1 day - // We expect the lag of 3600 seconds to exist because program.activatedAt uses hoursSinceArbitrum that - // rounds down (the current time since ArbitrumStartTime in hours)/3600 - if expectedExpirySeconds-ptl > 3600 { - t.Errorf("ProgramTimeLeft from arbWasm precompile returned value lesser than expected. %d <= want <= %d, have: %d", expectedExpirySeconds-3600, expectedExpirySeconds, ptl) - } // Since ArbOwner has set wasm KeepaliveDays to 0, it enables us to do this, though this shouldn't have any effect codehashKeepaliveAuth := ownerAuth codehashKeepaliveAuth.Value = oneEth From 67d55aa3aae5125960b1b656b150afbdf69300bd Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 22 Oct 2024 10:29:33 -0500 Subject: [PATCH 059/210] Change trace logs to debug --- arbnode/inbox_reader.go | 20 ++++++++++---------- arbnode/inbox_tracker.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 42e99fad66..816d6d7a31 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -353,7 +353,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestDelayedCount < checkingDelayedCount { - log.Trace("Expecting to find delayed messages", "checkingDelayedCount", checkingDelayedCount, "ourLatestDelayedCount", ourLatestDelayedCount, "currentHeight", currentHeight) + log.Debug("Expecting to find delayed messages", "checkingDelayedCount", checkingDelayedCount, "ourLatestDelayedCount", ourLatestDelayedCount, "currentHeight", currentHeight) checkingDelayedCount = ourLatestDelayedCount missingDelayed = true } else if ourLatestDelayedCount > checkingDelayedCount { @@ -374,7 +374,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbDelayedAcc != l1DelayedAcc { - log.Trace("Latest delayed accumulator mismatch", "delayedSeqNum", checkingDelayedSeqNum, "dbDelayedAcc", dbDelayedAcc, "l1DelayedAcc", l1DelayedAcc) + log.Debug("Latest delayed accumulator mismatch", "delayedSeqNum", checkingDelayedSeqNum, "dbDelayedAcc", dbDelayedAcc, "l1DelayedAcc", l1DelayedAcc) reorgingDelayed = true } } @@ -392,7 +392,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestBatchCount < checkingBatchCount { - log.Trace("Expecting to find sequencer batches", "checkingBatchCount", checkingBatchCount, "ourLatestBatchCount", ourLatestBatchCount, "currentHeight", currentHeight) + log.Debug("Expecting to find sequencer batches", "checkingBatchCount", checkingBatchCount, "ourLatestBatchCount", ourLatestBatchCount, "currentHeight", currentHeight) checkingBatchCount = ourLatestBatchCount missingSequencer = true } else if ourLatestBatchCount > checkingBatchCount && config.HardReorg { @@ -412,7 +412,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbBatchAcc != l1BatchAcc { - log.Trace("Latest sequencer batch accumulator mismatch", "batchSeqNum", checkingBatchSeqNum, "dbBatchAcc", dbBatchAcc, "l1BatchAcc", l1BatchAcc) + log.Debug("Latest sequencer batch accumulator mismatch", "batchSeqNum", checkingBatchSeqNum, "dbBatchAcc", dbBatchAcc, "l1BatchAcc", l1BatchAcc) reorgingSequencer = true } } @@ -455,7 +455,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if to.Cmp(currentHeight) > 0 { to.Set(currentHeight) } - log.Trace( + log.Debug( "Looking up messages", "from", from.String(), "to", to.String(), @@ -526,7 +526,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } } } - log.Trace( + log.Debug( "Found sequencer batches", "firstSequenceNumber", firstBatch.SequenceNumber, "newBatchesCount", len(sequencerBatches), @@ -537,7 +537,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { "readLastAcc", readLastAcc, ) } else if missingSequencer && to.Cmp(currentHeight) >= 0 { - log.Trace("Didn't find expected sequencer batches", "from", from, "to", to, "currentHeight", currentHeight) + log.Debug("Didn't find expected sequencer batches", "from", from, "to", to, "currentHeight", currentHeight) // We were missing sequencer batches but didn't find any. // This must mean that the sequencer batches are in the past. reorgingSequencer = true @@ -564,7 +564,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } havePrevAcc = haveAcc } - log.Trace( + log.Debug( "Found delayed messages", "firstSequenceNumber", beforeCount, "count", len(delayedMessages), @@ -572,12 +572,12 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { "readBeforeAcc", beforeAcc, "haveBeforeAcc", havePrevAcc, "readLastAcc", lazyHashLogging{func() common.Hash { - // Only compute this if we need to log it, as it's expensive + // Only compute this if we need to log it, as it's somewhat expensive return delayedMessages[len(delayedMessages)-1].AfterInboxAcc() }}, ) } else if missingDelayed && to.Cmp(currentHeight) >= 0 { - log.Trace("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight) + log.Debug("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight) // We were missing delayed messages but didn't find any. // This must mean that the delayed messages are in the past. reorgingDelayed = true diff --git a/arbnode/inbox_tracker.go b/arbnode/inbox_tracker.go index 862610100c..d2ab5ef1f5 100644 --- a/arbnode/inbox_tracker.go +++ b/arbnode/inbox_tracker.go @@ -709,7 +709,7 @@ func (t *InboxTracker) AddSequencerBatches(ctx context.Context, client arbutil.L return err } if notFound || haveDelayedAcc != batch.AfterDelayedAcc { - log.Trace( + log.Debug( "Delayed message accumulator doesn't match sequencer batch", "batch", batch.SequenceNumber, "delayedPosition", batch.AfterDelayedCount-1, From 6d9067acef4e0add5105cb952be3a04d73ddad4e Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 23 Oct 2024 11:39:51 +0530 Subject: [PATCH 060/210] Add flags and other info for nitro --dev --- arbnode/inbox_test.go | 2 +- arbos/arbosState/initialization_test.go | 2 +- arbos/arbosState/initialize.go | 5 ++++- cmd/conf/init.go | 3 +++ cmd/nitro/init.go | 9 ++++++++- cmd/util/confighelpers/configuration.go | 3 ++- execution/gethexec/blockchain.go | 8 ++++---- system_tests/common_test.go | 4 ++-- system_tests/state_fuzz_test.go | 1 + 9 files changed, 26 insertions(+), 11 deletions(-) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index e588ef399b..78c50f9de7 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -61,7 +61,7 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* initReader := statetransfer.NewMemoryInitDataReader(&initData) cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) - bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefault.TxLookupLimit, 0) + bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefault.TxLookupLimit, 0, common.Address{}) if err != nil { Fail(t, err) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 5e605b8bd2..608ccfd194 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -64,7 +64,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin chainConfig := params.ArbitrumDevTestChainConfig() cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) - stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) + stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0, common.Address{}) Require(t, err) triedbConfig := cacheConfig.TriedbConfig() diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 427bdc3087..3045df47d2 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -54,7 +54,7 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) } -func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { +func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint, chainOwner common.Address) (root common.Hash, err error) { triedbConfig := cacheConfig.TriedbConfig() triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) @@ -96,6 +96,9 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, log.Crit("failed to open the ArbOS state", "error", err) } + if chainOwner != (common.Address{}) { + arbosState.ChainOwners().Add(chainOwner) + } addrTable := arbosState.AddressTable() addrTableSize, err := addrTable.Size() if err != nil { diff --git a/cmd/conf/init.go b/cmd/conf/init.go index f01d99f8b7..0e624e8f61 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -20,6 +20,7 @@ type InitConfig struct { DownloadPoll time.Duration `koanf:"download-poll"` DevInit bool `koanf:"dev-init"` DevInitAddress string `koanf:"dev-init-address"` + DevMaxCodeSize uint64 `koanf:"MaxCodeSize"` DevInitBlockNum uint64 `koanf:"dev-init-blocknum"` Empty bool `koanf:"empty"` ImportWasm bool `koanf:"import-wasm"` @@ -47,6 +48,7 @@ var InitConfigDefault = InitConfig{ DownloadPoll: time.Minute, DevInit: false, DevInitAddress: "", + DevMaxCodeSize: 0, DevInitBlockNum: 0, Empty: false, ImportWasm: false, @@ -75,6 +77,7 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".dev-init", InitConfigDefault.DevInit, "init with dev data (1 account with balance) instead of file import") f.String(prefix+".dev-init-address", InitConfigDefault.DevInitAddress, "Address of dev-account. Leave empty to use the dev-wallet.") f.Uint64(prefix+".dev-init-blocknum", InitConfigDefault.DevInitBlockNum, "Number of preinit blocks. Must exist in ancient database.") + f.Uint64(prefix+".dev-max-code-size", InitConfigDefault.DevMaxCodeSize, "Max code size for dev accounts") f.Bool(prefix+".empty", InitConfigDefault.Empty, "init with empty state") f.Bool(prefix+".import-wasm", InitConfigDefault.ImportWasm, "if set, import the wasm directory when downloading a database (contains executable code - only use with highly trusted source)") f.Bool(prefix+".then-quit", InitConfigDefault.ThenQuit, "quit after init is done") diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index f0b303817c..9ff5431e2c 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -716,6 +716,9 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if err != nil { return chainDb, nil, err } + if config.Init.DevInit && config.Init.DevMaxCodeSize != 0 { + chainConfig.ArbitrumChainParams.MaxCodeSize = config.Init.DevMaxCodeSize + } testUpdateTxIndex(chainDb, chainConfig, &txIndexWg) ancients, err := chainDb.Ancients() if err != nil { @@ -788,7 +791,11 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) && config.Init.Force { return chainDb, nil, errors.New("It is not possible to force init with non-empty blockchain when using path scheme") } - l2BlockChain, err = gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initDataReader, chainConfig, parsedInitMessage, config.Execution.TxLookupLimit, config.Init.AccountsPerSync) + var chainOwner common.Address + if config.Init.DevInit { + chainOwner = common.HexToAddress(config.Init.DevInitAddress) + } + l2BlockChain, err = gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initDataReader, chainConfig, parsedInitMessage, config.Execution.TxLookupLimit, config.Init.AccountsPerSync, chainOwner) if err != nil { return chainDb, nil, err } diff --git a/cmd/util/confighelpers/configuration.go b/cmd/util/confighelpers/configuration.go index 19b5b1a24c..c60eef961a 100644 --- a/cmd/util/confighelpers/configuration.go +++ b/cmd/util/confighelpers/configuration.go @@ -209,7 +209,8 @@ func devFlagArgs() []string { "--init.empty=false", "--http.port", "8547", "--http.addr", "127.0.0.1", - } + "--http.api=net,web3,eth,arb,arbdebug,debug", +, } return args } diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index fda8f49093..7ecf2e0e2b 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -125,7 +125,7 @@ func (c *CachingConfig) Validate() error { return c.validateStateScheme() } -func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint) error { +func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint, chainOwner common.Address) error { EmptyHash := common.Hash{} prevHash := EmptyHash prevDifficulty := big.NewInt(0) @@ -146,7 +146,7 @@ func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, } timestamp = prevHeader.Time } - stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, cacheConfig, initData, chainConfig, initMessage, timestamp, accountsPerSync) + stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, cacheConfig, initData, chainConfig, initMessage, timestamp, accountsPerSync, chainOwner) if err != nil { return err } @@ -213,7 +213,7 @@ func GetBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, chainC return core.NewBlockChain(chainDb, cacheConfig, chainConfig, nil, nil, engine, vmConfig, shouldPreserveFalse, &txLookupLimit) } -func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint) (*core.BlockChain, error) { +func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint, chainOwner common.Address) (*core.BlockChain, error) { emptyBlockChain := rawdb.ReadHeadHeader(chainDb) == nil if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) { // When using path scheme, and the stored state trie is not empty, @@ -222,7 +222,7 @@ func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig return GetBlockChain(chainDb, cacheConfig, chainConfig, txLookupLimit) } - err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync) + err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync, chainOwner) if err != nil { return nil, err } diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 027a41d875..44c0e8f740 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1346,7 +1346,7 @@ func createNonL1BlockChainWithStackConfig( } } coreCacheConfig := gethexec.DefaultCacheConfigFor(stack, &execConfig.Caching) - blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0) + blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0, common.Address{}) Require(t, err) return info, stack, chainDb, arbDb, blockchain @@ -1437,7 +1437,7 @@ func Create2ndNodeWithConfig( chainConfig := firstExec.ArbInterface.BlockChain().Config() coreCacheConfig := gethexec.DefaultCacheConfigFor(chainStack, &execConfig.Caching) - blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0) + blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0, common.Address{}) Require(t, err) AddValNodeIfNeeded(t, ctx, nodeConfig, true, "", valnodeConfig.Wasm.RootPath) diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index c8312350e6..7e1fc57e63 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -155,6 +155,7 @@ func FuzzStateTransition(f *testing.F) { initMessage, 0, 0, + common.Address{}, ) if err != nil { panic(err) From 8ad0182cc7af4ebda48ba0feefab609e81a7ba13 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 23 Oct 2024 11:48:23 +0530 Subject: [PATCH 061/210] minor fix --- cmd/util/confighelpers/configuration.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/util/confighelpers/configuration.go b/cmd/util/confighelpers/configuration.go index c60eef961a..8c4ef2a70b 100644 --- a/cmd/util/confighelpers/configuration.go +++ b/cmd/util/confighelpers/configuration.go @@ -210,7 +210,7 @@ func devFlagArgs() []string { "--http.port", "8547", "--http.addr", "127.0.0.1", "--http.api=net,web3,eth,arb,arbdebug,debug", -, } + } return args } From ff4ba9fc196240c3f25d8c9063656276d7309537 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 23 Oct 2024 12:06:58 +0530 Subject: [PATCH 062/210] fix lint --- arbos/arbosState/initialize.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 3045df47d2..0144390663 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -97,7 +97,10 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, } if chainOwner != (common.Address{}) { - arbosState.ChainOwners().Add(chainOwner) + err := arbosState.ChainOwners().Add(chainOwner) + if err != nil { + return common.Hash{}, err + } } addrTable := arbosState.AddressTable() addrTableSize, err := addrTable.Size() From b0f4728c9b74638728da04ed83ef0108a8cb8714 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 23 Oct 2024 12:08:37 +0530 Subject: [PATCH 063/210] fix lint --- cmd/conf/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/conf/init.go b/cmd/conf/init.go index 0e624e8f61..8e4e9a8892 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -20,7 +20,7 @@ type InitConfig struct { DownloadPoll time.Duration `koanf:"download-poll"` DevInit bool `koanf:"dev-init"` DevInitAddress string `koanf:"dev-init-address"` - DevMaxCodeSize uint64 `koanf:"MaxCodeSize"` + DevMaxCodeSize uint64 `koanf:"dev-max-code-size"` DevInitBlockNum uint64 `koanf:"dev-init-blocknum"` Empty bool `koanf:"empty"` ImportWasm bool `koanf:"import-wasm"` From 6497de171f8fdef7a6c23e0855038b904ea71f0b Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 23 Oct 2024 17:17:37 +0200 Subject: [PATCH 064/210] Snapshot of trying to get bold tests passing again This is just a commit on a branch to give Lee a picture of where Pepper was when he stopped trying to get the bold-review branch's tests passing again. Essentially, I think there is at least one (but maybe several) off-by-one issues with the current implementation in the bold_state_provider. I would recommend trying to get the `bold_state_provider_test.go` (specifically, `TestChallengeProtocolBOLD_StateProvider`) to pass before moving to the other tests. I think it is attempting to validate more tightly-scoped behavior than the other tests in this package. BTW, I'm not actually 100% confident that the whole system is wired together correctly before calling the state provider. But, I do believe that errors there are less-likely than in the implementation. In my heart, I think Raul had these tests passing at some point in history. We probably just silently broke them and never noticed. Thanks for looking into this. --- staker/bold/bold_staker.go | 2 +- staker/bold/bold_state_provider.go | 2 +- staker/legacy/challenge_test.go | 10 ++++---- staker/legacy/staker.go | 9 +++++++ system_tests/bold_challenge_protocol_test.go | 22 ++++++++++------- system_tests/bold_state_provider_test.go | 25 ++++++++++++++------ system_tests/fast_confirm_test.go | 3 ++- system_tests/outbox_test.go | 1 - 8 files changed, 49 insertions(+), 25 deletions(-) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 7cd9e651b8..53a119e431 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -1,6 +1,6 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE -package boldstaker +package bold import ( "context" diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 76a546217a..c1ee37809d 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -1,6 +1,6 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE -package boldstaker +package bold import ( "context" diff --git a/staker/legacy/challenge_test.go b/staker/legacy/challenge_test.go index 77810fe763..bd0bd314cf 100644 --- a/staker/legacy/challenge_test.go +++ b/staker/legacy/challenge_test.go @@ -17,7 +17,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -97,12 +97,12 @@ func createTransactOpts(t *testing.T) *bind.TransactOpts { return opts } -func createGenesisAlloc(accts ...*bind.TransactOpts) core.GenesisAlloc { - alloc := make(core.GenesisAlloc) +func createGenesisAlloc(accts ...*bind.TransactOpts) types.GenesisAlloc { + alloc := make(types.GenesisAlloc) amount := big.NewInt(10) amount.Exp(amount, big.NewInt(20), nil) for _, opts := range accts { - alloc[opts.From] = core.GenesisAccount{ + alloc[opts.From] = types.Account{ Balance: new(big.Int).Set(amount), } } @@ -241,7 +241,7 @@ func runChallengeTest( func createBaseMachine(t *testing.T, wasmname string, wasmModules []string) *server_arb.ArbitratorMachine { _, filename, _, _ := runtime.Caller(0) - wasmDir := path.Join(path.Dir(filename), "../arbitrator/prover/test-cases/") + wasmDir := path.Join(path.Dir(filename), "../../arbitrator/prover/test-cases/") wasmPath := path.Join(wasmDir, wasmname) diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index e9bc535279..43e1e7f04a 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -314,6 +314,9 @@ func NewStaker( validatorUtilsAddress common.Address, fatalErr chan<- error, ) (*Staker, error) { + if err := config().Validate(); err != nil { + return nil, err + } client := l1Reader.Client() val, err := NewL1Validator(client, wallet, validatorUtilsAddress, callOpts, statelessBlockValidator.InboxTracker(), statelessBlockValidator.InboxStreamer(), blockValidator) @@ -321,6 +324,9 @@ func NewStaker( return nil, err } stakerLastSuccessfulActionGauge.Update(time.Now().Unix()) + if config().StartValidationFromStaked && blockValidator != nil { + stakedNotifiers = append(stakedNotifiers, blockValidator) + } inactiveValidatedNodes := btree.NewG(2, func(a, b validatedNode) bool { return a.number < b.number || (a.number == b.number && a.hash.Cmp(b.hash) < 0) }) @@ -509,6 +515,9 @@ func (s *Staker) StopAndWait() { } func (s *Staker) Start(ctxIn context.Context) { + if s.Strategy() != WatchtowerStrategy { + s.wallet.Start(ctxIn) + } s.StopWaiter.Start(ctxIn, s) backoff := time.Second isAheadOfOnChainNonceEphemeralErrorHandler := util.NewEphemeralErrorHandler(10*time.Minute, "is ahead of on-chain nonce", 0) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 895927c2f4..bb9d72e466 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -36,6 +36,7 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" @@ -48,6 +49,7 @@ import ( "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/signature" @@ -182,11 +184,11 @@ func TestChallengeProtocolBOLD(t *testing.T) { Require(t, blockValidatorB.Initialize(ctx)) Require(t, blockValidatorB.Start(ctx)) - stateManager, err := staker.NewBOLDStateProvider( + stateManager, err := bold.NewBOLDStateProvider( blockValidatorA, statelessA, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &bold.StateProviderConfig{ ValidatorName: "good", MachineLeavesCachePath: "/tmp/good", CheckBatchFinality: false, @@ -194,11 +196,11 @@ func TestChallengeProtocolBOLD(t *testing.T) { ) Require(t, err) - stateManagerB, err := staker.NewBOLDStateProvider( + stateManagerB, err := bold.NewBOLDStateProvider( blockValidatorB, statelessB, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &bold.StateProviderConfig{ ValidatorName: "evil", MachineLeavesCachePath: "/tmp/evil", CheckBatchFinality: false, @@ -470,7 +472,7 @@ func createTestNodeOnL1ForBoldProtocol( isSequencer bool, nodeConfig *arbnode.Config, chainConfig *params.ChainConfig, - stackConfig *node.Config, + _ *node.Config, l2infoIn info, ) ( l2info info, currentNode *arbnode.Node, l2client *ethclient.Client, l2stack *node.Node, @@ -545,7 +547,8 @@ func createTestNodeOnL1ForBoldProtocol( execConfig := ExecConfigDefaultNonSequencerTest(t) Require(t, execConfig.Validate()) execConfig.Caching.StateScheme = rawdb.HashScheme - _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig) + useWasmCache := uint32(0) + _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig, useWasmCache) var sequencerTxOptsPtr *bind.TransactOpts var dataSigner signature.DataSignerFunc if isSequencer { @@ -818,13 +821,13 @@ func makeBoldBatch( sequencer *bind.TransactOpts, seqInbox *bridgegen.SequencerInbox, seqInboxAddr common.Address, - messagesPerBatch, + numMessages, divergeAtIndex int64, ) { ctx := context.Background() batchBuffer := bytes.NewBuffer([]byte{}) - for i := int64(0); i < messagesPerBatch; i++ { + for i := int64(0); i < numMessages; i++ { value := i if i == divergeAtIndex { value++ @@ -852,7 +855,8 @@ func makeBoldBatch( } err = l2Node.InboxTracker.AddSequencerBatches(ctx, backend, batches) Require(t, err) - _, err = l2Node.InboxTracker.GetBatchMetadata(0) + batchMetaData, err := l2Node.InboxTracker.GetBatchMetadata(batches[0].SequenceNumber) + log.Info("Batch metadata", "md", batchMetaData) Require(t, err, "failed to get batch metadata after adding batch:") } diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index db6fa91104..713a7dfe6b 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -18,12 +18,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/validator/valnode" @@ -65,7 +67,7 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { _, err = honestUpgradeExec.ExecuteCall(&honestRollupOwnerOpts, seqInbox, data) Require(t, err) - // We will make two batches, with 5 messages in each batch. + // Make two batchs. One with 5 messages, and one with 10 messages. numMessagesPerBatch := int64(5) divergeAt := int64(-1) // No divergence. makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, seqInboxBinding, seqInbox, numMessagesPerBatch, divergeAt) @@ -79,13 +81,17 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { totalBatches := totalBatchesBig.Uint64() totalMessageCount, err := l2node.InboxTracker.GetBatchMessageCount(totalBatches - 1) Require(t, err) + t.Logf("totalBatches: %v, totalMessageCount: %v\n", totalBatches, totalMessageCount) // Wait until the validator has validated the batches. for { + // This was previously 100ms, but increasing it for getting the tests working. + time.Sleep(time.Millisecond * 1000) lastInfo, err := blockValidator.ReadLastValidatedInfo() if lastInfo == nil || err != nil { continue } + t.Logf("lastInfo: %v\n", lastInfo) batchMsgCount, err := l2node.InboxTracker.GetBatchMessageCount(lastInfo.GlobalState.Batch) if err != nil { continue @@ -95,7 +101,6 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { if batchMsgCount >= totalMessageCount { break } - time.Sleep(time.Millisecond * 100) } historyCommitter := l2stateprovider.NewHistoryCommitmentProvider( @@ -146,7 +151,7 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { } func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { - t.Parallel() + // t.Parallel() ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx) @@ -190,19 +195,25 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { // Wait until the validator has validated the batches. for { + // This was previously 100ms, but increasing it for getting the tests working. + time.Sleep(time.Millisecond * 1000) lastInfo, err := blockValidator.ReadLastValidatedInfo() if lastInfo == nil || err != nil { continue } + log.Info("loop 1:", "lastInfo", lastInfo) + if lastInfo.GlobalState.Batch >= totalBatches { + break + } batchMsgCount, err := l2node.InboxTracker.GetBatchMessageCount(lastInfo.GlobalState.Batch) if err != nil { continue } + log.Info("loop 2:", "lastValidatedMessageCount", batchMsgCount, "totalMessageCount", totalMessageCount) t.Log("lastValidatedMessageCount", batchMsgCount, "totalMessageCount", totalMessageCount) if batchMsgCount >= totalMessageCount { break } - time.Sleep(time.Millisecond * 100) } maxBlocks := uint64(1 << 14) @@ -342,7 +353,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { }) } -func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *staker.BOLDStateProvider, *staker.BlockValidator) { +func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *bold.BOLDStateProvider, *staker.BlockValidator) { var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs l2chainConfig := params.ArbitrumDevTestChainConfig() l2info := NewBlockChainTestInfo( @@ -384,11 +395,11 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * Require(t, blockValidator.Initialize(ctx)) Require(t, blockValidator.Start(ctx)) - stateManager, err := staker.NewBOLDStateProvider( + stateManager, err := bold.NewBOLDStateProvider( blockValidator, stateless, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &bold.StateProviderConfig{ ValidatorName: "", MachineLeavesCachePath: "", CheckBatchFinality: false, diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index d15f467ad4..8eb71bffd4 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -10,6 +10,7 @@ package arbtest import ( "context" "errors" + "fmt" "math/big" "strings" "testing" @@ -212,7 +213,7 @@ func TestFastConfirmation(t *testing.T) { latestConfirmAfterAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) Require(t, err) if latestConfirmAfterAct <= latestConfirmBeforeAct { - Fatal(t, "staker A didn't advance the latest confirmed node") + Fatal(t, fmt.Sprintf("staker A didn't advance the latest confirmed node: want > %d, got: %d", latestConfirmBeforeAct, latestConfirmAfterAct)) } } diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 25c52396f9..b1f3613fbd 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -53,7 +53,6 @@ func TestP256VerifyEnabled(t *testing.T) { func TestOutboxProofs(t *testing.T) { t.Parallel() gethhook.RequireHookedGeth() - rand.Seed(time.Now().UTC().UnixNano()) ctx, cancel := context.WithCancel(context.Background()) defer cancel() From 55480695262cd91722aa45955429f0c58aee9df4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 23 Oct 2024 14:05:40 -0300 Subject: [PATCH 065/210] Do not use SetFinalizer to remove entries from preimageResolvers in a hostio machine --- validator/server_arb/machine.go | 19 +++++++++++++++++-- validator/server_arb/validator_spawner.go | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 1e73e6b212..9617de5fcb 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -53,6 +53,7 @@ type ArbitratorMachine struct { ptr *C.struct_Machine contextId *int64 // has a finalizer attached to remove the preimage resolver from the global map frozen bool // does not allow anything that changes machine state, not cloned with the machine + isHostIo bool } // Assert that ArbitratorMachine implements MachineInterface @@ -71,7 +72,14 @@ func (m *ArbitratorMachine) Destroy() { // We no longer need a finalizer runtime.SetFinalizer(m, nil) } - m.contextId = nil + + // there is no finalizer related to contextId when the machine is HostIo, + // so we need to manually remove the preimage resolver + if m.isHostIo && (m.contextId != nil) { + preimageResolvers.Delete(*m.contextId) + } else { + m.contextId = nil + } } func freeContextId(context *int64) { @@ -110,6 +118,11 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { defer runtime.KeepAlive(m) m.mutex.Lock() defer m.mutex.Unlock() + + if m.isHostIo { + panic("it is not allowed to clone a hostio machine") + } + newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId return newMach @@ -385,7 +398,9 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err id := lastPreimageResolverId.Add(1) preimageResolvers.Store(id, resolver) m.contextId = &id - runtime.SetFinalizer(m.contextId, freeContextId) + if !m.isHostIo { + runtime.SetFinalizer(m.contextId, freeContextId) + } C.arbitrator_set_context(m.ptr, u64(id)) return nil } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 07971e2ba5..fc25ebac75 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -160,6 +160,7 @@ func (v *ArbitratorSpawner) execute( } mach := basemachine.Clone() + mach.isHostIo = true defer mach.Destroy() err = v.loadEntryToMachine(ctx, entry, mach) if err != nil { From f7588dc0224ba2258c0605e7b3b9b8ea80592965 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 24 Oct 2024 23:10:09 -0500 Subject: [PATCH 066/210] Fix state provider and pull in bold unify-req-meta --- bold | 2 +- staker/bold/bold_state_provider.go | 159 +++++++++++-------- staker/challenge-cache/cache.go | 30 ++-- system_tests/bold_challenge_protocol_test.go | 8 + system_tests/bold_state_provider_test.go | 22 +-- 5 files changed, 130 insertions(+), 91 deletions(-) diff --git a/bold b/bold index 9d0448fa76..669b61c030 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 9d0448fa760a8925a0ebc3dfb92762705e02c46b +Subproject commit 669b61c03067f104cd2f649b1cfbdd553eb71018 diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index c1ee37809d..4202be4570 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -83,8 +83,8 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( if maxInboxCount == 0 { return nil, errors.New("max inbox count cannot be zero") } - batchIndex := maxInboxCount - 1 - messageCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(batchIndex) + batchIndex := maxInboxCount + messageCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(batchIndex - 1) if err != nil { if strings.Contains(err.Error(), "not found") { return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) @@ -92,14 +92,17 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( return nil, err } if previousGlobalState != nil { - // TODO: Use safer sub here. - previousMessageCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(previousGlobalState.Batch - 1) - if err != nil { - if strings.Contains(err.Error(), "not found") { - return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) + var previousMessageCount arbutil.MessageIndex + if previousGlobalState.Batch > 0 { + previousMessageCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(previousGlobalState.Batch - 1) + if err != nil { + if strings.Contains(err.Error(), "not found") { + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) + } + return nil, err } - return nil, err } + previousMessageCount += arbutil.MessageIndex(previousGlobalState.PosInBatch) messageDiffBetweenBatches := messageCount - previousMessageCount maxMessageCount := previousMessageCount + arbutil.MessageIndex(maxNumberOfBlocks) if messageDiffBetweenBatches > maxMessageCount { @@ -127,24 +130,17 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( GlobalState: protocol.GoGlobalState(globalState), MachineStatus: protocol.MachineStatusFinished, } - // If the execution state did not consume all messages in a batch, we then return - // the next batch's execution state. - if executionState.GlobalState.PosInBatch != 0 { - executionState.GlobalState.Batch += 1 - executionState.GlobalState.PosInBatch = 0 - } - fromBatch := uint64(0) + var previousGlobalStateOrDefault protocol.GoGlobalState if previousGlobalState != nil { - fromBatch = previousGlobalState.Batch + previousGlobalStateOrDefault = *previousGlobalState } toBatch := executionState.GlobalState.Batch historyCommitStates, _, err := s.StatesInBatchRange( ctx, - 0, - l2stateprovider.Height(maxNumberOfBlocks)+1, - l2stateprovider.Batch(fromBatch), - l2stateprovider.Batch(toBatch), + previousGlobalStateOrDefault, + toBatch, + l2stateprovider.Height(maxNumberOfBlocks), ) if err != nil { return nil, err @@ -154,6 +150,7 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( return nil, err } executionState.EndHistoryRoot = historyCommit.Merkle + fmt.Printf("ExecutionStateAfterPreviousState for previous state batch %v pos %v got end batch %v pos %v last leaf %v hash %v\n", previousGlobalStateOrDefault.Batch, previousGlobalStateOrDefault.PosInBatch, executionState.GlobalState.Batch, executionState.GlobalState.PosInBatch, historyCommitStates[len(historyCommitStates)-1], executionState.EndHistoryRoot) return executionState, nil } @@ -187,46 +184,39 @@ func (s *BOLDStateProvider) isStateValidatedAndMessageCountPastThreshold( func (s *BOLDStateProvider) StatesInBatchRange( ctx context.Context, - fromHeight l2stateprovider.Height, + fromState protocol.GoGlobalState, + batchLimit uint64, toHeight l2stateprovider.Height, - fromBatch l2stateprovider.Batch, - toBatch l2stateprovider.Batch, ) ([]common.Hash, []validator.GoGlobalState, error) { // Check the integrity of the arguments. - if fromBatch >= toBatch { - return nil, nil, fmt.Errorf("from batch %v cannot be greater than or equal to batch %v", fromBatch, toBatch) - } - if fromHeight > toHeight { - return nil, nil, fmt.Errorf("from height %v cannot be greater than to height %v", fromHeight, toHeight) + if batchLimit < fromState.Batch || (batchLimit == fromState.Batch && fromState.PosInBatch > 0) { + return nil, nil, fmt.Errorf("batch limit %v cannot be less than from batch %v", batchLimit, fromState.Batch) } // Compute the total desired hashes from this request. - totalDesiredHashes := (toHeight - fromHeight) + 1 - machineHashes := make([]common.Hash, 0, totalDesiredHashes) - states := make([]validator.GoGlobalState, 0, totalDesiredHashes) + totalDesiredHashes := uint64(toHeight + 1) + machineHashes := make([]common.Hash, 0) + states := make([]validator.GoGlobalState, 0) var prevBatchMsgCount arbutil.MessageIndex var err error - batchNum, found, err := s.statelessValidator.InboxTracker().FindInboxBatchContainingMessage(arbutil.MessageIndex(fromHeight)) - if err != nil { - return nil, nil, err - } - if !found { - return nil, nil, fmt.Errorf("could not find batch containing message %d", fromHeight) - } - if batchNum == 0 { - prevBatchMsgCount = 0 - } else { - prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum - 1) - } - if err != nil { - return nil, nil, err + if fromState.Batch > 0 { + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch) - 1) + if err != nil { + return nil, nil, err + } } + + batchNum := fromState.Batch currBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum) if err != nil { return nil, nil, err } - posInBatch := uint64(fromHeight) - uint64(prevBatchMsgCount) - for pos := fromHeight; pos <= toHeight; pos++ { + posInBatch := fromState.PosInBatch + initialPos := prevBatchMsgCount + arbutil.MessageIndex(posInBatch) + if initialPos >= currBatchMsgCount { + return nil, nil, fmt.Errorf("initial position %v is past end of from batch %v message count %v", initialPos, batchNum, currBatchMsgCount) + } + for pos := initialPos; uint64(len(states)) < totalDesiredHashes; pos++ { if ctx.Err() != nil { return nil, nil, ctx.Err() } @@ -242,17 +232,31 @@ func (s *BOLDStateProvider) StatesInBatchRange( } states = append(states, state) machineHashes = append(machineHashes, machineHash(state)) - if uint64(pos) == uint64(currBatchMsgCount) { + if batchNum >= batchLimit { + break + } + // Check if the next message is in the next batch. + if uint64(pos+1) == uint64(currBatchMsgCount) { posInBatch = 0 batchNum++ - currBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum) - if err != nil { - return nil, nil, err + // Only get the next batch metadata if it'll be needed. + // Otherwise, we might try to read too many batches, and hit an error that the next batch isn't found. + if uint64(len(states)) < totalDesiredHashes && batchNum < batchLimit { + currBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum) + if err != nil { + return nil, nil, err + } } } else { posInBatch++ } } + fmt.Printf("got states from batch %v pos %v up to batch %v height %v\n", fromState.Batch, fromState.PosInBatch, batchLimit, toHeight) + println("----- states -----") + for i, state := range states { + fmt.Printf("batch %v pos %v hash %v\n", state.Batch, state.PosInBatch, machineHashes[i]) + } + println("------------------") return machineHashes, states, nil } @@ -269,7 +273,16 @@ func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbuti return validator.GoGlobalState{}, err } if prevBatchMsgCount > count { - return validator.GoGlobalState{}, errors.New("bad batch provided") + return validator.GoGlobalState{}, fmt.Errorf("bad batch %v provided for message count %v as previous batch ended at message count %v", batchIndex, count, prevBatchMsgCount) + } + } + if count != prevBatchMsgCount { + batchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(batchIndex)) + if err != nil { + return validator.GoGlobalState{}, err + } + if count > batchMsgCount { + return validator.GoGlobalState{}, fmt.Errorf("message count %v is past end of batch %v message count %v", count, batchIndex, batchMsgCount) } } res, err := s.statelessValidator.InboxStreamer().ResultAtCount(count) @@ -290,10 +303,9 @@ func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbuti // hashes at each message number. func (s *BOLDStateProvider) L2MessageStatesUpTo( ctx context.Context, - fromHeight l2stateprovider.Height, + fromState protocol.GoGlobalState, + batchLimit l2stateprovider.Batch, toHeight option.Option[l2stateprovider.Height], - fromBatch, - toBatch l2stateprovider.Batch, ) ([]common.Hash, error) { var to l2stateprovider.Height if !toHeight.IsNone() { @@ -301,7 +313,7 @@ func (s *BOLDStateProvider) L2MessageStatesUpTo( } else { to = s.blockChallengeLeafHeight } - items, _, err := s.StatesInBatchRange(ctx, fromHeight, to, fromBatch, toBatch) + items, _, err := s.StatesInBatchRange(ctx, fromState, uint64(batchLimit), to) if err != nil { return nil, err } @@ -314,21 +326,26 @@ func (s *BOLDStateProvider) CollectMachineHashes( ) ([]common.Hash, error) { s.Lock() defer s.Unlock() - prevBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(cfg.FromBatch - 1)) - if err != nil { - return nil, fmt.Errorf("could not get batch message count at %d: %w", cfg.FromBatch, err) + var prevBatchMsgCount arbutil.MessageIndex + if cfg.FromState.Batch > 0 { + var err error + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(cfg.FromState.Batch - 1)) + if err != nil { + return nil, fmt.Errorf("could not get batch message count at %d: %w", cfg.FromState.Batch-1, err) + } } - messageNum := prevBatchMsgCount + arbutil.MessageIndex(cfg.BlockChallengeHeight) + // cfg.BlockChallengeHeight is the index of the last correct block, before the block we're challenging. + messageNum := prevBatchMsgCount + arbutil.MessageIndex(cfg.FromState.PosInBatch) + arbutil.MessageIndex(cfg.BlockChallengeHeight) stepHeights := make([]uint64, len(cfg.StepHeights)) for i, h := range cfg.StepHeights { stepHeights[i] = uint64(h) } - globalState, err := s.findGlobalStateFromMessageCountAndBatch(prevBatchMsgCount, cfg.FromBatch-1) + messageResult, err := s.statelessValidator.InboxStreamer().ResultAtCount(arbutil.MessageIndex(messageNum + 1)) if err != nil { return nil, err } cacheKey := &challengecache.Key{ - RollupBlockHash: globalState.BlockHash, + RollupBlockHash: messageResult.BlockHash, WavmModuleRoot: cfg.WasmModuleRoot, MessageHeight: uint64(messageNum), StepHeights: stepHeights, @@ -361,6 +378,7 @@ func (s *BOLDStateProvider) CollectMachineHashes( if err != nil { return nil, err } + defer execRun.Close() ctxCheckAlive, cancelCheckAlive := ctxWithCheckAlive(ctx, execRun) defer cancelCheckAlive() stepLeaves := execRun.GetMachineHashesWithStepSize(uint64(cfg.MachineStartIndex), uint64(cfg.StepSize), cfg.NumDesiredHashes) @@ -377,6 +395,12 @@ func (s *BOLDStateProvider) CollectMachineHashes( } } } + fmt.Printf("got machine hashes for message %v start %v step size %v num %v\n", messageNum, cfg.MachineStartIndex, cfg.StepSize, cfg.NumDesiredHashes) + println("----- hashes -----") + for i, h := range result { + fmt.Printf("hash %v = %v\n", i, h) + } + println("------------------") return result, nil } @@ -418,16 +442,17 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c // CollectProof Collects osp of at a message number and OpcodeIndex . func (s *BOLDStateProvider) CollectProof( ctx context.Context, + fromState protocol.GoGlobalState, wasmModuleRoot common.Hash, - fromBatch l2stateprovider.Batch, blockChallengeHeight l2stateprovider.Height, machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { - prevBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromBatch) - 1) + prevBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch) - 1) if err != nil { return nil, err } - messageNum := prevBatchMsgCount + arbutil.MessageIndex(blockChallengeHeight) + // blockChallengeHeight is the index of the last correct block, before the block we're challenging. + messageNum := prevBatchMsgCount + arbutil.MessageIndex(fromState.PosInBatch) + arbutil.MessageIndex(blockChallengeHeight) entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum) if err != nil { return nil, err @@ -438,7 +463,8 @@ func (s *BOLDStateProvider) CollectProof( } log.Info( "Getting machine OSP", - "fromBatch", fromBatch, + "fromBatch", fromState.Batch, + "fromPosInBatch", fromState.PosInBatch, "prevBatchMsgCount", prevBatchMsgCount, "blockChallengeHeight", blockChallengeHeight, "messageNum", messageNum, @@ -448,6 +474,7 @@ func (s *BOLDStateProvider) CollectProof( if err != nil { return nil, err } + defer execRun.Close() ctxCheckAlive, cancelCheckAlive := ctxWithCheckAlive(ctx, execRun) defer cancelCheckAlive() oneStepProofPromise := execRun.GetProofAt(uint64(machineIndex)) diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index 5dca2764e8..ca9c828e64 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -79,29 +79,23 @@ type Cache struct { // New cache from a base directory path. func New(baseDir string) (*Cache, error) { - return &Cache{ - baseDir: baseDir, - tempWritesDir: "", - }, nil -} - -// Init a cache by verifying its base directory exists. -func (c *Cache) Init(_ context.Context) error { - if _, err := os.Stat(c.baseDir); err != nil { - if err := os.MkdirAll(c.baseDir, os.ModePerm); err != nil { - return fmt.Errorf("could not make initialize challenge cache directory %s: %w", c.baseDir, err) + if _, err := os.Stat(baseDir); err != nil { + if err := os.MkdirAll(baseDir, os.ModePerm); err != nil { + return nil, fmt.Errorf("could not make initialize challenge cache directory %s: %w", baseDir, err) } } // We create a temp directory to write our hashes to first when putting to the cache. // Once writing succeeds, we rename in an atomic operation to the correct file name // in the cache directory hierarchy in the `Put` function. All of these temporary writes // will occur in a subdir of the base directory called temp. - tempWritesDir, err := os.MkdirTemp(c.baseDir, "temp") + tempWritesDir, err := os.MkdirTemp(baseDir, "temp") if err != nil { - return err + return nil, err } - c.tempWritesDir = tempWritesDir - return nil + return &Cache{ + baseDir: baseDir, + tempWritesDir: tempWritesDir, + }, nil } // Get a list of hashes from the cache from index 0 up to a certain index. Hashes are saved as files in the directory @@ -111,6 +105,9 @@ func (c *Cache) Get( lookup *Key, numToRead uint64, ) ([]common.Hash, error) { + // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" + // Also see Put stubbed out because of this + return nil, ErrNotFoundInCache fName, err := determineFilePath(c.baseDir, lookup) if err != nil { return nil, err @@ -137,6 +134,9 @@ func (c *Cache) Get( // This function first creates a temporary file, writes the hashes to it, and then renames the file // to the final directory to ensure atomic writes. func (c *Cache) Put(lookup *Key, hashes []common.Hash) error { + // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" + // Also see Get stubbed out because of this + return nil // We should error if trying to put 0 hashes to disk. if len(hashes) == 0 { return ErrNoHashes diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index bb9d72e466..af6c0b130f 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -122,6 +122,14 @@ func TestChallengeProtocolBOLD(t *testing.T) { _, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, l2nodeConfig, nil, stakeTokenAddr) defer l2nodeB.StopAndWait() + genesisA, err := l2nodeA.Execution.ResultAtPos(0) + Require(t, err) + genesisB, err := l2nodeB.Execution.ResultAtPos(0) + Require(t, err) + if genesisA.BlockHash != genesisB.BlockHash { + Fatal(t, "genesis blocks mismatch between nodes") + } + balance := big.NewInt(params.Ether) balance.Mul(balance, big.NewInt(100)) TransferBalance(t, "Faucet", "Asserter", balance, l1info, l1client, ctx) diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 713a7dfe6b..115cb52e89 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -116,11 +116,14 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { ) bisectionHeight := l2stateprovider.Height(16) request := &l2stateprovider.HistoryCommitmentRequest{ - WasmModuleRoot: common.Hash{}, - FromBatch: 1, - ToBatch: 3, + AssertionMetadata: &l2stateprovider.AssociatedAssertionMetadata{ + FromState: protocol.GoGlobalState{ + Batch: 1, + }, + BatchLimit: 3, + WasmModuleRoot: common.Hash{}, + }, UpperChallengeOriginHeights: []l2stateprovider.Height{}, - FromHeight: 0, UpToHeight: option.Some(bisectionHeight), } bisectionCommitment, err := historyCommitter.HistoryCommitment(ctx, request) @@ -219,11 +222,12 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { maxBlocks := uint64(1 << 14) t.Run("StatesInBatchRange", func(t *testing.T) { - fromBatch := l2stateprovider.Batch(1) - toBatch := l2stateprovider.Batch(3) - fromHeight := l2stateprovider.Height(0) + toBatch := uint64(3) toHeight := l2stateprovider.Height(14) - stateRoots, states, err := stateManager.StatesInBatchRange(ctx, fromHeight, toHeight, fromBatch, toBatch) + fromState := protocol.GoGlobalState{ + Batch: 1, + } + stateRoots, states, err := stateManager.StatesInBatchRange(ctx, fromState, toBatch, toHeight) Require(t, err) if len(stateRoots) != 15 { @@ -401,7 +405,7 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * l2stateprovider.Height(blockChallengeLeafHeight), &bold.StateProviderConfig{ ValidatorName: "", - MachineLeavesCachePath: "", + MachineLeavesCachePath: t.TempDir(), CheckBatchFinality: false, }, ) From dba3e46f86d350e27cdd98f88242f0265ebeb23b Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 25 Oct 2024 18:04:26 +0200 Subject: [PATCH 067/210] Update to the tip of bold/unify-req-meta --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 0b91f28bbe..d48cb15395 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 0b91f28bbe301b59b16a8e412a62e339b85df20a +Subproject commit d48cb153957ffff4e4fcebf1f19bb42fcd1f448f From a5f3cf7d546b2379cc472f6eafc20b92cbde5021 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 25 Oct 2024 21:47:14 +0200 Subject: [PATCH 068/210] Get's the bold_state_provider_test.go tests passing The big problem is still the end-to-end TestChallengeProtocolBOLD test. --- staker/challenge-cache/cache.go | 4 +-- staker/challenge-cache/cache_test.go | 13 ---------- system_tests/bold_challenge_protocol_test.go | 24 +++++++++--------- system_tests/bold_state_provider_test.go | 26 +++++++++----------- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index ca9c828e64..1fec3002e9 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -107,7 +107,7 @@ func (c *Cache) Get( ) ([]common.Hash, error) { // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" // Also see Put stubbed out because of this - return nil, ErrNotFoundInCache + // return nil, ErrNotFoundInCache fName, err := determineFilePath(c.baseDir, lookup) if err != nil { return nil, err @@ -136,7 +136,7 @@ func (c *Cache) Get( func (c *Cache) Put(lookup *Key, hashes []common.Hash) error { // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" // Also see Get stubbed out because of this - return nil + //return nil // We should error if trying to put 0 hashes to disk. if len(hashes) == 0 { return ErrNoHashes diff --git a/staker/challenge-cache/cache_test.go b/staker/challenge-cache/cache_test.go index 40be627b7a..bbbd0a34e8 100644 --- a/staker/challenge-cache/cache_test.go +++ b/staker/challenge-cache/cache_test.go @@ -18,8 +18,6 @@ import ( var _ HistoryCommitmentCacher = (*Cache)(nil) func TestCache(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() basePath := t.TempDir() if err := os.MkdirAll(basePath, os.ModePerm); err != nil { t.Fatal(err) @@ -28,9 +26,6 @@ func TestCache(t *testing.T) { if err != nil { t.Fatal(err) } - if err = cache.Init(ctx); err != nil { - t.Fatal(err) - } key := &Key{ WavmModuleRoot: common.BytesToHash([]byte("foo")), MessageHeight: 0, @@ -81,9 +76,6 @@ func TestPrune(t *testing.T) { if err != nil { t.Fatal(err) } - if err = cache.Init(ctx); err != nil { - t.Fatal(err) - } key := &Key{ WavmModuleRoot: common.BytesToHash([]byte("foo")), MessageHeight: 20, @@ -424,8 +416,6 @@ func Test_determineFilePath(t *testing.T) { } func BenchmarkCache_Read_32Mb(b *testing.B) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() b.StopTimer() basePath := os.TempDir() if err := os.MkdirAll(basePath, os.ModePerm); err != nil { @@ -435,9 +425,6 @@ func BenchmarkCache_Read_32Mb(b *testing.B) { if err != nil { b.Fatal(err) } - if err = cache.Init(ctx); err != nil { - b.Fatal(err) - } key := &Key{ WavmModuleRoot: common.BytesToHash([]byte("foo")), MessageHeight: 0, diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index dfa9aa0f9b..57071e56ab 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -16,17 +16,6 @@ import ( "testing" "time" - protocol "github.com/offchainlabs/bold/chain-abstraction" - solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" - challengemanager "github.com/offchainlabs/bold/challenge-manager" - modes "github.com/offchainlabs/bold/challenge-manager/types" - l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" - "github.com/offchainlabs/bold/solgen/go/bridgegen" - "github.com/offchainlabs/bold/solgen/go/challengeV2gen" - "github.com/offchainlabs/bold/solgen/go/mocksgen" - "github.com/offchainlabs/bold/solgen/go/rollupgen" - challengetesting "github.com/offchainlabs/bold/testing" - "github.com/offchainlabs/bold/testing/setup" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -40,6 +29,17 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + protocol "github.com/offchainlabs/bold/chain-abstraction" + solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" + challengemanager "github.com/offchainlabs/bold/challenge-manager" + modes "github.com/offchainlabs/bold/challenge-manager/types" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/bridgegen" + "github.com/offchainlabs/bold/solgen/go/challengeV2gen" + "github.com/offchainlabs/bold/solgen/go/mocksgen" + "github.com/offchainlabs/bold/solgen/go/rollupgen" + challengetesting "github.com/offchainlabs/bold/testing" + "github.com/offchainlabs/bold/testing/setup" "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" @@ -555,7 +555,7 @@ func createTestNodeOnL1ForBoldProtocol( execConfig := ExecConfigDefaultNonSequencerTest(t) Require(t, execConfig.Validate()) execConfig.Caching.StateScheme = rawdb.HashScheme - useWasmCache := uint32(0) + useWasmCache := uint32(1) _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig, useWasmCache) var sequencerTxOptsPtr *bind.TransactOpts var dataSigner signature.DataSignerFunc diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 361441504b..420b38f7e5 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -81,23 +81,23 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { totalBatches := totalBatchesBig.Uint64() totalMessageCount, err := l2node.InboxTracker.GetBatchMessageCount(totalBatches - 1) Require(t, err) + log.Info("Status", "totalBatches", totalBatches, "totalMessageCount", totalMessageCount) t.Logf("totalBatches: %v, totalMessageCount: %v\n", totalBatches, totalMessageCount) // Wait until the validator has validated the batches. for { - // This was previously 100ms, but increasing it for getting the tests working. - time.Sleep(time.Millisecond * 1000) + time.Sleep(time.Millisecond * 100) lastInfo, err := blockValidator.ReadLastValidatedInfo() if lastInfo == nil || err != nil { continue } - t.Logf("lastInfo: %v\n", lastInfo) + if lastInfo.GlobalState.Batch >= totalBatches { + break + } batchMsgCount, err := l2node.InboxTracker.GetBatchMessageCount(lastInfo.GlobalState.Batch) if err != nil { continue } - Require(t, err) - t.Log("lastValidatedMessageCount", batchMsgCount, "totalMessageCount", totalMessageCount) if batchMsgCount >= totalMessageCount { break } @@ -198,13 +198,11 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { // Wait until the validator has validated the batches. for { - // This was previously 100ms, but increasing it for getting the tests working. - time.Sleep(time.Millisecond * 1000) + time.Sleep(time.Millisecond * 100) lastInfo, err := blockValidator.ReadLastValidatedInfo() if lastInfo == nil || err != nil { continue } - log.Info("loop 1:", "lastInfo", lastInfo) if lastInfo.GlobalState.Batch >= totalBatches { break } @@ -212,8 +210,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { if err != nil { continue } - log.Info("loop 2:", "lastValidatedMessageCount", batchMsgCount, "totalMessageCount", totalMessageCount) - t.Log("lastValidatedMessageCount", batchMsgCount, "totalMessageCount", totalMessageCount) if batchMsgCount >= totalMessageCount { break } @@ -223,22 +219,24 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { t.Run("StatesInBatchRange", func(t *testing.T) { toBatch := uint64(3) - toHeight := l2stateprovider.Height(14) + toHeight := l2stateprovider.Height(10) fromState := protocol.GoGlobalState{ Batch: 1, } stateRoots, states, err := stateManager.StatesInBatchRange(ctx, fromState, toBatch, toHeight) Require(t, err) + want := 11 + got := len(stateRoots) - if len(stateRoots) != 15 { - Fatal(t, "wrong number of state roots") + if got != want { + t.Errorf("len(stateRoots): got %v, want %v", got, want) } firstState := states[0] if firstState.Batch != 1 && firstState.PosInBatch != 0 { Fatal(t, "wrong first state") } lastState := states[len(states)-1] - if lastState.Batch != 1 && lastState.PosInBatch != 0 { + if lastState.Batch != 3 && lastState.PosInBatch != 0 { Fatal(t, "wrong last state") } }) From 5caa3a269a49199b295a52906d902bccde4b097e Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 25 Oct 2024 15:28:34 -0500 Subject: [PATCH 069/210] Get TestChallengeProtocolBOLD passing --- staker/challenge-cache/cache.go | 4 ++-- system_tests/bold_challenge_protocol_test.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index 1fec3002e9..ca9c828e64 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -107,7 +107,7 @@ func (c *Cache) Get( ) ([]common.Hash, error) { // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" // Also see Put stubbed out because of this - // return nil, ErrNotFoundInCache + return nil, ErrNotFoundInCache fName, err := determineFilePath(c.baseDir, lookup) if err != nil { return nil, err @@ -136,7 +136,7 @@ func (c *Cache) Get( func (c *Cache) Put(lookup *Key, hashes []common.Hash) error { // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" // Also see Get stubbed out because of this - //return nil + return nil // We should error if trying to put 0 hashes to disk. if len(hashes) == 0 { return ErrNoHashes diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 57071e56ab..8b03518a34 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -556,7 +556,8 @@ func createTestNodeOnL1ForBoldProtocol( Require(t, execConfig.Validate()) execConfig.Caching.StateScheme = rawdb.HashScheme useWasmCache := uint32(1) - _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig, useWasmCache) + initMessage := getInitMessage(ctx, t, l1client, addresses) + _, l2stack, l2chainDb, l2arbDb, l2blockchain = createNonL1BlockChainWithStackConfig(t, l2info, "", chainConfig, initMessage, nil, execConfig, useWasmCache) var sequencerTxOptsPtr *bind.TransactOpts var dataSigner signature.DataSignerFunc if isSequencer { From 2b1de3512e3295f07187cd39a35ef70106fc6b21 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 28 Oct 2024 10:23:17 +0100 Subject: [PATCH 070/210] Fix the cache Now that the virtual padding is handled in the BoLD protocol itself and not in the creation of the hash leaves being fed into the history committer, the number of hashes read from the cache doesn't need to equal the number of leaves (including virtual leaves.) --- staker/bold/bold_state_provider.go | 6 ------ staker/challenge-cache/cache.go | 17 ++--------------- staker/challenge-cache/cache_test.go | 24 +++++++----------------- 3 files changed, 9 insertions(+), 38 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index f4b3dd6358..db3595d1df 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -395,12 +395,6 @@ func (s *BOLDStateProvider) CollectMachineHashes( } } } - fmt.Printf("got machine hashes for message %v start %v step size %v num %v\n", messageNum, cfg.MachineStartIndex, cfg.StepSize, cfg.NumDesiredHashes) - println("----- hashes -----") - for i, h := range result { - fmt.Printf("hash %v = %v\n", i, h) - } - println("------------------") return result, nil } diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index ca9c828e64..44c9a002cf 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -105,9 +105,6 @@ func (c *Cache) Get( lookup *Key, numToRead uint64, ) ([]common.Hash, error) { - // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" - // Also see Put stubbed out because of this - return nil, ErrNotFoundInCache fName, err := determineFilePath(c.baseDir, lookup) if err != nil { return nil, err @@ -134,9 +131,6 @@ func (c *Cache) Get( // This function first creates a temporary file, writes the hashes to it, and then renames the file // to the final directory to ensure atomic writes. func (c *Cache) Put(lookup *Key, hashes []common.Hash) error { - // TODO cache seems broken around virtual hashes: "wanted to read 1025 hashes, but only read 4 hashes" - // Also see Get stubbed out because of this - return nil // We should error if trying to put 0 hashes to disk. if len(hashes) == 0 { return ErrNoHashes @@ -217,11 +211,11 @@ func (c *Cache) Prune(ctx context.Context, messageNumber uint64) error { } // Reads 32 bytes at a time from a reader up to a specified height. If none, then read all. -func readHashes(r io.Reader, numToRead uint64) ([]common.Hash, error) { +func readHashes(r io.Reader, toReadLimit uint64) ([]common.Hash, error) { br := bufio.NewReader(r) hashes := make([]common.Hash, 0) buf := make([]byte, 0, common.HashLength) - for totalRead := uint64(0); totalRead < numToRead; totalRead++ { + for totalRead := uint64(0); totalRead < toReadLimit; totalRead++ { n, err := br.Read(buf[:cap(buf)]) if err != nil { // If we try to read but reach EOF, we break out of the loop. @@ -236,13 +230,6 @@ func readHashes(r io.Reader, numToRead uint64) ([]common.Hash, error) { } hashes = append(hashes, common.BytesToHash(buf)) } - if numToRead > uint64(len(hashes)) { - return nil, fmt.Errorf( - "wanted to read %d hashes, but only read %d hashes", - numToRead, - len(hashes), - ) - } return hashes, nil } diff --git a/staker/challenge-cache/cache_test.go b/staker/challenge-cache/cache_test.go index bbbd0a34e8..4328ceee12 100644 --- a/staker/challenge-cache/cache_test.go +++ b/staker/challenge-cache/cache_test.go @@ -204,16 +204,6 @@ func TestPrune(t *testing.T) { } func TestReadWriteStatehashes(t *testing.T) { - t.Run("read up to, but had empty reader", func(t *testing.T) { - b := bytes.NewBuffer([]byte{}) - _, err := readHashes(b, 100) - if err == nil { - t.Fatal("Wanted error") - } - if !strings.Contains(err.Error(), "only read 0 hashes") { - t.Fatal("Unexpected error") - } - }) t.Run("read single root", func(t *testing.T) { b := bytes.NewBuffer([]byte{}) want := common.BytesToHash([]byte("foo")) @@ -316,20 +306,20 @@ func Test_readHashes(t *testing.T) { t.Fatalf("Unexpected error: %v", err) } }) - t.Run("EOF, but did not read as much as was expected", func(t *testing.T) { + t.Run("EOF, but did not read as much as was possible", func(t *testing.T) { want := []common.Hash{ common.BytesToHash([]byte("foo")), common.BytesToHash([]byte("bar")), common.BytesToHash([]byte("baz")), } - m := &mockReader{wantErr: true, hashes: want, err: io.EOF} - _, err := readHashes(m, 100) - if err == nil { - t.Fatal(err) - } - if !strings.Contains(err.Error(), "wanted to read 100") { + m := &mockReader{wantErr: false, hashes: want, bytesRead: 32} + hashes, err := readHashes(m, 100) + if err != nil { t.Fatalf("Unexpected error: %v", err) } + if len(hashes) != len(want) { + t.Fatalf("Wrong number of hashes. Expected %d, got %d", len(want), len(hashes)) + } }) t.Run("Reads wrong number of bytes", func(t *testing.T) { want := []common.Hash{ From 8f4998c881dc46ab41ae7b460d3bad33c477248c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 28 Oct 2024 21:17:43 -0500 Subject: [PATCH 071/210] Use geth's in-tree BLS again after v1.14.0 --- blsSignatures/blsSignatures.go | 22 ++++++++++++---------- go-ethereum | 2 +- go.mod | 1 - go.sum | 3 --- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/blsSignatures/blsSignatures.go b/blsSignatures/blsSignatures.go index cfcbc34d80..b597d6a07e 100644 --- a/blsSignatures/blsSignatures.go +++ b/blsSignatures/blsSignatures.go @@ -7,8 +7,10 @@ import ( cryptorand "crypto/rand" "encoding/base64" "errors" + "math/big" + "github.com/ethereum/go-ethereum/crypto" - bls12381 "github.com/kilic/bls12-381" + "github.com/ethereum/go-ethereum/crypto/bls12381" ) type PublicKey struct { @@ -16,13 +18,13 @@ type PublicKey struct { validityProof *bls12381.PointG1 // if this is nil, key came from a trusted source } -type PrivateKey *bls12381.Fr +type PrivateKey *big.Int type Signature *bls12381.PointG1 func GeneratePrivKeyString() (string, error) { - fr := bls12381.NewFr() - privKey, err := fr.Rand(cryptorand.Reader) + g2 := bls12381.NewG2() + privKey, err := cryptorand.Int(cryptorand.Reader, g2.Q()) if err != nil { return "", err } @@ -33,8 +35,8 @@ func GeneratePrivKeyString() (string, error) { } func GenerateKeys() (PublicKey, PrivateKey, error) { - fr := bls12381.NewFr() - privateKey, err := fr.Rand(cryptorand.Reader) + g2 := bls12381.NewG2() + privateKey, err := cryptorand.Int(cryptorand.Reader, g2.Q()) if err != nil { return PublicKey{}, nil, err } @@ -118,7 +120,7 @@ func verifySignature2(sig Signature, message []byte, publicKey PublicKey, keyVal return false, err } - engine := bls12381.NewEngine() + engine := bls12381.NewPairingEngine() engine.Reset() engine.AddPair(pointOnCurve, publicKey.key) leftSide := engine.Result() @@ -154,7 +156,7 @@ func VerifyAggregatedSignatureDifferentMessages(sig Signature, messages [][]byte if len(messages) != len(pubKeys) { return false, errors.New("len(messages) does not match (len(pub keys) in verification") } - engine := bls12381.NewEngine() + engine := bls12381.NewPairingEngine() engine.Reset() for i, msg := range messages { pointOnCurve, err := hashToG1Curve(msg, false) @@ -240,11 +242,11 @@ func PublicKeyFromBytes(in []byte, trustedSource bool) (PublicKey, error) { } func PrivateKeyToBytes(priv PrivateKey) []byte { - return bls12381.NewFr().Set(priv).ToBytes() + return ((*big.Int)(priv)).Bytes() } func PrivateKeyFromBytes(in []byte) (PrivateKey, error) { - return bls12381.NewFr().FromBytes(in), nil + return new(big.Int).SetBytes(in), nil } func SignatureToBytes(sig Signature) []byte { diff --git a/go-ethereum b/go-ethereum index 2b01a1c83e..0fd8140a61 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 2b01a1c83e022983547559c070b200b95cfcab4e +Subproject commit 0fd8140a6127e77c228bc1beb0b9374244478dcd diff --git a/go.mod b/go.mod index f5a6768eb2..cbe473d15b 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,6 @@ require ( github.com/google/uuid v1.6.0 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/holiman/uint256 v1.2.4 - github.com/kilic/bls12-381 v0.1.0 github.com/knadh/koanf v1.4.0 github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f github.com/mitchellh/mapstructure v1.4.1 diff --git a/go.sum b/go.sum index 419b1acfae..25b594cc25 100644 --- a/go.sum +++ b/go.sum @@ -441,8 +441,6 @@ github.com/juju/utils v0.0.0-20180808125547-9dfc6dbfb02b/go.mod h1:6/KLg8Wz/y2KV github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= -github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= @@ -810,7 +808,6 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From d4e2ecdc7c05a6f6618f39752aec38109e875163 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 29 Oct 2024 11:19:36 +0530 Subject: [PATCH 072/210] handle race condition and address minor comments --- blocks_reexecutor/blocks_reexecutor.go | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index c6083a9ad5..6347975534 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -7,6 +7,7 @@ import ( "math/rand" "runtime" "strings" + "sync" "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" @@ -82,6 +83,7 @@ type BlocksReExecutor struct { startBlock uint64 currentBlock uint64 minBlocksPerThread uint64 + mutex sync.Mutex } func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrChan chan error) (*BlocksReExecutor, error) { @@ -126,7 +128,7 @@ func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrC // Divide work equally among available threads when MinBlocksPerThread is zero if c.MinBlocksPerThread == 0 { // #nosec G115 - work := (end - start) / uint64(c.Room) + work := (end - start) / uint64(c.Room*2) if work > 0 { minBlocksPerThread = work } @@ -148,13 +150,12 @@ func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrC fatalErrChan: fatalErrChan, } blocksReExecutor.stateFor = func(header *types.Header) (*state.StateDB, arbitrum.StateReleaseFunc, error) { - sdb, err := state.NewDeterministic(header.Root, blocksReExecutor.db) + blocksReExecutor.mutex.Lock() + defer blocksReExecutor.mutex.Unlock() + sdb, err := state.New(header.Root, blocksReExecutor.db, nil) if err == nil { _ = blocksReExecutor.db.TrieDB().Reference(header.Root, common.Hash{}) // Will be dereferenced later in advanceStateUpToBlock - stateReleaseFunc := func() { - _ = blocksReExecutor.db.TrieDB().Dereference(header.Root) - } - return sdb, stateReleaseFunc, nil + return sdb, func() { blocksReExecutor.dereferenceRoot(header.Root) }, nil } return sdb, arbitrum.NoopStateRelease, err } @@ -225,7 +226,15 @@ func (s *BlocksReExecutor) StopAndWait() { s.StopWaiter.StopAndWait() } +func (s *BlocksReExecutor) dereferenceRoot(root common.Hash) { + s.mutex.Lock() + defer s.mutex.Unlock() + _ = s.db.TrieDB().Dereference(root) +} + func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected common.Hash, blockNumber uint64) (*state.StateDB, arbitrum.StateReleaseFunc, error) { + s.mutex.Lock() + defer s.mutex.Unlock() result, err := statedb.Commit(blockNumber, true) if err != nil { return nil, arbitrum.NoopStateRelease, err @@ -233,13 +242,10 @@ func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected if result != expected { return nil, arbitrum.NoopStateRelease, fmt.Errorf("bad root hash expected: %v got: %v", expected, result) } - sdb, err := state.New(result, statedb.Database(), nil) + sdb, err := state.New(result, s.db, nil) if err == nil { _ = s.db.TrieDB().Reference(result, common.Hash{}) - stateReleaseFunc := func() { - _ = s.db.TrieDB().Dereference(result) - } - return sdb, stateReleaseFunc, nil + return sdb, func() { s.dereferenceRoot(result) }, nil } return sdb, arbitrum.NoopStateRelease, err } From 8d8cfbead170540ea0dc5a25e98aa755a51ff405 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 29 Oct 2024 11:45:19 +0530 Subject: [PATCH 073/210] update geth pin --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index fece13e75a..2f247a3182 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit fece13e75a3448d5ef53e72a7d46ebb6118575ad +Subproject commit 2f247a31822ecd06e39d89f7d5332fa16fd2f6b6 From c2ccab55821d47110c76cbe434c1b7c5330a792d Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 29 Oct 2024 12:03:53 +0530 Subject: [PATCH 074/210] StateBuildingLogFunction shouldn't take targetHeader as an arg --- blocks_reexecutor/blocks_reexecutor.go | 2 +- execution/gethexec/block_recorder.go | 32 ++++++++++++++------------ go-ethereum | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index 6347975534..5a883e5d42 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -261,7 +261,7 @@ func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *sta var block *types.Block var err error for ctx.Err() == nil { - state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, targetHeader, blockToRecreate, prevHash, nil) + state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, blockToRecreate, prevHash, nil) if err != nil { return err } diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index a3af7876a8..6f30e16e5c 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -75,19 +75,21 @@ func NewBlockRecorder(config *BlockRecorderConfig, execEngine *ExecutionEngine, return recorder } -func stateLogFunc(targetHeader, header *types.Header, hasState bool) { - if targetHeader == nil || header == nil { - return - } - gap := targetHeader.Number.Int64() - header.Number.Int64() - step := int64(500) - stage := "computing state" - if !hasState { - step = 3000 - stage = "looking for full block" - } - if (gap >= step) && (gap%step == 0) { - log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number) +func stateLogFunc(targetHeader *types.Header) arbitrum.StateBuildingLogFunction { + return func(header *types.Header, hasState bool) { + if targetHeader == nil || header == nil { + return + } + gap := targetHeader.Number.Int64() - header.Number.Int64() + step := int64(500) + stage := "computing state" + if !hasState { + step = 3000 + stage = "looking for full block" + } + if (gap >= step) && (gap%step == 0) { + log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number) + } } } @@ -109,7 +111,7 @@ func (r *BlockRecorder) RecordBlockCreation( } } - recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc) + recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc(prevHeader)) if err != nil { return nil, err } @@ -321,7 +323,7 @@ func (r *BlockRecorder) PrepareForRecord(ctx context.Context, start, end arbutil log.Warn("prepareblocks asked for non-found block", "hdrNum", hdrNum) break } - _, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc) + _, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc(header)) if err != nil { log.Warn("prepareblocks failed to get state for block", "hdrNum", hdrNum, "err", err) break diff --git a/go-ethereum b/go-ethereum index 2f247a3182..f9b447d74c 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 2f247a31822ecd06e39d89f7d5332fa16fd2f6b6 +Subproject commit f9b447d74c00e554752ae60eb2200966d68a4f7a From dda8af230f5bb2d82807a16fed95f1bb9ecaff5c Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 29 Oct 2024 19:54:10 +0530 Subject: [PATCH 075/210] Add support for standard genesis.json format --- cmd/conf/init.go | 3 +++ cmd/nitro/init.go | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cmd/conf/init.go b/cmd/conf/init.go index f01d99f8b7..d54d35bf4e 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -25,6 +25,7 @@ type InitConfig struct { ImportWasm bool `koanf:"import-wasm"` AccountsPerSync uint `koanf:"accounts-per-sync"` ImportFile string `koanf:"import-file"` + GenesisJsonFile string `koanf:"genesis-json-file"` ThenQuit bool `koanf:"then-quit"` Prune string `koanf:"prune"` PruneBloomSize uint64 `koanf:"prune-bloom-size"` @@ -51,6 +52,7 @@ var InitConfigDefault = InitConfig{ Empty: false, ImportWasm: false, ImportFile: "", + GenesisJsonFile: "", AccountsPerSync: 100000, ThenQuit: false, Prune: "", @@ -79,6 +81,7 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".import-wasm", InitConfigDefault.ImportWasm, "if set, import the wasm directory when downloading a database (contains executable code - only use with highly trusted source)") f.Bool(prefix+".then-quit", InitConfigDefault.ThenQuit, "quit after init is done") f.String(prefix+".import-file", InitConfigDefault.ImportFile, "path for json data to import") + f.String(prefix+".genesis-json-file", InitConfigDefault.GenesisJsonFile, "path for genesis json file") f.Uint(prefix+".accounts-per-sync", InitConfigDefault.AccountsPerSync, "during init - sync database every X accounts. Lower value for low-memory systems. 0 disables.") f.String(prefix+".prune", InitConfigDefault.Prune, "pruning for a given use: \"full\" for full nodes serving RPC requests, or \"validator\" for validators") f.Uint64(prefix+".prune-bloom-size", InitConfigDefault.PruneBloomSize, "the amount of memory in megabytes to use for the pruning bloom filter (higher values prune better)") diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index f0b303817c..a5a6ec4ca8 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -687,6 +687,36 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo var chainConfig *params.ChainConfig + if config.Init.GenesisJsonFile != "" { + if initDataReader != nil { + return chainDb, nil, errors.New("multiple init methods supplied") + } + genesisJson, err := os.ReadFile(config.Init.GenesisJsonFile) + if err != nil { + return chainDb, nil, err + } + var gen core.Genesis + if err := json.Unmarshal(genesisJson, &gen); err != nil { + return chainDb, nil, err + } + var accounts []statetransfer.AccountInitializationInfo + for address, account := range gen.Alloc { + accounts = append(accounts, statetransfer.AccountInitializationInfo{ + Addr: address, + EthBalance: account.Balance, + Nonce: account.Nonce, + ContractInfo: &statetransfer.AccountInitContractInfo{ + Code: account.Code, + ContractStorage: account.Storage, + }, + }) + } + initDataReader = statetransfer.NewMemoryInitDataReader(&statetransfer.ArbosInitializationInfo{ + Accounts: accounts, + }) + chainConfig = gen.Config + } + var l2BlockChain *core.BlockChain txIndexWg := sync.WaitGroup{} if initDataReader == nil { @@ -712,9 +742,11 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if err != nil { return chainDb, nil, err } - chainConfig, err = chaininfo.GetChainConfig(new(big.Int).SetUint64(config.Chain.ID), config.Chain.Name, genesisBlockNr, config.Chain.InfoFiles, config.Chain.InfoJson) - if err != nil { - return chainDb, nil, err + if chainConfig == nil { + chainConfig, err = chaininfo.GetChainConfig(new(big.Int).SetUint64(config.Chain.ID), config.Chain.Name, genesisBlockNr, config.Chain.InfoFiles, config.Chain.InfoJson) + if err != nil { + return chainDb, nil, err + } } testUpdateTxIndex(chainDb, chainConfig, &txIndexWg) ancients, err := chainDb.Ancients() From 60daa96d9ef8c1f85b4cbdc29b19952686a7929f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 29 Oct 2024 20:34:02 +0530 Subject: [PATCH 076/210] minor fix --- staker/bold/bold_state_provider.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 0983bc790b..1fbe60f09d 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -361,6 +361,7 @@ func (s *BOLDStateProvider) CollectMachineHashes( if err != nil { return nil, err } + defer execRun.Close() ctxCheckAlive, cancelCheckAlive := ctxWithCheckAlive(ctx, execRun) defer cancelCheckAlive() stepLeaves := execRun.GetMachineHashesWithStepSize(uint64(cfg.MachineStartIndex), uint64(cfg.StepSize), cfg.NumDesiredHashes) @@ -448,6 +449,7 @@ func (s *BOLDStateProvider) CollectProof( if err != nil { return nil, err } + defer execRun.Close() ctxCheckAlive, cancelCheckAlive := ctxWithCheckAlive(ctx, execRun) defer cancelCheckAlive() oneStepProofPromise := execRun.GetProofAt(uint64(machineIndex)) From 8e39be5fb8b8c4874cfafed4bbd04d4ded5ad054 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 29 Oct 2024 20:50:08 +0530 Subject: [PATCH 077/210] fix linter --- staker/multi_protocol/multi_protocol_staker.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index d4d4e1b54f..f8bc46fa2b 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -5,12 +5,12 @@ import ( "github.com/offchainlabs/nitro/staker" "time" - "github.com/offchainlabs/bold/solgen/go/bridgegen" - boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/bold/solgen/go/bridgegen" + boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" boldstaker "github.com/offchainlabs/nitro/staker/bold" legacystaker "github.com/offchainlabs/nitro/staker/legacy" From cffb7930b05c064b37a4452297367f44ed0061e3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 09:14:08 -0300 Subject: [PATCH 078/210] Revert "Do not use SetFinalizer to remove entries from preimageResolvers in a hostio machine" This reverts commit 55480695262cd91722aa45955429f0c58aee9df4. --- validator/server_arb/machine.go | 19 ++----------------- validator/server_arb/validator_spawner.go | 1 - 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 9617de5fcb..1e73e6b212 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -53,7 +53,6 @@ type ArbitratorMachine struct { ptr *C.struct_Machine contextId *int64 // has a finalizer attached to remove the preimage resolver from the global map frozen bool // does not allow anything that changes machine state, not cloned with the machine - isHostIo bool } // Assert that ArbitratorMachine implements MachineInterface @@ -72,14 +71,7 @@ func (m *ArbitratorMachine) Destroy() { // We no longer need a finalizer runtime.SetFinalizer(m, nil) } - - // there is no finalizer related to contextId when the machine is HostIo, - // so we need to manually remove the preimage resolver - if m.isHostIo && (m.contextId != nil) { - preimageResolvers.Delete(*m.contextId) - } else { - m.contextId = nil - } + m.contextId = nil } func freeContextId(context *int64) { @@ -118,11 +110,6 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { defer runtime.KeepAlive(m) m.mutex.Lock() defer m.mutex.Unlock() - - if m.isHostIo { - panic("it is not allowed to clone a hostio machine") - } - newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId return newMach @@ -398,9 +385,7 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err id := lastPreimageResolverId.Add(1) preimageResolvers.Store(id, resolver) m.contextId = &id - if !m.isHostIo { - runtime.SetFinalizer(m.contextId, freeContextId) - } + runtime.SetFinalizer(m.contextId, freeContextId) C.arbitrator_set_context(m.ptr, u64(id)) return nil } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index fc25ebac75..07971e2ba5 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -160,7 +160,6 @@ func (v *ArbitratorSpawner) execute( } mach := basemachine.Clone() - mach.isHostIo = true defer mach.Destroy() err = v.loadEntryToMachine(ctx, entry, mach) if err != nil { From 5390b0e09fbd9e1160aebbaedb2fe52e2b382988 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 10:00:17 -0300 Subject: [PATCH 079/210] Uses preimageResolverRefCounter instead of relying on finalizers to remove preimage resolvers from global map --- validator/server_arb/machine.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 1e73e6b212..5e381db82f 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -51,14 +51,15 @@ type MachineInterface interface { type ArbitratorMachine struct { mutex sync.Mutex // needed because go finalizers don't synchronize (meaning they aren't thread safe) ptr *C.struct_Machine - contextId *int64 // has a finalizer attached to remove the preimage resolver from the global map - frozen bool // does not allow anything that changes machine state, not cloned with the machine + contextId int64 + frozen bool // does not allow anything that changes machine state, not cloned with the machine } // Assert that ArbitratorMachine implements MachineInterface var _ MachineInterface = (*ArbitratorMachine)(nil) var preimageResolvers containers.SyncMap[int64, GoPreimageResolver] +var preimageResolverRefCounter containers.SyncMap[int64, *atomic.Int64] var lastPreimageResolverId atomic.Int64 // atomic // Any future calls to this machine will result in a panic @@ -68,14 +69,14 @@ func (m *ArbitratorMachine) Destroy() { if m.ptr != nil { C.arbitrator_free_machine(m.ptr) m.ptr = nil - // We no longer need a finalizer - runtime.SetFinalizer(m, nil) } - m.contextId = nil -} - -func freeContextId(context *int64) { - preimageResolvers.Delete(*context) + refCounter, ok := preimageResolverRefCounter.Load(m.contextId) + if ok { + if refCounter.Add(-1) == 0 { + preimageResolverRefCounter.Delete(m.contextId) + preimageResolvers.Delete(m.contextId) + } + } } func machineFromPointer(ptr *C.struct_Machine) *ArbitratorMachine { @@ -112,6 +113,10 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { defer m.mutex.Unlock() newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId + refCounter, ok := preimageResolverRefCounter.Load(m.contextId) + if ok { + refCounter.Add(1) + } return newMach } @@ -384,8 +389,10 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err } id := lastPreimageResolverId.Add(1) preimageResolvers.Store(id, resolver) - m.contextId = &id - runtime.SetFinalizer(m.contextId, freeContextId) + refCounter := atomic.Int64{} + refCounter.Store(1) + preimageResolverRefCounter.Store(id, &refCounter) + m.contextId = id C.arbitrator_set_context(m.ptr, u64(id)) return nil } From b7ba9c306b9dc3124979664ee578f37ea7307f0c Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 10:16:11 -0300 Subject: [PATCH 080/210] Reuse same global map to keep preimage resolver reference counter --- validator/server_arb/machine.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 5e381db82f..aa4ab85706 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -58,8 +58,7 @@ type ArbitratorMachine struct { // Assert that ArbitratorMachine implements MachineInterface var _ MachineInterface = (*ArbitratorMachine)(nil) -var preimageResolvers containers.SyncMap[int64, GoPreimageResolver] -var preimageResolverRefCounter containers.SyncMap[int64, *atomic.Int64] +var preimageResolvers containers.SyncMap[int64, goPreimageResolverWithRefCounter] var lastPreimageResolverId atomic.Int64 // atomic // Any future calls to this machine will result in a panic @@ -70,10 +69,9 @@ func (m *ArbitratorMachine) Destroy() { C.arbitrator_free_machine(m.ptr) m.ptr = nil } - refCounter, ok := preimageResolverRefCounter.Load(m.contextId) + resolverWithRefCounter, ok := preimageResolvers.Load(m.contextId) if ok { - if refCounter.Add(-1) == 0 { - preimageResolverRefCounter.Delete(m.contextId) + if resolverWithRefCounter.refCounter.Add(-1) == 0 { preimageResolvers.Delete(m.contextId) } } @@ -113,10 +111,12 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { defer m.mutex.Unlock() newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId - refCounter, ok := preimageResolverRefCounter.Load(m.contextId) + + resolverWithRefCounter, ok := preimageResolvers.Load(m.contextId) if ok { - refCounter.Add(1) + resolverWithRefCounter.refCounter.Add(1) } + return newMach } @@ -355,19 +355,23 @@ func (m *ArbitratorMachine) AddDelayedInboxMessage(index uint64, data []byte) er } type GoPreimageResolver = func(arbutil.PreimageType, common.Hash) ([]byte, error) +type goPreimageResolverWithRefCounter struct { + resolver GoPreimageResolver + refCounter *atomic.Int64 +} //export preimageResolver func preimageResolver(context C.size_t, ty C.uint8_t, ptr unsafe.Pointer) C.ResolvedPreimage { var hash common.Hash input := (*[1 << 30]byte)(ptr)[:32] copy(hash[:], input) - resolver, ok := preimageResolvers.Load(int64(context)) + resolverWithRefCounter, ok := preimageResolvers.Load(int64(context)) if !ok { return C.ResolvedPreimage{ len: -1, } } - preimage, err := resolver(arbutil.PreimageType(ty), hash) + preimage, err := resolverWithRefCounter.resolver(arbutil.PreimageType(ty), hash) if err != nil { log.Error("preimage resolution failed", "err", err) return C.ResolvedPreimage{ @@ -388,10 +392,15 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err return errors.New("machine frozen") } id := lastPreimageResolverId.Add(1) - preimageResolvers.Store(id, resolver) + refCounter := atomic.Int64{} refCounter.Store(1) - preimageResolverRefCounter.Store(id, &refCounter) + resolverWithRefCounter := goPreimageResolverWithRefCounter{ + resolver: resolver, + refCounter: &refCounter, + } + preimageResolvers.Store(id, resolverWithRefCounter) + m.contextId = id C.arbitrator_set_context(m.ptr, u64(id)) return nil From 98ccb2dfda661686b2bec7c6ec25fa0ae6dd69b2 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 14:45:03 -0300 Subject: [PATCH 081/210] TestEntriesAreDeletedFromPreimageResolversGlobalMap --- util/containers/syncmap.go | 10 ++++ validator/server_arb/machine_test.go | 75 ++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 validator/server_arb/machine_test.go diff --git a/util/containers/syncmap.go b/util/containers/syncmap.go index 7952a32252..e24d56fda6 100644 --- a/util/containers/syncmap.go +++ b/util/containers/syncmap.go @@ -22,3 +22,13 @@ func (m *SyncMap[K, V]) Store(key K, val V) { func (m *SyncMap[K, V]) Delete(key K) { m.internal.Delete(key) } + +// Only used for testing +func (m *SyncMap[K, V]) Keys() []K { + s := make([]K, 0) + m.internal.Range(func(k, v interface{}) bool { + s = append(s, k.(K)) + return true + }) + return s +} diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go new file mode 100644 index 0000000000..3255970350 --- /dev/null +++ b/validator/server_arb/machine_test.go @@ -0,0 +1,75 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package server_arb + +import ( + "path" + "reflect" + "runtime" + "sort" + "testing" + + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/util/testhelpers" +) + +func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { + resolver := func(arbutil.PreimageType, common.Hash) ([]byte, error) { + return nil, nil + } + + sortedKeys := func() []int64 { + keys := preimageResolvers.Keys() + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + return keys + } + + // clear global map before running test + preimageKeys := sortedKeys() + for _, key := range preimageKeys { + preimageResolvers.Delete(key) + } + + _, filename, _, _ := runtime.Caller(0) + wasmDir := path.Join(path.Dir(filename), "../../arbitrator/prover/test-cases/") + wasmPath := path.Join(wasmDir, "global-state.wasm") + modulePaths := []string{path.Join(wasmDir, "global-state-wrapper.wasm")} + + machine1, err := LoadSimpleMachine(wasmPath, modulePaths, true) + testhelpers.RequireImpl(t, err) + err = machine1.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + + machine2, err := LoadSimpleMachine(wasmPath, modulePaths, true) + testhelpers.RequireImpl(t, err) + err = machine2.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + + machine1_clone1 := machine1.Clone() + machine1_clone2 := machine1.Clone() + + checkKeys := func(expectedKeys []int64, scenario string) { + keys := sortedKeys() + if !reflect.DeepEqual(keys, expectedKeys) { + t.Fatal("Unexpected preimageResolversKeys got", keys, "expected", expectedKeys, "scenario", scenario) + } + } + + checkKeys([]int64{machine1.contextId, machine2.contextId}, "initial") + + machine1_clone1.Destroy() + checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1_clone1 destroy") + + machine1_clone2.Destroy() + checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1_clone2 destroy") + + machine2.Destroy() + checkKeys([]int64{machine1.contextId}, "after machine2 destroy") + + machine1.Destroy() + checkKeys([]int64{}, "after machine1 destroy") +} From efc592f2c37029d55ab9f1686c3d0f9d996efab8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 15:18:09 -0300 Subject: [PATCH 082/210] Adds machine's finalizer back --- validator/server_arb/machine.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index aa4ab85706..a9475c7f7c 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -68,6 +68,8 @@ func (m *ArbitratorMachine) Destroy() { if m.ptr != nil { C.arbitrator_free_machine(m.ptr) m.ptr = nil + // We no longer need a finalizer + runtime.SetFinalizer(m, nil) } resolverWithRefCounter, ok := preimageResolvers.Load(m.contextId) if ok { From 7ebf2dcf4b6e1fe0979ccee29f1a402fc2fc06bc Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 30 Oct 2024 16:16:31 -0300 Subject: [PATCH 083/210] Change machine destroy order in TestEntriesAreDeletedFromPreimageResolversGlobalMap --- validator/server_arb/machine_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go index 3255970350..b6b64c4b53 100644 --- a/validator/server_arb/machine_test.go +++ b/validator/server_arb/machine_test.go @@ -64,12 +64,12 @@ func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { machine1_clone1.Destroy() checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1_clone1 destroy") + machine1.Destroy() + checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1 destroy") + machine1_clone2.Destroy() - checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1_clone2 destroy") + checkKeys([]int64{machine2.contextId}, "after machine1_clone2 destroy") machine2.Destroy() - checkKeys([]int64{machine1.contextId}, "after machine2 destroy") - - machine1.Destroy() - checkKeys([]int64{}, "after machine1 destroy") + checkKeys([]int64{}, "after machine2 destroy") } From 0b4dbef3a3e566aa376bde81ad66bd86dcacdfd9 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Wed, 30 Oct 2024 16:36:08 -0600 Subject: [PATCH 084/210] fix MockTransfer in trace --- arbos/util/transfer.go | 6 ++++-- system_tests/program_gas_test.go | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index e186dee0fa..ed5e07c8cf 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -36,8 +36,10 @@ func TransferBalance( return errors.New("tracing scenario mismatch") } - if scenario != TracingDuringEVM && tracer.CaptureArbitrumTransfer != nil { - tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) + if scenario != TracingDuringEVM { + if tracer.CaptureArbitrumTransfer != nil { + tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) + } } else { fromCopy := from toCopy := to diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 03f63ff39e..10a371532d 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -353,7 +353,7 @@ func compareGasUsage( switch mode { case compareGasForEach: if len(evmGasUsage[opcode]) != len(stylusGasUsage[hostio]) { - Fatal(t, "mismatch between hostios and opcodes", evmGasUsage, stylusGasUsage) + Fatal(t, "mismatch between opcode ", opcode, " - ", evmGasUsage[opcode], " and hostio ", hostio, " - ", stylusGasUsage[hostio]) } for i := range evmGasUsage[opcode] { opcodeGas := evmGasUsage[opcode][i] @@ -390,10 +390,6 @@ func evmOpcodesGasUsage(ctx context.Context, rpcClient rpc.ClientInterface, tx * op := vm.StringToOp(result.StructLogs[i].Op) gasUsed := uint64(0) if op == vm.CALL || op == vm.STATICCALL || op == vm.DELEGATECALL || op == vm.CREATE || op == vm.CREATE2 { - if result.StructLogs[i].GasCost == 0 { - // ignore mock call emitted by arbos - continue - } // For the CALL* opcodes, the GasCost in the tracer represents the gas sent // to the callee contract, which is 63/64 of the remaining gas. This happens // because the tracer is evaluated before the call is executed, so the EVM From 04a8d83fd8cc2bc5c8a0af5c76a887d1e3c3413f Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 30 Oct 2024 21:50:28 -0500 Subject: [PATCH 085/210] Add a test challenging the start step in BoLD --- cmd/nitro-val/nitro_val.go | 1 + cmd/nitro/nitro.go | 1 + staker/bold/bold_state_provider.go | 7 ++++ staker/legacy/challenge_test.go | 10 ++--- .../legacy/mock_machine_test.go | 17 +++++--- system_tests/bold_challenge_protocol_test.go | 18 +++++++-- system_tests/bold_state_provider_test.go | 2 +- system_tests/common_test.go | 7 ++-- system_tests/fast_confirm_test.go | 4 +- system_tests/full_challenge_impl_test.go | 2 +- system_tests/mock_machine_test.go | 40 +++++++++++++++++++ system_tests/program_test.go | 2 +- system_tests/staker_test.go | 2 +- validator/server_arb/execution_run.go | 5 ++- validator/server_arb/execution_run_test.go | 3 ++ validator/server_arb/machine.go | 1 + validator/server_arb/validator_spawner.go | 20 +++++++--- validator/valnode/valnode.go | 4 +- 18 files changed, 115 insertions(+), 31 deletions(-) rename validator/server_arb/mock_machine.go => staker/legacy/mock_machine_test.go (78%) create mode 100644 system_tests/mock_machine_test.go diff --git a/cmd/nitro-val/nitro_val.go b/cmd/nitro-val/nitro_val.go index 3ff859c302..b5a3d823ab 100644 --- a/cmd/nitro-val/nitro_val.go +++ b/cmd/nitro-val/nitro_val.go @@ -135,6 +135,7 @@ func mainImpl() int { func() *valnode.Config { return &liveNodeConfig.Get().Validation }, stack, fatalErrChan, + nil, ) if err != nil { log.Error("couldn't init validation node", "err", err) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index e55c8b9691..3d4fe6f06d 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -513,6 +513,7 @@ func mainImpl() int { func() *valnode.Config { return &liveNodeConfig.Get().Validation }, stack, fatalErrChan, + nil, ) if err != nil { valNode = nil diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index db3595d1df..254415df9b 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -387,6 +387,12 @@ func (s *BOLDStateProvider) CollectMachineHashes( return nil, err } log.Info(fmt.Sprintf("Finished gathering machine hashes for request %+v", cfg)) + fmt.Printf("got machine hashes from message num %v start index %v step size %v desired hashes %v\n", messageNum, cfg.MachineStartIndex, cfg.StepSize, cfg.NumDesiredHashes) + println("----- hashes -----") + for i, h := range result { + fmt.Printf("index %v hash %v\n", i, h) + } + println("------------------") // Do not save a history commitment of length 1 to the cache. if len(result) > 1 && s.historyCache != nil { if err := s.historyCache.Put(cacheKey, result); err != nil { @@ -462,6 +468,7 @@ func (s *BOLDStateProvider) CollectProof( "prevBatchMsgCount", prevBatchMsgCount, "blockChallengeHeight", blockChallengeHeight, "messageNum", messageNum, + "machineIndex", machineIndex, "startState", fmt.Sprintf("%+v", input.StartState), ) execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModuleRoot, input).Await(ctx) diff --git a/staker/legacy/challenge_test.go b/staker/legacy/challenge_test.go index bd0bd314cf..2aebb99131 100644 --- a/staker/legacy/challenge_test.go +++ b/staker/legacy/challenge_test.go @@ -258,31 +258,31 @@ func createBaseMachine(t *testing.T, wasmname string, wasmModules []string) *ser func TestChallengeToOSP(t *testing.T) { machine := createBaseMachine(t, "global-state.wasm", []string{"global-state-wrapper.wasm"}) - IncorrectMachine := server_arb.NewIncorrectMachine(machine, 200) + IncorrectMachine := NewIncorrectMachine(machine, 200) runChallengeTest(t, machine, IncorrectMachine, false, false, 0) } func TestChallengeToFailedOSP(t *testing.T) { machine := createBaseMachine(t, "global-state.wasm", []string{"global-state-wrapper.wasm"}) - IncorrectMachine := server_arb.NewIncorrectMachine(machine, 200) + IncorrectMachine := NewIncorrectMachine(machine, 200) runChallengeTest(t, machine, IncorrectMachine, true, false, 0) } func TestChallengeToErroredOSP(t *testing.T) { machine := createBaseMachine(t, "const.wasm", nil) - IncorrectMachine := server_arb.NewIncorrectMachine(machine, 10) + IncorrectMachine := NewIncorrectMachine(machine, 10) runChallengeTest(t, machine, IncorrectMachine, false, false, 0) } func TestChallengeToFailedErroredOSP(t *testing.T) { machine := createBaseMachine(t, "const.wasm", nil) - IncorrectMachine := server_arb.NewIncorrectMachine(machine, 10) + IncorrectMachine := NewIncorrectMachine(machine, 10) runChallengeTest(t, machine, IncorrectMachine, true, false, 0) } func TestChallengeToTimeout(t *testing.T) { machine := createBaseMachine(t, "global-state.wasm", []string{"global-state-wrapper.wasm"}) - IncorrectMachine := server_arb.NewIncorrectMachine(machine, 200) + IncorrectMachine := NewIncorrectMachine(machine, 200) runChallengeTest(t, machine, IncorrectMachine, false, true, 0) } diff --git a/validator/server_arb/mock_machine.go b/staker/legacy/mock_machine_test.go similarity index 78% rename from validator/server_arb/mock_machine.go rename to staker/legacy/mock_machine_test.go index 3cf0f9f771..54bf9fecba 100644 --- a/validator/server_arb/mock_machine.go +++ b/staker/legacy/mock_machine_test.go @@ -1,33 +1,36 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package server_arb +package legacystaker import ( "context" "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_arb" ) +// IncorrectMachine will report a bad global state after the incorrectStep onwards. +// It'll also extend the step count to incorrectStep if necessary. type IncorrectMachine struct { - inner *ArbitratorMachine + inner *server_arb.ArbitratorMachine incorrectStep uint64 stepCount uint64 } var badGlobalState = validator.GoGlobalState{Batch: 0xbadbadbadbad, PosInBatch: 0xbadbadbadbad} -var _ MachineInterface = (*IncorrectMachine)(nil) +var _ server_arb.MachineInterface = (*IncorrectMachine)(nil) -func NewIncorrectMachine(inner *ArbitratorMachine, incorrectStep uint64) *IncorrectMachine { +func NewIncorrectMachine(inner *server_arb.ArbitratorMachine, incorrectStep uint64) *IncorrectMachine { return &IncorrectMachine{ inner: inner.Clone(), incorrectStep: incorrectStep, } } -func (m *IncorrectMachine) CloneMachineInterface() MachineInterface { +func (m *IncorrectMachine) CloneMachineInterface() server_arb.MachineInterface { return &IncorrectMachine{ inner: m.inner.Clone(), incorrectStep: m.incorrectStep, @@ -57,6 +60,10 @@ func (m *IncorrectMachine) IsRunning() bool { return m.inner.IsRunning() || m.stepCount < m.incorrectStep } +func (m *IncorrectMachine) IsErrored() bool { + return !m.IsRunning() && m.inner.IsErrored() +} + func (m *IncorrectMachine) ValidForStep(step uint64) bool { return m.inner.ValidForStep(step) } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 8b03518a34..8b1cc10b98 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -54,6 +54,7 @@ import ( "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" ) @@ -64,7 +65,17 @@ var ( smallStepChallengeLeafHeight = uint64(1 << 10) ) -func TestChallengeProtocolBOLD(t *testing.T) { +func TestChallengeProtocolBOLDReadInboxChallenge(t *testing.T) { + testChallengeProtocolBOLDWithMachineMock(t, nil) +} + +func TestChallengeProtocolBOLDStartStepChallenge(t *testing.T) { + testChallengeProtocolBOLDWithMachineMock(t, func(honest server_arb.MachineInterface) server_arb.MachineInterface { + return NewIncorrectIntermediateMachine(honest, 0) + }) +} + +func testChallengeProtocolBOLDWithMachineMock(t *testing.T, machineMock func(server_arb.MachineInterface) server_arb.MachineInterface) { Require(t, os.RemoveAll("/tmp/good")) Require(t, os.RemoveAll("/tmp/evil")) t.Cleanup(func() { @@ -137,7 +148,7 @@ func TestChallengeProtocolBOLD(t *testing.T) { valCfg := valnode.TestValidationConfig valCfg.UseJit = false - _, valStack := createTestValidationNode(t, ctx, &valCfg) + _, valStack := createTestValidationNode(t, ctx, &valCfg, nil) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( @@ -154,7 +165,7 @@ func TestChallengeProtocolBOLD(t *testing.T) { err = statelessA.Start(ctx) Require(t, err) - _, valStackB := createTestValidationNode(t, ctx, &valCfg) + _, valStackB := createTestValidationNode(t, ctx, &valCfg, machineMock) statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, @@ -464,6 +475,7 @@ func TestChallengeProtocolBOLD(t *testing.T) { if address == l1info.GetDefaultTransactOpts("Asserter", ctx).From { t.Log("Honest party won OSP, impossible for evil party to win if honest party continues") Require(t, it.Close()) + time.Sleep(time.Second * 10) return } } diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 420b38f7e5..8d84dae8eb 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -370,7 +370,7 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * _, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol(t, ctx, false, nil, l2chainConfig, nil, l2info) valnode.TestValidationConfig.UseJit = false - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) blockValidatorConfig := staker.TestBlockValidatorConfig stateless, err := staker.NewStatelessBlockValidator( diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 027a41d875..28ae6f762f 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -39,6 +39,7 @@ import ( "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/validator/inputs" "github.com/offchainlabs/nitro/validator/server_api" + "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" @@ -1079,7 +1080,7 @@ func destroyRedisGroup(ctx context.Context, t *testing.T, streamName string, cli } } -func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode.Config) (*valnode.ValidationNode, *node.Node) { +func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode.Config, arbitratorMachineMock func(server_arb.MachineInterface) server_arb.MachineInterface) (*valnode.ValidationNode, *node.Node) { stackConf := node.DefaultConfig stackConf.HTTPPort = 0 stackConf.DataDir = "" @@ -1096,7 +1097,7 @@ func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode Require(t, err) configFetcher := func() *valnode.Config { return config } - valnode, err := valnode.CreateValidationNode(configFetcher, stack, nil) + valnode, err := valnode.CreateValidationNode(configFetcher, stack, nil, arbitratorMachineMock) Require(t, err) err = stack.Start() @@ -1168,7 +1169,7 @@ func AddValNode(t *testing.T, ctx context.Context, nodeConfig *arbnode.Config, u t.Cleanup(func() { destroyRedisGroup(ctx, t, redisStream, redisClient) }) conf.Arbitrator.RedisValidationServerConfig.ModuleRoots = []string{currentRootModule(t).Hex()} } - _, valStack := createTestValidationNode(t, ctx, &conf) + _, valStack := createTestValidationNode(t, ctx, &conf, nil) configByValidationNode(nodeConfig, valStack) } diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index 8eb71bffd4..2051f25b55 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -140,7 +140,7 @@ func TestFastConfirmation(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) blockValidatorConfig := staker.TestBlockValidatorConfig stateless, err := staker.NewStatelessBlockValidator( @@ -341,7 +341,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index 4d902f87ba..1108ec9889 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -265,7 +265,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall } else { // For now validation only works with HashScheme set builder.execConfig.Caching.StateScheme = rawdb.HashScheme - _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig) + _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig, nil) } configByValidationNode(conf, valStack) diff --git a/system_tests/mock_machine_test.go b/system_tests/mock_machine_test.go new file mode 100644 index 0000000000..7a71e81d2d --- /dev/null +++ b/system_tests/mock_machine_test.go @@ -0,0 +1,40 @@ +// Copyright 2021-2022, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package arbtest + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_arb" +) + +// IncorrectIntermediateMachine will report an incorrect hash while running from incorrectStep onwards. +// However, it'll reach the correct final hash and global state once finished. +type IncorrectIntermediateMachine struct { + server_arb.MachineInterface + incorrectStep uint64 +} + +var _ server_arb.MachineInterface = (*IncorrectIntermediateMachine)(nil) + +func NewIncorrectIntermediateMachine(inner server_arb.MachineInterface, incorrectStep uint64) *IncorrectIntermediateMachine { + return &IncorrectIntermediateMachine{ + MachineInterface: inner, + incorrectStep: incorrectStep, + } +} + +func (m *IncorrectIntermediateMachine) CloneMachineInterface() server_arb.MachineInterface { + return &IncorrectIntermediateMachine{ + MachineInterface: m.MachineInterface.CloneMachineInterface(), + incorrectStep: m.incorrectStep, + } +} + +func (m *IncorrectIntermediateMachine) Hash() common.Hash { + h := m.MachineInterface.Hash() + if m.GetStepCount() >= m.incorrectStep && m.IsRunning() { + h[0] = 0xFF + } + return h +} diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 4c896d1791..dd59124f78 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1520,7 +1520,7 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) valConf := valnode.TestValidationConfig valConf.UseJit = jit - _, valStack := createTestValidationNode(t, ctx, &valConf) + _, valStack := createTestValidationNode(t, ctx, &valConf, nil) configByValidationNode(builder.nodeConfig, valStack) builder.execConfig.Sequencer.MaxRevertGasReject = 0 diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 69645d8878..a1ac337040 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -193,7 +193,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index f65dbe04ba..02060a1240 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -105,7 +105,8 @@ func (e *executionRun) machineHashesWithStepSize( if err != nil { return nil, err } - log.Debug(fmt.Sprintf("Advanced machine to index %d, beginning hash computation", machineStartIndex)) + log.Info(fmt.Sprintf("Advanced machine to index %d, beginning hash computation", machineStartIndex)) + fmt.Printf("got machine type %T\n", machine) // In BOLD, the hash of a machine at index 0 is a special hash that is computed as the // `machineFinishedHash(gs)` where `gs` is the global state of the machine at index 0. @@ -114,7 +115,7 @@ func (e *executionRun) machineHashesWithStepSize( var machineHashes []common.Hash if machineStartIndex == 0 { gs := machine.GetGlobalState() - log.Debug(fmt.Sprintf("Start global state for machine index 0: %+v", gs)) + log.Info(fmt.Sprintf("Start global state for machine index 0: %+v", gs)) machineHashes = append(machineHashes, machineFinishedHash(gs)) } else { // Otherwise, we simply append the machine hash at the specified start index. diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index 479db58515..3e86c2cdd0 100644 --- a/validator/server_arb/execution_run_test.go +++ b/validator/server_arb/execution_run_test.go @@ -47,6 +47,9 @@ func (m *mockMachine) GetStepCount() uint64 { func (m *mockMachine) IsRunning() bool { return m.gs.PosInBatch < m.totalSteps-1 } +func (m *mockMachine) IsErrored() bool { + return false +} func (m *mockMachine) ValidForStep(uint64) bool { return true } diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 1e73e6b212..637caf9b5d 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -37,6 +37,7 @@ type MachineInterface interface { CloneMachineInterface() MachineInterface GetStepCount() uint64 IsRunning() bool + IsErrored() bool ValidForStep(uint64) bool Status() uint8 Step(context.Context, uint64) error diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 07971e2ba5..8af46e9c33 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -61,14 +61,16 @@ type ArbitratorSpawner struct { count atomic.Int32 locator *server_common.MachineLocator machineLoader *ArbMachineLoader + machineMock func(MachineInterface) MachineInterface config ArbitratorSpawnerConfigFecher } -func NewArbitratorSpawner(locator *server_common.MachineLocator, config ArbitratorSpawnerConfigFecher) (*ArbitratorSpawner, error) { +func NewArbitratorSpawner(locator *server_common.MachineLocator, config ArbitratorSpawnerConfigFecher, machineMock func(MachineInterface) MachineInterface) (*ArbitratorSpawner, error) { // TODO: preload machines spawner := &ArbitratorSpawner{ locator: locator, machineLoader: NewArbMachineLoader(&DefaultArbitratorMachineConfig, locator), + machineMock: machineMock, config: config, } return spawner, nil @@ -159,12 +161,16 @@ func (v *ArbitratorSpawner) execute( return validator.GoGlobalState{}, fmt.Errorf("unabled to get WASM machine: %w", err) } - mach := basemachine.Clone() - defer mach.Destroy() - err = v.loadEntryToMachine(ctx, entry, mach) + arbMach := basemachine.Clone() + defer arbMach.Destroy() + err = v.loadEntryToMachine(ctx, entry, arbMach) if err != nil { return validator.GoGlobalState{}, err } + var mach MachineInterface = arbMach + if v.machineMock != nil { + mach = v.machineMock(mach) + } var steps uint64 for mach.IsRunning() { var count uint64 = 500000000 @@ -218,7 +224,11 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input machine.Destroy() return nil, err } - return machine, nil + if v.machineMock != nil { + return v.machineMock(machine), nil + } else { + return machine, nil + } } currentExecConfig := v.config().Execution return stopwaiter.LaunchPromiseThread[validator.ExecutionRun](v, func(ctx context.Context) (validator.ExecutionRun, error) { diff --git a/validator/valnode/valnode.go b/validator/valnode/valnode.go index 972e11189d..8e59e66ee8 100644 --- a/validator/valnode/valnode.go +++ b/validator/valnode/valnode.go @@ -93,7 +93,7 @@ func EnsureValidationExposedViaAuthRPC(stackConf *node.Config) { } } -func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Node, fatalErrChan chan error) (*ValidationNode, error) { +func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Node, fatalErrChan chan error, arbitratorMachineMock func(server_arb.MachineInterface) server_arb.MachineInterface) (*ValidationNode, error) { config := configFetcher() locator, err := server_common.NewMachineLocator(config.Wasm.RootPath) if err != nil { @@ -102,7 +102,7 @@ func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Nod arbConfigFetcher := func() *server_arb.ArbitratorSpawnerConfig { return &configFetcher().Arbitrator } - arbSpawner, err := server_arb.NewArbitratorSpawner(locator, arbConfigFetcher) + arbSpawner, err := server_arb.NewArbitratorSpawner(locator, arbConfigFetcher, arbitratorMachineMock) if err != nil { return nil, err } From 4649a541fe34bb143d5b22a2e486c2935a7dfe0b Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 31 Oct 2024 14:22:18 +0100 Subject: [PATCH 086/210] Update the pin for the bold submodule This is the current unify-req-meta branch which fixes a bug in one-step proof calculation. --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index d48cb15395..56579e55b4 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit d48cb153957ffff4e4fcebf1f19bb42fcd1f448f +Subproject commit 56579e55b462d079f8cd6634948757ba3a02ea6d From 493f45bce37060a030bad7286524c00dc978b727 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 1 Nov 2024 14:48:54 -0300 Subject: [PATCH 087/210] Sets contextId to zero when destroying a machine --- validator/server_arb/machine.go | 1 + validator/server_arb/machine_test.go | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index a9475c7f7c..198e76370c 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -77,6 +77,7 @@ func (m *ArbitratorMachine) Destroy() { preimageResolvers.Delete(m.contextId) } } + m.contextId = 0 } func machineFromPointer(ptr *C.struct_Machine) *ArbitratorMachine { diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go index b6b64c4b53..cd3e326385 100644 --- a/validator/server_arb/machine_test.go +++ b/validator/server_arb/machine_test.go @@ -49,8 +49,8 @@ func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { err = machine2.SetPreimageResolver(resolver) testhelpers.RequireImpl(t, err) - machine1_clone1 := machine1.Clone() - machine1_clone2 := machine1.Clone() + machine1Clone1 := machine1.Clone() + machine1Clone2 := machine1.Clone() checkKeys := func(expectedKeys []int64, scenario string) { keys := sortedKeys() @@ -59,17 +59,23 @@ func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { } } - checkKeys([]int64{machine1.contextId, machine2.contextId}, "initial") + machine1ContextId := machine1.contextId + machine2ContextId := machine2.contextId - machine1_clone1.Destroy() - checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1_clone1 destroy") + checkKeys([]int64{machine1ContextId, machine2ContextId}, "initial") + + machine1Clone1.Destroy() + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1Clone1 is destroyed") + + machine1.Destroy() + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed") machine1.Destroy() - checkKeys([]int64{machine1.contextId, machine2.contextId}, "after machine1 destroy") + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed again") - machine1_clone2.Destroy() - checkKeys([]int64{machine2.contextId}, "after machine1_clone2 destroy") + machine1Clone2.Destroy() + checkKeys([]int64{machine2ContextId}, "after machine1Clone2 is destroyed") machine2.Destroy() - checkKeys([]int64{}, "after machine2 destroy") + checkKeys([]int64{}, "after machine2 is destroyed") } From 7ca0f246b82fa180dc2d2f80d3f70c0a089fcc1e Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 1 Nov 2024 14:55:49 -0300 Subject: [PATCH 088/210] contextId as pointer to avoid worrying about what are the valid context ids --- validator/server_arb/machine.go | 25 +++++++++++++++---------- validator/server_arb/machine_test.go | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 198e76370c..b2312368c3 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -51,7 +51,7 @@ type MachineInterface interface { type ArbitratorMachine struct { mutex sync.Mutex // needed because go finalizers don't synchronize (meaning they aren't thread safe) ptr *C.struct_Machine - contextId int64 + contextId *int64 frozen bool // does not allow anything that changes machine state, not cloned with the machine } @@ -71,13 +71,16 @@ func (m *ArbitratorMachine) Destroy() { // We no longer need a finalizer runtime.SetFinalizer(m, nil) } - resolverWithRefCounter, ok := preimageResolvers.Load(m.contextId) - if ok { - if resolverWithRefCounter.refCounter.Add(-1) == 0 { - preimageResolvers.Delete(m.contextId) + + if m.contextId != nil { + resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) + if ok { + if resolverWithRefCounter.refCounter.Add(-1) == 0 { + preimageResolvers.Delete(*m.contextId) + } } } - m.contextId = 0 + m.contextId = nil } func machineFromPointer(ptr *C.struct_Machine) *ArbitratorMachine { @@ -115,9 +118,11 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId - resolverWithRefCounter, ok := preimageResolvers.Load(m.contextId) - if ok { - resolverWithRefCounter.refCounter.Add(1) + if m.contextId != nil { + resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) + if ok { + resolverWithRefCounter.refCounter.Add(1) + } } return newMach @@ -404,7 +409,7 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err } preimageResolvers.Store(id, resolverWithRefCounter) - m.contextId = id + m.contextId = &id C.arbitrator_set_context(m.ptr, u64(id)) return nil } diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go index cd3e326385..e18ee5788c 100644 --- a/validator/server_arb/machine_test.go +++ b/validator/server_arb/machine_test.go @@ -59,8 +59,8 @@ func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { } } - machine1ContextId := machine1.contextId - machine2ContextId := machine2.contextId + machine1ContextId := *machine1.contextId + machine2ContextId := *machine2.contextId checkKeys([]int64{machine1ContextId, machine2ContextId}, "initial") From d71865a2231bd815b97beff2a824b5069c8b9a8a Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 1 Nov 2024 14:58:45 -0300 Subject: [PATCH 089/210] Simplifies if --- validator/server_arb/machine.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index b2312368c3..e8a4164ed5 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -74,10 +74,8 @@ func (m *ArbitratorMachine) Destroy() { if m.contextId != nil { resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) - if ok { - if resolverWithRefCounter.refCounter.Add(-1) == 0 { - preimageResolvers.Delete(*m.contextId) - } + if ok && (resolverWithRefCounter.refCounter.Add(-1) == 0) { + preimageResolvers.Delete(*m.contextId) } } m.contextId = nil From b38a1fa160af377635999ec8e800439032f01bf5 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 1 Nov 2024 21:23:30 +0100 Subject: [PATCH 090/210] WIP: Add the boldmach wrapper This *should* be able to wrap an arbitrator machine and do the special handling for the BoLD protocol to make it look like there is one more machine state at the front of processing a machine. --- arbitrator/prover/src/lib.rs | 6 + arbitrator/prover/src/machine.rs | 30 ++++ bold | 2 +- system_tests/bold_challenge_protocol_test.go | 24 ++- system_tests/common_test.go | 4 +- validator/server_arb/boldmach/machine.go | 145 +++++++++++++++++++ validator/server_arb/execution_run.go | 15 +- validator/server_arb/machine.go | 8 + validator/server_arb/validator_spawner.go | 46 ++++-- validator/valnode/valnode.go | 4 +- 10 files changed, 244 insertions(+), 40 deletions(-) create mode 100644 validator/server_arb/boldmach/machine.go diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 08473c2598..2e8ccfcfd5 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -127,6 +127,12 @@ pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) } } +#[no_mangle] +#[cfg(feature = "native")] +pub unsafe extern "C" fn arbitrator_new_finished() -> *mut Machine { + Box::into_raw(Box::new(Machine::new_finished())) +} + unsafe fn cstr_to_string(c_str: *const c_char) -> String { CStr::from_ptr(c_str).to_string_lossy().into_owned() } diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index dec355ac7c..21a7e48694 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1565,6 +1565,36 @@ impl Machine { Ok(mach) } + // new_finished returns a Machine in the Finished state. + // + // This allows the Mahine to be set up to model the final state of the + // machine at the end of the execution of a block. + // + // Callers should use set_global_state to set the global state of the + // machine to the global state at the end of the block. + pub fn new_finished() -> Machine { + Machine { + steps: 0, + thread_state: ThreadState::Main, + status: MachineStatus::Finished, + value_stacks: Default::default(), + internal_stack: Default::default(), + frame_stacks: Default::default(), + modules: Default::default(), + modules_merkle: Default::default(), + global_state: Default::default(), + pc: Default::default(), + stdio_output: Default::default(), + inbox_contents: Default::default(), + first_too_far: Default::default(), + preimage_resolver: PreimageResolverWrapper::new(Arc::new(|_, _, _| None)), + stylus_modules: Default::default(), + initial_hash: Default::default(), + context: Default::default(), + debug_info: Default::default(), + } + } + pub fn new_from_wavm(wavm_binary: &Path) -> Result { let mut modules: Vec = { let compressed = std::fs::read(wavm_binary)?; diff --git a/bold b/bold index 56579e55b4..491164ae0d 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 56579e55b462d079f8cd6634948757ba3a02ea6d +Subproject commit 491164ae0df4195962ad84ce4264087428195096 diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 8b1cc10b98..ddfdb34f90 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -55,6 +55,7 @@ import ( "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/validator/server_arb" + "github.com/offchainlabs/nitro/validator/server_arb/boldmach" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" ) @@ -66,16 +67,19 @@ var ( ) func TestChallengeProtocolBOLDReadInboxChallenge(t *testing.T) { - testChallengeProtocolBOLDWithMachineMock(t, nil) + testChallengeProtocolBOLD(t) } func TestChallengeProtocolBOLDStartStepChallenge(t *testing.T) { - testChallengeProtocolBOLDWithMachineMock(t, func(honest server_arb.MachineInterface) server_arb.MachineInterface { - return NewIncorrectIntermediateMachine(honest, 0) - }) + opts := []server_arb.SpawnerOption{ + server_arb.WithWrapper(func(inner server_arb.MachineInterface) server_arb.MachineInterface { + return NewIncorrectIntermediateMachine(inner, 0) + }), + } + testChallengeProtocolBOLD(t, opts...) } -func testChallengeProtocolBOLDWithMachineMock(t *testing.T, machineMock func(server_arb.MachineInterface) server_arb.MachineInterface) { +func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOption) { Require(t, os.RemoveAll("/tmp/good")) Require(t, os.RemoveAll("/tmp/evil")) t.Cleanup(func() { @@ -148,7 +152,11 @@ func testChallengeProtocolBOLDWithMachineMock(t *testing.T, machineMock func(ser valCfg := valnode.TestValidationConfig valCfg.UseJit = false - _, valStack := createTestValidationNode(t, ctx, &valCfg, nil) + boldWrapperOpt := server_arb.WithWrapper( + func(inner server_arb.MachineInterface) server_arb.MachineInterface { + return boldmach.MachineWrapper(inner) + }) + _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( @@ -164,8 +172,8 @@ func testChallengeProtocolBOLDWithMachineMock(t *testing.T, machineMock func(ser Require(t, err) err = statelessA.Start(ctx) Require(t, err) - - _, valStackB := createTestValidationNode(t, ctx, &valCfg, machineMock) + spawnerOpts = append([]server_arb.SpawnerOption{boldWrapperOpt}, spawnerOpts...) + _, valStackB := createTestValidationNode(t, ctx, &valCfg, spawnerOpts...) statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 28ae6f762f..a3618cbdf1 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1080,7 +1080,7 @@ func destroyRedisGroup(ctx context.Context, t *testing.T, streamName string, cli } } -func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode.Config, arbitratorMachineMock func(server_arb.MachineInterface) server_arb.MachineInterface) (*valnode.ValidationNode, *node.Node) { +func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode.Config, spawnerOpts ...server_arb.SpawnerOption) (*valnode.ValidationNode, *node.Node) { stackConf := node.DefaultConfig stackConf.HTTPPort = 0 stackConf.DataDir = "" @@ -1097,7 +1097,7 @@ func createTestValidationNode(t *testing.T, ctx context.Context, config *valnode Require(t, err) configFetcher := func() *valnode.Config { return config } - valnode, err := valnode.CreateValidationNode(configFetcher, stack, nil, arbitratorMachineMock) + valnode, err := valnode.CreateValidationNode(configFetcher, stack, nil, spawnerOpts...) Require(t, err) err = stack.Start() diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go new file mode 100644 index 0000000000..6cee1dea84 --- /dev/null +++ b/validator/server_arb/boldmach/machine.go @@ -0,0 +1,145 @@ +package boldmach + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_arb" +) + +// boldMachine wraps a server_arb.MachineInterface. +type boldMachine struct { + server_arb.MachineInterface + zeroMachine *server_arb.ArbitratorMachine + hasStepped bool +} + +// Ensure boldMachine implements server_arb.MachineInterface. +var _ server_arb.MachineInterface = (*boldMachine)(nil) + +// MachineWrapper wraps a server_arb.MachineInterface and adds one step to the +// front of the machine's execution. +// +// This zeroth step should be at the same global state as the inner arbitrator +// machine has at step 0, but the machine is in the Finished state rather than +// the Running state. +func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { + z := server_arb.NewFinishedMachine() + z.SetGlobalState(inner.GetGlobalState()) + return &boldMachine{ + MachineInterface: inner, + zeroMachine: z, + hasStepped: false, + } +} + +// CloneMachineInterface returns a new boldMachine with the same inner machine. +func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { + c := MachineWrapper(m.MachineInterface.CloneMachineInterface()) + c.(*boldMachine).hasStepped = m.hasStepped + return c +} + +// GetStepCount returns zero if the machine has not stepped, otherwise it +// returns the inner machine's step count plus one. +func (m *boldMachine) GetStepCount() uint64 { + if !m.hasStepped { + return 0 + } + return m.MachineInterface.GetStepCount() + 1 +} + +// Hash returns the hash of the inner machine if the machine has not stepped, +// otherwise it returns the hash of the zeroth step machine. +func (m *boldMachine) Hash() common.Hash { + if !m.hasStepped { + return m.MachineInterface.Hash() + } + return m.zeroMachine.Hash() +} + +// Destroy destroys the inner machine and the zeroth step machine. +func (m *boldMachine) Destroy() { + m.MachineInterface.Destroy() + m.zeroMachine.Destroy() +} + +// Freeze freezes the inner machine and the zeroth step machine. +func (m *boldMachine) Freeze() { + m.MachineInterface.Freeze() + m.zeroMachine.Freeze() +} + +// Status returns the status of the inner machine if the machine has not +// stepped, otherwise it returns the status of the zeroth step machine. +func (m *boldMachine) Status() uint8 { + if !m.hasStepped { + return m.MachineInterface.Status() + } + return m.zeroMachine.Status() +} + +// IsRunning returns the running state of the zeroeth state machine if the +// machine has not stepped, otherwise it returns the running state of the +// inner machine. +func (m *boldMachine) IsRunning() bool { + if !m.hasStepped { + return m.zeroMachine.IsRunning() + } + return m.MachineInterface.IsRunning() +} + +// IsErrored returns the errored state of the inner machine, or false if the +// machine has not stepped. +func (m *boldMachine) IsErrored() bool { + if !m.hasStepped { + return false + } + return m.MachineInterface.IsErrored() +} + +// Step steps the inner machine if the machine has not stepped, otherwise it +// steps the zeroth step machine. +func (m *boldMachine) Step(ctx context.Context, steps uint64) error { + if !m.hasStepped { + if steps == 0 { + // Zero is okay, but doesn't advance the machine. + return nil + } + m.hasStepped = true + // Only the first step or set of steps needs to be adjusted. + steps = steps - 1 + } + return m.MachineInterface.Step(ctx, steps) +} + +// ValidForStep returns true for step 0, and the inner machine's ValidForStep +// for the step minus one. +func (m *boldMachine) ValidForStep(step uint64) bool { + if step == 0 { + return true + } + return m.MachineInterface.ValidForStep(step - 1) +} + +// GetGlobalState returns the global state of the inner machine if the machine +// has stepped, otherwise it returns the global state of the zeroth step. +func (m *boldMachine) GetGlobalState() validator.GoGlobalState { + if !m.hasStepped { + return m.zeroMachine.GetGlobalState() + } + return m.MachineInterface.GetGlobalState() +} + +// ProveNextStep returns the proof of the next step of the inner machine if the +// machine has stepped, otherwise it returns the proof that the zeroth step +// results in the inner machine's initial global state. +func (m *boldMachine) ProveNextStep() []byte { + if !m.hasStepped { + // NOT AT ALL SURE ABOUT THIS. I THINK IT'S WRONG. + return m.zeroMachine.ProveNextStep() + } + return m.MachineInterface.ProveNextStep() +} diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index 02060a1240..9cfceea7d2 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -10,7 +10,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/util/containers" @@ -112,15 +111,7 @@ func (e *executionRun) machineHashesWithStepSize( // `machineFinishedHash(gs)` where `gs` is the global state of the machine at index 0. // This is so that the hash aligns with the start state of the claimed challenge edge // at the level above, as required by the BOLD protocol. - var machineHashes []common.Hash - if machineStartIndex == 0 { - gs := machine.GetGlobalState() - log.Info(fmt.Sprintf("Start global state for machine index 0: %+v", gs)) - machineHashes = append(machineHashes, machineFinishedHash(gs)) - } else { - // Otherwise, we simply append the machine hash at the specified start index. - machineHashes = append(machineHashes, machine.Hash()) - } + machineHashes := []common.Hash{machine.Hash()} startHash := machineHashes[0] // If we only want 1 hash, we can return early. @@ -199,7 +190,3 @@ func (e *executionRun) GetLastStep() containers.PromiseInterface[*validator.Mach func (e *executionRun) CheckAlive(ctx context.Context) error { return nil } - -func machineFinishedHash(gs validator.GoGlobalState) common.Hash { - return crypto.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) -} diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 637caf9b5d..bc890870a5 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -102,6 +102,14 @@ func LoadSimpleMachine(wasm string, libraries []string, debugChain bool) (*Arbit return machineFromPointer(mach), nil } +func NewFinishedMachine() *ArbitratorMachine { + mach := C.arbitrator_new_finished() + if mach == nil { + return nil + } + return machineFromPointer(mach) +} + func (m *ArbitratorMachine) Freeze() { m.frozen = true } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 8af46e9c33..7bbb8ffcc1 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -56,22 +56,42 @@ func DefaultArbitratorSpawnerConfigFetcher() *ArbitratorSpawnerConfig { return &DefaultArbitratorSpawnerConfig } +// MachineWrapper is a function that wraps a MachineInterface +// +// This is a mechanism to allow clients of the AribtratorSpawner to inject +// functionality around the arbitrator machine. Possible use cases include +// mocking out the machine for testing purposes, or having the machine behave +// differently when certain features (like BoLD) are enabled. +type MachineWrapper func(MachineInterface) MachineInterface + +type SpawnerOption func(*ArbitratorSpawner) + type ArbitratorSpawner struct { stopwaiter.StopWaiter count atomic.Int32 locator *server_common.MachineLocator machineLoader *ArbMachineLoader - machineMock func(MachineInterface) MachineInterface - config ArbitratorSpawnerConfigFecher + // Oreder of wrappers is important. The first wrapper is the innermost. + machineWrappers []MachineWrapper + config ArbitratorSpawnerConfigFecher +} + +func WithWrapper(wrapper MachineWrapper) SpawnerOption { + return func(s *ArbitratorSpawner) { + s.machineWrappers = append(s.machineWrappers, wrapper) + } } -func NewArbitratorSpawner(locator *server_common.MachineLocator, config ArbitratorSpawnerConfigFecher, machineMock func(MachineInterface) MachineInterface) (*ArbitratorSpawner, error) { +func NewArbitratorSpawner(locator *server_common.MachineLocator, config ArbitratorSpawnerConfigFecher, opts ...SpawnerOption) (*ArbitratorSpawner, error) { // TODO: preload machines spawner := &ArbitratorSpawner{ - locator: locator, - machineLoader: NewArbMachineLoader(&DefaultArbitratorMachineConfig, locator), - machineMock: machineMock, - config: config, + locator: locator, + machineLoader: NewArbMachineLoader(&DefaultArbitratorMachineConfig, locator), + machineWrappers: make([]MachineWrapper, 0), + config: config, + } + for _, opt := range opts { + opt(spawner) } return spawner, nil } @@ -168,8 +188,8 @@ func (v *ArbitratorSpawner) execute( return validator.GoGlobalState{}, err } var mach MachineInterface = arbMach - if v.machineMock != nil { - mach = v.machineMock(mach) + for _, wrapper := range v.machineWrappers { + mach = wrapper(mach) } var steps uint64 for mach.IsRunning() { @@ -224,11 +244,11 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input machine.Destroy() return nil, err } - if v.machineMock != nil { - return v.machineMock(machine), nil - } else { - return machine, nil + wrapped := MachineInterface(machine) + for _, wrapper := range v.machineWrappers { + wrapped = wrapper(wrapped) } + return wrapped, nil } currentExecConfig := v.config().Execution return stopwaiter.LaunchPromiseThread[validator.ExecutionRun](v, func(ctx context.Context) (validator.ExecutionRun, error) { diff --git a/validator/valnode/valnode.go b/validator/valnode/valnode.go index 8e59e66ee8..fbb1a4964e 100644 --- a/validator/valnode/valnode.go +++ b/validator/valnode/valnode.go @@ -93,7 +93,7 @@ func EnsureValidationExposedViaAuthRPC(stackConf *node.Config) { } } -func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Node, fatalErrChan chan error, arbitratorMachineMock func(server_arb.MachineInterface) server_arb.MachineInterface) (*ValidationNode, error) { +func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Node, fatalErrChan chan error, spawnerOpts ...server_arb.SpawnerOption) (*ValidationNode, error) { config := configFetcher() locator, err := server_common.NewMachineLocator(config.Wasm.RootPath) if err != nil { @@ -102,7 +102,7 @@ func CreateValidationNode(configFetcher ValidationConfigFetcher, stack *node.Nod arbConfigFetcher := func() *server_arb.ArbitratorSpawnerConfig { return &configFetcher().Arbitrator } - arbSpawner, err := server_arb.NewArbitratorSpawner(locator, arbConfigFetcher, arbitratorMachineMock) + arbSpawner, err := server_arb.NewArbitratorSpawner(locator, arbConfigFetcher, spawnerOpts...) if err != nil { return nil, err } From 976a18f9410d889bb570014b7df75cd42fdc4eaf Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 1 Nov 2024 21:46:36 +0100 Subject: [PATCH 091/210] Fix the two obviously errored hasStepped bits This still doesn't get the test passing, but it's bound to be closer. --- validator/server_arb/boldmach/machine.go | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go index 6cee1dea84..d5b20f25ca 100644 --- a/validator/server_arb/boldmach/machine.go +++ b/validator/server_arb/boldmach/machine.go @@ -11,7 +11,7 @@ import ( // boldMachine wraps a server_arb.MachineInterface. type boldMachine struct { - server_arb.MachineInterface + inner server_arb.MachineInterface zeroMachine *server_arb.ArbitratorMachine hasStepped bool } @@ -29,15 +29,15 @@ func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterfa z := server_arb.NewFinishedMachine() z.SetGlobalState(inner.GetGlobalState()) return &boldMachine{ - MachineInterface: inner, - zeroMachine: z, - hasStepped: false, + inner: inner, + zeroMachine: z, + hasStepped: false, } } // CloneMachineInterface returns a new boldMachine with the same inner machine. func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { - c := MachineWrapper(m.MachineInterface.CloneMachineInterface()) + c := MachineWrapper(m.inner.CloneMachineInterface()) c.(*boldMachine).hasStepped = m.hasStepped return c } @@ -48,27 +48,27 @@ func (m *boldMachine) GetStepCount() uint64 { if !m.hasStepped { return 0 } - return m.MachineInterface.GetStepCount() + 1 + return m.inner.GetStepCount() + 1 } // Hash returns the hash of the inner machine if the machine has not stepped, // otherwise it returns the hash of the zeroth step machine. func (m *boldMachine) Hash() common.Hash { if !m.hasStepped { - return m.MachineInterface.Hash() + return m.zeroMachine.Hash() } - return m.zeroMachine.Hash() + return m.inner.Hash() } // Destroy destroys the inner machine and the zeroth step machine. func (m *boldMachine) Destroy() { - m.MachineInterface.Destroy() + m.inner.Destroy() m.zeroMachine.Destroy() } // Freeze freezes the inner machine and the zeroth step machine. func (m *boldMachine) Freeze() { - m.MachineInterface.Freeze() + m.inner.Freeze() m.zeroMachine.Freeze() } @@ -76,9 +76,9 @@ func (m *boldMachine) Freeze() { // stepped, otherwise it returns the status of the zeroth step machine. func (m *boldMachine) Status() uint8 { if !m.hasStepped { - return m.MachineInterface.Status() + return m.zeroMachine.Status() } - return m.zeroMachine.Status() + return m.inner.Status() } // IsRunning returns the running state of the zeroeth state machine if the @@ -88,7 +88,7 @@ func (m *boldMachine) IsRunning() bool { if !m.hasStepped { return m.zeroMachine.IsRunning() } - return m.MachineInterface.IsRunning() + return m.inner.IsRunning() } // IsErrored returns the errored state of the inner machine, or false if the @@ -97,7 +97,7 @@ func (m *boldMachine) IsErrored() bool { if !m.hasStepped { return false } - return m.MachineInterface.IsErrored() + return m.inner.IsErrored() } // Step steps the inner machine if the machine has not stepped, otherwise it @@ -112,7 +112,7 @@ func (m *boldMachine) Step(ctx context.Context, steps uint64) error { // Only the first step or set of steps needs to be adjusted. steps = steps - 1 } - return m.MachineInterface.Step(ctx, steps) + return m.inner.Step(ctx, steps) } // ValidForStep returns true for step 0, and the inner machine's ValidForStep @@ -121,7 +121,7 @@ func (m *boldMachine) ValidForStep(step uint64) bool { if step == 0 { return true } - return m.MachineInterface.ValidForStep(step - 1) + return m.inner.ValidForStep(step - 1) } // GetGlobalState returns the global state of the inner machine if the machine @@ -130,7 +130,7 @@ func (m *boldMachine) GetGlobalState() validator.GoGlobalState { if !m.hasStepped { return m.zeroMachine.GetGlobalState() } - return m.MachineInterface.GetGlobalState() + return m.inner.GetGlobalState() } // ProveNextStep returns the proof of the next step of the inner machine if the @@ -141,5 +141,5 @@ func (m *boldMachine) ProveNextStep() []byte { // NOT AT ALL SURE ABOUT THIS. I THINK IT'S WRONG. return m.zeroMachine.ProveNextStep() } - return m.MachineInterface.ProveNextStep() + return m.inner.ProveNextStep() } From 4c316e531cee0e8521a64a379ff85ed1c435b338 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 2 Nov 2024 09:16:11 -0500 Subject: [PATCH 092/210] Fix TestChallengeProtocolBOLDStartStepChallenge --- arbitrator/prover/src/machine.rs | 22 ++++++++++---- .../multi_protocol/multi_protocol_staker.go | 4 +-- system_tests/bold_challenge_protocol_test.go | 5 +++- system_tests/bold_state_provider_test.go | 2 +- system_tests/common_test.go | 2 +- system_tests/fast_confirm_test.go | 4 +-- system_tests/full_challenge_impl_test.go | 2 +- system_tests/program_test.go | 2 +- system_tests/staker_test.go | 2 +- validator/server_arb/boldmach/machine.go | 30 ++++++++++++------- validator/server_arb/execution_run_test.go | 11 +++++++ validator/server_arb/machine_test.go | 13 ++++++++ 12 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 validator/server_arb/machine_test.go diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 21a7e48694..7cbdeb3cac 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1565,7 +1565,7 @@ impl Machine { Ok(mach) } - // new_finished returns a Machine in the Finished state. + // new_finished returns a Machine in the Finished state at step 0. // // This allows the Mahine to be set up to model the final state of the // machine at the end of the execution of a block. @@ -1575,14 +1575,17 @@ impl Machine { pub fn new_finished() -> Machine { Machine { steps: 0, - thread_state: ThreadState::Main, status: MachineStatus::Finished, - value_stacks: Default::default(), + global_state: Default::default(), + // The machine is in the Finished state, so nothing else really matters. + // values_stacks and frame_stacks cannot be empty for proof serialization, + // but everything else can just be entirely blank. + thread_state: ThreadState::Main, + value_stacks: vec![Vec::new()], + frame_stacks: vec![Vec::new()], internal_stack: Default::default(), - frame_stacks: Default::default(), modules: Default::default(), modules_merkle: Default::default(), - global_state: Default::default(), pc: Default::default(), stdio_output: Default::default(), inbox_contents: Default::default(), @@ -2897,6 +2900,15 @@ impl Machine { let mod_merkle = self.get_modules_merkle(); out!(mod_merkle.root()); + if self.is_halted() { + // If the machine is halted, instead of serializing the module, + // serialize the global state and return. + // This is for the "kickstart" BoLD proof, but it's backwards compatible + // with the old OSP behavior which reads no further. + out!(self.global_state.serialize()); + return data; + } + // End machine serialization, serialize module let module = &self.modules[self.pc.module()]; diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index d4d4e1b54f..f8bc46fa2b 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -5,12 +5,12 @@ import ( "github.com/offchainlabs/nitro/staker" "time" - "github.com/offchainlabs/bold/solgen/go/bridgegen" - boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/bold/solgen/go/bridgegen" + boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" boldstaker "github.com/offchainlabs/nitro/staker/bold" legacystaker "github.com/offchainlabs/nitro/staker/legacy" diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index ddfdb34f90..efba373765 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -73,7 +73,10 @@ func TestChallengeProtocolBOLDReadInboxChallenge(t *testing.T) { func TestChallengeProtocolBOLDStartStepChallenge(t *testing.T) { opts := []server_arb.SpawnerOption{ server_arb.WithWrapper(func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return NewIncorrectIntermediateMachine(inner, 0) + // This wrapper is applied after the BOLD wrapper, so step 0 is the finished machine. + // Modifying its hash results in invalid inclusion proofs for the evil validator, + // so we start modifying hashes at step 1 (the first machine step in the running state). + return NewIncorrectIntermediateMachine(inner, 1) }), } testChallengeProtocolBOLD(t, opts...) diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 8d84dae8eb..420b38f7e5 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -370,7 +370,7 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * _, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol(t, ctx, false, nil, l2chainConfig, nil, l2info) valnode.TestValidationConfig.UseJit = false - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) blockValidatorConfig := staker.TestBlockValidatorConfig stateless, err := staker.NewStatelessBlockValidator( diff --git a/system_tests/common_test.go b/system_tests/common_test.go index a3618cbdf1..cab5b29805 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1169,7 +1169,7 @@ func AddValNode(t *testing.T, ctx context.Context, nodeConfig *arbnode.Config, u t.Cleanup(func() { destroyRedisGroup(ctx, t, redisStream, redisClient) }) conf.Arbitrator.RedisValidationServerConfig.ModuleRoots = []string{currentRootModule(t).Hex()} } - _, valStack := createTestValidationNode(t, ctx, &conf, nil) + _, valStack := createTestValidationNode(t, ctx, &conf) configByValidationNode(nodeConfig, valStack) } diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index 2051f25b55..8eb71bffd4 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -140,7 +140,7 @@ func TestFastConfirmation(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) blockValidatorConfig := staker.TestBlockValidatorConfig stateless, err := staker.NewStatelessBlockValidator( @@ -341,7 +341,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index 1108ec9889..4d902f87ba 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -265,7 +265,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall } else { // For now validation only works with HashScheme set builder.execConfig.Caching.StateScheme = rawdb.HashScheme - _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig, nil) + _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig) } configByValidationNode(conf, valStack) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index dd59124f78..4c896d1791 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1520,7 +1520,7 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) valConf := valnode.TestValidationConfig valConf.UseJit = jit - _, valStack := createTestValidationNode(t, ctx, &valConf, nil) + _, valStack := createTestValidationNode(t, ctx, &valConf) configByValidationNode(builder.nodeConfig, valStack) builder.execConfig.Sequencer.MaxRevertGasReject = 0 diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index a1ac337040..69645d8878 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -193,7 +193,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig, nil) + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go index d5b20f25ca..6341f5510d 100644 --- a/validator/server_arb/boldmach/machine.go +++ b/validator/server_arb/boldmach/machine.go @@ -27,7 +27,12 @@ var _ server_arb.MachineInterface = (*boldMachine)(nil) // the Running state. func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { z := server_arb.NewFinishedMachine() - z.SetGlobalState(inner.GetGlobalState()) + err := z.SetGlobalState(inner.GetGlobalState()) + if err != nil { + // This should only occur if the machine is frozen, + // which it isn't because we just created it. + panic(err) + } return &boldMachine{ inner: inner, zeroMachine: z, @@ -63,13 +68,17 @@ func (m *boldMachine) Hash() common.Hash { // Destroy destroys the inner machine and the zeroth step machine. func (m *boldMachine) Destroy() { m.inner.Destroy() - m.zeroMachine.Destroy() + if !m.hasStepped { + m.zeroMachine.Destroy() + } } // Freeze freezes the inner machine and the zeroth step machine. func (m *boldMachine) Freeze() { m.inner.Freeze() - m.zeroMachine.Freeze() + if !m.hasStepped { + m.zeroMachine.Freeze() + } } // Status returns the status of the inner machine if the machine has not @@ -81,12 +90,11 @@ func (m *boldMachine) Status() uint8 { return m.inner.Status() } -// IsRunning returns the running state of the zeroeth state machine if the -// machine has not stepped, otherwise it returns the running state of the -// inner machine. +// IsRunning returns true if the machine has not stepped, otherwise it +// returns the running state of the inner machine. func (m *boldMachine) IsRunning() bool { if !m.hasStepped { - return m.zeroMachine.IsRunning() + return true } return m.inner.IsRunning() } @@ -109,17 +117,18 @@ func (m *boldMachine) Step(ctx context.Context, steps uint64) error { return nil } m.hasStepped = true + m.zeroMachine.Destroy() // Only the first step or set of steps needs to be adjusted. steps = steps - 1 } return m.inner.Step(ctx, steps) } -// ValidForStep returns true for step 0, and the inner machine's ValidForStep -// for the step minus one. +// ValidForStep returns true for step 0 if and only if the machine has not stepped yet, +// and the inner machine's ValidForStep for the step minus one otherwise. func (m *boldMachine) ValidForStep(step uint64) bool { if step == 0 { - return true + return !m.hasStepped } return m.inner.ValidForStep(step - 1) } @@ -138,7 +147,6 @@ func (m *boldMachine) GetGlobalState() validator.GoGlobalState { // results in the inner machine's initial global state. func (m *boldMachine) ProveNextStep() []byte { if !m.hasStepped { - // NOT AT ALL SURE ABOUT THIS. I THINK IT'S WRONG. return m.zeroMachine.ProveNextStep() } return m.inner.ProveNextStep() diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index 3e86c2cdd0..ab450504c9 100644 --- a/validator/server_arb/execution_run_test.go +++ b/validator/server_arb/execution_run_test.go @@ -14,6 +14,17 @@ type mockMachine struct { totalSteps uint64 } +func machineFinishedHash(gs validator.GoGlobalState) common.Hash { + mach := NewFinishedMachine() + err := mach.SetGlobalState(gs) + if err != nil { + panic(err) + } + hash := mach.Hash() + mach.Destroy() + return hash +} + func (m *mockMachine) Hash() common.Hash { if m.gs.PosInBatch == m.totalSteps-1 { return machineFinishedHash(m.gs) diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go new file mode 100644 index 0000000000..009de06361 --- /dev/null +++ b/validator/server_arb/machine_test.go @@ -0,0 +1,13 @@ +// Copyright 2024, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE + +package server_arb + +import "testing" + +func TestFinishedMachineProof(t *testing.T) { + mach := NewFinishedMachine() + // Just test that this doesn't panic + mach.ProveNextStep() + mach.Destroy() +} From 4aaee14bfe8eec32578da8e2a8e90d998ba827b4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 09:41:33 -0300 Subject: [PATCH 093/210] Handle SetPreimageResolver being called multiple times for the same machine --- validator/server_arb/machine.go | 19 ++++++++++++------- validator/server_arb/machine_test.go | 12 ++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index e8a4164ed5..0291185a54 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -61,6 +61,15 @@ var _ MachineInterface = (*ArbitratorMachine)(nil) var preimageResolvers containers.SyncMap[int64, goPreimageResolverWithRefCounter] var lastPreimageResolverId atomic.Int64 // atomic +func dereferenceContextId(contextId *int64) { + if contextId != nil { + resolverWithRefCounter, ok := preimageResolvers.Load(*contextId) + if ok && (resolverWithRefCounter.refCounter.Add(-1) == 0) { + preimageResolvers.Delete(*contextId) + } + } +} + // Any future calls to this machine will result in a panic func (m *ArbitratorMachine) Destroy() { m.mutex.Lock() @@ -72,12 +81,7 @@ func (m *ArbitratorMachine) Destroy() { runtime.SetFinalizer(m, nil) } - if m.contextId != nil { - resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) - if ok && (resolverWithRefCounter.refCounter.Add(-1) == 0) { - preimageResolvers.Delete(*m.contextId) - } - } + dereferenceContextId(m.contextId) m.contextId = nil } @@ -397,8 +401,9 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err if m.frozen { return errors.New("machine frozen") } - id := lastPreimageResolverId.Add(1) + dereferenceContextId(m.contextId) + id := lastPreimageResolverId.Add(1) refCounter := atomic.Int64{} refCounter.Store(1) resolverWithRefCounter := goPreimageResolverWithRefCounter{ diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go index e18ee5788c..e3ffb28b42 100644 --- a/validator/server_arb/machine_test.go +++ b/validator/server_arb/machine_test.go @@ -64,15 +64,27 @@ func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { checkKeys([]int64{machine1ContextId, machine2ContextId}, "initial") + // the machine's contextId should change when setting preimage resolver for the second time, + // and the entry for the old context id should be deleted + err = machine2.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + if machine2ContextId == *machine2.contextId { + t.Fatal("Context id didn't change after setting preimage resolver for the second time") + } + machine2ContextId = *machine2.contextId + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after setting preimage resolver for machine2 for the second time") + machine1Clone1.Destroy() checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1Clone1 is destroyed") machine1.Destroy() checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed") + // it is possible to destroy the same machine multiple times machine1.Destroy() checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed again") + // entry for machine1ContextId should be deleted only after machine1 and all its clones are destroyed machine1Clone2.Destroy() checkKeys([]int64{machine2ContextId}, "after machine1Clone2 is destroyed") From 8b81224a58c8169c430efed30c6342e01448c6e0 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 12:21:03 -0300 Subject: [PATCH 094/210] panic in case when resolver is not found, or when ref counter is negative --- validator/server_arb/machine.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 0291185a54..20b236e5a7 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -64,7 +64,14 @@ var lastPreimageResolverId atomic.Int64 // atomic func dereferenceContextId(contextId *int64) { if contextId != nil { resolverWithRefCounter, ok := preimageResolvers.Load(*contextId) - if ok && (resolverWithRefCounter.refCounter.Add(-1) == 0) { + if !ok { + panic(fmt.Sprintf("dereferenceContextId: resolver with ref counter not found, contextId: %v", *contextId)) + } + + refCounterAfter := resolverWithRefCounter.refCounter.Add(-1) + if refCounterAfter < 0 { + panic(fmt.Sprintf("dereferenceContextId: ref counter is negative, contextId: %v", *contextId)) + } else if refCounterAfter == 0 { preimageResolvers.Delete(*contextId) } } @@ -124,6 +131,8 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) if ok { resolverWithRefCounter.refCounter.Add(1) + } else { + panic(fmt.Sprintf("Clone: resolver with ref counter not found, contextId: %v", *m.contextId)) } } @@ -377,6 +386,7 @@ func preimageResolver(context C.size_t, ty C.uint8_t, ptr unsafe.Pointer) C.Reso copy(hash[:], input) resolverWithRefCounter, ok := preimageResolvers.Load(int64(context)) if !ok { + log.Error("preimageResolver: resolver with ref counter not found", "context", int64(context)) return C.ResolvedPreimage{ len: -1, } From f7f90d20a22ebeacf579f72686176c0ad6635b99 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 12:35:45 -0300 Subject: [PATCH 095/210] renames refCounterAfter to refCount --- validator/server_arb/machine.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 20b236e5a7..f882fe65a6 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -68,10 +68,10 @@ func dereferenceContextId(contextId *int64) { panic(fmt.Sprintf("dereferenceContextId: resolver with ref counter not found, contextId: %v", *contextId)) } - refCounterAfter := resolverWithRefCounter.refCounter.Add(-1) - if refCounterAfter < 0 { + refCount := resolverWithRefCounter.refCounter.Add(-1) + if refCount < 0 { panic(fmt.Sprintf("dereferenceContextId: ref counter is negative, contextId: %v", *contextId)) - } else if refCounterAfter == 0 { + } else if refCount == 0 { preimageResolvers.Delete(*contextId) } } From 84dfaf17ba9524b02ae5f4e912ab49389f0529ec Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Mon, 4 Nov 2024 11:44:20 -0700 Subject: [PATCH 096/210] fix variable name --- scripts/check-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-build.sh b/scripts/check-build.sh index ee79d12b8b..6084900f96 100755 --- a/scripts/check-build.sh +++ b/scripts/check-build.sh @@ -43,7 +43,7 @@ fi # Step 3: Check the version tag VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "") -if [[ -z "${VAR}" ]]; then +if [[ -z "${VERSION_TAG}" ]]; then echo -e "${YELLOW}Untagged version of Nitro checked out, may not be fully tested.${NC}" else echo -e "${GREEN}You are on Nitro version tag: $VERSION_TAG${NC}" From 11afd6971be80078e69ddbe171dcbc709de84db7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 4 Nov 2024 23:27:19 +0100 Subject: [PATCH 097/210] Fix the execution_run tests --- validator/server_arb/execution_run.go | 7 ++----- validator/server_arb/execution_run_test.go | 24 +++++----------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index 9cfceea7d2..7125c90288 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -24,7 +24,8 @@ type executionRun struct { } // NewExecutionRun creates a backend with the given arguments. -// Note: machineCache may be nil, but if present, it must not have a restricted range. +// Note: machineCache may be nil, but if present, it must not have a restricted +// range. func NewExecutionRun( ctxIn context.Context, initialMachineGetter func(context.Context) (MachineInterface, error), @@ -107,10 +108,6 @@ func (e *executionRun) machineHashesWithStepSize( log.Info(fmt.Sprintf("Advanced machine to index %d, beginning hash computation", machineStartIndex)) fmt.Printf("got machine type %T\n", machine) - // In BOLD, the hash of a machine at index 0 is a special hash that is computed as the - // `machineFinishedHash(gs)` where `gs` is the global state of the machine at index 0. - // This is so that the hash aligns with the start state of the claimed challenge edge - // at the level above, as required by the BOLD protocol. machineHashes := []common.Hash{machine.Hash()} startHash := machineHashes[0] diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index ab450504c9..0684cebfe4 100644 --- a/validator/server_arb/execution_run_test.go +++ b/validator/server_arb/execution_run_test.go @@ -14,21 +14,7 @@ type mockMachine struct { totalSteps uint64 } -func machineFinishedHash(gs validator.GoGlobalState) common.Hash { - mach := NewFinishedMachine() - err := mach.SetGlobalState(gs) - if err != nil { - panic(err) - } - hash := mach.Hash() - mach.Destroy() - return hash -} - func (m *mockMachine) Hash() common.Hash { - if m.gs.PosInBatch == m.totalSteps-1 { - return machineFinishedHash(m.gs) - } return m.gs.Hash() } @@ -116,7 +102,7 @@ func Test_machineHashesWithStep(t *testing.T) { if err != nil { t.Fatal(err) } - expected := machineFinishedHash(mm.gs) + expected := mm.gs.Hash() if len(hashes) != 1 { t.Error("Wanted one hash") } @@ -150,7 +136,7 @@ func Test_machineHashesWithStep(t *testing.T) { expectedHashes := make([]common.Hash, 0) for i := uint64(0); i < 4; i++ { if i == 0 { - expectedHashes = append(expectedHashes, machineFinishedHash(initialGs)) + expectedHashes = append(expectedHashes, initialGs.Hash()) continue } gs := validator.GoGlobalState{ @@ -195,7 +181,7 @@ func Test_machineHashesWithStep(t *testing.T) { expectedHashes := make([]common.Hash, 0) for i := uint64(0); i < 4; i++ { if i == 0 { - expectedHashes = append(expectedHashes, machineFinishedHash(initialGs)) + expectedHashes = append(expectedHashes, initialGs.Hash()) continue } gs := validator.GoGlobalState{ @@ -204,10 +190,10 @@ func Test_machineHashesWithStep(t *testing.T) { } expectedHashes = append(expectedHashes, gs.Hash()) } - expectedHashes = append(expectedHashes, machineFinishedHash(validator.GoGlobalState{ + expectedHashes = append(expectedHashes, validator.GoGlobalState{ Batch: 1, PosInBatch: mm.totalSteps - 1, - })) + }.Hash()) if uint64(len(hashes)) >= maxIterations { t.Fatal("Wanted fewer hashes than the max iterations") } From c3f806e2c9a1eb6955035cd8b8b2c9a907faaa0c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 4 Nov 2024 23:28:15 +0100 Subject: [PATCH 098/210] Attempt at fixing the virtual leaves issue The CollectProof and CollectMachineHashes functions were both susceptible to challenges where it was possible that the rival would have committed to more messages than this validator. And, in that case, it would attempt to look up a message number which was greater than the highest messge number it had verified as part of the batch in which the challenge originated. --- staker/bold/bold_state_provider.go | 111 ++++++++++++++++++----------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 254415df9b..d4d47b8a0b 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -1,5 +1,6 @@ // Copyright 2023, Offchain Labs, Inc. -// For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE +// For license information, see +// https://github.com/offchainlabs/bold/blob/main/LICENSE package bold import ( @@ -10,11 +11,6 @@ import ( "sync" "time" - protocol "github.com/offchainlabs/bold/chain-abstraction" - "github.com/offchainlabs/bold/containers/option" - l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" - "github.com/offchainlabs/bold/state-commitments/history" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/crypto" @@ -22,10 +18,15 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/bold/containers/option" + "github.com/offchainlabs/bold/state-commitments/history" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" - challengecache "github.com/offchainlabs/nitro/staker/challenge-cache" "github.com/offchainlabs/nitro/validator" + + protocol "github.com/offchainlabs/bold/chain-abstraction" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + challengecache "github.com/offchainlabs/nitro/staker/challenge-cache" ) var ( @@ -70,10 +71,13 @@ func NewBOLDStateProvider( return sp, nil } -// ExecutionStateAfterPreviousState Produces the L2 execution state for the next assertion. -// Returns the state at maxInboxCount or maxNumberOfBlocks after the previous state, whichever is earlier. -// If previousGlobalState is nil, defaults to returning the state at maxInboxCount. -// TODO: Check the block validator has validated the execution state we are proposing. +// ExecutionStateAfterPreviousState Produces the L2 execution state for the next +// assertion. Returns the state at maxInboxCount or maxNumberOfBlocks after the +// previous state, whichever is earlier. If previousGlobalState is nil, defaults +// to returning the state at maxInboxCount. +// +// TODO: Check the block validator has validated the execution state we are +// proposing. func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxInboxCount uint64, @@ -117,7 +121,8 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( if err != nil { return nil, err } - // If the state we are requested to produce is neither validated nor past threshold, we return ErrChainCatchingUp as an error. + // If the state we are requested to produce is neither validated nor past + // threshold, we return ErrChainCatchingUp as an error. stateValidatedAndMessageCountPastThreshold, err := s.isStateValidatedAndMessageCountPastThreshold(ctx, globalState, messageCount) if err != nil { return nil, err @@ -160,7 +165,6 @@ func (s *BOLDStateProvider) isStateValidatedAndMessageCountPastThreshold( if s.validator == nil { // If we do not have a validator, we cannot check if the state is validated. // So we assume it is validated and return true. - // This is a dangerous option, only users return true, nil } lastValidatedGs, err := s.validator.ReadLastValidatedInfo() @@ -240,7 +244,8 @@ func (s *BOLDStateProvider) StatesInBatchRange( posInBatch = 0 batchNum++ // Only get the next batch metadata if it'll be needed. - // Otherwise, we might try to read too many batches, and hit an error that the next batch isn't found. + // Otherwise, we might try to read too many batches, and hit an error that + // the next batch isn't found. if uint64(len(states)) < totalDesiredHashes && batchNum < batchLimit { currBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum) if err != nil { @@ -297,10 +302,10 @@ func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbuti }, nil } -// L2MessageStatesUpTo Computes a block history commitment from a -// start L2 message to an end L2 message index and up to a required -// batch index. The hashes used for this commitment are the machine -// hashes at each message number. +// L2MessageStatesUpTo Computes a block history commitment from a start L2 +// message to an end L2 message index and up to a required batch index. The +// hashes used for this commitment are the machine hashes at each message +// number. func (s *BOLDStateProvider) L2MessageStatesUpTo( ctx context.Context, fromState protocol.GoGlobalState, @@ -320,22 +325,21 @@ func (s *BOLDStateProvider) L2MessageStatesUpTo( return items, nil } -// CollectMachineHashes Collects a list of machine hashes at a message number based on some configuration parameters. +// CollectMachineHashes Collects a list of machine hashes at a message number +// based on some configuration parameters. func (s *BOLDStateProvider) CollectMachineHashes( ctx context.Context, cfg *l2stateprovider.HashCollectorConfig, ) ([]common.Hash, error) { s.Lock() defer s.Unlock() - var prevBatchMsgCount arbutil.MessageIndex - if cfg.FromState.Batch > 0 { - var err error - prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(cfg.FromState.Batch - 1)) - if err != nil { - return nil, fmt.Errorf("could not get batch message count at %d: %w", cfg.FromState.Batch-1, err) - } + fromState := cfg.FromState + // cfg.BlockChallengeHeight is the index of the last correct block, before the + // block we're challenging. + chalHeight := cfg.BlockChallengeHeight + messageNum, _, err := s.messageNum(fromState, chalHeight) + if err != nil { + return nil, err } - // cfg.BlockChallengeHeight is the index of the last correct block, before the block we're challenging. - messageNum := prevBatchMsgCount + arbutil.MessageIndex(cfg.FromState.PosInBatch) + arbutil.MessageIndex(cfg.BlockChallengeHeight) stepHeights := make([]uint64, len(cfg.StepHeights)) for i, h := range cfg.StepHeights { stepHeights[i] = uint64(h) @@ -404,18 +408,47 @@ func (s *BOLDStateProvider) CollectMachineHashes( return result, nil } -// CtxWithCheckAlive Creates a context with a check alive routine -// that will cancel the context if the check alive routine fails. +// messageNum finds the effective message number (or l2 block index) +// where the challenge is occurring. +func (s *BOLDStateProvider) messageNum(fromState protocol.GoGlobalState, chalHeight l2stateprovider.Height) (arbutil.MessageIndex, arbutil.MessageIndex, error) { + var prevBatchMsgCount arbutil.MessageIndex + if fromState.Batch > 0 { + var err error + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch - 1)) + if err != nil { + return 0, 0, fmt.Errorf("could not get prevBatchMsgCount at %d: %w", fromState.Batch-1, err) + } + } + currBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch)) + if err != nil { + return 0, 0, fmt.Errorf("could not get currBatchMsgCount at %d: %w", fromState, err) + } + messageNum := prevBatchMsgCount + arbutil.MessageIndex(fromState.PosInBatch) + arbutil.MessageIndex(chalHeight) + if messageNum > currBatchMsgCount { + // This can happen in the BoLD protocol when the rival block-level challenge + // edge has committed to more blocks that this validator expected for the + // current batch. In that case, the BlockChallengeHeight will be a block in + // the virtual padding of the history commitment of this validator. It will + // therefore be the same as the end state of the last block in the in the + // current batch. + messageNum = currBatchMsgCount + } + return messageNum, prevBatchMsgCount, nil +} + +// CtxWithCheckAlive Creates a context with a check alive routine that will +// cancel the context if the check alive routine fails. func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (context.Context, context.CancelFunc) { // Create a context that will cancel if the check alive routine fails. - // This is to ensure that we do not have the validator froze indefinitely if the execution run - // is no longer alive. + // This is to ensure that we do not have the validator froze indefinitely if + // the execution run is no longer alive. ctx, cancel := context.WithCancel(ctxIn) // Create a context with cancel, so that we can cancel the check alive routine // once the calling function returns. ctxCheckAlive, cancelCheckAlive := context.WithCancel(ctxIn) go func() { - // Call cancel so that the calling function is canceled if the check alive routine fails/returns. + // Call cancel so that the calling function is canceled if the check alive + // routine fails/returns. defer cancel() ticker := time.NewTicker(10 * time.Second) defer ticker.Stop() @@ -424,7 +457,8 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c case <-ctxCheckAlive.Done(): return case <-ticker.C: - // Create a context with a timeout, so that the check alive routine does not run indefinitely. + // Create a context with a timeout, so that the check alive routine does + // not run indefinitely. ctxCheckAliveWithTimeout, cancelCheckAliveWithTimeout := context.WithTimeout(ctxCheckAlive, 5*time.Second) err := execRun.CheckAlive(ctxCheckAliveWithTimeout) if err != nil { @@ -439,7 +473,7 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c return ctx, cancelCheckAlive } -// CollectProof Collects osp of at a message number and OpcodeIndex . +// CollectProof collects a one-step proof at a message number and OpcodeIndex. func (s *BOLDStateProvider) CollectProof( ctx context.Context, fromState protocol.GoGlobalState, @@ -447,12 +481,7 @@ func (s *BOLDStateProvider) CollectProof( blockChallengeHeight l2stateprovider.Height, machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { - prevBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch) - 1) - if err != nil { - return nil, err - } - // blockChallengeHeight is the index of the last correct block, before the block we're challenging. - messageNum := prevBatchMsgCount + arbutil.MessageIndex(fromState.PosInBatch) + arbutil.MessageIndex(blockChallengeHeight) + messageNum, prevBatchMsgCount, err := s.messageNum(fromState, blockChallengeHeight) entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum) if err != nil { return nil, err From 6e20fc61289ce80a6c7d617d1f2a65b6479824c1 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 4 Nov 2024 20:16:01 -0600 Subject: [PATCH 099/210] Begin work on TestChallengeProtocolBOLDVirtualBlocks --- bold | 2 +- system_tests/bold_challenge_protocol_test.go | 57 ++++---- system_tests/bold_new_challenge_test.go | 144 +++++++++++++++++++ system_tests/common_test.go | 108 ++++++++++++-- 4 files changed, 267 insertions(+), 44 deletions(-) create mode 100644 system_tests/bold_new_challenge_test.go diff --git a/bold b/bold index 491164ae0d..17b6a41bdd 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 491164ae0df4195962ad84ce4264087428195096 +Subproject commit 17b6a41bdd79872493854d66a2fd333b335ee8f0 diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index efba373765..ad9a2c58e1 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -60,12 +60,6 @@ import ( "github.com/offchainlabs/nitro/validator/valnode" ) -var ( - blockChallengeLeafHeight = uint64(1 << 5) // 32 - bigStepChallengeLeafHeight = uint64(1 << 10) - smallStepChallengeLeafHeight = uint64(1 << 10) -) - func TestChallengeProtocolBOLDReadInboxChallenge(t *testing.T) { testChallengeProtocolBOLD(t) } @@ -110,31 +104,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp ctx, cancelCtx = context.WithCancel(ctx) defer cancelCtx() - // Every 3 seconds, send an L1 transaction to keep the chain moving. - go func() { - delay := time.Second * 3 - for { - select { - case <-ctx.Done(): - return - default: - time.Sleep(delay) - balance := big.NewInt(params.GWei) - if ctx.Err() != nil { - break - } - TransferBalance(t, "Faucet", "Asserter", balance, l1info, l1client, ctx) - latestBlock, err := l1client.BlockNumber(ctx) - if ctx.Err() != nil { - break - } - Require(t, err) - if latestBlock > 150 { - delay = time.Second - } - } - } - }() + go keepChainMoving(t, ctx, l1info, l1client) l2nodeConfig := arbnode.ConfigDefaultL1Test() _, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, l2nodeConfig, nil, stakeTokenAddr) @@ -497,6 +467,31 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp } } +// Every 3 seconds, send an L1 transaction to keep the chain moving. +func keepChainMoving(t *testing.T, ctx context.Context, l1Info *BlockchainTestInfo, l1Client *ethclient.Client) { + delay := time.Second * 3 + for { + select { + case <-ctx.Done(): + return + default: + time.Sleep(delay) + if ctx.Err() != nil { + break + } + TransferBalance(t, "Faucet", "Faucet", common.Big0, l1Info, l1Client, ctx) + latestBlock, err := l1Client.BlockNumber(ctx) + if ctx.Err() != nil { + break + } + Require(t, err) + if latestBlock > 150 { + delay = time.Second + } + } + } +} + func createTestNodeOnL1ForBoldProtocol( t *testing.T, ctx context.Context, diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go new file mode 100644 index 0000000000..5dd4e964b6 --- /dev/null +++ b/system_tests/bold_new_challenge_test.go @@ -0,0 +1,144 @@ +// Copyright 2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +//go:build challengetest && !race + +package arbtest + +import ( + "context" + "math/big" + "testing" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/params" + solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" + challengemanager "github.com/offchainlabs/bold/challenge-manager" + modes "github.com/offchainlabs/bold/challenge-manager/types" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/rollupgen" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" + "github.com/offchainlabs/nitro/staker/bold" + "github.com/offchainlabs/nitro/validator/valnode" +) + +func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true).WithBoldDeployment() + + // Block validation requires db hash scheme + builder.execConfig.Caching.StateScheme = rawdb.HashScheme + + valConf := valnode.TestValidationConfig + _, valStack := createTestValidationNode(t, ctx, &valConf) + configByValidationNode(builder.nodeConfig, valStack) + + builder.execConfig.Sequencer.MaxRevertGasReject = 0 + + cleanup := builder.Build(t) + defer cleanup() + + evilNode, cleanupEvilNode := builder.Build2ndNode(t, &SecondNodeParams{}) + defer cleanupEvilNode() + + go keepChainMoving(t, ctx, builder.L1Info, builder.L1.Client) + + builder.L1Info.GenerateAccount("Asserter") + builder.L1Info.GenerateAccount("EvilAsserter") + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + TransferBalance(t, "Faucet", "Asserter", balance, builder.L1Info, builder.L1.Client, ctx) + TransferBalance(t, "Faucet", "EvilAsserter", balance, builder.L1Info, builder.L1.Client, ctx) + + cleanupHonestChallengeManager := startBoldChallengeManager(t, ctx, builder, builder.L2, "Asserter") + defer cleanupHonestChallengeManager() + + // TODO: inject an evil BOLDStateProvider to the evil node (right now it's using an honest one) + cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "Asserter") + defer cleanupEvilChallengeManager() + + // TODO: the rest of the test +} + +func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeBuilder, node *TestClient, addressName string) func() { + if !builder.deployBold { + t.Fatal("bold deployment not enabled") + } + + stateManager, err := bold.NewBOLDStateProvider( + node.ConsensusNode.BlockValidator, + node.ConsensusNode.StatelessBlockValidator, + l2stateprovider.Height(blockChallengeLeafHeight), + &bold.StateProviderConfig{ + ValidatorName: addressName, + MachineLeavesCachePath: t.TempDir(), + CheckBatchFinality: false, + }, + ) + Require(t, err) + + provider := l2stateprovider.NewHistoryCommitmentProvider( + stateManager, + stateManager, + stateManager, + []l2stateprovider.Height{ + l2stateprovider.Height(blockChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(smallStepChallengeLeafHeight), + }, + stateManager, + nil, // Api db + ) + + rollupUserLogic, err := rollupgen.NewRollupUserLogic(builder.addresses.Rollup, builder.L1.Client) + Require(t, err) + chalManagerAddr, err := rollupUserLogic.ChallengeManager(&bind.CallOpts{}) + Require(t, err) + + txOpts := builder.L1Info.GetDefaultTransactOpts(addressName, ctx) + + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(node.ConsensusNode.ArbDB, storage.StakerPrefix), + node.ConsensusNode.L1Reader, + &txOpts, + NewFetcherFromConfig(builder.nodeConfig), + node.ConsensusNode.SyncMonitor, + builder.L1Info.Signer.ChainID(), + ) + Require(t, err) + + assertionChain, err := solimpl.NewAssertionChain( + ctx, + builder.addresses.Rollup, + chalManagerAddr, + &txOpts, + builder.L1.Client, + solimpl.NewDataPosterTransactor(dp), + ) + + Require(t, err) + challengeManager, err := challengemanager.New( + ctx, + assertionChain, + provider, + assertionChain.RollupAddress(), + challengemanager.WithName("honest"), + challengemanager.WithMode(modes.MakeMode), + challengemanager.WithAddress(txOpts.From), + challengemanager.WithAssertionPostingInterval(time.Second*3), + challengemanager.WithAssertionScanningInterval(time.Second), + challengemanager.WithAvgBlockCreationTime(time.Second), + ) + Require(t, err) + + challengeManager.Start(ctx) + return challengeManager.StopAndWait +} diff --git a/system_tests/common_test.go b/system_tests/common_test.go index cab5b29805..0b4621a34d 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/offchainlabs/bold/testing/setup" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/util" @@ -72,6 +73,8 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" + boldMocksgen "github.com/offchainlabs/bold/solgen/go/mocksgen" + "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/nitro/arbnode" _ "github.com/offchainlabs/nitro/execution/nodeInterface" "github.com/offchainlabs/nitro/solgen/go/bridgegen" @@ -238,6 +241,7 @@ type NodeBuilder struct { l2StackConfig *node.Config valnodeConfig *valnode.Config l3Config *NitroConfig + deployBold bool L1Info info L2Info info L3Info info @@ -346,6 +350,11 @@ func (b *NodeBuilder) WithProdConfirmPeriodBlocks() *NodeBuilder { return b } +func (b *NodeBuilder) WithBoldDeployment() *NodeBuilder { + b.deployBold = true + return b +} + func (b *NodeBuilder) WithWasmRootDir(wasmRootDir string) *NodeBuilder { b.valnodeConfig.Wasm.RootPath = wasmRootDir return b @@ -414,6 +423,7 @@ func (b *NodeBuilder) BuildL1(t *testing.T) { locator.LatestWasmModuleRoot(), b.withProdConfirmPeriodBlocks, true, + b.deployBold, ) b.L1.cleanup = func() { requireClose(t, b.L1.Stack) } } @@ -517,6 +527,7 @@ func (b *NodeBuilder) BuildL3OnL2(t *testing.T) func() { locator.LatestWasmModuleRoot(), b.l3Config.withProdConfirmPeriodBlocks, false, + b.deployBold, ) b.L3 = buildOnParentChain( @@ -1250,6 +1261,12 @@ func getInitMessage(ctx context.Context, t *testing.T, parentChainClient *ethcli return initMessage } +var ( + blockChallengeLeafHeight = uint64(1 << 5) // 32 + bigStepChallengeLeafHeight = uint64(1 << 10) + smallStepChallengeLeafHeight = uint64(1 << 10) +) + func deployOnParentChain( t *testing.T, ctx context.Context, @@ -1260,6 +1277,7 @@ func deployOnParentChain( wasmModuleRoot common.Hash, prodConfirmPeriodBlocks bool, chainSupportsBlobs bool, + deployBold bool, ) (*chaininfo.RollupAddresses, *arbostypes.ParsedInitMessage) { parentChainInfo.GenerateAccount("RollupOwner") parentChainInfo.GenerateAccount("Sequencer") @@ -1284,18 +1302,84 @@ func deployOnParentChain( nativeToken := common.Address{} maxDataSize := big.NewInt(117964) - addresses, err := deploy.DeployOnParentChain( - ctx, - parentChainReader, - &parentChainTransactionOpts, - []common.Address{parentChainInfo.GetAddress("Sequencer")}, - parentChainInfo.GetAddress("RollupOwner"), - 0, - arbnode.GenerateRollupConfig(prodConfirmPeriodBlocks, wasmModuleRoot, parentChainInfo.GetAddress("RollupOwner"), chainConfig, serializedChainConfig, common.Address{}), - nativeToken, - maxDataSize, - chainSupportsBlobs, - ) + var addresses *chaininfo.RollupAddresses + if deployBold { + stakeToken, tx, _, err := boldMocksgen.DeployTestWETH9( + &parentChainTransactionOpts, + parentChainReader.Client(), + "Weth", + "WETH", + ) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, parentChainReader.Client(), tx) + Require(t, err) + miniStakeValues := []*big.Int{big.NewInt(5), big.NewInt(4), big.NewInt(3), big.NewInt(2), big.NewInt(1)} + genesisExecutionState := rollupgen.AssertionState{ + GlobalState: rollupgen.GlobalState{}, + MachineStatus: 1, // Finished + EndHistoryRoot: [32]byte{}, + } + cfg := rollupgen.Config{ + MiniStakeValues: miniStakeValues, + ConfirmPeriodBlocks: 120, + StakeToken: stakeToken, + BaseStake: big.NewInt(1), + WasmModuleRoot: wasmModuleRoot, + Owner: parentChainTransactionOpts.From, + LoserStakeEscrow: parentChainTransactionOpts.From, + ChainId: chainConfig.ChainID, + ChainConfig: string(serializedChainConfig), + SequencerInboxMaxTimeVariation: rollupgen.ISequencerInboxMaxTimeVariation{ + DelayBlocks: big.NewInt(60 * 60 * 24 / 15), + FutureBlocks: big.NewInt(12), + DelaySeconds: big.NewInt(60 * 60 * 24), + FutureSeconds: big.NewInt(60 * 60), + }, + LayerZeroBlockEdgeHeight: new(big.Int).SetUint64(blockChallengeLeafHeight), + LayerZeroBigStepEdgeHeight: new(big.Int).SetUint64(bigStepChallengeLeafHeight), + LayerZeroSmallStepEdgeHeight: new(big.Int).SetUint64(smallStepChallengeLeafHeight), + GenesisAssertionState: genesisExecutionState, + GenesisInboxCount: common.Big0, + AnyTrustFastConfirmer: common.Address{}, + NumBigStepLevel: 3, + ChallengeGracePeriodBlocks: 3, + } + boldAddresses, err := setup.DeployFullRollupStack( + ctx, + parentChainReader.Client(), + &parentChainTransactionOpts, + parentChainInfo.GetAddress("Sequencer"), + cfg, + false, // do not use mock bridge. + false, // do not use a mock one-step prover + ) + Require(t, err) + addresses = &chaininfo.RollupAddresses{ + Bridge: boldAddresses.Bridge, + Inbox: boldAddresses.Inbox, + SequencerInbox: boldAddresses.SequencerInbox, + Rollup: boldAddresses.Rollup, + NativeToken: nativeToken, + UpgradeExecutor: boldAddresses.UpgradeExecutor, + ValidatorUtils: boldAddresses.ValidatorUtils, + ValidatorWalletCreator: boldAddresses.ValidatorWalletCreator, + StakeToken: stakeToken, + DeployedAt: boldAddresses.DeployedAt, + } + } else { + addresses, err = deploy.DeployOnParentChain( + ctx, + parentChainReader, + &parentChainTransactionOpts, + []common.Address{parentChainInfo.GetAddress("Sequencer")}, + parentChainInfo.GetAddress("RollupOwner"), + 0, + arbnode.GenerateRollupConfig(prodConfirmPeriodBlocks, wasmModuleRoot, parentChainInfo.GetAddress("RollupOwner"), chainConfig, serializedChainConfig, common.Address{}), + nativeToken, + maxDataSize, + chainSupportsBlobs, + ) + } Require(t, err) parentChainInfo.SetContract("Bridge", addresses.Bridge) parentChainInfo.SetContract("SequencerInbox", addresses.SequencerInbox) From d56470333ae20de5330404963207012919d18303 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 16:17:52 +0530 Subject: [PATCH 100/210] Update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index cdbadc1c4d..fc0b413ef7 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit cdbadc1c4d6df98dc2e7b07a6fcdb0259e58a046 +Subproject commit fc0b413ef764c368a7e6e0af17c47d3e73bbb361 From 60e7281f6eeb4c4b1b2adf09878d23b69d077612 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 16:21:36 +0530 Subject: [PATCH 101/210] fix build --- arbos/arbosState/initialization_test.go | 4 +--- arbos/arbosState/initialize.go | 6 +----- system_tests/state_fuzz_test.go | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 4bee02f9df..697a41e4fd 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -66,9 +66,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - number, err := initReader.GetNextBlockNumber() - Require(t, err) - triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), 0)) + triedbConfig := cacheConfig.TriedbConfig() stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil) Require(t, err) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index eef15869a2..374eff2cea 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -56,11 +56,7 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint } func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { - number, err := initData.GetNextBlockNumber() - if err != nil { - return common.Hash{}, err - } - triedbConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int).SetUint64(number), timestamp)) + triedbConfig := cacheConfig.TriedbConfig() triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) defer func() { diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 132bb7cc44..c8312350e6 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -159,7 +159,7 @@ func FuzzStateTransition(f *testing.F) { if err != nil { panic(err) } - trieDBConfig := cacheConfig.TriedbConfig(chainConfig.IsVerkle(new(big.Int), 0)) + trieDBConfig := cacheConfig.TriedbConfig() statedb, err := state.New(stateRoot, state.NewDatabaseWithConfig(chainDb, trieDBConfig), nil) if err != nil { panic(err) From 09f9fde8938197fbd3cedc06de70ba6e9574e297 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 16:46:36 +0530 Subject: [PATCH 102/210] Update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index fc0b413ef7..c4d8abf274 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit fc0b413ef764c368a7e6e0af17c47d3e73bbb361 +Subproject commit c4d8abf2741bb628fc905b24a2d50c6f56539f4a From 07d7ec40218b957bcdeb640ea4b0eb29dff887f8 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 17:24:56 +0530 Subject: [PATCH 103/210] Changes based on PR comments --- arbnode/inbox_test.go | 2 +- arbos/arbosState/initialization_test.go | 2 +- arbos/arbosState/initialize.go | 8 ++++++-- cmd/nitro/init.go | 7 ++----- execution/gethexec/blockchain.go | 8 ++++---- statetransfer/data.go | 1 + statetransfer/interface.go | 1 + statetransfer/jsondatareader.go | 4 ++++ statetransfer/memdatareader.go | 4 ++++ system_tests/common_test.go | 4 ++-- system_tests/state_fuzz_test.go | 1 - 11 files changed, 26 insertions(+), 16 deletions(-) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index 78c50f9de7..e588ef399b 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -61,7 +61,7 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* initReader := statetransfer.NewMemoryInitDataReader(&initData) cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) - bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefault.TxLookupLimit, 0, common.Address{}) + bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefault.TxLookupLimit, 0) if err != nil { Fail(t, err) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 608ccfd194..5e605b8bd2 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -64,7 +64,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin chainConfig := params.ArbitrumDevTestChainConfig() cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) - stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0, common.Address{}) + stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) triedbConfig := cacheConfig.TriedbConfig() diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 0144390663..33ae5f8f1d 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -54,7 +54,7 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) } -func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint, chainOwner common.Address) (root common.Hash, err error) { +func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { triedbConfig := cacheConfig.TriedbConfig() triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) @@ -96,8 +96,12 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, log.Crit("failed to open the ArbOS state", "error", err) } + chainOwner, err := initData.GetChainOwner() + if err != nil { + return common.Hash{}, err + } if chainOwner != (common.Address{}) { - err := arbosState.ChainOwners().Add(chainOwner) + err = arbosState.ChainOwners().Add(chainOwner) if err != nil { return common.Hash{}, err } diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index 9ff5431e2c..d4794f9fee 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -681,6 +681,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo Nonce: 0, }, }, + ChainOwner: common.HexToAddress(config.Init.DevInitAddress), } initDataReader = statetransfer.NewMemoryInitDataReader(&initData) } @@ -791,11 +792,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) && config.Init.Force { return chainDb, nil, errors.New("It is not possible to force init with non-empty blockchain when using path scheme") } - var chainOwner common.Address - if config.Init.DevInit { - chainOwner = common.HexToAddress(config.Init.DevInitAddress) - } - l2BlockChain, err = gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initDataReader, chainConfig, parsedInitMessage, config.Execution.TxLookupLimit, config.Init.AccountsPerSync, chainOwner) + l2BlockChain, err = gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initDataReader, chainConfig, parsedInitMessage, config.Execution.TxLookupLimit, config.Init.AccountsPerSync) if err != nil { return chainDb, nil, err } diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 7ecf2e0e2b..fda8f49093 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -125,7 +125,7 @@ func (c *CachingConfig) Validate() error { return c.validateStateScheme() } -func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint, chainOwner common.Address) error { +func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint) error { EmptyHash := common.Hash{} prevHash := EmptyHash prevDifficulty := big.NewInt(0) @@ -146,7 +146,7 @@ func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, } timestamp = prevHeader.Time } - stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, cacheConfig, initData, chainConfig, initMessage, timestamp, accountsPerSync, chainOwner) + stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, cacheConfig, initData, chainConfig, initMessage, timestamp, accountsPerSync) if err != nil { return err } @@ -213,7 +213,7 @@ func GetBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, chainC return core.NewBlockChain(chainDb, cacheConfig, chainConfig, nil, nil, engine, vmConfig, shouldPreserveFalse, &txLookupLimit) } -func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint, chainOwner common.Address) (*core.BlockChain, error) { +func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint) (*core.BlockChain, error) { emptyBlockChain := rawdb.ReadHeadHeader(chainDb) == nil if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) { // When using path scheme, and the stored state trie is not empty, @@ -222,7 +222,7 @@ func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig return GetBlockChain(chainDb, cacheConfig, chainConfig, txLookupLimit) } - err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync, chainOwner) + err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync) if err != nil { return nil, err } diff --git a/statetransfer/data.go b/statetransfer/data.go index df4694aa17..21268a443a 100644 --- a/statetransfer/data.go +++ b/statetransfer/data.go @@ -14,6 +14,7 @@ type ArbosInitializationInfo struct { AddressTableContents []common.Address RetryableData []InitializationDataForRetryable Accounts []AccountInitializationInfo + ChainOwner common.Address } type InitializationDataForRetryable struct { diff --git a/statetransfer/interface.go b/statetransfer/interface.go index 7d592b4430..cb70fdd14d 100644 --- a/statetransfer/interface.go +++ b/statetransfer/interface.go @@ -17,6 +17,7 @@ type InitDataReader interface { GetNextBlockNumber() (uint64, error) GetRetryableDataReader() (RetryableDataReader, error) GetAccountDataReader() (AccountDataReader, error) + GetChainOwner() (common.Address, error) } type ListReader interface { diff --git a/statetransfer/jsondatareader.go b/statetransfer/jsondatareader.go index c36061c0b0..5e992df3f0 100644 --- a/statetransfer/jsondatareader.go +++ b/statetransfer/jsondatareader.go @@ -210,3 +210,7 @@ func (r *JsonInitDataReader) GetAccountDataReader() (AccountDataReader, error) { JsonListReader: listreader, }, nil } + +func (r *JsonInitDataReader) GetChainOwner() (common.Address, error) { + return common.Address{}, nil +} diff --git a/statetransfer/memdatareader.go b/statetransfer/memdatareader.go index 1d60888937..3d6b68343c 100644 --- a/statetransfer/memdatareader.go +++ b/statetransfer/memdatareader.go @@ -99,6 +99,10 @@ func (r *MemoryInitDataReader) GetAccountDataReader() (AccountDataReader, error) }, nil } +func (r *MemoryInitDataReader) GetChainOwner() (common.Address, error) { + return r.d.ChainOwner, nil +} + func (r *MemoryInitDataReader) Close() error { return nil } diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 44c0e8f740..027a41d875 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1346,7 +1346,7 @@ func createNonL1BlockChainWithStackConfig( } } coreCacheConfig := gethexec.DefaultCacheConfigFor(stack, &execConfig.Caching) - blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0, common.Address{}) + blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0) Require(t, err) return info, stack, chainDb, arbDb, blockchain @@ -1437,7 +1437,7 @@ func Create2ndNodeWithConfig( chainConfig := firstExec.ArbInterface.BlockChain().Config() coreCacheConfig := gethexec.DefaultCacheConfigFor(chainStack, &execConfig.Caching) - blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0, common.Address{}) + blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest(t).TxLookupLimit, 0) Require(t, err) AddValNodeIfNeeded(t, ctx, nodeConfig, true, "", valnodeConfig.Wasm.RootPath) diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 7e1fc57e63..c8312350e6 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -155,7 +155,6 @@ func FuzzStateTransition(f *testing.F) { initMessage, 0, 0, - common.Address{}, ) if err != nil { panic(err) From 6566ff06e8df0c92a1528da98a685dd3aa0a55dd Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 20:02:59 +0530 Subject: [PATCH 104/210] Changes based on PR comments --- arbnode/batch_poster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index e5f31a1eee..46a0160b71 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -1126,7 +1126,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error) } var use4844 bool config := b.config() - if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && *latestHeader.ExcessBlobGas != 0 && latestHeader.BlobGasUsed != nil && *latestHeader.BlobGasUsed != 0 { + if config.Post4844Blobs && b.dapWriter == nil && latestHeader.ExcessBlobGas != nil && latestHeader.BlobGasUsed != nil { arbOSVersion, err := b.arbOSVersionGetter.ArbOSVersionForMessageNumber(arbutil.MessageIndex(arbmath.SaturatingUSub(uint64(batchPosition.MessageCount), 1))) if err != nil { return false, err From c7f4f916bcbfcd937e6423c5d2a2df1e0aea230e Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 21:48:26 +0530 Subject: [PATCH 105/210] Update geth --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index c4d8abf274..c4334737c9 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit c4d8abf2741bb628fc905b24a2d50c6f56539f4a +Subproject commit c4334737c95dc2b1bd398d2fe7feefee72da2f0f From 800f0226e1ddecac2585c8c2b7674d15704a0655 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 5 Nov 2024 22:37:13 +0530 Subject: [PATCH 106/210] disable blob posting in the test batch poster config --- arbnode/batch_poster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 46a0160b71..185f43fce7 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -280,7 +280,7 @@ var TestBatchPosterConfig = BatchPosterConfig{ DASRetentionPeriod: daprovider.DefaultDASRetentionPeriod, GasRefunderAddress: "", ExtraBatchGas: 10_000, - Post4844Blobs: true, + Post4844Blobs: false, IgnoreBlobPrice: false, DataPoster: dataposter.TestDataPosterConfig, ParentChainWallet: DefaultBatchPosterL1WalletConfig, From 463f1679b5bedda1c803c9a4a6acd3097f0aeb22 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 5 Nov 2024 11:13:49 -0600 Subject: [PATCH 107/210] Complete TestChallengeProtocolBOLDVirtualBlocks --- bold | 2 +- system_tests/bold_challenge_protocol_test.go | 1 - system_tests/bold_new_challenge_test.go | 226 +++++++++++++++++-- system_tests/mock_machine_test.go | 2 +- 4 files changed, 207 insertions(+), 24 deletions(-) diff --git a/bold b/bold index 17b6a41bdd..e0fd45fec1 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 17b6a41bdd79872493854d66a2fd333b335ee8f0 +Subproject commit e0fd45fec194244ef4a43823c23e76987e5f729f diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index ad9a2c58e1..b104599587 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -456,7 +456,6 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp if address == l1info.GetDefaultTransactOpts("Asserter", ctx).From { t.Log("Honest party won OSP, impossible for evil party to win if honest party continues") Require(t, it.Close()) - time.Sleep(time.Second * 10) return } } diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 5dd4e964b6..a417ead2fa 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -7,24 +7,112 @@ package arbtest import ( "context" + "fmt" "math/big" "testing" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" modes "github.com/offchainlabs/bold/challenge-manager/types" + "github.com/offchainlabs/bold/containers/option" l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/challengeV2gen" + "github.com/offchainlabs/bold/solgen/go/mocksgen" "github.com/offchainlabs/bold/solgen/go/rollupgen" + "github.com/offchainlabs/bold/state-commitments/history" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/staker/bold" - "github.com/offchainlabs/nitro/validator/valnode" ) +type incorrectBlockStateProvider struct { + honest *bold.BOLDStateProvider + wrongAtBlockHeight uint64 + honestMachineHash common.Hash + evilMachineHash common.Hash +} + +func (s *incorrectBlockStateProvider) ExecutionStateAfterPreviousState( + ctx context.Context, + maxInboxCount uint64, + previousGlobalState *protocol.GoGlobalState, + maxNumberOfBlocks uint64, +) (*protocol.ExecutionState, error) { + executionState, err := s.honest.ExecutionStateAfterPreviousState(ctx, maxInboxCount, previousGlobalState, maxNumberOfBlocks) + if err != nil { + return nil, err + } + evilStates, err := s.L2MessageStatesUpTo(ctx, *previousGlobalState, l2stateprovider.Batch(maxInboxCount), option.Some(l2stateprovider.Height(maxNumberOfBlocks))) + if err != nil { + return nil, err + } + historyCommit, err := history.NewCommitment(evilStates, maxNumberOfBlocks+1) + if err != nil { + return nil, err + } + executionState.EndHistoryRoot = historyCommit.Merkle + return executionState, nil +} + +func (s *incorrectBlockStateProvider) L2MessageStatesUpTo( + ctx context.Context, + fromState protocol.GoGlobalState, + batchLimit l2stateprovider.Batch, + toHeight option.Option[l2stateprovider.Height], +) ([]common.Hash, error) { + states, err := s.honest.L2MessageStatesUpTo(ctx, fromState, batchLimit, toHeight) + if err != nil { + return nil, err + } + if toHeight.IsNone() || uint64(toHeight.Unwrap()) >= s.wrongAtBlockHeight { + for uint64(len(states)) <= s.wrongAtBlockHeight { + states = append(states, states[len(states)-1]) + } + s.honestMachineHash = states[s.wrongAtBlockHeight] + states[s.wrongAtBlockHeight][0] ^= 0xFF + s.evilMachineHash = states[s.wrongAtBlockHeight] + if uint64(len(states)) == s.wrongAtBlockHeight+1 && (toHeight.IsNone() || uint64(len(states)) < uint64(toHeight.Unwrap())) { + // don't break the end inclusion proof + states = append(states, s.honestMachineHash) + } + } + return states, nil +} + +func (s *incorrectBlockStateProvider) CollectMachineHashes( + ctx context.Context, cfg *l2stateprovider.HashCollectorConfig, +) ([]common.Hash, error) { + honestHashes, err := s.honest.CollectMachineHashes(ctx, cfg) + if err != nil { + return nil, err + } + if uint64(cfg.BlockChallengeHeight)+1 == s.wrongAtBlockHeight { + if uint64(len(honestHashes)) < cfg.NumDesiredHashes && honestHashes[len(honestHashes)-1] == s.honestMachineHash { + honestHashes = append(honestHashes, s.evilMachineHash) + } + } else if uint64(cfg.BlockChallengeHeight) >= s.wrongAtBlockHeight { + panic(fmt.Sprintf("challenge occured at block height %v at or after wrongAtBlockHeight %v", cfg.BlockChallengeHeight, s.wrongAtBlockHeight)) + } + return honestHashes, nil +} + +func (s *incorrectBlockStateProvider) CollectProof( + ctx context.Context, + fromState protocol.GoGlobalState, + wasmModuleRoot common.Hash, + blockChallengeHeight l2stateprovider.Height, + machineIndex l2stateprovider.OpcodeIndex, +) ([]byte, error) { + return s.honest.CollectProof(ctx, fromState, wasmModuleRoot, blockChallengeHeight, machineIndex) +} + func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -33,44 +121,136 @@ func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { // Block validation requires db hash scheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme - - valConf := valnode.TestValidationConfig - _, valStack := createTestValidationNode(t, ctx, &valConf) - configByValidationNode(builder.nodeConfig, valStack) - - builder.execConfig.Sequencer.MaxRevertGasReject = 0 + builder.nodeConfig.BlockValidator.Enable = true + builder.valnodeConfig.UseJit = false cleanup := builder.Build(t) defer cleanup() - evilNode, cleanupEvilNode := builder.Build2ndNode(t, &SecondNodeParams{}) + evilNodeConfig := arbnode.ConfigDefaultL1NonSequencerTest() + evilNodeConfig.BlockValidator.Enable = true + evilNode, cleanupEvilNode := builder.Build2ndNode(t, &SecondNodeParams{ + nodeConfig: evilNodeConfig, + }) defer cleanupEvilNode() go keepChainMoving(t, ctx, builder.L1Info, builder.L1.Client) - builder.L1Info.GenerateAccount("Asserter") + builder.L1Info.GenerateAccount("HonestAsserter") + fundBoldStaker(t, ctx, builder, "HonestAsserter") builder.L1Info.GenerateAccount("EvilAsserter") - balance := big.NewInt(params.Ether) - balance.Mul(balance, big.NewInt(100)) - TransferBalance(t, "Faucet", "Asserter", balance, builder.L1Info, builder.L1.Client, ctx) - TransferBalance(t, "Faucet", "EvilAsserter", balance, builder.L1Info, builder.L1.Client, ctx) + fundBoldStaker(t, ctx, builder, "EvilAsserter") - cleanupHonestChallengeManager := startBoldChallengeManager(t, ctx, builder, builder.L2, "Asserter") + assertionChain, cleanupHonestChallengeManager := startBoldChallengeManager(t, ctx, builder, builder.L2, "HonestAsserter", nil) defer cleanupHonestChallengeManager() - // TODO: inject an evil BOLDStateProvider to the evil node (right now it's using an honest one) - cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "Asserter") + _, cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "EvilAsserter", func(stateManager BoldStateProviderInterface) BoldStateProviderInterface { + return &incorrectBlockStateProvider{ + honest: stateManager.(*bold.BOLDStateProvider), + wrongAtBlockHeight: blockChallengeLeafHeight - 2, + } + }) defer cleanupEvilChallengeManager() - // TODO: the rest of the test + TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L2Info, builder.L2.Client, ctx) + + // Everything's setup, now just wait for the challenge to complete and ensure the honest party won + + chalManager, err := assertionChain.SpecChallengeManager(ctx) + Require(t, err) + + filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), builder.L1.Client) + Require(t, err) + + fromBlock := uint64(0) + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + for { + select { + case <-ticker.C: + latestBlock, err := builder.L1.Client.HeaderByNumber(ctx, nil) + Require(t, err) + toBlock := latestBlock.Number.Uint64() + if fromBlock == toBlock { + continue + } + filterOpts := &bind.FilterOpts{ + Start: fromBlock, + End: &toBlock, + Context: ctx, + } + it, err := filterer.FilterEdgeConfirmedByOneStepProof(filterOpts, nil, nil) + Require(t, err) + for it.Next() { + if it.Error() != nil { + t.Fatalf("Error in filter iterator: %v", it.Error()) + } + t.Log("Received event of OSP confirmation!") + tx, _, err := builder.L1.Client.TransactionByHash(ctx, it.Event.Raw.TxHash) + Require(t, err) + signer := types.NewCancunSigner(tx.ChainId()) + address, err := signer.Sender(tx) + Require(t, err) + if address == builder.L1Info.GetAddress("Asserter") { + t.Log("Honest party won OSP, impossible for evil party to win if honest party continues") + Require(t, it.Close()) + return + } + } + fromBlock = toBlock + case <-ctx.Done(): + return + } + } } -func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeBuilder, node *TestClient, addressName string) func() { +func fundBoldStaker(t *testing.T, ctx context.Context, builder *NodeBuilder, name string) { + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + TransferBalance(t, "Faucet", name, balance, builder.L1Info, builder.L1.Client, ctx) + + rollupUserLogic, err := rollupgen.NewRollupUserLogic(builder.addresses.Rollup, builder.L1.Client) + Require(t, err) + stakeToken, err := rollupUserLogic.StakeToken(&bind.CallOpts{Context: ctx}) + Require(t, err) + stakeTokenWeth, err := mocksgen.NewTestWETH9(stakeToken, builder.L1.Client) + Require(t, err) + + txOpts := builder.L1Info.GetDefaultTransactOpts(name, ctx) + + txOpts.Value = big.NewInt(params.Ether) + tx, err := stakeTokenWeth.Deposit(&txOpts) + Require(t, err) + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + txOpts.Value = nil + + tx, err = stakeTokenWeth.Approve(&txOpts, builder.addresses.Rollup, balance) + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + challengeManager, err := rollupUserLogic.ChallengeManager(&bind.CallOpts{Context: ctx}) + Require(t, err) + tx, err = stakeTokenWeth.Approve(&txOpts, challengeManager, balance) + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) +} + +type BoldStateProviderInterface interface { + l2stateprovider.L2MessageStateCollector + l2stateprovider.MachineHashCollector + l2stateprovider.ProofCollector + l2stateprovider.ExecutionProvider +} + +func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeBuilder, node *TestClient, addressName string, mockStateProvider func(BoldStateProviderInterface) BoldStateProviderInterface) (*solimpl.AssertionChain, func()) { if !builder.deployBold { t.Fatal("bold deployment not enabled") } - stateManager, err := bold.NewBOLDStateProvider( + var stateManager BoldStateProviderInterface + var err error + stateManager, err = bold.NewBOLDStateProvider( node.ConsensusNode.BlockValidator, node.ConsensusNode.StatelessBlockValidator, l2stateprovider.Height(blockChallengeLeafHeight), @@ -82,6 +262,10 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB ) Require(t, err) + if mockStateProvider != nil { + stateManager = mockStateProvider(stateManager) + } + provider := l2stateprovider.NewHistoryCommitmentProvider( stateManager, stateManager, @@ -130,7 +314,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB assertionChain, provider, assertionChain.RollupAddress(), - challengemanager.WithName("honest"), + challengemanager.WithName(addressName), challengemanager.WithMode(modes.MakeMode), challengemanager.WithAddress(txOpts.From), challengemanager.WithAssertionPostingInterval(time.Second*3), @@ -140,5 +324,5 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB Require(t, err) challengeManager.Start(ctx) - return challengeManager.StopAndWait + return assertionChain, challengeManager.StopAndWait } diff --git a/system_tests/mock_machine_test.go b/system_tests/mock_machine_test.go index 7a71e81d2d..516a6b31d8 100644 --- a/system_tests/mock_machine_test.go +++ b/system_tests/mock_machine_test.go @@ -34,7 +34,7 @@ func (m *IncorrectIntermediateMachine) CloneMachineInterface() server_arb.Machin func (m *IncorrectIntermediateMachine) Hash() common.Hash { h := m.MachineInterface.Hash() if m.GetStepCount() >= m.incorrectStep && m.IsRunning() { - h[0] = 0xFF + h[0] ^= 0xFF } return h } From 259a4ebb436a97033ddcd61c408c4e5334e521e8 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 5 Nov 2024 18:27:01 +0100 Subject: [PATCH 108/210] Handle challenges in the virtually padded part of the leaaves Before this change, if there was a block challenge at a height in any block above the batchLimit, then the validator was not correctly creating inclusion proofs because it was attempting to fetch execution results for blocks which didn't really exist. Now, the code detects that situation and simply returns the hash of an arbitrator machine in the FINISHED state (since the Virtual leaf hashes) are all in that state by virtue of their being repeated copies of the end state of a block. --- bold | 2 +- staker/bold/bold_state_provider.go | 92 +++++++++++++++++++----------- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/bold b/bold index e0fd45fec1..9f2eb6c0b7 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit e0fd45fec194244ef4a43823c23e76987e5f729f +Subproject commit 9f2eb6c0b7af70f1c194627e9e9915004031be4f diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index d4d47b8a0b..9e2c92df45 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -23,6 +23,7 @@ import ( "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_arb" protocol "github.com/offchainlabs/bold/chain-abstraction" l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" @@ -332,14 +333,20 @@ func (s *BOLDStateProvider) CollectMachineHashes( ) ([]common.Hash, error) { s.Lock() defer s.Unlock() - fromState := cfg.FromState - // cfg.BlockChallengeHeight is the index of the last correct block, before the - // block we're challenging. - chalHeight := cfg.BlockChallengeHeight - messageNum, _, err := s.messageNum(fromState, chalHeight) + batchLimit := cfg.AssertionMetadata.BatchLimit + messageNum, err := s.messageNum(cfg.AssertionMetadata, cfg.BlockChallengeHeight) if err != nil { return nil, err } + useFinishedMachine, err := s.useFinishedMachine(messageNum, batchLimit) + if err != nil { + return nil, err + } + if useFinishedMachine { + m := server_arb.NewFinishedMachine() + defer m.Destroy() + return []common.Hash{m.Hash()}, nil + } stepHeights := make([]uint64, len(cfg.StepHeights)) for i, h := range cfg.StepHeights { stepHeights[i] = uint64(h) @@ -350,7 +357,7 @@ func (s *BOLDStateProvider) CollectMachineHashes( } cacheKey := &challengecache.Key{ RollupBlockHash: messageResult.BlockHash, - WavmModuleRoot: cfg.WasmModuleRoot, + WavmModuleRoot: cfg.AssertionMetadata.WasmModuleRoot, MessageHeight: uint64(messageNum), StepHeights: stepHeights, } @@ -378,7 +385,8 @@ func (s *BOLDStateProvider) CollectMachineHashes( return nil, err } // TODO: Enable Redis streams. - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(cfg.WasmModuleRoot, input).Await(ctx) + wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx) if err != nil { return nil, err } @@ -408,32 +416,40 @@ func (s *BOLDStateProvider) CollectMachineHashes( return result, nil } -// messageNum finds the effective message number (or l2 block index) -// where the challenge is occurring. -func (s *BOLDStateProvider) messageNum(fromState protocol.GoGlobalState, chalHeight l2stateprovider.Height) (arbutil.MessageIndex, arbutil.MessageIndex, error) { +// messageNum returns the message number at which the BoLD protocol should +// process machine hashes based on the AssociatedAssertionMetadata and +// chalHeight. +func (s *BOLDStateProvider) messageNum(md *l2stateprovider.AssociatedAssertionMetadata, chalHeight l2stateprovider.Height) (arbutil.MessageIndex, error) { var prevBatchMsgCount arbutil.MessageIndex - if fromState.Batch > 0 { + bNum := md.FromState.Batch + posInBatch := md.FromState.PosInBatch + if bNum > 0 { var err error - prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch - 1)) + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(bNum - 1)) if err != nil { - return 0, 0, fmt.Errorf("could not get prevBatchMsgCount at %d: %w", fromState.Batch-1, err) + return 0, fmt.Errorf("could not get prevBatchMsgCount at %d: %w", bNum-1, err) } } - currBatchMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(fromState.Batch)) + return prevBatchMsgCount + arbutil.MessageIndex(posInBatch) + arbutil.MessageIndex(chalHeight), nil +} + +// useFinishedMachine returns true if messageNum is a virtual block or the +// last real block to which this validator's assertion committed. +// +// This can happen in the BoLD protocol when the rival block-level challenge +// edge has committed to more blocks that this validator expected for the +// current batch. In that case, the chalHeight will be a block in the virtual +// padding of the history commitment of this validator. +// +// A return value of true means that callers don't need to actually step through +// a machine to produce a series of hashes, because all of the hashes can just +// be "virtual" copies of a single machine in the FINISHED state's hash. +func (s *BOLDStateProvider) useFinishedMachine(msgNum arbutil.MessageIndex, limit l2stateprovider.Batch) (bool, error) { + limitMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(limit) - 1) if err != nil { - return 0, 0, fmt.Errorf("could not get currBatchMsgCount at %d: %w", fromState, err) - } - messageNum := prevBatchMsgCount + arbutil.MessageIndex(fromState.PosInBatch) + arbutil.MessageIndex(chalHeight) - if messageNum > currBatchMsgCount { - // This can happen in the BoLD protocol when the rival block-level challenge - // edge has committed to more blocks that this validator expected for the - // current batch. In that case, the BlockChallengeHeight will be a block in - // the virtual padding of the history commitment of this validator. It will - // therefore be the same as the end state of the last block in the in the - // current batch. - messageNum = currBatchMsgCount - } - return messageNum, prevBatchMsgCount, nil + return false, fmt.Errorf("could not get limitMsgCount at %d: %w", limit, err) + } + return msgNum > limitMsgCount, nil } // CtxWithCheckAlive Creates a context with a check alive routine that will @@ -476,12 +492,20 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c // CollectProof collects a one-step proof at a message number and OpcodeIndex. func (s *BOLDStateProvider) CollectProof( ctx context.Context, - fromState protocol.GoGlobalState, - wasmModuleRoot common.Hash, + assertionMetadata *l2stateprovider.AssociatedAssertionMetadata, blockChallengeHeight l2stateprovider.Height, machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { - messageNum, prevBatchMsgCount, err := s.messageNum(fromState, blockChallengeHeight) + messageNum, err := s.messageNum(assertionMetadata, blockChallengeHeight) + useFinishedMachine, err := s.useFinishedMachine(messageNum, assertionMetadata.BatchLimit) + if err != nil { + return nil, err + } + if useFinishedMachine { + m := server_arb.NewFinishedMachine() + defer m.Destroy() + return m.ProveNextStep(), nil + } entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum) if err != nil { return nil, err @@ -492,15 +516,15 @@ func (s *BOLDStateProvider) CollectProof( } log.Info( "Getting machine OSP", - "fromBatch", fromState.Batch, - "fromPosInBatch", fromState.PosInBatch, - "prevBatchMsgCount", prevBatchMsgCount, + "fromBatch", assertionMetadata.FromState.Batch, + "fromPosInBatch", assertionMetadata.FromState.PosInBatch, "blockChallengeHeight", blockChallengeHeight, "messageNum", messageNum, "machineIndex", machineIndex, "startState", fmt.Sprintf("%+v", input.StartState), ) - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModuleRoot, input).Await(ctx) + wasmModRoot := assertionMetadata.WasmModuleRoot + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx) if err != nil { return nil, err } From f878323143e1ee61bfe51a7c606349d16fa6104a Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Tue, 5 Nov 2024 17:02:48 -0700 Subject: [PATCH 109/210] common_test: remove race condition --- system_tests/common_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 4fac71e3f9..9d491f522b 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1224,7 +1224,6 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client, stack.RegisterAPIs(tracers.APIs(l1backend.APIBackend)) Require(t, stack.Start()) - Require(t, l1backend.Start()) rpcClient := stack.Attach() From aa5ebaae58ff054ab1b680d24fe451a86fab67b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 01:13:05 +0000 Subject: [PATCH 110/210] Bump google.golang.org/grpc from 1.64.0 to 1.64.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.64.0 to 1.64.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.64.0...v1.64.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cbe473d15b..34b04121f0 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,7 @@ require ( google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect - google.golang.org/grpc v1.64.0 // indirect + google.golang.org/grpc v1.64.1 // indirect ) require ( diff --git a/go.sum b/go.sum index 25b594cc25..bbb38af6ac 100644 --- a/go.sum +++ b/go.sum @@ -980,8 +980,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 30af4fffa28dcb8ea7bb906d3cd4a83daf78998c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 6 Nov 2024 15:28:47 +0100 Subject: [PATCH 111/210] Get the test to compile --- system_tests/bold_new_challenge_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index a417ead2fa..15251e5c2b 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -105,12 +105,11 @@ func (s *incorrectBlockStateProvider) CollectMachineHashes( func (s *incorrectBlockStateProvider) CollectProof( ctx context.Context, - fromState protocol.GoGlobalState, - wasmModuleRoot common.Hash, + assertionMetadata *l2stateprovider.AssociatedAssertionMetadata, blockChallengeHeight l2stateprovider.Height, machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { - return s.honest.CollectProof(ctx, fromState, wasmModuleRoot, blockChallengeHeight, machineIndex) + return s.honest.CollectProof(ctx, assertionMetadata, blockChallengeHeight, machineIndex) } func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { From e712059084cf36b4ac30943f5e93a891cad8dcd5 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 6 Nov 2024 08:39:34 -0600 Subject: [PATCH 112/210] Split virtual blocks test into first and near last virtual block tests --- system_tests/bold_new_challenge_test.go | 42 ++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 15251e5c2b..2330e051ab 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -33,10 +33,11 @@ import ( ) type incorrectBlockStateProvider struct { - honest *bold.BOLDStateProvider - wrongAtBlockHeight uint64 - honestMachineHash common.Hash - evilMachineHash common.Hash + honest *bold.BOLDStateProvider + wrongAtFirstVirtual bool + wrongAtBlockHeight uint64 + honestMachineHash common.Hash + evilMachineHash common.Hash } func (s *incorrectBlockStateProvider) ExecutionStateAfterPreviousState( @@ -71,6 +72,19 @@ func (s *incorrectBlockStateProvider) L2MessageStatesUpTo( if err != nil { return nil, err } + if s.wrongAtFirstVirtual && (toHeight.IsNone() || uint64(len(states)) < uint64(toHeight.Unwrap())) { + // We've found the first virtual block, now let's make it wrong + s.wrongAtFirstVirtual = false + s.wrongAtBlockHeight = uint64(len(states)) + // Double check that the first virtual block isn't earlier + for i := len(states) - 1; i >= 1; i-- { + if states[i] == states[i-1] { + s.wrongAtBlockHeight = uint64(i) + } else { + break + } + } + } if toHeight.IsNone() || uint64(toHeight.Unwrap()) >= s.wrongAtBlockHeight { for uint64(len(states)) <= s.wrongAtBlockHeight { states = append(states, states[len(states)-1]) @@ -112,7 +126,7 @@ func (s *incorrectBlockStateProvider) CollectProof( return s.honest.CollectProof(ctx, assertionMetadata, blockChallengeHeight, machineIndex) } -func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { +func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bool) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -144,10 +158,14 @@ func TestChallengeProtocolBOLDVirtualBlocks(t *testing.T) { defer cleanupHonestChallengeManager() _, cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "EvilAsserter", func(stateManager BoldStateProviderInterface) BoldStateProviderInterface { - return &incorrectBlockStateProvider{ - honest: stateManager.(*bold.BOLDStateProvider), - wrongAtBlockHeight: blockChallengeLeafHeight - 2, + p := &incorrectBlockStateProvider{ + honest: stateManager.(*bold.BOLDStateProvider), + wrongAtFirstVirtual: wrongAtFirstVirtual, + } + if !wrongAtFirstVirtual { + p.wrongAtBlockHeight = blockChallengeLeafHeight - 2 } + return p }) defer cleanupEvilChallengeManager() @@ -235,6 +253,14 @@ func fundBoldStaker(t *testing.T, ctx context.Context, builder *NodeBuilder, nam Require(t, err) } +func TestChallengeProtocolBOLDNearLastVirtualBlock(t *testing.T) { + testChallengeProtocolBOLDVirtualBlocks(t, false) +} + +func TestChallengeProtocolBOLDFirstVirtualBlock(t *testing.T) { + testChallengeProtocolBOLDVirtualBlocks(t, true) +} + type BoldStateProviderInterface interface { l2stateprovider.L2MessageStateCollector l2stateprovider.MachineHashCollector From d3266db61cb69f447ae9de1e70685e8613447f99 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 6 Nov 2024 08:46:09 -0600 Subject: [PATCH 113/210] Update test to better handle virtual blocks returned by honest impl --- system_tests/bold_new_challenge_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 2330e051ab..e30f019d55 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -72,18 +72,18 @@ func (s *incorrectBlockStateProvider) L2MessageStatesUpTo( if err != nil { return nil, err } + // Double check that virtual blocks aren't being enumerated by the honest impl + for i := len(states) - 1; i >= 1; i-- { + if states[i] == states[i-1] { + panic("Virtual block found repeated in honest impl (test case currently doesn't accomodate this)") + } else { + break + } + } if s.wrongAtFirstVirtual && (toHeight.IsNone() || uint64(len(states)) < uint64(toHeight.Unwrap())) { // We've found the first virtual block, now let's make it wrong s.wrongAtFirstVirtual = false s.wrongAtBlockHeight = uint64(len(states)) - // Double check that the first virtual block isn't earlier - for i := len(states) - 1; i >= 1; i-- { - if states[i] == states[i-1] { - s.wrongAtBlockHeight = uint64(i) - } else { - break - } - } } if toHeight.IsNone() || uint64(toHeight.Unwrap()) >= s.wrongAtBlockHeight { for uint64(len(states)) <= s.wrongAtBlockHeight { From 5c69c82e13104a5e3d0f97ebbce41772e2ef2dfa Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Wed, 6 Nov 2024 15:36:55 -0700 Subject: [PATCH 114/210] switch geth-hook to PostingGasHook --- execution/nodeInterface/NodeInterface.go | 10 ++++------ execution/nodeInterface/virtual-contracts.go | 20 ++++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 005cc62d44..00da1ba4b6 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -522,11 +522,10 @@ func (n NodeInterface) GasEstimateL1Component( args.Gas = (*hexutil.Uint64)(&randomGas) // We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate - gasLimitNotSetByUser := args.Gas == nil - if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil { + if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser) + msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) pricing := c.State.L1PricingState() l1BaseFeeEstimate, err := pricing.PricePerUnit() @@ -579,11 +578,10 @@ func (n NodeInterface) GasEstimateComponents( // Setting the gas currently doesn't affect the PosterDataCost, // but we do it anyways for accuracy with potential future changes. args.Gas = &totalRaw - gasLimitNotSetByUser := args.Gas == nil - if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID, gasLimitNotSetByUser); err != nil { + if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode, evm.ChainConfig().ChainID, gasLimitNotSetByUser) + msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) brotliCompressionLevel, err := c.State.BrotliCompressionLevel() if err != nil { return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err) diff --git a/execution/nodeInterface/virtual-contracts.go b/execution/nodeInterface/virtual-contracts.go index d04be10857..53c64a0ed3 100644 --- a/execution/nodeInterface/virtual-contracts.go +++ b/execution/nodeInterface/virtual-contracts.go @@ -23,7 +23,6 @@ import ( "github.com/offchainlabs/nitro/precompiles" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/arbmath" ) type addr = common.Address @@ -115,35 +114,28 @@ func init() { return msg, nil, nil } - core.InterceptRPCGasCap = func(gascap *uint64, msg *core.Message, header *types.Header, statedb *state.StateDB) { - if *gascap == 0 { - // It's already unlimited - return - } + core.PostingGasHook = func(msg *core.Message, header *types.Header, statedb *state.StateDB) (uint64, error) { arbosVersion := arbosState.ArbOSVersion(statedb) if arbosVersion == 0 { // ArbOS hasn't been installed, so use the vanilla gas cap - return + return 0, nil } state, err := arbosState.OpenSystemArbosState(statedb, nil, true) if err != nil { - log.Error("failed to open ArbOS state", "err", err) - return + return 0, err } if header.BaseFee.Sign() == 0 { // if gas is free or there's no reimbursable poster, the user won't pay for L1 data costs - return + return 0, nil } brotliCompressionLevel, err := state.BrotliCompressionLevel() if err != nil { - log.Error("failed to get brotli compression level", "err", err) - return + return 0, err } posterCost, _ := state.L1PricingState().PosterDataCost(msg, l1pricing.BatchPosterAddress, brotliCompressionLevel) // Use estimate mode because this is used to raise the gas cap, so we don't want to underestimate. - posterCostInL2Gas := arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost) - *gascap = arbmath.SaturatingUAdd(*gascap, posterCostInL2Gas) + return arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost), nil } core.GetArbOSSpeedLimitPerSecond = func(statedb *state.StateDB) (uint64, error) { From a4809d448c48063340d595cd7bcb286bd0a52f66 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Wed, 6 Nov 2024 15:37:05 -0700 Subject: [PATCH 115/210] update geth pin for posting gas hook --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index c4334737c9..319e72fe9d 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit c4334737c95dc2b1bd398d2fe7feefee72da2f0f +Subproject commit 319e72fe9d0779bac3a6864214f7bb5dbf2babe3 From 967074af3e2b3c136f636f993518dfc9dba31636 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Wed, 6 Nov 2024 18:17:45 -0700 Subject: [PATCH 116/210] rename to RPCPostingGasHook --- execution/nodeInterface/virtual-contracts.go | 2 +- go-ethereum | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/execution/nodeInterface/virtual-contracts.go b/execution/nodeInterface/virtual-contracts.go index 53c64a0ed3..86382870b7 100644 --- a/execution/nodeInterface/virtual-contracts.go +++ b/execution/nodeInterface/virtual-contracts.go @@ -114,7 +114,7 @@ func init() { return msg, nil, nil } - core.PostingGasHook = func(msg *core.Message, header *types.Header, statedb *state.StateDB) (uint64, error) { + core.RPCPostingGasHook = func(msg *core.Message, header *types.Header, statedb *state.StateDB) (uint64, error) { arbosVersion := arbosState.ArbOSVersion(statedb) if arbosVersion == 0 { // ArbOS hasn't been installed, so use the vanilla gas cap diff --git a/go-ethereum b/go-ethereum index 319e72fe9d..973f8a3c27 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 319e72fe9d0779bac3a6864214f7bb5dbf2babe3 +Subproject commit 973f8a3c278c961ac5cb5049167c8e28dd16262b From ae1d18a4c83be1473a931068adf8491928447add Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 7 Nov 2024 07:45:30 +0100 Subject: [PATCH 117/210] Fix the CollectProof and CollectMachineHashes calls Previously, they couldn't produce correct inclusion proofs for block-level challenges on blocks in the virtual range. That is to say, if this validaotor processed n L2Blocks when creating an assertion and a rival processed >= n+1 L2Blocks, this validator would attempt to lookup a block index for which no real block existed. Now, the code properly catches this case and the last machine state for the last real block is used for all virtual L2Blocks. --- staker/bold/bold_state_provider.go | 46 ++++++++++++++++++------- system_tests/bold_new_challenge_test.go | 2 +- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 9e2c92df45..899bcaf009 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -338,12 +338,14 @@ func (s *BOLDStateProvider) CollectMachineHashes( if err != nil { return nil, err } - useFinishedMachine, err := s.useFinishedMachine(messageNum, batchLimit) + // Check if we have a virtual global state. + vs, err := s.virtualState(messageNum, batchLimit) if err != nil { return nil, err } - if useFinishedMachine { + if vs.IsSome() { m := server_arb.NewFinishedMachine() + m.SetGlobalState(vs.Unwrap()) defer m.Destroy() return []common.Hash{m.Hash()}, nil } @@ -433,23 +435,41 @@ func (s *BOLDStateProvider) messageNum(md *l2stateprovider.AssociatedAssertionMe return prevBatchMsgCount + arbutil.MessageIndex(posInBatch) + arbutil.MessageIndex(chalHeight), nil } -// useFinishedMachine returns true if messageNum is a virtual block or the -// last real block to which this validator's assertion committed. +// virtualState returns an optional global state. +// +// If messageNum is a virtual block or the last real block to which this +// validator's assertion committed, then this function retuns a global state +// representing that virtual block's finished machine. Otherwise, it returns +// an Option.None. // // This can happen in the BoLD protocol when the rival block-level challenge // edge has committed to more blocks that this validator expected for the // current batch. In that case, the chalHeight will be a block in the virtual // padding of the history commitment of this validator. // -// A return value of true means that callers don't need to actually step through -// a machine to produce a series of hashes, because all of the hashes can just -// be "virtual" copies of a single machine in the FINISHED state's hash. -func (s *BOLDStateProvider) useFinishedMachine(msgNum arbutil.MessageIndex, limit l2stateprovider.Batch) (bool, error) { +// If there is an Option.Some() retrun value, it means that callers don't need +// to actually step through a machine to produce a series of hashes, because all +// of the hashes can just be "virtual" copies of a single machine in the +// FINISHED state's hash. +func (s *BOLDStateProvider) virtualState(msgNum arbutil.MessageIndex, limit l2stateprovider.Batch) (option.Option[validator.GoGlobalState], error) { + gs := option.None[validator.GoGlobalState]() limitMsgCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(limit) - 1) if err != nil { - return false, fmt.Errorf("could not get limitMsgCount at %d: %w", limit, err) + return gs, fmt.Errorf("could not get limitMsgCount at %d: %w", limit, err) } - return msgNum > limitMsgCount, nil + if msgNum >= limitMsgCount { + result, err := s.statelessValidator.InboxStreamer().ResultAtCount(arbutil.MessageIndex(limitMsgCount)) + if err != nil { + return gs, fmt.Errorf("could not get global state at limitMsgCount %d: %w", limitMsgCount, err) + } + gs = option.Some(validator.GoGlobalState{ + BlockHash: result.BlockHash, + SendRoot: result.SendRoot, + Batch: uint64(limit), + PosInBatch: 0, + }) + } + return gs, nil } // CtxWithCheckAlive Creates a context with a check alive routine that will @@ -497,12 +517,14 @@ func (s *BOLDStateProvider) CollectProof( machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { messageNum, err := s.messageNum(assertionMetadata, blockChallengeHeight) - useFinishedMachine, err := s.useFinishedMachine(messageNum, assertionMetadata.BatchLimit) + // Check if we have a virtual global state. + vs, err := s.virtualState(messageNum, assertionMetadata.BatchLimit) if err != nil { return nil, err } - if useFinishedMachine { + if vs.IsSome() { m := server_arb.NewFinishedMachine() + m.SetGlobalState(vs.Unwrap()) defer m.Destroy() return m.ProveNextStep(), nil } diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 2330e051ab..b929421756 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -208,7 +208,7 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo signer := types.NewCancunSigner(tx.ChainId()) address, err := signer.Sender(tx) Require(t, err) - if address == builder.L1Info.GetAddress("Asserter") { + if address == builder.L1Info.GetAddress("HonestAsserter") { t.Log("Honest party won OSP, impossible for evil party to win if honest party continues") Require(t, it.Close()) return From 40c8c9a2aca7d37a9bf5b66c5be5ea697d3d18c9 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 7 Nov 2024 14:44:51 -0700 Subject: [PATCH 118/210] Add dangerous batch poster options configurable --- arbnode/batch_poster.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 185f43fce7..2438d46958 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -203,6 +203,10 @@ func (c *BatchPosterConfig) Validate() error { type BatchPosterConfigFetcher func() *BatchPosterConfig +func DangerousBatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { + f.Bool(prefix+".allow-posting-first-batch-when-sequencer-message-count-mismatch", DefaultBatchPosterConfig.Dangerous.AllowPostingFirstBatchWhenSequencerMessageCountMismatch, "allow posting the first batch even if sequence number doesn't match chain (useful after force-inclusion)") +} + func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".enable", DefaultBatchPosterConfig.Enable, "enable posting batches to l1") f.Bool(prefix+".disable-dap-fallback-store-data-on-chain", DefaultBatchPosterConfig.DisableDapFallbackStoreDataOnChain, "If unable to batch to DA provider, disable fallback storing data on chain") @@ -229,6 +233,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { redislock.AddConfigOptions(prefix+".redis-lock", f) dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfig) genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultBatchPosterConfig.ParentChainWallet.Pathname) + DangerousBatchPosterConfigAddOptions(prefix+".dangerous", f) } var DefaultBatchPosterConfig = BatchPosterConfig{ From 26558d055542f1cda2673ed2146fb1d74c30439c Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Fri, 8 Nov 2024 16:41:43 +0530 Subject: [PATCH 119/210] stylus test: infinite loop should create out-of-gas error --- arbitrator/prover/test-cases/user.wat | 12 ++++++++++++ system_tests/program_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/arbitrator/prover/test-cases/user.wat b/arbitrator/prover/test-cases/user.wat index 9ecb4dcc45..68f45a610a 100644 --- a/arbitrator/prover/test-cases/user.wat +++ b/arbitrator/prover/test-cases/user.wat @@ -22,6 +22,12 @@ i32.const 0xFFFFFF i32.load ) + (func $infinite_loop (result i32) + (loop $loop + br $loop + ) + i32.const 0 + ) (func (export "user_entrypoint") (param $args_len i32) (result i32) ;; this func uses $args_len to select which func to call @@ -43,6 +49,12 @@ (then (call $out_of_bounds) (return)) ) + ;; reverts due to an out-of-gas error + (i32.eq (local.get $args_len) (i32.const 4)) + (if + (then (call $infinite_loop) (return)) + ) + (i32.eq (local.get $args_len) (i32.const 32)) (if (then (call $storage_load) (return)) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index ea4ccddd03..94aaef5f34 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1005,6 +1005,31 @@ func TestProgramMemory(t *testing.T) { testMemory(t, true) } +func TestProgramInfiniteLoopShouldCauseErrOutOfGas(t *testing.T) { + t.Parallel() + testInfiniteLoopCausesErrOutOfGas(t, true) + testInfiniteLoopCausesErrOutOfGas(t, false) +} + +func testInfiniteLoopCausesErrOutOfGas(t *testing.T, jit bool) { + builder, auth, cleanup := setupProgramTest(t, jit) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + userWasm := deployWasm(t, ctx, auth, l2client, "../arbitrator/prover/test-cases/user.wat") + // Passing input of size 4 invokes $infinite_loop function that calls the infinite loop + tx := l2info.PrepareTxTo("Owner", &userWasm, 1000000, nil, make([]byte, 4)) + Require(t, l2client.SendTransaction(ctx, tx)) + receipt, err := EnsureTxSucceeded(ctx, l2client, tx) + if !strings.Contains(err.Error(), vm.ErrOutOfGas.Error()) { + t.Fatalf("transaction should have failed with out of gas error but instead failed with: %v", err) + } + + validateBlocks(t, receipt.BlockNumber.Uint64(), jit, builder) +} + func testMemory(t *testing.T, jit bool) { builder, auth, cleanup := setupProgramTest(t, jit) ctx := builder.ctx From 4fe5c8b10047558ccea91e42b84e7eb9a13abcfa Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Fri, 8 Nov 2024 18:32:09 +0530 Subject: [PATCH 120/210] fix user.wat --- arbitrator/prover/test-cases/user.wat | 2 +- system_tests/program_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arbitrator/prover/test-cases/user.wat b/arbitrator/prover/test-cases/user.wat index 68f45a610a..694d2f3ed8 100644 --- a/arbitrator/prover/test-cases/user.wat +++ b/arbitrator/prover/test-cases/user.wat @@ -26,7 +26,7 @@ (loop $loop br $loop ) - i32.const 0 + unreachable ) (func (export "user_entrypoint") (param $args_len i32) (result i32) ;; this func uses $args_len to select which func to call diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 94aaef5f34..fbff338d7d 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1000,11 +1000,6 @@ func testCreate(t *testing.T, jit bool) { validateBlockRange(t, blocks, jit, builder) } -func TestProgramMemory(t *testing.T) { - t.Parallel() - testMemory(t, true) -} - func TestProgramInfiniteLoopShouldCauseErrOutOfGas(t *testing.T) { t.Parallel() testInfiniteLoopCausesErrOutOfGas(t, true) @@ -1030,6 +1025,11 @@ func testInfiniteLoopCausesErrOutOfGas(t *testing.T, jit bool) { validateBlocks(t, receipt.BlockNumber.Uint64(), jit, builder) } +func TestProgramMemory(t *testing.T) { + t.Parallel() + testMemory(t, true) +} + func testMemory(t *testing.T, jit bool) { builder, auth, cleanup := setupProgramTest(t, jit) ctx := builder.ctx From f8b2c3fb83022e0be9325729a97a408baf7c0c08 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Fri, 8 Nov 2024 21:56:30 +0530 Subject: [PATCH 121/210] update user.wat's module hash --- arbitrator/prover/test-cases/dynamic.wat | 2 +- arbitrator/prover/test-cases/go/main.go | 2 +- arbitrator/prover/test-cases/link.wat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arbitrator/prover/test-cases/dynamic.wat b/arbitrator/prover/test-cases/dynamic.wat index 8771bde87c..5de0dbdca1 100644 --- a/arbitrator/prover/test-cases/dynamic.wat +++ b/arbitrator/prover/test-cases/dynamic.wat @@ -12,7 +12,7 @@ ;; WAVM Module hash (data (i32.const 0x000) - "\a1\49\cf\81\13\ff\9c\95\f2\c8\c2\a1\42\35\75\36\7d\e8\6d\d4\22\d8\71\14\bb\9e\a4\7b\af\53\5d\d7") ;; user + "\ae\87\91\cf\6a\c4\55\ff\28\06\b9\55\d5\a7\36\e8\1b\c7\91\f7\93\8a\22\a4\08\23\25\16\37\01\48\25") ;; user (func $start (local $user i32) (local $internals i32) ;; link in user.wat i32.const 0 diff --git a/arbitrator/prover/test-cases/go/main.go b/arbitrator/prover/test-cases/go/main.go index 1f81553af2..b959454d26 100644 --- a/arbitrator/prover/test-cases/go/main.go +++ b/arbitrator/prover/test-cases/go/main.go @@ -73,7 +73,7 @@ const BYTES_PER_FIELD_ELEMENT = 32 var BLS_MODULUS, _ = new(big.Int).SetString("52435875175126190479447740508185965837690552500527637822603658699938581184513", 10) -var stylusModuleHash = common.HexToHash("a149cf8113ff9c95f2c8c2a1423575367de86dd422d87114bb9ea47baf535dd7") // user.wat +var stylusModuleHash = common.HexToHash("ae8791cf6ac455ff2806b955d5a736e81bc791f7938a22a40823251637014825") // user.wat func callStylusProgram(recurse int) { evmData := programs.EvmData{} diff --git a/arbitrator/prover/test-cases/link.wat b/arbitrator/prover/test-cases/link.wat index ef15326481..85490a40b1 100644 --- a/arbitrator/prover/test-cases/link.wat +++ b/arbitrator/prover/test-cases/link.wat @@ -30,7 +30,7 @@ (data (i32.const 0x140) "\47\f7\4f\9c\21\51\4f\52\24\ea\d3\37\5c\bf\a9\1b\1a\5f\ef\22\a5\2a\60\30\c5\52\18\90\6b\b1\51\e5") ;; iops (data (i32.const 0x160) - "\a1\49\cf\81\13\ff\9c\95\f2\c8\c2\a1\42\35\75\36\7d\e8\6d\d4\22\d8\71\14\bb\9e\a4\7b\af\53\5d\d7") ;; user + "\ae\87\91\cf\6a\c4\55\ff\28\06\b9\55\d5\a7\36\e8\1b\c7\91\f7\93\8a\22\a4\08\23\25\16\37\01\48\25") ;; user (data (i32.const 0x180) "\ee\47\08\f6\47\b2\10\88\1f\89\86\e7\e3\79\6b\b2\77\43\f1\4e\ee\cf\45\4a\9b\7c\d7\c4\5b\63\b6\d7") ;; return From b8a297b4470d66efc597c73a25bbf20bd71ab871 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 8 Nov 2024 10:28:10 -0600 Subject: [PATCH 122/210] Use exec for docker entrypoint --- scripts/split-val-entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/split-val-entry.sh b/scripts/split-val-entry.sh index 42e0c5fe08..ab8c520918 100755 --- a/scripts/split-val-entry.sh +++ b/scripts/split-val-entry.sh @@ -39,4 +39,4 @@ for port in 52000 52001; do done done echo launching nitro-node -/usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52001"}]' "$@" +exec /usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52001"}]' "$@" From 2f0bc89a0f2e3d16d8cdd8d71134902b3f7a08ec Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 09:21:48 +0100 Subject: [PATCH 123/210] Get the branch building again This is probably not where we ultimately want to be. Too much boilerplate is escaping from the bold system. Maybe, before introducing a dependency injection framework, I should just introduce something manual that would instatiate all the instances that the challenge manager, watcher, assertion manager, etc. need and then wires them together in the "default" way using the constructors from each package. --- bold | 2 +- staker/bold/bold_staker.go | 30 ++++++++++++++--- staker/bold/bold_state_provider.go | 11 ++++-- system_tests/bold_challenge_protocol_test.go | 35 +++++++++++++++++--- system_tests/bold_new_challenge_test.go | 18 ++++++++-- 5 files changed, 82 insertions(+), 14 deletions(-) diff --git a/bold b/bold index 9f2eb6c0b7..06de67750e 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 9f2eb6c0b7af70f1c194627e9e9915004031be4f +Subproject commit 06de67750eac6ea40ba6359df605ce02a7997d5f diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index e099af58b9..d57d95ee2c 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -9,6 +9,7 @@ import ( "math/big" "time" + "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -394,11 +395,29 @@ func newBOLDChallengeManager( scanningInterval := config.AssertionScanningInterval // The interval at which the manager will attempt to confirm assertions. confirmingInterval := config.AssertionConfirmingInterval - opts := []challengemanager.Opt{ + + amOpts := []assertions.Opt{ + assertions.WithPostingInterval(postingInterval), + assertions.WithPollingInterval(scanningInterval), + assertions.WithConfirmationInterval(confirmingInterval), + } + assertionManager, err := assertions.NewManager( + assertionChain, + provider, + assertionChain.Backend(), + assertionChain.RollupAddress(), + config.StateProviderConfig.ValidatorName, + nil, // TODO: This is not going to cut it. + BoldModes[config.Mode], + amOpts..., + ) + if err != nil { + return nil, fmt.Errorf("could not create assertion manager: %w", err) + } + + cmOpts := []challengemanager.Opt{ challengemanager.WithName(config.StateProviderConfig.ValidatorName), challengemanager.WithMode(BoldModes[config.Mode]), - challengemanager.WithAssertionPostingInterval(postingInterval), - challengemanager.WithAssertionScanningInterval(scanningInterval), challengemanager.WithAssertionConfirmingInterval(confirmingInterval), challengemanager.WithAddress(txOpts.From), // Configure the validator to track only certain challenges if configured to do so. @@ -406,14 +425,15 @@ func newBOLDChallengeManager( } if config.API { // Conditionally enables the BOLD API if configured. - opts = append(opts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.APIHost, config.APIPort), config.APIDBPath)) + cmOpts = append(cmOpts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.APIHost, config.APIPort), config.APIDBPath)) } manager, err := challengemanager.New( ctx, assertionChain, provider, + assertionManager, assertionChain.RollupAddress(), - opts..., + cmOpts..., ) if err != nil { return nil, fmt.Errorf("could not create challenge manager: %w", err) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 899bcaf009..b204788d9a 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -345,7 +345,9 @@ func (s *BOLDStateProvider) CollectMachineHashes( } if vs.IsSome() { m := server_arb.NewFinishedMachine() - m.SetGlobalState(vs.Unwrap()) + if err := m.SetGlobalState(vs.Unwrap()); err != nil { + return nil, err + } defer m.Destroy() return []common.Hash{m.Hash()}, nil } @@ -517,6 +519,9 @@ func (s *BOLDStateProvider) CollectProof( machineIndex l2stateprovider.OpcodeIndex, ) ([]byte, error) { messageNum, err := s.messageNum(assertionMetadata, blockChallengeHeight) + if err != nil { + return nil, err + } // Check if we have a virtual global state. vs, err := s.virtualState(messageNum, assertionMetadata.BatchLimit) if err != nil { @@ -524,7 +529,9 @@ func (s *BOLDStateProvider) CollectProof( } if vs.IsSome() { m := server_arb.NewFinishedMachine() - m.SetGlobalState(vs.Unwrap()) + if err := m.SetGlobalState(vs.Unwrap()); err != nil { + return nil, err + } defer m.Destroy() return m.ProveNextStep(), nil } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index b104599587..55fb2790b0 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -387,30 +388,56 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp nil, // Api db ) + assertionManager, err := assertions.NewManager( + assertionChain, + provider, + assertionChain.Backend(), + assertionChain.RollupAddress(), + "honest", + nil, + modes.MakeMode, + assertions.WithPostingInterval(time.Second*3), + assertions.WithPollingInterval(time.Second), + assertions.WithAverageBlockCreationTime(time.Second), + ) + Require(t, err) + manager, err := challengemanager.New( ctx, assertionChain, provider, + assertionManager, assertionChain.RollupAddress(), challengemanager.WithName("honest"), challengemanager.WithMode(modes.MakeMode), challengemanager.WithAddress(l1info.GetDefaultTransactOpts("Asserter", ctx).From), - challengemanager.WithAssertionPostingInterval(time.Second*3), - challengemanager.WithAssertionScanningInterval(time.Second), challengemanager.WithAvgBlockCreationTime(time.Second), ) Require(t, err) + assertionManagerB, err := assertions.NewManager( + chainB, + evilProvider, + chainB.Backend(), + chainB.RollupAddress(), + "evil", + nil, + modes.MakeMode, + assertions.WithPostingInterval(time.Second*3), + assertions.WithPollingInterval(time.Second), + assertions.WithAverageBlockCreationTime(time.Second), + ) + Require(t, err) + managerB, err := challengemanager.New( ctx, chainB, evilProvider, + assertionManagerB, assertionChain.RollupAddress(), challengemanager.WithName("evil"), challengemanager.WithMode(modes.MakeMode), challengemanager.WithAddress(l1info.GetDefaultTransactOpts("EvilAsserter", ctx).From), - challengemanager.WithAssertionPostingInterval(time.Second*3), - challengemanager.WithAssertionScanningInterval(time.Second), challengemanager.WithAvgBlockCreationTime(time.Second), ) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 77b3311c32..0d4090dccb 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -332,18 +333,31 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB builder.L1.Client, solimpl.NewDataPosterTransactor(dp), ) + Require(t, err) + assertionManager, err := assertions.NewManager( + assertionChain, + provider, + assertionChain.Backend(), + assertionChain.RollupAddress(), + addressName, + nil, + modes.MakeMode, + assertions.WithPostingInterval(time.Second*3), + assertions.WithPollingInterval(time.Second), + assertions.WithAverageBlockCreationTime(time.Second), + ) Require(t, err) + challengeManager, err := challengemanager.New( ctx, assertionChain, provider, + assertionManager, assertionChain.RollupAddress(), challengemanager.WithName(addressName), challengemanager.WithMode(modes.MakeMode), challengemanager.WithAddress(txOpts.From), - challengemanager.WithAssertionPostingInterval(time.Second*3), - challengemanager.WithAssertionScanningInterval(time.Second), challengemanager.WithAvgBlockCreationTime(time.Second), ) Require(t, err) From 2fc8cf110c138bdbe887623396834b622679153f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 09:35:02 +0100 Subject: [PATCH 124/210] Add gci to the golangci-lint config This change also runs the gci linter against the repo to give us a "hard reset" on all of the package imports. Editor integrations: https://golangci-lint.run/welcome/integrations/ --- .golangci.yml | 8 ++++ arbcompress/native.go | 1 + arbnode/api.go | 1 + arbnode/dataposter/data_poster.go | 11 ++--- arbnode/dataposter/dataposter_test.go | 6 ++- arbnode/dataposter/dbstorage/storage.go | 1 + .../externalsignertest/externalsignertest.go | 1 + arbnode/dataposter/redis/redisstorage.go | 3 +- arbnode/dataposter/storage/storage.go | 1 + arbnode/dataposter/storage_test.go | 6 ++- arbnode/delayed_seq_reorg_test.go | 1 + arbnode/delayed_sequencer.go | 3 +- arbnode/inbox_reader.go | 3 +- arbnode/inbox_test.go | 17 ++++---- arbnode/inbox_tracker_test.go | 1 + arbnode/maintenance.go | 4 +- arbnode/message_pruner.go | 4 +- arbnode/message_pruner_test.go | 1 + arbnode/node.go | 1 + arbnode/redislock/redis.go | 6 ++- .../resourcemanager/resource_management.go | 3 +- arbnode/sequencer_inbox.go | 2 +- arbnode/sync_monitor.go | 4 +- arbnode/transaction_streamer.go | 3 +- arbos/activate_test.go | 1 + arbos/addressSet/addressSet.go | 1 + arbos/addressSet/addressSet_test.go | 5 ++- arbos/addressTable/addressTable.go | 1 + arbos/addressTable/addressTable_test.go | 1 + arbos/arbosState/arbosstate_test.go | 1 + arbos/arbosState/initialization_test.go | 1 + arbos/arbosState/initialize.go | 6 ++- arbos/arbostypes/messagewithmeta.go | 1 + arbos/block_processor.go | 12 +++--- arbos/blockhash/blockhash.go | 1 + arbos/blockhash/blockhash_test.go | 1 + arbos/burn/burn.go | 1 + arbos/extra_transaction_checks.go | 1 + arbos/incomingmessage_test.go | 1 + arbos/internal_tx.go | 7 ++-- arbos/l1pricing/batchPoster.go | 1 + arbos/l1pricing/batchPoster_test.go | 1 + arbos/l1pricing/l1PricingOldVersions.go | 1 + arbos/l1pricing/l1pricing.go | 14 +++---- arbos/l1pricing/l1pricing_test.go | 1 + arbos/l1pricing_test.go | 11 ++--- arbos/l2pricing/model.go | 1 + arbos/merkleAccumulator/merkleAccumulator.go | 1 + arbos/parse_l2.go | 1 + arbos/programs/api.go | 4 +- arbos/programs/native.go | 2 + arbos/programs/native_api.go | 2 + arbos/programs/params.go | 1 + arbos/programs/programs.go | 1 + arbos/programs/testcompile.go | 1 + arbos/queue_test.go | 1 - arbos/retryable_test.go | 10 ++--- arbos/retryables/retryable.go | 1 + arbos/storage/queue.go | 4 +- arbos/storage/storage.go | 1 + arbos/storage/storage_test.go | 1 + arbos/tx_processor.go | 18 ++++---- arbos/util/retryable_encoding_test.go | 9 ++-- arbos/util/storage_cache.go | 3 +- arbos/util/storage_cache_test.go | 4 +- arbos/util/tracing.go | 3 +- arbos/util/transfer.go | 4 +- arbos/util/util.go | 1 + arbstate/daprovider/reader.go | 1 + arbstate/inbox_fuzz_test.go | 1 + arbutil/hash_test.go | 3 +- blocks_reexecutor/blocks_reexecutor.go | 4 +- broadcastclient/broadcastclient.go | 1 + broadcaster/backlog/backlog.go | 1 + broadcaster/message/message.go | 1 + .../message/message_serialization_test.go | 1 + cmd/conf/chain.go | 3 +- cmd/conf/database.go | 3 +- cmd/conf/init.go | 3 +- .../data_availability_check.go | 4 +- cmd/datool/datool.go | 2 +- cmd/dbconv/dbconv/config.go | 3 +- cmd/dbconv/dbconv/dbconv.go | 1 + cmd/dbconv/main.go | 4 +- cmd/deploy/deploy.go | 12 +++--- cmd/genericconf/config.go | 3 +- cmd/genericconf/filehandler_test.go | 1 + cmd/genericconf/liveconfig.go | 1 + cmd/genericconf/logging.go | 3 +- cmd/genericconf/pprof.go | 1 - cmd/nitro-val/config.go | 5 ++- cmd/nitro/config_test.go | 6 +-- cmd/nitro/init.go | 1 + cmd/nitro/init_test.go | 4 +- cmd/pruning/pruning.go | 1 + cmd/replay/db.go | 1 + .../rediscoordinator/redis_coordinator.go | 3 +- .../seq-coordinator-manager.go | 6 ++- das/aggregator_test.go | 4 +- das/cache_storage_service.go | 7 ++-- das/chain_fetch_das.go | 4 +- das/das.go | 3 +- das/dasRpcClient.go | 5 ++- das/dasRpcServer.go | 1 - das/dastree/dastree.go | 1 + das/dastree/dastree_test.go | 1 + das/db_storage_service.go | 4 +- das/fallback_storage_service.go | 1 + das/fallback_storage_service_test.go | 1 + das/google_cloud_storage_service_test.go | 9 ++-- das/key_utils.go | 1 + das/local_file_storage_service.go | 6 ++- das/memory_backed_storage_service.go | 1 + das/panic_wrapper.go | 1 + das/reader_aggregator_strategies_test.go | 1 + das/redis_storage_service.go | 10 ++--- das/redis_storage_service_test.go | 1 + das/redundant_storage_service.go | 1 + das/restful_client.go | 1 + das/restful_server.go | 1 + das/rpc_aggregator.go | 7 ++-- das/rpc_test.go | 1 + das/s3_storage_service.go | 8 ++-- das/signature_verifier.go | 1 + das/simple_das_reader_aggregator.go | 4 +- das/storage_service.go | 1 + das/syncing_fallback_storage.go | 4 +- das/util.go | 1 + deploy/deploy.go | 1 + execution/gethexec/api.go | 1 + execution/gethexec/block_recorder.go | 4 +- execution/gethexec/blockchain.go | 1 + execution/gethexec/executionengine.go | 5 ++- execution/gethexec/forwarder.go | 5 ++- execution/gethexec/node.go | 4 +- execution/gethexec/sequencer.go | 11 ++--- execution/gethexec/stylus_tracer.go | 1 + execution/gethexec/sync_monitor.go | 3 +- execution/gethexec/tx_pre_checker.go | 4 +- execution/gethexec/wasmstorerebuilder.go | 1 + execution/interface.go | 1 + execution/nodeInterface/NodeInterface.go | 1 + execution/nodeInterface/NodeInterfaceDebug.go | 1 + execution/nodeInterface/virtual-contracts.go | 1 + gethhook/geth-hook.go | 1 + linters/linters.go | 3 +- precompiles/ArbAddressTable_test.go | 1 + precompiles/ArbAggregator_test.go | 1 + precompiles/ArbGasInfo.go | 1 + precompiles/ArbGasInfo_test.go | 1 + precompiles/ArbInfo.go | 1 + precompiles/ArbOwner.go | 6 +-- precompiles/ArbOwner_test.go | 5 ++- precompiles/ArbRetryableTx.go | 2 +- precompiles/ArbRetryableTx_test.go | 6 +-- precompiles/ArbSys.go | 1 + precompiles/ArbWasm.go | 1 + precompiles/precompile.go | 14 +++---- precompiles/precompile_test.go | 6 +-- precompiles/wrapper.go | 6 +-- pubsub/common.go | 3 +- pubsub/consumer.go | 6 ++- pubsub/producer.go | 8 ++-- pubsub/pubsub_test.go | 6 ++- relay/relay_stress_test.go | 1 + staker/block_challenge_backend.go | 1 + staker/block_validator.go | 4 +- staker/block_validator_schema.go | 1 + staker/challenge_manager.go | 1 + staker/challenge_test.go | 1 + staker/execution_challenge_bakend.go | 1 + staker/l1_validator.go | 10 ++--- staker/rollup_watcher.go | 8 ++-- staker/staker.go | 5 ++- staker/stateless_block_validator.go | 7 ++-- staker/validatorwallet/contract.go | 1 + staker/validatorwallet/eoa.go | 1 + staker/validatorwallet/noop.go | 1 + system_tests/aliasing_test.go | 1 + system_tests/batch_poster_test.go | 1 + system_tests/block_hash_test.go | 1 + system_tests/blocks_reexecutor_test.go | 1 + system_tests/bloom_test.go | 1 + system_tests/common_test.go | 42 +++++++++---------- system_tests/conditionaltx_test.go | 1 + system_tests/contract_tx_test.go | 1 + system_tests/db_conversion_test.go | 1 + system_tests/debugapi_test.go | 1 + system_tests/delayedinbox_test.go | 1 + system_tests/estimation_test.go | 1 + system_tests/forwarder_test.go | 2 + system_tests/infra_fee_test.go | 1 + system_tests/initialization_test.go | 1 + system_tests/log_subscription_test.go | 1 + system_tests/meaningless_reorg_test.go | 1 + system_tests/nodeinterface_test.go | 1 + system_tests/outbox_test.go | 1 + system_tests/precompile_doesnt_revert_test.go | 1 + system_tests/precompile_fuzz_test.go | 1 + system_tests/precompile_test.go | 1 + system_tests/program_gas_test.go | 1 + system_tests/program_norace_test.go | 1 + system_tests/program_recursive_test.go | 1 + system_tests/program_test.go | 1 + system_tests/pruning_test.go | 1 + system_tests/recreatestate_rpc_test.go | 1 + system_tests/retryable_test.go | 2 +- system_tests/seq_nonce_test.go | 1 + system_tests/seq_pause_test.go | 1 + system_tests/seq_reject_test.go | 1 + system_tests/seqcompensation_test.go | 1 + system_tests/seqfeed_test.go | 1 + system_tests/state_fuzz_test.go | 1 + system_tests/staterecovery_test.go | 1 + system_tests/stylus_trace_test.go | 4 +- system_tests/stylus_tracer_test.go | 4 +- system_tests/test_info.go | 6 +-- system_tests/triedb_race_test.go | 1 + system_tests/twonodeslong_test.go | 4 +- system_tests/unsupported_txtypes_test.go | 3 +- system_tests/validation_mock_test.go | 4 +- system_tests/wrap_transaction_test.go | 1 + util/arbmath/bits.go | 3 +- util/arbmath/math_test.go | 1 + util/contracts/address_verifier.go | 1 + util/dbutil/dbutil.go | 3 +- util/headerreader/blob_client.go | 5 ++- util/headerreader/blob_client_test.go | 3 +- util/headerreader/header_reader.go | 4 +- util/jsonapi/preimages_test.go | 1 + util/merkletree/merkleAccumulator_test.go | 1 + util/merkletree/merkleEventProof.go | 1 + util/merkletree/merkleEventProof_test.go | 1 + util/merkletree/merkleTree.go | 1 + util/redisutil/test_redis.go | 1 + util/rpcclient/rpcclient_test.go | 6 ++- util/sharedmetrics/sharedmetrics.go | 1 + util/signature/sign_verify.go | 4 +- util/stopwaiter/stopwaiter.go | 1 + util/stopwaiter/stopwaiter_test.go | 1 + util/testhelpers/testhelpers.go | 1 + validator/client/redis/producer.go | 6 ++- validator/client/validation_client.go | 16 ++++--- validator/execution_state.go | 1 + validator/interface.go | 1 + validator/server_api/json.go | 2 +- validator/server_arb/execution_run.go | 2 +- validator/server_arb/execution_run_test.go | 1 + validator/server_arb/machine.go | 2 + validator/server_arb/machine_loader.go | 1 + validator/server_arb/machine_test.go | 1 + validator/server_arb/mock_machine.go | 1 + validator/server_arb/nitro_machine.go | 2 + validator/server_arb/prover_interface.go | 2 + validator/server_arb/validator_spawner.go | 10 ++--- validator/server_common/machine_loader.go | 1 + validator/server_common/valrun.go | 1 + validator/server_jit/jit_machine.go | 1 + validator/server_jit/machine_loader.go | 1 + validator/server_jit/spawner.go | 3 +- validator/validation_entry.go | 1 + validator/valnode/redis/consumer.go | 4 +- validator/valnode/redis/consumer_test.go | 1 + validator/valnode/valnode.go | 5 ++- wavmio/stub.go | 1 + wsbroadcastserver/clientconnection.go | 9 ++-- wsbroadcastserver/connectionlimiter.go | 3 +- wsbroadcastserver/utils.go | 3 +- wsbroadcastserver/wsbroadcastserver.go | 1 + 269 files changed, 536 insertions(+), 273 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 0594670137..8e597f950a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,7 @@ linters: enable: - asciicheck # check for non-ascii characters - errorlint # enure error wrapping is safely done + - gci # keep imports sorted deterministically - gocritic # check for certain simplifications - gofmt # ensure code is formatted - gosec # check for security concerns @@ -30,6 +31,13 @@ linters-settings: # check-type-assertions: true + gci: + sections: + - standard + - default + - prefix(github.com/ethereum/go-ethereum) + - prefix(github.com/offchainlabs) + gocritic: disabled-tags: - experimental diff --git a/arbcompress/native.go b/arbcompress/native.go index f7b8f0b8e0..943d21e89e 100644 --- a/arbcompress/native.go +++ b/arbcompress/native.go @@ -12,6 +12,7 @@ package arbcompress #include "arbitrator.h" */ import "C" + import ( "errors" "fmt" diff --git a/arbnode/api.go b/arbnode/api.go index 2dabd41bff..55dc92434f 100644 --- a/arbnode/api.go +++ b/arbnode/api.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/validator" diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 0949d929e1..65d8f579fa 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -20,6 +20,10 @@ import ( "time" "github.com/Knetic/govaluate" + "github.com/holiman/uint256" + "github.com/redis/go-redis/v9" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -35,9 +39,10 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/signer/core/apitypes" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbnode/dataposter/dbstorage" "github.com/offchainlabs/nitro/arbnode/dataposter/noop" + redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis" "github.com/offchainlabs/nitro/arbnode/dataposter/slice" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/arbmath" @@ -46,10 +51,6 @@ import ( "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/stopwaiter" - "github.com/redis/go-redis/v9" - "github.com/spf13/pflag" - - redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis" ) var ( diff --git a/arbnode/dataposter/dataposter_test.go b/arbnode/dataposter/dataposter_test.go index 7bf0f86e6f..dc5df1a6c4 100644 --- a/arbnode/dataposter/dataposter_test.go +++ b/arbnode/dataposter/dataposter_test.go @@ -9,6 +9,9 @@ import ( "time" "github.com/Knetic/govaluate" + "github.com/google/go-cmp/cmp" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -17,8 +20,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" - "github.com/google/go-cmp/cmp" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbnode/dataposter/dbstorage/storage.go b/arbnode/dataposter/dbstorage/storage.go index 6a6cd3cfa4..88989cf757 100644 --- a/arbnode/dataposter/dbstorage/storage.go +++ b/arbnode/dataposter/dbstorage/storage.go @@ -11,6 +11,7 @@ import ( "strconv" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/dbutil" ) diff --git a/arbnode/dataposter/externalsignertest/externalsignertest.go b/arbnode/dataposter/externalsignertest/externalsignertest.go index 554defc764..51ccec1903 100644 --- a/arbnode/dataposter/externalsignertest/externalsignertest.go +++ b/arbnode/dataposter/externalsignertest/externalsignertest.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/signer/core/apitypes" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/arbnode/dataposter/redis/redisstorage.go b/arbnode/dataposter/redis/redisstorage.go index b54abf618b..364f9fc85c 100644 --- a/arbnode/dataposter/redis/redisstorage.go +++ b/arbnode/dataposter/redis/redisstorage.go @@ -9,9 +9,10 @@ import ( "errors" "fmt" + "github.com/redis/go-redis/v9" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/signature" - "github.com/redis/go-redis/v9" ) // Storage implements redis sorted set backed storage. It does not support diff --git a/arbnode/dataposter/storage/storage.go b/arbnode/dataposter/storage/storage.go index 8e5a7e1798..dfd4c2745c 100644 --- a/arbnode/dataposter/storage/storage.go +++ b/arbnode/dataposter/storage/storage.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbnode/dataposter/storage_test.go b/arbnode/dataposter/storage_test.go index c6316caea7..cd4e4babae 100644 --- a/arbnode/dataposter/storage_test.go +++ b/arbnode/dataposter/storage_test.go @@ -9,12 +9,14 @@ import ( "path" "testing" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" + "github.com/offchainlabs/nitro/arbnode/dataposter/dbstorage" "github.com/offchainlabs/nitro/arbnode/dataposter/redis" "github.com/offchainlabs/nitro/arbnode/dataposter/slice" diff --git a/arbnode/delayed_seq_reorg_test.go b/arbnode/delayed_seq_reorg_test.go index 699eb3e8f6..f821d71e63 100644 --- a/arbnode/delayed_seq_reorg_test.go +++ b/arbnode/delayed_seq_reorg_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/arbnode/delayed_sequencer.go b/arbnode/delayed_sequencer.go index b29a66dd05..abd24dbd12 100644 --- a/arbnode/delayed_sequencer.go +++ b/arbnode/delayed_sequencer.go @@ -10,10 +10,11 @@ import ( "math/big" "sync" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/execution" diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 14ca83ab13..50893ca392 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -13,10 +13,11 @@ import ( "sync/atomic" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index e588ef399b..32023877b7 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -11,23 +11,22 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/env" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos" ) type execClientWrapper struct { diff --git a/arbnode/inbox_tracker_test.go b/arbnode/inbox_tracker_test.go index 582b334aee..82d380b03c 100644 --- a/arbnode/inbox_tracker_test.go +++ b/arbnode/inbox_tracker_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/arbnode/maintenance.go b/arbnode/maintenance.go index 7397229c2e..5e4e56b577 100644 --- a/arbnode/maintenance.go +++ b/arbnode/maintenance.go @@ -10,12 +10,14 @@ import ( "strings" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode/redislock" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // Regularly runs db compaction if configured diff --git a/arbnode/message_pruner.go b/arbnode/message_pruner.go index b249bd886c..840a15f328 100644 --- a/arbnode/message_pruner.go +++ b/arbnode/message_pruner.go @@ -11,14 +11,14 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" - - flag "github.com/spf13/pflag" ) type MessagePruner struct { diff --git a/arbnode/message_pruner_test.go b/arbnode/message_pruner_test.go index e64bb4f838..8e6b744430 100644 --- a/arbnode/message_pruner_test.go +++ b/arbnode/message_pruner_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbnode/node.go b/arbnode/node.go index c5b3bbe071..77562817dd 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbnode/resourcemanager" diff --git a/arbnode/redislock/redis.go b/arbnode/redislock/redis.go index de9508323a..075ff60c09 100644 --- a/arbnode/redislock/redis.go +++ b/arbnode/redislock/redis.go @@ -11,10 +11,12 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/log" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" flag "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/stopwaiter" ) type Simple struct { diff --git a/arbnode/resourcemanager/resource_management.go b/arbnode/resourcemanager/resource_management.go index 249b689443..462b38c578 100644 --- a/arbnode/resourcemanager/resource_management.go +++ b/arbnode/resourcemanager/resource_management.go @@ -14,10 +14,11 @@ import ( "strings" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/node" - "github.com/spf13/pflag" ) var ( diff --git a/arbnode/sequencer_inbox.go b/arbnode/sequencer_inbox.go index 81146ed46e..4643ae6d84 100644 --- a/arbnode/sequencer_inbox.go +++ b/arbnode/sequencer_inbox.go @@ -16,9 +16,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/arbnode/sync_monitor.go b/arbnode/sync_monitor.go index 5ab1ede2d6..629068c4fb 100644 --- a/arbnode/sync_monitor.go +++ b/arbnode/sync_monitor.go @@ -5,10 +5,12 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type SyncMonitor struct { diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 38b1c003db..1a961ebd3f 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -8,6 +8,7 @@ import ( "context" "encoding/binary" "encoding/json" + "errors" "fmt" "math/big" "reflect" @@ -17,8 +18,6 @@ import ( "testing" "time" - "errors" - flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" diff --git a/arbos/activate_test.go b/arbos/activate_test.go index a89a38639a..b723c37aa6 100644 --- a/arbos/activate_test.go +++ b/arbos/activate_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/addressSet/addressSet.go b/arbos/addressSet/addressSet.go index 156f36e7e7..4bb87e614d 100644 --- a/arbos/addressSet/addressSet.go +++ b/arbos/addressSet/addressSet.go @@ -9,6 +9,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/addressSet/addressSet_test.go b/arbos/addressSet/addressSet_test.go index d32e07a546..4997359dcf 100644 --- a/arbos/addressSet/addressSet_test.go +++ b/arbos/addressSet/addressSet_test.go @@ -8,13 +8,14 @@ import ( "math/rand" "testing" - "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/params" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/arbos/addressTable/addressTable.go b/arbos/addressTable/addressTable.go index 6ae271060d..608883c34d 100644 --- a/arbos/addressTable/addressTable.go +++ b/arbos/addressTable/addressTable.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/addressTable/addressTable_test.go b/arbos/addressTable/addressTable_test.go index 6b06ed3406..873d5a4d1c 100644 --- a/arbos/addressTable/addressTable_test.go +++ b/arbos/addressTable/addressTable_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/arbos/arbosState/arbosstate_test.go b/arbos/arbosState/arbosstate_test.go index ef63c23386..440598991c 100644 --- a/arbos/arbosState/arbosstate_test.go +++ b/arbos/arbosState/arbosstate_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 697a41e4fd..5154606e3d 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 7ea2938c74..29cb75b758 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -5,21 +5,23 @@ package arbosState import ( "errors" - "github.com/ethereum/go-ethereum/core/tracing" "math/big" "regexp" "sort" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/l2pricing" diff --git a/arbos/arbostypes/messagewithmeta.go b/arbos/arbostypes/messagewithmeta.go index 79b7c4f9d2..a3bc167526 100644 --- a/arbos/arbostypes/messagewithmeta.go +++ b/arbos/arbostypes/messagewithmeta.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbos/block_processor.go b/arbos/block_processor.go index 19fc36b351..e654531880 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -10,12 +10,6 @@ import ( "math" "math/big" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/arbostypes" - "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/ethereum/go-ethereum/arbitrum_types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -25,6 +19,12 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) // set by the precompile module, to avoid a package dependence cycle diff --git a/arbos/blockhash/blockhash.go b/arbos/blockhash/blockhash.go index 34c907207c..ff29bbca9a 100644 --- a/arbos/blockhash/blockhash.go +++ b/arbos/blockhash/blockhash.go @@ -8,6 +8,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/blockhash/blockhash_test.go b/arbos/blockhash/blockhash_test.go index bf3ee5ee11..c7cc04d966 100644 --- a/arbos/blockhash/blockhash_test.go +++ b/arbos/blockhash/blockhash_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/arbos/burn/burn.go b/arbos/burn/burn.go index 7d30ad12ec..c94f6bec2f 100644 --- a/arbos/burn/burn.go +++ b/arbos/burn/burn.go @@ -7,6 +7,7 @@ import ( "fmt" glog "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/extra_transaction_checks.go b/arbos/extra_transaction_checks.go index 0f970c9925..480058cb0f 100644 --- a/arbos/extra_transaction_checks.go +++ b/arbos/extra_transaction_checks.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" ) diff --git a/arbos/incomingmessage_test.go b/arbos/incomingmessage_test.go index 2933f6a719..22aba05bce 100644 --- a/arbos/incomingmessage_test.go +++ b/arbos/incomingmessage_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" ) diff --git a/arbos/internal_tx.go b/arbos/internal_tx.go index 9832ac8005..64dede6290 100644 --- a/arbos/internal_tx.go +++ b/arbos/internal_tx.go @@ -8,15 +8,14 @@ import ( "fmt" "math/big" - "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) func InternalTxStartBlock( diff --git a/arbos/l1pricing/batchPoster.go b/arbos/l1pricing/batchPoster.go index a3428c441c..5975e95d0f 100644 --- a/arbos/l1pricing/batchPoster.go +++ b/arbos/l1pricing/batchPoster.go @@ -9,6 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/addressSet" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/l1pricing/batchPoster_test.go b/arbos/l1pricing/batchPoster_test.go index 4e9b8565c0..3263ffca81 100644 --- a/arbos/l1pricing/batchPoster_test.go +++ b/arbos/l1pricing/batchPoster_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/l1pricing/l1PricingOldVersions.go b/arbos/l1pricing/l1PricingOldVersions.go index 821d743e7d..1377351af3 100644 --- a/arbos/l1pricing/l1PricingOldVersions.go +++ b/arbos/l1pricing/l1PricingOldVersions.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/util" am "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/l1pricing/l1pricing.go b/arbos/l1pricing/l1pricing.go index 392bf36d37..34ab6ed523 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -10,20 +10,18 @@ import ( "math/big" "sync/atomic" - "github.com/ethereum/go-ethereum/crypto" - + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbcompress" - "github.com/offchainlabs/nitro/util/arbmath" - am "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/types" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" + am "github.com/offchainlabs/nitro/util/arbmath" ) type L1PricingState struct { diff --git a/arbos/l1pricing/l1pricing_test.go b/arbos/l1pricing/l1pricing_test.go index b301c94257..b842c26db7 100644 --- a/arbos/l1pricing/l1pricing_test.go +++ b/arbos/l1pricing/l1pricing_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/l1pricing_test.go b/arbos/l1pricing_test.go index 6de69db1de..da5f577c5b 100644 --- a/arbos/l1pricing_test.go +++ b/arbos/l1pricing_test.go @@ -4,22 +4,23 @@ package arbos import ( - "github.com/ethereum/go-ethereum/core/tracing" "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" - "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos/burn" ) type l1PricingTest struct { diff --git a/arbos/l2pricing/model.go b/arbos/l2pricing/model.go index 476effa8aa..367e8b6e1a 100644 --- a/arbos/l2pricing/model.go +++ b/arbos/l2pricing/model.go @@ -7,6 +7,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/merkleAccumulator/merkleAccumulator.go b/arbos/merkleAccumulator/merkleAccumulator.go index e62303e5fd..0d51602c02 100644 --- a/arbos/merkleAccumulator/merkleAccumulator.go +++ b/arbos/merkleAccumulator/merkleAccumulator.go @@ -6,6 +6,7 @@ package merkleAccumulator import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/parse_l2.go b/arbos/parse_l2.go index 06722e4063..cd926f47bf 100644 --- a/arbos/parse_l2.go +++ b/arbos/parse_l2.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 5ec8c97207..d8f12ffbd3 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -4,12 +4,14 @@ package programs import ( + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" am "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/programs/native.go b/arbos/programs/native.go index 725b302ac0..f162704995 100644 --- a/arbos/programs/native.go +++ b/arbos/programs/native.go @@ -18,6 +18,7 @@ typedef uint64_t u64; typedef size_t usize; */ import "C" + import ( "errors" "fmt" @@ -30,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" diff --git a/arbos/programs/native_api.go b/arbos/programs/native_api.go index 6cecb8ef63..ab15800ef9 100644 --- a/arbos/programs/native_api.go +++ b/arbos/programs/native_api.go @@ -22,6 +22,7 @@ void handleReqWrap(usize api, u32 req_type, RustSlice *data, u64 *out_cost, GoSl } */ import "C" + import ( "runtime" "sync" @@ -29,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbos/programs/params.go b/arbos/programs/params.go index a0b8acd95c..9b219737d9 100644 --- a/arbos/programs/params.go +++ b/arbos/programs/params.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" am "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/programs/programs.go b/arbos/programs/programs.go index 06ff4137da..06ba6ead8c 100644 --- a/arbos/programs/programs.go +++ b/arbos/programs/programs.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" gethParams "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/addressSet" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/arbos/programs/testcompile.go b/arbos/programs/testcompile.go index 615b0f3f72..8a4e38444a 100644 --- a/arbos/programs/testcompile.go +++ b/arbos/programs/testcompile.go @@ -20,6 +20,7 @@ typedef size_t usize; void handleReqWrap(usize api, u32 req_type, RustSlice *data, u64 *out_cost, GoSliceData *out_result, GoSliceData *out_raw_data); */ import "C" + import ( "fmt" "os" diff --git a/arbos/queue_test.go b/arbos/queue_test.go index ff993a233f..75d60b82c3 100644 --- a/arbos/queue_test.go +++ b/arbos/queue_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/retryable_test.go b/arbos/retryable_test.go index 2eccaea6c2..b2989de331 100644 --- a/arbos/retryable_test.go +++ b/arbos/retryable_test.go @@ -9,17 +9,17 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/params" ) func TestOpenNonexistentRetryable(t *testing.T) { diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index 5938244782..23ba2458ff 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/storage/queue.go b/arbos/storage/queue.go index 9c02dc1ee7..3c852a5743 100644 --- a/arbos/storage/queue.go +++ b/arbos/storage/queue.go @@ -4,9 +4,9 @@ package storage import ( - "github.com/offchainlabs/nitro/arbos/util" - "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/arbos/util" ) type Queue struct { diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index bc16491af0..63db8ee928 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" "github.com/ethereum/go-ethereum/triedb/pathdb" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/storage/storage_test.go b/arbos/storage/storage_test.go index b2e8bdb2ea..dd2c40b8f0 100644 --- a/arbos/storage/storage_test.go +++ b/arbos/storage/storage_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index e05368dea7..aec08b15b5 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -9,22 +9,20 @@ import ( "math/big" "github.com/holiman/uint256" - "github.com/offchainlabs/nitro/arbos/l1pricing" - - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/util/arbmath" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + glog "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/arbosState" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/vm" - glog "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/l1pricing" + "github.com/offchainlabs/nitro/arbos/retryables" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) var arbosAddress = types.ArbosAddress diff --git a/arbos/util/retryable_encoding_test.go b/arbos/util/retryable_encoding_test.go index d7a5480138..b74983ed0b 100644 --- a/arbos/util/retryable_encoding_test.go +++ b/arbos/util/retryable_encoding_test.go @@ -10,16 +10,15 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" ) func TestRetryableEncoding(t *testing.T) { diff --git a/arbos/util/storage_cache.go b/arbos/util/storage_cache.go index 9573d1ffc7..a9be5fe870 100644 --- a/arbos/util/storage_cache.go +++ b/arbos/util/storage_cache.go @@ -4,8 +4,9 @@ package util import ( - "github.com/ethereum/go-ethereum/common" "slices" + + "github.com/ethereum/go-ethereum/common" ) type storageCacheEntry struct { diff --git a/arbos/util/storage_cache_test.go b/arbos/util/storage_cache_test.go index 9fd452851d..0ba2c5285e 100644 --- a/arbos/util/storage_cache_test.go +++ b/arbos/util/storage_cache_test.go @@ -7,8 +7,10 @@ import ( "slices" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/google/go-cmp/cmp" + + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index fb39460d44..f092d32c2d 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -7,11 +7,12 @@ import ( "encoding/binary" "math/big" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" - "github.com/holiman/uint256" ) type TracingScenario uint64 diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index ed5e07c8cf..37437e01f6 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -9,11 +9,13 @@ import ( "fmt" "math/big" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/util/util.go b/arbos/util/util.go index 69d90171a0..abb7135757 100644 --- a/arbos/util/util.go +++ b/arbos/util/util.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbstate/daprovider/reader.go b/arbstate/daprovider/reader.go index 488b156454..e2fd884340 100644 --- a/arbstate/daprovider/reader.go +++ b/arbstate/daprovider/reader.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/blobs" ) diff --git a/arbstate/inbox_fuzz_test.go b/arbstate/inbox_fuzz_test.go index 5ede321810..5a77b7e298 100644 --- a/arbstate/inbox_fuzz_test.go +++ b/arbstate/inbox_fuzz_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/arbutil/hash_test.go b/arbutil/hash_test.go index 2b93353d08..4b39bf328e 100644 --- a/arbutil/hash_test.go +++ b/arbutil/hash_test.go @@ -4,8 +4,9 @@ import ( "bytes" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/google/go-cmp/cmp" + + "github.com/ethereum/go-ethereum/common" ) func TestSlotAddress(t *testing.T) { diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index 5a883e5d42..d074457626 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -9,6 +9,8 @@ import ( "strings" "sync" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -19,9 +21,9 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type Config struct { diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index 4e97ca8cd0..ac684902e4 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" m "github.com/offchainlabs/nitro/broadcaster/message" "github.com/offchainlabs/nitro/util/contracts" diff --git a/broadcaster/backlog/backlog.go b/broadcaster/backlog/backlog.go index b7b935fb7a..685789a33d 100644 --- a/broadcaster/backlog/backlog.go +++ b/broadcaster/backlog/backlog.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + m "github.com/offchainlabs/nitro/broadcaster/message" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/containers" diff --git a/broadcaster/message/message.go b/broadcaster/message/message.go index 1e26e6da5e..f2439912f8 100644 --- a/broadcaster/message/message.go +++ b/broadcaster/message/message.go @@ -2,6 +2,7 @@ package message import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/broadcaster/message/message_serialization_test.go b/broadcaster/message/message_serialization_test.go index 1d8c10e388..5fb9d55dda 100644 --- a/broadcaster/message/message_serialization_test.go +++ b/broadcaster/message/message_serialization_test.go @@ -10,6 +10,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" ) diff --git a/cmd/conf/chain.go b/cmd/conf/chain.go index 28b06aad2b..435246e357 100644 --- a/cmd/conf/chain.go +++ b/cmd/conf/chain.go @@ -6,10 +6,11 @@ package conf import ( "time" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/rpcclient" - flag "github.com/spf13/pflag" ) type ParentChainConfig struct { diff --git a/cmd/conf/database.go b/cmd/conf/database.go index af18bacd57..8857b615f3 100644 --- a/cmd/conf/database.go +++ b/cmd/conf/database.go @@ -12,8 +12,9 @@ import ( "runtime" "time" - "github.com/ethereum/go-ethereum/ethdb/pebble" flag "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/ethdb/pebble" ) type PersistentConfig struct { diff --git a/cmd/conf/init.go b/cmd/conf/init.go index 8e4e9a8892..cd2b6c8805 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -6,8 +6,9 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/log" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" ) type InitConfig struct { diff --git a/cmd/dataavailability/data_availability_check.go b/cmd/dataavailability/data_availability_check.go index d80c0475bf..e961215925 100644 --- a/cmd/dataavailability/data_availability_check.go +++ b/cmd/dataavailability/data_availability_check.go @@ -13,6 +13,8 @@ import ( "syscall" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -27,8 +29,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/metricsutil" "github.com/offchainlabs/nitro/util/stopwaiter" - - flag "github.com/spf13/pflag" ) // Data availability check is done to as to make sure that the data that is being stored by DAS is available at all time. diff --git a/cmd/datool/datool.go b/cmd/datool/datool.go index f791d8cbc4..06f94dc952 100644 --- a/cmd/datool/datool.go +++ b/cmd/datool/datool.go @@ -22,10 +22,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util" - "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" "github.com/offchainlabs/nitro/das/dastree" diff --git a/cmd/dbconv/dbconv/config.go b/cmd/dbconv/dbconv/config.go index 917f34261d..fdebda2d54 100644 --- a/cmd/dbconv/dbconv/config.go +++ b/cmd/dbconv/dbconv/config.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/genericconf" - flag "github.com/spf13/pflag" ) type DBConfig struct { diff --git a/cmd/dbconv/dbconv/dbconv.go b/cmd/dbconv/dbconv/dbconv.go index 6a97df31c0..fdba1907c2 100644 --- a/cmd/dbconv/dbconv/dbconv.go +++ b/cmd/dbconv/dbconv/dbconv.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/dbutil" ) diff --git a/cmd/dbconv/main.go b/cmd/dbconv/main.go index 2d61c96552..f5aaced40b 100644 --- a/cmd/dbconv/main.go +++ b/cmd/dbconv/main.go @@ -6,13 +6,15 @@ import ( "os" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/exp" + "github.com/offchainlabs/nitro/cmd/dbconv/dbconv" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" - flag "github.com/spf13/pflag" ) func parseDBConv(args []string) (*dbconv.DBConvConfig, error) { diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index c70ceb1d94..a597799b06 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go @@ -14,20 +14,20 @@ import ( "strings" "time" - "github.com/offchainlabs/nitro/cmd/chaininfo" - "github.com/offchainlabs/nitro/cmd/genericconf" - "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/cmd/chaininfo" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util" deploycode "github.com/offchainlabs/nitro/deploy" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/validator/server_common" ) func main() { diff --git a/cmd/genericconf/config.go b/cmd/genericconf/config.go index 7c0c5034b3..408ba9a552 100644 --- a/cmd/genericconf/config.go +++ b/cmd/genericconf/config.go @@ -9,9 +9,10 @@ import ( "log/slog" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" - flag "github.com/spf13/pflag" ) type ConfConfig struct { diff --git a/cmd/genericconf/filehandler_test.go b/cmd/genericconf/filehandler_test.go index daa9ed397c..291ea76442 100644 --- a/cmd/genericconf/filehandler_test.go +++ b/cmd/genericconf/filehandler_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/cmd/genericconf/liveconfig.go b/cmd/genericconf/liveconfig.go index 1054140e9e..f256fe6612 100644 --- a/cmd/genericconf/liveconfig.go +++ b/cmd/genericconf/liveconfig.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/cmd/genericconf/logging.go b/cmd/genericconf/logging.go index fa45953278..4cdaa5f3e8 100644 --- a/cmd/genericconf/logging.go +++ b/cmd/genericconf/logging.go @@ -8,8 +8,9 @@ import ( "os" "sync" - "github.com/ethereum/go-ethereum/log" "gopkg.in/natefinch/lumberjack.v2" + + "github.com/ethereum/go-ethereum/log" ) var globalFileLoggerFactory = fileLoggerFactory{} diff --git a/cmd/genericconf/pprof.go b/cmd/genericconf/pprof.go index 9fd3a6f2a4..0bde03decd 100644 --- a/cmd/genericconf/pprof.go +++ b/cmd/genericconf/pprof.go @@ -3,7 +3,6 @@ package genericconf import ( "fmt" "net/http" - // Blank import pprof registers its HTTP handlers. _ "net/http/pprof" // #nosec G108 diff --git a/cmd/nitro-val/config.go b/cmd/nitro-val/config.go index 2adbe5e9aa..bca83277b3 100644 --- a/cmd/nitro-val/config.go +++ b/cmd/nitro-val/config.go @@ -2,19 +2,20 @@ package main import ( "fmt" - "reflect" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/validator/valnode" - flag "github.com/spf13/pflag" ) type ValidationNodeConfig struct { diff --git a/cmd/nitro/config_test.go b/cmd/nitro/config_test.go index 9626893083..ef41d704f1 100644 --- a/cmd/nitro/config_test.go +++ b/cmd/nitro/config_test.go @@ -14,14 +14,14 @@ import ( "testing" "time" + "github.com/r3labs/diff/v3" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/r3labs/diff/v3" - flag "github.com/spf13/pflag" ) func TestEmptyCliConfig(t *testing.T) { diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index d4794f9fee..eb6d7df6fc 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -25,6 +25,7 @@ import ( "github.com/cavaliergopher/grab/v3" "github.com/codeclysm/extract/v3" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" diff --git a/cmd/nitro/init_test.go b/cmd/nitro/init_test.go index 48d969f053..8e7afe369d 100644 --- a/cmd/nitro/init_test.go +++ b/cmd/nitro/init_test.go @@ -23,11 +23,13 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" - "github.com/google/go-cmp/cmp" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/cmd/conf" diff --git a/cmd/pruning/pruning.go b/cmd/pruning/pruning.go index 0755f5ff9e..e89c79bc89 100644 --- a/cmd/pruning/pruning.go +++ b/cmd/pruning/pruning.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbutil" diff --git a/cmd/replay/db.go b/cmd/replay/db.go index 7147c48f75..3dc9f15da0 100644 --- a/cmd/replay/db.go +++ b/cmd/replay/db.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/wavmio" ) diff --git a/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go b/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go index b897b23252..b6b5342ca2 100644 --- a/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go +++ b/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go @@ -5,8 +5,9 @@ import ( "errors" "strings" - "github.com/offchainlabs/nitro/util/redisutil" "github.com/redis/go-redis/v9" + + "github.com/offchainlabs/nitro/util/redisutil" ) // RedisCoordinator builds upon RedisCoordinator of redisutil with additional functionality diff --git a/cmd/seq-coordinator-manager/seq-coordinator-manager.go b/cmd/seq-coordinator-manager/seq-coordinator-manager.go index 43d90441ef..7b5dc68699 100644 --- a/cmd/seq-coordinator-manager/seq-coordinator-manager.go +++ b/cmd/seq-coordinator-manager/seq-coordinator-manager.go @@ -7,11 +7,13 @@ import ( "strconv" "github.com/enescakir/emoji" - "github.com/ethereum/go-ethereum/log" "github.com/gdamore/tcell/v2" + "github.com/rivo/tview" + + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/cmd/seq-coordinator-manager/rediscoordinator" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/rivo/tview" ) // Tview diff --git a/das/aggregator_test.go b/das/aggregator_test.go index 4bc209513e..217315eef0 100644 --- a/das/aggregator_test.go +++ b/das/aggregator_test.go @@ -16,10 +16,10 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" - - "github.com/ethereum/go-ethereum/log" ) func TestDAS_BasicAggregationLocal(t *testing.T) { diff --git a/das/cache_storage_service.go b/das/cache_storage_service.go index 439ccda086..0ba20ac55b 100644 --- a/das/cache_storage_service.go +++ b/das/cache_storage_service.go @@ -7,14 +7,15 @@ import ( "context" "fmt" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/das/dastree" - "github.com/offchainlabs/nitro/util/pretty" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/das/dastree" + "github.com/offchainlabs/nitro/util/pretty" ) type CacheConfig struct { diff --git a/das/chain_fetch_das.go b/das/chain_fetch_das.go index 4de6c981cf..34b10d45ec 100644 --- a/das/chain_fetch_das.go +++ b/das/chain_fetch_das.go @@ -8,14 +8,14 @@ import ( "errors" "sync" - "github.com/offchainlabs/nitro/util/pretty" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/solgen/go/bridgegen" + "github.com/offchainlabs/nitro/util/pretty" ) type syncedKeysetCache struct { diff --git a/das/das.go b/das/das.go index 0b03c05ad6..e870761ac2 100644 --- a/das/das.go +++ b/das/das.go @@ -10,10 +10,11 @@ import ( "math" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/dasRpcClient.go b/das/dasRpcClient.go index d6e2c389c9..3ea6c4e2c6 100644 --- a/das/dasRpcClient.go +++ b/das/dasRpcClient.go @@ -9,13 +9,14 @@ import ( "strings" "time" + "golang.org/x/sync/errgroup" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "golang.org/x/sync/errgroup" - "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/dasRpcServer.go b/das/dasRpcServer.go index bb1be0384e..adddf26571 100644 --- a/das/dasRpcServer.go +++ b/das/dasRpcServer.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/blsSignatures" diff --git a/das/dastree/dastree.go b/das/dastree/dastree.go index 2bcbccaae3..29a6b2495c 100644 --- a/das/dastree/dastree.go +++ b/das/dastree/dastree.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/das/dastree/dastree_test.go b/das/dastree/dastree_test.go index 4d24c9ae98..b24d6ce69b 100644 --- a/das/dastree/dastree_test.go +++ b/das/dastree/dastree_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/db_storage_service.go b/das/db_storage_service.go index 74bf12b927..0e38505a13 100644 --- a/das/db_storage_service.go +++ b/das/db_storage_service.go @@ -14,13 +14,15 @@ import ( "time" badger "github.com/dgraph-io/badger/v4" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type LocalDBStorageConfig struct { diff --git a/das/fallback_storage_service.go b/das/fallback_storage_service.go index 0a451678d0..64bc3c2a7a 100644 --- a/das/fallback_storage_service.go +++ b/das/fallback_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/das/fallback_storage_service_test.go b/das/fallback_storage_service_test.go index b73df31624..4c7c0351e9 100644 --- a/das/fallback_storage_service_test.go +++ b/das/fallback_storage_service_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/math" + "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/google_cloud_storage_service_test.go b/das/google_cloud_storage_service_test.go index 799d999bad..94d6f3ee44 100644 --- a/das/google_cloud_storage_service_test.go +++ b/das/google_cloud_storage_service_test.go @@ -2,13 +2,16 @@ package das import ( "bytes" - googlestorage "cloud.google.com/go/storage" "context" "errors" - "github.com/ethereum/go-ethereum/common" - "github.com/offchainlabs/nitro/das/dastree" "testing" "time" + + googlestorage "cloud.google.com/go/storage" + + "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/das/dastree" ) type mockGCSClient struct { diff --git a/das/key_utils.go b/das/key_utils.go index 33f29788b6..0262e7f666 100644 --- a/das/key_utils.go +++ b/das/key_utils.go @@ -11,6 +11,7 @@ import ( "os" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/blsSignatures" ) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 5e64c34b10..71c98c7879 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -20,14 +20,16 @@ import ( "syscall" "time" + flag "github.com/spf13/pflag" + "golang.org/x/sys/unix" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" - "golang.org/x/sys/unix" ) type LocalFileStorageConfig struct { diff --git a/das/memory_backed_storage_service.go b/das/memory_backed_storage_service.go index c013b501b9..8a2df28902 100644 --- a/das/memory_backed_storage_service.go +++ b/das/memory_backed_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/panic_wrapper.go b/das/panic_wrapper.go index 3530cb651d..4729792c33 100644 --- a/das/panic_wrapper.go +++ b/das/panic_wrapper.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/reader_aggregator_strategies_test.go b/das/reader_aggregator_strategies_test.go index cdb85b25e9..3e7e40fd5d 100644 --- a/das/reader_aggregator_strategies_test.go +++ b/das/reader_aggregator_strategies_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/redis_storage_service.go b/das/redis_storage_service.go index e57240992c..cdd18ea974 100644 --- a/das/redis_storage_service.go +++ b/das/redis_storage_service.go @@ -10,17 +10,17 @@ import ( "fmt" "time" + "github.com/redis/go-redis/v9" + flag "github.com/spf13/pflag" "golang.org/x/crypto/sha3" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/redis/go-redis/v9" - flag "github.com/spf13/pflag" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/log" ) type RedisConfig struct { diff --git a/das/redis_storage_service_test.go b/das/redis_storage_service_test.go index 77d3e8cd0f..41ca6bac90 100644 --- a/das/redis_storage_service_test.go +++ b/das/redis_storage_service_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/alicebob/miniredis/v2" + "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/redundant_storage_service.go b/das/redundant_storage_service.go index 3158d28076..85274188d6 100644 --- a/das/redundant_storage_service.go +++ b/das/redundant_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/util/pretty" ) diff --git a/das/restful_client.go b/das/restful_client.go index b65426e7cd..3004ea1b59 100644 --- a/das/restful_client.go +++ b/das/restful_client.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/restful_server.go b/das/restful_server.go index b1607729e2..6c5e2ec453 100644 --- a/das/restful_server.go +++ b/das/restful_server.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/rpc_aggregator.go b/das/rpc_aggregator.go index 9cf481e015..916637aac6 100644 --- a/das/rpc_aggregator.go +++ b/das/rpc_aggregator.go @@ -14,14 +14,15 @@ import ( "github.com/knadh/koanf" "github.com/knadh/koanf/providers/confmap" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/metricsutil" "github.com/offchainlabs/nitro/util/signature" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" ) type BackendConfig struct { diff --git a/das/rpc_test.go b/das/rpc_test.go index 370ec0a872..ebc4b736d5 100644 --- a/das/rpc_test.go +++ b/das/rpc_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/signature" diff --git a/das/s3_storage_service.go b/das/s3_storage_service.go index d251f12214..4c0dcaf5a3 100644 --- a/das/s3_storage_service.go +++ b/das/s3_storage_service.go @@ -16,14 +16,14 @@ import ( "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/das/dastree" - "github.com/offchainlabs/nitro/util/pretty" + flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/das/dastree" + "github.com/offchainlabs/nitro/util/pretty" ) type S3Uploader interface { diff --git a/das/signature_verifier.go b/das/signature_verifier.go index 0aa42bceb6..453b2fe305 100644 --- a/das/signature_verifier.go +++ b/das/signature_verifier.go @@ -11,6 +11,7 @@ import ( "os" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/contracts" ) diff --git a/das/simple_das_reader_aggregator.go b/das/simple_das_reader_aggregator.go index f45c56afe0..ff28d6a22a 100644 --- a/das/simple_das_reader_aggregator.go +++ b/das/simple_das_reader_aggregator.go @@ -12,13 +12,15 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // Most of the time we will use the SimpleDASReaderAggregator only to aggregate diff --git a/das/storage_service.go b/das/storage_service.go index b7526077e9..925bbb520a 100644 --- a/das/storage_service.go +++ b/das/storage_service.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/syncing_fallback_storage.go b/das/syncing_fallback_storage.go index 0670a29c73..1aec2b7328 100644 --- a/das/syncing_fallback_storage.go +++ b/das/syncing_fallback_storage.go @@ -12,6 +12,8 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -19,13 +21,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) var sequencerInboxABI *abi.ABI diff --git a/das/util.go b/das/util.go index 114e075e79..cd300175bb 100644 --- a/das/util.go +++ b/das/util.go @@ -7,6 +7,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/util/pretty" ) diff --git a/deploy/deploy.go b/deploy/deploy.go index bb4b2e6594..2738373c72 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/challengegen" diff --git a/execution/gethexec/api.go b/execution/gethexec/api.go index 4fa60693d5..713d1496f9 100644 --- a/execution/gethexec/api.go +++ b/execution/gethexec/api.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index 6f30e16e5c..2e3d51fec9 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -6,18 +6,20 @@ import ( "sync" "testing" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" - flag "github.com/spf13/pflag" ) // BlockRecorder uses a separate statedatabase from the blockchain. diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index fda8f49093..53b494a3c2 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index 6571672b71..cae2c5fb0c 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -12,6 +12,7 @@ package gethexec #include "arbitrator.h" */ import "C" + import ( "bytes" "context" @@ -26,6 +27,8 @@ import ( "testing" "time" + "github.com/google/uuid" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" @@ -33,7 +36,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" - "github.com/google/uuid" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/execution/gethexec/forwarder.go b/execution/gethexec/forwarder.go index cdb4f394e5..8e64508e6c 100644 --- a/execution/gethexec/forwarder.go +++ b/execution/gethexec/forwarder.go @@ -14,8 +14,6 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/util/redisutil" - "github.com/offchainlabs/nitro/util/stopwaiter" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/arbitrum" @@ -24,6 +22,9 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/util/redisutil" + "github.com/offchainlabs/nitro/util/stopwaiter" ) type ForwarderConfig struct { diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 499a13164e..11d173a21e 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -9,6 +9,8 @@ import ( "sync/atomic" "testing" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -21,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbutil" @@ -28,7 +31,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/dbutil" "github.com/offchainlabs/nitro/util/headerreader" - flag "github.com/spf13/pflag" ) type StylusTargetConfig struct { diff --git a/execution/gethexec/sequencer.go b/execution/gethexec/sequencer.go index cc98c7930f..92d440e8cb 100644 --- a/execution/gethexec/sequencer.go +++ b/execution/gethexec/sequencer.go @@ -15,11 +15,6 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/execution" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/headerreader" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/arbitrum" @@ -34,10 +29,16 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l1pricing" + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/execution" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/execution/gethexec/stylus_tracer.go b/execution/gethexec/stylus_tracer.go index cb4e858048..8a024941d3 100644 --- a/execution/gethexec/stylus_tracer.go +++ b/execution/gethexec/stylus_tracer.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/execution/gethexec/sync_monitor.go b/execution/gethexec/sync_monitor.go index 86949c7767..7f04b2ee4a 100644 --- a/execution/gethexec/sync_monitor.go +++ b/execution/gethexec/sync_monitor.go @@ -3,9 +3,10 @@ package gethexec import ( "context" - "github.com/offchainlabs/nitro/execution" "github.com/pkg/errors" flag "github.com/spf13/pflag" + + "github.com/offchainlabs/nitro/execution" ) type SyncMonitorConfig struct { diff --git a/execution/gethexec/tx_pre_checker.go b/execution/gethexec/tx_pre_checker.go index e0ae330148..e7ef20bae9 100644 --- a/execution/gethexec/tx_pre_checker.go +++ b/execution/gethexec/tx_pre_checker.go @@ -8,6 +8,8 @@ import ( "fmt" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum_types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -15,11 +17,11 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" - flag "github.com/spf13/pflag" ) var ( diff --git a/execution/gethexec/wasmstorerebuilder.go b/execution/gethexec/wasmstorerebuilder.go index e3eb8e9268..b40a7cd128 100644 --- a/execution/gethexec/wasmstorerebuilder.go +++ b/execution/gethexec/wasmstorerebuilder.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbos/arbosState" ) diff --git a/execution/interface.go b/execution/interface.go index 2a3d79c697..c0aa71c146 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 00da1ba4b6..3b8719b07d 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/retryables" diff --git a/execution/nodeInterface/NodeInterfaceDebug.go b/execution/nodeInterface/NodeInterfaceDebug.go index ae9c157ce4..7066bf2ed2 100644 --- a/execution/nodeInterface/NodeInterfaceDebug.go +++ b/execution/nodeInterface/NodeInterfaceDebug.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" ) diff --git a/execution/nodeInterface/virtual-contracts.go b/execution/nodeInterface/virtual-contracts.go index 86382870b7..5b9f4b3474 100644 --- a/execution/nodeInterface/virtual-contracts.go +++ b/execution/nodeInterface/virtual-contracts.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/l1pricing" diff --git a/gethhook/geth-hook.go b/gethhook/geth-hook.go index 776e8cc452..3ad275b352 100644 --- a/gethhook/geth-hook.go +++ b/gethhook/geth-hook.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/precompiles" ) diff --git a/linters/linters.go b/linters/linters.go index a6c9f6d55e..8d2807c0b2 100644 --- a/linters/linters.go +++ b/linters/linters.go @@ -1,11 +1,12 @@ package main import ( + "golang.org/x/tools/go/analysis/multichecker" + "github.com/offchainlabs/nitro/linters/koanf" "github.com/offchainlabs/nitro/linters/pointercheck" "github.com/offchainlabs/nitro/linters/rightshift" "github.com/offchainlabs/nitro/linters/structinit" - "golang.org/x/tools/go/analysis/multichecker" ) func main() { diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index 62ce177480..9aeddadf71 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/precompiles/ArbAggregator_test.go b/precompiles/ArbAggregator_test.go index 879fc737e4..eb72f12f25 100644 --- a/precompiles/ArbAggregator_test.go +++ b/precompiles/ArbAggregator_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/l1pricing" ) diff --git a/precompiles/ArbGasInfo.go b/precompiles/ArbGasInfo.go index b41dfda8a2..8d916926f3 100644 --- a/precompiles/ArbGasInfo.go +++ b/precompiles/ArbGasInfo.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/ArbGasInfo_test.go b/precompiles/ArbGasInfo_test.go index 260d7b3cef..76489c3c9a 100644 --- a/precompiles/ArbGasInfo_test.go +++ b/precompiles/ArbGasInfo_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/precompiles/ArbInfo.go b/precompiles/ArbInfo.go index 9f8cf34532..60e23ffb6e 100644 --- a/precompiles/ArbInfo.go +++ b/precompiles/ArbInfo.go @@ -5,6 +5,7 @@ package precompiles import ( "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/precompiles/ArbOwner.go b/precompiles/ArbOwner.go index 8b87445e0e..90a7b4ccc2 100644 --- a/precompiles/ArbOwner.go +++ b/precompiles/ArbOwner.go @@ -10,13 +10,13 @@ import ( "fmt" "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/util/arbmath" am "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" ) // ArbOwner precompile provides owners with tools for managing the rollup. diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index fe995c6b32..73252c0763 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -6,16 +6,17 @@ package precompiles import ( "bytes" "encoding/json" - "github.com/ethereum/go-ethereum/core/tracing" "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" diff --git a/precompiles/ArbRetryableTx.go b/precompiles/ArbRetryableTx.go index d925499180..49cc9a3264 100644 --- a/precompiles/ArbRetryableTx.go +++ b/precompiles/ArbRetryableTx.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/precompiles/ArbRetryableTx_test.go b/precompiles/ArbRetryableTx_test.go index 47450299ce..d5b93640c9 100644 --- a/precompiles/ArbRetryableTx_test.go +++ b/precompiles/ArbRetryableTx_test.go @@ -7,12 +7,12 @@ import ( "math/big" "testing" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/storage" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" + + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/storage" templates "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/precompiles/ArbSys.go b/precompiles/ArbSys.go index 689d3b18de..04cde46ebe 100644 --- a/precompiles/ArbSys.go +++ b/precompiles/ArbSys.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/merkletree" diff --git a/precompiles/ArbWasm.go b/precompiles/ArbWasm.go index bc24c8a6e8..eecca35ce6 100644 --- a/precompiles/ArbWasm.go +++ b/precompiles/ArbWasm.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" gethparams "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/precompile.go b/precompiles/precompile.go index 9a356c5a8e..5b5376a4ca 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -14,13 +14,6 @@ import ( "strings" "unicode" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/programs" - "github.com/offchainlabs/nitro/arbos/util" - pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -30,6 +23,13 @@ import ( "github.com/ethereum/go-ethereum/log" glog "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/programs" + "github.com/offchainlabs/nitro/arbos/util" + pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" + "github.com/offchainlabs/nitro/util/arbmath" ) type ArbosPrecompile interface { diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index 18b33714aa..c8b8a46b96 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -10,12 +10,12 @@ import ( "os" "testing" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/storage" templates "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/wrapper.go b/precompiles/wrapper.go index b9363c40a2..edc079fc5b 100644 --- a/precompiles/wrapper.go +++ b/precompiles/wrapper.go @@ -7,12 +7,12 @@ import ( "errors" "math/big" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/util" ) // DebugPrecompile is a precompile wrapper for those not allowed in production diff --git a/pubsub/common.go b/pubsub/common.go index ad36b6e622..a4fc141bb5 100644 --- a/pubsub/common.go +++ b/pubsub/common.go @@ -5,8 +5,9 @@ import ( "fmt" "strings" - "github.com/ethereum/go-ethereum/log" "github.com/redis/go-redis/v9" + + "github.com/ethereum/go-ethereum/log" ) func ResultKeyFor(streamName, id string) string { return fmt.Sprintf("%s.%s", streamName, id) } diff --git a/pubsub/consumer.go b/pubsub/consumer.go index 391042bd7e..3f28749473 100644 --- a/pubsub/consumer.go +++ b/pubsub/consumer.go @@ -10,11 +10,13 @@ import ( "strconv" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/uuid" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/stopwaiter" ) type ConsumerConfig struct { diff --git a/pubsub/producer.go b/pubsub/producer.go index 722c145a09..5aaca77aa7 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -18,12 +18,14 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/uuid" - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/stopwaiter" ) const ( diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index 8bd1aed25d..c82a35e0b8 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -9,12 +9,14 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/go-cmp/cmp" "github.com/google/uuid" + "github.com/redis/go-redis/v9" + + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/redis/go-redis/v9" ) var ( diff --git a/relay/relay_stress_test.go b/relay/relay_stress_test.go index 575a77ee6f..93ba510193 100644 --- a/relay/relay_stress_test.go +++ b/relay/relay_stress_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcastclient" diff --git a/staker/block_challenge_backend.go b/staker/block_challenge_backend.go index 0dd89865bd..a8a6e917a2 100644 --- a/staker/block_challenge_backend.go +++ b/staker/block_challenge_backend.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/validator" diff --git a/staker/block_validator.go b/staker/block_validator.go index 5a1f123693..0a1a38ba17 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -16,12 +16,15 @@ import ( "testing" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbnode/resourcemanager" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/containers" @@ -31,7 +34,6 @@ import ( "github.com/offchainlabs/nitro/validator/client/redis" "github.com/offchainlabs/nitro/validator/inputs" "github.com/offchainlabs/nitro/validator/server_api" - "github.com/spf13/pflag" ) var ( diff --git a/staker/block_validator_schema.go b/staker/block_validator_schema.go index f6eb39f015..330116dda0 100644 --- a/staker/block_validator_schema.go +++ b/staker/block_validator_schema.go @@ -5,6 +5,7 @@ package staker import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/staker/challenge_manager.go b/staker/challenge_manager.go index 27cb92a5c7..96e496acf8 100644 --- a/staker/challenge_manager.go +++ b/staker/challenge_manager.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/validator" diff --git a/staker/challenge_test.go b/staker/challenge_test.go index 33f1644c63..ede1295a13 100644 --- a/staker/challenge_test.go +++ b/staker/challenge_test.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/ospgen" "github.com/offchainlabs/nitro/validator" diff --git a/staker/execution_challenge_bakend.go b/staker/execution_challenge_bakend.go index 8ab60efced..6616d8f8c1 100644 --- a/staker/execution_challenge_bakend.go +++ b/staker/execution_challenge_bakend.go @@ -7,6 +7,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/staker/l1_validator.go b/staker/l1_validator.go index 5b0c211324..8ee05dda22 100644 --- a/staker/l1_validator.go +++ b/staker/l1_validator.go @@ -10,19 +10,19 @@ import ( "math/big" "time" - "github.com/offchainlabs/nitro/staker/txbuilder" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/validator" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/rollupgen" + "github.com/offchainlabs/nitro/staker/txbuilder" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/validator" ) type ConfirmType uint8 diff --git a/staker/rollup_watcher.go b/staker/rollup_watcher.go index 4d7db52322..8b27e544b1 100644 --- a/staker/rollup_watcher.go +++ b/staker/rollup_watcher.go @@ -13,17 +13,17 @@ import ( "strings" "sync/atomic" + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/util/headerreader" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" ) var rollupInitializedID common.Hash diff --git a/staker/staker.go b/staker/staker.go index 45e6f6f551..c5f9c1cd65 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -12,6 +12,9 @@ import ( "strings" "time" + "github.com/google/btree" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -19,8 +22,6 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rpc" - "github.com/google/btree" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index d9c9c5446b..bb25a38f5d 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -9,23 +9,22 @@ import ( "fmt" "testing" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/validator" + validatorclient "github.com/offchainlabs/nitro/validator/client" "github.com/offchainlabs/nitro/validator/client/redis" "github.com/offchainlabs/nitro/validator/server_api" - - validatorclient "github.com/offchainlabs/nitro/validator/client" ) type StatelessBlockValidator struct { diff --git a/staker/validatorwallet/contract.go b/staker/validatorwallet/contract.go index 3202d58569..4d4f8288ef 100644 --- a/staker/validatorwallet/contract.go +++ b/staker/validatorwallet/contract.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker/txbuilder" diff --git a/staker/validatorwallet/eoa.go b/staker/validatorwallet/eoa.go index 7c7f472579..870a959152 100644 --- a/staker/validatorwallet/eoa.go +++ b/staker/validatorwallet/eoa.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" diff --git a/staker/validatorwallet/noop.go b/staker/validatorwallet/noop.go index fec39ac2b1..24c7280811 100644 --- a/staker/validatorwallet/noop.go +++ b/staker/validatorwallet/noop.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/staker/txbuilder" ) diff --git a/system_tests/aliasing_test.go b/system_tests/aliasing_test.go index 60a89468a5..e6c9dab45f 100644 --- a/system_tests/aliasing_test.go +++ b/system_tests/aliasing_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/batch_poster_test.go b/system_tests/batch_poster_test.go index 0ec03e84c4..39d7fa576c 100644 --- a/system_tests/batch_poster_test.go +++ b/system_tests/batch_poster_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/andybalholm/brotli" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" diff --git a/system_tests/block_hash_test.go b/system_tests/block_hash_test.go index b437f3dad9..454b4359ad 100644 --- a/system_tests/block_hash_test.go +++ b/system_tests/block_hash_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/blocks_reexecutor_test.go b/system_tests/blocks_reexecutor_test.go index 1a97919e66..e9ef5a2260 100644 --- a/system_tests/blocks_reexecutor_test.go +++ b/system_tests/blocks_reexecutor_test.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" + blocksreexecutor "github.com/offchainlabs/nitro/blocks_reexecutor" ) diff --git a/system_tests/bloom_test.go b/system_tests/bloom_test.go index 68fb7c3add..df6c549dda 100644 --- a/system_tests/bloom_test.go +++ b/system_tests/bloom_test.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 9d491f522b..b8e7befcc5 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -22,27 +22,6 @@ import ( "testing" "time" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/arbostypes" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/blsSignatures" - "github.com/offchainlabs/nitro/cmd/chaininfo" - "github.com/offchainlabs/nitro/cmd/conf" - "github.com/offchainlabs/nitro/cmd/genericconf" - "github.com/offchainlabs/nitro/das" - "github.com/offchainlabs/nitro/deploy" - "github.com/offchainlabs/nitro/execution/gethexec" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/util/redisutil" - "github.com/offchainlabs/nitro/util/signature" - "github.com/offchainlabs/nitro/validator/inputs" - "github.com/offchainlabs/nitro/validator/server_api" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/offchainlabs/nitro/validator/valnode" - rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" "github.com/redis/go-redis/v9" "github.com/ethereum/go-ethereum" @@ -73,15 +52,36 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/blsSignatures" + "github.com/offchainlabs/nitro/cmd/chaininfo" + "github.com/offchainlabs/nitro/cmd/conf" + "github.com/offchainlabs/nitro/cmd/genericconf" + "github.com/offchainlabs/nitro/das" + "github.com/offchainlabs/nitro/deploy" + "github.com/offchainlabs/nitro/execution/gethexec" _ "github.com/offchainlabs/nitro/execution/nodeInterface" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/util/redisutil" + "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/env" "github.com/offchainlabs/nitro/util/testhelpers/github" + "github.com/offchainlabs/nitro/validator/inputs" + "github.com/offchainlabs/nitro/validator/server_api" + "github.com/offchainlabs/nitro/validator/server_common" + "github.com/offchainlabs/nitro/validator/valnode" + rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" ) type info = *BlockchainTestInfo diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 286060e666..2d9140ffcd 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/contract_tx_test.go b/system_tests/contract_tx_test.go index c1ef840c43..157028c6c1 100644 --- a/system_tests/contract_tx_test.go +++ b/system_tests/contract_tx_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/system_tests/db_conversion_test.go b/system_tests/db_conversion_test.go index aca28262cb..d19629fade 100644 --- a/system_tests/db_conversion_test.go +++ b/system_tests/db_conversion_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/dbconv/dbconv" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/system_tests/debugapi_test.go b/system_tests/debugapi_test.go index eb2bcd095d..6be79ed4c9 100644 --- a/system_tests/debugapi_test.go +++ b/system_tests/debugapi_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/delayedinbox_test.go b/system_tests/delayedinbox_test.go index ca3e7b5999..346b0fbc2f 100644 --- a/system_tests/delayedinbox_test.go +++ b/system_tests/delayedinbox_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/system_tests/estimation_test.go b/system_tests/estimation_test.go index 6285702342..e489b1864e 100644 --- a/system_tests/estimation_test.go +++ b/system_tests/estimation_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" diff --git a/system_tests/forwarder_test.go b/system_tests/forwarder_test.go index 6a1d1c68d8..843668454d 100644 --- a/system_tests/forwarder_test.go +++ b/system_tests/forwarder_test.go @@ -15,7 +15,9 @@ import ( "time" "github.com/alicebob/miniredis/v2" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/util/redisutil" ) diff --git a/system_tests/infra_fee_test.go b/system_tests/infra_fee_test.go index 9366fc204e..2e03eb0815 100644 --- a/system_tests/infra_fee_test.go +++ b/system_tests/infra_fee_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/system_tests/initialization_test.go b/system_tests/initialization_test.go index 17e020e6ab..467882c802 100644 --- a/system_tests/initialization_test.go +++ b/system_tests/initialization_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/system_tests/log_subscription_test.go b/system_tests/log_subscription_test.go index e4402533a6..4d38ea6e9c 100644 --- a/system_tests/log_subscription_test.go +++ b/system_tests/log_subscription_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/meaningless_reorg_test.go b/system_tests/meaningless_reorg_test.go index 06a5d3d2b3..350b21a6cf 100644 --- a/system_tests/meaningless_reorg_test.go +++ b/system_tests/meaningless_reorg_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/system_tests/nodeinterface_test.go b/system_tests/nodeinterface_test.go index 927dc1b630..5c32dcf20f 100644 --- a/system_tests/nodeinterface_test.go +++ b/system_tests/nodeinterface_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" ) diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 25c52396f9..ea6dc2be8b 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index e6751d347d..dca5d6d539 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/precompile_fuzz_test.go b/system_tests/precompile_fuzz_test.go index 8ab133cf58..5d0ecd1785 100644 --- a/system_tests/precompile_fuzz_test.go +++ b/system_tests/precompile_fuzz_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 9d5737c249..8821add864 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 10a371532d..e924b224b2 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_norace_test.go b/system_tests/program_norace_test.go index 56b2046716..b1e5af8395 100644 --- a/system_tests/program_norace_test.go +++ b/system_tests/program_norace_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_recursive_test.go b/system_tests/program_recursive_test.go index e928f9f3aa..ca726c684d 100644 --- a/system_tests/program_recursive_test.go +++ b/system_tests/program_recursive_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_test.go b/system_tests/program_test.go index ea4ccddd03..29cdc14281 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbos/util" diff --git a/system_tests/pruning_test.go b/system_tests/pruning_test.go index 90ac3c6909..f49ed8ddcf 100644 --- a/system_tests/pruning_test.go +++ b/system_tests/pruning_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/pruning" "github.com/offchainlabs/nitro/execution/gethexec" diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index 22329a1be5..dc1356347c 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util" ) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 89446e3c4b..af5f8bf57c 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -16,13 +16,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" diff --git a/system_tests/seq_nonce_test.go b/system_tests/seq_nonce_test.go index c099563e29..7486b8a4ae 100644 --- a/system_tests/seq_nonce_test.go +++ b/system_tests/seq_nonce_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/system_tests/seq_pause_test.go b/system_tests/seq_pause_test.go index 6ce464d8da..c867a98271 100644 --- a/system_tests/seq_pause_test.go +++ b/system_tests/seq_pause_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/execution/gethexec" ) diff --git a/system_tests/seq_reject_test.go b/system_tests/seq_reject_test.go index 2dbdba6804..6b229b3b63 100644 --- a/system_tests/seq_reject_test.go +++ b/system_tests/seq_reject_test.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/colors" diff --git a/system_tests/seqcompensation_test.go b/system_tests/seqcompensation_test.go index 156ced6bfc..41133b8a42 100644 --- a/system_tests/seqcompensation_test.go +++ b/system_tests/seqcompensation_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/l1pricing" ) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 21f0755225..f57f43e621 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l1pricing" diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index c8312350e6..6969a902ab 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 42faee7e0d..d5ed3fcd33 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/staterecovery" "github.com/offchainlabs/nitro/execution/gethexec" diff --git a/system_tests/stylus_trace_test.go b/system_tests/stylus_trace_test.go index 52039df460..fe5de21dad 100644 --- a/system_tests/stylus_trace_test.go +++ b/system_tests/stylus_trace_test.go @@ -10,12 +10,14 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/tracers/logger" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/stylus_tracer_test.go b/system_tests/stylus_tracer_test.go index 7fda39f04e..b833d7df17 100644 --- a/system_tests/stylus_tracer_test.go +++ b/system_tests/stylus_tracer_test.go @@ -7,9 +7,11 @@ import ( "encoding/binary" "testing" + "github.com/google/go-cmp/cmp" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - "github.com/google/go-cmp/cmp" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/util/containers" diff --git a/system_tests/test_info.go b/system_tests/test_info.go index 6313e392ca..105d491006 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -11,16 +11,16 @@ import ( "sync/atomic" "testing" - "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/util" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util" ) var simulatedChainID = big.NewInt(1337) diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 7828cf386d..78a7258aea 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/system_tests/twonodeslong_test.go b/system_tests/twonodeslong_test.go index 60707b83fb..5791661b16 100644 --- a/system_tests/twonodeslong_test.go +++ b/system_tests/twonodeslong_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" - - "github.com/ethereum/go-ethereum/core/types" ) func testTwoNodesLong(t *testing.T, dasModeStr string) { diff --git a/system_tests/unsupported_txtypes_test.go b/system_tests/unsupported_txtypes_test.go index a228cb2454..6e92243c85 100644 --- a/system_tests/unsupported_txtypes_test.go +++ b/system_tests/unsupported_txtypes_test.go @@ -13,10 +13,11 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" ) func TestBlobAndInternalTxsReject(t *testing.T) { diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 912b48ea6a..ad19203093 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" @@ -21,11 +22,10 @@ import ( "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/validator" + validatorclient "github.com/offchainlabs/nitro/validator/client" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/valnode" - - validatorclient "github.com/offchainlabs/nitro/validator/client" ) type mockSpawner struct { diff --git a/system_tests/wrap_transaction_test.go b/system_tests/wrap_transaction_test.go index 36052fb2db..dd68c25d6a 100644 --- a/system_tests/wrap_transaction_test.go +++ b/system_tests/wrap_transaction_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" diff --git a/util/arbmath/bits.go b/util/arbmath/bits.go index 1b91e2755a..501ef9787e 100644 --- a/util/arbmath/bits.go +++ b/util/arbmath/bits.go @@ -6,8 +6,9 @@ package arbmath import ( "encoding/binary" - "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" + + "github.com/ethereum/go-ethereum/common" ) type bytes32 = common.Hash diff --git a/util/arbmath/math_test.go b/util/arbmath/math_test.go index 3660f3657e..befa7813e1 100644 --- a/util/arbmath/math_test.go +++ b/util/arbmath/math_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/contracts/address_verifier.go b/util/contracts/address_verifier.go index eb2f862210..66686e9dc8 100644 --- a/util/contracts/address_verifier.go +++ b/util/contracts/address_verifier.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/util/dbutil/dbutil.go b/util/dbutil/dbutil.go index 6573c5742c..28a57025e9 100644 --- a/util/dbutil/dbutil.go +++ b/util/dbutil/dbutil.go @@ -10,9 +10,10 @@ import ( "regexp" "github.com/cockroachdb/pebble" + "github.com/syndtr/goleveldb/leveldb" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb/memorydb" - "github.com/syndtr/goleveldb/leveldb" ) func IsErrNotFound(err error) bool { diff --git a/util/headerreader/blob_client.go b/util/headerreader/blob_client.go index fbdb4335a0..0c92ff2e85 100644 --- a/util/headerreader/blob_client.go +++ b/util/headerreader/blob_client.go @@ -15,16 +15,17 @@ import ( "path" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/blobs" "github.com/offchainlabs/nitro/util/jsonapi" "github.com/offchainlabs/nitro/util/pretty" - - "github.com/spf13/pflag" ) type BlobClient struct { diff --git a/util/headerreader/blob_client_test.go b/util/headerreader/blob_client_test.go index 9735899daa..52c22e434a 100644 --- a/util/headerreader/blob_client_test.go +++ b/util/headerreader/blob_client_test.go @@ -11,8 +11,9 @@ import ( "reflect" "testing" - "github.com/offchainlabs/nitro/util/testhelpers" "github.com/r3labs/diff/v3" + + "github.com/offchainlabs/nitro/util/testhelpers" ) func TestSaveBlobsToDisk(t *testing.T) { diff --git a/util/headerreader/header_reader.go b/util/headerreader/header_reader.go index 98f778dee8..f8e3bc6cd6 100644 --- a/util/headerreader/header_reader.go +++ b/util/headerreader/header_reader.go @@ -12,6 +12,8 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -19,9 +21,9 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // A regexp matching "execution reverted" errors returned from the parent chain RPC. diff --git a/util/jsonapi/preimages_test.go b/util/jsonapi/preimages_test.go index 3074a1e698..5b699df5fe 100644 --- a/util/jsonapi/preimages_test.go +++ b/util/jsonapi/preimages_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/merkletree/merkleAccumulator_test.go b/util/merkletree/merkleAccumulator_test.go index d26f0244d3..95e1862b7a 100644 --- a/util/merkletree/merkleAccumulator_test.go +++ b/util/merkletree/merkleAccumulator_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) diff --git a/util/merkletree/merkleEventProof.go b/util/merkletree/merkleEventProof.go index 130249cc3f..cab85dbefe 100644 --- a/util/merkletree/merkleEventProof.go +++ b/util/merkletree/merkleEventProof.go @@ -5,6 +5,7 @@ package merkletree import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) diff --git a/util/merkletree/merkleEventProof_test.go b/util/merkletree/merkleEventProof_test.go index 6af8479190..c0c8e777cb 100644 --- a/util/merkletree/merkleEventProof_test.go +++ b/util/merkletree/merkleEventProof_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/util/merkletree/merkleTree.go b/util/merkletree/merkleTree.go index fffa9bcabc..9cf7b485d9 100644 --- a/util/merkletree/merkleTree.go +++ b/util/merkletree/merkleTree.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/util/redisutil/test_redis.go b/util/redisutil/test_redis.go index 6d493b1546..9cabfc23d6 100644 --- a/util/redisutil/test_redis.go +++ b/util/redisutil/test_redis.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/alicebob/miniredis/v2" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/rpcclient/rpcclient_test.go b/util/rpcclient/rpcclient_test.go index 1a7da54774..f711747b70 100644 --- a/util/rpcclient/rpcclient_test.go +++ b/util/rpcclient/rpcclient_test.go @@ -9,10 +9,12 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/rpc" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/sharedmetrics/sharedmetrics.go b/util/sharedmetrics/sharedmetrics.go index 9b4b3609bc..1df34d4d54 100644 --- a/util/sharedmetrics/sharedmetrics.go +++ b/util/sharedmetrics/sharedmetrics.go @@ -2,6 +2,7 @@ package sharedmetrics import ( "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 5ed852bfbc..f222860d8b 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,9 +4,11 @@ import ( "context" "errors" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/util/contracts" - flag "github.com/spf13/pflag" ) type SignVerify struct { diff --git a/util/stopwaiter/stopwaiter.go b/util/stopwaiter/stopwaiter.go index 1e70e328eb..993768dd85 100644 --- a/util/stopwaiter/stopwaiter.go +++ b/util/stopwaiter/stopwaiter.go @@ -13,6 +13,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/util/stopwaiter/stopwaiter_test.go b/util/stopwaiter/stopwaiter_test.go index 5319927887..c561e1f43b 100644 --- a/util/stopwaiter/stopwaiter_test.go +++ b/util/stopwaiter/stopwaiter_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/testhelpers/testhelpers.go b/util/testhelpers/testhelpers.go index 557d45808a..7f3e63a811 100644 --- a/util/testhelpers/testhelpers.go +++ b/util/testhelpers/testhelpers.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/colors" ) diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index c5726ffe8b..4bfb721f59 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -5,10 +5,14 @@ import ( "fmt" "sync/atomic" + "github.com/redis/go-redis/v9" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/pubsub" "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/redisutil" @@ -16,8 +20,6 @@ import ( "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_common" - "github.com/redis/go-redis/v9" - "github.com/spf13/pflag" ) type ValidationClientConfig struct { diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 934362f00a..0a6555121e 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -11,21 +11,19 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/validator" - - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/rpcclient" - "github.com/offchainlabs/nitro/util/stopwaiter" - - "github.com/offchainlabs/nitro/validator/server_api" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/rpcclient" + "github.com/offchainlabs/nitro/util/stopwaiter" + "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_api" + "github.com/offchainlabs/nitro/validator/server_common" ) type ValidationClient struct { diff --git a/validator/execution_state.go b/validator/execution_state.go index 092fbe2908..b9cea8ec3b 100644 --- a/validator/execution_state.go +++ b/validator/execution_state.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" ) diff --git a/validator/interface.go b/validator/interface.go index 9fb831ca0d..bfccaefcfa 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 8dfbc8446a..f56493cd92 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/util/jsonapi" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index d29a88d34d..270ace3180 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index 479db58515..1f8e9625c1 100644 --- a/validator/server_arb/execution_run_test.go +++ b/validator/server_arb/execution_run_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index f882fe65a6..c429fa6101 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -10,6 +10,7 @@ package server_arb ResolvedPreimage preimageResolverC(size_t context, uint8_t preimageType, const uint8_t* hash); */ import "C" + import ( "context" "errors" @@ -21,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/containers" diff --git a/validator/server_arb/machine_loader.go b/validator/server_arb/machine_loader.go index 13cf0f2403..8c9d37e174 100644 --- a/validator/server_arb/machine_loader.go +++ b/validator/server_arb/machine_loader.go @@ -4,6 +4,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go index e3ffb28b42..008d757889 100644 --- a/validator/server_arb/machine_test.go +++ b/validator/server_arb/machine_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/validator/server_arb/mock_machine.go b/validator/server_arb/mock_machine.go index 3cf0f9f771..00512d1d77 100644 --- a/validator/server_arb/mock_machine.go +++ b/validator/server_arb/mock_machine.go @@ -7,6 +7,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/nitro_machine.go b/validator/server_arb/nitro_machine.go index 926b1e8930..a2f7de3153 100644 --- a/validator/server_arb/nitro_machine.go +++ b/validator/server_arb/nitro_machine.go @@ -9,6 +9,7 @@ package server_arb #include */ import "C" + import ( "context" "errors" @@ -19,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_arb/prover_interface.go b/validator/server_arb/prover_interface.go index 3010d2138d..8479a8aa8f 100644 --- a/validator/server_arb/prover_interface.go +++ b/validator/server_arb/prover_interface.go @@ -22,10 +22,12 @@ void AddToStringList(char** list, int index, char* val) { } */ import "C" + import ( "unsafe" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 07971e2ba5..bb7fbcf97d 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -10,18 +10,18 @@ import ( "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode/redis" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var arbitratorValidationSteps = metrics.NewRegisteredHistogram("arbitrator/validation/steps", nil, metrics.NewBoundedHistogramSample()) diff --git a/validator/server_common/machine_loader.go b/validator/server_common/machine_loader.go index f4633ebedf..e86589b657 100644 --- a/validator/server_common/machine_loader.go +++ b/validator/server_common/machine_loader.go @@ -5,6 +5,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/validator/server_common/valrun.go b/validator/server_common/valrun.go index 8486664008..9a2a6cb414 100644 --- a/validator/server_common/valrun.go +++ b/validator/server_common/valrun.go @@ -2,6 +2,7 @@ package server_common import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_jit/jit_machine.go b/validator/server_jit/jit_machine.go index 0748101277..dc7657441e 100644 --- a/validator/server_jit/jit_machine.go +++ b/validator/server_jit/jit_machine.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_jit/machine_loader.go b/validator/server_jit/machine_loader.go index 3d8b01367f..a4ccede324 100644 --- a/validator/server_jit/machine_loader.go +++ b/validator/server_jit/machine_loader.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_jit/spawner.go b/validator/server_jit/spawner.go index f30b6e181a..91b1e818f0 100644 --- a/validator/server_jit/spawner.go +++ b/validator/server_jit/spawner.go @@ -3,11 +3,12 @@ package server_jit import ( "context" "fmt" - flag "github.com/spf13/pflag" "runtime" "sync/atomic" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" diff --git a/validator/validation_entry.go b/validator/validation_entry.go index 4ec6919d3b..555a4c76c7 100644 --- a/validator/validation_entry.go +++ b/validator/validation_entry.go @@ -3,6 +3,7 @@ package validator import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/validator/valnode/redis/consumer.go b/validator/valnode/redis/consumer.go index 4392a3c91e..93b3eddd3f 100644 --- a/validator/valnode/redis/consumer.go +++ b/validator/valnode/redis/consumer.go @@ -6,14 +6,16 @@ import ( "runtime" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/pubsub" "github.com/offchainlabs/nitro/util/redisutil" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" - "github.com/spf13/pflag" ) // ValidationServer implements consumer for the requests originated from diff --git a/validator/valnode/redis/consumer_test.go b/validator/valnode/redis/consumer_test.go index 0ebd697f16..595aecc9ca 100644 --- a/validator/valnode/redis/consumer_test.go +++ b/validator/valnode/redis/consumer_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/redisutil" "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/validator/valnode/valnode.go b/validator/valnode/valnode.go index 972e11189d..e2f4f79bef 100644 --- a/validator/valnode/valnode.go +++ b/validator/valnode/valnode.go @@ -3,17 +3,18 @@ package valnode import ( "context" - "github.com/offchainlabs/nitro/validator" + "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/server_jit" "github.com/offchainlabs/nitro/validator/valnode/redis" - "github.com/spf13/pflag" ) type WasmConfig struct { diff --git a/wavmio/stub.go b/wavmio/stub.go index 0c82506ff3..01031860e9 100644 --- a/wavmio/stub.go +++ b/wavmio/stub.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/wsbroadcastserver/clientconnection.go b/wsbroadcastserver/clientconnection.go index 00ae0f0dcf..2585452db7 100644 --- a/wsbroadcastserver/clientconnection.go +++ b/wsbroadcastserver/clientconnection.go @@ -13,14 +13,15 @@ import ( "sync/atomic" "time" + "github.com/gobwas/ws" + "github.com/gobwas/ws/wsflate" + "github.com/mailru/easygo/netpoll" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcaster/backlog" m "github.com/offchainlabs/nitro/broadcaster/message" - - "github.com/gobwas/ws" - "github.com/gobwas/ws/wsflate" - "github.com/mailru/easygo/netpoll" "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/wsbroadcastserver/connectionlimiter.go b/wsbroadcastserver/connectionlimiter.go index e483eb545e..d086fc074e 100644 --- a/wsbroadcastserver/connectionlimiter.go +++ b/wsbroadcastserver/connectionlimiter.go @@ -8,9 +8,10 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - flag "github.com/spf13/pflag" ) var ( diff --git a/wsbroadcastserver/utils.go b/wsbroadcastserver/utils.go index 9df1d7d9ca..1e72915047 100644 --- a/wsbroadcastserver/utils.go +++ b/wsbroadcastserver/utils.go @@ -12,10 +12,11 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/log" "github.com/gobwas/ws" "github.com/gobwas/ws/wsflate" "github.com/gobwas/ws/wsutil" + + "github.com/ethereum/go-ethereum/log" ) func init() { diff --git a/wsbroadcastserver/wsbroadcastserver.go b/wsbroadcastserver/wsbroadcastserver.go index ee21cbaae3..da9420a527 100644 --- a/wsbroadcastserver/wsbroadcastserver.go +++ b/wsbroadcastserver/wsbroadcastserver.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcaster/backlog" m "github.com/offchainlabs/nitro/broadcaster/message" From ef9e90c23a68424c5e25cfb85377bcfb05fea326 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 11:19:18 +0100 Subject: [PATCH 125/210] Make golangci-lint 1.62.0 happy The linter learned how to find missing checks for safe typecasts and we had some spots where they weren't being checked. --- arbnode/delayed.go | 6 +++++- arbnode/sequencer_inbox.go | 6 +++++- broadcastclient/broadcastclient_test.go | 21 ++++++++++++++++++--- broadcaster/backlog/backlog.go | 2 +- cmd/genericconf/filehandler_test.go | 6 +++++- das/reader_aggregator_strategies_test.go | 6 ++++-- execution/nodeInterface/NodeInterface.go | 12 ++++++++++-- linters/koanf/handlers.go | 6 +++++- system_tests/seq_coordinator_test.go | 13 ++++++++++--- system_tests/seq_reject_test.go | 4 ++-- system_tests/seqfeed_test.go | 13 ++++++------- util/containers/syncmap.go | 13 +++++++++++-- util/testhelpers/port.go | 11 +++++++++++ util/testhelpers/port_test.go | 12 ++++++++++-- 14 files changed, 103 insertions(+), 28 deletions(-) diff --git a/arbnode/delayed.go b/arbnode/delayed.go index 354fa671b3..f28a9617a3 100644 --- a/arbnode/delayed.go +++ b/arbnode/delayed.go @@ -334,7 +334,11 @@ func (b *DelayedBridge) parseMessage(ctx context.Context, ethLog types.Log) (*bi if err != nil { return nil, nil, err } - return parsedLog.MessageNum, args["messageData"].([]byte), nil + dataBytes, ok := args["messageData"].([]byte) + if !ok { + return nil, nil, errors.New("messageData not a byte array") + } + return parsedLog.MessageNum, dataBytes, nil default: return nil, nil, errors.New("unexpected log type") } diff --git a/arbnode/sequencer_inbox.go b/arbnode/sequencer_inbox.go index 81146ed46e..b2840492fe 100644 --- a/arbnode/sequencer_inbox.go +++ b/arbnode/sequencer_inbox.go @@ -124,7 +124,11 @@ func (m *SequencerInboxBatch) getSequencerData(ctx context.Context, client *ethc if err != nil { return nil, err } - return args["data"].([]byte), nil + dataBytes, ok := args["data"].([]byte) + if !ok { + return nil, errors.New("args[\"data\"] not a byte array") + } + return dataBytes, nil case batchDataSeparateEvent: var numberAsHash common.Hash binary.BigEndian.PutUint64(numberAsHash[(32-8):], m.SequenceNumber) diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index a499628cd5..d9f7443af5 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -138,7 +138,11 @@ func TestInvalidSignature(t *testing.T) { badPrivateKey, err := crypto.GenerateKey() Require(t, err) badPublicKey := badPrivateKey.Public() - badSequencerAddr := crypto.PubkeyToAddress(*badPublicKey.(*ecdsa.PublicKey)) + badECDSA, ok := badPublicKey.(*ecdsa.PublicKey) + if !ok { + t.Fatal("badPublicKey is not an ecdsa.PublicKey") + } + badSequencerAddr := crypto.PubkeyToAddress(*badECDSA) config := DefaultTestConfig ts := NewDummyTransactionStreamer(chainId, &badSequencerAddr) @@ -151,6 +155,7 @@ func TestInvalidSignature(t *testing.T) { nil, fatalErrChan, &badSequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -201,8 +206,9 @@ func (ts *dummyTransactionStreamer) AddBroadcastMessages(feedMessages []*m.Broad return nil } -func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address) (*BroadcastClient, error) { - port := listenerAddress.(*net.TCPAddr).Port +func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address, t *testing.T) (*BroadcastClient, error) { + t.Helper() + port := testhelpers.AddrTCPPort(listenerAddress, t) var av contracts.AddressVerifierInterface if validAddr != nil { config.Verify.AcceptSequencer = true @@ -225,6 +231,7 @@ func startMakeBroadcastClient(ctx context.Context, t *testing.T, clientConfig Co nil, feedErrChan, sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -313,6 +320,7 @@ func TestServerClientDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -384,6 +392,7 @@ func TestBroadcastClientConfirmedMessage(t *testing.T) { confirmedSequenceNumberListener, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -456,6 +465,7 @@ func TestServerIncorrectChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -515,6 +525,7 @@ func TestServerMissingChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -572,6 +583,7 @@ func TestServerIncorrectFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -631,6 +643,7 @@ func TestServerMissingFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -682,6 +695,7 @@ func TestBroadcastClientReconnectsOnServerDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -794,6 +808,7 @@ func connectAndGetCachedMessages(ctx context.Context, addr net.Addr, chainId uin nil, feedErrChan, sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) diff --git a/broadcaster/backlog/backlog.go b/broadcaster/backlog/backlog.go index b7b935fb7a..413a14b782 100644 --- a/broadcaster/backlog/backlog.go +++ b/broadcaster/backlog/backlog.go @@ -328,7 +328,7 @@ func newBacklogSegment() *backlogSegment { func IsBacklogSegmentNil(segment BacklogSegment) bool { if segment == nil { return true - } else if segment.(*backlogSegment) == nil { + } else if bs, ok := segment.(*backlogSegment); ok && bs == nil { return true } return false diff --git a/cmd/genericconf/filehandler_test.go b/cmd/genericconf/filehandler_test.go index daa9ed397c..adf468bc1d 100644 --- a/cmd/genericconf/filehandler_test.go +++ b/cmd/genericconf/filehandler_test.go @@ -55,7 +55,11 @@ func readLogMessagesFromJSONFile(t *testing.T, path string) ([]string, error) { if !ok { testhelpers.FailImpl(t, "Incorrect record, msg key is missing", "record", record) } - messages = append(messages, msg.(string)) + msgString, ok := msg.(string) + if !ok { + testhelpers.FailImpl(t, "Incorrect record, msg is not a string", "record", record) + } + messages = append(messages, msgString) } if errors.Is(err, io.EOF) { return messages, nil diff --git a/das/reader_aggregator_strategies_test.go b/das/reader_aggregator_strategies_test.go index cdb85b25e9..67d8681f78 100644 --- a/das/reader_aggregator_strategies_test.go +++ b/das/reader_aggregator_strategies_test.go @@ -72,8 +72,10 @@ func TestDAS_SimpleExploreExploit(t *testing.T) { } for i := 0; i < len(was) && doMatch; i++ { - if expected[i].(*dummyReader).int != was[i].(*dummyReader).int { - Fail(t, fmt.Sprintf("expected %d, was %d", expected[i].(*dummyReader).int, was[i].(*dummyReader).int)) + expR, expOK := expected[i].(*dummyReader) + wasR, wasOK := was[i].(*dummyReader) + if !expOK || !wasOK || expR.int != wasR.int { + Fail(t, fmt.Sprintf("expected %d, was %d", expected[i], was[i])) } } } diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 00da1ba4b6..cd87e23b73 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -525,7 +525,11 @@ func (n NodeInterface) GasEstimateL1Component( if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) + sdb, ok := evm.StateDB.(*state.StateDB) + if !ok { + return 0, nil, nil, errors.New("failed to cast to stateDB") + } + msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, sdb, core.MessageEthcallMode) pricing := c.State.L1PricingState() l1BaseFeeEstimate, err := pricing.PricePerUnit() @@ -581,7 +585,11 @@ func (n NodeInterface) GasEstimateComponents( if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, 0, nil, nil, err } - msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) + sdb, ok := evm.StateDB.(*state.StateDB) + if !ok { + return 0, 0, nil, nil, errors.New("failed to cast to stateDB") + } + msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, sdb, core.MessageGasEstimationMode) brotliCompressionLevel, err := c.State.BrotliCompressionLevel() if err != nil { return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err) diff --git a/linters/koanf/handlers.go b/linters/koanf/handlers.go index 5ee3b80f9f..e3f7c67f68 100644 --- a/linters/koanf/handlers.go +++ b/linters/koanf/handlers.go @@ -126,7 +126,11 @@ func checkFlagDefs(pass *analysis.Pass, f *ast.FuncDecl, cnt map[string]int) Res if !ok { continue } - handleSelector(pass, callE.Args[1].(*ast.SelectorExpr), -1, cnt) + sel, ok := callE.Args[1].(*ast.SelectorExpr) + if !ok { + continue + } + handleSelector(pass, sel, -1, cnt) if normSL := normalizeTag(sl); !strings.EqualFold(normSL, s) { res.Errors = append(res.Errors, koanfError{ Pos: f.Pos(), diff --git a/system_tests/seq_coordinator_test.go b/system_tests/seq_coordinator_test.go index e7d8bf6b39..76cff95f04 100644 --- a/system_tests/seq_coordinator_test.go +++ b/system_tests/seq_coordinator_test.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "math/big" - "net" "testing" "time" @@ -153,7 +152,15 @@ func TestRedisSeqCoordinatorPriorities(t *testing.T) { nodeForwardTarget := func(nodeNum int) int { execNode := testNodes[nodeNum].ExecNode - fwTarget := execNode.TxPublisher.(*gethexec.TxPreChecker).TransactionPublisher.(*gethexec.Sequencer).ForwardTarget() + preChecker, ok := execNode.TxPublisher.(*gethexec.TxPreChecker) + if !ok { + return -1 + } + sequencer, ok := preChecker.TransactionPublisher.(*gethexec.Sequencer) + if !ok { + return -1 + } + fwTarget := sequencer.ForwardTarget() if fwTarget == "" { return -1 } @@ -323,7 +330,7 @@ func testCoordinatorMessageSync(t *testing.T, successCase bool) { // nodeB doesn't sequence transactions, but adds messages related to them to its output feed. // nodeBOutputFeedReader reads those messages from this feed and processes them. // nodeBOutputFeedReader doesn't read messages from L1 since none of the nodes posts to L1. - nodeBPort := testClientB.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + nodeBPort := testhelpers.AddrTCPPort(testClientB.ConsensusNode.BroadcastServer.ListenerAddr(), t) nodeConfigNodeBOutputFeedReader := arbnode.ConfigDefaultL1NonSequencerTest() nodeConfigNodeBOutputFeedReader.Feed.Input = *newBroadcastClientConfigTest(nodeBPort) testClientNodeBOutputFeedReader, cleanupNodeBOutputFeedReader := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigNodeBOutputFeedReader}) diff --git a/system_tests/seq_reject_test.go b/system_tests/seq_reject_test.go index 2dbdba6804..fa2d1c382d 100644 --- a/system_tests/seq_reject_test.go +++ b/system_tests/seq_reject_test.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "math/big" - "net" "strings" "sync" "sync/atomic" @@ -20,6 +19,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/colors" + "github.com/offchainlabs/nitro/util/testhelpers" ) func TestSequencerRejection(t *testing.T) { @@ -35,7 +35,7 @@ func TestSequencerRejection(t *testing.T) { builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.takeOwnership = false - port := builderSeq.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(builderSeq.L2.ConsensusNode.BroadcastServer.ListenerAddr(), t) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) cleanup := builder.Build(t) defer cleanup() diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 21f0755225..a5180b5773 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "math/big" - "net" "reflect" "testing" "time" @@ -61,7 +60,7 @@ func TestSequencerFeed(t *testing.T) { defer cleanupSeq() seqInfo, seqNode, seqClient := builderSeq.L2Info, builderSeq.L2.ConsensusNode, builderSeq.L2.Client - port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(seqNode.BroadcastServer.ListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) builder.takeOwnership = false @@ -107,7 +106,7 @@ func TestRelayedSequencerFeed(t *testing.T) { Require(t, err) config := relay.ConfigDefault - port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(seqNode.BroadcastServer.ListenerAddr(), t) config.Node.Feed.Input = *newBroadcastClientConfigTest(port) config.Node.Feed.Output = *newBroadcasterConfigTest() config.Chain.ID = bigChainId.Uint64() @@ -119,7 +118,7 @@ func TestRelayedSequencerFeed(t *testing.T) { Require(t, err) defer currentRelay.StopAndWait() - port = currentRelay.GetListenerAddr().(*net.TCPAddr).Port + port = testhelpers.AddrTCPPort(currentRelay.GetListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) builder.takeOwnership = false @@ -219,7 +218,7 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { defer cleanupC() l2clientC, nodeC := testClientC.Client, testClientC.ConsensusNode - port := nodeC.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(nodeC.BroadcastServer.ListenerAddr(), t) // The client node, connects to lying sequencer's feed nodeConfigB := arbnode.ConfigDefaultL1NonSequencerTest() @@ -361,7 +360,7 @@ func testBlockHashComparison(t *testing.T, blockHash *common.Hash, mustMismatch } defer wsBroadcastServer.StopAndWait() - port := wsBroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(wsBroadcastServer.ListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) @@ -468,7 +467,7 @@ func TestPopulateFeedBacklog(t *testing.T) { // Creates a sink node that will read from the output feed of the previous node. nodeConfigSink := builder.nodeConfig - port := builder.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(builder.L2.ConsensusNode.BroadcastServer.ListenerAddr(), t) nodeConfigSink.Feed.Input = *newBroadcastClientConfigTest(port) testClientSink, cleanupSink := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigSink}) defer cleanupSink() diff --git a/util/containers/syncmap.go b/util/containers/syncmap.go index e24d56fda6..cc7563faec 100644 --- a/util/containers/syncmap.go +++ b/util/containers/syncmap.go @@ -12,7 +12,12 @@ func (m *SyncMap[K, V]) Load(key K) (V, bool) { var empty V return empty, false } - return val.(V), true + vVal, ok := val.(V) + if !ok { + var empty V + return empty, false + } + return vVal, true } func (m *SyncMap[K, V]) Store(key K, val V) { @@ -27,7 +32,11 @@ func (m *SyncMap[K, V]) Delete(key K) { func (m *SyncMap[K, V]) Keys() []K { s := make([]K, 0) m.internal.Range(func(k, v interface{}) bool { - s = append(s, k.(K)) + kKey, ok := k.(K) + if !ok { + return false + } + s = append(s, kKey) return true }) return s diff --git a/util/testhelpers/port.go b/util/testhelpers/port.go index d31fa41cdc..c17e9d9ec2 100644 --- a/util/testhelpers/port.go +++ b/util/testhelpers/port.go @@ -2,6 +2,7 @@ package testhelpers import ( "net" + "testing" ) // FreeTCPPortListener returns a listener listening on an unused local port. @@ -15,3 +16,13 @@ func FreeTCPPortListener() (net.Listener, error) { } return l, nil } + +// Func AddrTCPPort returns the port of a net.Addr. +func AddrTCPPort(n net.Addr, t *testing.T) int { + t.Helper() + tcpAddr, ok := n.(*net.TCPAddr) + if !ok { + t.Fatal("Could not get TCP address net.Addr") + } + return tcpAddr.Port +} diff --git a/util/testhelpers/port_test.go b/util/testhelpers/port_test.go index ef9bb18537..bb8f87b2f7 100644 --- a/util/testhelpers/port_test.go +++ b/util/testhelpers/port_test.go @@ -14,10 +14,18 @@ func TestFreeTCPPortListener(t *testing.T) { if err != nil { t.Fatal(err) } - if aListener.Addr().(*net.TCPAddr).Port == bListener.Addr().(*net.TCPAddr).Port { + aTCPAddr, ok := aListener.Addr().(*net.TCPAddr) + if !ok { + t.Fatalf("aListener.Addr() is not a *net.TCPAddr: %v", aListener.Addr()) + } + bTCPAddr, ok := bListener.Addr().(*net.TCPAddr) + if !ok { + t.Fatalf("bListener.Addr() is not a *net.TCPAddr: %v", aListener.Addr()) + } + if aTCPAddr.Port == bTCPAddr.Port { t.Errorf("FreeTCPPortListener() got same port: %v, %v", aListener, bListener) } - if aListener.Addr().(*net.TCPAddr).Port == 0 || bListener.Addr().(*net.TCPAddr).Port == 0 { + if aTCPAddr.Port == 0 || bTCPAddr.Port == 0 { t.Errorf("FreeTCPPortListener() got port 0") } } From 8e039e0ddde81e4145c551c6c4698e7faa16f4d8 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 14:28:32 +0100 Subject: [PATCH 126/210] Also log an error if the backlogSegment type cannot be asserted --- broadcaster/backlog/backlog.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/broadcaster/backlog/backlog.go b/broadcaster/backlog/backlog.go index 413a14b782..d75e5dafe5 100644 --- a/broadcaster/backlog/backlog.go +++ b/broadcaster/backlog/backlog.go @@ -328,7 +328,13 @@ func newBacklogSegment() *backlogSegment { func IsBacklogSegmentNil(segment BacklogSegment) bool { if segment == nil { return true - } else if bs, ok := segment.(*backlogSegment); ok && bs == nil { + } + bs, ok := segment.(*backlogSegment) + if !ok { + log.Error("error in backlogSegment type assertion: clearing backlog") + return false + } + if bs == nil { return true } return false From b51dcfdd71cb33b3070490a8bffea84c340b0a89 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 16:27:48 +0100 Subject: [PATCH 127/210] Panic in syncmap if the key cannot be converted to the type --- util/containers/syncmap.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/containers/syncmap.go b/util/containers/syncmap.go index cc7563faec..da15afaacc 100644 --- a/util/containers/syncmap.go +++ b/util/containers/syncmap.go @@ -1,6 +1,9 @@ package containers -import "sync" +import ( + "fmt" + "sync" +) type SyncMap[K any, V any] struct { internal sync.Map @@ -34,7 +37,7 @@ func (m *SyncMap[K, V]) Keys() []K { m.internal.Range(func(k, v interface{}) bool { kKey, ok := k.(K) if !ok { - return false + panic(fmt.Sprintf("type assertion failed on %s", k)) } s = append(s, kKey) return true From 013d501ea21c57ba85f654cf88542b06225c50a1 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 12 Nov 2024 16:37:34 +0100 Subject: [PATCH 128/210] change default scheme used in tests to HashScheme --- util/testhelpers/env/env.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/testhelpers/env/env.go b/util/testhelpers/env/env.go index 27d74465de..2a8090c212 100644 --- a/util/testhelpers/env/env.go +++ b/util/testhelpers/env/env.go @@ -14,7 +14,7 @@ import ( // An environment variable controls that behavior. func GetTestStateScheme() string { envTestStateScheme := os.Getenv("TEST_STATE_SCHEME") - stateScheme := rawdb.PathScheme + stateScheme := rawdb.HashScheme if envTestStateScheme == rawdb.PathScheme || envTestStateScheme == rawdb.HashScheme { stateScheme = envTestStateScheme } From 86b6cf0e94f388c38dd704167ae0a925d3bfc855 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 12 Nov 2024 16:46:20 +0100 Subject: [PATCH 129/210] Also panic in the other syncmap function on failed type assertions --- util/containers/syncmap.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/containers/syncmap.go b/util/containers/syncmap.go index da15afaacc..9190d81974 100644 --- a/util/containers/syncmap.go +++ b/util/containers/syncmap.go @@ -17,8 +17,7 @@ func (m *SyncMap[K, V]) Load(key K) (V, bool) { } vVal, ok := val.(V) if !ok { - var empty V - return empty, false + panic(fmt.Sprintf("type assertion failed on %s", val)) } return vVal, true } From 65d347d4f368a0275e8a1787e206712e56b33bde Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 15:17:55 -0300 Subject: [PATCH 130/210] TestHostioWithoutEVMEquivalentCosts --- .../stylus/tests/hostio-test/src/main.rs | 35 +++++++++++++ system_tests/program_gas_test.go | 49 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/arbitrator/stylus/tests/hostio-test/src/main.rs b/arbitrator/stylus/tests/hostio-test/src/main.rs index 17a5d10266..cf6e70bf4c 100644 --- a/arbitrator/stylus/tests/hostio-test/src/main.rs +++ b/arbitrator/stylus/tests/hostio-test/src/main.rs @@ -204,4 +204,39 @@ impl HostioTest { fn tx_origin() -> Result
{ Ok(tx::origin()) } + + fn msg_reentrant() { + unsafe { + hostio::msg_reentrant(); + } + } + + fn storage_cache_bytes32() { + let key = B256::ZERO; + let val = B256::ZERO; + unsafe { + hostio::storage_cache_bytes32(key.as_ptr(), val.as_ptr()); + } + } + + fn pay_for_memory_grow() { + unsafe { + hostio::pay_for_memory_grow(100); + } + } + + fn write_result() { + let len = 10000; + let data = vec![0; len]; + unsafe { + hostio::write_result(data.as_ptr(), len); + } + } + + fn read_args() { + let mut data = vec![0; 10000]; + unsafe { + hostio::read_args(data.as_mut_ptr()); + } + } } diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 10a371532d..ef82925b45 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" @@ -23,6 +24,54 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) +func TestHostioWithoutEVMEquivalentCosts(t *testing.T) { + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) + matchSnake := regexp.MustCompile("_[a-z]") + + for _, tc := range []struct { + hostio string + expectedInc uint64 + }{ + {hostio: "read_args", expectedInc: 8400 + 5040}, + {hostio: "write_result", expectedInc: 8400 + (16381+55*(10000-32))*2}, + {hostio: "storage_cache_bytes32", expectedInc: 8400 + (13440-8400)*2}, + {hostio: "msg_reentrant", expectedInc: 8400}, + {hostio: "pay_for_memory_grow", expectedInc: 9320660000}, + } { + t.Run(tc.hostio, func(t *testing.T) { + funcName := matchSnake.ReplaceAllStringFunc(tc.hostio, func(s string) string { + return strings.ToUpper(strings.TrimPrefix(s, "_")) + }) + signature := fmt.Sprintf("%v()", funcName) + data := crypto.Keccak256([]byte(signature))[:4] + + const txGas uint64 = 32_000_000 + tx := builder.L2Info.PrepareTxTo("Owner", &stylusProgram, txGas, nil, data) + + err := builder.L2.Client.SendTransaction(builder.ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + stylusGasUsage, err := stylusHostiosGasUsage(builder.ctx, builder.L2.Client.Client(), tx) + Require(t, err) + + _, ok := stylusGasUsage[tc.hostio] + if !ok { + Fatal(t, "hostio not found in gas usage", "hostio", tc.hostio, "stylusGasUsage", stylusGasUsage) + } + + expectedGas := float64(tc.expectedInc) / 10000 + returnedGas := stylusGasUsage[tc.hostio][0] + if math.Abs(expectedGas-returnedGas) > 1e-9 { + Fatal(t, "unexpected gas usage", "hostio", tc.hostio, "expected", expectedGas, "returned", returnedGas) + } + }) + } +} + func TestProgramSimpleCost(t *testing.T) { builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) From 9dde2d3e95c8d6b9d81ed6df1ce4d411710c6c07 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 15:22:47 -0300 Subject: [PATCH 131/210] Renames test to TestGasUsageOfHostiosThatDontHaveGoodEVMEquivalents --- system_tests/program_gas_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index ef82925b45..b5f1a49a88 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -24,7 +24,7 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) -func TestHostioWithoutEVMEquivalentCosts(t *testing.T) { +func TestGasUsageOfHostiosThatDontHaveGoodEVMEquivalents(t *testing.T) { builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) From 3e9ef9e9f86b61dd77dacf0f22b879df93426aa3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 4 Nov 2024 15:30:42 -0300 Subject: [PATCH 132/210] expectedInc to expectedInk --- system_tests/program_gas_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index b5f1a49a88..fc3c98bec1 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -32,13 +32,13 @@ func TestGasUsageOfHostiosThatDontHaveGoodEVMEquivalents(t *testing.T) { for _, tc := range []struct { hostio string - expectedInc uint64 + expectedInk uint64 }{ - {hostio: "read_args", expectedInc: 8400 + 5040}, - {hostio: "write_result", expectedInc: 8400 + (16381+55*(10000-32))*2}, - {hostio: "storage_cache_bytes32", expectedInc: 8400 + (13440-8400)*2}, - {hostio: "msg_reentrant", expectedInc: 8400}, - {hostio: "pay_for_memory_grow", expectedInc: 9320660000}, + {hostio: "read_args", expectedInk: 8400 + 5040}, + {hostio: "write_result", expectedInk: 8400 + (16381+55*(10000-32))*2}, + {hostio: "storage_cache_bytes32", expectedInk: 8400 + (13440-8400)*2}, + {hostio: "msg_reentrant", expectedInk: 8400}, + {hostio: "pay_for_memory_grow", expectedInk: 9320660000}, } { t.Run(tc.hostio, func(t *testing.T) { funcName := matchSnake.ReplaceAllStringFunc(tc.hostio, func(s string) string { @@ -63,7 +63,7 @@ func TestGasUsageOfHostiosThatDontHaveGoodEVMEquivalents(t *testing.T) { Fatal(t, "hostio not found in gas usage", "hostio", tc.hostio, "stylusGasUsage", stylusGasUsage) } - expectedGas := float64(tc.expectedInc) / 10000 + expectedGas := float64(tc.expectedInk) / 10000 returnedGas := stylusGasUsage[tc.hostio][0] if math.Abs(expectedGas-returnedGas) > 1e-9 { Fatal(t, "unexpected gas usage", "hostio", tc.hostio, "expected", expectedGas, "returned", returnedGas) From 6f43808abcc78a865c7097ea52f4d94abb519926 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 8 Nov 2024 12:20:08 -0300 Subject: [PATCH 133/210] Split TestHostioWithoutEVMEquivalentCosts in multiple tests, test hostios with multiple arguments --- .../stylus/tests/hostio-test/src/main.rs | 36 ++-- system_tests/program_gas_test.go | 158 ++++++++++++++---- 2 files changed, 138 insertions(+), 56 deletions(-) diff --git a/arbitrator/stylus/tests/hostio-test/src/main.rs b/arbitrator/stylus/tests/hostio-test/src/main.rs index cf6e70bf4c..47b46daad2 100644 --- a/arbitrator/stylus/tests/hostio-test/src/main.rs +++ b/arbitrator/stylus/tests/hostio-test/src/main.rs @@ -205,12 +205,6 @@ impl HostioTest { Ok(tx::origin()) } - fn msg_reentrant() { - unsafe { - hostio::msg_reentrant(); - } - } - fn storage_cache_bytes32() { let key = B256::ZERO; let val = B256::ZERO; @@ -219,24 +213,28 @@ impl HostioTest { } } - fn pay_for_memory_grow() { + fn pay_for_memory_grow(pages: U256) { + let pages: u16 = pages.try_into().unwrap(); unsafe { - hostio::pay_for_memory_grow(100); + hostio::pay_for_memory_grow(pages); } } - fn write_result() { - let len = 10000; - let data = vec![0; len]; - unsafe { - hostio::write_result(data.as_ptr(), len); - } + fn write_result_empty() { } - fn read_args() { - let mut data = vec![0; 10000]; - unsafe { - hostio::read_args(data.as_mut_ptr()); - } + fn write_result(size: U256) -> Result> { + let size: usize = size.try_into().unwrap(); + let data = vec![0; size]; + Ok(data) + } + + fn read_args_no_args() { + } + + fn read_args_one_arg(_arg1: U256) { + } + + fn read_args_three_args(_arg1: U256, _arg2: U256, _arg3: U256) { } } diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index fc3c98bec1..8920c840b2 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -2,6 +2,7 @@ package arbtest import ( "context" + "encoding/binary" "fmt" "math" "math/big" @@ -24,52 +25,135 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) -func TestGasUsageOfHostiosThatDontHaveGoodEVMEquivalents(t *testing.T) { +func checkInkUsage( + t *testing.T, + builder *NodeBuilder, + stylusProgram common.Address, + hostio string, + signature string, + params []uint32, + expectedInk uint64, +) { + toU256ByteSlice := func(i uint32) []byte { + arr := make([]byte, 32) + binary.BigEndian.PutUint32(arr[28:32], i) + return arr[:] + } + + testName := fmt.Sprintf("%v_%v", signature, params) + + data := crypto.Keccak256([]byte(signature))[:4] + for _, p := range params { + data = append(data, toU256ByteSlice(p)...) + } + + const txGas uint64 = 32_000_000 + tx := builder.L2Info.PrepareTxTo("Owner", &stylusProgram, txGas, nil, data) + + err := builder.L2.Client.SendTransaction(builder.ctx, tx) + Require(t, err, "testName", testName) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err, "testName", testName) + + stylusGasUsage, err := stylusHostiosGasUsage(builder.ctx, builder.L2.Client.Client(), tx) + Require(t, err, "testName", testName) + + _, ok := stylusGasUsage[hostio] + if !ok { + Fatal(t, "hostio not found in gas usage", "hostio", hostio, "stylusGasUsage", stylusGasUsage, "testName", testName) + } + + if len(stylusGasUsage[hostio]) != 1 { + Fatal(t, "unexpected number of gas usage", "hostio", hostio, "stylusGasUsage", stylusGasUsage, "testName", testName) + } + + expectedGas := float64(expectedInk) / 10000 + returnedGas := stylusGasUsage[hostio][0] + if math.Abs(expectedGas-returnedGas) > 1e-9 { + Fatal(t, "unexpected gas usage", "hostio", hostio, "expected", expectedGas, "returned", returnedGas, "testName", testName) + } +} + +func TestWriteResultGasUsage(t *testing.T) { builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) - matchSnake := regexp.MustCompile("_[a-z]") - for _, tc := range []struct { - hostio string - expectedInk uint64 - }{ - {hostio: "read_args", expectedInk: 8400 + 5040}, - {hostio: "write_result", expectedInk: 8400 + (16381+55*(10000-32))*2}, - {hostio: "storage_cache_bytes32", expectedInk: 8400 + (13440-8400)*2}, - {hostio: "msg_reentrant", expectedInk: 8400}, - {hostio: "pay_for_memory_grow", expectedInk: 9320660000}, - } { - t.Run(tc.hostio, func(t *testing.T) { - funcName := matchSnake.ReplaceAllStringFunc(tc.hostio, func(s string) string { - return strings.ToUpper(strings.TrimPrefix(s, "_")) - }) - signature := fmt.Sprintf("%v()", funcName) - data := crypto.Keccak256([]byte(signature))[:4] + hostio := "write_result" - const txGas uint64 = 32_000_000 - tx := builder.L2Info.PrepareTxTo("Owner", &stylusProgram, txGas, nil, data) + // writeResultEmpty doesn't return any value + signature := "writeResultEmpty()" + expectedInk := 8400 + 16381*2 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) - err := builder.L2.Client.SendTransaction(builder.ctx, tx) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) + // writeResult(uint256) returns an array of uint256 + signature = "writeResult(uint256)" + numberOfElementsInReturnedArray := 10000 + arrayOverhead := 32 + 32 // 32 bytes for the array length and 32 bytes for the array offset + expectedInk = 8400 + (16381+55*(32*numberOfElementsInReturnedArray+arrayOverhead-32))*2 + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) - stylusGasUsage, err := stylusHostiosGasUsage(builder.ctx, builder.L2.Client.Client(), tx) - Require(t, err) + signature = "writeResult(uint256)" + numberOfElementsInReturnedArray = 0 + expectedInk = 8400 + (16381+55*(arrayOverhead-32))*2 + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) +} - _, ok := stylusGasUsage[tc.hostio] - if !ok { - Fatal(t, "hostio not found in gas usage", "hostio", tc.hostio, "stylusGasUsage", stylusGasUsage) - } +func TestReadArgsGasUsage(t *testing.T) { + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) - expectedGas := float64(tc.expectedInk) / 10000 - returnedGas := stylusGasUsage[tc.hostio][0] - if math.Abs(expectedGas-returnedGas) > 1e-9 { - Fatal(t, "unexpected gas usage", "hostio", tc.hostio, "expected", expectedGas, "returned", returnedGas) - } - }) - } + hostio := "read_args" + + signature := "readArgsNoArgs()" + expectedInk := 8400 + 5040 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) + + signature = "readArgsOneArg(uint256)" + signatureOverhead := 4 + expectedInk = 8400 + 5040 + 30*(32+signatureOverhead-32) + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1}, uint64(expectedInk)) + + signature = "readArgsThreeArgs(uint256,uint256,uint256)" + expectedInk = 8400 + 5040 + 30*(3*32+signatureOverhead-32) + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1, 1, 1}, uint64(expectedInk)) +} + +func TestMsgReentrantGasUsage(t *testing.T) { + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) + + hostio := "msg_reentrant" + + signature := "writeResultEmpty()" + expectedInk := 8400 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) +} + +func TestStorageCacheBytes32GasUsage(t *testing.T) { + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) + + hostio := "storage_cache_bytes32" + + signature := "storageCacheBytes32()" + expectedInk := 8400 + (13440-8400)*2 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) +} + +func TestPayForMemoryGrowGasUsage(t *testing.T) { + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) + + hostio := "pay_for_memory_grow" + signature := "payForMemoryGrow(uint256)" + + expectedInk := 9320660000 + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{100}, uint64(expectedInk)) } func TestProgramSimpleCost(t *testing.T) { From c502d68b54277b08c6cdd82101adc81dbe34376a Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 8 Nov 2024 15:27:11 -0300 Subject: [PATCH 134/210] Adds missing t.Parallel() to gas usage hostio tests --- system_tests/program_gas_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 8920c840b2..8c463a2c81 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -75,6 +75,8 @@ func checkInkUsage( } func TestWriteResultGasUsage(t *testing.T) { + t.Parallel() + builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) @@ -100,6 +102,8 @@ func TestWriteResultGasUsage(t *testing.T) { } func TestReadArgsGasUsage(t *testing.T) { + t.Parallel() + builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) @@ -121,6 +125,8 @@ func TestReadArgsGasUsage(t *testing.T) { } func TestMsgReentrantGasUsage(t *testing.T) { + t.Parallel() + builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) @@ -133,6 +139,8 @@ func TestMsgReentrantGasUsage(t *testing.T) { } func TestStorageCacheBytes32GasUsage(t *testing.T) { + t.Parallel() + builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) @@ -145,6 +153,8 @@ func TestStorageCacheBytes32GasUsage(t *testing.T) { } func TestPayForMemoryGrowGasUsage(t *testing.T) { + t.Parallel() + builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) From 2d901690e9ee442d027d7de336e1499222563cb8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 8 Nov 2024 15:41:46 -0300 Subject: [PATCH 135/210] TestPayForMemoryGrowGasUsage with zero pages --- arbitrator/wasm-libraries/user-host-trait/src/lib.rs | 2 +- system_tests/program_gas_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arbitrator/wasm-libraries/user-host-trait/src/lib.rs b/arbitrator/wasm-libraries/user-host-trait/src/lib.rs index 35a4a31347..2f410849fc 100644 --- a/arbitrator/wasm-libraries/user-host-trait/src/lib.rs +++ b/arbitrator/wasm-libraries/user-host-trait/src/lib.rs @@ -936,7 +936,7 @@ pub trait UserHost: GasMeteredMachine { fn pay_for_memory_grow(&mut self, pages: u16) -> Result<(), Self::Err> { if pages == 0 { self.buy_ink(HOSTIO_INK)?; - return Ok(()); + return trace!("pay_for_memory_grow", self, be!(pages), &[]); } let gas_cost = self.evm_api().add_pages(pages); // no sentry needed since the work happens after the hostio self.buy_gas(gas_cost)?; diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 8c463a2c81..264a6603fa 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -164,6 +164,9 @@ func TestPayForMemoryGrowGasUsage(t *testing.T) { expectedInk := 9320660000 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{100}, uint64(expectedInk)) + + expectedInk = 8400 + checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{0}, uint64(expectedInk)) } func TestProgramSimpleCost(t *testing.T) { From 28d71f1bb163583b9ec67d6fa6e1671116f6689c Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 8 Nov 2024 15:43:31 -0300 Subject: [PATCH 136/210] HOSTIO_INK const --- system_tests/program_gas_test.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 264a6603fa..68fd427526 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -25,6 +25,8 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) +const HOSTIO_INK = 8400 + func checkInkUsage( t *testing.T, builder *NodeBuilder, @@ -85,19 +87,19 @@ func TestWriteResultGasUsage(t *testing.T) { // writeResultEmpty doesn't return any value signature := "writeResultEmpty()" - expectedInk := 8400 + 16381*2 + expectedInk := HOSTIO_INK + 16381*2 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) // writeResult(uint256) returns an array of uint256 signature = "writeResult(uint256)" numberOfElementsInReturnedArray := 10000 arrayOverhead := 32 + 32 // 32 bytes for the array length and 32 bytes for the array offset - expectedInk = 8400 + (16381+55*(32*numberOfElementsInReturnedArray+arrayOverhead-32))*2 + expectedInk = HOSTIO_INK + (16381+55*(32*numberOfElementsInReturnedArray+arrayOverhead-32))*2 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) signature = "writeResult(uint256)" numberOfElementsInReturnedArray = 0 - expectedInk = 8400 + (16381+55*(arrayOverhead-32))*2 + expectedInk = HOSTIO_INK + (16381+55*(arrayOverhead-32))*2 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) } @@ -111,16 +113,16 @@ func TestReadArgsGasUsage(t *testing.T) { hostio := "read_args" signature := "readArgsNoArgs()" - expectedInk := 8400 + 5040 + expectedInk := HOSTIO_INK + 5040 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) signature = "readArgsOneArg(uint256)" signatureOverhead := 4 - expectedInk = 8400 + 5040 + 30*(32+signatureOverhead-32) + expectedInk = HOSTIO_INK + 5040 + 30*(32+signatureOverhead-32) checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1}, uint64(expectedInk)) signature = "readArgsThreeArgs(uint256,uint256,uint256)" - expectedInk = 8400 + 5040 + 30*(3*32+signatureOverhead-32) + expectedInk = HOSTIO_INK + 5040 + 30*(3*32+signatureOverhead-32) checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1, 1, 1}, uint64(expectedInk)) } @@ -134,7 +136,7 @@ func TestMsgReentrantGasUsage(t *testing.T) { hostio := "msg_reentrant" signature := "writeResultEmpty()" - expectedInk := 8400 + expectedInk := HOSTIO_INK checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) } @@ -148,7 +150,7 @@ func TestStorageCacheBytes32GasUsage(t *testing.T) { hostio := "storage_cache_bytes32" signature := "storageCacheBytes32()" - expectedInk := 8400 + (13440-8400)*2 + expectedInk := HOSTIO_INK + (13440-HOSTIO_INK)*2 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) } @@ -165,7 +167,7 @@ func TestPayForMemoryGrowGasUsage(t *testing.T) { expectedInk := 9320660000 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{100}, uint64(expectedInk)) - expectedInk = 8400 + expectedInk = HOSTIO_INK checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{0}, uint64(expectedInk)) } From 6307447a2a651be0c91a2b07331e53ef3a6c57c7 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 11 Nov 2024 09:55:33 -0300 Subject: [PATCH 137/210] Fix lint issues --- system_tests/program_gas_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 68fd427526..3260e91d51 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -39,7 +39,7 @@ func checkInkUsage( toU256ByteSlice := func(i uint32) []byte { arr := make([]byte, 32) binary.BigEndian.PutUint32(arr[28:32], i) - return arr[:] + return arr } testName := fmt.Sprintf("%v_%v", signature, params) @@ -88,6 +88,7 @@ func TestWriteResultGasUsage(t *testing.T) { // writeResultEmpty doesn't return any value signature := "writeResultEmpty()" expectedInk := HOSTIO_INK + 16381*2 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) // writeResult(uint256) returns an array of uint256 @@ -95,11 +96,13 @@ func TestWriteResultGasUsage(t *testing.T) { numberOfElementsInReturnedArray := 10000 arrayOverhead := 32 + 32 // 32 bytes for the array length and 32 bytes for the array offset expectedInk = HOSTIO_INK + (16381+55*(32*numberOfElementsInReturnedArray+arrayOverhead-32))*2 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) signature = "writeResult(uint256)" numberOfElementsInReturnedArray = 0 expectedInk = HOSTIO_INK + (16381+55*(arrayOverhead-32))*2 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{uint32(numberOfElementsInReturnedArray)}, uint64(expectedInk)) } From 7c6cf629ebb829cc74eba0d2e48eb4e09d6a778d Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 11 Nov 2024 10:15:30 -0300 Subject: [PATCH 138/210] Fix lint issues --- system_tests/program_gas_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 3260e91d51..81d9a7a5f5 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -117,15 +117,18 @@ func TestReadArgsGasUsage(t *testing.T) { signature := "readArgsNoArgs()" expectedInk := HOSTIO_INK + 5040 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) signature = "readArgsOneArg(uint256)" signatureOverhead := 4 expectedInk = HOSTIO_INK + 5040 + 30*(32+signatureOverhead-32) + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1}, uint64(expectedInk)) signature = "readArgsThreeArgs(uint256,uint256,uint256)" expectedInk = HOSTIO_INK + 5040 + 30*(3*32+signatureOverhead-32) + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{1, 1, 1}, uint64(expectedInk)) } @@ -140,6 +143,7 @@ func TestMsgReentrantGasUsage(t *testing.T) { signature := "writeResultEmpty()" expectedInk := HOSTIO_INK + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) } @@ -154,6 +158,7 @@ func TestStorageCacheBytes32GasUsage(t *testing.T) { signature := "storageCacheBytes32()" expectedInk := HOSTIO_INK + (13440-HOSTIO_INK)*2 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) } @@ -168,9 +173,11 @@ func TestPayForMemoryGrowGasUsage(t *testing.T) { signature := "payForMemoryGrow(uint256)" expectedInk := 9320660000 + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{100}, uint64(expectedInk)) expectedInk = HOSTIO_INK + // #nosec G115 checkInkUsage(t, builder, stylusProgram, hostio, signature, []uint32{0}, uint64(expectedInk)) } From 0abf704f24f61d6fc50e57c4c188d9987e3ebadc Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 14 Nov 2024 23:23:19 +0100 Subject: [PATCH 139/210] Fix the wiring after the giant refactoring in bold repo --- bold | 2 +- staker/bold/bold_staker.go | 47 ++++----------- system_tests/bold_challenge_protocol_test.go | 62 +++++--------------- system_tests/bold_new_challenge_test.go | 35 ++++------- 4 files changed, 37 insertions(+), 109 deletions(-) diff --git a/bold b/bold index 06de67750e..ece8f7a0cf 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 06de67750eac6ea40ba6359df605ce02a7997d5f +Subproject commit ece8f7a0cf26caa6525f32aa409df48b5f572fbd diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index d57d95ee2c..bb9b5dde47 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -9,7 +9,6 @@ import ( "math/big" "time" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -396,49 +395,27 @@ func newBOLDChallengeManager( // The interval at which the manager will attempt to confirm assertions. confirmingInterval := config.AssertionConfirmingInterval - amOpts := []assertions.Opt{ - assertions.WithPostingInterval(postingInterval), - assertions.WithPollingInterval(scanningInterval), - assertions.WithConfirmationInterval(confirmingInterval), - } - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - config.StateProviderConfig.ValidatorName, - nil, // TODO: This is not going to cut it. - BoldModes[config.Mode], - amOpts..., - ) - if err != nil { - return nil, fmt.Errorf("could not create assertion manager: %w", err) - } - - cmOpts := []challengemanager.Opt{ - challengemanager.WithName(config.StateProviderConfig.ValidatorName), - challengemanager.WithMode(BoldModes[config.Mode]), - challengemanager.WithAssertionConfirmingInterval(confirmingInterval), - challengemanager.WithAddress(txOpts.From), - // Configure the validator to track only certain challenges if configured to do so. - challengemanager.WithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName(config.StateProviderConfig.ValidatorName), + challengemanager.StackWithMode(BoldModes[config.Mode]), + challengemanager.StackWithPollingInterval(scanningInterval), + challengemanager.StackWithPostingInterval(postingInterval), + challengemanager.StackWithConfirmationInterval(confirmingInterval), + challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), } if config.API { - // Conditionally enables the BOLD API if configured. - cmOpts = append(cmOpts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.APIHost, config.APIPort), config.APIDBPath)) + apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort) + stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, config.APIDBPath)) } - manager, err := challengemanager.New( - ctx, + + manager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - cmOpts..., + stackOpts..., ) if err != nil { return nil, fmt.Errorf("could not create challenge manager: %w", err) } - provider.UpdateAPIDatabase(manager.Database()) return manager, nil } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 55fb2790b0..5c1e4f7369 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -29,7 +29,6 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -212,8 +211,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp Require(t, l2nodeA.Start(ctx)) Require(t, l2nodeB.Start(ctx)) - chalManagerAddr, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) + chalManagerAddr := assertionChain.SpecChallengeManager() evilOpts := l1info.GetDefaultTransactOpts("EvilAsserter", ctx) l1ChainId, err := l1client.ChainID(ctx) Require(t, err) @@ -388,66 +386,34 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp nil, // Api db ) - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - "honest", - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName("honest"), + challengemanager.StackWithMode(modes.MakeMode), + challengemanager.StackWithPostingInterval(time.Second * 3), + challengemanager.StackWithPollingInterval(time.Second), + challengemanager.StackWithAverageBlockCreationTime(time.Second), + } - manager, err := challengemanager.New( - ctx, + manager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - challengemanager.WithName("honest"), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(l1info.GetDefaultTransactOpts("Asserter", ctx).From), - challengemanager.WithAvgBlockCreationTime(time.Second), + stackOpts..., ) Require(t, err) - assertionManagerB, err := assertions.NewManager( - chainB, - evilProvider, - chainB.Backend(), - chainB.RollupAddress(), - "evil", - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + evilStackOpts := append(stackOpts, challengemanager.StackWithName("evil")) - managerB, err := challengemanager.New( - ctx, + managerB, err := challengemanager.NewChallengeStack( chainB, evilProvider, - assertionManagerB, - assertionChain.RollupAddress(), - challengemanager.WithName("evil"), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(l1info.GetDefaultTransactOpts("EvilAsserter", ctx).From), - challengemanager.WithAvgBlockCreationTime(time.Second), + evilStackOpts..., ) Require(t, err) manager.Start(ctx) managerB.Start(ctx) - chalManager, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) - + chalManager := assertionChain.SpecChallengeManager() filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), l1client) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 0d4090dccb..fab6e7eabf 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -174,9 +173,7 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo // Everything's setup, now just wait for the challenge to complete and ensure the honest party won - chalManager, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) - + chalManager := assertionChain.SpecChallengeManager() filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), builder.L1.Client) Require(t, err) @@ -335,30 +332,18 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB ) Require(t, err) - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - addressName, - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName(addressName), + challengemanager.StackWithMode(modes.MakeMode), + challengemanager.StackWithPostingInterval(time.Second * 3), + challengemanager.StackWithPollingInterval(time.Second), + challengemanager.StackWithAverageBlockCreationTime(time.Second), + } - challengeManager, err := challengemanager.New( - ctx, + challengeManager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - challengemanager.WithName(addressName), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(txOpts.From), - challengemanager.WithAvgBlockCreationTime(time.Second), + stackOpts..., ) Require(t, err) From d7f4134e6b81568f0ac6af16bd725bdf95e9313b Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Fri, 15 Nov 2024 16:38:23 +0100 Subject: [PATCH 140/210] update batch-poster.max-size and batch-poster.max-4844-batch-size descriptions --- arbnode/batch_poster.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 2438d46958..a3256cb78f 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -210,8 +210,8 @@ func DangerousBatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".enable", DefaultBatchPosterConfig.Enable, "enable posting batches to l1") f.Bool(prefix+".disable-dap-fallback-store-data-on-chain", DefaultBatchPosterConfig.DisableDapFallbackStoreDataOnChain, "If unable to batch to DA provider, disable fallback storing data on chain") - f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum batch size") - f.Int(prefix+".max-4844-batch-size", DefaultBatchPosterConfig.Max4844BatchSize, "maximum 4844 blob enabled batch size") + f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum estimated compressed batch size") + f.Int(prefix+".max-4844-batch-size", DefaultBatchPosterConfig.Max4844BatchSize, "maximum estimated compressed 4844 blob enabled batch size") f.Duration(prefix+".max-delay", DefaultBatchPosterConfig.MaxDelay, "maximum batch posting delay") f.Bool(prefix+".wait-for-max-delay", DefaultBatchPosterConfig.WaitForMaxDelay, "wait for the max batch delay, even if the batch is full") f.Duration(prefix+".poll-interval", DefaultBatchPosterConfig.PollInterval, "how long to wait after no batches are ready to be posted before checking again") From 176b04de4f8b636a65c9e36f3d7746e768370b4b Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 15 Nov 2024 10:58:19 -0600 Subject: [PATCH 141/210] Move ArbOS upgrade handling to a bit later in block production --- arbos/block_processor.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arbos/block_processor.go b/arbos/block_processor.go index e654531880..fe0a39d230 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -340,18 +340,6 @@ func ProduceBlockAdvanced( return receipt, result, nil })() - if tx.Type() == types.ArbitrumInternalTxType { - // ArbOS might have upgraded to a new version, so we need to refresh our state - state, err = arbosState.OpenSystemArbosState(statedb, nil, true) - if err != nil { - return nil, nil, err - } - // Update the ArbOS version in the header (if it changed) - extraInfo := types.DeserializeHeaderExtraInformation(header) - extraInfo.ArbOSFormatVersion = state.ArbOSVersion() - extraInfo.UpdateHeaderWithInfo(header) - } - // append the err, even if it is nil hooks.TxErrors = append(hooks.TxErrors, err) @@ -373,6 +361,18 @@ func ProduceBlockAdvanced( continue } + if tx.Type() == types.ArbitrumInternalTxType { + // ArbOS might have upgraded to a new version, so we need to refresh our state + state, err = arbosState.OpenSystemArbosState(statedb, nil, true) + if err != nil { + return nil, nil, err + } + // Update the ArbOS version in the header (if it changed) + extraInfo := types.DeserializeHeaderExtraInformation(header) + extraInfo.ArbOSFormatVersion = state.ArbOSVersion() + extraInfo.UpdateHeaderWithInfo(header) + } + if tx.Type() == types.ArbitrumInternalTxType && result.Err != nil { return nil, nil, fmt.Errorf("failed to apply internal transaction: %w", result.Err) } From 4d61af05d6ab428588934f9dfddbdfb58dd4a5e3 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Mon, 18 Nov 2024 17:00:23 +0530 Subject: [PATCH 142/210] block reexecution should requite init.then-quit --- cmd/nitro/nitro.go | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 50abc414dc..a4536e11d0 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -466,28 +466,29 @@ func mainImpl() int { fatalErrChan := make(chan error, 10) - var blocksReExecutor *blocksreexecutor.BlocksReExecutor if nodeConfig.BlocksReExecutor.Enable && l2BlockChain != nil { - blocksReExecutor, err = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, chainDb, fatalErrChan) + if !nodeConfig.Init.ThenQuit { + log.Error("blocks-reexecutor cannot be enabled without --init.then-quit") + return 1 + } + blocksReExecutor, err := blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, chainDb, fatalErrChan) if err != nil { log.Error("error initializing blocksReExecutor", "err", err) return 1 } - if nodeConfig.Init.ThenQuit { - if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil { - log.Error("error populating stylus target cache", "err", err) - return 1 - } - success := make(chan struct{}) - blocksReExecutor.Start(ctx, success) - deferFuncs = append(deferFuncs, func() { blocksReExecutor.StopAndWait() }) - select { - case err := <-fatalErrChan: - log.Error("shutting down due to fatal error", "err", err) - defer log.Error("shut down due to fatal error", "err", err) - return 1 - case <-success: - } + if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil { + log.Error("error populating stylus target cache", "err", err) + return 1 + } + success := make(chan struct{}) + blocksReExecutor.Start(ctx, success) + deferFuncs = append(deferFuncs, func() { blocksReExecutor.StopAndWait() }) + select { + case err := <-fatalErrChan: + log.Error("shutting down due to fatal error", "err", err) + defer log.Error("shut down due to fatal error", "err", err) + return 1 + case <-success: } } @@ -639,10 +640,6 @@ func mainImpl() int { // remove previous deferFuncs, StopAndWait closes database and blockchain. deferFuncs = []func(){func() { currentNode.StopAndWait() }} } - if blocksReExecutor != nil && !nodeConfig.Init.ThenQuit { - blocksReExecutor.Start(ctx, nil) - deferFuncs = append(deferFuncs, func() { blocksReExecutor.StopAndWait() }) - } sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt, syscall.SIGTERM) From fb5886e836612319c8365f231f203a1e2a544f7f Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Mon, 18 Nov 2024 16:12:25 +0100 Subject: [PATCH 143/210] broadcastclient: check if compression was negotiated when connecting to feed server --- broadcastclient/broadcastclient.go | 30 +++++++++++++++++++++++++----- wsbroadcastserver/utils.go | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index ac684902e4..c4a3743276 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -130,9 +130,10 @@ type BroadcastClient struct { chainId uint64 - // Protects conn and shuttingDown - connMutex sync.Mutex - conn net.Conn + // Protects conn, shuttingDown and compression + connMutex sync.Mutex + conn net.Conn + compression bool retryCount atomic.Int64 @@ -299,7 +300,7 @@ func (bc *BroadcastClient) connect(ctx context.Context, nextSeqNum arbutil.Messa return nil, nil } - conn, br, _, err := timeoutDialer.Dial(ctx, bc.websocketUrl) + conn, br, hs, err := timeoutDialer.Dial(ctx, bc.websocketUrl) if errors.Is(err, ErrIncorrectFeedServerVersion) || errors.Is(err, ErrIncorrectChainId) { return nil, err } @@ -325,6 +326,24 @@ func (bc *BroadcastClient) connect(ctx context.Context, nextSeqNum arbutil.Messa return nil, ErrMissingFeedServerVersion } + compressionNegotiated := false + for _, ext := range hs.Extensions { + if ext.Equal(deflateExt) { + compressionNegotiated = true + break + } + } + if !compressionNegotiated && config.EnableCompression { + log.Warn("Compression was not negotiated when connecting to feed server.") + } + if compressionNegotiated && !config.EnableCompression { + err := conn.Close() + if err != nil { + return nil, fmt.Errorf("error closing connection when negotiated disabled extension: %w", err) + } + return nil, errors.New("error dialing feed server: negotiated compression ws extension, but it is disabled") + } + var earlyFrameData io.Reader if br != nil { // Depending on how long the client takes to read the response, there may be @@ -339,6 +358,7 @@ func (bc *BroadcastClient) connect(ctx context.Context, nextSeqNum arbutil.Messa bc.connMutex.Lock() bc.conn = conn + bc.compression = compressionNegotiated bc.connMutex.Unlock() log.Info("Feed connected", "feedServerVersion", feedServerVersion, "chainId", chainId, "requestedSeqNum", nextSeqNum) @@ -362,7 +382,7 @@ func (bc *BroadcastClient) startBackgroundReader(earlyFrameData io.Reader) { var op ws.OpCode var err error config := bc.config() - msg, op, err = wsbroadcastserver.ReadData(ctx, bc.conn, earlyFrameData, config.Timeout, ws.StateClientSide, config.EnableCompression, flateReader) + msg, op, err = wsbroadcastserver.ReadData(ctx, bc.conn, earlyFrameData, config.Timeout, ws.StateClientSide, bc.compression, flateReader) if err != nil { if bc.isShuttingDown() { return diff --git a/wsbroadcastserver/utils.go b/wsbroadcastserver/utils.go index 1e72915047..40ceb3e5bf 100644 --- a/wsbroadcastserver/utils.go +++ b/wsbroadcastserver/utils.go @@ -137,7 +137,7 @@ func ReadData(ctx context.Context, conn net.Conn, earlyFrameData io.Reader, time var data []byte if msg.IsCompressed() { if !compression { - return nil, 0, errors.New("Received compressed frame even though compression is disabled") + return nil, 0, errors.New("Received compressed frame even though compression extension wasn't negotiated") } flateReader.Reset(&reader) data, err = io.ReadAll(flateReader) From ed396249869738e2dc8d0a6a38f12c9ef26e7a86 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Mon, 18 Nov 2024 16:13:56 +0100 Subject: [PATCH 144/210] use t.Run in broadcastclient tests --- broadcastclient/broadcastclient_test.go | 53 ++++++++++--------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index d9f7443af5..0d9b8443e6 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -30,43 +30,30 @@ import ( "github.com/offchainlabs/nitro/wsbroadcastserver" ) -func TestReceiveMessagesWithoutCompression(t *testing.T) { +func TestReceiveMessages(t *testing.T) { t.Parallel() - testReceiveMessages(t, false, false, false, false) -} - -func TestReceiveMessagesWithCompression(t *testing.T) { - t.Parallel() - testReceiveMessages(t, true, true, false, false) -} - -func TestReceiveMessagesWithServerOptionalCompression(t *testing.T) { - t.Parallel() - testReceiveMessages(t, true, true, false, false) -} - -func TestReceiveMessagesWithServerOnlyCompression(t *testing.T) { - t.Parallel() - testReceiveMessages(t, false, true, false, false) -} - -func TestReceiveMessagesWithClientOnlyCompression(t *testing.T) { - t.Parallel() - testReceiveMessages(t, true, false, false, false) -} - -func TestReceiveMessagesWithRequiredCompression(t *testing.T) { - t.Parallel() - testReceiveMessages(t, true, true, true, false) -} - -func TestReceiveMessagesWithRequiredCompressionButClientDisabled(t *testing.T) { - t.Parallel() - testReceiveMessages(t, false, true, true, true) + t.Run("withoutCompression", func(t *testing.T) { + testReceiveMessages(t, false, false, false, false) + }) + t.Run("withServerOptionalCompression", func(t *testing.T) { + testReceiveMessages(t, true, true, false, false) + }) + t.Run("withServerOnlyCompression", func(t *testing.T) { + testReceiveMessages(t, false, true, false, false) + }) + t.Run("withClientOnlyCompression", func(t *testing.T) { + testReceiveMessages(t, true, false, false, false) + }) + t.Run("withRequiredCompression", func(t *testing.T) { + testReceiveMessages(t, true, true, true, false) + }) + t.Run("withRequiredCompressionButClientDisabled", func(t *testing.T) { + testReceiveMessages(t, false, true, true, true) + }) } func testReceiveMessages(t *testing.T, clientCompression bool, serverCompression bool, serverRequire bool, expectNoMessagesReceived bool) { - t.Helper() + t.Parallel() ctx, cancel := context.WithCancel(context.Background()) defer cancel() From 683d190027780f063f9ed79451f2a96d18dda89d Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 18 Nov 2024 21:08:09 +0100 Subject: [PATCH 145/210] Merge branch 'master' into bold-review --- .golangci.yml | 8 + arbcompress/native.go | 1 + arbitrator/bench/src/bin.rs | 8 +- arbitrator/prover/test-cases/dynamic.wat | 2 +- arbitrator/prover/test-cases/go/main.go | 2 +- arbitrator/prover/test-cases/link.wat | 2 +- arbitrator/prover/test-cases/user.wat | 12 + arbnode/api.go | 1 + arbnode/batch_poster.go | 11 +- arbnode/dataposter/data_poster.go | 25 ++- arbnode/dataposter/dataposter_test.go | 6 +- arbnode/dataposter/dbstorage/storage.go | 1 + .../externalsignertest/externalsignertest.go | 1 + arbnode/dataposter/redis/redisstorage.go | 3 +- arbnode/dataposter/storage/storage.go | 1 + arbnode/dataposter/storage_test.go | 6 +- arbnode/delayed.go | 6 +- arbnode/delayed_seq_reorg_test.go | 1 + arbnode/delayed_sequencer.go | 3 +- arbnode/inbox_reader.go | 88 +++++++- arbnode/inbox_test.go | 17 +- arbnode/inbox_tracker.go | 20 +- arbnode/inbox_tracker_test.go | 1 + arbnode/maintenance.go | 4 +- arbnode/message_pruner.go | 8 +- arbnode/message_pruner_test.go | 1 + arbnode/node.go | 1 + arbnode/redislock/redis.go | 6 +- .../resourcemanager/resource_management.go | 3 +- arbnode/sequencer_inbox.go | 8 +- arbnode/sync_monitor.go | 4 +- arbnode/transaction_streamer.go | 3 +- arbos/activate_test.go | 1 + arbos/addressSet/addressSet.go | 1 + arbos/addressSet/addressSet_test.go | 5 +- arbos/addressTable/addressTable.go | 1 + arbos/addressTable/addressTable_test.go | 1 + arbos/arbosState/arbosstate_test.go | 1 + arbos/arbosState/initialization_test.go | 2 +- arbos/arbosState/initialize.go | 21 +- arbos/arbostypes/messagewithmeta.go | 1 + arbos/block_processor.go | 12 +- arbos/blockhash/blockhash.go | 1 + arbos/blockhash/blockhash_test.go | 1 + arbos/burn/burn.go | 1 + arbos/engine.go | 11 +- arbos/extra_transaction_checks.go | 1 + arbos/incomingmessage_test.go | 1 + arbos/internal_tx.go | 7 +- arbos/l1pricing/batchPoster.go | 1 + arbos/l1pricing/batchPoster_test.go | 1 + arbos/l1pricing/l1PricingOldVersions.go | 1 + arbos/l1pricing/l1pricing.go | 14 +- arbos/l1pricing/l1pricing_test.go | 1 + arbos/l1pricing_test.go | 12 +- arbos/l2pricing/model.go | 1 + arbos/merkleAccumulator/merkleAccumulator.go | 1 + arbos/parse_l2.go | 1 + arbos/programs/api.go | 8 +- arbos/programs/native.go | 2 + arbos/programs/native_api.go | 2 + arbos/programs/params.go | 1 + arbos/programs/programs.go | 1 + arbos/programs/testcompile.go | 1 + arbos/queue_test.go | 1 - arbos/retryable_test.go | 10 +- arbos/retryables/retryable.go | 1 + arbos/storage/queue.go | 4 +- arbos/storage/storage.go | 1 + arbos/storage/storage_test.go | 1 + arbos/tx_processor.go | 26 ++- arbos/util/retryable_encoding_test.go | 9 +- arbos/util/storage_cache.go | 3 +- arbos/util/storage_cache_test.go | 4 +- arbos/util/tracing.go | 42 +++- arbos/util/transfer.go | 64 +++--- arbos/util/util.go | 1 + arbstate/daprovider/reader.go | 1 + arbstate/inbox_fuzz_test.go | 1 + arbutil/hash_test.go | 3 +- blocks_reexecutor/blocks_reexecutor.go | 181 +++++++++++---- broadcastclient/broadcastclient.go | 1 + broadcastclient/broadcastclient_test.go | 21 +- broadcaster/backlog/backlog.go | 9 +- broadcaster/message/message.go | 1 + .../message/message_serialization_test.go | 1 + cmd/conf/chain.go | 3 +- cmd/conf/database.go | 3 +- cmd/conf/init.go | 6 +- .../data_availability_check.go | 4 +- cmd/datool/datool.go | 2 +- cmd/dbconv/dbconv/config.go | 3 +- cmd/dbconv/dbconv/dbconv.go | 1 + cmd/dbconv/main.go | 4 +- cmd/deploy/deploy.go | 12 +- cmd/genericconf/config.go | 5 +- cmd/genericconf/filehandler_test.go | 7 +- cmd/genericconf/liveconfig.go | 1 + cmd/genericconf/logging.go | 3 +- cmd/genericconf/loglevel.go | 2 +- cmd/genericconf/pprof.go | 1 - cmd/nitro-val/config.go | 5 +- cmd/nitro/config_test.go | 6 +- cmd/nitro/init.go | 5 + cmd/nitro/init_test.go | 4 +- cmd/nitro/nitro.go | 6 +- cmd/pruning/pruning.go | 1 + cmd/replay/db.go | 1 + .../rediscoordinator/redis_coordinator.go | 3 +- .../seq-coordinator-manager.go | 6 +- cmd/util/confighelpers/configuration.go | 1 + das/aggregator_test.go | 4 +- das/cache_storage_service.go | 7 +- das/chain_fetch_das.go | 4 +- das/das.go | 3 +- das/dasRpcClient.go | 5 +- das/dasRpcServer.go | 1 - das/dastree/dastree.go | 1 + das/dastree/dastree_test.go | 1 + das/db_storage_service.go | 4 +- das/fallback_storage_service.go | 1 + das/fallback_storage_service_test.go | 1 + das/google_cloud_storage_service_test.go | 9 +- das/key_utils.go | 1 + das/local_file_storage_service.go | 6 +- das/memory_backed_storage_service.go | 1 + das/panic_wrapper.go | 1 + das/reader_aggregator_strategies_test.go | 7 +- das/redis_storage_service.go | 10 +- das/redis_storage_service_test.go | 1 + das/redundant_storage_service.go | 1 + das/restful_client.go | 1 + das/restful_server.go | 1 + das/rpc_aggregator.go | 7 +- das/rpc_test.go | 1 + das/s3_storage_service.go | 8 +- das/signature_verifier.go | 1 + das/simple_das_reader_aggregator.go | 4 +- das/storage_service.go | 1 + das/syncing_fallback_storage.go | 4 +- das/util.go | 1 + deploy/deploy.go | 1 + execution/gethexec/api.go | 1 + execution/gethexec/block_recorder.go | 36 +-- execution/gethexec/blockchain.go | 1 + execution/gethexec/executionengine.go | 5 +- execution/gethexec/forwarder.go | 5 +- execution/gethexec/node.go | 4 +- execution/gethexec/sequencer.go | 11 +- execution/gethexec/stylus_tracer.go | 45 ++-- execution/gethexec/sync_monitor.go | 3 +- execution/gethexec/tx_pre_checker.go | 4 +- execution/gethexec/wasmstorerebuilder.go | 1 + execution/interface.go | 1 + execution/nodeInterface/NodeInterface.go | 17 +- execution/nodeInterface/NodeInterfaceDebug.go | 1 + execution/nodeInterface/virtual-contracts.go | 21 +- gethhook/geth-hook.go | 1 + go.mod | 18 +- go.sum | 206 ++---------------- linters/koanf/handlers.go | 6 +- linters/linters.go | 3 +- precompiles/ArbAddressTable_test.go | 1 + precompiles/ArbAggregator_test.go | 1 + precompiles/ArbGasInfo.go | 1 + precompiles/ArbGasInfo_test.go | 1 + precompiles/ArbInfo.go | 1 + precompiles/ArbOwner.go | 6 +- precompiles/ArbOwner_test.go | 6 +- precompiles/ArbRetryableTx.go | 2 +- precompiles/ArbRetryableTx_test.go | 6 +- precompiles/ArbSys.go | 1 + precompiles/ArbWasm.go | 1 + precompiles/precompile.go | 14 +- precompiles/precompile_test.go | 6 +- precompiles/wrapper.go | 6 +- pubsub/common.go | 3 +- pubsub/consumer.go | 6 +- pubsub/producer.go | 8 +- pubsub/pubsub_test.go | 6 +- relay/relay_stress_test.go | 1 + scripts/check-build.sh | 15 +- scripts/split-val-entry.sh | 2 +- staker/block_validator.go | 4 +- staker/block_validator_schema.go | 1 + staker/bold/bold_staker.go | 15 +- staker/bold/bold_state_provider.go | 9 +- staker/execution_challenge_bakend.go | 1 + staker/legacy/block_challenge_backend.go | 1 + staker/legacy/challenge_manager.go | 2 +- staker/legacy/challenge_test.go | 1 + staker/legacy/l1_validator.go | 10 +- staker/legacy/staker.go | 6 +- .../multi_protocol/multi_protocol_staker.go | 4 +- staker/rollup_watcher.go | 8 +- staker/stateless_block_validator.go | 7 +- staker/validatorwallet/contract.go | 1 + staker/validatorwallet/eoa.go | 1 + staker/validatorwallet/noop.go | 1 + statetransfer/data.go | 1 + statetransfer/interface.go | 1 + statetransfer/jsondatareader.go | 4 + statetransfer/memdatareader.go | 4 + system_tests/aliasing_test.go | 1 + system_tests/batch_poster_test.go | 1 + system_tests/block_hash_test.go | 1 + system_tests/blocks_reexecutor_test.go | 9 +- system_tests/bloom_test.go | 1 + system_tests/bold_challenge_protocol_test.go | 36 +-- system_tests/bold_state_provider_test.go | 7 +- system_tests/common_test.go | 54 +++-- system_tests/conditionaltx_test.go | 1 + system_tests/contract_tx_test.go | 1 + system_tests/das_test.go | 2 +- system_tests/db_conversion_test.go | 1 + system_tests/debugapi_test.go | 1 + system_tests/delayedinbox_test.go | 1 + system_tests/estimation_test.go | 1 + system_tests/forwarder_test.go | 2 + system_tests/infra_fee_test.go | 1 + system_tests/initialization_test.go | 1 + system_tests/log_subscription_test.go | 1 + system_tests/meaningless_reorg_test.go | 1 + system_tests/nodeinterface_test.go | 1 + system_tests/outbox_test.go | 1 + system_tests/precompile_doesnt_revert_test.go | 1 + system_tests/precompile_fuzz_test.go | 1 + system_tests/precompile_test.go | 1 + system_tests/program_gas_test.go | 34 +-- system_tests/program_norace_test.go | 1 + system_tests/program_recursive_test.go | 1 + system_tests/program_test.go | 26 +++ system_tests/pruning_test.go | 1 + system_tests/recreatestate_rpc_test.go | 1 + system_tests/retryable_test.go | 2 +- system_tests/seq_coordinator_test.go | 13 +- system_tests/seq_nonce_test.go | 1 + system_tests/seq_pause_test.go | 1 + system_tests/seq_reject_test.go | 5 +- system_tests/seqcompensation_test.go | 1 + system_tests/seqfeed_test.go | 14 +- system_tests/state_fuzz_test.go | 1 + system_tests/staterecovery_test.go | 1 + system_tests/stylus_trace_test.go | 4 +- system_tests/stylus_tracer_test.go | 4 +- system_tests/test_info.go | 6 +- system_tests/triedb_race_test.go | 1 + system_tests/twonodeslong_test.go | 4 +- system_tests/unsupported_txtypes_test.go | 3 +- system_tests/validation_mock_test.go | 3 +- system_tests/wrap_transaction_test.go | 1 + util/arbmath/bits.go | 3 +- util/arbmath/math_test.go | 1 + util/blobs/blobs.go | 4 +- util/containers/syncmap.go | 25 ++- util/contracts/address_verifier.go | 1 + util/dbutil/dbutil.go | 3 +- util/headerreader/blob_client.go | 7 +- util/headerreader/blob_client_test.go | 3 +- util/headerreader/header_reader.go | 4 +- util/jsonapi/preimages_test.go | 1 + util/merkletree/merkleAccumulator_test.go | 1 + util/merkletree/merkleEventProof.go | 1 + util/merkletree/merkleEventProof_test.go | 1 + util/merkletree/merkleTree.go | 1 + util/redisutil/test_redis.go | 1 + util/rpcclient/rpcclient_test.go | 6 +- util/sharedmetrics/sharedmetrics.go | 1 + util/signature/sign_verify.go | 4 +- util/stopwaiter/stopwaiter.go | 1 + util/stopwaiter/stopwaiter_test.go | 1 + util/testhelpers/env/env.go | 2 +- util/testhelpers/port.go | 11 + util/testhelpers/port_test.go | 12 +- util/testhelpers/testhelpers.go | 3 +- validator/client/redis/producer.go | 6 +- validator/client/validation_client.go | 16 +- validator/execution_state.go | 1 + validator/interface.go | 1 + validator/server_api/json.go | 2 +- validator/server_arb/execution_run.go | 2 +- validator/server_arb/execution_run_test.go | 1 + validator/server_arb/machine.go | 61 +++++- validator/server_arb/machine_loader.go | 1 + validator/server_arb/machine_test.go | 94 ++++++++ validator/server_arb/mock_machine.go | 1 + validator/server_arb/nitro_machine.go | 2 + validator/server_arb/prover_interface.go | 2 + validator/server_arb/validator_spawner.go | 10 +- validator/server_common/machine_loader.go | 1 + validator/server_common/valrun.go | 1 + validator/server_jit/jit_machine.go | 1 + validator/server_jit/machine_loader.go | 1 + validator/server_jit/spawner.go | 3 +- validator/validation_entry.go | 1 + validator/valnode/redis/consumer.go | 4 +- validator/valnode/redis/consumer_test.go | 1 + validator/valnode/valnode.go | 5 +- wavmio/stub.go | 1 + wsbroadcastserver/clientconnection.go | 9 +- wsbroadcastserver/connectionlimiter.go | 3 +- wsbroadcastserver/utils.go | 3 +- wsbroadcastserver/wsbroadcastserver.go | 1 + 303 files changed, 1350 insertions(+), 768 deletions(-) create mode 100644 validator/server_arb/machine_test.go diff --git a/.golangci.yml b/.golangci.yml index 0594670137..8e597f950a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,7 @@ linters: enable: - asciicheck # check for non-ascii characters - errorlint # enure error wrapping is safely done + - gci # keep imports sorted deterministically - gocritic # check for certain simplifications - gofmt # ensure code is formatted - gosec # check for security concerns @@ -30,6 +31,13 @@ linters-settings: # check-type-assertions: true + gci: + sections: + - standard + - default + - prefix(github.com/ethereum/go-ethereum) + - prefix(github.com/offchainlabs) + gocritic: disabled-tags: - experimental diff --git a/arbcompress/native.go b/arbcompress/native.go index f7b8f0b8e0..943d21e89e 100644 --- a/arbcompress/native.go +++ b/arbcompress/native.go @@ -12,6 +12,7 @@ package arbcompress #include "arbitrator.h" */ import "C" + import ( "errors" "fmt" diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 60a7036e2b..f9bd85ce53 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -18,13 +18,13 @@ use prover::prepare::prepare_machine; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { - /// Path to a preimages text file + /// Path to a preimages json file #[arg(short, long)] - preimages_path: PathBuf, + json_inputs: PathBuf, /// Path to a machine.wavm.br #[arg(short, long)] - machine_path: PathBuf, + binary: PathBuf, } fn main() -> eyre::Result<()> { @@ -33,7 +33,7 @@ fn main() -> eyre::Result<()> { println!("Running benchmark with always merkleize feature on"); for step_size in step_sizes { - let mut machine = prepare_machine(args.preimages_path.clone(), args.machine_path.clone())?; + let mut machine = prepare_machine(args.json_inputs.clone(), args.binary.clone())?; let _ = machine.hash(); let mut hash_times = vec![]; let mut step_times = vec![]; diff --git a/arbitrator/prover/test-cases/dynamic.wat b/arbitrator/prover/test-cases/dynamic.wat index 8771bde87c..5de0dbdca1 100644 --- a/arbitrator/prover/test-cases/dynamic.wat +++ b/arbitrator/prover/test-cases/dynamic.wat @@ -12,7 +12,7 @@ ;; WAVM Module hash (data (i32.const 0x000) - "\a1\49\cf\81\13\ff\9c\95\f2\c8\c2\a1\42\35\75\36\7d\e8\6d\d4\22\d8\71\14\bb\9e\a4\7b\af\53\5d\d7") ;; user + "\ae\87\91\cf\6a\c4\55\ff\28\06\b9\55\d5\a7\36\e8\1b\c7\91\f7\93\8a\22\a4\08\23\25\16\37\01\48\25") ;; user (func $start (local $user i32) (local $internals i32) ;; link in user.wat i32.const 0 diff --git a/arbitrator/prover/test-cases/go/main.go b/arbitrator/prover/test-cases/go/main.go index 1f81553af2..b959454d26 100644 --- a/arbitrator/prover/test-cases/go/main.go +++ b/arbitrator/prover/test-cases/go/main.go @@ -73,7 +73,7 @@ const BYTES_PER_FIELD_ELEMENT = 32 var BLS_MODULUS, _ = new(big.Int).SetString("52435875175126190479447740508185965837690552500527637822603658699938581184513", 10) -var stylusModuleHash = common.HexToHash("a149cf8113ff9c95f2c8c2a1423575367de86dd422d87114bb9ea47baf535dd7") // user.wat +var stylusModuleHash = common.HexToHash("ae8791cf6ac455ff2806b955d5a736e81bc791f7938a22a40823251637014825") // user.wat func callStylusProgram(recurse int) { evmData := programs.EvmData{} diff --git a/arbitrator/prover/test-cases/link.wat b/arbitrator/prover/test-cases/link.wat index ef15326481..85490a40b1 100644 --- a/arbitrator/prover/test-cases/link.wat +++ b/arbitrator/prover/test-cases/link.wat @@ -30,7 +30,7 @@ (data (i32.const 0x140) "\47\f7\4f\9c\21\51\4f\52\24\ea\d3\37\5c\bf\a9\1b\1a\5f\ef\22\a5\2a\60\30\c5\52\18\90\6b\b1\51\e5") ;; iops (data (i32.const 0x160) - "\a1\49\cf\81\13\ff\9c\95\f2\c8\c2\a1\42\35\75\36\7d\e8\6d\d4\22\d8\71\14\bb\9e\a4\7b\af\53\5d\d7") ;; user + "\ae\87\91\cf\6a\c4\55\ff\28\06\b9\55\d5\a7\36\e8\1b\c7\91\f7\93\8a\22\a4\08\23\25\16\37\01\48\25") ;; user (data (i32.const 0x180) "\ee\47\08\f6\47\b2\10\88\1f\89\86\e7\e3\79\6b\b2\77\43\f1\4e\ee\cf\45\4a\9b\7c\d7\c4\5b\63\b6\d7") ;; return diff --git a/arbitrator/prover/test-cases/user.wat b/arbitrator/prover/test-cases/user.wat index 9ecb4dcc45..694d2f3ed8 100644 --- a/arbitrator/prover/test-cases/user.wat +++ b/arbitrator/prover/test-cases/user.wat @@ -22,6 +22,12 @@ i32.const 0xFFFFFF i32.load ) + (func $infinite_loop (result i32) + (loop $loop + br $loop + ) + unreachable + ) (func (export "user_entrypoint") (param $args_len i32) (result i32) ;; this func uses $args_len to select which func to call @@ -43,6 +49,12 @@ (then (call $out_of_bounds) (return)) ) + ;; reverts due to an out-of-gas error + (i32.eq (local.get $args_len) (i32.const 4)) + (if + (then (call $infinite_loop) (return)) + ) + (i32.eq (local.get $args_len) (i32.const 32)) (if (then (call $storage_load) (return)) diff --git a/arbnode/api.go b/arbnode/api.go index 2dabd41bff..55dc92434f 100644 --- a/arbnode/api.go +++ b/arbnode/api.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/validator" diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index 46a0160b71..a3256cb78f 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -203,11 +203,15 @@ func (c *BatchPosterConfig) Validate() error { type BatchPosterConfigFetcher func() *BatchPosterConfig +func DangerousBatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { + f.Bool(prefix+".allow-posting-first-batch-when-sequencer-message-count-mismatch", DefaultBatchPosterConfig.Dangerous.AllowPostingFirstBatchWhenSequencerMessageCountMismatch, "allow posting the first batch even if sequence number doesn't match chain (useful after force-inclusion)") +} + func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".enable", DefaultBatchPosterConfig.Enable, "enable posting batches to l1") f.Bool(prefix+".disable-dap-fallback-store-data-on-chain", DefaultBatchPosterConfig.DisableDapFallbackStoreDataOnChain, "If unable to batch to DA provider, disable fallback storing data on chain") - f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum batch size") - f.Int(prefix+".max-4844-batch-size", DefaultBatchPosterConfig.Max4844BatchSize, "maximum 4844 blob enabled batch size") + f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum estimated compressed batch size") + f.Int(prefix+".max-4844-batch-size", DefaultBatchPosterConfig.Max4844BatchSize, "maximum estimated compressed 4844 blob enabled batch size") f.Duration(prefix+".max-delay", DefaultBatchPosterConfig.MaxDelay, "maximum batch posting delay") f.Bool(prefix+".wait-for-max-delay", DefaultBatchPosterConfig.WaitForMaxDelay, "wait for the max batch delay, even if the batch is full") f.Duration(prefix+".poll-interval", DefaultBatchPosterConfig.PollInterval, "how long to wait after no batches are ready to be posted before checking again") @@ -229,6 +233,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { redislock.AddConfigOptions(prefix+".redis-lock", f) dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfig) genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultBatchPosterConfig.ParentChainWallet.Pathname) + DangerousBatchPosterConfigAddOptions(prefix+".dangerous", f) } var DefaultBatchPosterConfig = BatchPosterConfig{ @@ -280,7 +285,7 @@ var TestBatchPosterConfig = BatchPosterConfig{ DASRetentionPeriod: daprovider.DefaultDASRetentionPeriod, GasRefunderAddress: "", ExtraBatchGas: 10_000, - Post4844Blobs: true, + Post4844Blobs: false, IgnoreBlobPrice: false, DataPoster: dataposter.TestDataPosterConfig, ParentChainWallet: DefaultBatchPosterL1WalletConfig, diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 85edc15b9c..4bcc14ffab 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -20,10 +20,15 @@ import ( "time" "github.com/Knetic/govaluate" + "github.com/holiman/uint256" + "github.com/redis/go-redis/v9" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/misc/eip4844" + "github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/ethclient" @@ -34,9 +39,10 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/signer/core/apitypes" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbnode/dataposter/dbstorage" "github.com/offchainlabs/nitro/arbnode/dataposter/noop" + redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis" "github.com/offchainlabs/nitro/arbnode/dataposter/slice" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/arbmath" @@ -45,10 +51,6 @@ import ( "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/stopwaiter" - "github.com/redis/go-redis/v9" - "github.com/spf13/pflag" - - redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis" ) var ( @@ -1101,7 +1103,7 @@ func (p *DataPoster) updateBalance(ctx context.Context) error { return nil } -const maxConsecutiveIntermittentErrors = 10 +const maxConsecutiveIntermittentErrors = 20 func (p *DataPoster) maybeLogError(err error, tx *storage.QueuedTransaction, msg string) { nonce := tx.FullTx.Nonce() @@ -1110,10 +1112,17 @@ func (p *DataPoster) maybeLogError(err error, tx *storage.QueuedTransaction, msg return } logLevel := log.Error - if errors.Is(err, storage.ErrStorageRace) { + isStorageRace := errors.Is(err, storage.ErrStorageRace) + if isStorageRace || strings.Contains(err.Error(), txpool.ErrFutureReplacePending.Error()) { p.errorCount[nonce]++ if p.errorCount[nonce] <= maxConsecutiveIntermittentErrors { - logLevel = log.Debug + if isStorageRace { + logLevel = log.Debug + } else { + logLevel = log.Info + } + } else if isStorageRace { + logLevel = log.Warn } } else { delete(p.errorCount, nonce) diff --git a/arbnode/dataposter/dataposter_test.go b/arbnode/dataposter/dataposter_test.go index 7bf0f86e6f..dc5df1a6c4 100644 --- a/arbnode/dataposter/dataposter_test.go +++ b/arbnode/dataposter/dataposter_test.go @@ -9,6 +9,9 @@ import ( "time" "github.com/Knetic/govaluate" + "github.com/google/go-cmp/cmp" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -17,8 +20,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" - "github.com/google/go-cmp/cmp" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbnode/dataposter/dbstorage/storage.go b/arbnode/dataposter/dbstorage/storage.go index 6a6cd3cfa4..88989cf757 100644 --- a/arbnode/dataposter/dbstorage/storage.go +++ b/arbnode/dataposter/dbstorage/storage.go @@ -11,6 +11,7 @@ import ( "strconv" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/dbutil" ) diff --git a/arbnode/dataposter/externalsignertest/externalsignertest.go b/arbnode/dataposter/externalsignertest/externalsignertest.go index 554defc764..51ccec1903 100644 --- a/arbnode/dataposter/externalsignertest/externalsignertest.go +++ b/arbnode/dataposter/externalsignertest/externalsignertest.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/signer/core/apitypes" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/arbnode/dataposter/redis/redisstorage.go b/arbnode/dataposter/redis/redisstorage.go index b54abf618b..364f9fc85c 100644 --- a/arbnode/dataposter/redis/redisstorage.go +++ b/arbnode/dataposter/redis/redisstorage.go @@ -9,9 +9,10 @@ import ( "errors" "fmt" + "github.com/redis/go-redis/v9" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/signature" - "github.com/redis/go-redis/v9" ) // Storage implements redis sorted set backed storage. It does not support diff --git a/arbnode/dataposter/storage/storage.go b/arbnode/dataposter/storage/storage.go index 8e5a7e1798..dfd4c2745c 100644 --- a/arbnode/dataposter/storage/storage.go +++ b/arbnode/dataposter/storage/storage.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbnode/dataposter/storage_test.go b/arbnode/dataposter/storage_test.go index c6316caea7..cd4e4babae 100644 --- a/arbnode/dataposter/storage_test.go +++ b/arbnode/dataposter/storage_test.go @@ -9,12 +9,14 @@ import ( "path" "testing" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" + "github.com/offchainlabs/nitro/arbnode/dataposter/dbstorage" "github.com/offchainlabs/nitro/arbnode/dataposter/redis" "github.com/offchainlabs/nitro/arbnode/dataposter/slice" diff --git a/arbnode/delayed.go b/arbnode/delayed.go index 354fa671b3..f28a9617a3 100644 --- a/arbnode/delayed.go +++ b/arbnode/delayed.go @@ -334,7 +334,11 @@ func (b *DelayedBridge) parseMessage(ctx context.Context, ethLog types.Log) (*bi if err != nil { return nil, nil, err } - return parsedLog.MessageNum, args["messageData"].([]byte), nil + dataBytes, ok := args["messageData"].([]byte) + if !ok { + return nil, nil, errors.New("messageData not a byte array") + } + return parsedLog.MessageNum, dataBytes, nil default: return nil, nil, errors.New("unexpected log type") } diff --git a/arbnode/delayed_seq_reorg_test.go b/arbnode/delayed_seq_reorg_test.go index 699eb3e8f6..f821d71e63 100644 --- a/arbnode/delayed_seq_reorg_test.go +++ b/arbnode/delayed_seq_reorg_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/arbnode/delayed_sequencer.go b/arbnode/delayed_sequencer.go index b29a66dd05..abd24dbd12 100644 --- a/arbnode/delayed_sequencer.go +++ b/arbnode/delayed_sequencer.go @@ -10,10 +10,11 @@ import ( "math/big" "sync" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/execution" diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 98104b2ea7..50893ca392 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -13,10 +13,11 @@ import ( "sync/atomic" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" @@ -229,6 +230,26 @@ func (r *InboxReader) CaughtUp() chan struct{} { return r.caughtUpChan } +type lazyHashLogging struct { + f func() common.Hash +} + +func (l lazyHashLogging) String() string { + return l.f().String() +} + +func (l lazyHashLogging) TerminalString() string { + return l.f().TerminalString() +} + +func (l lazyHashLogging) MarshalText() ([]byte, error) { + return l.f().MarshalText() +} + +func (l lazyHashLogging) Format(s fmt.State, c rune) { + l.f().Format(s, c) +} + func (r *InboxReader) run(ctx context.Context, hadError bool) error { readMode := r.config().ReadMode from, err := r.getNextBlockToRead(ctx) @@ -334,6 +355,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestDelayedCount < checkingDelayedCount { + log.Debug("Expecting to find delayed messages", "checkingDelayedCount", checkingDelayedCount, "ourLatestDelayedCount", ourLatestDelayedCount, "currentHeight", currentHeight) checkingDelayedCount = ourLatestDelayedCount missingDelayed = true } else if ourLatestDelayedCount > checkingDelayedCount { @@ -354,6 +376,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbDelayedAcc != l1DelayedAcc { + log.Debug("Latest delayed accumulator mismatch", "delayedSeqNum", checkingDelayedSeqNum, "dbDelayedAcc", dbDelayedAcc, "l1DelayedAcc", l1DelayedAcc) reorgingDelayed = true } } @@ -371,6 +394,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if ourLatestBatchCount < checkingBatchCount { + log.Debug("Expecting to find sequencer batches", "checkingBatchCount", checkingBatchCount, "ourLatestBatchCount", ourLatestBatchCount, "currentHeight", currentHeight) checkingBatchCount = ourLatestBatchCount missingSequencer = true } else if ourLatestBatchCount > checkingBatchCount && config.HardReorg { @@ -390,6 +414,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { return err } if dbBatchAcc != l1BatchAcc { + log.Debug("Latest sequencer batch accumulator mismatch", "batchSeqNum", checkingBatchSeqNum, "dbBatchAcc", dbBatchAcc, "l1BatchAcc", l1BatchAcc) reorgingSequencer = true } } @@ -432,6 +457,15 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if to.Cmp(currentHeight) > 0 { to.Set(currentHeight) } + log.Debug( + "Looking up messages", + "from", from.String(), + "to", to.String(), + "missingDelayed", missingDelayed, + "missingSequencer", missingSequencer, + "reorgingDelayed", reorgingDelayed, + "reorgingSequencer", reorgingSequencer, + ) sequencerBatches, err := r.sequencerInbox.LookupBatchesInRange(ctx, from, to) if err != nil { return err @@ -457,6 +491,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if len(sequencerBatches) > 0 { missingSequencer = false reorgingSequencer = false + var havePrevAcc common.Hash firstBatch := sequencerBatches[0] if firstBatch.SequenceNumber > 0 { haveAcc, err := r.tracker.GetBatchAcc(firstBatch.SequenceNumber - 1) @@ -467,7 +502,10 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc != firstBatch.BeforeInboxAcc { reorgingSequencer = true } + havePrevAcc = haveAcc } + readLastAcc := sequencerBatches[len(sequencerBatches)-1].AfterInboxAcc + var duplicateBatches int if !reorgingSequencer { // Skip any batches we already have in the database for len(sequencerBatches) > 0 { @@ -482,6 +520,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc == batch.AfterInboxAcc { // Skip this batch, as we already have it in the database sequencerBatches = sequencerBatches[1:] + duplicateBatches++ } else { // The first batch AfterInboxAcc matches, but this batch doesn't, // so we'll successfully reorg it when we hit the addMessages @@ -489,7 +528,18 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } } } + log.Debug( + "Found sequencer batches", + "firstSequenceNumber", firstBatch.SequenceNumber, + "newBatchesCount", len(sequencerBatches), + "duplicateBatches", duplicateBatches, + "reorgingSequencer", reorgingSequencer, + "readBeforeAcc", firstBatch.BeforeInboxAcc, + "haveBeforeAcc", havePrevAcc, + "readLastAcc", readLastAcc, + ) } else if missingSequencer && to.Cmp(currentHeight) >= 0 { + log.Debug("Didn't find expected sequencer batches", "from", from, "to", to, "currentHeight", currentHeight) // We were missing sequencer batches but didn't find any. // This must mean that the sequencer batches are in the past. reorgingSequencer = true @@ -504,6 +554,7 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { if err != nil { return err } + var havePrevAcc common.Hash if beforeCount > 0 { haveAcc, err := r.tracker.GetDelayedAcc(beforeCount - 1) if errors.Is(err, AccumulatorNotFoundErr) { @@ -513,14 +564,27 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if haveAcc != beforeAcc { reorgingDelayed = true } + havePrevAcc = haveAcc } + log.Debug( + "Found delayed messages", + "firstSequenceNumber", beforeCount, + "count", len(delayedMessages), + "reorgingDelayed", reorgingDelayed, + "readBeforeAcc", beforeAcc, + "haveBeforeAcc", havePrevAcc, + "readLastAcc", lazyHashLogging{func() common.Hash { + // Only compute this if we need to log it, as it's somewhat expensive + return delayedMessages[len(delayedMessages)-1].AfterInboxAcc() + }}, + ) } else if missingDelayed && to.Cmp(currentHeight) >= 0 { + log.Debug("Didn't find expected delayed messages", "from", from, "to", to, "currentHeight", currentHeight) // We were missing delayed messages but didn't find any. // This must mean that the delayed messages are in the past. reorgingDelayed = true } - log.Trace("looking up messages", "from", from.String(), "to", to.String(), "missingDelayed", missingDelayed, "missingSequencer", missingSequencer, "reorgingDelayed", reorgingDelayed, "reorgingSequencer", reorgingSequencer) if !reorgingDelayed && !reorgingSequencer && (len(delayedMessages) != 0 || len(sequencerBatches) != 0) { delayedMismatch, err := r.addMessages(ctx, sequencerBatches, delayedMessages) if err != nil { @@ -535,14 +599,6 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { storeSeenBatchCount() } } - if reorgingDelayed || reorgingSequencer { - from, err = r.getPrevBlockForReorg(from) - if err != nil { - return err - } - } else { - from = arbmath.BigAddByUint(to, 1) - } // #nosec G115 haveMessages := uint64(len(delayedMessages) + len(sequencerBatches)) if haveMessages <= (config.TargetMessagesRead / 2) { @@ -556,6 +612,14 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error { } else if blocksToFetch > config.MaxBlocksToRead { blocksToFetch = config.MaxBlocksToRead } + if reorgingDelayed || reorgingSequencer { + from, err = r.getPrevBlockForReorg(from, blocksToFetch) + if err != nil { + return err + } + } else { + from = arbmath.BigAddByUint(to, 1) + } } if !readAnyBatches { @@ -579,11 +643,11 @@ func (r *InboxReader) addMessages(ctx context.Context, sequencerBatches []*Seque return false, nil } -func (r *InboxReader) getPrevBlockForReorg(from *big.Int) (*big.Int, error) { +func (r *InboxReader) getPrevBlockForReorg(from *big.Int, maxBlocksBackwards uint64) (*big.Int, error) { if from.Cmp(r.firstMessageBlock) <= 0 { return nil, errors.New("can't get older messages") } - newFrom := arbmath.BigSub(from, big.NewInt(10)) + newFrom := arbmath.BigSub(from, new(big.Int).SetUint64(maxBlocksBackwards)) if newFrom.Cmp(r.firstMessageBlock) < 0 { newFrom = new(big.Int).Set(r.firstMessageBlock) } diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index e588ef399b..32023877b7 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -11,23 +11,22 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/env" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos" ) type execClientWrapper struct { diff --git a/arbnode/inbox_tracker.go b/arbnode/inbox_tracker.go index 7686fe413f..d5afa142d8 100644 --- a/arbnode/inbox_tracker.go +++ b/arbnode/inbox_tracker.go @@ -697,22 +697,26 @@ func (t *InboxTracker) AddSequencerBatches(ctx context.Context, client *ethclien for _, batch := range batches { if batch.SequenceNumber != pos { - return errors.New("unexpected batch sequence number") + return fmt.Errorf("unexpected batch sequence number %v expected %v", batch.SequenceNumber, pos) } if nextAcc != batch.BeforeInboxAcc { - return errors.New("previous batch accumulator mismatch") + return fmt.Errorf("previous batch accumulator %v mismatch expected %v", batch.BeforeInboxAcc, nextAcc) } if batch.AfterDelayedCount > 0 { haveDelayedAcc, err := t.GetDelayedAcc(batch.AfterDelayedCount - 1) - if errors.Is(err, AccumulatorNotFoundErr) { - // We somehow missed a referenced delayed message; go back and look for it - return delayedMessagesMismatch - } - if err != nil { + notFound := errors.Is(err, AccumulatorNotFoundErr) + if err != nil && !notFound { return err } - if haveDelayedAcc != batch.AfterDelayedAcc { + if notFound || haveDelayedAcc != batch.AfterDelayedAcc { + log.Debug( + "Delayed message accumulator doesn't match sequencer batch", + "batch", batch.SequenceNumber, + "delayedPosition", batch.AfterDelayedCount-1, + "haveDelayedAcc", haveDelayedAcc, + "batchDelayedAcc", batch.AfterDelayedAcc, + ) // We somehow missed a delayed message reorg; go back and look for it return delayedMessagesMismatch } diff --git a/arbnode/inbox_tracker_test.go b/arbnode/inbox_tracker_test.go index 582b334aee..82d380b03c 100644 --- a/arbnode/inbox_tracker_test.go +++ b/arbnode/inbox_tracker_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/arbnode/maintenance.go b/arbnode/maintenance.go index 7397229c2e..5e4e56b577 100644 --- a/arbnode/maintenance.go +++ b/arbnode/maintenance.go @@ -10,12 +10,14 @@ import ( "strings" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode/redislock" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // Regularly runs db compaction if configured diff --git a/arbnode/message_pruner.go b/arbnode/message_pruner.go index e1bc72632b..840a15f328 100644 --- a/arbnode/message_pruner.go +++ b/arbnode/message_pruner.go @@ -11,14 +11,14 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" - - flag "github.com/spf13/pflag" ) type MessagePruner struct { @@ -112,6 +112,10 @@ func (m *MessagePruner) prune(ctx context.Context, count arbutil.MessageIndex, g } msgCount := endBatchMetadata.MessageCount delayedCount := endBatchMetadata.DelayedMessageCount + if delayedCount > 0 { + // keep an extra delayed message for the inbox reader to use + delayedCount-- + } return m.deleteOldMessagesFromDB(ctx, msgCount, delayedCount) } diff --git a/arbnode/message_pruner_test.go b/arbnode/message_pruner_test.go index e64bb4f838..8e6b744430 100644 --- a/arbnode/message_pruner_test.go +++ b/arbnode/message_pruner_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbnode/node.go b/arbnode/node.go index 3613b986ac..506e1f0ab0 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbnode/resourcemanager" diff --git a/arbnode/redislock/redis.go b/arbnode/redislock/redis.go index de9508323a..075ff60c09 100644 --- a/arbnode/redislock/redis.go +++ b/arbnode/redislock/redis.go @@ -11,10 +11,12 @@ import ( "sync/atomic" "time" - "github.com/ethereum/go-ethereum/log" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" flag "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/stopwaiter" ) type Simple struct { diff --git a/arbnode/resourcemanager/resource_management.go b/arbnode/resourcemanager/resource_management.go index 249b689443..462b38c578 100644 --- a/arbnode/resourcemanager/resource_management.go +++ b/arbnode/resourcemanager/resource_management.go @@ -14,10 +14,11 @@ import ( "strings" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/node" - "github.com/spf13/pflag" ) var ( diff --git a/arbnode/sequencer_inbox.go b/arbnode/sequencer_inbox.go index 81146ed46e..9dae7cfb8d 100644 --- a/arbnode/sequencer_inbox.go +++ b/arbnode/sequencer_inbox.go @@ -16,9 +16,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) @@ -124,7 +124,11 @@ func (m *SequencerInboxBatch) getSequencerData(ctx context.Context, client *ethc if err != nil { return nil, err } - return args["data"].([]byte), nil + dataBytes, ok := args["data"].([]byte) + if !ok { + return nil, errors.New("args[\"data\"] not a byte array") + } + return dataBytes, nil case batchDataSeparateEvent: var numberAsHash common.Hash binary.BigEndian.PutUint64(numberAsHash[(32-8):], m.SequenceNumber) diff --git a/arbnode/sync_monitor.go b/arbnode/sync_monitor.go index 5ab1ede2d6..629068c4fb 100644 --- a/arbnode/sync_monitor.go +++ b/arbnode/sync_monitor.go @@ -5,10 +5,12 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type SyncMonitor struct { diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 38b1c003db..1a961ebd3f 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -8,6 +8,7 @@ import ( "context" "encoding/binary" "encoding/json" + "errors" "fmt" "math/big" "reflect" @@ -17,8 +18,6 @@ import ( "testing" "time" - "errors" - flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" diff --git a/arbos/activate_test.go b/arbos/activate_test.go index a89a38639a..b723c37aa6 100644 --- a/arbos/activate_test.go +++ b/arbos/activate_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/addressSet/addressSet.go b/arbos/addressSet/addressSet.go index 156f36e7e7..4bb87e614d 100644 --- a/arbos/addressSet/addressSet.go +++ b/arbos/addressSet/addressSet.go @@ -9,6 +9,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/addressSet/addressSet_test.go b/arbos/addressSet/addressSet_test.go index d32e07a546..4997359dcf 100644 --- a/arbos/addressSet/addressSet_test.go +++ b/arbos/addressSet/addressSet_test.go @@ -8,13 +8,14 @@ import ( "math/rand" "testing" - "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/params" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/arbos/addressTable/addressTable.go b/arbos/addressTable/addressTable.go index 6ae271060d..608883c34d 100644 --- a/arbos/addressTable/addressTable.go +++ b/arbos/addressTable/addressTable.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/addressTable/addressTable_test.go b/arbos/addressTable/addressTable_test.go index 6b06ed3406..873d5a4d1c 100644 --- a/arbos/addressTable/addressTable_test.go +++ b/arbos/addressTable/addressTable_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/arbos/arbosState/arbosstate_test.go b/arbos/arbosState/arbosstate_test.go index ef63c23386..440598991c 100644 --- a/arbos/arbosState/arbosstate_test.go +++ b/arbos/arbosState/arbosstate_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 5e605b8bd2..5154606e3d 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" @@ -66,7 +67,6 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - triedbConfig := cacheConfig.TriedbConfig() stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil) Require(t, err) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 427bdc3087..29cb75b758 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -9,16 +9,19 @@ import ( "regexp" "sort" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/l2pricing" @@ -96,6 +99,16 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, log.Crit("failed to open the ArbOS state", "error", err) } + chainOwner, err := initData.GetChainOwner() + if err != nil { + return common.Hash{}, err + } + if chainOwner != (common.Address{}) { + err = arbosState.ChainOwners().Add(chainOwner) + if err != nil { + return common.Hash{}, err + } + } addrTable := arbosState.AddressTable() addrTableSize, err := addrTable.Size() if err != nil { @@ -159,7 +172,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, if err != nil { return common.Hash{}, err } - statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance)) + statedb.SetBalance(account.Addr, uint256.MustFromBig(account.EthBalance), tracing.BalanceChangeUnspecified) statedb.SetNonce(account.Addr, account.Nonce) if account.ContractInfo != nil { statedb.SetCode(account.Addr, account.ContractInfo.Code) @@ -190,7 +203,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, return err } if r.Timeout <= currentTimestamp { - statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue)) + statedb.AddBalance(r.Beneficiary, uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified) continue } retryablesList = append(retryablesList, r) @@ -209,7 +222,7 @@ func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, addr := r.To to = &addr } - statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue)) + statedb.AddBalance(retryables.RetryableEscrowAddress(r.Id), uint256.MustFromBig(r.Callvalue), tracing.BalanceChangeUnspecified) _, err := rs.CreateRetryable(r.Id, r.Timeout, r.From, to, r.Callvalue, r.Beneficiary, r.Calldata) if err != nil { return err diff --git a/arbos/arbostypes/messagewithmeta.go b/arbos/arbostypes/messagewithmeta.go index 79b7c4f9d2..a3bc167526 100644 --- a/arbos/arbostypes/messagewithmeta.go +++ b/arbos/arbostypes/messagewithmeta.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbos/block_processor.go b/arbos/block_processor.go index 19fc36b351..e654531880 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -10,12 +10,6 @@ import ( "math" "math/big" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/arbostypes" - "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/ethereum/go-ethereum/arbitrum_types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -25,6 +19,12 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) // set by the precompile module, to avoid a package dependence cycle diff --git a/arbos/blockhash/blockhash.go b/arbos/blockhash/blockhash.go index 34c907207c..ff29bbca9a 100644 --- a/arbos/blockhash/blockhash.go +++ b/arbos/blockhash/blockhash.go @@ -8,6 +8,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/blockhash/blockhash_test.go b/arbos/blockhash/blockhash_test.go index bf3ee5ee11..c7cc04d966 100644 --- a/arbos/blockhash/blockhash_test.go +++ b/arbos/blockhash/blockhash_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/arbos/burn/burn.go b/arbos/burn/burn.go index 7d30ad12ec..c94f6bec2f 100644 --- a/arbos/burn/burn.go +++ b/arbos/burn/burn.go @@ -7,6 +7,7 @@ import ( "fmt" glog "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/engine.go b/arbos/engine.go index 0014e8ab96..a4aa9c46a9 100644 --- a/arbos/engine.go +++ b/arbos/engine.go @@ -48,16 +48,15 @@ func (e Engine) Prepare(chain consensus.ChainHeaderReader, header *types.Header) return nil } -func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { - FinalizeBlock(header, txs, state, chain.Config()) +func (e Engine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) { + FinalizeBlock(header, body.Transactions, state, chain.Config()) } -func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, - uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { +func (e Engine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) { - e.Finalize(chain, header, state, txs, uncles, withdrawals) + e.Finalize(chain, header, state, body) - block := types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) + block := types.NewBlock(header, body.Transactions, nil, receipts, trie.NewStackTrie(nil)) return block, nil } diff --git a/arbos/extra_transaction_checks.go b/arbos/extra_transaction_checks.go index 0f970c9925..480058cb0f 100644 --- a/arbos/extra_transaction_checks.go +++ b/arbos/extra_transaction_checks.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" ) diff --git a/arbos/incomingmessage_test.go b/arbos/incomingmessage_test.go index 2933f6a719..22aba05bce 100644 --- a/arbos/incomingmessage_test.go +++ b/arbos/incomingmessage_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" ) diff --git a/arbos/internal_tx.go b/arbos/internal_tx.go index 9832ac8005..64dede6290 100644 --- a/arbos/internal_tx.go +++ b/arbos/internal_tx.go @@ -8,15 +8,14 @@ import ( "fmt" "math/big" - "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) func InternalTxStartBlock( diff --git a/arbos/l1pricing/batchPoster.go b/arbos/l1pricing/batchPoster.go index a3428c441c..5975e95d0f 100644 --- a/arbos/l1pricing/batchPoster.go +++ b/arbos/l1pricing/batchPoster.go @@ -9,6 +9,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/addressSet" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/l1pricing/batchPoster_test.go b/arbos/l1pricing/batchPoster_test.go index 4e9b8565c0..3263ffca81 100644 --- a/arbos/l1pricing/batchPoster_test.go +++ b/arbos/l1pricing/batchPoster_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/l1pricing/l1PricingOldVersions.go b/arbos/l1pricing/l1PricingOldVersions.go index 821d743e7d..1377351af3 100644 --- a/arbos/l1pricing/l1PricingOldVersions.go +++ b/arbos/l1pricing/l1PricingOldVersions.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/util" am "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/l1pricing/l1pricing.go b/arbos/l1pricing/l1pricing.go index 392bf36d37..34ab6ed523 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -10,20 +10,18 @@ import ( "math/big" "sync/atomic" - "github.com/ethereum/go-ethereum/crypto" - + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbcompress" - "github.com/offchainlabs/nitro/util/arbmath" - am "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/types" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" + am "github.com/offchainlabs/nitro/util/arbmath" ) type L1PricingState struct { diff --git a/arbos/l1pricing/l1pricing_test.go b/arbos/l1pricing/l1pricing_test.go index b301c94257..b842c26db7 100644 --- a/arbos/l1pricing/l1pricing_test.go +++ b/arbos/l1pricing/l1pricing_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" ) diff --git a/arbos/l1pricing_test.go b/arbos/l1pricing_test.go index 6f9e3ecb35..da5f577c5b 100644 --- a/arbos/l1pricing_test.go +++ b/arbos/l1pricing_test.go @@ -7,18 +7,20 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" - "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos/burn" ) type l1PricingTest struct { @@ -172,7 +174,7 @@ func _testL1PricingFundsDue(t *testing.T, testParams *l1PricingTest, expectedRes // create some fake collection balanceAdded := new(big.Int).SetUint64(testParams.fundsCollectedPerSecond * 3) unitsAdded := testParams.unitsPerSecond * 3 - evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded)) + evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(balanceAdded), tracing.BalanceChangeUnspecified) err = l1p.SetL1FeesAvailable(balanceAdded) Require(t, err) err = l1p.SetUnitsSinceUpdate(unitsAdded) diff --git a/arbos/l2pricing/model.go b/arbos/l2pricing/model.go index 476effa8aa..367e8b6e1a 100644 --- a/arbos/l2pricing/model.go +++ b/arbos/l2pricing/model.go @@ -7,6 +7,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/merkleAccumulator/merkleAccumulator.go b/arbos/merkleAccumulator/merkleAccumulator.go index e62303e5fd..0d51602c02 100644 --- a/arbos/merkleAccumulator/merkleAccumulator.go +++ b/arbos/merkleAccumulator/merkleAccumulator.go @@ -6,6 +6,7 @@ package merkleAccumulator import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/parse_l2.go b/arbos/parse_l2.go index 06722e4063..cd926f47bf 100644 --- a/arbos/parse_l2.go +++ b/arbos/parse_l2.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/programs/api.go b/arbos/programs/api.go index 3e59031b2d..d8f12ffbd3 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -4,12 +4,14 @@ package programs import ( + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" am "github.com/offchainlabs/nitro/util/arbmath" @@ -254,7 +256,9 @@ func newApiClosures( return memoryModel.GasCost(pages, open, ever) } captureHostio := func(name string, args, outs []byte, startInk, endInk uint64) { - tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) + if tracingInfo.Tracer != nil && tracingInfo.Tracer.CaptureStylusHostio != nil { + tracingInfo.Tracer.CaptureStylusHostio(name, args, outs, startInk, endInk) + } tracingInfo.CaptureEVMTraceForHostio(name, args, outs, startInk, endInk) } diff --git a/arbos/programs/native.go b/arbos/programs/native.go index 725b302ac0..f162704995 100644 --- a/arbos/programs/native.go +++ b/arbos/programs/native.go @@ -18,6 +18,7 @@ typedef uint64_t u64; typedef size_t usize; */ import "C" + import ( "errors" "fmt" @@ -30,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" diff --git a/arbos/programs/native_api.go b/arbos/programs/native_api.go index 6cecb8ef63..ab15800ef9 100644 --- a/arbos/programs/native_api.go +++ b/arbos/programs/native_api.go @@ -22,6 +22,7 @@ void handleReqWrap(usize api, u32 req_type, RustSlice *data, u64 *out_cost, GoSl } */ import "C" + import ( "runtime" "sync" @@ -29,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/arbos/programs/params.go b/arbos/programs/params.go index a0b8acd95c..9b219737d9 100644 --- a/arbos/programs/params.go +++ b/arbos/programs/params.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" am "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/programs/programs.go b/arbos/programs/programs.go index 06ff4137da..06ba6ead8c 100644 --- a/arbos/programs/programs.go +++ b/arbos/programs/programs.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" gethParams "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/addressSet" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/arbos/programs/testcompile.go b/arbos/programs/testcompile.go index 615b0f3f72..8a4e38444a 100644 --- a/arbos/programs/testcompile.go +++ b/arbos/programs/testcompile.go @@ -20,6 +20,7 @@ typedef size_t usize; void handleReqWrap(usize api, u32 req_type, RustSlice *data, u64 *out_cost, GoSliceData *out_result, GoSliceData *out_raw_data); */ import "C" + import ( "fmt" "os" diff --git a/arbos/queue_test.go b/arbos/queue_test.go index ff993a233f..75d60b82c3 100644 --- a/arbos/queue_test.go +++ b/arbos/queue_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/arbos/retryable_test.go b/arbos/retryable_test.go index 2eccaea6c2..b2989de331 100644 --- a/arbos/retryable_test.go +++ b/arbos/retryable_test.go @@ -9,17 +9,17 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/params" ) func TestOpenNonexistentRetryable(t *testing.T) { diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index 5938244782..23ba2458ff 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/storage/queue.go b/arbos/storage/queue.go index 9c02dc1ee7..3c852a5743 100644 --- a/arbos/storage/queue.go +++ b/arbos/storage/queue.go @@ -4,9 +4,9 @@ package storage import ( - "github.com/offchainlabs/nitro/arbos/util" - "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/arbos/util" ) type Queue struct { diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index bc16491af0..63db8ee928 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" "github.com/ethereum/go-ethereum/triedb/pathdb" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/storage/storage_test.go b/arbos/storage/storage_test.go index b2e8bdb2ea..dd2c40b8f0 100644 --- a/arbos/storage/storage_test.go +++ b/arbos/storage/storage_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/tx_processor.go b/arbos/tx_processor.go index d6c35339f6..aec08b15b5 100644 --- a/arbos/tx_processor.go +++ b/arbos/tx_processor.go @@ -9,22 +9,20 @@ import ( "math/big" "github.com/holiman/uint256" - "github.com/offchainlabs/nitro/arbos/l1pricing" - - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/util/arbmath" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + glog "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/arbosState" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/vm" - glog "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/l1pricing" + "github.com/offchainlabs/nitro/arbos/retryables" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/arbmath" ) var arbosAddress = types.ArbosAddress @@ -153,13 +151,17 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r } evm.IncrementDepth() // fake a call from := p.msg.From - tracer.CaptureStart(evm, from, *p.msg.To, false, p.msg.Data, p.msg.GasLimit, p.msg.Value) + if tracer.OnEnter != nil { + tracer.OnEnter(evm.Depth(), byte(vm.CALL), from, *p.msg.To, p.msg.Data, p.msg.GasLimit, p.msg.Value) + } tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingDuringEVM) p.state = arbosState.OpenSystemArbosStateOrPanic(evm.StateDB, tracingInfo, false) return func() { - tracer.CaptureEnd(nil, p.state.Burner.Burned(), nil) + if tracer.OnExit != nil { + tracer.OnExit(evm.Depth(), nil, p.state.Burner.Burned(), nil, false) + } evm.DecrementDepth() // fake the return to the first faked call tracingInfo = util.NewTracingInfo(evm, from, *p.msg.To, util.TracingAfterEVM) diff --git a/arbos/util/retryable_encoding_test.go b/arbos/util/retryable_encoding_test.go index d7a5480138..b74983ed0b 100644 --- a/arbos/util/retryable_encoding_test.go +++ b/arbos/util/retryable_encoding_test.go @@ -10,16 +10,15 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" ) func TestRetryableEncoding(t *testing.T) { diff --git a/arbos/util/storage_cache.go b/arbos/util/storage_cache.go index 9573d1ffc7..a9be5fe870 100644 --- a/arbos/util/storage_cache.go +++ b/arbos/util/storage_cache.go @@ -4,8 +4,9 @@ package util import ( - "github.com/ethereum/go-ethereum/common" "slices" + + "github.com/ethereum/go-ethereum/common" ) type storageCacheEntry struct { diff --git a/arbos/util/storage_cache_test.go b/arbos/util/storage_cache_test.go index 9fd452851d..0ba2c5285e 100644 --- a/arbos/util/storage_cache_test.go +++ b/arbos/util/storage_cache_test.go @@ -7,8 +7,10 @@ import ( "slices" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/google/go-cmp/cmp" + + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/arbos/util/tracing.go b/arbos/util/tracing.go index c4a7168977..f092d32c2d 100644 --- a/arbos/util/tracing.go +++ b/arbos/util/tracing.go @@ -7,10 +7,12 @@ import ( "encoding/binary" "math/big" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" - "github.com/holiman/uint256" ) type TracingScenario uint64 @@ -22,7 +24,7 @@ const ( ) type TracingInfo struct { - Tracer vm.EVMLogger + Tracer *tracing.Hooks Scenario TracingScenario Contract *vm.Contract Depth int @@ -59,8 +61,10 @@ func (info *TracingInfo) RecordStorageGet(key common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key)), Contract: info.Contract, } - tracer.CaptureState(0, vm.SLOAD, 0, 0, scope, []byte{}, info.Depth, nil) - } else { + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.SLOAD), 0, 0, scope, []byte{}, info.Depth, nil) + } + } else if tracer.CaptureArbitrumStorageGet != nil { tracer.CaptureArbitrumStorageGet(key, info.Depth, info.Scenario == TracingBeforeEVM) } } @@ -73,8 +77,10 @@ func (info *TracingInfo) RecordStorageSet(key, value common.Hash) { Stack: TracingStackFromArgs(HashToUint256(key), HashToUint256(value)), Contract: info.Contract, } - tracer.CaptureState(0, vm.SSTORE, 0, 0, scope, []byte{}, info.Depth, nil) - } else { + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.SSTORE), 0, 0, scope, []byte{}, info.Depth, nil) + } + } else if tracer.CaptureArbitrumStorageSet != nil { tracer.CaptureArbitrumStorageSet(key, value, info.Depth, info.Scenario == TracingBeforeEVM) } } @@ -98,8 +104,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.CALL, 0, 0, scope, []byte{}, depth, nil) - tracer.CaptureEnter(vm.INVALID, from, to, input, 0, amount) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.CALL), 0, 0, scope, []byte{}, depth, nil) + } + if tracer.OnEnter != nil { + tracer.OnEnter(depth, byte(vm.CALL), from, to, input, gas, amount) + } retScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -109,8 +119,12 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.RETURN, 0, 0, retScope, []byte{}, depth+1, nil) - tracer.CaptureExit(nil, 0, nil) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.RETURN), 0, 0, retScope, []byte{}, depth+1, nil) + } + if tracer.OnExit != nil { + tracer.OnExit(depth, nil, 0, nil, false) + } popScope := &vm.ScopeContext{ Memory: vm.NewMemory(), @@ -119,7 +133,9 @@ func (info *TracingInfo) MockCall(input []byte, gas uint64, from, to common.Addr ), Contract: contract, } - tracer.CaptureState(0, vm.POP, 0, 0, popScope, []byte{}, depth, nil) + if tracer.OnOpcode != nil { + tracer.OnOpcode(0, byte(vm.POP), 0, 0, popScope, []byte{}, depth, nil) + } } func (info *TracingInfo) CaptureEVMTraceForHostio(name string, args, outs []byte, startInk, endInk uint64) { @@ -533,7 +549,9 @@ func (info *TracingInfo) captureState(op vm.OpCode, gas uint64, cost uint64, mem Stack: TracingStackFromArgs(stack...), Contract: info.Contract, } - info.Tracer.CaptureState(0, op, gas, cost, scope, []byte{}, info.Depth, nil) + if info.Tracer.OnOpcode != nil { + info.Tracer.OnOpcode(0, byte(op), gas, cost, scope, []byte{}, info.Depth, nil) + } } func lenToBytes(data []byte) []byte { diff --git a/arbos/util/transfer.go b/arbos/util/transfer.go index e293ef13c3..37437e01f6 100644 --- a/arbos/util/transfer.go +++ b/arbos/util/transfer.go @@ -9,10 +9,13 @@ import ( "fmt" "math/big" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/util/arbmath" ) @@ -28,20 +31,6 @@ func TransferBalance( if amount.Sign() < 0 { panic(fmt.Sprintf("Tried to transfer negative amount %v from %v to %v", amount, from, to)) } - if from != nil { - balance := evm.StateDB.GetBalance(*from) - if arbmath.BigLessThan(balance.ToBig(), amount) { - return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) - } - evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount)) - if evm.Context.ArbOSVersion >= 30 { - // ensure the from account is "touched" for EIP-161 - evm.StateDB.AddBalance(*from, &uint256.Int{}) - } - } - if to != nil { - evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount)) - } if tracer := evm.Config.Tracer; tracer != nil { if evm.Depth() != 0 && scenario != TracingDuringEVM { // A non-zero depth implies this transfer is occurring inside EVM execution @@ -50,24 +39,41 @@ func TransferBalance( } if scenario != TracingDuringEVM { - tracer.CaptureArbitrumTransfer(evm, from, to, amount, scenario == TracingBeforeEVM, purpose) - return nil - } + if tracer.CaptureArbitrumTransfer != nil { + tracer.CaptureArbitrumTransfer(from, to, amount, scenario == TracingBeforeEVM, purpose) + } + } else { + fromCopy := from + toCopy := to + if fromCopy == nil { + fromCopy = &common.Address{} + } + if toCopy == nil { + toCopy = &common.Address{} + } - if from == nil { - from = &common.Address{} + info := &TracingInfo{ + Tracer: evm.Config.Tracer, + Scenario: scenario, + Contract: vm.NewContract(addressHolder{*toCopy}, addressHolder{*fromCopy}, uint256.NewInt(0), 0), + Depth: evm.Depth(), + } + info.MockCall([]byte{}, 0, *fromCopy, *toCopy, amount) } - if to == nil { - to = &common.Address{} + } + if from != nil { + balance := evm.StateDB.GetBalance(*from) + if arbmath.BigLessThan(balance.ToBig(), amount) { + return fmt.Errorf("%w: addr %v have %v want %v", vm.ErrInsufficientBalance, *from, balance, amount) } - - info := &TracingInfo{ - Tracer: evm.Config.Tracer, - Scenario: scenario, - Contract: vm.NewContract(addressHolder{*to}, addressHolder{*from}, uint256.NewInt(0), 0), - Depth: evm.Depth(), + evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) + if evm.Context.ArbOSVersion >= 30 { + // ensure the from account is "touched" for EIP-161 + evm.StateDB.AddBalance(*from, &uint256.Int{}, tracing.BalanceChangeTransfer) } - info.MockCall([]byte{}, 0, *from, *to, amount) + } + if to != nil { + evm.StateDB.AddBalance(*to, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) } return nil } diff --git a/arbos/util/util.go b/arbos/util/util.go index 69d90171a0..abb7135757 100644 --- a/arbos/util/util.go +++ b/arbos/util/util.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbstate/daprovider/reader.go b/arbstate/daprovider/reader.go index 488b156454..e2fd884340 100644 --- a/arbstate/daprovider/reader.go +++ b/arbstate/daprovider/reader.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/blobs" ) diff --git a/arbstate/inbox_fuzz_test.go b/arbstate/inbox_fuzz_test.go index 5ede321810..5a77b7e298 100644 --- a/arbstate/inbox_fuzz_test.go +++ b/arbstate/inbox_fuzz_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/arbutil/hash_test.go b/arbutil/hash_test.go index 2b93353d08..4b39bf328e 100644 --- a/arbutil/hash_test.go +++ b/arbutil/hash_test.go @@ -4,8 +4,9 @@ import ( "bytes" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/google/go-cmp/cmp" + + "github.com/ethereum/go-ethereum/common" ) func TestSlotAddress(t *testing.T) { diff --git a/blocks_reexecutor/blocks_reexecutor.go b/blocks_reexecutor/blocks_reexecutor.go index b43999a7db..d074457626 100644 --- a/blocks_reexecutor/blocks_reexecutor.go +++ b/blocks_reexecutor/blocks_reexecutor.go @@ -7,24 +7,33 @@ import ( "math/rand" "runtime" "strings" + "sync" + + flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/arbitrum" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/triedb" + "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type Config struct { - Enable bool `koanf:"enable"` - Mode string `koanf:"mode"` - StartBlock uint64 `koanf:"start-block"` - EndBlock uint64 `koanf:"end-block"` - Room int `koanf:"room"` - BlocksPerThread uint64 `koanf:"blocks-per-thread"` + Enable bool `koanf:"enable"` + Mode string `koanf:"mode"` + StartBlock uint64 `koanf:"start-block"` + EndBlock uint64 `koanf:"end-block"` + Room int `koanf:"room"` + MinBlocksPerThread uint64 `koanf:"min-blocks-per-thread"` + TrieCleanLimit int `koanf:"trie-clean-limit"` } func (c *Config) Validate() error { @@ -48,10 +57,11 @@ var DefaultConfig = Config{ } var TestConfig = Config{ - Enable: true, - Mode: "full", - Room: runtime.NumCPU(), - BlocksPerThread: 10, + Enable: true, + Mode: "full", + Room: runtime.NumCPU(), + MinBlocksPerThread: 10, + TrieCleanLimit: 600, } func ConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -60,22 +70,28 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".start-block", DefaultConfig.StartBlock, "first block number of the block range for re-execution") f.Uint64(prefix+".end-block", DefaultConfig.EndBlock, "last block number of the block range for re-execution") f.Int(prefix+".room", DefaultConfig.Room, "number of threads to parallelize blocks re-execution") - f.Uint64(prefix+".blocks-per-thread", DefaultConfig.BlocksPerThread, "minimum number of blocks to execute per thread. When mode is random this acts as the size of random block range sample") + f.Uint64(prefix+".min-blocks-per-thread", DefaultConfig.MinBlocksPerThread, "minimum number of blocks to execute per thread. When mode is random this acts as the size of random block range sample") + f.Int(prefix+".trie-clean-limit", DefaultConfig.TrieCleanLimit, "memory allowance (MB) to use for caching trie nodes in memory") } type BlocksReExecutor struct { stopwaiter.StopWaiter - config *Config - blockchain *core.BlockChain - stateFor arbitrum.StateForHeaderFunction - done chan struct{} - fatalErrChan chan error - startBlock uint64 - currentBlock uint64 - blocksPerThread uint64 + config *Config + db state.Database + blockchain *core.BlockChain + stateFor arbitrum.StateForHeaderFunction + done chan struct{} + fatalErrChan chan error + startBlock uint64 + currentBlock uint64 + minBlocksPerThread uint64 + mutex sync.Mutex } -func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *BlocksReExecutor { +func New(c *Config, blockchain *core.BlockChain, ethDb ethdb.Database, fatalErrChan chan error) (*BlocksReExecutor, error) { + if blockchain.TrieDB().Scheme() == rawdb.PathScheme { + return nil, errors.New("blocksReExecutor not supported on pathdb") + } start := c.StartBlock end := c.EndBlock chainStart := blockchain.Config().ArbitrumChainParams.GenesisBlockNum @@ -92,13 +108,13 @@ func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *Block log.Warn("invalid state reexecutor's end block number, resetting to latest", "end", end, "latest", chainEnd) end = chainEnd } - blocksPerThread := uint64(10000) - if c.BlocksPerThread != 0 { - blocksPerThread = c.BlocksPerThread + minBlocksPerThread := uint64(10000) + if c.MinBlocksPerThread != 0 { + minBlocksPerThread = c.MinBlocksPerThread } if c.Mode == "random" && end != start { - // Reexecute a range of 10000 or (non-zero) c.BlocksPerThread number of blocks between start to end picked randomly - rng := blocksPerThread + // Reexecute a range of 10000 or (non-zero) c.MinBlocksPerThread number of blocks between start to end picked randomly + rng := minBlocksPerThread if rng > end-start { rng = end - start } @@ -111,32 +127,46 @@ func New(c *Config, blockchain *core.BlockChain, fatalErrChan chan error) *Block if start > 0 && start != chainStart { start-- } - // Divide work equally among available threads when BlocksPerThread is zero - if c.BlocksPerThread == 0 { + // Divide work equally among available threads when MinBlocksPerThread is zero + if c.MinBlocksPerThread == 0 { // #nosec G115 - work := (end - start) / uint64(c.Room) + work := (end - start) / uint64(c.Room*2) if work > 0 { - blocksPerThread = work + minBlocksPerThread = work } } - return &BlocksReExecutor{ - config: c, - blockchain: blockchain, - currentBlock: end, - startBlock: start, - blocksPerThread: blocksPerThread, - done: make(chan struct{}, c.Room), - fatalErrChan: fatalErrChan, - stateFor: func(header *types.Header) (*state.StateDB, arbitrum.StateReleaseFunc, error) { - state, err := blockchain.StateAt(header.Root) - return state, arbitrum.NoopStateRelease, err - }, + hashConfig := *hashdb.Defaults + hashConfig.CleanCacheSize = c.TrieCleanLimit * 1024 * 1024 + trieConfig := triedb.Config{ + Preimages: false, + HashDB: &hashConfig, + } + blocksReExecutor := &BlocksReExecutor{ + config: c, + db: state.NewDatabaseWithConfig(ethDb, &trieConfig), + blockchain: blockchain, + currentBlock: end, + startBlock: start, + minBlocksPerThread: minBlocksPerThread, + done: make(chan struct{}, c.Room), + fatalErrChan: fatalErrChan, } + blocksReExecutor.stateFor = func(header *types.Header) (*state.StateDB, arbitrum.StateReleaseFunc, error) { + blocksReExecutor.mutex.Lock() + defer blocksReExecutor.mutex.Unlock() + sdb, err := state.New(header.Root, blocksReExecutor.db, nil) + if err == nil { + _ = blocksReExecutor.db.TrieDB().Reference(header.Root, common.Hash{}) // Will be dereferenced later in advanceStateUpToBlock + return sdb, func() { blocksReExecutor.dereferenceRoot(header.Root) }, nil + } + return sdb, arbitrum.NoopStateRelease, err + } + return blocksReExecutor, nil } -// LaunchBlocksReExecution launches the thread to apply blocks of range [currentBlock-s.config.BlocksPerThread, currentBlock] to the last available valid state +// LaunchBlocksReExecution launches the thread to apply blocks of range [currentBlock-s.config.MinBlocksPerThread, currentBlock] to the last available valid state func (s *BlocksReExecutor) LaunchBlocksReExecution(ctx context.Context, currentBlock uint64) uint64 { - start := arbmath.SaturatingUSub(currentBlock, s.blocksPerThread) + start := arbmath.SaturatingUSub(currentBlock, s.minBlocksPerThread) if start < s.startBlock { start = s.startBlock } @@ -145,12 +175,10 @@ func (s *BlocksReExecutor) LaunchBlocksReExecution(ctx context.Context, currentB s.fatalErrChan <- fmt.Errorf("blocksReExecutor failed to get last available state while searching for state at %d, err: %w", start, err) return s.startBlock } - // NoOp - defer release() start = startHeader.Number.Uint64() s.LaunchThread(func(ctx context.Context) { - _, err := arbitrum.AdvanceStateUpToBlock(ctx, s.blockchain, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader, nil) - if err != nil { + log.Info("Starting reexecution of blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) + if err := s.advanceStateUpToBlock(ctx, startState, s.blockchain.GetHeaderByNumber(currentBlock), startHeader, release); err != nil { s.fatalErrChan <- fmt.Errorf("blocksReExecutor errored advancing state from block %d to block %d, err: %w", start, currentBlock, err) } else { log.Info("Successfully reexecuted blocks against historic state", "stateAt", start, "startBlock", start+1, "endBlock", currentBlock) @@ -199,3 +227,60 @@ func (s *BlocksReExecutor) Start(ctx context.Context, done chan struct{}) { func (s *BlocksReExecutor) StopAndWait() { s.StopWaiter.StopAndWait() } + +func (s *BlocksReExecutor) dereferenceRoot(root common.Hash) { + s.mutex.Lock() + defer s.mutex.Unlock() + _ = s.db.TrieDB().Dereference(root) +} + +func (s *BlocksReExecutor) commitStateAndVerify(statedb *state.StateDB, expected common.Hash, blockNumber uint64) (*state.StateDB, arbitrum.StateReleaseFunc, error) { + s.mutex.Lock() + defer s.mutex.Unlock() + result, err := statedb.Commit(blockNumber, true) + if err != nil { + return nil, arbitrum.NoopStateRelease, err + } + if result != expected { + return nil, arbitrum.NoopStateRelease, fmt.Errorf("bad root hash expected: %v got: %v", expected, result) + } + sdb, err := state.New(result, s.db, nil) + if err == nil { + _ = s.db.TrieDB().Reference(result, common.Hash{}) + return sdb, func() { s.dereferenceRoot(result) }, nil + } + return sdb, arbitrum.NoopStateRelease, err +} + +func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *state.StateDB, targetHeader *types.Header, lastAvailableHeader *types.Header, lastRelease arbitrum.StateReleaseFunc) error { + targetBlockNumber := targetHeader.Number.Uint64() + blockToRecreate := lastAvailableHeader.Number.Uint64() + 1 + prevHash := lastAvailableHeader.Hash() + var stateRelease arbitrum.StateReleaseFunc + defer func() { + lastRelease() + }() + var block *types.Block + var err error + for ctx.Err() == nil { + state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, blockToRecreate, prevHash, nil) + if err != nil { + return err + } + prevHash = block.Hash() + state, stateRelease, err = s.commitStateAndVerify(state, block.Root(), block.NumberU64()) + if err != nil { + return fmt.Errorf("failed committing state for block %d : %w", blockToRecreate, err) + } + lastRelease() + lastRelease = stateRelease + if blockToRecreate >= targetBlockNumber { + if block.Hash() != targetHeader.Hash() { + return fmt.Errorf("blockHash doesn't match when recreating number: %d expected: %v got: %v", blockToRecreate, targetHeader.Hash(), block.Hash()) + } + return nil + } + blockToRecreate++ + } + return ctx.Err() +} diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index 4e97ca8cd0..ac684902e4 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" m "github.com/offchainlabs/nitro/broadcaster/message" "github.com/offchainlabs/nitro/util/contracts" diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index a499628cd5..d9f7443af5 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -138,7 +138,11 @@ func TestInvalidSignature(t *testing.T) { badPrivateKey, err := crypto.GenerateKey() Require(t, err) badPublicKey := badPrivateKey.Public() - badSequencerAddr := crypto.PubkeyToAddress(*badPublicKey.(*ecdsa.PublicKey)) + badECDSA, ok := badPublicKey.(*ecdsa.PublicKey) + if !ok { + t.Fatal("badPublicKey is not an ecdsa.PublicKey") + } + badSequencerAddr := crypto.PubkeyToAddress(*badECDSA) config := DefaultTestConfig ts := NewDummyTransactionStreamer(chainId, &badSequencerAddr) @@ -151,6 +155,7 @@ func TestInvalidSignature(t *testing.T) { nil, fatalErrChan, &badSequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -201,8 +206,9 @@ func (ts *dummyTransactionStreamer) AddBroadcastMessages(feedMessages []*m.Broad return nil } -func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address) (*BroadcastClient, error) { - port := listenerAddress.(*net.TCPAddr).Port +func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address, t *testing.T) (*BroadcastClient, error) { + t.Helper() + port := testhelpers.AddrTCPPort(listenerAddress, t) var av contracts.AddressVerifierInterface if validAddr != nil { config.Verify.AcceptSequencer = true @@ -225,6 +231,7 @@ func startMakeBroadcastClient(ctx context.Context, t *testing.T, clientConfig Co nil, feedErrChan, sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -313,6 +320,7 @@ func TestServerClientDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -384,6 +392,7 @@ func TestBroadcastClientConfirmedMessage(t *testing.T) { confirmedSequenceNumberListener, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -456,6 +465,7 @@ func TestServerIncorrectChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -515,6 +525,7 @@ func TestServerMissingChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -572,6 +583,7 @@ func TestServerIncorrectFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -631,6 +643,7 @@ func TestServerMissingFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -682,6 +695,7 @@ func TestBroadcastClientReconnectsOnServerDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -794,6 +808,7 @@ func connectAndGetCachedMessages(ctx context.Context, addr net.Addr, chainId uin nil, feedErrChan, sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) diff --git a/broadcaster/backlog/backlog.go b/broadcaster/backlog/backlog.go index b7b935fb7a..0897eedd10 100644 --- a/broadcaster/backlog/backlog.go +++ b/broadcaster/backlog/backlog.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + m "github.com/offchainlabs/nitro/broadcaster/message" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/containers" @@ -328,7 +329,13 @@ func newBacklogSegment() *backlogSegment { func IsBacklogSegmentNil(segment BacklogSegment) bool { if segment == nil { return true - } else if segment.(*backlogSegment) == nil { + } + bs, ok := segment.(*backlogSegment) + if !ok { + log.Error("error in backlogSegment type assertion: clearing backlog") + return false + } + if bs == nil { return true } return false diff --git a/broadcaster/message/message.go b/broadcaster/message/message.go index 1e26e6da5e..f2439912f8 100644 --- a/broadcaster/message/message.go +++ b/broadcaster/message/message.go @@ -2,6 +2,7 @@ package message import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/broadcaster/message/message_serialization_test.go b/broadcaster/message/message_serialization_test.go index 1d8c10e388..5fb9d55dda 100644 --- a/broadcaster/message/message_serialization_test.go +++ b/broadcaster/message/message_serialization_test.go @@ -10,6 +10,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" ) diff --git a/cmd/conf/chain.go b/cmd/conf/chain.go index 28b06aad2b..435246e357 100644 --- a/cmd/conf/chain.go +++ b/cmd/conf/chain.go @@ -6,10 +6,11 @@ package conf import ( "time" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/rpcclient" - flag "github.com/spf13/pflag" ) type ParentChainConfig struct { diff --git a/cmd/conf/database.go b/cmd/conf/database.go index af18bacd57..8857b615f3 100644 --- a/cmd/conf/database.go +++ b/cmd/conf/database.go @@ -12,8 +12,9 @@ import ( "runtime" "time" - "github.com/ethereum/go-ethereum/ethdb/pebble" flag "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/ethdb/pebble" ) type PersistentConfig struct { diff --git a/cmd/conf/init.go b/cmd/conf/init.go index f01d99f8b7..cd2b6c8805 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -6,8 +6,9 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/log" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" ) type InitConfig struct { @@ -20,6 +21,7 @@ type InitConfig struct { DownloadPoll time.Duration `koanf:"download-poll"` DevInit bool `koanf:"dev-init"` DevInitAddress string `koanf:"dev-init-address"` + DevMaxCodeSize uint64 `koanf:"dev-max-code-size"` DevInitBlockNum uint64 `koanf:"dev-init-blocknum"` Empty bool `koanf:"empty"` ImportWasm bool `koanf:"import-wasm"` @@ -47,6 +49,7 @@ var InitConfigDefault = InitConfig{ DownloadPoll: time.Minute, DevInit: false, DevInitAddress: "", + DevMaxCodeSize: 0, DevInitBlockNum: 0, Empty: false, ImportWasm: false, @@ -75,6 +78,7 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".dev-init", InitConfigDefault.DevInit, "init with dev data (1 account with balance) instead of file import") f.String(prefix+".dev-init-address", InitConfigDefault.DevInitAddress, "Address of dev-account. Leave empty to use the dev-wallet.") f.Uint64(prefix+".dev-init-blocknum", InitConfigDefault.DevInitBlockNum, "Number of preinit blocks. Must exist in ancient database.") + f.Uint64(prefix+".dev-max-code-size", InitConfigDefault.DevMaxCodeSize, "Max code size for dev accounts") f.Bool(prefix+".empty", InitConfigDefault.Empty, "init with empty state") f.Bool(prefix+".import-wasm", InitConfigDefault.ImportWasm, "if set, import the wasm directory when downloading a database (contains executable code - only use with highly trusted source)") f.Bool(prefix+".then-quit", InitConfigDefault.ThenQuit, "quit after init is done") diff --git a/cmd/dataavailability/data_availability_check.go b/cmd/dataavailability/data_availability_check.go index d80c0475bf..e961215925 100644 --- a/cmd/dataavailability/data_availability_check.go +++ b/cmd/dataavailability/data_availability_check.go @@ -13,6 +13,8 @@ import ( "syscall" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -27,8 +29,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/metricsutil" "github.com/offchainlabs/nitro/util/stopwaiter" - - flag "github.com/spf13/pflag" ) // Data availability check is done to as to make sure that the data that is being stored by DAS is available at all time. diff --git a/cmd/datool/datool.go b/cmd/datool/datool.go index f791d8cbc4..06f94dc952 100644 --- a/cmd/datool/datool.go +++ b/cmd/datool/datool.go @@ -22,10 +22,10 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util" - "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" "github.com/offchainlabs/nitro/das/dastree" diff --git a/cmd/dbconv/dbconv/config.go b/cmd/dbconv/dbconv/config.go index 917f34261d..fdebda2d54 100644 --- a/cmd/dbconv/dbconv/config.go +++ b/cmd/dbconv/dbconv/config.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/genericconf" - flag "github.com/spf13/pflag" ) type DBConfig struct { diff --git a/cmd/dbconv/dbconv/dbconv.go b/cmd/dbconv/dbconv/dbconv.go index 6a97df31c0..fdba1907c2 100644 --- a/cmd/dbconv/dbconv/dbconv.go +++ b/cmd/dbconv/dbconv/dbconv.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/dbutil" ) diff --git a/cmd/dbconv/main.go b/cmd/dbconv/main.go index 2d61c96552..f5aaced40b 100644 --- a/cmd/dbconv/main.go +++ b/cmd/dbconv/main.go @@ -6,13 +6,15 @@ import ( "os" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/exp" + "github.com/offchainlabs/nitro/cmd/dbconv/dbconv" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" - flag "github.com/spf13/pflag" ) func parseDBConv(args []string) (*dbconv.DBConvConfig, error) { diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index c70ceb1d94..a597799b06 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go @@ -14,20 +14,20 @@ import ( "strings" "time" - "github.com/offchainlabs/nitro/cmd/chaininfo" - "github.com/offchainlabs/nitro/cmd/genericconf" - "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/cmd/chaininfo" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util" deploycode "github.com/offchainlabs/nitro/deploy" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/validator/server_common" ) func main() { diff --git a/cmd/genericconf/config.go b/cmd/genericconf/config.go index 06e1fcd12d..408ba9a552 100644 --- a/cmd/genericconf/config.go +++ b/cmd/genericconf/config.go @@ -6,12 +6,13 @@ package genericconf import ( "errors" "io" + "log/slog" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" - flag "github.com/spf13/pflag" - "golang.org/x/exp/slog" ) type ConfConfig struct { diff --git a/cmd/genericconf/filehandler_test.go b/cmd/genericconf/filehandler_test.go index daa9ed397c..7d24fbb69f 100644 --- a/cmd/genericconf/filehandler_test.go +++ b/cmd/genericconf/filehandler_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -55,7 +56,11 @@ func readLogMessagesFromJSONFile(t *testing.T, path string) ([]string, error) { if !ok { testhelpers.FailImpl(t, "Incorrect record, msg key is missing", "record", record) } - messages = append(messages, msg.(string)) + msgString, ok := msg.(string) + if !ok { + testhelpers.FailImpl(t, "Incorrect record, msg is not a string", "record", record) + } + messages = append(messages, msgString) } if errors.Is(err, io.EOF) { return messages, nil diff --git a/cmd/genericconf/liveconfig.go b/cmd/genericconf/liveconfig.go index 1054140e9e..f256fe6612 100644 --- a/cmd/genericconf/liveconfig.go +++ b/cmd/genericconf/liveconfig.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/cmd/genericconf/logging.go b/cmd/genericconf/logging.go index fa45953278..4cdaa5f3e8 100644 --- a/cmd/genericconf/logging.go +++ b/cmd/genericconf/logging.go @@ -8,8 +8,9 @@ import ( "os" "sync" - "github.com/ethereum/go-ethereum/log" "gopkg.in/natefinch/lumberjack.v2" + + "github.com/ethereum/go-ethereum/log" ) var globalFileLoggerFactory = fileLoggerFactory{} diff --git a/cmd/genericconf/loglevel.go b/cmd/genericconf/loglevel.go index f7ad05a2cc..79cba22439 100644 --- a/cmd/genericconf/loglevel.go +++ b/cmd/genericconf/loglevel.go @@ -5,11 +5,11 @@ package genericconf import ( "errors" + "log/slog" "strconv" "strings" "github.com/ethereum/go-ethereum/log" - "golang.org/x/exp/slog" ) func ToSlogLevel(str string) (slog.Level, error) { diff --git a/cmd/genericconf/pprof.go b/cmd/genericconf/pprof.go index 9fd3a6f2a4..0bde03decd 100644 --- a/cmd/genericconf/pprof.go +++ b/cmd/genericconf/pprof.go @@ -3,7 +3,6 @@ package genericconf import ( "fmt" "net/http" - // Blank import pprof registers its HTTP handlers. _ "net/http/pprof" // #nosec G108 diff --git a/cmd/nitro-val/config.go b/cmd/nitro-val/config.go index 2adbe5e9aa..bca83277b3 100644 --- a/cmd/nitro-val/config.go +++ b/cmd/nitro-val/config.go @@ -2,19 +2,20 @@ package main import ( "fmt" - "reflect" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/validator/valnode" - flag "github.com/spf13/pflag" ) type ValidationNodeConfig struct { diff --git a/cmd/nitro/config_test.go b/cmd/nitro/config_test.go index 9626893083..ef41d704f1 100644 --- a/cmd/nitro/config_test.go +++ b/cmd/nitro/config_test.go @@ -14,14 +14,14 @@ import ( "testing" "time" + "github.com/r3labs/diff/v3" + flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" - - "github.com/r3labs/diff/v3" - flag "github.com/spf13/pflag" ) func TestEmptyCliConfig(t *testing.T) { diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index f0b303817c..eb6d7df6fc 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -25,6 +25,7 @@ import ( "github.com/cavaliergopher/grab/v3" "github.com/codeclysm/extract/v3" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" @@ -681,6 +682,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo Nonce: 0, }, }, + ChainOwner: common.HexToAddress(config.Init.DevInitAddress), } initDataReader = statetransfer.NewMemoryInitDataReader(&initData) } @@ -716,6 +718,9 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if err != nil { return chainDb, nil, err } + if config.Init.DevInit && config.Init.DevMaxCodeSize != 0 { + chainConfig.ArbitrumChainParams.MaxCodeSize = config.Init.DevMaxCodeSize + } testUpdateTxIndex(chainDb, chainConfig, &txIndexWg) ancients, err := chainDb.Ancients() if err != nil { diff --git a/cmd/nitro/init_test.go b/cmd/nitro/init_test.go index 48d969f053..8e7afe369d 100644 --- a/cmd/nitro/init_test.go +++ b/cmd/nitro/init_test.go @@ -23,11 +23,13 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" - "github.com/google/go-cmp/cmp" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/cmd/conf" diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index e55c8b9691..73c71c9582 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -468,7 +468,11 @@ func mainImpl() int { var blocksReExecutor *blocksreexecutor.BlocksReExecutor if nodeConfig.BlocksReExecutor.Enable && l2BlockChain != nil { - blocksReExecutor = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, fatalErrChan) + blocksReExecutor, err = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, chainDb, fatalErrChan) + if err != nil { + log.Error("error initializing blocksReExecutor", "err", err) + return 1 + } if nodeConfig.Init.ThenQuit { if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil { log.Error("error populating stylus target cache", "err", err) diff --git a/cmd/pruning/pruning.go b/cmd/pruning/pruning.go index 0755f5ff9e..e89c79bc89 100644 --- a/cmd/pruning/pruning.go +++ b/cmd/pruning/pruning.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbutil" diff --git a/cmd/replay/db.go b/cmd/replay/db.go index 7147c48f75..3dc9f15da0 100644 --- a/cmd/replay/db.go +++ b/cmd/replay/db.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/wavmio" ) diff --git a/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go b/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go index b897b23252..b6b5342ca2 100644 --- a/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go +++ b/cmd/seq-coordinator-manager/rediscoordinator/redis_coordinator.go @@ -5,8 +5,9 @@ import ( "errors" "strings" - "github.com/offchainlabs/nitro/util/redisutil" "github.com/redis/go-redis/v9" + + "github.com/offchainlabs/nitro/util/redisutil" ) // RedisCoordinator builds upon RedisCoordinator of redisutil with additional functionality diff --git a/cmd/seq-coordinator-manager/seq-coordinator-manager.go b/cmd/seq-coordinator-manager/seq-coordinator-manager.go index 43d90441ef..7b5dc68699 100644 --- a/cmd/seq-coordinator-manager/seq-coordinator-manager.go +++ b/cmd/seq-coordinator-manager/seq-coordinator-manager.go @@ -7,11 +7,13 @@ import ( "strconv" "github.com/enescakir/emoji" - "github.com/ethereum/go-ethereum/log" "github.com/gdamore/tcell/v2" + "github.com/rivo/tview" + + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/cmd/seq-coordinator-manager/rediscoordinator" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/rivo/tview" ) // Tview diff --git a/cmd/util/confighelpers/configuration.go b/cmd/util/confighelpers/configuration.go index 19b5b1a24c..8c4ef2a70b 100644 --- a/cmd/util/confighelpers/configuration.go +++ b/cmd/util/confighelpers/configuration.go @@ -209,6 +209,7 @@ func devFlagArgs() []string { "--init.empty=false", "--http.port", "8547", "--http.addr", "127.0.0.1", + "--http.api=net,web3,eth,arb,arbdebug,debug", } return args } diff --git a/das/aggregator_test.go b/das/aggregator_test.go index 4bc209513e..217315eef0 100644 --- a/das/aggregator_test.go +++ b/das/aggregator_test.go @@ -16,10 +16,10 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" - - "github.com/ethereum/go-ethereum/log" ) func TestDAS_BasicAggregationLocal(t *testing.T) { diff --git a/das/cache_storage_service.go b/das/cache_storage_service.go index 439ccda086..0ba20ac55b 100644 --- a/das/cache_storage_service.go +++ b/das/cache_storage_service.go @@ -7,14 +7,15 @@ import ( "context" "fmt" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/das/dastree" - "github.com/offchainlabs/nitro/util/pretty" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/das/dastree" + "github.com/offchainlabs/nitro/util/pretty" ) type CacheConfig struct { diff --git a/das/chain_fetch_das.go b/das/chain_fetch_das.go index 4de6c981cf..34b10d45ec 100644 --- a/das/chain_fetch_das.go +++ b/das/chain_fetch_das.go @@ -8,14 +8,14 @@ import ( "errors" "sync" - "github.com/offchainlabs/nitro/util/pretty" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/solgen/go/bridgegen" + "github.com/offchainlabs/nitro/util/pretty" ) type syncedKeysetCache struct { diff --git a/das/das.go b/das/das.go index 0b03c05ad6..e870761ac2 100644 --- a/das/das.go +++ b/das/das.go @@ -10,10 +10,11 @@ import ( "math" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/dasRpcClient.go b/das/dasRpcClient.go index d6e2c389c9..3ea6c4e2c6 100644 --- a/das/dasRpcClient.go +++ b/das/dasRpcClient.go @@ -9,13 +9,14 @@ import ( "strings" "time" + "golang.org/x/sync/errgroup" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "golang.org/x/sync/errgroup" - "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/dasRpcServer.go b/das/dasRpcServer.go index bb1be0384e..adddf26571 100644 --- a/das/dasRpcServer.go +++ b/das/dasRpcServer.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/blsSignatures" diff --git a/das/dastree/dastree.go b/das/dastree/dastree.go index 2bcbccaae3..29a6b2495c 100644 --- a/das/dastree/dastree.go +++ b/das/dastree/dastree.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/das/dastree/dastree_test.go b/das/dastree/dastree_test.go index 4d24c9ae98..b24d6ce69b 100644 --- a/das/dastree/dastree_test.go +++ b/das/dastree/dastree_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/db_storage_service.go b/das/db_storage_service.go index 74bf12b927..0e38505a13 100644 --- a/das/db_storage_service.go +++ b/das/db_storage_service.go @@ -14,13 +14,15 @@ import ( "time" badger "github.com/dgraph-io/badger/v4" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) type LocalDBStorageConfig struct { diff --git a/das/fallback_storage_service.go b/das/fallback_storage_service.go index 0a451678d0..64bc3c2a7a 100644 --- a/das/fallback_storage_service.go +++ b/das/fallback_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/das/fallback_storage_service_test.go b/das/fallback_storage_service_test.go index b73df31624..4c7c0351e9 100644 --- a/das/fallback_storage_service_test.go +++ b/das/fallback_storage_service_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/math" + "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/google_cloud_storage_service_test.go b/das/google_cloud_storage_service_test.go index 799d999bad..94d6f3ee44 100644 --- a/das/google_cloud_storage_service_test.go +++ b/das/google_cloud_storage_service_test.go @@ -2,13 +2,16 @@ package das import ( "bytes" - googlestorage "cloud.google.com/go/storage" "context" "errors" - "github.com/ethereum/go-ethereum/common" - "github.com/offchainlabs/nitro/das/dastree" "testing" "time" + + googlestorage "cloud.google.com/go/storage" + + "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/das/dastree" ) type mockGCSClient struct { diff --git a/das/key_utils.go b/das/key_utils.go index 33f29788b6..0262e7f666 100644 --- a/das/key_utils.go +++ b/das/key_utils.go @@ -11,6 +11,7 @@ import ( "os" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/blsSignatures" ) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 5e64c34b10..71c98c7879 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -20,14 +20,16 @@ import ( "syscall" "time" + flag "github.com/spf13/pflag" + "golang.org/x/sys/unix" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" - "golang.org/x/sys/unix" ) type LocalFileStorageConfig struct { diff --git a/das/memory_backed_storage_service.go b/das/memory_backed_storage_service.go index c013b501b9..8a2df28902 100644 --- a/das/memory_backed_storage_service.go +++ b/das/memory_backed_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/panic_wrapper.go b/das/panic_wrapper.go index 3530cb651d..4729792c33 100644 --- a/das/panic_wrapper.go +++ b/das/panic_wrapper.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/reader_aggregator_strategies_test.go b/das/reader_aggregator_strategies_test.go index cdb85b25e9..e211ee38fe 100644 --- a/das/reader_aggregator_strategies_test.go +++ b/das/reader_aggregator_strategies_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) @@ -72,8 +73,10 @@ func TestDAS_SimpleExploreExploit(t *testing.T) { } for i := 0; i < len(was) && doMatch; i++ { - if expected[i].(*dummyReader).int != was[i].(*dummyReader).int { - Fail(t, fmt.Sprintf("expected %d, was %d", expected[i].(*dummyReader).int, was[i].(*dummyReader).int)) + expR, expOK := expected[i].(*dummyReader) + wasR, wasOK := was[i].(*dummyReader) + if !expOK || !wasOK || expR.int != wasR.int { + Fail(t, fmt.Sprintf("expected %d, was %d", expected[i], was[i])) } } } diff --git a/das/redis_storage_service.go b/das/redis_storage_service.go index e57240992c..cdd18ea974 100644 --- a/das/redis_storage_service.go +++ b/das/redis_storage_service.go @@ -10,17 +10,17 @@ import ( "fmt" "time" + "github.com/redis/go-redis/v9" + flag "github.com/spf13/pflag" "golang.org/x/crypto/sha3" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/redis/go-redis/v9" - flag "github.com/spf13/pflag" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/log" ) type RedisConfig struct { diff --git a/das/redis_storage_service_test.go b/das/redis_storage_service_test.go index 77d3e8cd0f..41ca6bac90 100644 --- a/das/redis_storage_service_test.go +++ b/das/redis_storage_service_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/alicebob/miniredis/v2" + "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/redundant_storage_service.go b/das/redundant_storage_service.go index 3158d28076..85274188d6 100644 --- a/das/redundant_storage_service.go +++ b/das/redundant_storage_service.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/util/pretty" ) diff --git a/das/restful_client.go b/das/restful_client.go index b65426e7cd..3004ea1b59 100644 --- a/das/restful_client.go +++ b/das/restful_client.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" ) diff --git a/das/restful_server.go b/das/restful_server.go index b1607729e2..6c5e2ec453 100644 --- a/das/restful_server.go +++ b/das/restful_server.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/pretty" diff --git a/das/rpc_aggregator.go b/das/rpc_aggregator.go index 9cf481e015..916637aac6 100644 --- a/das/rpc_aggregator.go +++ b/das/rpc_aggregator.go @@ -14,14 +14,15 @@ import ( "github.com/knadh/koanf" "github.com/knadh/koanf/providers/confmap" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/metricsutil" "github.com/offchainlabs/nitro/util/signature" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" ) type BackendConfig struct { diff --git a/das/rpc_test.go b/das/rpc_test.go index 370ec0a872..ebc4b736d5 100644 --- a/das/rpc_test.go +++ b/das/rpc_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/blsSignatures" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/util/signature" diff --git a/das/s3_storage_service.go b/das/s3_storage_service.go index d251f12214..4c0dcaf5a3 100644 --- a/das/s3_storage_service.go +++ b/das/s3_storage_service.go @@ -16,14 +16,14 @@ import ( "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/das/dastree" - "github.com/offchainlabs/nitro/util/pretty" + flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" - flag "github.com/spf13/pflag" + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/das/dastree" + "github.com/offchainlabs/nitro/util/pretty" ) type S3Uploader interface { diff --git a/das/signature_verifier.go b/das/signature_verifier.go index 0aa42bceb6..453b2fe305 100644 --- a/das/signature_verifier.go +++ b/das/signature_verifier.go @@ -11,6 +11,7 @@ import ( "os" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/contracts" ) diff --git a/das/simple_das_reader_aggregator.go b/das/simple_das_reader_aggregator.go index f45c56afe0..ff28d6a22a 100644 --- a/das/simple_das_reader_aggregator.go +++ b/das/simple_das_reader_aggregator.go @@ -12,13 +12,15 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/das/dastree" "github.com/offchainlabs/nitro/util/pretty" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // Most of the time we will use the SimpleDASReaderAggregator only to aggregate diff --git a/das/storage_service.go b/das/storage_service.go index b7526077e9..925bbb520a 100644 --- a/das/storage_service.go +++ b/das/storage_service.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/offchainlabs/nitro/arbstate/daprovider" ) diff --git a/das/syncing_fallback_storage.go b/das/syncing_fallback_storage.go index 0670a29c73..1aec2b7328 100644 --- a/das/syncing_fallback_storage.go +++ b/das/syncing_fallback_storage.go @@ -12,6 +12,8 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -19,13 +21,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) var sequencerInboxABI *abi.ABI diff --git a/das/util.go b/das/util.go index 114e075e79..cd300175bb 100644 --- a/das/util.go +++ b/das/util.go @@ -7,6 +7,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/util/pretty" ) diff --git a/deploy/deploy.go b/deploy/deploy.go index bb4b2e6594..2738373c72 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/challengegen" diff --git a/execution/gethexec/api.go b/execution/gethexec/api.go index 4fa60693d5..713d1496f9 100644 --- a/execution/gethexec/api.go +++ b/execution/gethexec/api.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index a3af7876a8..2e3d51fec9 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -6,18 +6,20 @@ import ( "sync" "testing" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" - flag "github.com/spf13/pflag" ) // BlockRecorder uses a separate statedatabase from the blockchain. @@ -75,19 +77,21 @@ func NewBlockRecorder(config *BlockRecorderConfig, execEngine *ExecutionEngine, return recorder } -func stateLogFunc(targetHeader, header *types.Header, hasState bool) { - if targetHeader == nil || header == nil { - return - } - gap := targetHeader.Number.Int64() - header.Number.Int64() - step := int64(500) - stage := "computing state" - if !hasState { - step = 3000 - stage = "looking for full block" - } - if (gap >= step) && (gap%step == 0) { - log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number) +func stateLogFunc(targetHeader *types.Header) arbitrum.StateBuildingLogFunction { + return func(header *types.Header, hasState bool) { + if targetHeader == nil || header == nil { + return + } + gap := targetHeader.Number.Int64() - header.Number.Int64() + step := int64(500) + stage := "computing state" + if !hasState { + step = 3000 + stage = "looking for full block" + } + if (gap >= step) && (gap%step == 0) { + log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number) + } } } @@ -109,7 +113,7 @@ func (r *BlockRecorder) RecordBlockCreation( } } - recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc) + recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc(prevHeader)) if err != nil { return nil, err } @@ -321,7 +325,7 @@ func (r *BlockRecorder) PrepareForRecord(ctx context.Context, start, end arbutil log.Warn("prepareblocks asked for non-found block", "hdrNum", hdrNum) break } - _, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc) + _, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc(header)) if err != nil { log.Warn("prepareblocks failed to get state for block", "hdrNum", hdrNum, "err", err) break diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index fda8f49093..53b494a3c2 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index 6571672b71..cae2c5fb0c 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -12,6 +12,7 @@ package gethexec #include "arbitrator.h" */ import "C" + import ( "bytes" "context" @@ -26,6 +27,8 @@ import ( "testing" "time" + "github.com/google/uuid" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" @@ -33,7 +36,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" - "github.com/google/uuid" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/execution/gethexec/forwarder.go b/execution/gethexec/forwarder.go index cdb4f394e5..8e64508e6c 100644 --- a/execution/gethexec/forwarder.go +++ b/execution/gethexec/forwarder.go @@ -14,8 +14,6 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/util/redisutil" - "github.com/offchainlabs/nitro/util/stopwaiter" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/arbitrum" @@ -24,6 +22,9 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/util/redisutil" + "github.com/offchainlabs/nitro/util/stopwaiter" ) type ForwarderConfig struct { diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 499a13164e..11d173a21e 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -9,6 +9,8 @@ import ( "sync/atomic" "testing" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -21,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbutil" @@ -28,7 +31,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/dbutil" "github.com/offchainlabs/nitro/util/headerreader" - flag "github.com/spf13/pflag" ) type StylusTargetConfig struct { diff --git a/execution/gethexec/sequencer.go b/execution/gethexec/sequencer.go index cc98c7930f..92d440e8cb 100644 --- a/execution/gethexec/sequencer.go +++ b/execution/gethexec/sequencer.go @@ -15,11 +15,6 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/execution" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/headerreader" flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/arbitrum" @@ -34,10 +29,16 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l1pricing" + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/execution" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/execution/gethexec/stylus_tracer.go b/execution/gethexec/stylus_tracer.go index 4c18bb2ebe..8a024941d3 100644 --- a/execution/gethexec/stylus_tracer.go +++ b/execution/gethexec/stylus_tracer.go @@ -13,9 +13,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" ) @@ -67,10 +69,20 @@ var nestsHostios = map[string]bool{ "static_call_contract": true, } -func newStylusTracer(ctx *tracers.Context, _ json.RawMessage) (tracers.Tracer, error) { - return &stylusTracer{ +func newStylusTracer(ctx *tracers.Context, _ json.RawMessage) (*tracers.Tracer, error) { + t := &stylusTracer{ open: containers.NewStack[HostioTraceInfo](), stack: containers.NewStack[*containers.Stack[HostioTraceInfo]](), + } + + return &tracers.Tracer{ + Hooks: &tracing.Hooks{ + OnEnter: t.OnEnter, + OnExit: t.OnExit, + CaptureStylusHostio: t.CaptureStylusHostio, + }, + GetResult: t.GetResult, + Stop: t.Stop, }, nil } @@ -104,16 +116,18 @@ func (t *stylusTracer) CaptureStylusHostio(name string, args, outs []byte, start } t.open.Push(info) } - -func (t *stylusTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { +func (t *stylusTracer) OnEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { if t.interrupt.Load() { return } + if depth == 0 { + return + } // This function adds the prefix evm_ because it assumes the opcode came from the EVM. // If the opcode comes from WASM, the CaptureStylusHostio function will remove the evm prefix. var name string - switch typ { + switch vm.OpCode(typ) { case vm.CALL: name = "evm_call_contract" case vm.DELEGATECALL: @@ -139,10 +153,13 @@ func (t *stylusTracer) CaptureEnter(typ vm.OpCode, from common.Address, to commo t.open = inner } -func (t *stylusTracer) CaptureExit(output []byte, gasUsed uint64, _ error) { +func (t *stylusTracer) OnExit(depth int, output []byte, gasUsed uint64, _ error, reverted bool) { if t.interrupt.Load() { return } + if depth == 0 { + return + } var err error t.open, err = t.stack.Pop() if err != nil { @@ -181,19 +198,3 @@ func (t *stylusTracer) Stop(err error) { t.reason = err t.interrupt.Store(true) } - -// Unimplemented EVMLogger interface methods - -func (t *stylusTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { -} -func (t *stylusTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} -func (t *stylusTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} -func (t *stylusTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { -} -func (t *stylusTracer) CaptureEnd(output []byte, gasUsed uint64, err error) {} -func (t *stylusTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) { -} -func (t *stylusTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, _ *vm.ScopeContext, depth int, err error) { -} -func (t *stylusTracer) CaptureTxStart(gasLimit uint64) {} -func (t *stylusTracer) CaptureTxEnd(restGas uint64) {} diff --git a/execution/gethexec/sync_monitor.go b/execution/gethexec/sync_monitor.go index 86949c7767..7f04b2ee4a 100644 --- a/execution/gethexec/sync_monitor.go +++ b/execution/gethexec/sync_monitor.go @@ -3,9 +3,10 @@ package gethexec import ( "context" - "github.com/offchainlabs/nitro/execution" "github.com/pkg/errors" flag "github.com/spf13/pflag" + + "github.com/offchainlabs/nitro/execution" ) type SyncMonitorConfig struct { diff --git a/execution/gethexec/tx_pre_checker.go b/execution/gethexec/tx_pre_checker.go index e0ae330148..e7ef20bae9 100644 --- a/execution/gethexec/tx_pre_checker.go +++ b/execution/gethexec/tx_pre_checker.go @@ -8,6 +8,8 @@ import ( "fmt" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbitrum_types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -15,11 +17,11 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" - flag "github.com/spf13/pflag" ) var ( diff --git a/execution/gethexec/wasmstorerebuilder.go b/execution/gethexec/wasmstorerebuilder.go index e3eb8e9268..b40a7cd128 100644 --- a/execution/gethexec/wasmstorerebuilder.go +++ b/execution/gethexec/wasmstorerebuilder.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbos/arbosState" ) diff --git a/execution/interface.go b/execution/interface.go index 2a3d79c697..c0aa71c146 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" ) diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 71ebbcce80..20282f8231 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/retryables" @@ -522,10 +523,14 @@ func (n NodeInterface) GasEstimateL1Component( args.Gas = (*hexutil.Uint64)(&randomGas) // We set the run mode to eth_call mode here because we want an exact estimate, not a padded estimate - msg, err := args.ToMessage(randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode) - if err != nil { + if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, nil, nil, err } + sdb, ok := evm.StateDB.(*state.StateDB) + if !ok { + return 0, nil, nil, errors.New("failed to cast to stateDB") + } + msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, sdb, core.MessageEthcallMode) pricing := c.State.L1PricingState() l1BaseFeeEstimate, err := pricing.PricePerUnit() @@ -578,10 +583,14 @@ func (n NodeInterface) GasEstimateComponents( // Setting the gas currently doesn't affect the PosterDataCost, // but we do it anyways for accuracy with potential future changes. args.Gas = &totalRaw - msg, err := args.ToMessage(gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode) - if err != nil { + if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil { return 0, 0, nil, nil, err } + sdb, ok := evm.StateDB.(*state.StateDB) + if !ok { + return 0, 0, nil, nil, errors.New("failed to cast to stateDB") + } + msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, sdb, core.MessageGasEstimationMode) brotliCompressionLevel, err := c.State.BrotliCompressionLevel() if err != nil { return 0, 0, nil, nil, fmt.Errorf("failed to get brotli compression level: %w", err) diff --git a/execution/nodeInterface/NodeInterfaceDebug.go b/execution/nodeInterface/NodeInterfaceDebug.go index ae9c157ce4..7066bf2ed2 100644 --- a/execution/nodeInterface/NodeInterfaceDebug.go +++ b/execution/nodeInterface/NodeInterfaceDebug.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" ) diff --git a/execution/nodeInterface/virtual-contracts.go b/execution/nodeInterface/virtual-contracts.go index d04be10857..5b9f4b3474 100644 --- a/execution/nodeInterface/virtual-contracts.go +++ b/execution/nodeInterface/virtual-contracts.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/l1pricing" @@ -23,7 +24,6 @@ import ( "github.com/offchainlabs/nitro/precompiles" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/arbmath" ) type addr = common.Address @@ -115,35 +115,28 @@ func init() { return msg, nil, nil } - core.InterceptRPCGasCap = func(gascap *uint64, msg *core.Message, header *types.Header, statedb *state.StateDB) { - if *gascap == 0 { - // It's already unlimited - return - } + core.RPCPostingGasHook = func(msg *core.Message, header *types.Header, statedb *state.StateDB) (uint64, error) { arbosVersion := arbosState.ArbOSVersion(statedb) if arbosVersion == 0 { // ArbOS hasn't been installed, so use the vanilla gas cap - return + return 0, nil } state, err := arbosState.OpenSystemArbosState(statedb, nil, true) if err != nil { - log.Error("failed to open ArbOS state", "err", err) - return + return 0, err } if header.BaseFee.Sign() == 0 { // if gas is free or there's no reimbursable poster, the user won't pay for L1 data costs - return + return 0, nil } brotliCompressionLevel, err := state.BrotliCompressionLevel() if err != nil { - log.Error("failed to get brotli compression level", "err", err) - return + return 0, err } posterCost, _ := state.L1PricingState().PosterDataCost(msg, l1pricing.BatchPosterAddress, brotliCompressionLevel) // Use estimate mode because this is used to raise the gas cap, so we don't want to underestimate. - posterCostInL2Gas := arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost) - *gascap = arbmath.SaturatingUAdd(*gascap, posterCostInL2Gas) + return arbos.GetPosterGas(state, header.BaseFee, core.MessageGasEstimationMode, posterCost), nil } core.GetArbOSSpeedLimitPerSecond = func(statedb *state.StateDB) (uint64, error) { diff --git a/gethhook/geth-hook.go b/gethhook/geth-hook.go index 776e8cc452..3ad275b352 100644 --- a/gethhook/geth-hook.go +++ b/gethhook/geth-hook.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/precompiles" ) diff --git a/go.mod b/go.mod index 0a37e91727..a6ae49c02c 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ replace github.com/offchainlabs/bold => ./bold require ( cloud.google.com/go/storage v1.43.0 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible - github.com/offchainlabs/bold v0.0.0-00010101000000-000000000000 github.com/Shopify/toxiproxy v2.1.4+incompatible github.com/alicebob/miniredis/v2 v2.32.1 github.com/andybalholm/brotli v1.0.4 @@ -21,7 +20,7 @@ require ( github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.27 github.com/aws/aws-sdk-go-v2/service/s3 v1.64.1 github.com/cavaliergopher/grab/v3 v3.0.1 - github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 + github.com/cockroachdb/pebble v1.1.0 github.com/codeclysm/extract/v3 v3.0.2 github.com/dgraph-io/badger/v4 v4.2.0 github.com/enescakir/emoji v1.0.0 @@ -39,6 +38,7 @@ require ( github.com/knadh/koanf v1.4.0 github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f github.com/mitchellh/mapstructure v1.4.1 + github.com/offchainlabs/bold v0.0.0-00010101000000-000000000000 github.com/pkg/errors v0.9.1 github.com/r3labs/diff/v3 v3.0.1 github.com/redis/go-redis/v9 v9.6.1 @@ -47,7 +47,6 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/wealdtech/go-merkletree v1.0.0 golang.org/x/crypto v0.24.0 - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa golang.org/x/sys v0.21.0 golang.org/x/term v0.21.0 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d @@ -73,10 +72,11 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect - google.golang.org/grpc v1.64.0 // indirect + google.golang.org/grpc v1.64.1 // indirect ) require ( @@ -101,16 +101,16 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/errors v1.9.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/redact v1.1.3 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect - github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect + github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect @@ -119,7 +119,7 @@ require ( github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + github.com/ethereum/c-kzg-4844 v1.0.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gammazero/deque v0.2.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect diff --git a/go.sum b/go.sum index 198fed00d1..6bc1e16750 100644 --- a/go.sum +++ b/go.sum @@ -13,23 +13,17 @@ cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuA cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng= cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs= cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0= -github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis/v2 v2.32.1 h1:Bz7CciDnYSaa0mX5xODh6GUITRSx+cVhjNoOR4JssBo= @@ -40,7 +34,6 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/arduino/go-paths-helper v1.2.0 h1:qDW93PR5IZUN/jzO4rCtexiwF8P4OIcOmcSgAYLZfY4= github.com/arduino/go-paths-helper v1.2.0/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= @@ -91,12 +84,15 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.31.4/go.mod h1:yMWe0F+XG0DkRZK5ODZhG github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -108,8 +104,6 @@ github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -120,38 +114,30 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= -github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= -github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codeclysm/extract/v3 v3.0.2 h1:sB4LcE3Php7LkhZwN0n2p8GCwZe92PEQutdbGURf5xc= github.com/codeclysm/extract/v3 v3.0.2/go.mod h1:NKsw+hqua9H+Rlwy/w/3Qgt9jDonYEgB6wJu+25eOKw= -github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= -github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= +github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -162,7 +148,6 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= @@ -181,18 +166,14 @@ github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/enescakir/emoji v1.0.0 h1:W+HsNql8swfCQFtioDGDHCHri8nudlK1n5p2rHCJoog= github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkKp+WKFD0= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= -github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= +github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= +github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= @@ -205,7 +186,6 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= -github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= @@ -214,13 +194,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.7.1 h1:TiCcmpWHiAU7F0rA2I3S2Y4mmLmO9KHxJ7E1QhYzQbc= github.com/gdamore/tcell/v2 v2.7.1/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg= -github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= -github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= @@ -229,7 +204,6 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= @@ -238,26 +212,18 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gobwas/ws v1.2.1 h1:F2aeBZrm2NDsc7vbovKrWSogd4wvfAxg0FQ89/iqOTk= github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= github.com/gobwas/ws-examples v0.0.0-20190625122829-a9e8908d9484 h1:XC9N1eiAyO1zg62dpOU8bex8emB/zluUtKcbLNjJxGI= github.com/gobwas/ws-examples v0.0.0-20190625122829-a9e8908d9484/go.mod h1:5nDZF4afNA1S7ZKcBXCMvDo4nuCTp1931DND7/W4aXo= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -278,15 +244,12 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= @@ -299,16 +262,13 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v62 v62.0.0 h1:/6mGCaRywZz9MuHyw9gD1CwsbmBX8GWsbFkwMmHdhl4= github.com/google/go-github/v62 v62.0.0/go.mod h1:EMxeUqGJq2xRu9DYBMwel/mr7kZrzUOfQmmpYrZn2a4= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= @@ -326,10 +286,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.12.5 h1:8gw9KZK8TiVKB6q3zHY3SBzLnrGp6HQjyfYBYGmXdxA= github.com/googleapis/gax-go/v2 v2.12.5/go.mod h1:BUDKcWo+RaKq5SC9vVYL0wLADa3VcfswbOMMRmB9H3E= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY41SORZyNJ0= @@ -352,7 +310,6 @@ github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjG github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= @@ -372,15 +329,7 @@ github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXei github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= -github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= -github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= -github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -389,9 +338,6 @@ github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/clock v0.0.0-20180524022203-d293bb356ca4/go.mod h1:nD0vlnrUjcjJhqN5WuCWZyzfd5AHZAC9/ajvbSx69xA= github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= @@ -404,19 +350,10 @@ github.com/juju/testing v0.0.0-20200510222523-6c8c298c77a0 h1:+WWUkhnTjV6RNOxkcw github.com/juju/testing v0.0.0-20200510222523-6c8c298c77a0/go.mod h1:hpGvhGHPVbNBraRLZEhoQwFLMrjK8PSlO4D3nDjKYXo= github.com/juju/utils v0.0.0-20180808125547-9dfc6dbfb02b/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= -github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= -github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= -github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= -github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/knadh/koanf v1.4.0 h1:/k0Bh49SqLyLNfte9r6cvuZWrApOQhglOmhIU3L/zDw= github.com/knadh/koanf v1.4.0/go.mod h1:1cfH5223ZeZUOs8FU2UdTmaNfHpqgtjV0+NHjRO43gs= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -430,29 +367,18 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f h1:4+gHs0jJFJ06bfN8PshnM6cHcxGjRUVRLo5jndDiKRQ= github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f/go.mod h1:tHCZHV8b2A90ObojrEAzY0Lb03gxUxjDHr5IJyAh4ew= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -461,11 +387,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -485,15 +408,6 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= @@ -502,7 +416,6 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= @@ -512,14 +425,12 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -547,31 +458,18 @@ github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -581,7 +479,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -599,37 +496,18 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/wealdtech/go-merkletree v1.0.0 h1:DsF1xMzj5rK3pSQM6mPv8jlyJyHXhFxpnA2bwEjMMBY= github.com/wealdtech/go-merkletree v1.0.0/go.mod h1:cdil512d/8ZC7Kx3bfrDvGMQXB25NTKbsm0rFrmDax4= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= @@ -650,13 +528,9 @@ go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35 go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= @@ -666,11 +540,8 @@ golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUU golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -679,23 +550,16 @@ golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= @@ -713,44 +577,28 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -775,7 +623,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= @@ -784,22 +631,16 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= @@ -813,19 +654,16 @@ google.golang.org/api v0.187.0 h1:Mxs7VATVC2v7CY+7Xwm4ndkX71hpElcvx0D1Ji/p1eo= google.golang.org/api v0.187.0/go.mod h1:KIHlTc4x7N7gKKuVsdmfBXN13yEEWXWFURWY6SBp2gk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d h1:PksQg4dV6Sem3/HkBX+Ltq8T0ke0PKIRBNBatoDTVls= google.golang.org/genproto v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:s7iA721uChleev562UJO2OYB0PPT9CMFjV+Ce7VJH5M= google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk= google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -833,9 +671,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -845,26 +682,19 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= -gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4 h1:hILp2hNrRnYjZpmIbx70psAHbBSEcQ1NIzDcUbJ1b6g= gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= @@ -877,9 +707,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/linters/koanf/handlers.go b/linters/koanf/handlers.go index 5ee3b80f9f..e3f7c67f68 100644 --- a/linters/koanf/handlers.go +++ b/linters/koanf/handlers.go @@ -126,7 +126,11 @@ func checkFlagDefs(pass *analysis.Pass, f *ast.FuncDecl, cnt map[string]int) Res if !ok { continue } - handleSelector(pass, callE.Args[1].(*ast.SelectorExpr), -1, cnt) + sel, ok := callE.Args[1].(*ast.SelectorExpr) + if !ok { + continue + } + handleSelector(pass, sel, -1, cnt) if normSL := normalizeTag(sl); !strings.EqualFold(normSL, s) { res.Errors = append(res.Errors, koanfError{ Pos: f.Pos(), diff --git a/linters/linters.go b/linters/linters.go index a6c9f6d55e..8d2807c0b2 100644 --- a/linters/linters.go +++ b/linters/linters.go @@ -1,11 +1,12 @@ package main import ( + "golang.org/x/tools/go/analysis/multichecker" + "github.com/offchainlabs/nitro/linters/koanf" "github.com/offchainlabs/nitro/linters/pointercheck" "github.com/offchainlabs/nitro/linters/rightshift" "github.com/offchainlabs/nitro/linters/structinit" - "golang.org/x/tools/go/analysis/multichecker" ) func main() { diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index 62ce177480..9aeddadf71 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/precompiles/ArbAggregator_test.go b/precompiles/ArbAggregator_test.go index 879fc737e4..eb72f12f25 100644 --- a/precompiles/ArbAggregator_test.go +++ b/precompiles/ArbAggregator_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/l1pricing" ) diff --git a/precompiles/ArbGasInfo.go b/precompiles/ArbGasInfo.go index b41dfda8a2..8d916926f3 100644 --- a/precompiles/ArbGasInfo.go +++ b/precompiles/ArbGasInfo.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/ArbGasInfo_test.go b/precompiles/ArbGasInfo_test.go index 260d7b3cef..76489c3c9a 100644 --- a/precompiles/ArbGasInfo_test.go +++ b/precompiles/ArbGasInfo_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/precompiles/ArbInfo.go b/precompiles/ArbInfo.go index 9f8cf34532..60e23ffb6e 100644 --- a/precompiles/ArbInfo.go +++ b/precompiles/ArbInfo.go @@ -5,6 +5,7 @@ package precompiles import ( "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/precompiles/ArbOwner.go b/precompiles/ArbOwner.go index 8b87445e0e..90a7b4ccc2 100644 --- a/precompiles/ArbOwner.go +++ b/precompiles/ArbOwner.go @@ -10,13 +10,13 @@ import ( "fmt" "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/util/arbmath" am "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" ) // ArbOwner precompile provides owners with tools for managing the rollup. diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index 1fc6e679cb..73252c0763 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,12 +9,14 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" @@ -114,7 +116,7 @@ func TestArbOwner(t *testing.T) { Fail(t, avail) } deposited := big.NewInt(1000000) - evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(deposited)) + evm.StateDB.AddBalance(l1pricing.L1PricerFundsPoolAddress, uint256.MustFromBig(deposited), tracing.BalanceChangeUnspecified) avail, err = gasInfo.GetL1FeesAvailable(callCtx, evm) Require(t, err) if avail.Sign() != 0 { diff --git a/precompiles/ArbRetryableTx.go b/precompiles/ArbRetryableTx.go index d925499180..49cc9a3264 100644 --- a/precompiles/ArbRetryableTx.go +++ b/precompiles/ArbRetryableTx.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/precompiles/ArbRetryableTx_test.go b/precompiles/ArbRetryableTx_test.go index 47450299ce..d5b93640c9 100644 --- a/precompiles/ArbRetryableTx_test.go +++ b/precompiles/ArbRetryableTx_test.go @@ -7,12 +7,12 @@ import ( "math/big" "testing" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/storage" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" + + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/storage" templates "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/precompiles/ArbSys.go b/precompiles/ArbSys.go index 689d3b18de..04cde46ebe 100644 --- a/precompiles/ArbSys.go +++ b/precompiles/ArbSys.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/merkletree" diff --git a/precompiles/ArbWasm.go b/precompiles/ArbWasm.go index bc24c8a6e8..eecca35ce6 100644 --- a/precompiles/ArbWasm.go +++ b/precompiles/ArbWasm.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" gethparams "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/precompile.go b/precompiles/precompile.go index 9a356c5a8e..5b5376a4ca 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -14,13 +14,6 @@ import ( "strings" "unicode" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/programs" - "github.com/offchainlabs/nitro/arbos/util" - pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -30,6 +23,13 @@ import ( "github.com/ethereum/go-ethereum/log" glog "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/programs" + "github.com/offchainlabs/nitro/arbos/util" + pgen "github.com/offchainlabs/nitro/solgen/go/precompilesgen" + "github.com/offchainlabs/nitro/util/arbmath" ) type ArbosPrecompile interface { diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index 18b33714aa..c8b8a46b96 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -10,12 +10,12 @@ import ( "os" "testing" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/storage" templates "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/precompiles/wrapper.go b/precompiles/wrapper.go index b9363c40a2..edc079fc5b 100644 --- a/precompiles/wrapper.go +++ b/precompiles/wrapper.go @@ -7,12 +7,12 @@ import ( "errors" "math/big" - "github.com/offchainlabs/nitro/arbos/arbosState" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/arbos/util" ) // DebugPrecompile is a precompile wrapper for those not allowed in production diff --git a/pubsub/common.go b/pubsub/common.go index ad36b6e622..a4fc141bb5 100644 --- a/pubsub/common.go +++ b/pubsub/common.go @@ -5,8 +5,9 @@ import ( "fmt" "strings" - "github.com/ethereum/go-ethereum/log" "github.com/redis/go-redis/v9" + + "github.com/ethereum/go-ethereum/log" ) func ResultKeyFor(streamName, id string) string { return fmt.Sprintf("%s.%s", streamName, id) } diff --git a/pubsub/consumer.go b/pubsub/consumer.go index 391042bd7e..3f28749473 100644 --- a/pubsub/consumer.go +++ b/pubsub/consumer.go @@ -10,11 +10,13 @@ import ( "strconv" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/uuid" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/stopwaiter" ) type ConsumerConfig struct { diff --git a/pubsub/producer.go b/pubsub/producer.go index 722c145a09..5aaca77aa7 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -18,12 +18,14 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/uuid" - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/redis/go-redis/v9" "github.com/spf13/pflag" + + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/stopwaiter" ) const ( diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index 8bd1aed25d..c82a35e0b8 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -9,12 +9,14 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/log" "github.com/google/go-cmp/cmp" "github.com/google/uuid" + "github.com/redis/go-redis/v9" + + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/redisutil" - "github.com/redis/go-redis/v9" ) var ( diff --git a/relay/relay_stress_test.go b/relay/relay_stress_test.go index 575a77ee6f..93ba510193 100644 --- a/relay/relay_stress_test.go +++ b/relay/relay_stress_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcastclient" diff --git a/scripts/check-build.sh b/scripts/check-build.sh index d654405c49..6084900f96 100755 --- a/scripts/check-build.sh +++ b/scripts/check-build.sh @@ -21,7 +21,6 @@ EXIT_CODE=0 # Detect operating system OS=$(uname -s) echo -e "${BLUE}Detected OS: $OS${NC}" -echo -e "${BLUE}Checking prerequisites for building Nitro locally...${NC}" # Step 1: Check Docker Installation if command_exists docker; then @@ -32,7 +31,7 @@ else fi # Step 2: Check if Docker service is running -if [[ "$OS" == "Linux" ]] && ! sudo service docker status >/dev/null; then +if [[ "$OS" == "Linux" ]] && ! pidof dockerd >/dev/null; then echo -e "${YELLOW}Docker service is not running on Linux. Start it with: sudo service docker start${NC}" EXIT_CODE=1 elif [[ "$OS" == "Darwin" ]] && ! docker info >/dev/null 2>&1; then @@ -43,8 +42,12 @@ else fi # Step 3: Check the version tag -VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "dev") -echo -e "${YELLOW}You are on the version tag: $VERSION_TAG${NC}" +VERSION_TAG=$(git tag --points-at HEAD | sed '/-/!s/$/_/' | sort -rV | sed 's/_$//' | head -n 1 | grep ^ || git show -s --pretty=%D | sed 's/, /\n/g' | grep -v '^origin/' | grep -v '^grafted\|HEAD\|master\|main$' || echo "") +if [[ -z "${VERSION_TAG}" ]]; then + echo -e "${YELLOW}Untagged version of Nitro checked out, may not be fully tested.${NC}" +else + echo -e "${GREEN}You are on Nitro version tag: $VERSION_TAG${NC}" +fi # Check if submodules are properly initialized and updated if git submodule status | grep -qE '^-|\+'; then @@ -62,7 +65,6 @@ else fi # Step 5: Check prerequisites for building binaries -echo -e "${BLUE}Checking prerequisites for building Nitro's binaries...${NC}" if [[ "$OS" == "Linux" ]]; then prerequisites=(git curl make cmake npm golang clang make gotestsum wasm2wat wasm-ld python3 yarn) else @@ -128,10 +130,11 @@ else EXIT_CODE=1 fi -echo -e "${BLUE}Verification complete.${NC}" if [ $EXIT_CODE != 0 ]; then echo -e "${RED}One or more dependencies missing. $INSTALLATION_DOCS_URL${NC}" +else + echo -e "${BLUE}Build readiness check passed.${NC}" fi exit $EXIT_CODE diff --git a/scripts/split-val-entry.sh b/scripts/split-val-entry.sh index 42e0c5fe08..ab8c520918 100755 --- a/scripts/split-val-entry.sh +++ b/scripts/split-val-entry.sh @@ -39,4 +39,4 @@ for port in 52000 52001; do done done echo launching nitro-node -/usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52001"}]' "$@" +exec /usr/local/bin/nitro --validation.wasm.allowed-wasm-module-roots /home/user/nitro-legacy/machines,/home/user/target/machines --node.block-validator.validation-server-configs-list='[{"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"ws://127.0.0.10:52001"}]' "$@" diff --git a/staker/block_validator.go b/staker/block_validator.go index 73301b3f15..43e5c7d28f 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -16,12 +16,15 @@ import ( "testing" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" + "github.com/offchainlabs/nitro/arbnode/resourcemanager" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/containers" @@ -31,7 +34,6 @@ import ( "github.com/offchainlabs/nitro/validator/client/redis" "github.com/offchainlabs/nitro/validator/inputs" "github.com/offchainlabs/nitro/validator/server_api" - "github.com/spf13/pflag" ) var ( diff --git a/staker/block_validator_schema.go b/staker/block_validator_schema.go index f6eb39f015..330116dda0 100644 --- a/staker/block_validator_schema.go +++ b/staker/block_validator_schema.go @@ -5,6 +5,7 @@ package staker import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 152c6327ef..50fb781366 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -9,12 +9,7 @@ import ( "math/big" "time" - protocol "github.com/offchainlabs/bold/chain-abstraction" - solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" - challengemanager "github.com/offchainlabs/bold/challenge-manager" - boldtypes "github.com/offchainlabs/bold/challenge-manager/types" - l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" - boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" + flag "github.com/spf13/pflag" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -22,14 +17,18 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + protocol "github.com/offchainlabs/bold/chain-abstraction" + solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" + challengemanager "github.com/offchainlabs/bold/challenge-manager" + boldtypes "github.com/offchainlabs/bold/challenge-manager/types" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" - - flag "github.com/spf13/pflag" ) var assertionCreatedId common.Hash diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 1fbe60f09d..b8d0b56ffa 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -10,11 +10,6 @@ import ( "sync" "time" - protocol "github.com/offchainlabs/bold/chain-abstraction" - "github.com/offchainlabs/bold/containers/option" - l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" - "github.com/offchainlabs/bold/state-commitments/history" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/crypto" @@ -22,6 +17,10 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + protocol "github.com/offchainlabs/bold/chain-abstraction" + "github.com/offchainlabs/bold/containers/option" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/state-commitments/history" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" challengecache "github.com/offchainlabs/nitro/staker/challenge-cache" diff --git a/staker/execution_challenge_bakend.go b/staker/execution_challenge_bakend.go index 8ab60efced..6616d8f8c1 100644 --- a/staker/execution_challenge_bakend.go +++ b/staker/execution_challenge_bakend.go @@ -7,6 +7,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/staker/legacy/block_challenge_backend.go b/staker/legacy/block_challenge_backend.go index 0af119c4f1..969c482586 100644 --- a/staker/legacy/block_challenge_backend.go +++ b/staker/legacy/block_challenge_backend.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/staker" diff --git a/staker/legacy/challenge_manager.go b/staker/legacy/challenge_manager.go index 83371e5f93..2e192d1e3f 100644 --- a/staker/legacy/challenge_manager.go +++ b/staker/legacy/challenge_manager.go @@ -10,7 +10,7 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" diff --git a/staker/legacy/challenge_test.go b/staker/legacy/challenge_test.go index 77810fe763..a85e392d99 100644 --- a/staker/legacy/challenge_test.go +++ b/staker/legacy/challenge_test.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/ospgen" "github.com/offchainlabs/nitro/validator" diff --git a/staker/legacy/l1_validator.go b/staker/legacy/l1_validator.go index 9a582b4105..9f929141c8 100644 --- a/staker/legacy/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -10,20 +10,20 @@ import ( "math/big" "time" - "github.com/offchainlabs/nitro/staker/txbuilder" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/validator" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/txbuilder" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/validator" ) type ConfirmType uint8 diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index e9bc535279..609202adcc 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -12,6 +12,9 @@ import ( "strings" "time" + "github.com/google/btree" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -31,9 +34,6 @@ import ( "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" - - "github.com/google/btree" - flag "github.com/spf13/pflag" ) var ( diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index f8bc46fa2b..cb4171bfc9 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -2,16 +2,16 @@ package multiprotocolstaker import ( "context" - "github.com/offchainlabs/nitro/staker" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/bold/solgen/go/bridgegen" boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" - + "github.com/offchainlabs/nitro/staker" boldstaker "github.com/offchainlabs/nitro/staker/bold" legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/staker/txbuilder" diff --git a/staker/rollup_watcher.go b/staker/rollup_watcher.go index 12d78114e1..b117b30c2b 100644 --- a/staker/rollup_watcher.go +++ b/staker/rollup_watcher.go @@ -13,17 +13,17 @@ import ( "strings" "sync/atomic" + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/util/headerreader" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" ) var rollupInitializedID common.Hash diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index d42951210a..62e772d5f8 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -9,23 +9,22 @@ import ( "fmt" "testing" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/validator" + validatorclient "github.com/offchainlabs/nitro/validator/client" "github.com/offchainlabs/nitro/validator/client/redis" "github.com/offchainlabs/nitro/validator/server_api" - - validatorclient "github.com/offchainlabs/nitro/validator/client" ) type StatelessBlockValidator struct { diff --git a/staker/validatorwallet/contract.go b/staker/validatorwallet/contract.go index 3202d58569..4d4f8288ef 100644 --- a/staker/validatorwallet/contract.go +++ b/staker/validatorwallet/contract.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker/txbuilder" diff --git a/staker/validatorwallet/eoa.go b/staker/validatorwallet/eoa.go index 7c7f472579..870a959152 100644 --- a/staker/validatorwallet/eoa.go +++ b/staker/validatorwallet/eoa.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" diff --git a/staker/validatorwallet/noop.go b/staker/validatorwallet/noop.go index fec39ac2b1..24c7280811 100644 --- a/staker/validatorwallet/noop.go +++ b/staker/validatorwallet/noop.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/staker/txbuilder" ) diff --git a/statetransfer/data.go b/statetransfer/data.go index df4694aa17..21268a443a 100644 --- a/statetransfer/data.go +++ b/statetransfer/data.go @@ -14,6 +14,7 @@ type ArbosInitializationInfo struct { AddressTableContents []common.Address RetryableData []InitializationDataForRetryable Accounts []AccountInitializationInfo + ChainOwner common.Address } type InitializationDataForRetryable struct { diff --git a/statetransfer/interface.go b/statetransfer/interface.go index 7d592b4430..cb70fdd14d 100644 --- a/statetransfer/interface.go +++ b/statetransfer/interface.go @@ -17,6 +17,7 @@ type InitDataReader interface { GetNextBlockNumber() (uint64, error) GetRetryableDataReader() (RetryableDataReader, error) GetAccountDataReader() (AccountDataReader, error) + GetChainOwner() (common.Address, error) } type ListReader interface { diff --git a/statetransfer/jsondatareader.go b/statetransfer/jsondatareader.go index c36061c0b0..5e992df3f0 100644 --- a/statetransfer/jsondatareader.go +++ b/statetransfer/jsondatareader.go @@ -210,3 +210,7 @@ func (r *JsonInitDataReader) GetAccountDataReader() (AccountDataReader, error) { JsonListReader: listreader, }, nil } + +func (r *JsonInitDataReader) GetChainOwner() (common.Address, error) { + return common.Address{}, nil +} diff --git a/statetransfer/memdatareader.go b/statetransfer/memdatareader.go index 1d60888937..3d6b68343c 100644 --- a/statetransfer/memdatareader.go +++ b/statetransfer/memdatareader.go @@ -99,6 +99,10 @@ func (r *MemoryInitDataReader) GetAccountDataReader() (AccountDataReader, error) }, nil } +func (r *MemoryInitDataReader) GetChainOwner() (common.Address, error) { + return r.d.ChainOwner, nil +} + func (r *MemoryInitDataReader) Close() error { return nil } diff --git a/system_tests/aliasing_test.go b/system_tests/aliasing_test.go index 60a89468a5..e6c9dab45f 100644 --- a/system_tests/aliasing_test.go +++ b/system_tests/aliasing_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/batch_poster_test.go b/system_tests/batch_poster_test.go index 0ec03e84c4..39d7fa576c 100644 --- a/system_tests/batch_poster_test.go +++ b/system_tests/batch_poster_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/andybalholm/brotli" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" diff --git a/system_tests/block_hash_test.go b/system_tests/block_hash_test.go index b437f3dad9..454b4359ad 100644 --- a/system_tests/block_hash_test.go +++ b/system_tests/block_hash_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/blocks_reexecutor_test.go b/system_tests/blocks_reexecutor_test.go index c6a7181c46..e9ef5a2260 100644 --- a/system_tests/blocks_reexecutor_test.go +++ b/system_tests/blocks_reexecutor_test.go @@ -5,6 +5,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + blocksreexecutor "github.com/offchainlabs/nitro/blocks_reexecutor" ) @@ -13,6 +15,7 @@ func TestBlocksReExecutorModes(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, false) + builder.execConfig.Caching.StateScheme = rawdb.HashScheme cleanup := builder.Build(t) defer cleanup() @@ -37,7 +40,8 @@ func TestBlocksReExecutorModes(t *testing.T) { // Reexecute blocks at mode full success := make(chan struct{}) - executorFull := blocksreexecutor.New(&blocksreexecutor.TestConfig, blockchain, feedErrChan) + executorFull, err := blocksreexecutor.New(&blocksreexecutor.TestConfig, blockchain, builder.L2.ExecNode.ChainDB, feedErrChan) + Require(t, err) executorFull.Start(ctx, success) select { case err := <-feedErrChan: @@ -49,7 +53,8 @@ func TestBlocksReExecutorModes(t *testing.T) { success = make(chan struct{}) c := &blocksreexecutor.TestConfig c.Mode = "random" - executorRandom := blocksreexecutor.New(c, blockchain, feedErrChan) + executorRandom, err := blocksreexecutor.New(c, blockchain, builder.L2.ExecNode.ChainDB, feedErrChan) + Require(t, err) executorRandom.Start(ctx, success) select { case err := <-feedErrChan: diff --git a/system_tests/bloom_test.go b/system_tests/bloom_test.go index 68fb7c3add..df6c549dda 100644 --- a/system_tests/bloom_test.go +++ b/system_tests/bloom_test.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 2448a875fd..fa99346360 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -16,17 +16,6 @@ import ( "testing" "time" - protocol "github.com/offchainlabs/bold/chain-abstraction" - solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" - challengemanager "github.com/offchainlabs/bold/challenge-manager" - modes "github.com/offchainlabs/bold/challenge-manager/types" - l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" - "github.com/offchainlabs/bold/solgen/go/bridgegen" - "github.com/offchainlabs/bold/solgen/go/challengeV2gen" - "github.com/offchainlabs/bold/solgen/go/mocksgen" - "github.com/offchainlabs/bold/solgen/go/rollupgen" - challengetesting "github.com/offchainlabs/bold/testing" - "github.com/offchainlabs/bold/testing/setup" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -39,6 +28,17 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + protocol "github.com/offchainlabs/bold/chain-abstraction" + solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" + challengemanager "github.com/offchainlabs/bold/challenge-manager" + modes "github.com/offchainlabs/bold/challenge-manager/types" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/bridgegen" + "github.com/offchainlabs/bold/solgen/go/challengeV2gen" + "github.com/offchainlabs/bold/solgen/go/mocksgen" + "github.com/offchainlabs/bold/solgen/go/rollupgen" + challengetesting "github.com/offchainlabs/bold/testing" + "github.com/offchainlabs/bold/testing/setup" "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" @@ -48,6 +48,7 @@ import ( "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/staker" + boldstaker "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/signature" @@ -182,11 +183,11 @@ func TestChallengeProtocolBOLD(t *testing.T) { Require(t, blockValidatorB.Initialize(ctx)) Require(t, blockValidatorB.Start(ctx)) - stateManager, err := staker.NewBOLDStateProvider( + stateManager, err := boldstaker.NewBOLDStateProvider( blockValidatorA, statelessA, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &boldstaker.StateProviderConfig{ ValidatorName: "good", MachineLeavesCachePath: "/tmp/good", CheckBatchFinality: false, @@ -194,11 +195,11 @@ func TestChallengeProtocolBOLD(t *testing.T) { ) Require(t, err) - stateManagerB, err := staker.NewBOLDStateProvider( + stateManagerB, err := boldstaker.NewBOLDStateProvider( blockValidatorB, statelessB, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &boldstaker.StateProviderConfig{ ValidatorName: "evil", MachineLeavesCachePath: "/tmp/evil", CheckBatchFinality: false, @@ -470,7 +471,7 @@ func createTestNodeOnL1ForBoldProtocol( isSequencer bool, nodeConfig *arbnode.Config, chainConfig *params.ChainConfig, - stackConfig *node.Config, + _ *node.Config, l2infoIn info, ) ( l2info info, currentNode *arbnode.Node, l2client *ethclient.Client, l2stack *node.Node, @@ -545,7 +546,8 @@ func createTestNodeOnL1ForBoldProtocol( execConfig := ExecConfigDefaultNonSequencerTest(t) Require(t, execConfig.Validate()) execConfig.Caching.StateScheme = rawdb.HashScheme - _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig) + useStylusWasmCache := uint32(1) + _, l2stack, l2chainDb, l2arbDb, l2blockchain = createL2BlockChain(t, l2info, "", chainConfig, execConfig, useStylusWasmCache) var sequencerTxOptsPtr *bind.TransactOpts var dataSigner signature.DataSignerFunc if isSequencer { diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index cc93b4f775..9e0adc2d9e 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -24,6 +24,7 @@ import ( "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/staker" + boldstaker "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/validator/valnode" @@ -342,7 +343,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { }) } -func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *staker.BOLDStateProvider, *staker.BlockValidator) { +func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *boldstaker.BOLDStateProvider, *staker.BlockValidator) { var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs l2chainConfig := params.ArbitrumDevTestChainConfig() l2info := NewBlockChainTestInfo( @@ -384,11 +385,11 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * Require(t, blockValidator.Initialize(ctx)) Require(t, blockValidator.Start(ctx)) - stateManager, err := staker.NewBOLDStateProvider( + stateManager, err := boldstaker.NewBOLDStateProvider( blockValidator, stateless, l2stateprovider.Height(blockChallengeLeafHeight), - &staker.StateProviderConfig{ + &boldstaker.StateProviderConfig{ ValidatorName: "", MachineLeavesCachePath: "", CheckBatchFinality: false, diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 027a41d875..b8e7befcc5 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -11,6 +11,7 @@ import ( "encoding/json" "flag" "io" + "log/slog" "math/big" "net" "net/http" @@ -21,27 +22,6 @@ import ( "testing" "time" - "github.com/offchainlabs/nitro/arbos" - "github.com/offchainlabs/nitro/arbos/arbostypes" - "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/arbstate/daprovider" - "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/blsSignatures" - "github.com/offchainlabs/nitro/cmd/chaininfo" - "github.com/offchainlabs/nitro/cmd/conf" - "github.com/offchainlabs/nitro/cmd/genericconf" - "github.com/offchainlabs/nitro/das" - "github.com/offchainlabs/nitro/deploy" - "github.com/offchainlabs/nitro/execution/gethexec" - "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/headerreader" - "github.com/offchainlabs/nitro/util/redisutil" - "github.com/offchainlabs/nitro/util/signature" - "github.com/offchainlabs/nitro/validator/inputs" - "github.com/offchainlabs/nitro/validator/server_api" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/offchainlabs/nitro/validator/valnode" - rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" "github.com/redis/go-redis/v9" "github.com/ethereum/go-ethereum" @@ -72,16 +52,36 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/arbostypes" + "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/arbstate/daprovider" + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/blsSignatures" + "github.com/offchainlabs/nitro/cmd/chaininfo" + "github.com/offchainlabs/nitro/cmd/conf" + "github.com/offchainlabs/nitro/cmd/genericconf" + "github.com/offchainlabs/nitro/das" + "github.com/offchainlabs/nitro/deploy" + "github.com/offchainlabs/nitro/execution/gethexec" _ "github.com/offchainlabs/nitro/execution/nodeInterface" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/util/redisutil" + "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/offchainlabs/nitro/util/testhelpers/env" "github.com/offchainlabs/nitro/util/testhelpers/github" - "golang.org/x/exp/slog" + "github.com/offchainlabs/nitro/validator/inputs" + "github.com/offchainlabs/nitro/validator/server_api" + "github.com/offchainlabs/nitro/validator/server_common" + "github.com/offchainlabs/nitro/validator/valnode" + rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" ) type info = *BlockchainTestInfo @@ -1196,6 +1196,7 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client, l1Genesis.BaseFee = big.NewInt(50 * params.GWei) nodeConf.Genesis = l1Genesis nodeConf.Miner.Etherbase = l1info.GetAddress("Faucet") + nodeConf.Miner.PendingFeeRecipient = l1info.GetAddress("Faucet") nodeConf.SyncMode = downloader.FullSync l1backend, err := eth.New(stack, &nodeConf) @@ -1206,26 +1207,23 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client, catalyst.RegisterSimulatedBeaconAPIs(stack, simBeacon) stack.RegisterLifecycle(simBeacon) - tempKeyStore := keystore.NewPlaintextKeyStore(t.TempDir()) + tempKeyStore := keystore.NewKeyStore(t.TempDir(), keystore.LightScryptN, keystore.LightScryptP) faucetAccount, err := tempKeyStore.ImportECDSA(l1info.Accounts["Faucet"].PrivateKey, "passphrase") Require(t, err) Require(t, tempKeyStore.Unlock(faucetAccount, "passphrase")) l1backend.AccountManager().AddBackend(tempKeyStore) - l1backend.SetEtherbase(l1info.GetAddress("Faucet")) stack.RegisterLifecycle(&lifecycle{stop: func() error { - l1backend.StopMining() - return nil + return l1backend.Stop() }}) stack.RegisterAPIs([]rpc.API{{ Namespace: "eth", - Service: filters.NewFilterAPI(filters.NewFilterSystem(l1backend.APIBackend, filters.Config{}), false), + Service: filters.NewFilterAPI(filters.NewFilterSystem(l1backend.APIBackend, filters.Config{})), }}) stack.RegisterAPIs(tracers.APIs(l1backend.APIBackend)) Require(t, stack.Start()) - Require(t, l1backend.StartMining()) rpcClient := stack.Attach() diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 286060e666..2d9140ffcd 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) diff --git a/system_tests/contract_tx_test.go b/system_tests/contract_tx_test.go index c1ef840c43..157028c6c1 100644 --- a/system_tests/contract_tx_test.go +++ b/system_tests/contract_tx_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/system_tests/das_test.go b/system_tests/das_test.go index ed3844d528..689ee924e1 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -8,6 +8,7 @@ import ( "encoding/base64" "errors" "io" + "log/slog" "math/big" "net" "net/http" @@ -30,7 +31,6 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/testhelpers" - "golang.org/x/exp/slog" ) func startLocalDASServer( diff --git a/system_tests/db_conversion_test.go b/system_tests/db_conversion_test.go index aca28262cb..d19629fade 100644 --- a/system_tests/db_conversion_test.go +++ b/system_tests/db_conversion_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/dbconv/dbconv" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/system_tests/debugapi_test.go b/system_tests/debugapi_test.go index eb2bcd095d..6be79ed4c9 100644 --- a/system_tests/debugapi_test.go +++ b/system_tests/debugapi_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/delayedinbox_test.go b/system_tests/delayedinbox_test.go index ca3e7b5999..346b0fbc2f 100644 --- a/system_tests/delayedinbox_test.go +++ b/system_tests/delayedinbox_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/system_tests/estimation_test.go b/system_tests/estimation_test.go index 6285702342..e489b1864e 100644 --- a/system_tests/estimation_test.go +++ b/system_tests/estimation_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" diff --git a/system_tests/forwarder_test.go b/system_tests/forwarder_test.go index 6a1d1c68d8..843668454d 100644 --- a/system_tests/forwarder_test.go +++ b/system_tests/forwarder_test.go @@ -15,7 +15,9 @@ import ( "time" "github.com/alicebob/miniredis/v2" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/util/redisutil" ) diff --git a/system_tests/infra_fee_test.go b/system_tests/infra_fee_test.go index 9366fc204e..2e03eb0815 100644 --- a/system_tests/infra_fee_test.go +++ b/system_tests/infra_fee_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/system_tests/initialization_test.go b/system_tests/initialization_test.go index 17e020e6ab..467882c802 100644 --- a/system_tests/initialization_test.go +++ b/system_tests/initialization_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/system_tests/log_subscription_test.go b/system_tests/log_subscription_test.go index e4402533a6..4d38ea6e9c 100644 --- a/system_tests/log_subscription_test.go +++ b/system_tests/log_subscription_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/meaningless_reorg_test.go b/system_tests/meaningless_reorg_test.go index 06a5d3d2b3..350b21a6cf 100644 --- a/system_tests/meaningless_reorg_test.go +++ b/system_tests/meaningless_reorg_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/system_tests/nodeinterface_test.go b/system_tests/nodeinterface_test.go index 927dc1b630..5c32dcf20f 100644 --- a/system_tests/nodeinterface_test.go +++ b/system_tests/nodeinterface_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" ) diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 25c52396f9..ea6dc2be8b 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index e6751d347d..dca5d6d539 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) diff --git a/system_tests/precompile_fuzz_test.go b/system_tests/precompile_fuzz_test.go index 8ab133cf58..5d0ecd1785 100644 --- a/system_tests/precompile_fuzz_test.go +++ b/system_tests/precompile_fuzz_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 9d5737c249..8821add864 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 119897cbfe..e924b224b2 100644 --- a/system_tests/program_gas_test.go +++ b/system_tests/program_gas_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/eth/tracers/logger" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -122,20 +123,23 @@ func TestProgramStorageCost(t *testing.T) { writeZeroData = multicallAppendStore(writeZeroData, slot, common.Hash{}, false) } + writePair := compareGasPair{vm.SSTORE, "storage_flush_cache"} + readPair := compareGasPair{vm.SLOAD, "storage_load_bytes32"} + for _, tc := range []struct { name string data []byte + pair compareGasPair }{ - {"initialWrite", writeRandAData}, - {"read", readData}, - {"writeAgain", writeRandBData}, - {"delete", writeZeroData}, - {"readZeros", readData}, - {"writeAgainAgain", writeRandAData}, + {"initialWrite", writeRandAData, writePair}, + {"read", readData, readPair}, + {"writeAgain", writeRandBData, writePair}, + {"delete", writeZeroData, writePair}, + {"readZeros", readData, readPair}, + {"writeAgainAgain", writeRandAData, writePair}, } { t.Run(tc.name, func(t *testing.T) { - compareGasUsage(t, builder, evmMulticall, stylusMulticall, tc.data, nil, compareGasSum, 0, - compareGasPair{vm.SSTORE, "storage_flush_cache"}, compareGasPair{vm.SLOAD, "storage_load_bytes32"}) + compareGasUsage(t, builder, evmMulticall, stylusMulticall, tc.data, nil, compareGasSum, 0, tc.pair) }) } } @@ -350,7 +354,7 @@ func compareGasUsage( switch mode { case compareGasForEach: if len(evmGasUsage[opcode]) != len(stylusGasUsage[hostio]) { - Fatal(t, "mismatch between hostios and opcodes", evmGasUsage, stylusGasUsage) + Fatal(t, "mismatch between opcode ", opcode, " - ", evmGasUsage[opcode], " and hostio ", hostio, " - ", stylusGasUsage[hostio]) } for i := range evmGasUsage[opcode] { opcodeGas := evmGasUsage[opcode][i] @@ -360,10 +364,12 @@ func compareGasUsage( } case compareGasSum: evmSum := float64(0) + for _, v := range evmGasUsage[opcode] { + evmSum += float64(v) + } stylusSum := float64(0) - for i := range evmGasUsage[opcode] { - evmSum += float64(evmGasUsage[opcode][i]) - stylusSum += stylusGasUsage[hostio][i] + for _, v := range stylusGasUsage[hostio] { + stylusSum += v } t.Logf("evm %v usage: %v - stylus %v usage: %v", opcode, evmSum, hostio, stylusSum) checkPercentDiff(t, evmSum, stylusSum, maxAllowedDifference) @@ -400,14 +406,16 @@ func evmOpcodesGasUsage(ctx context.Context, rpcClient rpc.ClientInterface, tx * // in the caller's depth. Then, we subtract the gas before the call by the // gas after the call returned. var gasAfterCall uint64 + var found bool for j := i + 1; j < len(result.StructLogs); j++ { if result.StructLogs[j].Depth == result.StructLogs[i].Depth { // back to the original call gasAfterCall = result.StructLogs[j].Gas + result.StructLogs[j].GasCost + found = true break } } - if gasAfterCall == 0 { + if !found { return nil, fmt.Errorf("malformed log: didn't get back to call original depth") } if i == 0 { diff --git a/system_tests/program_norace_test.go b/system_tests/program_norace_test.go index 56b2046716..b1e5af8395 100644 --- a/system_tests/program_norace_test.go +++ b/system_tests/program_norace_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/tracers" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_recursive_test.go b/system_tests/program_recursive_test.go index e928f9f3aa..ca726c684d 100644 --- a/system_tests/program_recursive_test.go +++ b/system_tests/program_recursive_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/mocksgen" diff --git a/system_tests/program_test.go b/system_tests/program_test.go index ea4ccddd03..5fbb1189c7 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/programs" "github.com/offchainlabs/nitro/arbos/util" @@ -1000,6 +1001,31 @@ func testCreate(t *testing.T, jit bool) { validateBlockRange(t, blocks, jit, builder) } +func TestProgramInfiniteLoopShouldCauseErrOutOfGas(t *testing.T) { + t.Parallel() + testInfiniteLoopCausesErrOutOfGas(t, true) + testInfiniteLoopCausesErrOutOfGas(t, false) +} + +func testInfiniteLoopCausesErrOutOfGas(t *testing.T, jit bool) { + builder, auth, cleanup := setupProgramTest(t, jit) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + userWasm := deployWasm(t, ctx, auth, l2client, "../arbitrator/prover/test-cases/user.wat") + // Passing input of size 4 invokes $infinite_loop function that calls the infinite loop + tx := l2info.PrepareTxTo("Owner", &userWasm, 1000000, nil, make([]byte, 4)) + Require(t, l2client.SendTransaction(ctx, tx)) + receipt, err := EnsureTxSucceeded(ctx, l2client, tx) + if !strings.Contains(err.Error(), vm.ErrOutOfGas.Error()) { + t.Fatalf("transaction should have failed with out of gas error but instead failed with: %v", err) + } + + validateBlocks(t, receipt.BlockNumber.Uint64(), jit, builder) +} + func TestProgramMemory(t *testing.T) { t.Parallel() testMemory(t, true) diff --git a/system_tests/pruning_test.go b/system_tests/pruning_test.go index 90ac3c6909..f49ed8ddcf 100644 --- a/system_tests/pruning_test.go +++ b/system_tests/pruning_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/pruning" "github.com/offchainlabs/nitro/execution/gethexec" diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index 22329a1be5..dc1356347c 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -21,6 +21,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util" ) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 89446e3c4b..af5f8bf57c 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -16,13 +16,13 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/gasestimator" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" diff --git a/system_tests/seq_coordinator_test.go b/system_tests/seq_coordinator_test.go index e7d8bf6b39..76cff95f04 100644 --- a/system_tests/seq_coordinator_test.go +++ b/system_tests/seq_coordinator_test.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "math/big" - "net" "testing" "time" @@ -153,7 +152,15 @@ func TestRedisSeqCoordinatorPriorities(t *testing.T) { nodeForwardTarget := func(nodeNum int) int { execNode := testNodes[nodeNum].ExecNode - fwTarget := execNode.TxPublisher.(*gethexec.TxPreChecker).TransactionPublisher.(*gethexec.Sequencer).ForwardTarget() + preChecker, ok := execNode.TxPublisher.(*gethexec.TxPreChecker) + if !ok { + return -1 + } + sequencer, ok := preChecker.TransactionPublisher.(*gethexec.Sequencer) + if !ok { + return -1 + } + fwTarget := sequencer.ForwardTarget() if fwTarget == "" { return -1 } @@ -323,7 +330,7 @@ func testCoordinatorMessageSync(t *testing.T, successCase bool) { // nodeB doesn't sequence transactions, but adds messages related to them to its output feed. // nodeBOutputFeedReader reads those messages from this feed and processes them. // nodeBOutputFeedReader doesn't read messages from L1 since none of the nodes posts to L1. - nodeBPort := testClientB.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + nodeBPort := testhelpers.AddrTCPPort(testClientB.ConsensusNode.BroadcastServer.ListenerAddr(), t) nodeConfigNodeBOutputFeedReader := arbnode.ConfigDefaultL1NonSequencerTest() nodeConfigNodeBOutputFeedReader.Feed.Input = *newBroadcastClientConfigTest(nodeBPort) testClientNodeBOutputFeedReader, cleanupNodeBOutputFeedReader := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigNodeBOutputFeedReader}) diff --git a/system_tests/seq_nonce_test.go b/system_tests/seq_nonce_test.go index c099563e29..7486b8a4ae 100644 --- a/system_tests/seq_nonce_test.go +++ b/system_tests/seq_nonce_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/system_tests/seq_pause_test.go b/system_tests/seq_pause_test.go index 6ce464d8da..c867a98271 100644 --- a/system_tests/seq_pause_test.go +++ b/system_tests/seq_pause_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/execution/gethexec" ) diff --git a/system_tests/seq_reject_test.go b/system_tests/seq_reject_test.go index 2dbdba6804..be230e26f5 100644 --- a/system_tests/seq_reject_test.go +++ b/system_tests/seq_reject_test.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "math/big" - "net" "strings" "sync" "sync/atomic" @@ -17,9 +16,11 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/colors" + "github.com/offchainlabs/nitro/util/testhelpers" ) func TestSequencerRejection(t *testing.T) { @@ -35,7 +36,7 @@ func TestSequencerRejection(t *testing.T) { builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.takeOwnership = false - port := builderSeq.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(builderSeq.L2.ConsensusNode.BroadcastServer.ListenerAddr(), t) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) cleanup := builder.Build(t) defer cleanup() diff --git a/system_tests/seqcompensation_test.go b/system_tests/seqcompensation_test.go index 156ced6bfc..41133b8a42 100644 --- a/system_tests/seqcompensation_test.go +++ b/system_tests/seqcompensation_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/l1pricing" ) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 21f0755225..b757291561 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "math/big" - "net" "reflect" "testing" "time" @@ -15,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l1pricing" @@ -61,7 +61,7 @@ func TestSequencerFeed(t *testing.T) { defer cleanupSeq() seqInfo, seqNode, seqClient := builderSeq.L2Info, builderSeq.L2.ConsensusNode, builderSeq.L2.Client - port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(seqNode.BroadcastServer.ListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) builder.takeOwnership = false @@ -107,7 +107,7 @@ func TestRelayedSequencerFeed(t *testing.T) { Require(t, err) config := relay.ConfigDefault - port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(seqNode.BroadcastServer.ListenerAddr(), t) config.Node.Feed.Input = *newBroadcastClientConfigTest(port) config.Node.Feed.Output = *newBroadcasterConfigTest() config.Chain.ID = bigChainId.Uint64() @@ -119,7 +119,7 @@ func TestRelayedSequencerFeed(t *testing.T) { Require(t, err) defer currentRelay.StopAndWait() - port = currentRelay.GetListenerAddr().(*net.TCPAddr).Port + port = testhelpers.AddrTCPPort(currentRelay.GetListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, false) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) builder.takeOwnership = false @@ -219,7 +219,7 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { defer cleanupC() l2clientC, nodeC := testClientC.Client, testClientC.ConsensusNode - port := nodeC.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(nodeC.BroadcastServer.ListenerAddr(), t) // The client node, connects to lying sequencer's feed nodeConfigB := arbnode.ConfigDefaultL1NonSequencerTest() @@ -361,7 +361,7 @@ func testBlockHashComparison(t *testing.T, blockHash *common.Hash, mustMismatch } defer wsBroadcastServer.StopAndWait() - port := wsBroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(wsBroadcastServer.ListenerAddr(), t) builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) @@ -468,7 +468,7 @@ func TestPopulateFeedBacklog(t *testing.T) { // Creates a sink node that will read from the output feed of the previous node. nodeConfigSink := builder.nodeConfig - port := builder.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + port := testhelpers.AddrTCPPort(builder.L2.ConsensusNode.BroadcastServer.ListenerAddr(), t) nodeConfigSink.Feed.Input = *newBroadcastClientConfigTest(port) testClientSink, cleanupSink := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigSink}) defer cleanupSink() diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index c8312350e6..6969a902ab 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 42faee7e0d..d5ed3fcd33 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/trie" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/cmd/staterecovery" "github.com/offchainlabs/nitro/execution/gethexec" diff --git a/system_tests/stylus_trace_test.go b/system_tests/stylus_trace_test.go index 52039df460..fe5de21dad 100644 --- a/system_tests/stylus_trace_test.go +++ b/system_tests/stylus_trace_test.go @@ -10,12 +10,14 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth/tracers/logger" - "github.com/holiman/uint256" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/stylus_tracer_test.go b/system_tests/stylus_tracer_test.go index 7fda39f04e..b833d7df17 100644 --- a/system_tests/stylus_tracer_test.go +++ b/system_tests/stylus_tracer_test.go @@ -7,9 +7,11 @@ import ( "encoding/binary" "testing" + "github.com/google/go-cmp/cmp" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - "github.com/google/go-cmp/cmp" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/util/containers" diff --git a/system_tests/test_info.go b/system_tests/test_info.go index 6313e392ca..105d491006 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -11,16 +11,16 @@ import ( "sync/atomic" "testing" - "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/util" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util" ) var simulatedChainID = big.NewInt(1337) diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 7828cf386d..78a7258aea 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/system_tests/twonodeslong_test.go b/system_tests/twonodeslong_test.go index 60707b83fb..5791661b16 100644 --- a/system_tests/twonodeslong_test.go +++ b/system_tests/twonodeslong_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" - - "github.com/ethereum/go-ethereum/core/types" ) func testTwoNodesLong(t *testing.T, dasModeStr string) { diff --git a/system_tests/unsupported_txtypes_test.go b/system_tests/unsupported_txtypes_test.go index a228cb2454..6e92243c85 100644 --- a/system_tests/unsupported_txtypes_test.go +++ b/system_tests/unsupported_txtypes_test.go @@ -13,10 +13,11 @@ import ( "math/big" "testing" + "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/holiman/uint256" ) func TestBlobAndInternalTxsReject(t *testing.T) { diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 6f6150208f..22d4e8294b 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -22,11 +22,10 @@ import ( "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/rpcclient" "github.com/offchainlabs/nitro/validator" + validatorclient "github.com/offchainlabs/nitro/validator/client" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/valnode" - - validatorclient "github.com/offchainlabs/nitro/validator/client" ) type mockSpawner struct { diff --git a/system_tests/wrap_transaction_test.go b/system_tests/wrap_transaction_test.go index 36052fb2db..dd68c25d6a 100644 --- a/system_tests/wrap_transaction_test.go +++ b/system_tests/wrap_transaction_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" diff --git a/util/arbmath/bits.go b/util/arbmath/bits.go index 1b91e2755a..501ef9787e 100644 --- a/util/arbmath/bits.go +++ b/util/arbmath/bits.go @@ -6,8 +6,9 @@ package arbmath import ( "encoding/binary" - "github.com/ethereum/go-ethereum/common" "github.com/holiman/uint256" + + "github.com/ethereum/go-ethereum/common" ) type bytes32 = common.Hash diff --git a/util/arbmath/math_test.go b/util/arbmath/math_test.go index 3660f3657e..befa7813e1 100644 --- a/util/arbmath/math_test.go +++ b/util/arbmath/math_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/blobs/blobs.go b/util/blobs/blobs.go index f5914edd2e..cae9c7d30f 100644 --- a/util/blobs/blobs.go +++ b/util/blobs/blobs.go @@ -118,7 +118,7 @@ func ComputeCommitmentsAndHashes(blobs []kzg4844.Blob) ([]kzg4844.Commitment, [] for i := range blobs { var err error - commitments[i], err = kzg4844.BlobToCommitment(blobs[i]) + commitments[i], err = kzg4844.BlobToCommitment(&blobs[i]) if err != nil { return nil, nil, err } @@ -135,7 +135,7 @@ func ComputeBlobProofs(blobs []kzg4844.Blob, commitments []kzg4844.Commitment) ( proofs := make([]kzg4844.Proof, len(blobs)) for i := range blobs { var err error - proofs[i], err = kzg4844.ComputeBlobProof(blobs[i], commitments[i]) + proofs[i], err = kzg4844.ComputeBlobProof(&blobs[i], commitments[i]) if err != nil { return nil, err } diff --git a/util/containers/syncmap.go b/util/containers/syncmap.go index 7952a32252..9190d81974 100644 --- a/util/containers/syncmap.go +++ b/util/containers/syncmap.go @@ -1,6 +1,9 @@ package containers -import "sync" +import ( + "fmt" + "sync" +) type SyncMap[K any, V any] struct { internal sync.Map @@ -12,7 +15,11 @@ func (m *SyncMap[K, V]) Load(key K) (V, bool) { var empty V return empty, false } - return val.(V), true + vVal, ok := val.(V) + if !ok { + panic(fmt.Sprintf("type assertion failed on %s", val)) + } + return vVal, true } func (m *SyncMap[K, V]) Store(key K, val V) { @@ -22,3 +29,17 @@ func (m *SyncMap[K, V]) Store(key K, val V) { func (m *SyncMap[K, V]) Delete(key K) { m.internal.Delete(key) } + +// Only used for testing +func (m *SyncMap[K, V]) Keys() []K { + s := make([]K, 0) + m.internal.Range(func(k, v interface{}) bool { + kKey, ok := k.(K) + if !ok { + panic(fmt.Sprintf("type assertion failed on %s", k)) + } + s = append(s, kKey) + return true + }) + return s +} diff --git a/util/contracts/address_verifier.go b/util/contracts/address_verifier.go index eb2f862210..66686e9dc8 100644 --- a/util/contracts/address_verifier.go +++ b/util/contracts/address_verifier.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/bridgegen" ) diff --git a/util/dbutil/dbutil.go b/util/dbutil/dbutil.go index 6573c5742c..28a57025e9 100644 --- a/util/dbutil/dbutil.go +++ b/util/dbutil/dbutil.go @@ -10,9 +10,10 @@ import ( "regexp" "github.com/cockroachdb/pebble" + "github.com/syndtr/goleveldb/leveldb" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb/memorydb" - "github.com/syndtr/goleveldb/leveldb" ) func IsErrNotFound(err error) bool { diff --git a/util/headerreader/blob_client.go b/util/headerreader/blob_client.go index 4831994bba..0c92ff2e85 100644 --- a/util/headerreader/blob_client.go +++ b/util/headerreader/blob_client.go @@ -15,16 +15,17 @@ import ( "path" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/blobs" "github.com/offchainlabs/nitro/util/jsonapi" "github.com/offchainlabs/nitro/util/pretty" - - "github.com/spf13/pflag" ) type BlobClient struct { @@ -248,7 +249,7 @@ func (b *BlobClient) blobSidecars(ctx context.Context, slot uint64, versionedHas var proof kzg4844.Proof copy(proof[:], blobItem.KzgProof) - err = kzg4844.VerifyBlobProof(output[outputIdx], commitment, proof) + err = kzg4844.VerifyBlobProof(&output[outputIdx], commitment, proof) if err != nil { return nil, fmt.Errorf("failed to verify blob proof for blob at slot(%d) at index(%d), blob(%s)", slot, blobItem.Index, pretty.FirstFewChars(blobItem.Blob.String())) } diff --git a/util/headerreader/blob_client_test.go b/util/headerreader/blob_client_test.go index 9735899daa..52c22e434a 100644 --- a/util/headerreader/blob_client_test.go +++ b/util/headerreader/blob_client_test.go @@ -11,8 +11,9 @@ import ( "reflect" "testing" - "github.com/offchainlabs/nitro/util/testhelpers" "github.com/r3labs/diff/v3" + + "github.com/offchainlabs/nitro/util/testhelpers" ) func TestSaveBlobsToDisk(t *testing.T) { diff --git a/util/headerreader/header_reader.go b/util/headerreader/header_reader.go index 98f778dee8..f8e3bc6cd6 100644 --- a/util/headerreader/header_reader.go +++ b/util/headerreader/header_reader.go @@ -12,6 +12,8 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -19,9 +21,9 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/stopwaiter" - flag "github.com/spf13/pflag" ) // A regexp matching "execution reverted" errors returned from the parent chain RPC. diff --git a/util/jsonapi/preimages_test.go b/util/jsonapi/preimages_test.go index 3074a1e698..5b699df5fe 100644 --- a/util/jsonapi/preimages_test.go +++ b/util/jsonapi/preimages_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/merkletree/merkleAccumulator_test.go b/util/merkletree/merkleAccumulator_test.go index d26f0244d3..95e1862b7a 100644 --- a/util/merkletree/merkleAccumulator_test.go +++ b/util/merkletree/merkleAccumulator_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) diff --git a/util/merkletree/merkleEventProof.go b/util/merkletree/merkleEventProof.go index 130249cc3f..cab85dbefe 100644 --- a/util/merkletree/merkleEventProof.go +++ b/util/merkletree/merkleEventProof.go @@ -5,6 +5,7 @@ package merkletree import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) diff --git a/util/merkletree/merkleEventProof_test.go b/util/merkletree/merkleEventProof_test.go index 6af8479190..c0c8e777cb 100644 --- a/util/merkletree/merkleEventProof_test.go +++ b/util/merkletree/merkleEventProof_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/util/merkletree/merkleTree.go b/util/merkletree/merkleTree.go index fffa9bcabc..9cf7b485d9 100644 --- a/util/merkletree/merkleTree.go +++ b/util/merkletree/merkleTree.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/util/redisutil/test_redis.go b/util/redisutil/test_redis.go index 6d493b1546..9cabfc23d6 100644 --- a/util/redisutil/test_redis.go +++ b/util/redisutil/test_redis.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/alicebob/miniredis/v2" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/rpcclient/rpcclient_test.go b/util/rpcclient/rpcclient_test.go index 1a7da54774..f711747b70 100644 --- a/util/rpcclient/rpcclient_test.go +++ b/util/rpcclient/rpcclient_test.go @@ -9,10 +9,12 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/rpc" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + + "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/rpc" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/sharedmetrics/sharedmetrics.go b/util/sharedmetrics/sharedmetrics.go index 9b4b3609bc..1df34d4d54 100644 --- a/util/sharedmetrics/sharedmetrics.go +++ b/util/sharedmetrics/sharedmetrics.go @@ -2,6 +2,7 @@ package sharedmetrics import ( "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 5ed852bfbc..f222860d8b 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,9 +4,11 @@ import ( "context" "errors" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/util/contracts" - flag "github.com/spf13/pflag" ) type SignVerify struct { diff --git a/util/stopwaiter/stopwaiter.go b/util/stopwaiter/stopwaiter.go index 1e70e328eb..993768dd85 100644 --- a/util/stopwaiter/stopwaiter.go +++ b/util/stopwaiter/stopwaiter.go @@ -13,6 +13,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/util/stopwaiter/stopwaiter_test.go b/util/stopwaiter/stopwaiter_test.go index 5319927887..c561e1f43b 100644 --- a/util/stopwaiter/stopwaiter_test.go +++ b/util/stopwaiter/stopwaiter_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/util/testhelpers/env/env.go b/util/testhelpers/env/env.go index 27d74465de..2a8090c212 100644 --- a/util/testhelpers/env/env.go +++ b/util/testhelpers/env/env.go @@ -14,7 +14,7 @@ import ( // An environment variable controls that behavior. func GetTestStateScheme() string { envTestStateScheme := os.Getenv("TEST_STATE_SCHEME") - stateScheme := rawdb.PathScheme + stateScheme := rawdb.HashScheme if envTestStateScheme == rawdb.PathScheme || envTestStateScheme == rawdb.HashScheme { stateScheme = envTestStateScheme } diff --git a/util/testhelpers/port.go b/util/testhelpers/port.go index d31fa41cdc..c17e9d9ec2 100644 --- a/util/testhelpers/port.go +++ b/util/testhelpers/port.go @@ -2,6 +2,7 @@ package testhelpers import ( "net" + "testing" ) // FreeTCPPortListener returns a listener listening on an unused local port. @@ -15,3 +16,13 @@ func FreeTCPPortListener() (net.Listener, error) { } return l, nil } + +// Func AddrTCPPort returns the port of a net.Addr. +func AddrTCPPort(n net.Addr, t *testing.T) int { + t.Helper() + tcpAddr, ok := n.(*net.TCPAddr) + if !ok { + t.Fatal("Could not get TCP address net.Addr") + } + return tcpAddr.Port +} diff --git a/util/testhelpers/port_test.go b/util/testhelpers/port_test.go index ef9bb18537..bb8f87b2f7 100644 --- a/util/testhelpers/port_test.go +++ b/util/testhelpers/port_test.go @@ -14,10 +14,18 @@ func TestFreeTCPPortListener(t *testing.T) { if err != nil { t.Fatal(err) } - if aListener.Addr().(*net.TCPAddr).Port == bListener.Addr().(*net.TCPAddr).Port { + aTCPAddr, ok := aListener.Addr().(*net.TCPAddr) + if !ok { + t.Fatalf("aListener.Addr() is not a *net.TCPAddr: %v", aListener.Addr()) + } + bTCPAddr, ok := bListener.Addr().(*net.TCPAddr) + if !ok { + t.Fatalf("bListener.Addr() is not a *net.TCPAddr: %v", aListener.Addr()) + } + if aTCPAddr.Port == bTCPAddr.Port { t.Errorf("FreeTCPPortListener() got same port: %v, %v", aListener, bListener) } - if aListener.Addr().(*net.TCPAddr).Port == 0 || bListener.Addr().(*net.TCPAddr).Port == 0 { + if aTCPAddr.Port == 0 || bTCPAddr.Port == 0 { t.Errorf("FreeTCPPortListener() got port 0") } } diff --git a/util/testhelpers/testhelpers.go b/util/testhelpers/testhelpers.go index d681b422bf..7f3e63a811 100644 --- a/util/testhelpers/testhelpers.go +++ b/util/testhelpers/testhelpers.go @@ -7,6 +7,7 @@ import ( "context" crypto "crypto/rand" "io" + "log/slog" "math/big" "math/rand" "os" @@ -17,8 +18,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/colors" - "golang.org/x/exp/slog" ) // Fail a test should an error occur diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index c5726ffe8b..4bfb721f59 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -5,10 +5,14 @@ import ( "fmt" "sync/atomic" + "github.com/redis/go-redis/v9" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/pubsub" "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/redisutil" @@ -16,8 +20,6 @@ import ( "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_common" - "github.com/redis/go-redis/v9" - "github.com/spf13/pflag" ) type ValidationClientConfig struct { diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index d81491f2a1..35ab9a8b12 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -11,21 +11,19 @@ import ( "sync/atomic" "time" - "github.com/offchainlabs/nitro/validator" - - "github.com/offchainlabs/nitro/util/containers" - "github.com/offchainlabs/nitro/util/rpcclient" - "github.com/offchainlabs/nitro/util/stopwaiter" - - "github.com/offchainlabs/nitro/validator/server_api" - "github.com/offchainlabs/nitro/validator/server_common" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/util/containers" + "github.com/offchainlabs/nitro/util/rpcclient" + "github.com/offchainlabs/nitro/util/stopwaiter" + "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_api" + "github.com/offchainlabs/nitro/validator/server_common" ) type ValidationClient struct { diff --git a/validator/execution_state.go b/validator/execution_state.go index a7e4480027..81e32a6992 100644 --- a/validator/execution_state.go +++ b/validator/execution_state.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" ) diff --git a/validator/interface.go b/validator/interface.go index 7cedd40b05..a1c22eb69f 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -5,6 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 8dfbc8446a..f56493cd92 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/util/jsonapi" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index f65dbe04ba..cf0a77e6de 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -11,8 +11,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index 479db58515..1f8e9625c1 100644 --- a/validator/server_arb/execution_run_test.go +++ b/validator/server_arb/execution_run_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 1e73e6b212..c429fa6101 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -10,6 +10,7 @@ package server_arb ResolvedPreimage preimageResolverC(size_t context, uint8_t preimageType, const uint8_t* hash); */ import "C" + import ( "context" "errors" @@ -21,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/containers" @@ -51,16 +53,32 @@ type MachineInterface interface { type ArbitratorMachine struct { mutex sync.Mutex // needed because go finalizers don't synchronize (meaning they aren't thread safe) ptr *C.struct_Machine - contextId *int64 // has a finalizer attached to remove the preimage resolver from the global map - frozen bool // does not allow anything that changes machine state, not cloned with the machine + contextId *int64 + frozen bool // does not allow anything that changes machine state, not cloned with the machine } // Assert that ArbitratorMachine implements MachineInterface var _ MachineInterface = (*ArbitratorMachine)(nil) -var preimageResolvers containers.SyncMap[int64, GoPreimageResolver] +var preimageResolvers containers.SyncMap[int64, goPreimageResolverWithRefCounter] var lastPreimageResolverId atomic.Int64 // atomic +func dereferenceContextId(contextId *int64) { + if contextId != nil { + resolverWithRefCounter, ok := preimageResolvers.Load(*contextId) + if !ok { + panic(fmt.Sprintf("dereferenceContextId: resolver with ref counter not found, contextId: %v", *contextId)) + } + + refCount := resolverWithRefCounter.refCounter.Add(-1) + if refCount < 0 { + panic(fmt.Sprintf("dereferenceContextId: ref counter is negative, contextId: %v", *contextId)) + } else if refCount == 0 { + preimageResolvers.Delete(*contextId) + } + } +} + // Any future calls to this machine will result in a panic func (m *ArbitratorMachine) Destroy() { m.mutex.Lock() @@ -71,11 +89,9 @@ func (m *ArbitratorMachine) Destroy() { // We no longer need a finalizer runtime.SetFinalizer(m, nil) } - m.contextId = nil -} -func freeContextId(context *int64) { - preimageResolvers.Delete(*context) + dereferenceContextId(m.contextId) + m.contextId = nil } func machineFromPointer(ptr *C.struct_Machine) *ArbitratorMachine { @@ -112,6 +128,16 @@ func (m *ArbitratorMachine) Clone() *ArbitratorMachine { defer m.mutex.Unlock() newMach := machineFromPointer(C.arbitrator_clone_machine(m.ptr)) newMach.contextId = m.contextId + + if m.contextId != nil { + resolverWithRefCounter, ok := preimageResolvers.Load(*m.contextId) + if ok { + resolverWithRefCounter.refCounter.Add(1) + } else { + panic(fmt.Sprintf("Clone: resolver with ref counter not found, contextId: %v", *m.contextId)) + } + } + return newMach } @@ -350,19 +376,24 @@ func (m *ArbitratorMachine) AddDelayedInboxMessage(index uint64, data []byte) er } type GoPreimageResolver = func(arbutil.PreimageType, common.Hash) ([]byte, error) +type goPreimageResolverWithRefCounter struct { + resolver GoPreimageResolver + refCounter *atomic.Int64 +} //export preimageResolver func preimageResolver(context C.size_t, ty C.uint8_t, ptr unsafe.Pointer) C.ResolvedPreimage { var hash common.Hash input := (*[1 << 30]byte)(ptr)[:32] copy(hash[:], input) - resolver, ok := preimageResolvers.Load(int64(context)) + resolverWithRefCounter, ok := preimageResolvers.Load(int64(context)) if !ok { + log.Error("preimageResolver: resolver with ref counter not found", "context", int64(context)) return C.ResolvedPreimage{ len: -1, } } - preimage, err := resolver(arbutil.PreimageType(ty), hash) + preimage, err := resolverWithRefCounter.resolver(arbutil.PreimageType(ty), hash) if err != nil { log.Error("preimage resolution failed", "err", err) return C.ResolvedPreimage{ @@ -382,10 +413,18 @@ func (m *ArbitratorMachine) SetPreimageResolver(resolver GoPreimageResolver) err if m.frozen { return errors.New("machine frozen") } + dereferenceContextId(m.contextId) + id := lastPreimageResolverId.Add(1) - preimageResolvers.Store(id, resolver) + refCounter := atomic.Int64{} + refCounter.Store(1) + resolverWithRefCounter := goPreimageResolverWithRefCounter{ + resolver: resolver, + refCounter: &refCounter, + } + preimageResolvers.Store(id, resolverWithRefCounter) + m.contextId = &id - runtime.SetFinalizer(m.contextId, freeContextId) C.arbitrator_set_context(m.ptr, u64(id)) return nil } diff --git a/validator/server_arb/machine_loader.go b/validator/server_arb/machine_loader.go index 13cf0f2403..8c9d37e174 100644 --- a/validator/server_arb/machine_loader.go +++ b/validator/server_arb/machine_loader.go @@ -4,6 +4,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_arb/machine_test.go b/validator/server_arb/machine_test.go new file mode 100644 index 0000000000..008d757889 --- /dev/null +++ b/validator/server_arb/machine_test.go @@ -0,0 +1,94 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package server_arb + +import ( + "path" + "reflect" + "runtime" + "sort" + "testing" + + "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/util/testhelpers" +) + +func TestEntriesAreDeletedFromPreimageResolversGlobalMap(t *testing.T) { + resolver := func(arbutil.PreimageType, common.Hash) ([]byte, error) { + return nil, nil + } + + sortedKeys := func() []int64 { + keys := preimageResolvers.Keys() + sort.Slice(keys, func(i, j int) bool { + return keys[i] < keys[j] + }) + return keys + } + + // clear global map before running test + preimageKeys := sortedKeys() + for _, key := range preimageKeys { + preimageResolvers.Delete(key) + } + + _, filename, _, _ := runtime.Caller(0) + wasmDir := path.Join(path.Dir(filename), "../../arbitrator/prover/test-cases/") + wasmPath := path.Join(wasmDir, "global-state.wasm") + modulePaths := []string{path.Join(wasmDir, "global-state-wrapper.wasm")} + + machine1, err := LoadSimpleMachine(wasmPath, modulePaths, true) + testhelpers.RequireImpl(t, err) + err = machine1.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + + machine2, err := LoadSimpleMachine(wasmPath, modulePaths, true) + testhelpers.RequireImpl(t, err) + err = machine2.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + + machine1Clone1 := machine1.Clone() + machine1Clone2 := machine1.Clone() + + checkKeys := func(expectedKeys []int64, scenario string) { + keys := sortedKeys() + if !reflect.DeepEqual(keys, expectedKeys) { + t.Fatal("Unexpected preimageResolversKeys got", keys, "expected", expectedKeys, "scenario", scenario) + } + } + + machine1ContextId := *machine1.contextId + machine2ContextId := *machine2.contextId + + checkKeys([]int64{machine1ContextId, machine2ContextId}, "initial") + + // the machine's contextId should change when setting preimage resolver for the second time, + // and the entry for the old context id should be deleted + err = machine2.SetPreimageResolver(resolver) + testhelpers.RequireImpl(t, err) + if machine2ContextId == *machine2.contextId { + t.Fatal("Context id didn't change after setting preimage resolver for the second time") + } + machine2ContextId = *machine2.contextId + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after setting preimage resolver for machine2 for the second time") + + machine1Clone1.Destroy() + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1Clone1 is destroyed") + + machine1.Destroy() + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed") + + // it is possible to destroy the same machine multiple times + machine1.Destroy() + checkKeys([]int64{machine1ContextId, machine2ContextId}, "after machine1 is destroyed again") + + // entry for machine1ContextId should be deleted only after machine1 and all its clones are destroyed + machine1Clone2.Destroy() + checkKeys([]int64{machine2ContextId}, "after machine1Clone2 is destroyed") + + machine2.Destroy() + checkKeys([]int64{}, "after machine2 is destroyed") +} diff --git a/validator/server_arb/mock_machine.go b/validator/server_arb/mock_machine.go index 3cf0f9f771..00512d1d77 100644 --- a/validator/server_arb/mock_machine.go +++ b/validator/server_arb/mock_machine.go @@ -7,6 +7,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/nitro_machine.go b/validator/server_arb/nitro_machine.go index 926b1e8930..a2f7de3153 100644 --- a/validator/server_arb/nitro_machine.go +++ b/validator/server_arb/nitro_machine.go @@ -9,6 +9,7 @@ package server_arb #include */ import "C" + import ( "context" "errors" @@ -19,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_arb/prover_interface.go b/validator/server_arb/prover_interface.go index 3010d2138d..8479a8aa8f 100644 --- a/validator/server_arb/prover_interface.go +++ b/validator/server_arb/prover_interface.go @@ -22,10 +22,12 @@ void AddToStringList(char** list, int index, char* val) { } */ import "C" + import ( "unsafe" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 07971e2ba5..bb7fbcf97d 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -10,18 +10,18 @@ import ( "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode/redis" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var arbitratorValidationSteps = metrics.NewRegisteredHistogram("arbitrator/validation/steps", nil, metrics.NewBoundedHistogramSample()) diff --git a/validator/server_common/machine_loader.go b/validator/server_common/machine_loader.go index f4633ebedf..e86589b657 100644 --- a/validator/server_common/machine_loader.go +++ b/validator/server_common/machine_loader.go @@ -5,6 +5,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/containers" ) diff --git a/validator/server_common/valrun.go b/validator/server_common/valrun.go index 8486664008..9a2a6cb414 100644 --- a/validator/server_common/valrun.go +++ b/validator/server_common/valrun.go @@ -2,6 +2,7 @@ package server_common import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/util/containers" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_jit/jit_machine.go b/validator/server_jit/jit_machine.go index 0748101277..dc7657441e 100644 --- a/validator/server_jit/jit_machine.go +++ b/validator/server_jit/jit_machine.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/validator" ) diff --git a/validator/server_jit/machine_loader.go b/validator/server_jit/machine_loader.go index 3d8b01367f..a4ccede324 100644 --- a/validator/server_jit/machine_loader.go +++ b/validator/server_jit/machine_loader.go @@ -10,6 +10,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_common" ) diff --git a/validator/server_jit/spawner.go b/validator/server_jit/spawner.go index f30b6e181a..91b1e818f0 100644 --- a/validator/server_jit/spawner.go +++ b/validator/server_jit/spawner.go @@ -3,11 +3,12 @@ package server_jit import ( "context" "fmt" - flag "github.com/spf13/pflag" "runtime" "sync/atomic" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/ethdb" diff --git a/validator/validation_entry.go b/validator/validation_entry.go index 4ec6919d3b..555a4c76c7 100644 --- a/validator/validation_entry.go +++ b/validator/validation_entry.go @@ -3,6 +3,7 @@ package validator import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/validator/valnode/redis/consumer.go b/validator/valnode/redis/consumer.go index 4392a3c91e..93b3eddd3f 100644 --- a/validator/valnode/redis/consumer.go +++ b/validator/valnode/redis/consumer.go @@ -6,14 +6,16 @@ import ( "runtime" "time" + "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/pubsub" "github.com/offchainlabs/nitro/util/redisutil" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" - "github.com/spf13/pflag" ) // ValidationServer implements consumer for the requests originated from diff --git a/validator/valnode/redis/consumer_test.go b/validator/valnode/redis/consumer_test.go index 0ebd697f16..595aecc9ca 100644 --- a/validator/valnode/redis/consumer_test.go +++ b/validator/valnode/redis/consumer_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/redisutil" "github.com/offchainlabs/nitro/util/testhelpers" ) diff --git a/validator/valnode/valnode.go b/validator/valnode/valnode.go index 972e11189d..e2f4f79bef 100644 --- a/validator/valnode/valnode.go +++ b/validator/valnode/valnode.go @@ -3,17 +3,18 @@ package valnode import ( "context" - "github.com/offchainlabs/nitro/validator" + "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + + "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_api" "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/server_jit" "github.com/offchainlabs/nitro/validator/valnode/redis" - "github.com/spf13/pflag" ) type WasmConfig struct { diff --git a/wavmio/stub.go b/wavmio/stub.go index 0c82506ff3..01031860e9 100644 --- a/wavmio/stub.go +++ b/wavmio/stub.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" ) diff --git a/wsbroadcastserver/clientconnection.go b/wsbroadcastserver/clientconnection.go index 00ae0f0dcf..2585452db7 100644 --- a/wsbroadcastserver/clientconnection.go +++ b/wsbroadcastserver/clientconnection.go @@ -13,14 +13,15 @@ import ( "sync/atomic" "time" + "github.com/gobwas/ws" + "github.com/gobwas/ws/wsflate" + "github.com/mailru/easygo/netpoll" + "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcaster/backlog" m "github.com/offchainlabs/nitro/broadcaster/message" - - "github.com/gobwas/ws" - "github.com/gobwas/ws/wsflate" - "github.com/mailru/easygo/netpoll" "github.com/offchainlabs/nitro/util/stopwaiter" ) diff --git a/wsbroadcastserver/connectionlimiter.go b/wsbroadcastserver/connectionlimiter.go index e483eb545e..d086fc074e 100644 --- a/wsbroadcastserver/connectionlimiter.go +++ b/wsbroadcastserver/connectionlimiter.go @@ -8,9 +8,10 @@ import ( "sync" "time" + flag "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - flag "github.com/spf13/pflag" ) var ( diff --git a/wsbroadcastserver/utils.go b/wsbroadcastserver/utils.go index 9df1d7d9ca..1e72915047 100644 --- a/wsbroadcastserver/utils.go +++ b/wsbroadcastserver/utils.go @@ -12,10 +12,11 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/log" "github.com/gobwas/ws" "github.com/gobwas/ws/wsflate" "github.com/gobwas/ws/wsutil" + + "github.com/ethereum/go-ethereum/log" ) func init() { diff --git a/wsbroadcastserver/wsbroadcastserver.go b/wsbroadcastserver/wsbroadcastserver.go index ee21cbaae3..da9420a527 100644 --- a/wsbroadcastserver/wsbroadcastserver.go +++ b/wsbroadcastserver/wsbroadcastserver.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcaster/backlog" m "github.com/offchainlabs/nitro/broadcaster/message" From bf1838e4217e130647c541e49683d9a391bf066d Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 18 Nov 2024 22:45:46 +0100 Subject: [PATCH 146/210] Update to the same go-ethereum pin as master This version of the go-ethereum project is needed for some of the tests to behave correctly. --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index b1075d3786..f30479f794 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit b1075d3786b28a6a3a06fe0e0ab8d1cdecc72f55 +Subproject commit f30479f79403b3657b3a5593a36ad8ae0e20c09e From d0bf3f4d7ad17736eae68330dea5825217f83d03 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 18 Nov 2024 23:12:04 +0100 Subject: [PATCH 147/210] Fix the path since it was moved down a dir --- staker/legacy/challenge_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staker/legacy/challenge_test.go b/staker/legacy/challenge_test.go index a85e392d99..b4ff7e1319 100644 --- a/staker/legacy/challenge_test.go +++ b/staker/legacy/challenge_test.go @@ -242,7 +242,7 @@ func runChallengeTest( func createBaseMachine(t *testing.T, wasmname string, wasmModules []string) *server_arb.ArbitratorMachine { _, filename, _, _ := runtime.Caller(0) - wasmDir := path.Join(path.Dir(filename), "../arbitrator/prover/test-cases/") + wasmDir := path.Join(path.Dir(filename), "../../arbitrator/prover/test-cases/") wasmPath := path.Join(wasmDir, wasmname) From bc73ebc5cd70b0dfc175968c72abe1ea93b56c7d Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 19 Nov 2024 10:57:51 +0530 Subject: [PATCH 148/210] update geth pin --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 81b27b89ae..70fb32ba6e 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 81b27b89ae823835646ebe5d649518a2755d8ee7 +Subproject commit 70fb32ba6e5cfc120d7496652828cf4fc9da3f2f From 1ef4e05d9ef7d8a625a0524e0f5d40c6ccdcf340 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 19 Nov 2024 15:26:02 +0530 Subject: [PATCH 149/210] update geth submodule --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 9cf4acc45a..2c34a6d386 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 9cf4acc45a2b0cea723e8323d2b811e358b04ca0 +Subproject commit 2c34a6d3869bd72f74cd46263434f438de321f7c From 7c1140fbaca9387341cd69dafceaa39c7377af63 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 19 Nov 2024 13:37:11 +0100 Subject: [PATCH 150/210] Update the bold pin and remove some logging --- bold | 2 +- staker/bold/bold_state_provider.go | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/bold b/bold index ece8f7a0cf..0dd25bff8e 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit ece8f7a0cf26caa6525f32aa409df48b5f572fbd +Subproject commit 0dd25bff8e8a39f8361201ddf67aa0c45d482028 diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 83051c0cb3..6e6a99646d 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -256,12 +256,6 @@ func (s *BOLDStateProvider) StatesInBatchRange( posInBatch++ } } - fmt.Printf("got states from batch %v pos %v up to batch %v height %v\n", fromState.Batch, fromState.PosInBatch, batchLimit, toHeight) - println("----- states -----") - for i, state := range states { - fmt.Printf("batch %v pos %v hash %v\n", state.Batch, state.PosInBatch, machineHashes[i]) - } - println("------------------") return machineHashes, states, nil } @@ -402,12 +396,6 @@ func (s *BOLDStateProvider) CollectMachineHashes( return nil, err } log.Info(fmt.Sprintf("Finished gathering machine hashes for request %+v", cfg)) - fmt.Printf("got machine hashes from message num %v start index %v step size %v desired hashes %v\n", messageNum, cfg.MachineStartIndex, cfg.StepSize, cfg.NumDesiredHashes) - println("----- hashes -----") - for i, h := range result { - fmt.Printf("index %v hash %v\n", i, h) - } - println("------------------") // Do not save a history commitment of length 1 to the cache. if len(result) > 1 && s.historyCache != nil { if err := s.historyCache.Put(cacheKey, result); err != nil { From 361a747c056ac2b90f11054f899cb7fee4db6cdb Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 19 Nov 2024 14:10:45 +0100 Subject: [PATCH 151/210] Fix 2 lint issues The first is to sort the imports in mock_machine_test.go. The second is to rearrange the bold machine to avoid the downcast. --- system_tests/mock_machine_test.go | 1 + validator/server_arb/boldmach/machine.go | 27 +++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/system_tests/mock_machine_test.go b/system_tests/mock_machine_test.go index 516a6b31d8..ea7fcbaef1 100644 --- a/system_tests/mock_machine_test.go +++ b/system_tests/mock_machine_test.go @@ -5,6 +5,7 @@ package arbtest import ( "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator/server_arb" ) diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go index 6341f5510d..ba51fe6b72 100644 --- a/validator/server_arb/boldmach/machine.go +++ b/validator/server_arb/boldmach/machine.go @@ -19,16 +19,9 @@ type boldMachine struct { // Ensure boldMachine implements server_arb.MachineInterface. var _ server_arb.MachineInterface = (*boldMachine)(nil) -// MachineWrapper wraps a server_arb.MachineInterface and adds one step to the -// front of the machine's execution. -// -// This zeroth step should be at the same global state as the inner arbitrator -// machine has at step 0, but the machine is in the Finished state rather than -// the Running state. -func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { +func newBoldMachine(inner server_arb.MachineInterface) *boldMachine { z := server_arb.NewFinishedMachine() - err := z.SetGlobalState(inner.GetGlobalState()) - if err != nil { + if err := z.SetGlobalState(inner.GetGlobalState()); err != nil { // This should only occur if the machine is frozen, // which it isn't because we just created it. panic(err) @@ -40,11 +33,21 @@ func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterfa } } +// MachineWrapper wraps a server_arb.MachineInterface and adds one step to the +// front of the machine's execution. +// +// This zeroth step should be at the same global state as the inner arbitrator +// machine has at step 0, but the machine is in the Finished state rather than +// the Running state. +func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { + return newBoldMachine(inner) +} + // CloneMachineInterface returns a new boldMachine with the same inner machine. func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { - c := MachineWrapper(m.inner.CloneMachineInterface()) - c.(*boldMachine).hasStepped = m.hasStepped - return c + bMach := newBoldMachine(m.inner.CloneMachineInterface()) + bMach.hasStepped = m.hasStepped + return bMach } // GetStepCount returns zero if the machine has not stepped, otherwise it From 61a81eb2f288311cc2a134a629ff1ab5795c56a6 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 19 Nov 2024 22:29:43 +0530 Subject: [PATCH 152/210] update geth pin to master --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 70fb32ba6e..46fee83ed9 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 70fb32ba6e5cfc120d7496652828cf4fc9da3f2f +Subproject commit 46fee83ed96f765f16a39b0a2733190c67294e27 From 3b07fccd001a9936ae22a0bfb63656e44c2f6146 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 20 Nov 2024 11:16:16 +0530 Subject: [PATCH 153/210] Check batchProcessed > 0 to avoid underflow --- arbnode/sync_monitor.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arbnode/sync_monitor.go b/arbnode/sync_monitor.go index 629068c4fb..f06e9ca49f 100644 --- a/arbnode/sync_monitor.go +++ b/arbnode/sync_monitor.go @@ -146,11 +146,13 @@ func (s *SyncMonitor) FullSyncProgressMap() map[string]interface{} { batchProcessed := s.inboxReader.GetLastReadBatchCount() res["batchProcessed"] = batchProcessed - processedBatchMsgs, err := s.inboxReader.Tracker().GetBatchMessageCount(batchProcessed - 1) - if err != nil { - res["batchMetadataError"] = err.Error() - } else { - res["messageOfProcessedBatch"] = processedBatchMsgs + if batchProcessed > 0 { + processedBatchMsgs, err := s.inboxReader.Tracker().GetBatchMessageCount(batchProcessed - 1) + if err != nil { + res["batchMetadataError"] = err.Error() + } else { + res["messageOfProcessedBatch"] = processedBatchMsgs + } } l1reader := s.inboxReader.l1Reader From 75370612c18b8cd978d81b87cc5bd42c87d97de0 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 20 Nov 2024 08:46:18 +0100 Subject: [PATCH 154/210] Remove maxNumberOfBlocks from bold state provider The signature changed in the bold repo, and needed to be updated in Nitro as well. --- bold | 2 +- staker/bold/bold_state_provider.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bold b/bold index 0dd25bff8e..64e8d6ad4c 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 0dd25bff8e8a39f8361201ddf67aa0c45d482028 +Subproject commit 64e8d6ad4cf2cb6868169f020e6a02833fedc679 diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 6e6a99646d..899b3c7a80 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -72,9 +72,9 @@ func NewBOLDStateProvider( } // ExecutionStateAfterPreviousState Produces the L2 execution state for the next -// assertion. Returns the state at maxInboxCount or maxNumberOfBlocks after the -// previous state, whichever is earlier. If previousGlobalState is nil, defaults -// to returning the state at maxInboxCount. +// assertion. Returns the state at maxInboxCount or blockChallengeLeafHeight +// after the previous state, whichever is earlier. If previousGlobalState is +// nil, defaults to returning the state at maxInboxCount. // // TODO: Check the block validator has validated the execution state we are // proposing. @@ -82,12 +82,12 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxInboxCount uint64, previousGlobalState *protocol.GoGlobalState, - maxNumberOfBlocks uint64, ) (*protocol.ExecutionState, error) { if maxInboxCount == 0 { return nil, errors.New("max inbox count cannot be zero") } batchIndex := maxInboxCount + maxNumberOfBlocks := uint64(s.blockChallengeLeafHeight) messageCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(batchIndex - 1) if err != nil { if strings.Contains(err.Error(), "not found") { From 6cc1d2fa98cec786d849571dc984c1e659275949 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 21 Nov 2024 13:01:39 +0100 Subject: [PATCH 155/210] Update the bold pin to use the tip of main --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 64e8d6ad4c..69111896a9 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 64e8d6ad4cf2cb6868169f020e6a02833fedc679 +Subproject commit 69111896a9cc3897000033443527b9e370c906da From 331c12e28ed4f1d7d25f15fc9254b836e17fd25e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 21 Nov 2024 17:17:50 +0100 Subject: [PATCH 156/210] Update bold pin and adjust nitro code accordingly Specifically, the type of the 2 AssertionHash fields in the AssertionCreationInfo struct is now a protocol.AssertionHash instead of `[32]byte`. This change also updates nitro's `go.mod` and `go.sum` with `go mod tidy` to pick up some of the new indrect dependencies the bold machinary pulls in. --- bold | 2 +- go.mod | 4 ++++ go.sum | 5 ++++- staker/bold/bold_staker.go | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bold b/bold index 69111896a9..3fcf7270b4 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 69111896a9cc3897000033443527b9e370c906da +Subproject commit 3fcf7270b4c0c966d31e7843323826206fc8e6da diff --git a/go.mod b/go.mod index a6ae49c02c..7a48b0520d 100644 --- a/go.mod +++ b/go.mod @@ -60,6 +60,7 @@ require ( cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.8 // indirect + github.com/ccoveille/go-safecast v1.1.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -67,6 +68,8 @@ require ( github.com/google/s2a-go v0.1.7 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.5 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect @@ -77,6 +80,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect google.golang.org/grpc v1.64.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( diff --git a/go.sum b/go.sum index 6bc1e16750..55ad86267a 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOF github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4= github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4= +github.com/ccoveille/go-safecast v1.1.0 h1:iHKNWaZm+OznO7Eh6EljXPjGfGQsSfa6/sxPlIEKO+g= +github.com/ccoveille/go-safecast v1.1.0/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= @@ -474,8 +476,9 @@ github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobt github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 776450a406..d31bedfdf5 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -474,12 +474,12 @@ func readBoldAssertionCreationInfo( return &protocol.AssertionCreatedInfo{ ConfirmPeriodBlocks: parsedLog.ConfirmPeriodBlocks, RequiredStake: parsedLog.RequiredStake, - ParentAssertionHash: parsedLog.ParentAssertionHash, + ParentAssertionHash: protocol.AssertionHash{Hash: parsedLog.ParentAssertionHash}, BeforeState: parsedLog.Assertion.BeforeState, AfterState: afterState, InboxMaxCount: parsedLog.InboxMaxCount, AfterInboxBatchAcc: parsedLog.AfterInboxBatchAcc, - AssertionHash: parsedLog.AssertionHash, + AssertionHash: protocol.AssertionHash{Hash: parsedLog.AssertionHash}, WasmModuleRoot: parsedLog.WasmModuleRoot, ChallengeManager: parsedLog.ChallengeManager, TransactionHash: ethLog.TxHash, From f36ed0daa7bac4c89d1fc63adccace0f1594f5f0 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 21 Nov 2024 22:25:50 +0100 Subject: [PATCH 157/210] Get the BoLD challenge tests compiling again Note, not "passing", but "compiling." --- system_tests/bold_challenge_protocol_test.go | 12 ++++----- system_tests/bold_new_challenge_test.go | 6 +++-- system_tests/bold_state_provider_test.go | 27 ++++++++------------ 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 5c1e4f7369..5bca3c2aef 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -86,7 +86,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs - l2chainConfig := params.ArbitrumDevTestChainConfig() + l2chainConfig := chaininfo.ArbitrumDevTestChainConfig() l2info := NewBlockChainTestInfo( t, types.NewArbitrumSigner(types.NewLondonSigner(l2chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), @@ -502,7 +502,7 @@ func createTestNodeOnL1ForBoldProtocol( } nodeConfig.ParentChainReader.OldHeaderTimeout = time.Minute * 10 if chainConfig == nil { - chainConfig = params.ArbitrumDevTestChainConfig() + chainConfig = chaininfo.ArbitrumDevTestChainConfig() } nodeConfig.BatchPoster.DataPoster.MaxMempoolTransactions = 18 fatalErrChan := make(chan error, 10) @@ -659,14 +659,14 @@ func deployContractsOnly( genesisInboxCount, anyTrustFastConfirmer, challengetesting.WithLayerZeroHeights(&protocol.LayerZeroHeights{ - BlockChallengeHeight: blockChallengeLeafHeight, - BigStepChallengeHeight: bigStepChallengeLeafHeight, - SmallStepChallengeHeight: smallStepChallengeLeafHeight, + BlockChallengeHeight: protocol.Height(blockChallengeLeafHeight), + BigStepChallengeHeight: protocol.Height(bigStepChallengeLeafHeight), + SmallStepChallengeHeight: protocol.Height(smallStepChallengeLeafHeight), }), challengetesting.WithNumBigStepLevels(uint8(3)), // TODO: Hardcoded. challengetesting.WithConfirmPeriodBlocks(uint64(120)), // TODO: Hardcoded. ) - config, err := json.Marshal(params.ArbitrumDevTestChainConfig()) + config, err := json.Marshal(chaininfo.ArbitrumDevTestChainConfig()) Require(t, err) cfg.ChainConfig = string(config) addresses, err := setup.DeployFullRollupStack( diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index fab6e7eabf..0fae396af4 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -34,6 +34,7 @@ import ( type incorrectBlockStateProvider struct { honest *bold.BOLDStateProvider + chain protocol.AssertionChain wrongAtFirstVirtual bool wrongAtBlockHeight uint64 honestMachineHash common.Hash @@ -44,9 +45,9 @@ func (s *incorrectBlockStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxInboxCount uint64, previousGlobalState *protocol.GoGlobalState, - maxNumberOfBlocks uint64, ) (*protocol.ExecutionState, error) { - executionState, err := s.honest.ExecutionStateAfterPreviousState(ctx, maxInboxCount, previousGlobalState, maxNumberOfBlocks) + maxNumberOfBlocks := s.chain.SpecChallengeManager().LayerZeroHeights().BlockChallengeHeight.Uint64() + executionState, err := s.honest.ExecutionStateAfterPreviousState(ctx, maxInboxCount, previousGlobalState) if err != nil { return nil, err } @@ -160,6 +161,7 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo _, cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "EvilAsserter", func(stateManager BoldStateProviderInterface) BoldStateProviderInterface { p := &incorrectBlockStateProvider{ honest: stateManager.(*bold.BOLDStateProvider), + chain: assertionChain, wrongAtFirstVirtual: wrongAtFirstVirtual, } if !wrongAtFirstVirtual { diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 420b38f7e5..4a6d715edc 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -24,6 +24,7 @@ import ( "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/util" @@ -42,7 +43,7 @@ func TestChallengeProtocolBOLD_Bisections(t *testing.T) { t.Parallel() ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() - l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx) + l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx, 1<<5) defer requireClose(t, l1stack) defer l2node.StopAndWait() l2info.GenerateAccount("Destination") @@ -157,7 +158,8 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { // t.Parallel() ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() - l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx) + maxNumBlocks := uint64(1 << 14) + l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx, maxNumBlocks) defer requireClose(t, l1stack) defer l2node.StopAndWait() l2info.GenerateAccount("Destination") @@ -215,8 +217,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { } } - maxBlocks := uint64(1 << 14) - t.Run("StatesInBatchRange", func(t *testing.T) { toBatch := uint64(3) toHeight := l2stateprovider.Height(10) @@ -249,7 +249,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { Batch: 0, PosInBatch: 1, }, - maxBlocks, ) if err == nil { Fatal(t, "should not agree with execution state") @@ -266,7 +265,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { Batch: 0, PosInBatch: 0, }, - maxBlocks, ) Require(t, err) if genesis == nil { @@ -278,7 +276,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { ctx, 2, &genesis.GlobalState, - maxBlocks, ) Require(t, err) if first == nil { @@ -290,7 +287,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { ctx, 10, &first.GlobalState, - maxBlocks, ) if err == nil { Fatal(t, "should not agree with execution state") @@ -309,7 +305,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { SendRoot: result.SendRoot, Batch: 3, } - got, err := stateManager.ExecutionStateAfterPreviousState(ctx, 3, &first.GlobalState, maxBlocks) + got, err := stateManager.ExecutionStateAfterPreviousState(ctx, 3, &first.GlobalState) Require(t, err) if state.Batch != got.GlobalState.Batch { Fatal(t, "wrong batch") @@ -327,7 +323,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { ctx, state.Batch+1, &got.GlobalState, - maxBlocks, ) if err == nil { Fatal(t, "should not agree with execution state") @@ -337,7 +332,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { } }) t.Run("ExecutionStateAfterBatchCount", func(t *testing.T) { - _, err = stateManager.ExecutionStateAfterPreviousState(ctx, 0, &protocol.GoGlobalState{}, maxBlocks) + _, err = stateManager.ExecutionStateAfterPreviousState(ctx, 0, &protocol.GoGlobalState{}) if err == nil { Fatal(t, "should have failed") } @@ -345,9 +340,9 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { Fatal(t, "wrong error message", err) } - genesis, err := stateManager.ExecutionStateAfterPreviousState(ctx, 1, &protocol.GoGlobalState{}, maxBlocks) + genesis, err := stateManager.ExecutionStateAfterPreviousState(ctx, 1, &protocol.GoGlobalState{}) Require(t, err) - execState, err := stateManager.ExecutionStateAfterPreviousState(ctx, totalBatches, &genesis.GlobalState, maxBlocks) + execState, err := stateManager.ExecutionStateAfterPreviousState(ctx, totalBatches, &genesis.GlobalState) Require(t, err) if execState == nil { Fatal(t, "should not be nil") @@ -355,9 +350,9 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { }) } -func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *bold.BOLDStateProvider, *staker.BlockValidator) { +func setupBoldStateProvider(t *testing.T, ctx context.Context, blockChallengeHeight uint64) (*arbnode.Node, *BlockchainTestInfo, *BlockchainTestInfo, *node.Node, *ethclient.Client, *bold.BOLDStateProvider, *staker.BlockValidator) { var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs - l2chainConfig := params.ArbitrumDevTestChainConfig() + l2chainConfig := chaininfo.ArbitrumDevTestChainConfig() l2info := NewBlockChainTestInfo( t, types.NewArbitrumSigner(types.NewLondonSigner(l2chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), @@ -400,7 +395,7 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context) (*arbnode.Node, * stateManager, err := bold.NewBOLDStateProvider( blockValidator, stateless, - l2stateprovider.Height(blockChallengeLeafHeight), + l2stateprovider.Height(blockChallengeHeight), &bold.StateProviderConfig{ ValidatorName: "", MachineLeavesCachePath: t.TempDir(), From 19bc1efd6832859a583c8fef2fd4eef5229bc128 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 21 Nov 2024 20:29:53 -0600 Subject: [PATCH 158/210] Bump nitro-testnode to bold-upgrade branch for bold testing --- nitro-testnode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitro-testnode b/nitro-testnode index 72141dd495..4c46f04113 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 72141dd495ad965aa2a23723ea3e755037903ad7 +Subproject commit 4c46f041131a08c7219e525b0a37afb6a5b18987 From 4aba248f256fe52534b64bd715971515f2e97e97 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 21 Nov 2024 20:30:26 -0600 Subject: [PATCH 159/210] Fix bold staker without block validation enabled --- staker/bold/bold_staker.go | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index d31bedfdf5..939861122c 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -139,16 +139,17 @@ func StateProviderConfigAddOptions(prefix string, f *flag.FlagSet) { type BOLDStaker struct { stopwaiter.StopWaiter - config *BoldConfig - chalManager *challengemanager.Manager - blockValidator *staker.BlockValidator - rollupAddress common.Address - client bind.ContractBackend - lastWasmModuleRoot common.Hash - callOpts bind.CallOpts - wallet legacystaker.ValidatorWalletInterface - stakedNotifiers []legacystaker.LatestStakedNotifier - confirmedNotifiers []legacystaker.LatestConfirmedNotifier + config *BoldConfig + chalManager *challengemanager.Manager + blockValidator *staker.BlockValidator + statelessBlockValidator *staker.StatelessBlockValidator + rollupAddress common.Address + client bind.ContractBackend + lastWasmModuleRoot common.Hash + callOpts bind.CallOpts + wallet legacystaker.ValidatorWalletInterface + stakedNotifiers []legacystaker.LatestStakedNotifier + confirmedNotifiers []legacystaker.LatestConfirmedNotifier } func NewBOLDStaker( @@ -170,15 +171,16 @@ func NewBOLDStaker( return nil, err } return &BOLDStaker{ - config: config, - chalManager: manager, - blockValidator: blockValidator, - rollupAddress: rollupAddress, - client: client, - callOpts: callOpts, - wallet: wallet, - stakedNotifiers: stakedNotifiers, - confirmedNotifiers: confirmedNotifiers, + config: config, + chalManager: manager, + blockValidator: blockValidator, + statelessBlockValidator: statelessBlockValidator, + rollupAddress: rollupAddress, + client: client, + callOpts: callOpts, + wallet: wallet, + stakedNotifiers: stakedNotifiers, + confirmedNotifiers: confirmedNotifiers, }, nil } @@ -270,7 +272,7 @@ func (b *BOLDStaker) getLatestState(ctx context.Context, confirmed bool) (arbuti if err != nil { return 0, nil, fmt.Errorf("error getting latest %s: %w", assertionType, err) } - caughtUp, count, err := staker.GlobalStateToMsgCount(b.blockValidator.InboxTracker(), b.blockValidator.InboxStreamer(), validator.GoGlobalState(globalState)) + caughtUp, count, err := staker.GlobalStateToMsgCount(b.statelessBlockValidator.InboxTracker(), b.statelessBlockValidator.InboxStreamer(), validator.GoGlobalState(globalState)) if err != nil { if errors.Is(err, staker.ErrGlobalStateNotInChain) { return 0, nil, fmt.Errorf("latest %s assertion of %v not yet in our node: %w", assertionType, globalState, err) @@ -283,7 +285,7 @@ func (b *BOLDStaker) getLatestState(ctx context.Context, confirmed bool) (arbuti return 0, nil, nil } - processedCount, err := b.blockValidator.InboxStreamer().GetProcessedMessageCount() + processedCount, err := b.statelessBlockValidator.InboxStreamer().GetProcessedMessageCount() if err != nil { return 0, nil, err } From 72ba88de67625c871f10d695d43cf803a7601cc2 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 21 Nov 2024 20:30:41 -0600 Subject: [PATCH 160/210] Fix multi protocol staker legacy staker wallet initialization --- staker/legacy/staker.go | 3 --- staker/multi_protocol/multi_protocol_staker.go | 10 ++++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index af3241c112..7b9d737107 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -515,9 +515,6 @@ func (s *Staker) StopAndWait() { } func (s *Staker) Start(ctxIn context.Context) { - if s.Strategy() != WatchtowerStrategy { - s.wallet.Start(ctxIn) - } s.StopWaiter.Start(ctxIn, s) backoff := time.Second isAheadOfOnChainNonceEphemeralErrorHandler := util.NewEphemeralErrorHandler(10*time.Minute, "is ahead of on-chain nonce", 0) diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index cb4171bfc9..576d369b70 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -111,9 +111,7 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { func (m *MultiProtocolStaker) Start(ctxIn context.Context) { m.StopWaiter.Start(ctxIn, m) - if m.legacyConfig().StrategyType() != legacystaker.WatchtowerStrategy { - m.wallet.Start(ctxIn) - } + m.wallet.Start(ctxIn) if m.boldStaker != nil { log.Info("Starting BOLD staker") m.boldStaker.Start(ctxIn) @@ -125,7 +123,7 @@ func (m *MultiProtocolStaker) Start(ctxIn context.Context) { m.CallIteratively(func(ctx context.Context) time.Duration { switchedToBoldProtocol, err := m.checkAndSwitchToBoldStaker(ctxIn) if err != nil { - log.Error("staker: error in checking switch to bold staker", "err", err) + log.Warn("staker: error in checking switch to bold staker", "err", err) return stakerSwitchInterval } if switchedToBoldProtocol { @@ -164,6 +162,10 @@ func (m *MultiProtocolStaker) isBoldActive(ctx context.Context) (bool, common.Ad return false, addr, err } _, err = userLogic.ChallengeGracePeriodBlocks(callOpts) + if err != nil && !headerreader.ExecutionRevertedRegexp.MatchString(err.Error()) { + // Unexpected error, perhaps an L1 issue? + return false, addr, err + } // ChallengeGracePeriodBlocks only exists in the BOLD rollup contracts. return err == nil, rollupAddress, nil } From eed7b127242eb8a3d99070e5cda6efbacdbd86e3 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 22 Nov 2024 16:39:01 +0100 Subject: [PATCH 161/210] Sync in the latests changes from the bold repo This includes wiring the HeaderProvider through to the challenge stack and a slightly clunky backend wrapper around the ethereum client instances. --- bold | 2 +- staker/bold/bold_staker.go | 19 +++++++++++++------ .../multi_protocol/multi_protocol_staker.go | 9 ++++----- system_tests/bold_challenge_protocol_test.go | 10 ++++++---- system_tests/bold_new_challenge_test.go | 4 +++- system_tests/common_test.go | 4 +++- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/bold b/bold index 3fcf7270b4..6fa5fa5c3f 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 3fcf7270b4c0c966d31e7843323826206fc8e6da +Subproject commit 6fa5fa5c3fdeb4516c978487fd1b7c825d72f7ef diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 939861122c..da3d446146 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -14,8 +14,8 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/rpc" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" @@ -23,10 +23,12 @@ import ( boldtypes "github.com/offchainlabs/bold/challenge-manager/types" l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" + "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/staker" legacystaker "github.com/offchainlabs/nitro/staker/legacy" + "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" ) @@ -144,8 +146,9 @@ type BOLDStaker struct { blockValidator *staker.BlockValidator statelessBlockValidator *staker.StatelessBlockValidator rollupAddress common.Address - client bind.ContractBackend + l1Reader *headerreader.HeaderReader lastWasmModuleRoot common.Hash + client protocol.ChainBackend callOpts bind.CallOpts wallet legacystaker.ValidatorWalletInterface stakedNotifiers []legacystaker.LatestStakedNotifier @@ -157,7 +160,7 @@ func NewBOLDStaker( rollupAddress common.Address, callOpts bind.CallOpts, txOpts *bind.TransactOpts, - client *ethclient.Client, + l1Reader *headerreader.HeaderReader, blockValidator *staker.BlockValidator, statelessBlockValidator *staker.StatelessBlockValidator, config *BoldConfig, @@ -166,7 +169,8 @@ func NewBOLDStaker( stakedNotifiers []legacystaker.LatestStakedNotifier, confirmedNotifiers []legacystaker.LatestConfirmedNotifier, ) (*BOLDStaker, error) { - manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, client, blockValidator, statelessBlockValidator, config, dataPoster) + wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber) + manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster) if err != nil { return nil, err } @@ -176,7 +180,8 @@ func NewBOLDStaker( blockValidator: blockValidator, statelessBlockValidator: statelessBlockValidator, rollupAddress: rollupAddress, - client: client, + l1Reader: l1Reader, + client: wrappedClient, callOpts: callOpts, wallet: wallet, stakedNotifiers: stakedNotifiers, @@ -340,7 +345,8 @@ func newBOLDChallengeManager( ctx context.Context, rollupAddress common.Address, txOpts *bind.TransactOpts, - client *ethclient.Client, + l1Reader *headerreader.HeaderReader, + client protocol.ChainBackend, blockValidator *staker.BlockValidator, statelessBlockValidator *staker.StatelessBlockValidator, config *BoldConfig, @@ -403,6 +409,7 @@ func newBOLDChallengeManager( challengemanager.StackWithPostingInterval(postingInterval), challengemanager.StackWithConfirmationInterval(confirmingInterval), challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), + challengemanager.StackWithHeaderProvider(l1Reader), } if config.API { apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort) diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index 576d369b70..34e725084c 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/bold/solgen/go/bridgegen" @@ -29,7 +28,7 @@ type MultiProtocolStaker struct { confirmedNotifiers []legacystaker.LatestConfirmedNotifier statelessBlockValidator *staker.StatelessBlockValidator wallet legacystaker.ValidatorWalletInterface - client *ethclient.Client + l1Reader *headerreader.HeaderReader blockValidator *staker.BlockValidator callOpts bind.CallOpts boldConfig *boldstaker.BoldConfig @@ -83,7 +82,7 @@ func NewMultiProtocolStaker( confirmedNotifiers: confirmedNotifiers, statelessBlockValidator: statelessBlockValidator, wallet: wallet, - client: l1Reader.Client(), + l1Reader: l1Reader, blockValidator: blockValidator, callOpts: callOpts, boldConfig: boldConfig, @@ -157,7 +156,7 @@ func (m *MultiProtocolStaker) isBoldActive(ctx context.Context) (bool, common.Ad if err != nil { return false, addr, err } - userLogic, err := boldrollup.NewRollupUserLogic(rollupAddress, m.client) + userLogic, err := boldrollup.NewRollupUserLogic(rollupAddress, m.l1Reader.Client()) if err != nil { return false, addr, err } @@ -213,7 +212,7 @@ func (m *MultiProtocolStaker) setupBoldStaker( rollupAddress, *m.getCallOpts(ctx), auth, - m.client, + m.l1Reader, m.blockValidator, m.statelessBlockValidator, m.boldConfig, diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 5bca3c2aef..2ad66ee9a4 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -29,6 +29,7 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -40,6 +41,7 @@ import ( "github.com/offchainlabs/bold/solgen/go/rollupgen" challengetesting "github.com/offchainlabs/bold/testing" "github.com/offchainlabs/bold/testing/setup" + butil "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" @@ -230,7 +232,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp assertionChain.RollupAddress(), chalManagerAddr.Address(), &evilOpts, - l1client, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), ) Require(t, err) @@ -616,7 +618,7 @@ func createTestNodeOnL1ForBoldProtocol( addresses.Rollup, chalManagerAddr, &opts, - l1client, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), ) Require(t, err) @@ -671,7 +673,7 @@ func deployContractsOnly( cfg.ChainConfig = string(config) addresses, err := setup.DeployFullRollupStack( ctx, - backend, + butil.NewBackendWrapper(backend, rpc.LatestBlockNumber), &l1TransactionOpts, l1info.GetAddress("Sequencer"), cfg, @@ -824,7 +826,7 @@ func create2ndNodeWithConfigForBoldProtocol( addresses.Rollup, chalManagerAddr, &evilOpts, - l1client, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), ) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 0fae396af4..b4e25a08af 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -17,6 +17,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rpc" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -27,6 +28,7 @@ import ( "github.com/offchainlabs/bold/solgen/go/mocksgen" "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/bold/state-commitments/history" + "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/staker/bold" @@ -329,7 +331,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB builder.addresses.Rollup, chalManagerAddr, &txOpts, - builder.L1.Client, + util.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), ) Require(t, err) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 93cc15382a..c33314eb15 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -54,6 +54,7 @@ import ( boldMocksgen "github.com/offchainlabs/bold/solgen/go/mocksgen" "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/bold/testing/setup" + butil "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -1342,9 +1343,10 @@ func deployOnParentChain( NumBigStepLevel: 3, ChallengeGracePeriodBlocks: 3, } + wrappedClient := butil.NewBackendWrapper(parentChainReader.Client(), rpc.LatestBlockNumber) boldAddresses, err := setup.DeployFullRollupStack( ctx, - parentChainReader.Client(), + wrappedClient, &parentChainTransactionOpts, parentChainInfo.GetAddress("Sequencer"), cfg, From e0a4a0f3301087b574dbc2d8670559d77e243891 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 22 Nov 2024 11:31:27 -0600 Subject: [PATCH 162/210] Validator wallet refactor for bold --- arbnode/dataposter/data_poster.go | 6 +- bold | 2 +- staker/bold/bold_staker.go | 6 +- staker/bold/data_poster_transactor.go | 40 +++++ staker/legacy/fast_confirm.go | 19 +-- staker/legacy/l1_validator.go | 17 +- staker/legacy/staker.go | 67 ++------ .../multi_protocol/multi_protocol_staker.go | 8 +- staker/txbuilder/builder.go | 158 ++++++++++-------- staker/validatorwallet/contract.go | 79 +++------ staker/validatorwallet/eoa.go | 13 +- staker/validatorwallet/noop.go | 3 +- system_tests/bold_challenge_protocol_test.go | 6 +- system_tests/bold_new_challenge_test.go | 6 +- 14 files changed, 197 insertions(+), 233 deletions(-) create mode 100644 staker/bold/data_poster_transactor.go diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 4bcc14ffab..a977b9fc08 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -712,7 +712,7 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u return newBaseFeeCap, newTipCap, newBlobFeeCap, nil } -func (p *DataPoster) PostSimpleTransactionAutoNonce(ctx context.Context, to common.Address, calldata []byte, gasLimit uint64, value *big.Int) (*types.Transaction, error) { +func (p *DataPoster) PostSimpleTransaction(ctx context.Context, to common.Address, calldata []byte, gasLimit uint64, value *big.Int) (*types.Transaction, error) { p.mutex.Lock() defer p.mutex.Unlock() nonce, _, _, _, err := p.getNextNonceAndMaybeMeta(ctx, 1) @@ -722,10 +722,6 @@ func (p *DataPoster) PostSimpleTransactionAutoNonce(ctx context.Context, to comm return p.postTransactionWithMutex(ctx, time.Now(), nonce, nil, to, calldata, gasLimit, value, nil, nil) } -func (p *DataPoster) PostSimpleTransaction(ctx context.Context, nonce uint64, to common.Address, calldata []byte, gasLimit uint64, value *big.Int) (*types.Transaction, error) { - return p.PostTransaction(ctx, time.Now(), nonce, nil, to, calldata, gasLimit, value, nil, nil) -} - func (p *DataPoster) PostTransaction(ctx context.Context, dataCreatedAt time.Time, nonce uint64, meta []byte, to common.Address, calldata []byte, gasLimit uint64, value *big.Int, kzgBlobs []kzg4844.Blob, accessList types.AccessList) (*types.Transaction, error) { p.mutex.Lock() defer p.mutex.Unlock() diff --git a/bold b/bold index 6fa5fa5c3f..8dc9c38366 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 6fa5fa5c3fdeb4516c978487fd1b7c825d72f7ef +Subproject commit 8dc9c38366bed37188ebea567f301b69fb4811eb diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index da3d446146..348b822aac 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -1,5 +1,5 @@ -// Copyright 2023, Offchain Labs, Inc. -// For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE +// Copyright 2023-2024, Offchain Labs, Inc. +// For license information, see https://github.com/offchainlabs/nitro/blob/main/LICENSE package bold import ( @@ -361,7 +361,7 @@ func newBOLDChallengeManager( if err != nil { return nil, fmt.Errorf("could not get challenge manager: %w", err) } - assertionChain, err := solimpl.NewAssertionChain(ctx, rollupAddress, chalManager, txOpts, client, solimpl.NewDataPosterTransactor(dataPoster)) + assertionChain, err := solimpl.NewAssertionChain(ctx, rollupAddress, chalManager, txOpts, client, NewDataPosterTransactor(dataPoster)) if err != nil { return nil, fmt.Errorf("could not create assertion chain: %w", err) } diff --git a/staker/bold/data_poster_transactor.go b/staker/bold/data_poster_transactor.go new file mode 100644 index 0000000000..d68a2b8d2d --- /dev/null +++ b/staker/bold/data_poster_transactor.go @@ -0,0 +1,40 @@ +// Copyright 2023-2024, Offchain Labs, Inc. +// For license information, see https://github.com/offchainlabs/nitro/blob/main/LICENSE +package bold + +import ( + "context" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/core/types" + + solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" + "github.com/offchainlabs/nitro/arbnode/dataposter" +) + +// DataPosterTransactor is a wrapper around a DataPoster that implements the Transactor interface. +type DataPosterTransactor struct { + fifo *solimpl.FIFO + *dataposter.DataPoster +} + +func NewDataPosterTransactor(dataPoster *dataposter.DataPoster) *DataPosterTransactor { + return &DataPosterTransactor{ + fifo: solimpl.NewFIFO(1000), + DataPoster: dataPoster, + } +} + +func (d *DataPosterTransactor) SendTransaction(ctx context.Context, fn func(opts *bind.TransactOpts) (*types.Transaction, error), opts *bind.TransactOpts, gas uint64) (*types.Transaction, error) { + // Try to acquire lock and if it fails, wait for a bit and try again. + for !d.fifo.Lock() { + <-time.After(100 * time.Millisecond) + } + defer d.fifo.Unlock() + tx, err := fn(opts) + if err != nil { + return nil, err + } + return d.PostSimpleTransaction(ctx, *tx.To(), tx.Data(), gas, tx.Value()) +} diff --git a/staker/legacy/fast_confirm.go b/staker/legacy/fast_confirm.go index 78f25d0d4f..13ce32b849 100644 --- a/staker/legacy/fast_confirm.go +++ b/staker/legacy/fast_confirm.go @@ -46,7 +46,7 @@ func NewFastConfirmSafe( gasRefunder: gasRefunder, l1Reader: l1Reader, } - safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, builder) + safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, wallet.L1Client()) if err != nil { return nil, err } @@ -127,11 +127,7 @@ func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash com } log.Info("Approving Safe tx hash to fast confirm", "safeHash", safeTxHash, "nodeHash", nodeHash) - auth, err := f.builder.Auth(ctx) - if err != nil { - return err - } - _, err = f.safe.ApproveHash(auth, safeTxHash) + _, err = f.safe.ApproveHash(f.builder.Auth(ctx), safeTxHash) if err != nil { return err } @@ -160,7 +156,7 @@ func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash com } func (f *FastConfirmSafe) flushTransactions(ctx context.Context) error { - arbTx, err := f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) + arbTx, err := f.builder.ExecuteTransactions(ctx) if err != nil { return err } @@ -172,7 +168,6 @@ func (f *FastConfirmSafe) flushTransactions(ctx context.Context) error { return fmt.Errorf("error waiting for tx receipt: %w", err) } } - f.builder.ClearTransactions() return nil } @@ -229,13 +224,9 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex } } if approvedHashCount >= f.threshold { - auth, err := f.builder.Auth(ctx) - if err != nil { - return false, err - } log.Info("Executing Safe tx to fast confirm", "safeHash", safeTxHash) - _, err = f.safe.ExecTransaction( - auth, + _, err := f.safe.ExecTransaction( + f.builder.Auth(ctx), f.wallet.RollupAddress(), big.NewInt(0), fastConfirmCallData, diff --git a/staker/legacy/l1_validator.go b/staker/legacy/l1_validator.go index 9f929141c8..f88ab93d0e 100644 --- a/staker/legacy/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -62,16 +62,17 @@ func NewL1Validator( client *ethclient.Client, wallet ValidatorWalletInterface, validatorUtilsAddress common.Address, + gasRefunder common.Address, callOpts bind.CallOpts, inboxTracker staker.InboxTrackerInterface, txStreamer staker.TransactionStreamerInterface, blockValidator *staker.BlockValidator, ) (*L1Validator, error) { - builder, err := txbuilder.NewBuilder(wallet) + builder, err := txbuilder.NewBuilder(wallet, gasRefunder) if err != nil { return nil, err } - rollup, err := staker.NewRollupWatcher(wallet.RollupAddress(), builder, callOpts) + rollup, err := staker.NewRollupWatcher(wallet.RollupAddress(), wallet.L1Client(), callOpts) if err != nil { return nil, err } @@ -159,11 +160,7 @@ func (v *L1Validator) resolveNextNode(ctx context.Context, info *staker.StakerIn return false, nil } log.Warn("rejecting node", "node", unresolvedNodeIndex) - auth, err := v.builder.Auth(ctx) - if err != nil { - return false, err - } - _, err = v.rollup.RejectNextNode(auth, *addr) + _, err = v.rollup.RejectNextNode(v.builder.Auth(ctx), *addr) return true, err case CONFIRM_TYPE_VALID: nodeInfo, err := v.rollup.LookupNode(ctx, unresolvedNodeIndex) @@ -172,11 +169,7 @@ func (v *L1Validator) resolveNextNode(ctx context.Context, info *staker.StakerIn } afterGs := nodeInfo.AfterState().GlobalState log.Info("confirming node", "node", unresolvedNodeIndex) - auth, err := v.builder.Auth(ctx) - if err != nil { - return false, err - } - _, err = v.rollup.ConfirmNextNode(auth, afterGs.BlockHash, afterGs.SendRoot) + _, err = v.rollup.ConfirmNextNode(v.builder.Auth(ctx), afterGs.BlockHash, afterGs.SendRoot) if err != nil { return false, err } diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index 7b9d737107..63ae4f97a9 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -28,7 +28,6 @@ import ( "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker" - "github.com/offchainlabs/nitro/staker/txbuilder" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" @@ -292,7 +291,7 @@ type ValidatorWalletInterface interface { ChallengeManagerAddress() common.Address L1Client() *ethclient.Client TestTransactions(context.Context, []*types.Transaction) error - ExecuteTransactions(context.Context, *txbuilder.Builder, common.Address) (*types.Transaction, error) + ExecuteTransactions(context.Context, []*types.Transaction, common.Address) (*types.Transaction, error) TimeoutChallenges(context.Context, []uint64) (*types.Transaction, error) CanBatchTxs() bool AuthIfEoa() *bind.TransactOpts @@ -318,7 +317,7 @@ func NewStaker( return nil, err } client := l1Reader.Client() - val, err := NewL1Validator(client, wallet, validatorUtilsAddress, callOpts, + val, err := NewL1Validator(client, wallet, validatorUtilsAddress, config().GasRefunder(), callOpts, statelessBlockValidator.InboxTracker(), statelessBlockValidator.InboxStreamer(), blockValidator) if err != nil { return nil, err @@ -452,12 +451,9 @@ func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, if s.fastConfirmSafe != nil { return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot, nodeHash) } - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } + auth := s.builder.Auth(ctx) log.Info("Fast confirming node with wallet", "wallet", auth.From, "nodeHash", nodeHash) - _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot, nodeHash) + _, err := s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot, nodeHash) return err } @@ -823,7 +819,7 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { } if s.builder.BuildingTransactionCount() > 0 { // Try to fast confirm previous nodes before working on new ones - return s.wallet.ExecuteTransactions(ctx, s.builder, cfg.GasRefunder()) + return s.builder.ExecuteTransactions(ctx) } } } @@ -893,24 +889,17 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { stakeIsUnwanted := effectiveStrategy < StakeLatestStrategy if stakeIsTooOutdated || stakeIsUnwanted { // Note: we must have an address if rawInfo != nil - auth, err := s.builder.Auth(ctx) - if err != nil { - return nil, err - } + auth := s.builder.Auth(ctx) _, err = s.rollup.ReturnOldDeposit(auth, walletAddressOrZero) if err != nil { return nil, fmt.Errorf("error returning old deposit (from our staker %v): %w", walletAddressOrZero, err) } - auth, err = s.builder.Auth(ctx) - if err != nil { - return nil, err - } _, err = s.rollup.WithdrawStakerFunds(auth) if err != nil { return nil, fmt.Errorf("error withdrawing staker funds from our staker %v: %w", walletAddressOrZero, err) } log.Info("removing old stake and withdrawing funds") - return s.wallet.ExecuteTransactions(ctx, s.builder, cfg.GasRefunder()) + return s.builder.ExecuteTransactions(ctx) } } @@ -920,11 +909,7 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { return nil, fmt.Errorf("error checking withdrawable funds of our staker %v: %w", walletAddressOrZero, err) } if withdrawable.Sign() > 0 { - auth, err := s.builder.Auth(ctx) - if err != nil { - return nil, err - } - _, err = s.rollup.WithdrawStakerFunds(auth) + _, err = s.rollup.WithdrawStakerFunds(s.builder.Auth(ctx)) if err != nil { return nil, fmt.Errorf("error withdrawing our staker %v funds: %w", walletAddressOrZero, err) } @@ -964,7 +949,7 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { if info.StakerInfo == nil && info.StakeExists { log.Info("staking to execute transactions") } - return s.wallet.ExecuteTransactions(ctx, s.builder, cfg.GasRefunder()) + return s.builder.ExecuteTransactions(ctx) } func (s *Staker) handleConflict(ctx context.Context, info *staker.StakerInfo) error { @@ -983,8 +968,8 @@ func (s *Staker) handleConflict(ctx context.Context, info *staker.StakerInfo) er newChallengeManager, err := NewChallengeManager( ctx, - s.builder, - s.builder.BuilderAuth(), + s.client, + s.builder.Auth(context.TODO()), *s.builder.WalletAddress(), s.wallet.ChallengeManagerAddress(), *info.CurrentChallenge, @@ -1042,11 +1027,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv // We'll return early if we already have a stake if info.StakeExists { - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } - _, err = s.rollup.StakeOnNewNode(auth, action.assertion.AsSolidityStruct(), action.hash, action.prevInboxMaxCount) + _, err = s.rollup.StakeOnNewNode(s.builder.Auth(ctx), action.assertion.AsSolidityStruct(), action.hash, action.prevInboxMaxCount) if err != nil { return fmt.Errorf("error staking on new node: %w", err) } @@ -1058,12 +1039,8 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error getting current required stake: %w", err) } - auth, err := s.builder.AuthWithAmount(ctx, stakeAmount) - if err != nil { - return err - } _, err = s.rollup.NewStakeOnNewNode( - auth, + s.builder.AuthWithAmount(ctx, stakeAmount), action.assertion.AsSolidityStruct(), action.hash, action.prevInboxMaxCount, @@ -1096,11 +1073,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv log.Info("staking on existing node", "node", action.number) // We'll return early if we already havea stake if info.StakeExists { - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } - _, err = s.rollup.StakeOnExistingNode(auth, action.number, action.hash) + _, err = s.rollup.StakeOnExistingNode(s.builder.Auth(ctx), action.number, action.hash) if err != nil { return fmt.Errorf("error staking on existing node: %w", err) } @@ -1112,12 +1085,8 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error getting current required stake: %w", err) } - auth, err := s.builder.AuthWithAmount(ctx, stakeAmount) - if err != nil { - return err - } _, err = s.rollup.NewStakeOnExistingNode( - auth, + s.builder.AuthWithAmount(ctx, stakeAmount), action.number, action.hash, ) @@ -1193,12 +1162,8 @@ func (s *Staker) createConflict(ctx context.Context, info *staker.StakerInfo) er return fmt.Errorf("error looking up node %v: %w", conflictInfo.Node2, err) } log.Warn("creating challenge", "node1", conflictInfo.Node1, "node2", conflictInfo.Node2, "otherStaker", staker) - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } _, err = s.rollup.CreateChallenge( - auth, + s.builder.Auth(ctx), [2]common.Address{staker1, staker2}, [2]uint64{conflictInfo.Node1, conflictInfo.Node2}, node1Info.MachineStatuses(), diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index 34e725084c..a7ba85ac07 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -199,11 +199,7 @@ func (m *MultiProtocolStaker) setupBoldStaker( ctx context.Context, rollupAddress common.Address, ) (*boldstaker.BOLDStaker, error) { - txBuilder, err := txbuilder.NewBuilder(m.wallet) - if err != nil { - return nil, err - } - auth, err := txBuilder.Auth(ctx) + txBuilder, err := txbuilder.NewBuilder(m.wallet, m.legacyConfig().GasRefunder()) if err != nil { return nil, err } @@ -211,7 +207,7 @@ func (m *MultiProtocolStaker) setupBoldStaker( ctx, rollupAddress, *m.getCallOpts(ctx), - auth, + txBuilder.SingleTxAuth(), m.l1Reader, m.blockValidator, m.statelessBlockValidator, diff --git a/staker/txbuilder/builder.go b/staker/txbuilder/builder.go index f52b03a781..18353422ae 100644 --- a/staker/txbuilder/builder.go +++ b/staker/txbuilder/builder.go @@ -5,22 +5,20 @@ package txbuilder import ( "context" + "fmt" "math/big" + "sync" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" ) type ValidatorWalletInterface interface { // Address must be able to be called concurrently with other functions Address() *common.Address - L1Client() *ethclient.Client - TestTransactions(context.Context, []*types.Transaction) error - ExecuteTransactions(context.Context, *Builder, common.Address) (*types.Transaction, error) + TestTransactions(ctx context.Context, txs []*types.Transaction) error + ExecuteTransactions(ctx context.Context, txs []*types.Transaction, gasRefunder common.Address) (*types.Transaction, error) AuthIfEoa() *bind.TransactOpts } @@ -30,34 +28,76 @@ type ValidatorWalletInterface interface { // This inherits from an ethclient.Client so it can be used to transparently // intercept calls to SendTransaction and queue them for the next batch. type Builder struct { - *ethclient.Client transactions []*types.Transaction - builderAuth *bind.TransactOpts + singleTxAuth bind.TransactOpts + multiTxAuth bind.TransactOpts isAuthFake bool + authMutex sync.Mutex wallet ValidatorWalletInterface + gasRefunder common.Address } -func NewBuilder(wallet ValidatorWalletInterface) (*Builder, error) { - randKey, err := crypto.GenerateKey() - if err != nil { - return nil, err - } - builderAuth := wallet.AuthIfEoa() +func NewBuilder(wallet ValidatorWalletInterface, gasRefunder common.Address) (*Builder, error) { + var builderAuth bind.TransactOpts var isAuthFake bool - if builderAuth == nil { - // Make a fake auth so we have txs to give to the smart contract wallet - builderAuth, err = bind.NewKeyedTransactorWithChainID(randKey, big.NewInt(9999999)) + if authIfEoa := wallet.AuthIfEoa(); authIfEoa != nil { + builderAuth = *authIfEoa + } else { + isAuthFake = true + var addressOrZero common.Address + if addr := wallet.Address(); addr != nil { + addressOrZero = *addr + } + builderAuth = bind.TransactOpts{ + From: addressOrZero, + GasLimit: 123, // don't gas estimate, that's done when the real tx is created + Signer: func(_ common.Address, tx *types.Transaction) (*types.Transaction, error) { + return tx, nil + }, + } + } + builderAuth.NoSend = true + builder := &Builder{ + singleTxAuth: builderAuth, + multiTxAuth: builderAuth, + wallet: wallet, + isAuthFake: isAuthFake, + gasRefunder: gasRefunder, + } + originalSigner := builderAuth.Signer + builder.multiTxAuth.Signer = func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { + tx, err := originalSigner(addr, tx) if err != nil { return nil, err } - isAuthFake = true + // Append the transaction to the builder's queue of transactions + builder.transactions = append(builder.transactions, tx) + err = builder.wallet.TestTransactions(context.TODO(), builder.transactions) + if err != nil { + // Remove the bad tx + builder.transactions = builder.transactions[:len(builder.transactions)-1] + return nil, err + } + return tx, nil + } + builder.singleTxAuth.Signer = func(addr common.Address, tx *types.Transaction) (*types.Transaction, error) { + if !isAuthFake { + return originalSigner(addr, tx) + } + // Try to process the transaction on its own + ctx := context.TODO() + txs := []*types.Transaction{tx} + err := builder.wallet.TestTransactions(ctx, txs) + if err != nil { + return nil, fmt.Errorf("failed to test builder transaction: %w", err) + } + signedTx, err := builder.wallet.ExecuteTransactions(ctx, txs, gasRefunder) + if err != nil { + return nil, fmt.Errorf("failed to execute builder transaction: %w", err) + } + return signedTx, nil } - return &Builder{ - builderAuth: builderAuth, - wallet: wallet, - Client: wallet.L1Client(), - isAuthFake: isAuthFake, - }, nil + return builder, nil } func (b *Builder) BuildingTransactionCount() int { @@ -68,59 +108,45 @@ func (b *Builder) ClearTransactions() { b.transactions = nil } -func (b *Builder) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) { - if len(b.transactions) == 0 && !b.isAuthFake { - return b.Client.EstimateGas(ctx, call) +func (b *Builder) tryToFillAuthAddress() { + if b.multiTxAuth.From == (common.Address{}) { + if addr := b.wallet.Address(); addr != nil { + b.multiTxAuth.From = *addr + b.singleTxAuth.From = *addr + } } - return 0, nil } -func (b *Builder) SendTransaction(ctx context.Context, tx *types.Transaction) error { - b.transactions = append(b.transactions, tx) - err := b.wallet.TestTransactions(ctx, b.transactions) - if err != nil { - // Remove the bad tx - b.transactions = b.transactions[:len(b.transactions)-1] - return err - } - return nil -} - -// While this is not currently required, it's recommended not to reuse the returned auth for multiple transactions, -// as for an EOA this has the nonce in it. However, the EOA wwallet currently will only publish the first created tx, -// which is why that doesn't really matter. -func (b *Builder) AuthWithAmount(ctx context.Context, amount *big.Int) (*bind.TransactOpts, error) { - nonce, err := b.NonceAt(ctx, b.builderAuth.From, nil) - if err != nil { - return nil, err - } - return &bind.TransactOpts{ - From: b.builderAuth.From, - Nonce: new(big.Int).SetUint64(nonce), - Signer: b.builderAuth.Signer, - Value: amount, - GasPrice: b.builderAuth.GasPrice, - GasLimit: b.builderAuth.GasLimit, - Context: ctx, - }, nil +func (b *Builder) AuthWithAmount(ctx context.Context, amount *big.Int) *bind.TransactOpts { + b.authMutex.Lock() + defer b.authMutex.Unlock() + b.tryToFillAuthAddress() + auth := b.multiTxAuth + auth.Context = ctx + auth.Value = amount + return &auth } // Auth is the same as AuthWithAmount with a 0 amount specified. -// See AuthWithAmount docs for important details. -func (b *Builder) Auth(ctx context.Context) (*bind.TransactOpts, error) { +func (b *Builder) Auth(ctx context.Context) *bind.TransactOpts { return b.AuthWithAmount(ctx, common.Big0) } -func (b *Builder) Transactions() []*types.Transaction { - return b.transactions -} - -// Auth is the same as AuthWithAmount with a 0 amount specified. -// See AuthWithAmount docs for important details. -func (b *Builder) BuilderAuth() *bind.TransactOpts { - return b.builderAuth +// SingleTxAuth should be used if you need an auth without the transaction batching of the builder. +func (b *Builder) SingleTxAuth() *bind.TransactOpts { + b.authMutex.Lock() + defer b.authMutex.Unlock() + b.tryToFillAuthAddress() + auth := b.singleTxAuth + return &auth } func (b *Builder) WalletAddress() *common.Address { return b.wallet.Address() } + +func (b *Builder) ExecuteTransactions(ctx context.Context) (*types.Transaction, error) { + tx, err := b.wallet.ExecuteTransactions(ctx, b.transactions, b.gasRefunder) + b.ClearTransactions() + return tx, err +} diff --git a/staker/validatorwallet/contract.go b/staker/validatorwallet/contract.go index 4d4f8288ef..22f579b82d 100644 --- a/staker/validatorwallet/contract.go +++ b/staker/validatorwallet/contract.go @@ -9,6 +9,7 @@ import ( "fmt" "math/big" "strings" + "sync" "sync/atomic" "github.com/ethereum/go-ethereum" @@ -22,7 +23,6 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/rollupgen" - "github.com/offchainlabs/nitro/staker/txbuilder" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" ) @@ -61,6 +61,7 @@ type Contract struct { challengeManagerAddress common.Address dataPoster *dataposter.DataPoster getExtraGas func() uint64 + populateWalletMutex sync.Mutex } func NewContract(dp *dataposter.DataPoster, address *common.Address, walletFactoryAddr, rollupAddress common.Address, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, rollupFromBlock int64, onWalletCreated func(common.Address), @@ -155,42 +156,22 @@ func (v *Contract) From() common.Address { return v.auth.From } -// nil value == 0 value -func getAuthWithUpdatedNonceFromL1(ctx context.Context, l1Reader *headerreader.HeaderReader, auth bind.TransactOpts, value *big.Int) (*bind.TransactOpts, error) { - auth.Context = ctx - auth.Value = value - nonce, err := l1Reader.Client().NonceAt(ctx, auth.From, nil) - if err != nil { - return nil, err - } - auth.Nonce = new(big.Int).SetUint64(nonce) - return &auth, nil -} - -func (v *Contract) getAuth(ctx context.Context, value *big.Int) (*bind.TransactOpts, error) { - return getAuthWithUpdatedNonceFromL1(ctx, v.l1Reader, *v.auth, value) -} - func (v *Contract) executeTransaction(ctx context.Context, tx *types.Transaction, gasRefunder common.Address) (*types.Transaction, error) { - auth, err := v.getAuth(ctx, tx.Value()) - if err != nil { - return nil, err - } data, err := validatorABI.Pack("executeTransactionWithGasRefunder", gasRefunder, tx.Data(), *tx.To(), tx.Value()) if err != nil { return nil, fmt.Errorf("packing arguments for executeTransactionWithGasRefunder: %w", err) } - gas, err := v.gasForTxData(ctx, auth, data) + gas, err := v.gasForTxData(ctx, data, tx.Value()) if err != nil { return nil, fmt.Errorf("getting gas for tx data: %w", err) } - return v.dataPoster.PostSimpleTransaction(ctx, auth.Nonce.Uint64(), *v.Address(), data, gas, auth.Value) + return v.dataPoster.PostSimpleTransaction(ctx, *v.Address(), data, gas, tx.Value()) } func createWalletContract( ctx context.Context, l1Reader *headerreader.HeaderReader, - auth *bind.TransactOpts, + from common.Address, dataPoster *dataposter.DataPoster, getExtraGas func() uint64, validatorWalletFactoryAddr common.Address, @@ -204,19 +185,22 @@ func createWalletContract( gas, err := gasForTxData( ctx, l1Reader, - auth, + from, &validatorWalletFactoryAddr, txData, + common.Big0, getExtraGas, ) if err != nil { return nil, fmt.Errorf("getting gas for tx data when creating validator wallet, validatorWalletFactory=%v: %w", validatorWalletFactoryAddr, err) } - return dataPoster.PostSimpleTransaction(ctx, auth.Nonce.Uint64(), validatorWalletFactoryAddr, txData, gas, common.Big0) + return dataPoster.PostSimpleTransaction(ctx, validatorWalletFactoryAddr, txData, gas, common.Big0) } func (v *Contract) populateWallet(ctx context.Context, createIfMissing bool) error { + v.populateWalletMutex.Lock() + defer v.populateWalletMutex.Unlock() if v.con != nil { return nil } @@ -269,9 +253,7 @@ func combineTxes(txes []*types.Transaction) ([][]byte, []common.Address, []*big. return data, dest, amount, totalAmount } -// Not thread safe! Don't call this from multiple threads at the same time. -func (v *Contract) ExecuteTransactions(ctx context.Context, builder *txbuilder.Builder, gasRefunder common.Address) (*types.Transaction, error) { - txes := builder.Transactions() +func (v *Contract) ExecuteTransactions(ctx context.Context, txes []*types.Transaction, gasRefunder common.Address) (*types.Transaction, error) { if len(txes) == 0 { return nil, nil } @@ -286,7 +268,6 @@ func (v *Contract) ExecuteTransactions(ctx context.Context, builder *txbuilder.B if err != nil { return nil, err } - builder.ClearTransactions() return arbTx, nil } @@ -311,31 +292,22 @@ func (v *Contract) ExecuteTransactions(ctx context.Context, builder *txbuilder.B if callValue.Sign() < 0 { callValue.SetInt64(0) } - auth, err := v.getAuth(ctx, callValue) - if err != nil { - return nil, err - } txData, err := validatorABI.Pack("executeTransactionsWithGasRefunder", gasRefunder, data, dest, amount) if err != nil { return nil, fmt.Errorf("packing arguments for executeTransactionWithGasRefunder: %w", err) } - gas, err := v.gasForTxData(ctx, auth, txData) + gas, err := v.gasForTxData(ctx, txData, callValue) if err != nil { return nil, fmt.Errorf("getting gas for tx data: %w", err) } - arbTx, err := v.dataPoster.PostSimpleTransaction(ctx, auth.Nonce.Uint64(), *v.Address(), txData, gas, auth.Value) + arbTx, err := v.dataPoster.PostSimpleTransaction(ctx, *v.Address(), txData, gas, callValue) if err != nil { return nil, err } - builder.ClearTransactions() return arbTx, nil } -func gasForTxData(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, to *common.Address, data []byte, getExtraGas func() uint64) (uint64, error) { - if auth.GasLimit != 0 { - return auth.GasLimit, nil - } - +func gasForTxData(ctx context.Context, l1Reader *headerreader.HeaderReader, from common.Address, to *common.Address, data []byte, value *big.Int, getExtraGas func() uint64) (uint64, error) { h, err := l1Reader.LastHeader(ctx) if err != nil { return 0, fmt.Errorf("getting the last header: %w", err) @@ -351,9 +323,9 @@ func gasForTxData(ctx context.Context, l1Reader *headerreader.HeaderReader, auth g, err := l1Reader.Client().EstimateGas( ctx, ethereum.CallMsg{ - From: auth.From, + From: from, To: to, - Value: auth.Value, + Value: value, Data: data, GasFeeCap: gasFeeCap, GasTipCap: gasTipCap, @@ -365,24 +337,20 @@ func gasForTxData(ctx context.Context, l1Reader *headerreader.HeaderReader, auth return g + getExtraGas(), nil } -func (v *Contract) gasForTxData(ctx context.Context, auth *bind.TransactOpts, data []byte) (uint64, error) { - return gasForTxData(ctx, v.l1Reader, auth, v.Address(), data, v.getExtraGas) +func (v *Contract) gasForTxData(ctx context.Context, data []byte, value *big.Int) (uint64, error) { + return gasForTxData(ctx, v.l1Reader, v.From(), v.Address(), data, value, v.getExtraGas) } func (v *Contract) TimeoutChallenges(ctx context.Context, challenges []uint64) (*types.Transaction, error) { - auth, err := v.getAuth(ctx, nil) - if err != nil { - return nil, err - } data, err := validatorABI.Pack("timeoutChallenges", v.challengeManagerAddress, challenges) if err != nil { return nil, fmt.Errorf("packing arguments for timeoutChallenges: %w", err) } - gas, err := v.gasForTxData(ctx, auth, data) + gas, err := v.gasForTxData(ctx, data, common.Big0) if err != nil { return nil, fmt.Errorf("getting gas for tx data: %w", err) } - return v.dataPoster.PostSimpleTransaction(ctx, auth.Nonce.Uint64(), *v.Address(), data, gas, auth.Value) + return v.dataPoster.PostSimpleTransaction(ctx, *v.Address(), data, gas, common.Big0) } func (v *Contract) L1Client() *ethclient.Client { @@ -486,12 +454,7 @@ func GetValidatorWalletContract( return nil, nil } - transactAuth, err = getAuthWithUpdatedNonceFromL1(ctx, l1Reader, *transactAuth, nil) - if err != nil { - return nil, err - } - - tx, err := createWalletContract(ctx, l1Reader, transactAuth, dataPoster, getExtraGas, validatorWalletFactoryAddr) + tx, err := createWalletContract(ctx, l1Reader, transactAuth.From, dataPoster, getExtraGas, validatorWalletFactoryAddr) if err != nil { return nil, err } diff --git a/staker/validatorwallet/eoa.go b/staker/validatorwallet/eoa.go index 870a959152..f84dfaa265 100644 --- a/staker/validatorwallet/eoa.go +++ b/staker/validatorwallet/eoa.go @@ -15,7 +15,6 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/solgen/go/challengegen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" - "github.com/offchainlabs/nitro/staker/txbuilder" ) type EOA struct { @@ -81,21 +80,17 @@ func (w *EOA) TestTransactions(context.Context, []*types.Transaction) error { return nil } -func (w *EOA) ExecuteTransactions(ctx context.Context, builder *txbuilder.Builder, _ common.Address) (*types.Transaction, error) { - if len(builder.Transactions()) == 0 { +func (w *EOA) ExecuteTransactions(ctx context.Context, txes []*types.Transaction, _ common.Address) (*types.Transaction, error) { + if len(txes) == 0 { return nil, nil } - tx := builder.Transactions()[0] // we ignore future txs and only execute the first + tx := txes[0] // we ignore future txs and only execute the first return w.postTransaction(ctx, tx) } func (w *EOA) postTransaction(ctx context.Context, baseTx *types.Transaction) (*types.Transaction, error) { - nonce, err := w.L1Client().NonceAt(ctx, w.auth.From, nil) - if err != nil { - return nil, err - } gas := baseTx.Gas() + w.getExtraGas() - newTx, err := w.dataPoster.PostSimpleTransaction(ctx, nonce, *baseTx.To(), baseTx.Data(), gas, baseTx.Value()) + newTx, err := w.dataPoster.PostSimpleTransaction(ctx, *baseTx.To(), baseTx.Data(), gas, baseTx.Value()) if err != nil { return nil, fmt.Errorf("post transaction: %w", err) } diff --git a/staker/validatorwallet/noop.go b/staker/validatorwallet/noop.go index 24c7280811..b483927753 100644 --- a/staker/validatorwallet/noop.go +++ b/staker/validatorwallet/noop.go @@ -13,7 +13,6 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/offchainlabs/nitro/arbnode/dataposter" - "github.com/offchainlabs/nitro/staker/txbuilder" ) // NoOp validator wallet is used for watchtower mode. @@ -39,7 +38,7 @@ func (*NoOp) TxSenderAddress() *common.Address { return nil } func (*NoOp) From() common.Address { return common.Address{} } -func (*NoOp) ExecuteTransactions(context.Context, *txbuilder.Builder, common.Address) (*types.Transaction, error) { +func (*NoOp) ExecuteTransactions(context.Context, []*types.Transaction, common.Address) (*types.Transaction, error) { return nil, errors.New("no op validator wallet cannot execute transactions") } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 2ad66ee9a4..ff706950e1 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -233,7 +233,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp chalManagerAddr.Address(), &evilOpts, butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), - solimpl.NewDataPosterTransactor(dp), + bold.NewDataPosterTransactor(dp), ) Require(t, err) @@ -619,7 +619,7 @@ func createTestNodeOnL1ForBoldProtocol( chalManagerAddr, &opts, butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), - solimpl.NewDataPosterTransactor(dp), + bold.NewDataPosterTransactor(dp), ) Require(t, err) assertionChain = assertionChainBindings @@ -827,7 +827,7 @@ func create2ndNodeWithConfigForBoldProtocol( chalManagerAddr, &evilOpts, butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), - solimpl.NewDataPosterTransactor(dp), + bold.NewDataPosterTransactor(dp), ) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index b4e25a08af..73ac8508a6 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -28,7 +28,7 @@ import ( "github.com/offchainlabs/bold/solgen/go/mocksgen" "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/bold/state-commitments/history" - "github.com/offchainlabs/bold/util" + butil "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/staker/bold" @@ -331,8 +331,8 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB builder.addresses.Rollup, chalManagerAddr, &txOpts, - util.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber), - solimpl.NewDataPosterTransactor(dp), + butil.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber), + bold.NewDataPosterTransactor(dp), ) Require(t, err) From b4f9dadf7ed277e72e0d17c112762525e4e4cca3 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 22 Nov 2024 22:53:49 -0600 Subject: [PATCH 163/210] Address PR comments --- staker/bold/data_poster_transactor.go | 6 +++++- staker/txbuilder/builder.go | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/staker/bold/data_poster_transactor.go b/staker/bold/data_poster_transactor.go index d68a2b8d2d..aa5f8d9768 100644 --- a/staker/bold/data_poster_transactor.go +++ b/staker/bold/data_poster_transactor.go @@ -29,7 +29,11 @@ func NewDataPosterTransactor(dataPoster *dataposter.DataPoster) *DataPosterTrans func (d *DataPosterTransactor) SendTransaction(ctx context.Context, fn func(opts *bind.TransactOpts) (*types.Transaction, error), opts *bind.TransactOpts, gas uint64) (*types.Transaction, error) { // Try to acquire lock and if it fails, wait for a bit and try again. for !d.fifo.Lock() { - <-time.After(100 * time.Millisecond) + select { + case <-time.After(100 * time.Millisecond): + case <-ctx.Done(): + return nil, ctx.Err() + } } defer d.fifo.Unlock() tx, err := fn(opts) diff --git a/staker/txbuilder/builder.go b/staker/txbuilder/builder.go index 18353422ae..b352036c7a 100644 --- a/staker/txbuilder/builder.go +++ b/staker/txbuilder/builder.go @@ -22,11 +22,9 @@ type ValidatorWalletInterface interface { AuthIfEoa() *bind.TransactOpts } -// Builder combines any transactions sent to it via SendTransaction into one batch, +// Builder combines any transactions signed via it into one batch, // which is then sent to the validator wallet. // This lets the validator make multiple atomic transactions. -// This inherits from an ethclient.Client so it can be used to transparently -// intercept calls to SendTransaction and queue them for the next batch. type Builder struct { transactions []*types.Transaction singleTxAuth bind.TransactOpts From c2ac13a3edb2f2aa758e1361a16cbca94fb80f08 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 23 Nov 2024 09:50:28 -0600 Subject: [PATCH 164/210] Add documentation for the EOA struct --- staker/validatorwallet/eoa.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/staker/validatorwallet/eoa.go b/staker/validatorwallet/eoa.go index f84dfaa265..80b805b396 100644 --- a/staker/validatorwallet/eoa.go +++ b/staker/validatorwallet/eoa.go @@ -17,6 +17,9 @@ import ( "github.com/offchainlabs/nitro/solgen/go/rollupgen" ) +// EOA is a ValidatorWallet that uses an Externally Owned Account to sign transactions. +// An Ethereum Externally Owned Account is directly represented by a private key, +// as opposed to a smart contract wallet where the smart contract authorizes transactions. type EOA struct { auth *bind.TransactOpts client *ethclient.Client From 0aa0cf85f840e81649b77c99a2fee6a10db7cea3 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 23 Nov 2024 22:07:37 -0600 Subject: [PATCH 165/210] Make bold state validated check more sturdy --- staker/bold/bold_state_provider.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 899b3c7a80..bda3d95510 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -162,6 +162,15 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( func (s *BOLDStateProvider) isStateValidatedAndMessageCountPastThreshold( ctx context.Context, gs validator.GoGlobalState, messageCount arbutil.MessageIndex, ) (bool, error) { + if s.stateProviderConfig.CheckBatchFinality { + finalizedMessageCount, err := s.statelessValidator.InboxReader().GetFinalizedMsgCount(ctx) + if err != nil { + return false, err + } + if messageCount > finalizedMessageCount { + return false, nil + } + } if s.validator == nil { // If we do not have a validator, we cannot check if the state is validated. // So we assume it is validated and return true. @@ -174,16 +183,8 @@ func (s *BOLDStateProvider) isStateValidatedAndMessageCountPastThreshold( if lastValidatedGs == nil { return false, ErrChainCatchingUp } - stateValidated := gs.Batch <= lastValidatedGs.GlobalState.Batch - if !s.stateProviderConfig.CheckBatchFinality { - return stateValidated, nil - } - finalizedMessageCount, err := s.statelessValidator.InboxReader().GetFinalizedMsgCount(ctx) - if err != nil { - return false, err - } - messageCountFinalized := messageCount <= finalizedMessageCount - return messageCountFinalized && stateValidated, nil + stateValidated := gs.Batch < lastValidatedGs.GlobalState.Batch || (gs.Batch == lastValidatedGs.GlobalState.Batch && gs.PosInBatch <= lastValidatedGs.GlobalState.PosInBatch) + return stateValidated, nil } func (s *BOLDStateProvider) StatesInBatchRange( From 28210845a1fbf793437e05a8fa4328ed3f5cf196 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 23 Nov 2024 22:08:03 -0600 Subject: [PATCH 166/210] Fix bold state provider test exiting loop early --- system_tests/bold_state_provider_test.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 4a6d715edc..766ecce380 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -208,13 +208,6 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { if lastInfo.GlobalState.Batch >= totalBatches { break } - batchMsgCount, err := l2node.InboxTracker.GetBatchMessageCount(lastInfo.GlobalState.Batch) - if err != nil { - continue - } - if batchMsgCount >= totalMessageCount { - break - } } t.Run("StatesInBatchRange", func(t *testing.T) { From 7b9264737f1b676c6e0b400bfdc57f02000d5bee Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:16:30 -0600 Subject: [PATCH 167/210] bug fix --- bold | 2 +- system_tests/__debug_bin3873387831 | 0 system_tests/bold_challenge_protocol_test.go | 4 ++-- system_tests/bold_new_challenge_test.go | 2 -- system_tests/bold_state_provider_test.go | 2 -- 5 files changed, 3 insertions(+), 7 deletions(-) create mode 100644 system_tests/__debug_bin3873387831 diff --git a/bold b/bold index 6fa5fa5c3f..1d48af9fca 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 6fa5fa5c3fdeb4516c978487fd1b7c825d72f7ef +Subproject commit 1d48af9fca6825472904695662b297f3d04a0d0b diff --git a/system_tests/__debug_bin3873387831 b/system_tests/__debug_bin3873387831 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 2ad66ee9a4..442082ee8e 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -1,8 +1,6 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -//go:build challengetest && !race - package arbtest import ( @@ -234,6 +232,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp &evilOpts, butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), + solimpl.WithRpcHeadBlockNumber(rpc.LatestBlockNumber), ) Require(t, err) @@ -620,6 +619,7 @@ func createTestNodeOnL1ForBoldProtocol( &opts, butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), solimpl.NewDataPosterTransactor(dp), + solimpl.WithRpcHeadBlockNumber(rpc.LatestBlockNumber), ) Require(t, err) assertionChain = assertionChainBindings diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index b4e25a08af..acaca79a85 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -1,8 +1,6 @@ // Copyright 2024, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -//go:build challengetest && !race - package arbtest import ( diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 766ecce380..df6fc95d2f 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -1,8 +1,6 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE -//go:build challengetest && !race - package arbtest import ( From dac6070f7072f96968a6dddb348a73352362e946 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:21:00 -0600 Subject: [PATCH 168/210] del --- system_tests/__debug_bin3873387831 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 system_tests/__debug_bin3873387831 diff --git a/system_tests/__debug_bin3873387831 b/system_tests/__debug_bin3873387831 deleted file mode 100644 index e69de29bb2..0000000000 From 1f259a987445a63021b4edbc3780e400a5024656 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:41:19 -0600 Subject: [PATCH 169/210] add back tag --- system_tests/bold_challenge_protocol_test.go | 2 ++ system_tests/bold_new_challenge_test.go | 2 ++ system_tests/bold_state_provider_test.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 442082ee8e..2a71e977ea 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -1,6 +1,8 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE +//go:build challengetest && !race + package arbtest import ( diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index acaca79a85..b4e25a08af 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -1,6 +1,8 @@ // Copyright 2024, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE +//go:build challengetest && !race + package arbtest import ( diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index df6fc95d2f..766ecce380 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -1,6 +1,8 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE +//go:build challengetest && !race + package arbtest import ( From f1de4c5142c8bd234ebbb16136e74f371cb3f0b6 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:43:55 -0600 Subject: [PATCH 170/210] edit bold submodule --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 8dc9c38366..1d48af9fca 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 8dc9c38366bed37188ebea567f301b69fb4811eb +Subproject commit 1d48af9fca6825472904695662b297f3d04a0d0b From 9e07266b7f96f7418c039b99311ab85b307974c7 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:45:38 -0600 Subject: [PATCH 171/210] bold submod --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 1d48af9fca..b4a1f85be1 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 1d48af9fca6825472904695662b297f3d04a0d0b +Subproject commit b4a1f85be1a2b00886b06002a02068d4d07b973b From 8aff5eec39536fbd0136e8fb7d4ed9650b0070fd Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 25 Nov 2024 13:45:50 -0600 Subject: [PATCH 172/210] bold submod --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 1d48af9fca..b4a1f85be1 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 1d48af9fca6825472904695662b297f3d04a0d0b +Subproject commit b4a1f85be1a2b00886b06002a02068d4d07b973b From 3e0cd74ec1a352d102383727c71fe62c4b312721 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 26 Nov 2024 13:22:01 +0530 Subject: [PATCH 173/210] Update gethpin v1.14.3 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 46fee83ed9..4f47f4c6ea 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 46fee83ed96f765f16a39b0a2733190c67294e27 +Subproject commit 4f47f4c6eafd81290d51a7f11fbd99bc2fc3c5a6 From b6ee9d26218a0ef0297d34e00e2fb7956449be82 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 26 Nov 2024 17:30:06 +0100 Subject: [PATCH 174/210] Make previousGlobalState a value instead of pointer There's no longer a need to be able to pass in nil. --- bold | 2 +- staker/bold/bold_state_provider.go | 45 ++++++++++-------------- system_tests/bold_new_challenge_test.go | 4 +-- system_tests/bold_state_provider_test.go | 18 +++++----- 4 files changed, 31 insertions(+), 38 deletions(-) diff --git a/bold b/bold index b4a1f85be1..9bc97907ce 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit b4a1f85be1a2b00886b06002a02068d4d07b973b +Subproject commit 9bc97907cef8d8123bf46753ed913d51fddf0c0b diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index bda3d95510..9707d09967 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -81,7 +81,7 @@ func NewBOLDStateProvider( func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxInboxCount uint64, - previousGlobalState *protocol.GoGlobalState, + previousGlobalState protocol.GoGlobalState, ) (*protocol.ExecutionState, error) { if maxInboxCount == 0 { return nil, errors.New("max inbox count cannot be zero") @@ -95,26 +95,24 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( } return nil, err } - if previousGlobalState != nil { - var previousMessageCount arbutil.MessageIndex - if previousGlobalState.Batch > 0 { - previousMessageCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(previousGlobalState.Batch - 1) - if err != nil { - if strings.Contains(err.Error(), "not found") { - return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) - } - return nil, err + var previousMessageCount arbutil.MessageIndex + if previousGlobalState.Batch > 0 { + previousMessageCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(previousGlobalState.Batch - 1) + if err != nil { + if strings.Contains(err.Error(), "not found") { + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) } + return nil, err } - previousMessageCount += arbutil.MessageIndex(previousGlobalState.PosInBatch) - messageDiffBetweenBatches := messageCount - previousMessageCount - maxMessageCount := previousMessageCount + arbutil.MessageIndex(maxNumberOfBlocks) - if messageDiffBetweenBatches > maxMessageCount { - messageCount = maxMessageCount - batchIndex, _, err = s.statelessValidator.InboxTracker().FindInboxBatchContainingMessage(messageCount) - if err != nil { - return nil, err - } + } + previousMessageCount += arbutil.MessageIndex(previousGlobalState.PosInBatch) + messageDiffBetweenBatches := messageCount - previousMessageCount + maxMessageCount := previousMessageCount + arbutil.MessageIndex(maxNumberOfBlocks) + if messageDiffBetweenBatches > maxMessageCount { + messageCount = maxMessageCount + batchIndex, _, err = s.statelessValidator.InboxTracker().FindInboxBatchContainingMessage(messageCount) + if err != nil { + return nil, err } } globalState, err := s.findGlobalStateFromMessageCountAndBatch(messageCount, l2stateprovider.Batch(batchIndex)) @@ -135,15 +133,10 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( GlobalState: protocol.GoGlobalState(globalState), MachineStatus: protocol.MachineStatusFinished, } - - var previousGlobalStateOrDefault protocol.GoGlobalState - if previousGlobalState != nil { - previousGlobalStateOrDefault = *previousGlobalState - } toBatch := executionState.GlobalState.Batch historyCommitStates, _, err := s.StatesInBatchRange( ctx, - previousGlobalStateOrDefault, + previousGlobalState, toBatch, l2stateprovider.Height(maxNumberOfBlocks), ) @@ -155,7 +148,7 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( return nil, err } executionState.EndHistoryRoot = historyCommit.Merkle - fmt.Printf("ExecutionStateAfterPreviousState for previous state batch %v pos %v got end batch %v pos %v last leaf %v hash %v\n", previousGlobalStateOrDefault.Batch, previousGlobalStateOrDefault.PosInBatch, executionState.GlobalState.Batch, executionState.GlobalState.PosInBatch, historyCommitStates[len(historyCommitStates)-1], executionState.EndHistoryRoot) + fmt.Printf("ExecutionStateAfterPreviousState for previous state batch %v pos %v got end batch %v pos %v last leaf %v hash %v\n", previousGlobalState.Batch, previousGlobalState.PosInBatch, executionState.GlobalState.Batch, executionState.GlobalState.PosInBatch, historyCommitStates[len(historyCommitStates)-1], executionState.EndHistoryRoot) return executionState, nil } diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 73ac8508a6..a9caec45f0 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -46,14 +46,14 @@ type incorrectBlockStateProvider struct { func (s *incorrectBlockStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxInboxCount uint64, - previousGlobalState *protocol.GoGlobalState, + previousGlobalState protocol.GoGlobalState, ) (*protocol.ExecutionState, error) { maxNumberOfBlocks := s.chain.SpecChallengeManager().LayerZeroHeights().BlockChallengeHeight.Uint64() executionState, err := s.honest.ExecutionStateAfterPreviousState(ctx, maxInboxCount, previousGlobalState) if err != nil { return nil, err } - evilStates, err := s.L2MessageStatesUpTo(ctx, *previousGlobalState, l2stateprovider.Batch(maxInboxCount), option.Some(l2stateprovider.Height(maxNumberOfBlocks))) + evilStates, err := s.L2MessageStatesUpTo(ctx, previousGlobalState, l2stateprovider.Batch(maxInboxCount), option.Some(l2stateprovider.Height(maxNumberOfBlocks))) if err != nil { return nil, err } diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 766ecce380..40578221db 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -238,7 +238,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { _, err = stateManager.ExecutionStateAfterPreviousState( ctx, 0, - &protocol.GoGlobalState{ + protocol.GoGlobalState{ Batch: 0, PosInBatch: 1, }, @@ -254,7 +254,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { genesis, err := stateManager.ExecutionStateAfterPreviousState( ctx, 1, - &protocol.GoGlobalState{ + protocol.GoGlobalState{ Batch: 0, PosInBatch: 0, }, @@ -268,7 +268,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { first, err := stateManager.ExecutionStateAfterPreviousState( ctx, 2, - &genesis.GlobalState, + genesis.GlobalState, ) Require(t, err) if first == nil { @@ -279,7 +279,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { _, err = stateManager.ExecutionStateAfterPreviousState( ctx, 10, - &first.GlobalState, + first.GlobalState, ) if err == nil { Fatal(t, "should not agree with execution state") @@ -298,7 +298,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { SendRoot: result.SendRoot, Batch: 3, } - got, err := stateManager.ExecutionStateAfterPreviousState(ctx, 3, &first.GlobalState) + got, err := stateManager.ExecutionStateAfterPreviousState(ctx, 3, first.GlobalState) Require(t, err) if state.Batch != got.GlobalState.Batch { Fatal(t, "wrong batch") @@ -315,7 +315,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { _, err = stateManager.ExecutionStateAfterPreviousState( ctx, state.Batch+1, - &got.GlobalState, + got.GlobalState, ) if err == nil { Fatal(t, "should not agree with execution state") @@ -325,7 +325,7 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { } }) t.Run("ExecutionStateAfterBatchCount", func(t *testing.T) { - _, err = stateManager.ExecutionStateAfterPreviousState(ctx, 0, &protocol.GoGlobalState{}) + _, err = stateManager.ExecutionStateAfterPreviousState(ctx, 0, protocol.GoGlobalState{}) if err == nil { Fatal(t, "should have failed") } @@ -333,9 +333,9 @@ func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { Fatal(t, "wrong error message", err) } - genesis, err := stateManager.ExecutionStateAfterPreviousState(ctx, 1, &protocol.GoGlobalState{}) + genesis, err := stateManager.ExecutionStateAfterPreviousState(ctx, 1, protocol.GoGlobalState{}) Require(t, err) - execState, err := stateManager.ExecutionStateAfterPreviousState(ctx, totalBatches, &genesis.GlobalState) + execState, err := stateManager.ExecutionStateAfterPreviousState(ctx, totalBatches, genesis.GlobalState) Require(t, err) if execState == nil { Fatal(t, "should not be nil") From 89b4cb5c9b99f95912670acad354f6f452c433df Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 27 Nov 2024 08:59:55 +0100 Subject: [PATCH 175/210] Update bold repo pin to main --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 9bc97907ce..7f3b9eb79a 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 9bc97907cef8d8123bf46753ed913d51fddf0c0b +Subproject commit 7f3b9eb79a07f5644b39f2f3a41053cf68071657 From 6608888b8d4304bb8f4ce89215a843f5856b6981 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 27 Nov 2024 14:17:29 -0600 Subject: [PATCH 176/210] remove nil opts from validation node creation --- cmd/nitro/nitro.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 8c3b6a3d92..71457a86e2 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -518,7 +518,6 @@ func mainImpl() int { func() *valnode.Config { return &liveNodeConfig.Get().Validation }, stack, fatalErrChan, - nil, ) if err != nil { valNode = nil From 5cec6a7b363853e355f717b327159405e97f97c8 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 27 Nov 2024 14:17:46 -0600 Subject: [PATCH 177/210] remove nil opts from validation node creation --- cmd/nitro-val/nitro_val.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/nitro-val/nitro_val.go b/cmd/nitro-val/nitro_val.go index b5a3d823ab..3ff859c302 100644 --- a/cmd/nitro-val/nitro_val.go +++ b/cmd/nitro-val/nitro_val.go @@ -135,7 +135,6 @@ func mainImpl() int { func() *valnode.Config { return &liveNodeConfig.Get().Validation }, stack, fatalErrChan, - nil, ) if err != nil { log.Error("couldn't init validation node", "err", err) From 0e6e2a8df0c058af08f391c84d402787c8614d6a Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 27 Nov 2024 14:20:43 -0600 Subject: [PATCH 178/210] rem print --- staker/bold/bold_state_provider.go | 1 - 1 file changed, 1 deletion(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 9707d09967..76ab6314fb 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -148,7 +148,6 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( return nil, err } executionState.EndHistoryRoot = historyCommit.Merkle - fmt.Printf("ExecutionStateAfterPreviousState for previous state batch %v pos %v got end batch %v pos %v last leaf %v hash %v\n", previousGlobalState.Batch, previousGlobalState.PosInBatch, executionState.GlobalState.Batch, executionState.GlobalState.PosInBatch, historyCommitStates[len(historyCommitStates)-1], executionState.EndHistoryRoot) return executionState, nil } From 1ad24f25565d055cabf95f113c337b39f6940d56 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 28 Nov 2024 13:25:05 +0100 Subject: [PATCH 179/210] Test an overflow assertion This test confirms that when there are more messages in the sequencer inbox than the block challenge level height, the next assertion is an "overflow" assertion and is not required to wait to minimumAssertionPeriod blocks before posting. Part of NIT-2794 --- bold | 2 +- system_tests/bold_challenge_protocol_test.go | 39 ++- system_tests/bold_state_provider_test.go | 17 +- system_tests/common_test.go | 7 +- system_tests/overflow_assertions_test.go | 320 +++++++++++++++++++ 5 files changed, 375 insertions(+), 10 deletions(-) create mode 100644 system_tests/overflow_assertions_test.go diff --git a/bold b/bold index 7f3b9eb79a..3d5ae947ce 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 7f3b9eb79a07f5644b39f2f3a41053cf68071657 +Subproject commit 3d5ae947ce248ad31b06b2799cbfaf2db585d2fd diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index fa2000077c..134d1daeb9 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -97,8 +97,22 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp ownerBal := big.NewInt(params.Ether) ownerBal.Mul(ownerBal, big.NewInt(1_000_000)) l2info.GenerateGenesisAccount("Owner", ownerBal) + sconf := setup.RollupStackConfig{ + UseMockBridge: false, + UseMockOneStepProver: false, + MinimumAssertionPeriod: 0, + } - _, l2nodeA, _, _, l1info, _, l1client, l1stack, assertionChain, stakeTokenAddr := createTestNodeOnL1ForBoldProtocol(t, ctx, true, nil, l2chainConfig, nil, l2info) + _, l2nodeA, _, _, l1info, _, l1client, l1stack, assertionChain, stakeTokenAddr := createTestNodeOnL1ForBoldProtocol( + t, + ctx, + true, + nil, + l2chainConfig, + nil, + sconf, + l2info, + ) defer requireClose(t, l1stack) defer l2nodeA.StopAndWait() @@ -109,7 +123,18 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp go keepChainMoving(t, ctx, l1info, l1client) l2nodeConfig := arbnode.ConfigDefaultL1Test() - _, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, l2nodeConfig, nil, stakeTokenAddr) + _, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol( + t, + ctx, + l2nodeA, + l1stack, + l1info, + &l2info.ArbInitData, + l2nodeConfig, + nil, + sconf, + stakeTokenAddr, + ) defer l2nodeB.StopAndWait() genesisA, err := l2nodeA.Execution.ResultAtPos(0) @@ -494,6 +519,7 @@ func createTestNodeOnL1ForBoldProtocol( nodeConfig *arbnode.Config, chainConfig *params.ChainConfig, _ *node.Config, + rollupStackConf setup.RollupStackConfig, l2infoIn info, ) ( l2info info, currentNode *arbnode.Node, l2client *ethclient.Client, l2stack *node.Node, @@ -554,7 +580,7 @@ func createTestNodeOnL1ForBoldProtocol( Require(t, err) l1TransactionOpts.Value = nil - addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, stakeToken) + addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, rollupStackConf, stakeToken) rollupUser, err := rollupgen.NewRollupUserLogic(addresses.Rollup, l1client) Require(t, err) chalManagerAddr, err := rollupUser.ChallengeManager(&bind.CallOpts{}) @@ -635,6 +661,7 @@ func deployContractsOnly( l1info info, backend *ethclient.Client, chainId *big.Int, + rollupStackConf setup.RollupStackConfig, stakeToken common.Address, ) *chaininfo.RollupAddresses { l1TransactionOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx) @@ -679,8 +706,7 @@ func deployContractsOnly( &l1TransactionOpts, l1info.GetAddress("Sequencer"), cfg, - false, // do not use mock bridge. - false, // do not use a mock one-step prover + rollupStackConf, ) Require(t, err) @@ -747,6 +773,7 @@ func create2ndNodeWithConfigForBoldProtocol( l2InitData *statetransfer.ArbosInitializationInfo, nodeConfig *arbnode.Config, stackConfig *node.Config, + rollupStackConf setup.RollupStackConfig, stakeTokenAddr common.Address, ) (*ethclient.Client, *arbnode.Node, *solimpl.AssertionChain) { fatalErrChan := make(chan error, 10) @@ -757,7 +784,7 @@ func create2ndNodeWithConfigForBoldProtocol( Fatal(t, "not geth execution node") } chainConfig := firstExec.ArbInterface.BlockChain().Config() - addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, stakeTokenAddr) + addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, rollupStackConf, stakeTokenAddr) l1info.SetContract("EvilBridge", addresses.Bridge) l1info.SetContract("EvilSequencerInbox", addresses.SequencerInbox) diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 40578221db..17fa436a83 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -37,6 +37,7 @@ import ( "github.com/offchainlabs/bold/solgen/go/mocksgen" prefixproofs "github.com/offchainlabs/bold/state-commitments/prefix-proofs" mockmanager "github.com/offchainlabs/bold/testing/mocks/state-provider" + "github.com/offchainlabs/bold/testing/setup" ) func TestChallengeProtocolBOLD_Bisections(t *testing.T) { @@ -354,8 +355,22 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context, blockChallengeHei ownerBal := big.NewInt(params.Ether) ownerBal.Mul(ownerBal, big.NewInt(1_000_000)) l2info.GenerateGenesisAccount("Owner", ownerBal) + sconf := setup.RollupStackConfig{ + UseMockBridge: false, + UseMockOneStepProver: false, + MinimumAssertionPeriod: 0, + } - _, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol(t, ctx, false, nil, l2chainConfig, nil, l2info) + _, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol( + t, + ctx, + false, + nil, + l2chainConfig, + nil, + sconf, + l2info, + ) valnode.TestValidationConfig.UseJit = false _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index c33314eb15..72d2645910 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1350,8 +1350,11 @@ func deployOnParentChain( &parentChainTransactionOpts, parentChainInfo.GetAddress("Sequencer"), cfg, - false, // do not use mock bridge. - false, // do not use a mock one-step prover + setup.RollupStackConfig{ + UseMockBridge: false, + UseMockOneStepProver: false, + MinimumAssertionPeriod: 0, + }, ) Require(t, err) addresses = &chaininfo.RollupAddresses{ diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go new file mode 100644 index 0000000000..c1e0ea36d8 --- /dev/null +++ b/system_tests/overflow_assertions_test.go @@ -0,0 +1,320 @@ +// Copyright 2024, Offchain Labs, Inc. +// For license information, see: +// https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md + +//go:build challengetest && !race + +package arbtest + +import ( + "context" + "math/big" + "os" + "strings" + "testing" + "time" + + "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + + protocol "github.com/offchainlabs/bold/chain-abstraction" + challengemanager "github.com/offchainlabs/bold/challenge-manager" + modes "github.com/offchainlabs/bold/challenge-manager/types" + l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/bridgegen" + "github.com/offchainlabs/bold/solgen/go/mocksgen" + "github.com/offchainlabs/bold/solgen/go/rollupgen" + "github.com/offchainlabs/bold/testing/setup" + "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/cmd/chaininfo" + "github.com/offchainlabs/nitro/execution/gethexec" + "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/bold" + "github.com/offchainlabs/nitro/util" + "github.com/offchainlabs/nitro/validator/server_arb" + "github.com/offchainlabs/nitro/validator/server_arb/boldmach" + "github.com/offchainlabs/nitro/validator/valnode" +) + +func TestOverflowAssertions(t *testing.T) { + // Get a simulated geth backend running. + // + // Create enough messages in batches to overflow the block level challenge + // height. (height == 32, messages = 45) + // + // Start the challenge manager with a minimumAssertionPeriod of 7 and make + // sure that it posts overflow-assertions right away instead of waiting for + // the 7 blocks to pass. + Require(t, os.RemoveAll("/tmp/good")) + t.Cleanup(func() { + Require(t, os.RemoveAll("/tmp/good")) + }) + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs + l2chainConfig := chaininfo.ArbitrumDevTestChainConfig() + l2info := NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(l2chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + // This is important to show that overflow assertions don't wait. + minAssertionBlocks := int64(7) + ownerBal := big.NewInt(params.Ether) + ownerBal.Mul(ownerBal, big.NewInt(1_000_000)) + l2info.GenerateGenesisAccount("Owner", ownerBal) + sconf := setup.RollupStackConfig{ + UseMockBridge: false, + UseMockOneStepProver: false, + MinimumAssertionPeriod: minAssertionBlocks, + } + + _, l2node, _, _, l1info, _, l1client, l1stack, assertionChain, _ := createTestNodeOnL1ForBoldProtocol(t, ctx, true, nil, l2chainConfig, nil, sconf, l2info) + defer requireClose(t, l1stack) + defer l2node.StopAndWait() + + // Make sure we shut down test functionality before the rest of the node + ctx, cancelCtx = context.WithCancel(ctx) + defer cancelCtx() + + go keepChainMoving(t, ctx, l1info, l1client) + + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + TransferBalance(t, "Faucet", "Asserter", balance, l1info, l1client, ctx) + + valCfg := valnode.TestValidationConfig + valCfg.UseJit = false + boldWrapperOpt := server_arb.WithWrapper( + func(inner server_arb.MachineInterface) server_arb.MachineInterface { + return boldmach.MachineWrapper(inner) + }) + _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) + blockValidatorConfig := staker.TestBlockValidatorConfig + + stateless, err := staker.NewStatelessBlockValidator( + l2node.InboxReader, + l2node.InboxTracker, + l2node.TxStreamer, + l2node.Execution, + l2node.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = stateless.Start(ctx) + Require(t, err) + + blockValidator, err := staker.NewBlockValidator( + stateless, + l2node.InboxTracker, + l2node.TxStreamer, + StaticFetcherFrom(t, &blockValidatorConfig), + nil, + ) + Require(t, err) + Require(t, blockValidator.Initialize(ctx)) + Require(t, blockValidator.Start(ctx)) + + stateManager, err := bold.NewBOLDStateProvider( + blockValidator, + stateless, + l2stateprovider.Height(blockChallengeLeafHeight), + &bold.StateProviderConfig{ + ValidatorName: "good", + MachineLeavesCachePath: "/tmp/good", + CheckBatchFinality: false, + }, + ) + Require(t, err) + + Require(t, l2node.Start(ctx)) + + l2info.GenerateAccount("Destination") + sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + + honestSeqInbox := l1info.GetAddress("SequencerInbox") + honestSeqInboxBinding, err := bridgegen.NewSequencerInbox(honestSeqInbox, l1client) + Require(t, err) + + // Post batches to the honest and inbox. + seqInboxABI, err := abi.JSON(strings.NewReader(bridgegen.SequencerInboxABI)) + Require(t, err) + + honestUpgradeExec, err := mocksgen.NewUpgradeExecutorMock(l1info.GetAddress("UpgradeExecutor"), l1client) + Require(t, err) + data, err := seqInboxABI.Pack( + "setIsBatchPoster", + sequencerTxOpts.From, + true, + ) + Require(t, err) + honestRollupOwnerOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx) + _, err = honestUpgradeExec.ExecuteCall(&honestRollupOwnerOpts, honestSeqInbox, data) + Require(t, err) + + // Post enough messages (45 across 2 batches) to overflow the block level + // challenge height (32). + totalMessagesPosted := int64(0) + numMessagesPerBatch := int64(32) + divergeAt := int64(-1) + makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, honestSeqInboxBinding, honestSeqInbox, numMessagesPerBatch, divergeAt) + totalMessagesPosted += numMessagesPerBatch + + numMessagesPerBatch = int64(13) + makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, honestSeqInboxBinding, honestSeqInbox, numMessagesPerBatch, divergeAt) + totalMessagesPosted += numMessagesPerBatch + + bc, err := l2node.InboxTracker.GetBatchCount() + Require(t, err) + msgs, err := l2node.InboxTracker.GetBatchMessageCount(bc - 1) + Require(t, err) + + t.Logf("Node batch count %d, msgs %d", bc, msgs) + + // Wait for the node to catch up. + nodeExec, ok := l2node.Execution.(*gethexec.ExecutionNode) + if !ok { + Fatal(t, "not geth execution node") + } + for { + latest := nodeExec.Backend.APIBackend().CurrentHeader() + isCaughtUp := latest.Number.Uint64() == uint64(totalMessagesPosted) + if isCaughtUp { + break + } + time.Sleep(time.Millisecond * 200) + } + + bridgeBinding, err := bridgegen.NewBridge(l1info.GetAddress("Bridge"), l1client) + Require(t, err) + totalBatchesBig, err := bridgeBinding.SequencerMessageCount(&bind.CallOpts{Context: ctx}) + Require(t, err) + totalBatches := totalBatchesBig.Uint64() + + // Wait until the validator has validated the batches. + for { + lastInfo, err := blockValidator.ReadLastValidatedInfo() + if lastInfo == nil || err != nil { + continue + } + t.Log("Batch", lastInfo.GlobalState.Batch, "Total", totalBatches-1) + if lastInfo.GlobalState.Batch >= totalBatches-1 { + break + } + time.Sleep(time.Millisecond * 200) + } + + provider := l2stateprovider.NewHistoryCommitmentProvider( + stateManager, + stateManager, + stateManager, + []l2stateprovider.Height{ + l2stateprovider.Height(blockChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(smallStepChallengeLeafHeight), + }, + stateManager, + nil, // Api db + ) + + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName("default"), + challengemanager.StackWithMode(modes.MakeMode), + challengemanager.StackWithPostingInterval(time.Second), + challengemanager.StackWithPollingInterval(time.Millisecond * 500), + challengemanager.StackWithAverageBlockCreationTime(time.Second), + } + + manager, err := challengemanager.NewChallengeStack( + assertionChain, + provider, + stackOpts..., + ) + Require(t, err) + manager.Start(ctx) + + filterer, err := rollupgen.NewRollupUserLogicFilterer(assertionChain.RollupAddress(), assertionChain.Backend()) + Require(t, err) + + // The goal of this test is to observe: + // + // 1. The genisis assertion (non-overflow) + // 2. The assertion of the first 32 blocks of the two batches manually set up + // above (non-overflow) + // 3. The overflow assertion that should be posted in fewer than + // minAssertionBlocks. (overflow) + // 4. One more normal assertion in >= minAssertionBlocks. (non-overflow) + + overflow := true + nonOverflow := false + expectedAssertions := []bool{nonOverflow, nonOverflow, overflow, nonOverflow} + mab64, err := safecast.ToUint64(minAssertionBlocks) + Require(t, err) + + lastInboxMax := uint64(0) + lastAssertionBlock := uint64(0) + fromBlock := uint64(0) + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + for len(expectedAssertions) > 0 { + select { + case <-ticker.C: + latestBlock, err := l1client.HeaderByNumber(ctx, nil) + Require(t, err) + toBlock := latestBlock.Number.Uint64() + if fromBlock >= toBlock { + continue + } + filterOpts := &bind.FilterOpts{ + Start: fromBlock, + End: &toBlock, + Context: ctx, + } + it, err := filterer.FilterAssertionCreated(filterOpts, nil, nil) + Require(t, err) + for it.Next() { + if it.Error() != nil { + t.Fatalf("Error in filter iterator: %v", it.Error()) + } + t.Log("Received event of assertion created!") + assertionHash := protocol.AssertionHash{Hash: it.Event.AssertionHash} + creationInfo, err := assertionChain.ReadAssertionCreationInfo(ctx, assertionHash) + Require(t, err) + t.Logf("Created assertion in block: %d", creationInfo.CreationBlock) + newState := protocol.GoGlobalStateFromSolidity(creationInfo.AfterState.GlobalState) + t.Logf("NewState PosInBatch: %d", newState.PosInBatch) + inboxMax := creationInfo.InboxMaxCount.Uint64() + t.Logf("InboxMax: %d", inboxMax) + blocks := creationInfo.CreationBlock - lastAssertionBlock + // PosInBatch == 0 && inboxMax > lastInboxMax means it is NOT an overflow assertion. + if newState.PosInBatch == 0 && inboxMax > lastInboxMax { + if expectedAssertions[0] == overflow { + t.Errorf("Expected overflow assertion, got non-overflow assertion") + } + if blocks < mab64 { + t.Errorf("non-overflow assertions should have >= =%d blocks between them. Got: %d", mab64, blocks) + } + } else { + if expectedAssertions[0] == nonOverflow { + t.Errorf("Expected non-overflow assertion, got overflow assertion") + } + if blocks >= mab64 { + t.Errorf("overflow assertions should not have %d blocks between them. Got: %d", mab64, blocks) + } + } + lastAssertionBlock = creationInfo.CreationBlock + lastInboxMax = inboxMax + expectedAssertions = expectedAssertions[1:] + } + fromBlock = toBlock + 1 + case <-ctx.Done(): + return + } + } + // PASS: All expected assertions were seen. +} From fd85fcd35e78038d9e2144a8c94688af627a7634 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 28 Nov 2024 16:36:31 +0100 Subject: [PATCH 180/210] Make the finished machine actually pass the global state No reason to keep this in a separate API. --- arbitrator/prover/src/lib.rs | 4 ++-- arbitrator/prover/src/machine.rs | 7 ++----- staker/bold/bold_state_provider.go | 10 ++-------- validator/server_arb/boldmach/machine.go | 7 +------ validator/server_arb/machine.go | 4 ++-- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 2e8ccfcfd5..bc2bd4bc48 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -129,8 +129,8 @@ pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) #[no_mangle] #[cfg(feature = "native")] -pub unsafe extern "C" fn arbitrator_new_finished() -> *mut Machine { - Box::into_raw(Box::new(Machine::new_finished())) +pub unsafe extern "C" fn arbitrator_new_finished(gs: GlobalState) -> *mut Machine { + Box::into_raw(Box::new(Machine::new_finished(gs))) } unsafe fn cstr_to_string(c_str: *const c_char) -> String { diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 7cbdeb3cac..0d39d87e77 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1569,14 +1569,11 @@ impl Machine { // // This allows the Mahine to be set up to model the final state of the // machine at the end of the execution of a block. - // - // Callers should use set_global_state to set the global state of the - // machine to the global state at the end of the block. - pub fn new_finished() -> Machine { + pub fn new_finished(gs: GlobalState) -> Machine { Machine { steps: 0, status: MachineStatus::Finished, - global_state: Default::default(), + global_state: gs, // The machine is in the Finished state, so nothing else really matters. // values_stacks and frame_stacks cannot be empty for proof serialization, // but everything else can just be entirely blank. diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 9707d09967..8d9ebcae48 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -331,10 +331,7 @@ func (s *BOLDStateProvider) CollectMachineHashes( return nil, err } if vs.IsSome() { - m := server_arb.NewFinishedMachine() - if err := m.SetGlobalState(vs.Unwrap()); err != nil { - return nil, err - } + m := server_arb.NewFinishedMachine(vs.Unwrap()) defer m.Destroy() return []common.Hash{m.Hash()}, nil } @@ -509,10 +506,7 @@ func (s *BOLDStateProvider) CollectProof( return nil, err } if vs.IsSome() { - m := server_arb.NewFinishedMachine() - if err := m.SetGlobalState(vs.Unwrap()); err != nil { - return nil, err - } + m := server_arb.NewFinishedMachine(vs.Unwrap()) defer m.Destroy() return m.ProveNextStep(), nil } diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go index ba51fe6b72..914c7b21d7 100644 --- a/validator/server_arb/boldmach/machine.go +++ b/validator/server_arb/boldmach/machine.go @@ -20,12 +20,7 @@ type boldMachine struct { var _ server_arb.MachineInterface = (*boldMachine)(nil) func newBoldMachine(inner server_arb.MachineInterface) *boldMachine { - z := server_arb.NewFinishedMachine() - if err := z.SetGlobalState(inner.GetGlobalState()); err != nil { - // This should only occur if the machine is frozen, - // which it isn't because we just created it. - panic(err) - } + z := server_arb.NewFinishedMachine(inner.GetGlobalState()) return &boldMachine{ inner: inner, zeroMachine: z, diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 9bd3904301..09a00635fb 100644 --- a/validator/server_arb/machine.go +++ b/validator/server_arb/machine.go @@ -118,8 +118,8 @@ func LoadSimpleMachine(wasm string, libraries []string, debugChain bool) (*Arbit return machineFromPointer(mach), nil } -func NewFinishedMachine() *ArbitratorMachine { - mach := C.arbitrator_new_finished() +func NewFinishedMachine(gs validator.GoGlobalState) *ArbitratorMachine { + mach := C.arbitrator_new_finished(GlobalStateToC(gs)) if mach == nil { return nil } From 497714845ae287536f7fecc760b4b386da767668 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 28 Nov 2024 17:55:11 +0100 Subject: [PATCH 181/210] Add BoLD ascii art for the log --- staker/multi_protocol/multi_protocol_staker.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index a7ba85ac07..1fbc957353 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -18,6 +18,18 @@ import ( "github.com/offchainlabs/nitro/util/stopwaiter" ) +const boldArt = ` + _______ __ _______ +/ \ / | / \ +$$$$$$$ | ______ $$ | $$$$$$$ | +$$ |__$$ | / \ $$ | $$ | $$ | +$$ $$< /$$$$$$ |$$ | $$ | $$ | +$$$$$$$ |$$ | $$ |$$ | $$ | $$ | +$$ |__$$ |$$ \__$$ |$$ |_____ $$ |__$$ | +$$ $$/ $$ $$/ $$ |$$ $$/ +$$$$$$$/ $$$$$$/ $$$$$$$$/ $$$$$$$/ +` + type MultiProtocolStaker struct { stopwaiter.StopWaiter bridge *bridgegen.IBridge @@ -95,7 +107,8 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { return err } if boldActive { - log.Info("BOLD protocol is active, initializing BOLD staker") + log.Info("BoLD protocol is active, initializing BoLD staker") + log.Info(boldArt) boldStaker, err := m.setupBoldStaker(ctx, rollupAddress) if err != nil { return err From e2a41e7c2a8bb56f3f5d8af0bae61b410dacfd58 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 28 Nov 2024 17:59:55 +0100 Subject: [PATCH 182/210] Rename maxInboxCount -> maxSeqInboxCount This makes it clear that the number is the maximum sequencer inbox count, and not the maximum delayed inbox count. --- staker/bold/bold_state_provider.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index b5987824c2..0459b72053 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -72,26 +72,26 @@ func NewBOLDStateProvider( } // ExecutionStateAfterPreviousState Produces the L2 execution state for the next -// assertion. Returns the state at maxInboxCount or blockChallengeLeafHeight +// assertion. Returns the state at maxSeqInboxCount or blockChallengeLeafHeight // after the previous state, whichever is earlier. If previousGlobalState is -// nil, defaults to returning the state at maxInboxCount. +// nil, defaults to returning the state at maxSeqInboxCount. // // TODO: Check the block validator has validated the execution state we are // proposing. func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, - maxInboxCount uint64, + maxSeqInboxCount uint64, previousGlobalState protocol.GoGlobalState, ) (*protocol.ExecutionState, error) { - if maxInboxCount == 0 { + if maxSeqInboxCount == 0 { return nil, errors.New("max inbox count cannot be zero") } - batchIndex := maxInboxCount + batchIndex := maxSeqInboxCount maxNumberOfBlocks := uint64(s.blockChallengeLeafHeight) messageCount, err := s.statelessValidator.InboxTracker().GetBatchMessageCount(batchIndex - 1) if err != nil { if strings.Contains(err.Error(), "not found") { - return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxSeqInboxCount) } return nil, err } @@ -100,7 +100,7 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( previousMessageCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(previousGlobalState.Batch - 1) if err != nil { if strings.Contains(err.Error(), "not found") { - return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxSeqInboxCount) } return nil, err } @@ -126,7 +126,7 @@ func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( return nil, err } if !stateValidatedAndMessageCountPastThreshold { - return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxInboxCount) + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxSeqInboxCount) } executionState := &protocol.ExecutionState{ From 6a0754ada3b7fe27cf185c3318da82737c23bb9f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 29 Nov 2024 10:50:29 +0100 Subject: [PATCH 183/210] Move the Info logging into the staker implmentations --- arbnode/node.go | 1 - staker/bold/bold_staker.go | 6 ++++++ staker/legacy/staker.go | 15 +++++++++++++++ staker/multi_protocol/multi_protocol_staker.go | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arbnode/node.go b/arbnode/node.go index 506e1f0ab0..33967409d3 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -703,7 +703,6 @@ func createNodeImpl( if dp != nil { stakerAddr = dp.Sender() } - log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", wallet.Address(), "strategy", config.Staker.Strategy) } var batchPoster *BatchPoster diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 348b822aac..6d4d43d9f6 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -196,6 +196,12 @@ func (b *BOLDStaker) Initialize(ctx context.Context) error { return err } walletAddressOrZero := b.wallet.AddressOrZero() + var stakerAddr common.Address + if b.wallet.DataPoster() != nil { + stakerAddr = b.wallet.DataPoster().Sender() + } + log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "mode", b.config.Mode) + if b.blockValidator != nil && b.config.StartValidationFromStaked && !b.blockValidator.Started() { rollupUserLogic, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client) if err != nil { diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index 63ae4f97a9..87f891b9ac 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -354,6 +354,21 @@ func (s *Staker) Initialize(ctx context.Context) error { if walletAddressOrZero != (common.Address{}) { s.updateStakerBalanceMetric(ctx) } + var stakerAddr common.Address + if s.L1Validator.wallet.DataPoster() != nil { + stakerAddr = s.L1Validator.wallet.DataPoster().Sender() + } + whiteListed, err := s.isWhitelisted(ctx) + if err != nil { + return fmt.Errorf("error checking if whitelisted: %w", err) + } + log.Info( + "running as validator", + "txSender", stakerAddr, + "actingAsWallet", walletAddressOrZero, + "whitelisted", whiteListed, + "strategy", s.Strategy(), + ) if s.blockValidator != nil && s.config().StartValidationFromStaked { latestStaked, _, err := s.validatorUtils.LatestStaked(&s.baseCallOpts, s.rollupAddress, walletAddressOrZero) if err != nil { diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index 1fbc957353..8dd5318cab 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -117,7 +117,7 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { m.oldStaker = nil return m.boldStaker.Initialize(ctx) } - log.Info("BOLD protocol not detected on startup, using old staker until upgrade") + log.Info("BoLD protocol not detected on startup, using old staker until upgrade") return m.oldStaker.Initialize(ctx) } From 902696e1e0c299ea00df967f673358291dc68344 Mon Sep 17 00:00:00 2001 From: Harry Kalodner Date: Mon, 2 Dec 2024 11:11:53 -0500 Subject: [PATCH 184/210] chore: update AEP link --- LICENSE.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 25768b3010..13e28a591a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -19,7 +19,7 @@ Additional Use Grant: You may use the Licensed Work in a production environment validating the correctness of the posted chain state, or to deploy and operate (x) a blockchain that settles to a Covered Arbitrum Chain or (y) a blockchain in accordance with, and subject to, the [Arbitrum - Expansion Program Term of Use](https://docs.arbitrum.foundation/assets/files/Arbitrum%20Expansion%20Program%20Jan182024-4f08b0c2cb476a55dc153380fa3e64b0.pdf). For purposes of this + Expansion Program Term of Use](https://docs.arbitrum.foundation/aep/ArbitrumExpansionProgramTerms.pdf). For purposes of this Additional Use Grant, the "Covered Arbitrum Chains" are (a) Arbitrum One (chainid:42161), Arbitrum Nova (chainid:42170), Arbitrum Rinkeby testnet/Rinkarby (chainid:421611),Arbitrum Nitro diff --git a/README.md b/README.md index 1f0e4ac81c..30904238dc 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Nitro is currently licensed under a [Business Source License](./LICENSE.md), sim The Additional Use Grant also permits the deployment of the Nitro software, in a permissionless fashion and without cost, as a new blockchain provided that the chain settles to either Arbitrum One or Arbitrum Nova. -For those that prefer to deploy the Nitro software either directly on Ethereum (i.e. an L2) or have it settle to another Layer-2 on top of Ethereum, the [Arbitrum Expansion Program (the "AEP")](https://docs.arbitrum.foundation/assets/files/Arbitrum%20Expansion%20Program%20Jan182024-4f08b0c2cb476a55dc153380fa3e64b0.pdf) was recently established. The AEP allows for the permissionless deployment in the aforementioned fashion provided that 10% of net revenue (as more fully described in the AEP) is contributed back to the Arbitrum community in accordance with the requirements of the AEP. +For those that prefer to deploy the Nitro software either directly on Ethereum (i.e. an L2) or have it settle to another Layer-2 on top of Ethereum, the [Arbitrum Expansion Program (the "AEP")](https://docs.arbitrum.foundation/aep/ArbitrumExpansionProgramTerms.pdf) was recently established. The AEP allows for the permissionless deployment in the aforementioned fashion provided that 10% of net revenue (as more fully described in the AEP) is contributed back to the Arbitrum community in accordance with the requirements of the AEP. ## Contact From 1403c8874a47c3b534fd24def6f935eafc848d31 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 3 Dec 2024 10:28:04 -0700 Subject: [PATCH 185/210] Fix StopOnly followed by StopAndWait --- util/stopwaiter/stopwaiter.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/util/stopwaiter/stopwaiter.go b/util/stopwaiter/stopwaiter.go index 993768dd85..974178e1cf 100644 --- a/util/stopwaiter/stopwaiter.go +++ b/util/stopwaiter/stopwaiter.go @@ -96,20 +96,12 @@ func (s *StopWaiterSafe) Start(ctx context.Context, parent any) error { } func (s *StopWaiterSafe) StopOnly() { - _ = s.stopOnly() -} - -// returns true if stop function was called -func (s *StopWaiterSafe) stopOnly() bool { - stopWasCalled := false s.mutex.Lock() defer s.mutex.Unlock() if s.started && !s.stopped { s.stopFunc() - stopWasCalled = true } s.stopped = true - return stopWasCalled } // StopAndWait may be called multiple times, even before start. @@ -126,9 +118,9 @@ func getAllStackTraces() string { } func (s *StopWaiterSafe) stopAndWaitImpl(warningTimeout time.Duration) error { - if !s.stopOnly() { - return nil - } + s.StopOnly() + // Even if StopOnly has been previously called, make sure we wait for everything to shut down. + // Otherwise, a StopOnly call followed by StopAndWait might return early without waiting. waitChan, err := s.GetWaitChannel() if err != nil { return err From 99830437ba13b1bab4d0a83fb700f1d9bd0e8a84 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 3 Dec 2024 12:14:34 -0700 Subject: [PATCH 186/210] Fix stop before start and add test --- util/stopwaiter/stopwaiter.go | 6 ++++++ util/stopwaiter/stopwaiter_test.go | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/util/stopwaiter/stopwaiter.go b/util/stopwaiter/stopwaiter.go index 974178e1cf..c242ac26ab 100644 --- a/util/stopwaiter/stopwaiter.go +++ b/util/stopwaiter/stopwaiter.go @@ -119,8 +119,14 @@ func getAllStackTraces() string { func (s *StopWaiterSafe) stopAndWaitImpl(warningTimeout time.Duration) error { s.StopOnly() + if !s.Started() { + // No need to wait, because nothing can be started if it's already stopped. + return nil + } // Even if StopOnly has been previously called, make sure we wait for everything to shut down. // Otherwise, a StopOnly call followed by StopAndWait might return early without waiting. + // At this point started must be true (because it was true above and cannot go back to false), + // so GetWaitChannel won't return an error. waitChan, err := s.GetWaitChannel() if err != nil { return err diff --git a/util/stopwaiter/stopwaiter_test.go b/util/stopwaiter/stopwaiter_test.go index c561e1f43b..68e49ac2be 100644 --- a/util/stopwaiter/stopwaiter_test.go +++ b/util/stopwaiter/stopwaiter_test.go @@ -5,6 +5,7 @@ package stopwaiter import ( "context" + "sync/atomic" "testing" "time" @@ -73,3 +74,19 @@ func TestStopWaiterStopAndWaitMultipleTimes(t *testing.T) { sw.StopAndWait() sw.StopAndWait() } + +func TestStopWaiterStopOnlyThenStopAndWait(t *testing.T) { + t.Parallel() + sw := StopWaiter{} + sw.Start(context.Background(), &TestStruct{}) + var threadStopping atomic.Bool + sw.LaunchThread(func(context.Context) { + time.Sleep(time.Second) + threadStopping.Store(true) + }) + sw.StopOnly() + sw.StopAndWait() + if !threadStopping.Load() { + t.Error("StopAndWait returned before background thread stopped") + } +} From abee6b856cfc7da9cbf1829e1922bbd18c416c0d Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 3 Dec 2024 15:57:21 -0600 Subject: [PATCH 187/210] commentary from lee addressed, part 1 --- Dockerfile | 1 - arbnode/node.go | 9 ++++----- staker/challenge-cache/cache.go | 4 +--- validator/server_arb/execution_run.go | 3 +-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index f94c43eb7e..ba1f2feb3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,6 @@ COPY ./safe-smart-account ./safe-smart-account COPY ./solgen/gen.go ./solgen/ COPY ./fastcache ./fastcache COPY ./go-ethereum ./go-ethereum -COPY ./bold ./bold COPY --from=brotli-wasm-export / target/ COPY --from=contracts-builder workspace/contracts/build/contracts/src/precompiles/ contracts/build/contracts/src/precompiles/ COPY --from=contracts-builder workspace/contracts/node_modules/@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json contracts/ diff --git a/arbnode/node.go b/arbnode/node.go index 33967409d3..453df81ad2 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -91,7 +91,7 @@ type Config struct { BlockValidator staker.BlockValidatorConfig `koanf:"block-validator" reload:"hot"` Feed broadcastclient.FeedConfig `koanf:"feed" reload:"hot"` Staker legacystaker.L1ValidatorConfig `koanf:"staker" reload:"hot"` - BOLD boldstaker.BoldConfig `koanf:"bold"` + Bold boldstaker.BoldConfig `koanf:"bold"` SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"` DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"` SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"` @@ -177,7 +177,7 @@ var ConfigDefault = Config{ BlockValidator: staker.DefaultBlockValidatorConfig, Feed: broadcastclient.FeedConfigDefault, Staker: legacystaker.DefaultL1ValidatorConfig, - BOLD: boldstaker.DefaultBoldConfig, + Bold: boldstaker.DefaultBoldConfig, SeqCoordinator: DefaultSeqCoordinatorConfig, DataAvailability: das.DefaultDataAvailabilityConfig, SyncMonitor: DefaultSyncMonitorConfig, @@ -693,7 +693,7 @@ func createNodeImpl( confirmedNotifiers = append(confirmedNotifiers, messagePruner) } - stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().BOLD, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) + stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) if err != nil { return nil, err } @@ -906,8 +906,7 @@ func (n *Node) Start(ctx context.Context) error { n.MessagePruner.Start(ctx) } if n.Staker != nil { - err = n.Staker. - Initialize(ctx) + err = n.Staker.Initialize(ctx) if err != nil { return fmt.Errorf("error initializing staker: %w", err) } diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index 44c9a002cf..0af1131dc1 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -80,9 +80,7 @@ type Cache struct { // New cache from a base directory path. func New(baseDir string) (*Cache, error) { if _, err := os.Stat(baseDir); err != nil { - if err := os.MkdirAll(baseDir, os.ModePerm); err != nil { - return nil, fmt.Errorf("could not make initialize challenge cache directory %s: %w", baseDir, err) - } + os.MkdirAll(baseDir, os.ModePerm) } // We create a temp directory to write our hashes to first when putting to the cache. // Once writing succeeds, we rename in an atomic operation to the correct file name diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index 1ee527af50..66d8e158d0 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -105,8 +105,7 @@ func (e *executionRun) machineHashesWithStepSize( if err != nil { return nil, err } - log.Info(fmt.Sprintf("Advanced machine to index %d, beginning hash computation", machineStartIndex)) - fmt.Printf("got machine type %T\n", machine) + log.Info("Advanced WASM machine index, beginning challenge hash computation", "machineStartIndex", machineStartIndex) machineHashes := []common.Hash{machine.Hash()} startHash := machineHashes[0] From cdf48cfc447f4ce8f47e1e2185de341242fe5198 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 3 Dec 2024 16:09:41 -0600 Subject: [PATCH 188/210] address more review comments --- cmd/chaininfo/arbitrum_chain_info.json | 2 ++ .../multi_protocol/multi_protocol_staker.go | 20 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cmd/chaininfo/arbitrum_chain_info.json b/cmd/chaininfo/arbitrum_chain_info.json index f862c6dfbf..18032877e9 100644 --- a/cmd/chaininfo/arbitrum_chain_info.json +++ b/cmd/chaininfo/arbitrum_chain_info.json @@ -44,6 +44,7 @@ "sequencer-inbox": "0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6", "validator-utils": "0x9e40625f52829cf04bc4839f186d621ee33b0e67", "validator-wallet-creator": "0x960953f7c69cd2bc2322db9223a815c680ccc7ea", + "stake-token": "0x0000000000000000000000000000000000000000", "deployed-at": 15411056 } }, @@ -90,6 +91,7 @@ "sequencer-inbox": "0x211e1c4c7f1bf5351ac850ed10fd68cffcf6c21b", "validator-utils": "0x2B081fbaB646D9013f2699BebEf62B7e7d7F0976", "validator-wallet-creator": "0xe05465Aab36ba1277dAE36aa27a7B74830e74DE4", + "stake-token": "0x0000000000000000000000000000000000000000", "deployed-at": 15016829 } }, diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index 8dd5318cab..b3d1f432a9 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -109,11 +109,9 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { if boldActive { log.Info("BoLD protocol is active, initializing BoLD staker") log.Info(boldArt) - boldStaker, err := m.setupBoldStaker(ctx, rollupAddress) - if err != nil { + if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { return err } - m.boldStaker = boldStaker m.oldStaker = nil return m.boldStaker.Initialize(ctx) } @@ -127,7 +125,6 @@ func (m *MultiProtocolStaker) Start(ctxIn context.Context) { if m.boldStaker != nil { log.Info("Starting BOLD staker") m.boldStaker.Start(ctxIn) - m.StopOnly() } else { log.Info("Starting pre-BOLD staker") m.oldStaker.Start(ctxIn) @@ -190,11 +187,9 @@ func (m *MultiProtocolStaker) checkAndSwitchToBoldStaker(ctx context.Context) (b if !shouldSwitch { return false, nil } - boldStaker, err := m.setupBoldStaker(ctx, rollupAddress) - if err != nil { + if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { return false, err } - m.boldStaker = boldStaker if err = m.boldStaker.Initialize(ctx); err != nil { return false, err } @@ -211,15 +206,15 @@ func (m *MultiProtocolStaker) getCallOpts(ctx context.Context) *bind.CallOpts { func (m *MultiProtocolStaker) setupBoldStaker( ctx context.Context, rollupAddress common.Address, -) (*boldstaker.BOLDStaker, error) { +) error { txBuilder, err := txbuilder.NewBuilder(m.wallet, m.legacyConfig().GasRefunder()) if err != nil { - return nil, err + return err } boldStaker, err := boldstaker.NewBOLDStaker( ctx, rollupAddress, - *m.getCallOpts(ctx), + m.callOpts, txBuilder.SingleTxAuth(), m.l1Reader, m.blockValidator, @@ -231,7 +226,8 @@ func (m *MultiProtocolStaker) setupBoldStaker( m.confirmedNotifiers, ) if err != nil { - return nil, err + return err } - return boldStaker, nil + m.boldStaker = boldStaker + return nil } From c874ed50a4351e1894ef971131cbc3b8e3ed1383 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 3 Dec 2024 16:19:14 -0600 Subject: [PATCH 189/210] check stake token addr --- staker/multi_protocol/multi_protocol_staker.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index b3d1f432a9..9af71e247a 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -2,6 +2,7 @@ package multiprotocolstaker import ( "context" + "fmt" "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -44,6 +45,7 @@ type MultiProtocolStaker struct { blockValidator *staker.BlockValidator callOpts bind.CallOpts boldConfig *boldstaker.BoldConfig + stakeTokenAddress common.Address } func NewMultiProtocolStaker( @@ -55,6 +57,7 @@ func NewMultiProtocolStaker( blockValidator *staker.BlockValidator, statelessBlockValidator *staker.StatelessBlockValidator, stakedNotifiers []legacystaker.LatestStakedNotifier, + stakeTokenAddress common.Address, confirmedNotifiers []legacystaker.LatestConfirmedNotifier, validatorUtilsAddress common.Address, bridgeAddress common.Address, @@ -98,6 +101,7 @@ func NewMultiProtocolStaker( blockValidator: blockValidator, callOpts: callOpts, boldConfig: boldConfig, + stakeTokenAddress: stakeTokenAddress, }, nil } @@ -107,6 +111,13 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { return err } if boldActive { + stakeTokenContract, err := m.l1Reader.Client().CodeAt(ctx, m.stakeTokenAddress, nil) + if err != nil { + return err + } + if len(stakeTokenContract) == 0 { + return fmt.Errorf("stake token address for BoLD %v does not point to a contract", m.stakeTokenAddress) + } log.Info("BoLD protocol is active, initializing BoLD staker") log.Info(boldArt) if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { From 6cd3aec297533439057e088bae8c41a2daa7521b Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 3 Dec 2024 16:34:59 -0600 Subject: [PATCH 190/210] move to test only file --- arbnode/node.go | 2 +- system_tests/bold_challenge_protocol_test.go | 145 +++++++++++++++++- system_tests/overflow_assertions_test.go | 3 +- validator/server_arb/boldmach/machine.go | 151 ------------------- 4 files changed, 145 insertions(+), 156 deletions(-) delete mode 100644 validator/server_arb/boldmach/machine.go diff --git a/arbnode/node.go b/arbnode/node.go index 453df81ad2..c20722826b 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -693,7 +693,7 @@ func createNodeImpl( confirmedNotifiers = append(confirmedNotifiers, messagePruner) } - stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) + stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) if err != nil { return nil, err } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 134d1daeb9..62d4c754ec 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -56,8 +56,8 @@ import ( "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_arb" - "github.com/offchainlabs/nitro/validator/server_arb/boldmach" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" ) @@ -154,7 +154,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp valCfg.UseJit = false boldWrapperOpt := server_arb.WithWrapper( func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return boldmach.MachineWrapper(inner) + return machineWrapper(inner) }) _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) blockValidatorConfig := staker.TestBlockValidatorConfig @@ -863,6 +863,147 @@ func create2ndNodeWithConfigForBoldProtocol( return l2client, l2node, assertionChain } +// boldMachine wraps a server_arb.MachineInterface. +type boldMachine struct { + inner server_arb.MachineInterface + zeroMachine *server_arb.ArbitratorMachine + hasStepped bool +} + +// Ensure boldMachine implements server_arb.MachineInterface. +var _ server_arb.MachineInterface = (*boldMachine)(nil) + +func newBoldMachine(inner server_arb.MachineInterface) *boldMachine { + z := server_arb.NewFinishedMachine(inner.GetGlobalState()) + return &boldMachine{ + inner: inner, + zeroMachine: z, + hasStepped: false, + } +} + +// Wraps a server_arb.MachineInterface and adds one step to the +// front of the machine's execution. +// +// This zeroth step should be at the same global state as the inner arbitrator +// machine has at step 0, but the machine is in the Finished state rather than +// the Running state. +func machineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { + return newBoldMachine(inner) +} + +// CloneMachineInterface returns a new boldMachine with the same inner machine. +func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { + bMach := newBoldMachine(m.inner.CloneMachineInterface()) + bMach.hasStepped = m.hasStepped + return bMach +} + +// GetStepCount returns zero if the machine has not stepped, otherwise it +// returns the inner machine's step count plus one. +func (m *boldMachine) GetStepCount() uint64 { + if !m.hasStepped { + return 0 + } + return m.inner.GetStepCount() + 1 +} + +// Hash returns the hash of the inner machine if the machine has not stepped, +// otherwise it returns the hash of the zeroth step machine. +func (m *boldMachine) Hash() common.Hash { + if !m.hasStepped { + return m.zeroMachine.Hash() + } + return m.inner.Hash() +} + +// Destroy destroys the inner machine and the zeroth step machine. +func (m *boldMachine) Destroy() { + m.inner.Destroy() + if !m.hasStepped { + m.zeroMachine.Destroy() + } +} + +// Freeze freezes the inner machine and the zeroth step machine. +func (m *boldMachine) Freeze() { + m.inner.Freeze() + if !m.hasStepped { + m.zeroMachine.Freeze() + } +} + +// Status returns the status of the inner machine if the machine has not +// stepped, otherwise it returns the status of the zeroth step machine. +func (m *boldMachine) Status() uint8 { + if !m.hasStepped { + return m.zeroMachine.Status() + } + return m.inner.Status() +} + +// IsRunning returns true if the machine has not stepped, otherwise it +// returns the running state of the inner machine. +func (m *boldMachine) IsRunning() bool { + if !m.hasStepped { + return true + } + return m.inner.IsRunning() +} + +// IsErrored returns the errored state of the inner machine, or false if the +// machine has not stepped. +func (m *boldMachine) IsErrored() bool { + if !m.hasStepped { + return false + } + return m.inner.IsErrored() +} + +// Step steps the inner machine if the machine has not stepped, otherwise it +// steps the zeroth step machine. +func (m *boldMachine) Step(ctx context.Context, steps uint64) error { + if !m.hasStepped { + if steps == 0 { + // Zero is okay, but doesn't advance the machine. + return nil + } + m.hasStepped = true + m.zeroMachine.Destroy() + // Only the first step or set of steps needs to be adjusted. + steps = steps - 1 + } + return m.inner.Step(ctx, steps) +} + +// ValidForStep returns true for step 0 if and only if the machine has not stepped yet, +// and the inner machine's ValidForStep for the step minus one otherwise. +func (m *boldMachine) ValidForStep(step uint64) bool { + if step == 0 { + return !m.hasStepped + } + return m.inner.ValidForStep(step - 1) +} + +// GetGlobalState returns the global state of the inner machine if the machine +// has stepped, otherwise it returns the global state of the zeroth step. +func (m *boldMachine) GetGlobalState() validator.GoGlobalState { + if !m.hasStepped { + return m.zeroMachine.GetGlobalState() + } + return m.inner.GetGlobalState() +} + +// ProveNextStep returns the proof of the next step of the inner machine if the +// machine has stepped, otherwise it returns the proof that the zeroth step +// results in the inner machine's initial global state. +func (m *boldMachine) ProveNextStep() []byte { + if !m.hasStepped { + return m.zeroMachine.ProveNextStep() + } + return m.inner.ProveNextStep() +} + func makeBoldBatch( t *testing.T, l2Node *arbnode.Node, diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index c1e0ea36d8..5b024ca122 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -35,7 +35,6 @@ import ( "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/validator/server_arb" - "github.com/offchainlabs/nitro/validator/server_arb/boldmach" "github.com/offchainlabs/nitro/validator/valnode" ) @@ -90,7 +89,7 @@ func TestOverflowAssertions(t *testing.T) { valCfg.UseJit = false boldWrapperOpt := server_arb.WithWrapper( func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return boldmach.MachineWrapper(inner) + return machineWrapper(inner) }) _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) blockValidatorConfig := staker.TestBlockValidatorConfig diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go deleted file mode 100644 index 914c7b21d7..0000000000 --- a/validator/server_arb/boldmach/machine.go +++ /dev/null @@ -1,151 +0,0 @@ -package boldmach - -import ( - "context" - - "github.com/ethereum/go-ethereum/common" - - "github.com/offchainlabs/nitro/validator" - "github.com/offchainlabs/nitro/validator/server_arb" -) - -// boldMachine wraps a server_arb.MachineInterface. -type boldMachine struct { - inner server_arb.MachineInterface - zeroMachine *server_arb.ArbitratorMachine - hasStepped bool -} - -// Ensure boldMachine implements server_arb.MachineInterface. -var _ server_arb.MachineInterface = (*boldMachine)(nil) - -func newBoldMachine(inner server_arb.MachineInterface) *boldMachine { - z := server_arb.NewFinishedMachine(inner.GetGlobalState()) - return &boldMachine{ - inner: inner, - zeroMachine: z, - hasStepped: false, - } -} - -// MachineWrapper wraps a server_arb.MachineInterface and adds one step to the -// front of the machine's execution. -// -// This zeroth step should be at the same global state as the inner arbitrator -// machine has at step 0, but the machine is in the Finished state rather than -// the Running state. -func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { - return newBoldMachine(inner) -} - -// CloneMachineInterface returns a new boldMachine with the same inner machine. -func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { - bMach := newBoldMachine(m.inner.CloneMachineInterface()) - bMach.hasStepped = m.hasStepped - return bMach -} - -// GetStepCount returns zero if the machine has not stepped, otherwise it -// returns the inner machine's step count plus one. -func (m *boldMachine) GetStepCount() uint64 { - if !m.hasStepped { - return 0 - } - return m.inner.GetStepCount() + 1 -} - -// Hash returns the hash of the inner machine if the machine has not stepped, -// otherwise it returns the hash of the zeroth step machine. -func (m *boldMachine) Hash() common.Hash { - if !m.hasStepped { - return m.zeroMachine.Hash() - } - return m.inner.Hash() -} - -// Destroy destroys the inner machine and the zeroth step machine. -func (m *boldMachine) Destroy() { - m.inner.Destroy() - if !m.hasStepped { - m.zeroMachine.Destroy() - } -} - -// Freeze freezes the inner machine and the zeroth step machine. -func (m *boldMachine) Freeze() { - m.inner.Freeze() - if !m.hasStepped { - m.zeroMachine.Freeze() - } -} - -// Status returns the status of the inner machine if the machine has not -// stepped, otherwise it returns the status of the zeroth step machine. -func (m *boldMachine) Status() uint8 { - if !m.hasStepped { - return m.zeroMachine.Status() - } - return m.inner.Status() -} - -// IsRunning returns true if the machine has not stepped, otherwise it -// returns the running state of the inner machine. -func (m *boldMachine) IsRunning() bool { - if !m.hasStepped { - return true - } - return m.inner.IsRunning() -} - -// IsErrored returns the errored state of the inner machine, or false if the -// machine has not stepped. -func (m *boldMachine) IsErrored() bool { - if !m.hasStepped { - return false - } - return m.inner.IsErrored() -} - -// Step steps the inner machine if the machine has not stepped, otherwise it -// steps the zeroth step machine. -func (m *boldMachine) Step(ctx context.Context, steps uint64) error { - if !m.hasStepped { - if steps == 0 { - // Zero is okay, but doesn't advance the machine. - return nil - } - m.hasStepped = true - m.zeroMachine.Destroy() - // Only the first step or set of steps needs to be adjusted. - steps = steps - 1 - } - return m.inner.Step(ctx, steps) -} - -// ValidForStep returns true for step 0 if and only if the machine has not stepped yet, -// and the inner machine's ValidForStep for the step minus one otherwise. -func (m *boldMachine) ValidForStep(step uint64) bool { - if step == 0 { - return !m.hasStepped - } - return m.inner.ValidForStep(step - 1) -} - -// GetGlobalState returns the global state of the inner machine if the machine -// has stepped, otherwise it returns the global state of the zeroth step. -func (m *boldMachine) GetGlobalState() validator.GoGlobalState { - if !m.hasStepped { - return m.zeroMachine.GetGlobalState() - } - return m.inner.GetGlobalState() -} - -// ProveNextStep returns the proof of the next step of the inner machine if the -// machine has stepped, otherwise it returns the proof that the zeroth step -// results in the inner machine's initial global state. -func (m *boldMachine) ProveNextStep() []byte { - if !m.hasStepped { - return m.zeroMachine.ProveNextStep() - } - return m.inner.ProveNextStep() -} From 7b43136771b10248b2a388229a20f9ed6ed1cf10 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 3 Dec 2024 16:43:58 -0600 Subject: [PATCH 191/210] lee feedback on testonly machine wrapper --- system_tests/bold_challenge_protocol_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 62d4c754ec..90b62ac7e1 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -920,17 +920,13 @@ func (m *boldMachine) Hash() common.Hash { // Destroy destroys the inner machine and the zeroth step machine. func (m *boldMachine) Destroy() { m.inner.Destroy() - if !m.hasStepped { - m.zeroMachine.Destroy() - } + m.zeroMachine.Destroy() } // Freeze freezes the inner machine and the zeroth step machine. func (m *boldMachine) Freeze() { m.inner.Freeze() - if !m.hasStepped { - m.zeroMachine.Freeze() - } + m.zeroMachine.Freeze() } // Status returns the status of the inner machine if the machine has not @@ -969,7 +965,6 @@ func (m *boldMachine) Step(ctx context.Context, steps uint64) error { return nil } m.hasStepped = true - m.zeroMachine.Destroy() // Only the first step or set of steps needs to be adjusted. steps = steps - 1 } From 17f0bbb25ab8074ad2520b8b98f3e390c60e9bae Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 4 Dec 2024 10:08:18 -0600 Subject: [PATCH 192/210] nolint --- staker/challenge-cache/cache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index 0af1131dc1..ebcc238243 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -80,6 +80,7 @@ type Cache struct { // New cache from a base directory path. func New(baseDir string) (*Cache, error) { if _, err := os.Stat(baseDir); err != nil { + //nolint:errcheck os.MkdirAll(baseDir, os.ModePerm) } // We create a temp directory to write our hashes to first when putting to the cache. From 14796b3f81daab30d15831279fad2a44562ee2ff Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 09:32:24 -0600 Subject: [PATCH 193/210] feedback --- cmd/chaininfo/arbitrum_chain_info.json | 4 +- staker/bold/bold_staker.go | 53 +++++++++++++++++--------- staker/bold/bold_state_provider.go | 11 ++++-- staker/challenge-cache/cache.go | 5 +-- 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/cmd/chaininfo/arbitrum_chain_info.json b/cmd/chaininfo/arbitrum_chain_info.json index 18032877e9..fcfbb6e26a 100644 --- a/cmd/chaininfo/arbitrum_chain_info.json +++ b/cmd/chaininfo/arbitrum_chain_info.json @@ -44,7 +44,7 @@ "sequencer-inbox": "0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6", "validator-utils": "0x9e40625f52829cf04bc4839f186d621ee33b0e67", "validator-wallet-creator": "0x960953f7c69cd2bc2322db9223a815c680ccc7ea", - "stake-token": "0x0000000000000000000000000000000000000000", + "stake-token": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "deployed-at": 15411056 } }, @@ -91,7 +91,7 @@ "sequencer-inbox": "0x211e1c4c7f1bf5351ac850ed10fd68cffcf6c21b", "validator-utils": "0x2B081fbaB646D9013f2699BebEf62B7e7d7F0976", "validator-wallet-creator": "0xe05465Aab36ba1277dAE36aa27a7B74830e74DE4", - "stake-token": "0x0000000000000000000000000000000000000000", + "stake-token": "0x765277eebeca2e31912c9946eae1021199b39c61", "deployed-at": 15016829 } }, diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 6d4d43d9f6..9a56bd5eea 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -22,6 +22,7 @@ import ( challengemanager "github.com/offchainlabs/bold/challenge-manager" boldtypes "github.com/offchainlabs/bold/challenge-manager/types" l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider" + "github.com/offchainlabs/bold/solgen/go/challengeV2gen" boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode/dataposter" @@ -50,12 +51,6 @@ func init() { type BoldConfig struct { Enable bool `koanf:"enable"` Mode string `koanf:"mode"` - // The height constants at each challenge level for the BOLD challenge manager. - BlockChallengeLeafHeight uint64 `koanf:"block-challenge-leaf-height"` - BigStepLeafHeight uint64 `koanf:"big-step-leaf-height"` - SmallStepLeafHeight uint64 `koanf:"small-step-leaf-height"` - // Number of big step challenges in the BOLD protocol. - NumBigSteps uint64 `koanf:"num-big-steps"` // How often to post assertions onchain. AssertionPostingInterval time.Duration `koanf:"assertion-posting-interval"` // How often to scan for newly created assertions onchain. @@ -89,10 +84,6 @@ var DefaultStateProviderConfig = StateProviderConfig{ var DefaultBoldConfig = BoldConfig{ Enable: false, Mode: "make-mode", - BlockChallengeLeafHeight: 1 << 26, - BigStepLeafHeight: 1 << 23, - SmallStepLeafHeight: 1 << 19, - NumBigSteps: 1, AssertionPostingInterval: time.Minute * 15, AssertionScanningInterval: time.Minute, AssertionConfirmingInterval: time.Minute, @@ -116,10 +107,6 @@ var BoldModes = map[string]boldtypes.Mode{ func BoldConfigAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".enable", DefaultBoldConfig.Enable, "enable bold challenge protocol") f.String(prefix+".mode", DefaultBoldConfig.Mode, "define the bold validator staker strategy") - f.Uint64(prefix+".block-challenge-leaf-height", DefaultBoldConfig.BlockChallengeLeafHeight, "block challenge leaf height") - f.Uint64(prefix+".big-step-leaf-height", DefaultBoldConfig.BigStepLeafHeight, "big challenge leaf height") - f.Uint64(prefix+".small-step-leaf-height", DefaultBoldConfig.SmallStepLeafHeight, "small challenge leaf height") - f.Uint64(prefix+".num-big-steps", DefaultBoldConfig.NumBigSteps, "num big steps") f.Duration(prefix+".assertion-posting-interval", DefaultBoldConfig.AssertionPostingInterval, "assertion posting interval") f.Duration(prefix+".assertion-scanning-interval", DefaultBoldConfig.AssertionScanningInterval, "scan assertion interval") f.Duration(prefix+".assertion-confirming-interval", DefaultBoldConfig.AssertionConfirmingInterval, "confirm assertion interval") @@ -367,13 +354,43 @@ func newBOLDChallengeManager( if err != nil { return nil, fmt.Errorf("could not get challenge manager: %w", err) } + chalManagerBindings, err := challengeV2gen.NewEdgeChallengeManager(chalManager, client) + if err != nil { + return nil, fmt.Errorf("could not create challenge manager bindings: %w", err) + } assertionChain, err := solimpl.NewAssertionChain(ctx, rollupAddress, chalManager, txOpts, client, NewDataPosterTransactor(dataPoster)) if err != nil { return nil, fmt.Errorf("could not create assertion chain: %w", err) } - blockChallengeLeafHeight := l2stateprovider.Height(config.BlockChallengeLeafHeight) - bigStepHeight := l2stateprovider.Height(config.BigStepLeafHeight) - smallStepHeight := l2stateprovider.Height(config.SmallStepLeafHeight) + + blockChallengeHeightBig, err := chalManagerBindings.LAYERZEROBLOCKEDGEHEIGHT(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get block challenge height: %w", err) + } + if !blockChallengeHeightBig.IsUint64() { + return nil, errors.New("block challenge height was not a uint64") + } + bigStepHeightBig, err := chalManagerBindings.LAYERZEROBIGSTEPEDGEHEIGHT(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get big step challenge height: %w", err) + } + if !bigStepHeightBig.IsUint64() { + return nil, errors.New("big step challenge height was not a uint64") + } + smallStepHeightBig, err := chalManagerBindings.LAYERZEROSMALLSTEPEDGEHEIGHT(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get small step challenge height: %w", err) + } + if !smallStepHeightBig.IsUint64() { + return nil, errors.New("small step challenge height was not a uint64") + } + numBigSteps, err := chalManagerBindings.NUMBIGSTEPLEVEL(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get number of big steps: %w", err) + } + blockChallengeLeafHeight := l2stateprovider.Height(blockChallengeHeightBig.Uint64()) + bigStepHeight := l2stateprovider.Height(bigStepHeightBig.Uint64()) + smallStepHeight := l2stateprovider.Height(smallStepHeightBig.Uint64()) // Sets up the state provider interface that BOLD will use to request data such as // execution states for assertions, history commitments for machine execution, and one step proofs. @@ -389,7 +406,7 @@ func newBOLDChallengeManager( return nil, fmt.Errorf("could not create state manager: %w", err) } providerHeights := []l2stateprovider.Height{blockChallengeLeafHeight} - for i := uint64(0); i < config.NumBigSteps; i++ { + for i := uint8(0); i < numBigSteps; i++ { providerHeights = append(providerHeights, bigStepHeight) } providerHeights = append(providerHeights, smallStepHeight) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 0459b72053..9fb9cba0b5 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -75,9 +75,6 @@ func NewBOLDStateProvider( // assertion. Returns the state at maxSeqInboxCount or blockChallengeLeafHeight // after the previous state, whichever is earlier. If previousGlobalState is // nil, defaults to returning the state at maxSeqInboxCount. -// -// TODO: Check the block validator has validated the execution state we are -// proposing. func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( ctx context.Context, maxSeqInboxCount uint64, @@ -507,6 +504,14 @@ func (s *BOLDStateProvider) CollectProof( if vs.IsSome() { m := server_arb.NewFinishedMachine(vs.Unwrap()) defer m.Destroy() + log.Info( + "Getting machine OSP from virtual state", + "fromBatch", assertionMetadata.FromState.Batch, + "fromPosInBatch", assertionMetadata.FromState.PosInBatch, + "blockChallengeHeight", blockChallengeHeight, + "messageNum", messageNum, + "machineIndex", machineIndex, + ) return m.ProveNextStep(), nil } entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum) diff --git a/staker/challenge-cache/cache.go b/staker/challenge-cache/cache.go index ebcc238243..98310c742a 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -79,9 +79,8 @@ type Cache struct { // New cache from a base directory path. func New(baseDir string) (*Cache, error) { - if _, err := os.Stat(baseDir); err != nil { - //nolint:errcheck - os.MkdirAll(baseDir, os.ModePerm) + if err := os.MkdirAll(baseDir, os.ModePerm); err != nil { + return nil, err } // We create a temp directory to write our hashes to first when putting to the cache. // Once writing succeeds, we rename in an atomic operation to the correct file name From 1d0c06fa795ae50efc6e13051ab1d0a489dc2034 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 09:38:20 -0600 Subject: [PATCH 194/210] more feedback from lee, contexts, no caching module root --- staker/bold/bold_staker.go | 31 ------------------------------ staker/bold/bold_state_provider.go | 9 +++------ 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 9a56bd5eea..41cb2463e7 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -179,9 +179,6 @@ func NewBOLDStaker( // Initialize Updates the block validator module root. // And updates the init state of the block validator if block validator has not started yet. func (b *BOLDStaker) Initialize(ctx context.Context) error { - if err := b.updateBlockValidatorModuleRoot(ctx); err != nil { - return err - } walletAddressOrZero := b.wallet.AddressOrZero() var stakerAddr common.Address if b.wallet.DataPoster() != nil { @@ -225,10 +222,6 @@ func (b *BOLDStaker) Start(ctxIn context.Context) { b.StopWaiter.Start(ctxIn, b) b.chalManager.Start(ctxIn) b.CallIteratively(func(ctx context.Context) time.Duration { - err := b.updateBlockValidatorModuleRoot(ctx) - if err != nil { - log.Warn("error updating latest wasm module root", "err", err) - } agreedMsgCount, agreedGlobalState, err := b.getLatestState(ctx, false) if err != nil { log.Error("staker: error checking latest agreed", "err", err) @@ -301,30 +294,6 @@ func (b *BOLDStaker) StopAndWait() { b.StopWaiter.StopAndWait() } -func (b *BOLDStaker) updateBlockValidatorModuleRoot(ctx context.Context) error { - if b.blockValidator == nil { - return nil - } - boldRollup, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client) - if err != nil { - return err - } - moduleRoot, err := boldRollup.WasmModuleRoot(b.getCallOpts(ctx)) - if err != nil { - return err - } - if moduleRoot != b.lastWasmModuleRoot { - err := b.blockValidator.SetCurrentWasmModuleRoot(moduleRoot) - if err != nil { - return err - } - b.lastWasmModuleRoot = moduleRoot - } else if (moduleRoot == common.Hash{}) { - return errors.New("wasmModuleRoot in rollup is zero") - } - return nil -} - func (b *BOLDStaker) getCallOpts(ctx context.Context) *bind.CallOpts { opts := b.callOpts opts.Context = ctx diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 9fb9cba0b5..2c8553e8aa 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -455,9 +455,6 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c // This is to ensure that we do not have the validator froze indefinitely if // the execution run is no longer alive. ctx, cancel := context.WithCancel(ctxIn) - // Create a context with cancel, so that we can cancel the check alive routine - // once the calling function returns. - ctxCheckAlive, cancelCheckAlive := context.WithCancel(ctxIn) go func() { // Call cancel so that the calling function is canceled if the check alive // routine fails/returns. @@ -466,12 +463,12 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c defer ticker.Stop() for { select { - case <-ctxCheckAlive.Done(): + case <-ctx.Done(): return case <-ticker.C: // Create a context with a timeout, so that the check alive routine does // not run indefinitely. - ctxCheckAliveWithTimeout, cancelCheckAliveWithTimeout := context.WithTimeout(ctxCheckAlive, 5*time.Second) + ctxCheckAliveWithTimeout, cancelCheckAliveWithTimeout := context.WithTimeout(ctx, 5*time.Second) err := execRun.CheckAlive(ctxCheckAliveWithTimeout) if err != nil { executionNodeOfflineGauge.Inc(1) @@ -482,7 +479,7 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c } } }() - return ctx, cancelCheckAlive + return ctx, cancel } // CollectProof collects a one-step proof at a message number and OpcodeIndex. From 027e2bdf1c771935c2917ea5f6e78f16709b06de Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 09:52:05 -0600 Subject: [PATCH 195/210] address remaining bold commentary --- bold | 2 +- staker/bold/bold_staker.go | 36 ++++++++++++------- staker/legacy/staker.go | 8 ++--- .../multi_protocol/multi_protocol_staker.go | 14 ++++---- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/bold b/bold index 3d5ae947ce..b7965e2b3c 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 3d5ae947ce248ad31b06b2799cbfaf2db585d2fd +Subproject commit b7965e2b3c4d00d6032d8a7683eebf4aa65ce6a2 diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 41cb2463e7..d341c5ccf9 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -49,8 +49,8 @@ func init() { } type BoldConfig struct { - Enable bool `koanf:"enable"` - Mode string `koanf:"mode"` + Enable bool `koanf:"enable"` + Strategy string `koanf:"strategy"` // How often to post assertions onchain. AssertionPostingInterval time.Duration `koanf:"assertion-posting-interval"` // How often to scan for newly created assertions onchain. @@ -65,6 +65,16 @@ type BoldConfig struct { CheckStakerSwitchInterval time.Duration `koanf:"check-staker-switch-interval"` StateProviderConfig StateProviderConfig `koanf:"state-provider-config"` StartValidationFromStaked bool `koanf:"start-validation-from-staked"` + strategy legacystaker.StakerStrategy +} + +func (c *BoldConfig) Validate() error { + strategy, err := legacystaker.ParseStrategy(c.Strategy) + if err != nil { + return err + } + c.strategy = strategy + return nil } type StateProviderConfig struct { @@ -83,7 +93,7 @@ var DefaultStateProviderConfig = StateProviderConfig{ var DefaultBoldConfig = BoldConfig{ Enable: false, - Mode: "make-mode", + Strategy: "Watchtower", AssertionPostingInterval: time.Minute * 15, AssertionScanningInterval: time.Minute, AssertionConfirmingInterval: time.Minute, @@ -97,16 +107,16 @@ var DefaultBoldConfig = BoldConfig{ StartValidationFromStaked: true, } -var BoldModes = map[string]boldtypes.Mode{ - "watchtower-mode": boldtypes.WatchTowerMode, - "resolve-mode": boldtypes.ResolveMode, - "defensive-mode": boldtypes.DefensiveMode, - "make-mode": boldtypes.MakeMode, +var BoldModes = map[legacystaker.StakerStrategy]boldtypes.Mode{ + legacystaker.WatchtowerStrategy: boldtypes.WatchTowerMode, + legacystaker.DefensiveStrategy: boldtypes.DefensiveMode, + legacystaker.ResolveNodesStrategy: boldtypes.ResolveMode, + legacystaker.MakeNodesStrategy: boldtypes.MakeMode, } func BoldConfigAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".enable", DefaultBoldConfig.Enable, "enable bold challenge protocol") - f.String(prefix+".mode", DefaultBoldConfig.Mode, "define the bold validator staker strategy") + f.String(prefix+".strategy", DefaultBoldConfig.Strategy, "define the bold validator staker strategy, either watchtower, defensive, stakeLatest, or makeNodes") f.Duration(prefix+".assertion-posting-interval", DefaultBoldConfig.AssertionPostingInterval, "assertion posting interval") f.Duration(prefix+".assertion-scanning-interval", DefaultBoldConfig.AssertionScanningInterval, "scan assertion interval") f.Duration(prefix+".assertion-confirming-interval", DefaultBoldConfig.AssertionConfirmingInterval, "confirm assertion interval") @@ -134,7 +144,6 @@ type BOLDStaker struct { statelessBlockValidator *staker.StatelessBlockValidator rollupAddress common.Address l1Reader *headerreader.HeaderReader - lastWasmModuleRoot common.Hash client protocol.ChainBackend callOpts bind.CallOpts wallet legacystaker.ValidatorWalletInterface @@ -156,6 +165,9 @@ func NewBOLDStaker( stakedNotifiers []legacystaker.LatestStakedNotifier, confirmedNotifiers []legacystaker.LatestConfirmedNotifier, ) (*BOLDStaker, error) { + if err := config.Validate(); err != nil { + return nil, err + } wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber) manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster) if err != nil { @@ -184,7 +196,7 @@ func (b *BOLDStaker) Initialize(ctx context.Context) error { if b.wallet.DataPoster() != nil { stakerAddr = b.wallet.DataPoster().Sender() } - log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "mode", b.config.Mode) + log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "strategy", b.config.Strategy) if b.blockValidator != nil && b.config.StartValidationFromStaked && !b.blockValidator.Started() { rollupUserLogic, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client) @@ -396,7 +408,7 @@ func newBOLDChallengeManager( stackOpts := []challengemanager.StackOpt{ challengemanager.StackWithName(config.StateProviderConfig.ValidatorName), - challengemanager.StackWithMode(BoldModes[config.Mode]), + challengemanager.StackWithMode(BoldModes[config.strategy]), challengemanager.StackWithPollingInterval(scanningInterval), challengemanager.StackWithPostingInterval(postingInterval), challengemanager.StackWithConfirmationInterval(confirmingInterval), diff --git a/staker/legacy/staker.go b/staker/legacy/staker.go index 87f891b9ac..fa74be327f 100644 --- a/staker/legacy/staker.go +++ b/staker/legacy/staker.go @@ -101,8 +101,8 @@ type L1ValidatorConfig struct { gasRefunder common.Address } -func (c *L1ValidatorConfig) ParseStrategy() (StakerStrategy, error) { - switch strings.ToLower(c.Strategy) { +func ParseStrategy(strategy string) (StakerStrategy, error) { + switch strings.ToLower(strategy) { case "watchtower": return WatchtowerStrategy, nil case "defensive": @@ -114,7 +114,7 @@ func (c *L1ValidatorConfig) ParseStrategy() (StakerStrategy, error) { case "makenodes": return MakeNodesStrategy, nil default: - return WatchtowerStrategy, fmt.Errorf("unknown staker strategy \"%v\"", c.Strategy) + return WatchtowerStrategy, fmt.Errorf("unknown staker strategy \"%v\"", strategy) } } @@ -132,7 +132,7 @@ func (c *L1ValidatorConfig) ValidatorRequired() bool { } func (c *L1ValidatorConfig) Validate() error { - strategy, err := c.ParseStrategy() + strategy, err := ParseStrategy(c.Strategy) if err != nil { return err } diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index 9af71e247a..e08352f37d 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -111,13 +111,6 @@ func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { return err } if boldActive { - stakeTokenContract, err := m.l1Reader.Client().CodeAt(ctx, m.stakeTokenAddress, nil) - if err != nil { - return err - } - if len(stakeTokenContract) == 0 { - return fmt.Errorf("stake token address for BoLD %v does not point to a contract", m.stakeTokenAddress) - } log.Info("BoLD protocol is active, initializing BoLD staker") log.Info(boldArt) if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { @@ -218,6 +211,13 @@ func (m *MultiProtocolStaker) setupBoldStaker( ctx context.Context, rollupAddress common.Address, ) error { + stakeTokenContract, err := m.l1Reader.Client().CodeAt(ctx, m.stakeTokenAddress, nil) + if err != nil { + return err + } + if len(stakeTokenContract) == 0 { + return fmt.Errorf("stake token address for BoLD %v does not point to a contract", m.stakeTokenAddress) + } txBuilder, err := txbuilder.NewBuilder(m.wallet, m.legacyConfig().GasRefunder()) if err != nil { return err From 6365875bd758f2db2b8fbd643b58a0cb5ad07ab0 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 10:13:54 -0600 Subject: [PATCH 196/210] add back --- cmd/nitro/nitro.go | 2 +- validator/server_arb/boldmach/machine.go | 145 +++++++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 validator/server_arb/boldmach/machine.go diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 71457a86e2..c0362ba050 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -290,7 +290,7 @@ func mainImpl() int { flag.Usage() log.Crit("validator must have the parent chain reader enabled") } - strategy, err := nodeConfig.Node.Staker.ParseStrategy() + strategy, err := legacystaker.ParseStrategy(nodeConfig.Node.Staker.Strategy) if err != nil { log.Crit("couldn't parse staker strategy", "err", err) } diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/boldmach/machine.go new file mode 100644 index 0000000000..978e5c8a40 --- /dev/null +++ b/validator/server_arb/boldmach/machine.go @@ -0,0 +1,145 @@ +package boldmach + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_arb" +) + +// boldMachine wraps a server_arb.MachineInterface. +type BoldMachine struct { + inner server_arb.MachineInterface + zeroMachine *server_arb.ArbitratorMachine + hasStepped bool +} + +// Ensure boldMachine implements server_arb.MachineInterface. +var _ server_arb.MachineInterface = (*BoldMachine)(nil) + +func newBoldMachine(inner server_arb.MachineInterface) *BoldMachine { + z := server_arb.NewFinishedMachine(inner.GetGlobalState()) + return &BoldMachine{ + inner: inner, + zeroMachine: z, + hasStepped: false, + } +} + +// Wraps a server_arb.MachineInterface and adds one step to the +// front of the machine's execution. +// +// This zeroth step should be at the same global state as the inner arbitrator +// machine has at step 0, but the machine is in the Finished state rather than +// the Running state. +func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { + return newBoldMachine(inner) +} + +// CloneMachineInterface returns a new boldMachine with the same inner machine. +func (m *BoldMachine) CloneMachineInterface() server_arb.MachineInterface { + bMach := newBoldMachine(m.inner.CloneMachineInterface()) + bMach.hasStepped = m.hasStepped + return bMach +} + +// GetStepCount returns zero if the machine has not stepped, otherwise it +// returns the inner machine's step count plus one. +func (m *BoldMachine) GetStepCount() uint64 { + if !m.hasStepped { + return 0 + } + return m.inner.GetStepCount() + 1 +} + +// Hash returns the hash of the inner machine if the machine has not stepped, +// otherwise it returns the hash of the zeroth step machine. +func (m *BoldMachine) Hash() common.Hash { + if !m.hasStepped { + return m.zeroMachine.Hash() + } + return m.inner.Hash() +} + +// Destroy destroys the inner machine and the zeroth step machine. +func (m *BoldMachine) Destroy() { + m.inner.Destroy() + m.zeroMachine.Destroy() +} + +// Freeze freezes the inner machine and the zeroth step machine. +func (m *BoldMachine) Freeze() { + m.inner.Freeze() + m.zeroMachine.Freeze() +} + +// Status returns the status of the inner machine if the machine has not +// stepped, otherwise it returns the status of the zeroth step machine. +func (m *BoldMachine) Status() uint8 { + if !m.hasStepped { + return m.zeroMachine.Status() + } + return m.inner.Status() +} + +// IsRunning returns true if the machine has not stepped, otherwise it +// returns the running state of the inner machine. +func (m *BoldMachine) IsRunning() bool { + if !m.hasStepped { + return true + } + return m.inner.IsRunning() +} + +// IsErrored returns the errored state of the inner machine, or false if the +// machine has not stepped. +func (m *BoldMachine) IsErrored() bool { + if !m.hasStepped { + return false + } + return m.inner.IsErrored() +} + +// Step steps the inner machine if the machine has not stepped, otherwise it +// steps the zeroth step machine. +func (m *BoldMachine) Step(ctx context.Context, steps uint64) error { + if !m.hasStepped { + if steps == 0 { + // Zero is okay, but doesn't advance the machine. + return nil + } + m.hasStepped = true + // Only the first step or set of steps needs to be adjusted. + steps = steps - 1 + } + return m.inner.Step(ctx, steps) +} + +// ValidForStep returns true for step 0 if and only if the machine has not stepped yet, +// and the inner machine's ValidForStep for the step minus one otherwise. +func (m *BoldMachine) ValidForStep(step uint64) bool { + if step == 0 { + return !m.hasStepped + } + return m.inner.ValidForStep(step - 1) +} + +// GetGlobalState returns the global state of the inner machine if the machine +// has stepped, otherwise it returns the global state of the zeroth step. +func (m *BoldMachine) GetGlobalState() validator.GoGlobalState { + if !m.hasStepped { + return m.zeroMachine.GetGlobalState() + } + return m.inner.GetGlobalState() +} + +// ProveNextStep returns the proof of the next step of the inner machine if the +// machine has stepped, otherwise it returns the proof that the zeroth step +// results in the inner machine's initial global state. +func (m *BoldMachine) ProveNextStep() []byte { + if !m.hasStepped { + return m.zeroMachine.ProveNextStep() + } + return m.inner.ProveNextStep() +} From bd2adaeab3250c72e587bcb510a95c5acc8f2b36 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 10:23:07 -0600 Subject: [PATCH 197/210] add back block validator set module root --- nitro.log | 8 ++++++++ staker/bold/bold_staker.go | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 nitro.log diff --git a/nitro.log b/nitro.log new file mode 100644 index 0000000000..623eda8b1f --- /dev/null +++ b/nitro.log @@ -0,0 +1,8 @@ +INFO [12-05|10:17:07.961] Running Arbitrum nitro validation node revision=6365875 vcs.time=2024-12-05T16:13:54Z +INFO [12-05|10:17:07.962] Starting peer-to-peer node instance=nitro-val/v6365875/darwin-arm64/go1.23.3 +WARN [12-05|10:17:07.965] P2P server will be useless, neither dialing nor listening +INFO [12-05|10:17:07.967] Loaded JWT secret file path=/Users/zypherpunk/Desktop/boldtestnetv2/jwt.hex crc32=0x565f8791 +INFO [12-05|10:17:07.968] New local node record seq=1,733,415,427,967 id=0a039aac49a7190b ip=127.0.0.1 udp=0 tcp=0 +INFO [12-05|10:17:07.971] Started P2P networking self=enode://12e6d1888c85b3918ffec635eb9e6264e8471d579d4d48b04670279792c75368a944f324ec10579fcf3aa78e7f5e5daeac2d011951e53faa3984967c81b65d10@127.0.0.1:0 +INFO [12-05|10:17:07.971] WebSocket enabled url=ws://127.0.0.1:8549 +INFO [12-05|10:17:07.971] HTTP server started endpoint=127.0.0.1:8549 auth=true prefix= cors=localhost vhosts= diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index d341c5ccf9..c1a9af2bea 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -191,6 +191,10 @@ func NewBOLDStaker( // Initialize Updates the block validator module root. // And updates the init state of the block validator if block validator has not started yet. func (b *BOLDStaker) Initialize(ctx context.Context) error { + err := b.updateBlockValidatorModuleRoot(ctx) + if err != nil { + log.Warn("error updating latest wasm module root", "err", err) + } walletAddressOrZero := b.wallet.AddressOrZero() var stakerAddr common.Address if b.wallet.DataPoster() != nil { @@ -234,6 +238,10 @@ func (b *BOLDStaker) Start(ctxIn context.Context) { b.StopWaiter.Start(ctxIn, b) b.chalManager.Start(ctxIn) b.CallIteratively(func(ctx context.Context) time.Duration { + err := b.updateBlockValidatorModuleRoot(ctx) + if err != nil { + log.Warn("error updating latest wasm module root", "err", err) + } agreedMsgCount, agreedGlobalState, err := b.getLatestState(ctx, false) if err != nil { log.Error("staker: error checking latest agreed", "err", err) @@ -306,6 +314,21 @@ func (b *BOLDStaker) StopAndWait() { b.StopWaiter.StopAndWait() } +func (b *BOLDStaker) updateBlockValidatorModuleRoot(ctx context.Context) error { + if b.blockValidator == nil { + return nil + } + boldRollup, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client) + if err != nil { + return err + } + moduleRoot, err := boldRollup.WasmModuleRoot(b.getCallOpts(ctx)) + if err != nil { + return err + } + return b.blockValidator.SetCurrentWasmModuleRoot(moduleRoot) +} + func (b *BOLDStaker) getCallOpts(ctx context.Context) *bind.CallOpts { opts := b.callOpts opts.Context = ctx From ec0a917f68cc6193ef73eb7a8600e21b34ce32c6 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 10:23:13 -0600 Subject: [PATCH 198/210] rm log --- nitro.log | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 nitro.log diff --git a/nitro.log b/nitro.log deleted file mode 100644 index 623eda8b1f..0000000000 --- a/nitro.log +++ /dev/null @@ -1,8 +0,0 @@ -INFO [12-05|10:17:07.961] Running Arbitrum nitro validation node revision=6365875 vcs.time=2024-12-05T16:13:54Z -INFO [12-05|10:17:07.962] Starting peer-to-peer node instance=nitro-val/v6365875/darwin-arm64/go1.23.3 -WARN [12-05|10:17:07.965] P2P server will be useless, neither dialing nor listening -INFO [12-05|10:17:07.967] Loaded JWT secret file path=/Users/zypherpunk/Desktop/boldtestnetv2/jwt.hex crc32=0x565f8791 -INFO [12-05|10:17:07.968] New local node record seq=1,733,415,427,967 id=0a039aac49a7190b ip=127.0.0.1 udp=0 tcp=0 -INFO [12-05|10:17:07.971] Started P2P networking self=enode://12e6d1888c85b3918ffec635eb9e6264e8471d579d4d48b04670279792c75368a944f324ec10579fcf3aa78e7f5e5daeac2d011951e53faa3984967c81b65d10@127.0.0.1:0 -INFO [12-05|10:17:07.971] WebSocket enabled url=ws://127.0.0.1:8549 -INFO [12-05|10:17:07.971] HTTP server started endpoint=127.0.0.1:8549 auth=true prefix= cors=localhost vhosts= From 828ebf4b5b16dff039345169dd00e1bf39747137 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 11:05:42 -0600 Subject: [PATCH 199/210] assertion hash topic and path defaults --- staker/bold/bold_staker.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index c1a9af2bea..be3cb15572 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -7,6 +7,8 @@ import ( "errors" "fmt" "math/big" + "os" + "path/filepath" "time" flag "github.com/spf13/pflag" @@ -27,6 +29,7 @@ import ( "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" + "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/staker" legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/util/headerreader" @@ -35,6 +38,7 @@ import ( ) var assertionCreatedId common.Hash +var homeDir string func init() { rollupAbi, err := boldrollup.RollupCoreMetaData.GetAbi() @@ -46,6 +50,11 @@ func init() { panic("RollupCore ABI missing AssertionCreated event") } assertionCreatedId = assertionCreatedEvent.ID + homeDirPath, err := os.UserHomeDir() + if err != nil { + panic(err) + } + homeDir = homeDirPath } type BoldConfig struct { @@ -88,7 +97,7 @@ type StateProviderConfig struct { var DefaultStateProviderConfig = StateProviderConfig{ ValidatorName: "default-validator", CheckBatchFinality: true, - MachineLeavesCachePath: "/tmp/machine-leaves-cache", + MachineLeavesCachePath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "machine-hashes-cache"), } var DefaultBoldConfig = BoldConfig{ @@ -100,7 +109,7 @@ var DefaultBoldConfig = BoldConfig{ API: false, APIHost: "127.0.0.1", APIPort: 9393, - APIDBPath: "/tmp/bold-api-db", + APIDBPath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "bold-api-db"), TrackChallengeParentAssertionHashes: []string{}, CheckStakerSwitchInterval: time.Minute, // Every minute, check if the Nitro node staker should switch to using BOLD. StateProviderConfig: DefaultStateProviderConfig, @@ -474,7 +483,6 @@ func readBoldAssertionCreationInfo( return nil, errors.New("rollup deployment block was not a uint64") } creationBlock = rollupDeploymentBlock.Uint64() - topics = [][]common.Hash{{assertionCreatedId}} } else { var b [32]byte copy(b[:], assertionHash[:]) @@ -483,8 +491,8 @@ func readBoldAssertionCreationInfo( return nil, err } creationBlock = node.CreatedAtBlock - topics = [][]common.Hash{{assertionCreatedId}, {assertionHash}} } + topics = [][]common.Hash{{assertionCreatedId}, {assertionHash}} var query = ethereum.FilterQuery{ FromBlock: new(big.Int).SetUint64(creationBlock), ToBlock: new(big.Int).SetUint64(creationBlock), From 25a0f89ce4f2075091703caf997665f3499e374c Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 11:33:22 -0600 Subject: [PATCH 200/210] builds --- staker/bold/bold_state_provider.go | 6 +- staker/legacy/challenge_manager.go | 3 +- system_tests/bold_challenge_protocol_test.go | 139 +----------------- system_tests/validation_mock_test.go | 10 +- validator/client/validation_client.go | 10 +- validator/interface.go | 2 +- .../{boldmach/machine.go => bold_machine.go} | 17 +-- validator/server_arb/validator_spawner.go | 9 +- validator/valnode/validation_api.go | 4 +- 9 files changed, 38 insertions(+), 162 deletions(-) rename validator/server_arb/{boldmach/machine.go => bold_machine.go} (88%) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 2c8553e8aa..1ab2405bc4 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -370,7 +370,8 @@ func (s *BOLDStateProvider) CollectMachineHashes( } // TODO: Enable Redis streams. wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx) + useBoldMachine := true + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx) if err != nil { return nil, err } @@ -529,7 +530,8 @@ func (s *BOLDStateProvider) CollectProof( "startState", fmt.Sprintf("%+v", input.StartState), ) wasmModRoot := assertionMetadata.WasmModuleRoot - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx) + useBoldMachine := true + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx) if err != nil { return nil, err } diff --git a/staker/legacy/challenge_manager.go b/staker/legacy/challenge_manager.go index 2e192d1e3f..20bfff6b80 100644 --- a/staker/legacy/challenge_manager.go +++ b/staker/legacy/challenge_manager.go @@ -485,7 +485,8 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint var execRun validator.ExecutionRun for _, spawner := range m.validator.ExecutionSpawners() { if validator.SpawnerSupportsModule(spawner, m.wasmModuleRoot) { - execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input).Await(ctx) + useBold := false + execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, &useBold).Await(ctx) if err != nil { return fmt.Errorf("error creating execution backend for msg %v: %w", initialCount, err) } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 90b62ac7e1..daea27e5a4 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -56,7 +56,6 @@ import ( "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" - "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/server_common" "github.com/offchainlabs/nitro/validator/valnode" @@ -154,7 +153,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp valCfg.UseJit = false boldWrapperOpt := server_arb.WithWrapper( func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return machineWrapper(inner) + return server_arb.BoldMachineWrapper(inner) }) _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) blockValidatorConfig := staker.TestBlockValidatorConfig @@ -863,142 +862,6 @@ func create2ndNodeWithConfigForBoldProtocol( return l2client, l2node, assertionChain } -// boldMachine wraps a server_arb.MachineInterface. -type boldMachine struct { - inner server_arb.MachineInterface - zeroMachine *server_arb.ArbitratorMachine - hasStepped bool -} - -// Ensure boldMachine implements server_arb.MachineInterface. -var _ server_arb.MachineInterface = (*boldMachine)(nil) - -func newBoldMachine(inner server_arb.MachineInterface) *boldMachine { - z := server_arb.NewFinishedMachine(inner.GetGlobalState()) - return &boldMachine{ - inner: inner, - zeroMachine: z, - hasStepped: false, - } -} - -// Wraps a server_arb.MachineInterface and adds one step to the -// front of the machine's execution. -// -// This zeroth step should be at the same global state as the inner arbitrator -// machine has at step 0, but the machine is in the Finished state rather than -// the Running state. -func machineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { - return newBoldMachine(inner) -} - -// CloneMachineInterface returns a new boldMachine with the same inner machine. -func (m *boldMachine) CloneMachineInterface() server_arb.MachineInterface { - bMach := newBoldMachine(m.inner.CloneMachineInterface()) - bMach.hasStepped = m.hasStepped - return bMach -} - -// GetStepCount returns zero if the machine has not stepped, otherwise it -// returns the inner machine's step count plus one. -func (m *boldMachine) GetStepCount() uint64 { - if !m.hasStepped { - return 0 - } - return m.inner.GetStepCount() + 1 -} - -// Hash returns the hash of the inner machine if the machine has not stepped, -// otherwise it returns the hash of the zeroth step machine. -func (m *boldMachine) Hash() common.Hash { - if !m.hasStepped { - return m.zeroMachine.Hash() - } - return m.inner.Hash() -} - -// Destroy destroys the inner machine and the zeroth step machine. -func (m *boldMachine) Destroy() { - m.inner.Destroy() - m.zeroMachine.Destroy() -} - -// Freeze freezes the inner machine and the zeroth step machine. -func (m *boldMachine) Freeze() { - m.inner.Freeze() - m.zeroMachine.Freeze() -} - -// Status returns the status of the inner machine if the machine has not -// stepped, otherwise it returns the status of the zeroth step machine. -func (m *boldMachine) Status() uint8 { - if !m.hasStepped { - return m.zeroMachine.Status() - } - return m.inner.Status() -} - -// IsRunning returns true if the machine has not stepped, otherwise it -// returns the running state of the inner machine. -func (m *boldMachine) IsRunning() bool { - if !m.hasStepped { - return true - } - return m.inner.IsRunning() -} - -// IsErrored returns the errored state of the inner machine, or false if the -// machine has not stepped. -func (m *boldMachine) IsErrored() bool { - if !m.hasStepped { - return false - } - return m.inner.IsErrored() -} - -// Step steps the inner machine if the machine has not stepped, otherwise it -// steps the zeroth step machine. -func (m *boldMachine) Step(ctx context.Context, steps uint64) error { - if !m.hasStepped { - if steps == 0 { - // Zero is okay, but doesn't advance the machine. - return nil - } - m.hasStepped = true - // Only the first step or set of steps needs to be adjusted. - steps = steps - 1 - } - return m.inner.Step(ctx, steps) -} - -// ValidForStep returns true for step 0 if and only if the machine has not stepped yet, -// and the inner machine's ValidForStep for the step minus one otherwise. -func (m *boldMachine) ValidForStep(step uint64) bool { - if step == 0 { - return !m.hasStepped - } - return m.inner.ValidForStep(step - 1) -} - -// GetGlobalState returns the global state of the inner machine if the machine -// has stepped, otherwise it returns the global state of the zeroth step. -func (m *boldMachine) GetGlobalState() validator.GoGlobalState { - if !m.hasStepped { - return m.zeroMachine.GetGlobalState() - } - return m.inner.GetGlobalState() -} - -// ProveNextStep returns the proof of the next step of the inner machine if the -// machine has stepped, otherwise it returns the proof that the zeroth step -// results in the inner machine's initial global state. -func (m *boldMachine) ProveNextStep() []byte { - if !m.hasStepped { - return m.zeroMachine.ProveNextStep() - } - return m.inner.ProveNextStep() -} - func makeBoldBatch( t *testing.T, l2Node *arbnode.Node, diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 22d4e8294b..5e076b31b6 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -84,7 +84,7 @@ func (s *mockSpawner) Stop() {} func (s *mockSpawner) Name() string { return "mock" } func (s *mockSpawner) Room() int { return 4 } -func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput) containers.PromiseInterface[validator.ExecutionRun] { +func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] { s.ExecSpawned = append(s.ExecSpawned, input.Id) return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{ startState: input.StartState, @@ -260,7 +260,8 @@ func TestValidationServerAPI(t *testing.T) { if res != endState { t.Error("unexpected mock validation run") } - execRun, err := client.CreateExecutionRun(wasmRoot, &valInput).Await(ctx) + useBoldMachine := false + execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) step0 := execRun.GetStepAt(0) step0Res, err := step0.Await(ctx) @@ -385,9 +386,10 @@ func TestExecutionKeepAlive(t *testing.T) { Require(t, err) valInput := validator.ValidationInput{} - runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput).Await(ctx) + useBoldMachine := false + runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) - runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput).Await(ctx) + runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) <-time.After(time.Second * 10) stepDefault := runDefault.GetStepAt(0) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 35ab9a8b12..caf3a789aa 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -153,10 +153,14 @@ func NewExecutionClient(config rpcclient.ClientConfigFetcher, stack *node.Node) } } -func (c *ExecutionClient) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput) containers.PromiseInterface[validator.ExecutionRun] { - return stopwaiter.LaunchPromiseThread[validator.ExecutionRun](c, func(ctx context.Context) (validator.ExecutionRun, error) { +func (c *ExecutionClient) CreateExecutionRun( + wasmModuleRoot common.Hash, + input *validator.ValidationInput, + useBoldMachine *bool, +) containers.PromiseInterface[validator.ExecutionRun] { + return stopwaiter.LaunchPromiseThread(c, func(ctx context.Context) (validator.ExecutionRun, error) { var res uint64 - err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input)) + err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), useBoldMachine) if err != nil { return nil, err } diff --git a/validator/interface.go b/validator/interface.go index a1c22eb69f..5c5052d8eb 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -26,7 +26,7 @@ type ValidationRun interface { type ExecutionSpawner interface { ValidationSpawner - CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput) containers.PromiseInterface[ExecutionRun] + CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput, useBoldMachine *bool) containers.PromiseInterface[ExecutionRun] LatestWasmModuleRoot() containers.PromiseInterface[common.Hash] } diff --git a/validator/server_arb/boldmach/machine.go b/validator/server_arb/bold_machine.go similarity index 88% rename from validator/server_arb/boldmach/machine.go rename to validator/server_arb/bold_machine.go index 978e5c8a40..45a439528f 100644 --- a/validator/server_arb/boldmach/machine.go +++ b/validator/server_arb/bold_machine.go @@ -1,25 +1,24 @@ -package boldmach +package server_arb import ( "context" "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/validator" - "github.com/offchainlabs/nitro/validator/server_arb" ) // boldMachine wraps a server_arb.MachineInterface. type BoldMachine struct { - inner server_arb.MachineInterface - zeroMachine *server_arb.ArbitratorMachine + inner MachineInterface + zeroMachine *ArbitratorMachine hasStepped bool } // Ensure boldMachine implements server_arb.MachineInterface. -var _ server_arb.MachineInterface = (*BoldMachine)(nil) +var _ MachineInterface = (*BoldMachine)(nil) -func newBoldMachine(inner server_arb.MachineInterface) *BoldMachine { - z := server_arb.NewFinishedMachine(inner.GetGlobalState()) +func newBoldMachine(inner MachineInterface) *BoldMachine { + z := NewFinishedMachine(inner.GetGlobalState()) return &BoldMachine{ inner: inner, zeroMachine: z, @@ -33,12 +32,12 @@ func newBoldMachine(inner server_arb.MachineInterface) *BoldMachine { // This zeroth step should be at the same global state as the inner arbitrator // machine has at step 0, but the machine is in the Finished state rather than // the Running state. -func MachineWrapper(inner server_arb.MachineInterface) server_arb.MachineInterface { +func BoldMachineWrapper(inner MachineInterface) MachineInterface { return newBoldMachine(inner) } // CloneMachineInterface returns a new boldMachine with the same inner machine. -func (m *BoldMachine) CloneMachineInterface() server_arb.MachineInterface { +func (m *BoldMachine) CloneMachineInterface() MachineInterface { bMach := newBoldMachine(m.inner.CloneMachineInterface()) bMach.hasStepped = m.hasStepped return bMach diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index ba1f4d719b..476b399921 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -232,7 +232,7 @@ func (v *ArbitratorSpawner) Room() int { return avail } -func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput) containers.PromiseInterface[validator.ExecutionRun] { +func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] { getMachine := func(ctx context.Context) (MachineInterface, error) { initialFrozenMachine, err := v.machineLoader.GetZeroStepMachine(ctx, wasmModuleRoot) if err != nil { @@ -244,7 +244,12 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input machine.Destroy() return nil, err } - wrapped := MachineInterface(machine) + var wrapped MachineInterface + if *useBoldMachine { + wrapped = BoldMachineWrapper(machine) + } else { + wrapped = MachineInterface(machine) + } for _, wrapper := range v.machineWrappers { wrapped = wrapper(wrapped) } diff --git a/validator/valnode/validation_api.go b/validator/valnode/validation_api.go index ac0b46cd0e..b5644adc21 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -80,12 +80,12 @@ func NewExecutionServerAPI(valSpawner validator.ValidationSpawner, execution val } } -func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON) (uint64, error) { +func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON, useBoldMachine *bool) (uint64, error) { input, err := server_api.ValidationInputFromJson(jsonInput) if err != nil { return 0, err } - execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input).Await(ctx) + execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input, useBoldMachine).Await(ctx) if err != nil { return 0, err } From 1f436a687ed75b54a48d979bdcfd022969a50150 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 11:48:55 -0600 Subject: [PATCH 201/210] gci --- validator/server_arb/bold_machine.go | 1 + 1 file changed, 1 insertion(+) diff --git a/validator/server_arb/bold_machine.go b/validator/server_arb/bold_machine.go index 45a439528f..6ca48ba228 100644 --- a/validator/server_arb/bold_machine.go +++ b/validator/server_arb/bold_machine.go @@ -4,6 +4,7 @@ import ( "context" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/validator" ) From dc36a3f5f5948a1a28366d23bfcb3554835ab503 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 12:18:41 -0600 Subject: [PATCH 202/210] gci --- system_tests/overflow_assertions_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index 5b024ca122..1e1dc5f119 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -89,7 +89,7 @@ func TestOverflowAssertions(t *testing.T) { valCfg.UseJit = false boldWrapperOpt := server_arb.WithWrapper( func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return machineWrapper(inner) + return server_arb.BoldMachineWrapper(inner) }) _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) blockValidatorConfig := staker.TestBlockValidatorConfig From d7060599736fced40b845f7120aaa1b8d59f2304 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 13:45:38 -0600 Subject: [PATCH 203/210] build --- arbnode/node.go | 2 +- staker/bold/bold_staker.go | 30 +++++++++++-------- staker/bold/bold_state_provider.go | 3 +- .../multi_protocol/multi_protocol_staker.go | 5 ++++ system_tests/validation_mock_test.go | 8 ++--- validator/client/validation_client.go | 2 +- validator/server_arb/validator_spawner.go | 2 +- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/arbnode/node.go b/arbnode/node.go index c20722826b..f2e3433ecd 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -693,7 +693,7 @@ func createNodeImpl( confirmedNotifiers = append(confirmedNotifiers, messagePruner) } - stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) + stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(stack, l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan) if err != nil { return nil, err } diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index be3cb15572..1a8eed80fa 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -7,8 +7,6 @@ import ( "errors" "fmt" "math/big" - "os" - "path/filepath" "time" flag "github.com/spf13/pflag" @@ -17,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" protocol "github.com/offchainlabs/bold/chain-abstraction" @@ -29,7 +28,6 @@ import ( "github.com/offchainlabs/bold/util" "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/cmd/conf" "github.com/offchainlabs/nitro/staker" legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/util/headerreader" @@ -38,7 +36,6 @@ import ( ) var assertionCreatedId common.Hash -var homeDir string func init() { rollupAbi, err := boldrollup.RollupCoreMetaData.GetAbi() @@ -50,11 +47,6 @@ func init() { panic("RollupCore ABI missing AssertionCreated event") } assertionCreatedId = assertionCreatedEvent.ID - homeDirPath, err := os.UserHomeDir() - if err != nil { - panic(err) - } - homeDir = homeDirPath } type BoldConfig struct { @@ -97,7 +89,7 @@ type StateProviderConfig struct { var DefaultStateProviderConfig = StateProviderConfig{ ValidatorName: "default-validator", CheckBatchFinality: true, - MachineLeavesCachePath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "machine-hashes-cache"), + MachineLeavesCachePath: "machine-hashes-cache", } var DefaultBoldConfig = BoldConfig{ @@ -109,7 +101,7 @@ var DefaultBoldConfig = BoldConfig{ API: false, APIHost: "127.0.0.1", APIPort: 9393, - APIDBPath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "bold-api-db"), + APIDBPath: "bold-api-db", TrackChallengeParentAssertionHashes: []string{}, CheckStakerSwitchInterval: time.Minute, // Every minute, check if the Nitro node staker should switch to using BOLD. StateProviderConfig: DefaultStateProviderConfig, @@ -162,6 +154,7 @@ type BOLDStaker struct { func NewBOLDStaker( ctx context.Context, + stack *node.Node, rollupAddress common.Address, callOpts bind.CallOpts, txOpts *bind.TransactOpts, @@ -178,7 +171,7 @@ func NewBOLDStaker( return nil, err } wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber) - manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster) + manager, err := newBOLDChallengeManager(ctx, stack, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster) if err != nil { return nil, err } @@ -349,6 +342,7 @@ func (b *BOLDStaker) getCallOpts(ctx context.Context) *bind.CallOpts { // implements the StopWaiter pattern as part of the Nitro validator. func newBOLDChallengeManager( ctx context.Context, + stack *node.Node, rollupAddress common.Address, txOpts *bind.TransactOpts, l1Reader *headerreader.HeaderReader, @@ -405,6 +399,15 @@ func newBOLDChallengeManager( bigStepHeight := l2stateprovider.Height(bigStepHeightBig.Uint64()) smallStepHeight := l2stateprovider.Height(smallStepHeightBig.Uint64()) + apiDBPath := config.APIDBPath + if apiDBPath != "" { + apiDBPath = stack.ResolvePath(apiDBPath) + } + machineHashesPath := config.StateProviderConfig.MachineLeavesCachePath + if machineHashesPath != "" { + machineHashesPath = stack.ResolvePath(machineHashesPath) + } + // Sets up the state provider interface that BOLD will use to request data such as // execution states for assertions, history commitments for machine execution, and one step proofs. stateProvider, err := NewBOLDStateProvider( @@ -414,6 +417,7 @@ func newBOLDChallengeManager( // TODO: Fetch these from the smart contract instead. blockChallengeLeafHeight, &config.StateProviderConfig, + machineHashesPath, ) if err != nil { return nil, fmt.Errorf("could not create state manager: %w", err) @@ -449,7 +453,7 @@ func newBOLDChallengeManager( } if config.API { apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort) - stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, config.APIDBPath)) + stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, apiDBPath)) } manager, err := challengemanager.NewChallengeStack( diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 1ab2405bc4..13e08f7d3f 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -56,8 +56,9 @@ func NewBOLDStateProvider( statelessValidator *staker.StatelessBlockValidator, blockChallengeLeafHeight l2stateprovider.Height, stateProviderConfig *StateProviderConfig, + machineHashesCachePath string, ) (*BOLDStateProvider, error) { - historyCache, err := challengecache.New(stateProviderConfig.MachineLeavesCachePath) + historyCache, err := challengecache.New(machineHashesCachePath) if err != nil { return nil, err } diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go index e08352f37d..0c104094ed 100644 --- a/staker/multi_protocol/multi_protocol_staker.go +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/node" "github.com/offchainlabs/bold/solgen/go/bridgegen" boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen" @@ -46,9 +47,11 @@ type MultiProtocolStaker struct { callOpts bind.CallOpts boldConfig *boldstaker.BoldConfig stakeTokenAddress common.Address + stack *node.Node } func NewMultiProtocolStaker( + stack *node.Node, l1Reader *headerreader.HeaderReader, wallet legacystaker.ValidatorWalletInterface, callOpts bind.CallOpts, @@ -102,6 +105,7 @@ func NewMultiProtocolStaker( callOpts: callOpts, boldConfig: boldConfig, stakeTokenAddress: stakeTokenAddress, + stack: stack, }, nil } @@ -224,6 +228,7 @@ func (m *MultiProtocolStaker) setupBoldStaker( } boldStaker, err := boldstaker.NewBOLDStaker( ctx, + m.stack, rollupAddress, m.callOpts, txBuilder.SingleTxAuth(), diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 5e076b31b6..7493608f0c 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -84,7 +84,7 @@ func (s *mockSpawner) Stop() {} func (s *mockSpawner) Name() string { return "mock" } func (s *mockSpawner) Room() int { return 4 } -func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] { +func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine bool) containers.PromiseInterface[validator.ExecutionRun] { s.ExecSpawned = append(s.ExecSpawned, input.Id) return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{ startState: input.StartState, @@ -261,7 +261,7 @@ func TestValidationServerAPI(t *testing.T) { t.Error("unexpected mock validation run") } useBoldMachine := false - execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) Require(t, err) step0 := execRun.GetStepAt(0) step0Res, err := step0.Await(ctx) @@ -387,9 +387,9 @@ func TestExecutionKeepAlive(t *testing.T) { valInput := validator.ValidationInput{} useBoldMachine := false - runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) Require(t, err) - runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) Require(t, err) <-time.After(time.Second * 10) stepDefault := runDefault.GetStepAt(0) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index caf3a789aa..9ac2271963 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -160,7 +160,7 @@ func (c *ExecutionClient) CreateExecutionRun( ) containers.PromiseInterface[validator.ExecutionRun] { return stopwaiter.LaunchPromiseThread(c, func(ctx context.Context) (validator.ExecutionRun, error) { var res uint64 - err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), useBoldMachine) + err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), *useBoldMachine) if err != nil { return nil, err } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 476b399921..5eb69ff60b 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -245,7 +245,7 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input return nil, err } var wrapped MachineInterface - if *useBoldMachine { + if useBoldMachine != nil && *useBoldMachine { wrapped = BoldMachineWrapper(machine) } else { wrapped = MachineInterface(machine) From 46d742e24d8b0ec1490ca5870abbd9065f8d599a Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 5 Dec 2024 14:13:33 -0600 Subject: [PATCH 204/210] test --- system_tests/validation_mock_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 7493608f0c..e0475daae8 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -84,7 +84,7 @@ func (s *mockSpawner) Stop() {} func (s *mockSpawner) Name() string { return "mock" } func (s *mockSpawner) Room() int { return 4 } -func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine bool) containers.PromiseInterface[validator.ExecutionRun] { +func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, _ *bool) containers.PromiseInterface[validator.ExecutionRun] { s.ExecSpawned = append(s.ExecSpawned, input.Id) return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{ startState: input.StartState, @@ -261,7 +261,7 @@ func TestValidationServerAPI(t *testing.T) { t.Error("unexpected mock validation run") } useBoldMachine := false - execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) + execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) step0 := execRun.GetStepAt(0) step0Res, err := step0.Await(ctx) @@ -387,9 +387,9 @@ func TestExecutionKeepAlive(t *testing.T) { valInput := validator.ValidationInput{} useBoldMachine := false - runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) + runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) - runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx) + runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) Require(t, err) <-time.After(time.Second * 10) stepDefault := runDefault.GetStepAt(0) From 8518e3d0c249f62b03a6d86a75d9d97f14b8c749 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 6 Dec 2024 08:41:17 -0700 Subject: [PATCH 205/210] Less useBoldMachine pointers --- staker/bold/bold_state_provider.go | 6 ++---- staker/legacy/challenge_manager.go | 3 +-- system_tests/validation_mock_test.go | 10 ++++------ validator/client/validation_client.go | 4 ++-- validator/interface.go | 2 +- validator/server_arb/validator_spawner.go | 4 ++-- validator/valnode/validation_api.go | 6 +++++- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 13e08f7d3f..48b7cbd91e 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -371,8 +371,7 @@ func (s *BOLDStateProvider) CollectMachineHashes( } // TODO: Enable Redis streams. wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot - useBoldMachine := true - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx) + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx) if err != nil { return nil, err } @@ -531,8 +530,7 @@ func (s *BOLDStateProvider) CollectProof( "startState", fmt.Sprintf("%+v", input.StartState), ) wasmModRoot := assertionMetadata.WasmModuleRoot - useBoldMachine := true - execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx) + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx) if err != nil { return nil, err } diff --git a/staker/legacy/challenge_manager.go b/staker/legacy/challenge_manager.go index 20bfff6b80..1aa13a9e05 100644 --- a/staker/legacy/challenge_manager.go +++ b/staker/legacy/challenge_manager.go @@ -485,8 +485,7 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint var execRun validator.ExecutionRun for _, spawner := range m.validator.ExecutionSpawners() { if validator.SpawnerSupportsModule(spawner, m.wasmModuleRoot) { - useBold := false - execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, &useBold).Await(ctx) + execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, false).Await(ctx) if err != nil { return fmt.Errorf("error creating execution backend for msg %v: %w", initialCount, err) } diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index e0475daae8..98dab7ad39 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -84,7 +84,7 @@ func (s *mockSpawner) Stop() {} func (s *mockSpawner) Name() string { return "mock" } func (s *mockSpawner) Room() int { return 4 } -func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, _ *bool) containers.PromiseInterface[validator.ExecutionRun] { +func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, _ bool) containers.PromiseInterface[validator.ExecutionRun] { s.ExecSpawned = append(s.ExecSpawned, input.Id) return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{ startState: input.StartState, @@ -260,8 +260,7 @@ func TestValidationServerAPI(t *testing.T) { if res != endState { t.Error("unexpected mock validation run") } - useBoldMachine := false - execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx) Require(t, err) step0 := execRun.GetStepAt(0) step0Res, err := step0.Await(ctx) @@ -386,10 +385,9 @@ func TestExecutionKeepAlive(t *testing.T) { Require(t, err) valInput := validator.ValidationInput{} - useBoldMachine := false - runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx) Require(t, err) - runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx) + runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx) Require(t, err) <-time.After(time.Second * 10) stepDefault := runDefault.GetStepAt(0) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 9ac2271963..c04817d654 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -156,11 +156,11 @@ func NewExecutionClient(config rpcclient.ClientConfigFetcher, stack *node.Node) func (c *ExecutionClient) CreateExecutionRun( wasmModuleRoot common.Hash, input *validator.ValidationInput, - useBoldMachine *bool, + useBoldMachine bool, ) containers.PromiseInterface[validator.ExecutionRun] { return stopwaiter.LaunchPromiseThread(c, func(ctx context.Context) (validator.ExecutionRun, error) { var res uint64 - err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), *useBoldMachine) + err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), useBoldMachine) if err != nil { return nil, err } diff --git a/validator/interface.go b/validator/interface.go index 5c5052d8eb..249cf1b1c3 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -26,7 +26,7 @@ type ValidationRun interface { type ExecutionSpawner interface { ValidationSpawner - CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput, useBoldMachine *bool) containers.PromiseInterface[ExecutionRun] + CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput, useBoldMachine bool) containers.PromiseInterface[ExecutionRun] LatestWasmModuleRoot() containers.PromiseInterface[common.Hash] } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 5eb69ff60b..76c19dc8f2 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -232,7 +232,7 @@ func (v *ArbitratorSpawner) Room() int { return avail } -func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] { +func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine bool) containers.PromiseInterface[validator.ExecutionRun] { getMachine := func(ctx context.Context) (MachineInterface, error) { initialFrozenMachine, err := v.machineLoader.GetZeroStepMachine(ctx, wasmModuleRoot) if err != nil { @@ -245,7 +245,7 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input return nil, err } var wrapped MachineInterface - if useBoldMachine != nil && *useBoldMachine { + if useBoldMachine { wrapped = BoldMachineWrapper(machine) } else { wrapped = MachineInterface(machine) diff --git a/validator/valnode/validation_api.go b/validator/valnode/validation_api.go index b5644adc21..dab74f6e29 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -80,11 +80,15 @@ func NewExecutionServerAPI(valSpawner validator.ValidationSpawner, execution val } } -func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON, useBoldMachine *bool) (uint64, error) { +func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON, useBoldMachineOptional *bool) (uint64, error) { input, err := server_api.ValidationInputFromJson(jsonInput) if err != nil { return 0, err } + useBoldMachine := false + if useBoldMachineOptional != nil { + useBoldMachine = *useBoldMachineOptional + } execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input, useBoldMachine).Await(ctx) if err != nil { return 0, err From 1e635e4d896e421d0fe42ffe33cc3049f7f909b4 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 6 Dec 2024 10:56:20 -0600 Subject: [PATCH 206/210] builds --- system_tests/bold_challenge_protocol_test.go | 16 ++++++++++------ system_tests/bold_new_challenge_test.go | 4 +++- system_tests/bold_state_provider_test.go | 4 +++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index daea27e5a4..eb210e53fd 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -78,11 +78,13 @@ func TestChallengeProtocolBOLDStartStepChallenge(t *testing.T) { } func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOption) { - Require(t, os.RemoveAll("/tmp/good")) - Require(t, os.RemoveAll("/tmp/evil")) + goodDir, err := os.MkdirTemp("", "good_*") + Require(t, err) + evilDir, err := os.MkdirTemp("", "evil_*") + Require(t, err) t.Cleanup(func() { - Require(t, os.RemoveAll("/tmp/good")) - Require(t, os.RemoveAll("/tmp/evil")) + Require(t, os.RemoveAll(goodDir)) + Require(t, os.RemoveAll(evilDir)) }) ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() @@ -216,9 +218,10 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp l2stateprovider.Height(blockChallengeLeafHeight), &bold.StateProviderConfig{ ValidatorName: "good", - MachineLeavesCachePath: "/tmp/good", + MachineLeavesCachePath: goodDir, CheckBatchFinality: false, }, + goodDir, ) Require(t, err) @@ -228,9 +231,10 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp l2stateprovider.Height(blockChallengeLeafHeight), &bold.StateProviderConfig{ ValidatorName: "evil", - MachineLeavesCachePath: "/tmp/evil", + MachineLeavesCachePath: evilDir, CheckBatchFinality: false, }, + evilDir, ) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index a9caec45f0..1363f700c1 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -277,15 +277,17 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB var stateManager BoldStateProviderInterface var err error + cacheDir := t.TempDir() stateManager, err = bold.NewBOLDStateProvider( node.ConsensusNode.BlockValidator, node.ConsensusNode.StatelessBlockValidator, l2stateprovider.Height(blockChallengeLeafHeight), &bold.StateProviderConfig{ ValidatorName: addressName, - MachineLeavesCachePath: t.TempDir(), + MachineLeavesCachePath: cacheDir, CheckBatchFinality: false, }, + cacheDir, ) Require(t, err) diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go index 17fa436a83..0ecce5ba64 100644 --- a/system_tests/bold_state_provider_test.go +++ b/system_tests/bold_state_provider_test.go @@ -400,15 +400,17 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context, blockChallengeHei Require(t, blockValidator.Initialize(ctx)) Require(t, blockValidator.Start(ctx)) + dir := t.TempDir() stateManager, err := bold.NewBOLDStateProvider( blockValidator, stateless, l2stateprovider.Height(blockChallengeHeight), &bold.StateProviderConfig{ ValidatorName: "", - MachineLeavesCachePath: t.TempDir(), + MachineLeavesCachePath: dir, CheckBatchFinality: false, }, + dir, ) Require(t, err) From a64cb8115979646a7f3fb1d2eb56a9c90413771c Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Fri, 6 Dec 2024 10:58:01 -0600 Subject: [PATCH 207/210] builds --- system_tests/overflow_assertions_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index 1e1dc5f119..1d9bb0c942 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -47,9 +47,10 @@ func TestOverflowAssertions(t *testing.T) { // Start the challenge manager with a minimumAssertionPeriod of 7 and make // sure that it posts overflow-assertions right away instead of waiting for // the 7 blocks to pass. - Require(t, os.RemoveAll("/tmp/good")) + goodDir, err := os.MkdirTemp("", "good_*") + Require(t, err) t.Cleanup(func() { - Require(t, os.RemoveAll("/tmp/good")) + Require(t, os.RemoveAll(goodDir)) }) ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() @@ -125,9 +126,10 @@ func TestOverflowAssertions(t *testing.T) { l2stateprovider.Height(blockChallengeLeafHeight), &bold.StateProviderConfig{ ValidatorName: "good", - MachineLeavesCachePath: "/tmp/good", + MachineLeavesCachePath: goodDir, CheckBatchFinality: false, }, + goodDir, ) Require(t, err) From 1a475818ac652f1ef19772855a21b54f436521c7 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 6 Dec 2024 12:23:21 -0700 Subject: [PATCH 208/210] Don't double wrap bold machines --- system_tests/bold_challenge_protocol_test.go | 7 +------ system_tests/bold_new_challenge_test.go | 4 ++-- system_tests/overflow_assertions_test.go | 7 +------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index eb210e53fd..777817bf3e 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -153,11 +153,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp valCfg := valnode.TestValidationConfig valCfg.UseJit = false - boldWrapperOpt := server_arb.WithWrapper( - func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return server_arb.BoldMachineWrapper(inner) - }) - _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) + _, valStack := createTestValidationNode(t, ctx, &valCfg) blockValidatorConfig := staker.TestBlockValidatorConfig statelessA, err := staker.NewStatelessBlockValidator( @@ -173,7 +169,6 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp Require(t, err) err = statelessA.Start(ctx) Require(t, err) - spawnerOpts = append([]server_arb.SpawnerOption{boldWrapperOpt}, spawnerOpts...) _, valStackB := createTestValidationNode(t, ctx, &valCfg, spawnerOpts...) statelessB, err := staker.NewStatelessBlockValidator( diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 1363f700c1..ad6e44bc71 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -35,7 +35,7 @@ import ( ) type incorrectBlockStateProvider struct { - honest *bold.BOLDStateProvider + honest BoldStateProviderInterface chain protocol.AssertionChain wrongAtFirstVirtual bool wrongAtBlockHeight uint64 @@ -162,7 +162,7 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo _, cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "EvilAsserter", func(stateManager BoldStateProviderInterface) BoldStateProviderInterface { p := &incorrectBlockStateProvider{ - honest: stateManager.(*bold.BOLDStateProvider), + honest: stateManager, chain: assertionChain, wrongAtFirstVirtual: wrongAtFirstVirtual, } diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index 1d9bb0c942..c024a43070 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -34,7 +34,6 @@ import ( "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/staker/bold" "github.com/offchainlabs/nitro/util" - "github.com/offchainlabs/nitro/validator/server_arb" "github.com/offchainlabs/nitro/validator/valnode" ) @@ -88,11 +87,7 @@ func TestOverflowAssertions(t *testing.T) { valCfg := valnode.TestValidationConfig valCfg.UseJit = false - boldWrapperOpt := server_arb.WithWrapper( - func(inner server_arb.MachineInterface) server_arb.MachineInterface { - return server_arb.BoldMachineWrapper(inner) - }) - _, valStack := createTestValidationNode(t, ctx, &valCfg, boldWrapperOpt) + _, valStack := createTestValidationNode(t, ctx, &valCfg) blockValidatorConfig := staker.TestBlockValidatorConfig stateless, err := staker.NewStatelessBlockValidator( From 76a8a0f9caa566e58e3fd7f10deaa0d4efabf49f Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 6 Dec 2024 12:27:10 -0700 Subject: [PATCH 209/210] Bump nitro-testnode to latest master to fix CI --- nitro-testnode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitro-testnode b/nitro-testnode index 4c46f04113..fa19e22104 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 4c46f041131a08c7219e525b0a37afb6a5b18987 +Subproject commit fa19e2210403ad24519ea46c2d337f54a9f47593 From 0535fd2c65255a48aba8f8f510aac0de21be2e95 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 7 Dec 2024 21:16:36 -0700 Subject: [PATCH 210/210] Update bold submodule to fix shutdown --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index b7965e2b3c..d0a87de774 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit b7965e2b3c4d00d6032d8a7683eebf4aa65ce6a2 +Subproject commit d0a87de774aecfa97161efd1b0a924d4d5fbcf74