diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ed49634ad..1eda1d9b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: redis: image: redis ports: - - 6379:6379 + - 6379:6379 strategy: fail-fast: false @@ -192,7 +192,7 @@ jobs: - name: run challenge tests if: matrix.test-mode == 'challenge' - run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags challengetest --run TestChallenge --cover + run: ${{ github.workspace }}/.github/workflows/gotestsum.sh --tags challengetest --run TestChallenge --timeout 60m --cover - name: run stylus tests if: matrix.test-mode == 'stylus' diff --git a/.gitmodules b/.gitmodules index d4d26282ae..24df007a79 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,6 +23,9 @@ [submodule "nitro-testnode"] path = nitro-testnode url = https://github.com/OffchainLabs/nitro-testnode.git +[submodule "bold"] + path = bold + url = https://github.com/OffchainLabs/bold.git [submodule "arbitrator/langs/rust"] path = arbitrator/langs/rust url = https://github.com/OffchainLabs/stylus-sdk-rs.git 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/Dockerfile b/Dockerfile index aba5432254..ba1f2feb3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -234,6 +234,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ COPY go.mod go.sum ./ COPY go-ethereum/go.mod go-ethereum/go.sum go-ethereum/ COPY fastcache/go.mod fastcache/go.sum fastcache/ +COPY bold/go.mod bold/go.sum bold/ RUN go mod download COPY . ./ COPY --from=contracts-builder workspace/contracts/build/ contracts/build/ 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 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/src/lib.rs b/arbitrator/prover/src/lib.rs index 08473c2598..bc2bd4bc48 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(gs: GlobalState) -> *mut Machine { + Box::into_raw(Box::new(Machine::new_finished(gs))) +} + 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..0d39d87e77 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 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. + pub fn new_finished(gs: GlobalState) -> Machine { + Machine { + steps: 0, + status: MachineStatus::Finished, + 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. + thread_state: ThreadState::Main, + value_stacks: vec![Vec::new()], + frame_stacks: vec![Vec::new()], + internal_stack: Default::default(), + modules: Default::default(), + modules_merkle: 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)?; @@ -2867,6 +2897,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/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/arbitrator/stylus/tests/hostio-test/src/main.rs b/arbitrator/stylus/tests/hostio-test/src/main.rs index 17a5d10266..47b46daad2 100644 --- a/arbitrator/stylus/tests/hostio-test/src/main.rs +++ b/arbitrator/stylus/tests/hostio-test/src/main.rs @@ -204,4 +204,37 @@ impl HostioTest { fn tx_origin() -> Result
{ Ok(tx::origin()) } + + 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(pages: U256) { + let pages: u16 = pages.try_into().unwrap(); + unsafe { + hostio::pay_for_memory_grow(pages); + } + } + + fn write_result_empty() { + } + + 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/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/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 373d247696..a977b9fc08 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 ( @@ -710,13 +712,23 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u return newBaseFeeCap, newTipCap, newBlobFeeCap, 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) 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) + if err != nil { + return nil, err + } + return p.postTransactionWithMutex(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() + return p.postTransactionWithMutex(ctx, dataCreatedAt, nonce, meta, to, calldata, gasLimit, value, kzgBlobs, accessList) +} + +func (p *DataPoster) postTransactionWithMutex(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) { if p.config().DisableNewTx { return nil, fmt.Errorf("posting new transaction is disabled") @@ -1087,7 +1099,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 +1108,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..0c31008ff1 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -11,23 +11,23 @@ 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/cmd/chaininfo" "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 { @@ -45,7 +45,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/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 c5b3bbe071..f2e3433ecd 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" @@ -41,6 +42,9 @@ import ( "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker" + boldstaker "github.com/offchainlabs/nitro/staker/bold" + legacystaker "github.com/offchainlabs/nitro/staker/legacy" + multiprotocolstaker "github.com/offchainlabs/nitro/staker/multi_protocol" "github.com/offchainlabs/nitro/staker/validatorwallet" "github.com/offchainlabs/nitro/util/contracts" "github.com/offchainlabs/nitro/util/headerreader" @@ -78,22 +82,23 @@ func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner com } type Config struct { - Sequencer bool `koanf:"sequencer"` - ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"` - InboxReader InboxReaderConfig `koanf:"inbox-reader" reload:"hot"` - DelayedSequencer DelayedSequencerConfig `koanf:"delayed-sequencer" reload:"hot"` - BatchPoster BatchPosterConfig `koanf:"batch-poster" reload:"hot"` - MessagePruner MessagePrunerConfig `koanf:"message-pruner" reload:"hot"` - BlockValidator staker.BlockValidatorConfig `koanf:"block-validator" reload:"hot"` - Feed broadcastclient.FeedConfig `koanf:"feed" reload:"hot"` - Staker staker.L1ValidatorConfig `koanf:"staker" reload:"hot"` - SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"` - DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"` - SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"` - Dangerous DangerousConfig `koanf:"dangerous"` - TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"` - Maintenance MaintenanceConfig `koanf:"maintenance" reload:"hot"` - ResourceMgmt resourcemanager.Config `koanf:"resource-mgmt" reload:"hot"` + Sequencer bool `koanf:"sequencer"` + ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"` + InboxReader InboxReaderConfig `koanf:"inbox-reader" reload:"hot"` + DelayedSequencer DelayedSequencerConfig `koanf:"delayed-sequencer" reload:"hot"` + BatchPoster BatchPosterConfig `koanf:"batch-poster" reload:"hot"` + MessagePruner MessagePrunerConfig `koanf:"message-pruner" reload:"hot"` + 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"` + SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"` + DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"` + SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"` + Dangerous DangerousConfig `koanf:"dangerous"` + TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"` + Maintenance MaintenanceConfig `koanf:"maintenance" reload:"hot"` + ResourceMgmt resourcemanager.Config `koanf:"resource-mgmt" reload:"hot"` // SnapSyncConfig is only used for testing purposes, these should not be configured in production. SnapSyncTest SnapSyncConfig } @@ -152,7 +157,8 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet, feedInputEnable bool, feed MessagePrunerConfigAddOptions(prefix+".message-pruner", f) staker.BlockValidatorConfigAddOptions(prefix+".block-validator", f) broadcastclient.FeedConfigAddOptions(prefix+".feed", f, feedInputEnable, feedOutputEnable) - staker.L1ValidatorConfigAddOptions(prefix+".staker", f) + legacystaker.L1ValidatorConfigAddOptions(prefix+".staker", f) + boldstaker.BoldConfigAddOptions(prefix+".bold", f) SeqCoordinatorConfigAddOptions(prefix+".seq-coordinator", f) das.DataAvailabilityConfigAddNodeOptions(prefix+".data-availability", f) SyncMonitorConfigAddOptions(prefix+".sync-monitor", f) @@ -170,7 +176,8 @@ var ConfigDefault = Config{ MessagePruner: DefaultMessagePrunerConfig, BlockValidator: staker.DefaultBlockValidatorConfig, Feed: broadcastclient.FeedConfigDefault, - Staker: staker.DefaultL1ValidatorConfig, + Staker: legacystaker.DefaultL1ValidatorConfig, + Bold: boldstaker.DefaultBoldConfig, SeqCoordinator: DefaultSeqCoordinatorConfig, DataAvailability: das.DefaultDataAvailabilityConfig, SyncMonitor: DefaultSyncMonitorConfig, @@ -202,7 +209,7 @@ func ConfigDefaultL1NonSequencerTest() *Config { config.SeqCoordinator.Enable = false config.BlockValidator = staker.TestBlockValidatorConfig config.SyncMonitor = TestSyncMonitorConfig - config.Staker = staker.TestL1ValidatorConfig + config.Staker = legacystaker.TestL1ValidatorConfig config.Staker.Enable = false config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}} @@ -218,7 +225,7 @@ func ConfigDefaultL2Test() *Config { config.Feed.Output.Signed = false config.SeqCoordinator.Signer.ECDSA.AcceptSequencer = false config.SeqCoordinator.Signer.ECDSA.Dangerous.AcceptMissing = true - config.Staker = staker.TestL1ValidatorConfig + config.Staker = legacystaker.TestL1ValidatorConfig config.SyncMonitor = TestSyncMonitorConfig config.Staker.Enable = false config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}} @@ -266,7 +273,7 @@ type Node struct { MessagePruner *MessagePruner BlockValidator *staker.BlockValidator StatelessBlockValidator *staker.StatelessBlockValidator - Staker *staker.Staker + Staker *multiprotocolstaker.MultiProtocolStaker BroadcastServer *broadcaster.Broadcaster BroadcastClients *broadcastclients.BroadcastClients SeqCoordinator *SeqCoordinator @@ -632,7 +639,7 @@ func createNodeImpl( } } - var stakerObj *staker.Staker + var stakerObj *multiprotocolstaker.MultiProtocolStaker var messagePruner *MessagePruner var stakerAddr common.Address @@ -652,7 +659,7 @@ func createNodeImpl( getExtraGas := func() uint64 { return configFetcher.Get().Staker.ExtraGas } // TODO: factor this out into separate helper, and split rest of node // creation into multiple helpers. - var wallet staker.ValidatorWalletInterface = validatorwallet.NewNoOp(l1client, deployInfo.Rollup) + var wallet legacystaker.ValidatorWalletInterface = validatorwallet.NewNoOp(l1client, deployInfo.Rollup) if !strings.EqualFold(config.Staker.Strategy, "watchtower") { if config.Staker.UseSmartContractWallet || (txOptsValidator == nil && config.Staker.DataPoster.ExternalSigner.URL == "") { var existingWalletAddress *common.Address @@ -680,13 +687,13 @@ func createNodeImpl( } } - var confirmedNotifiers []staker.LatestConfirmedNotifier + var confirmedNotifiers []legacystaker.LatestConfirmedNotifier if config.MessagePruner.Enable { messagePruner = NewMessagePruner(txStreamer, inboxTracker, func() *MessagePrunerConfig { return &configFetcher.Get().MessagePruner }) confirmedNotifiers = append(confirmedNotifiers, messagePruner) } - stakerObj, err = staker.NewStaker(l1Reader, wallet, bind.CallOpts{}, func() *staker.L1ValidatorConfig { return &configFetcher.Get().Staker }, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, 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 } @@ -696,11 +703,6 @@ func createNodeImpl( if dp != nil { stakerAddr = dp.Sender() } - whitelisted, err := stakerObj.IsWhitelisted(ctx) - if err != nil { - return nil, err - } - log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", wallet.Address(), "whitelisted", whitelisted, "strategy", config.Staker.Strategy) } var batchPoster *BatchPoster 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/seq_coordinator.go b/arbnode/seq_coordinator.go index 5987801d5f..fc2f3c9cf6 100644 --- a/arbnode/seq_coordinator.go +++ b/arbnode/seq_coordinator.go @@ -662,7 +662,7 @@ func (c *SeqCoordinator) update(ctx context.Context) time.Duration { for msgToRead < readUntil && localMsgCount >= remoteFinalizedMsgCount { var resString string resString, msgReadErr = 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 } 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..f06e9ca49f 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 { @@ -144,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 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..b65c278b2b 100644 --- a/arbos/addressSet/addressSet_test.go +++ b/arbos/addressSet/addressSet_test.go @@ -8,16 +8,17 @@ 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/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 +27,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 +50,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 +145,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/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.go b/arbos/arbosState/arbosstate.go index f53d9c892a..a3d1ae8386 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" ) @@ -128,7 +129,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/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..8ccfbc7cfb 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -13,9 +13,10 @@ 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,12 +62,11 @@ 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) 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..8fd417c2b2 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" @@ -51,7 +54,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) { @@ -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/incomingmessage.go b/arbos/arbostypes/incomingmessage.go index c4c2dc037b..b9a366cbd5 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" ) @@ -265,7 +266,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/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..77475856ac 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 @@ -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) } @@ -460,7 +460,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 { @@ -470,7 +470,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/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..a812e5486b 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, &types.Body{Transactions: body.Transactions}, 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..37dae08c33 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -10,20 +10,19 @@ 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/cmd/chaininfo" + "github.com/offchainlabs/nitro/util/arbmath" + am "github.com/offchainlabs/nitro/util/arbmath" ) type L1PricingState struct { @@ -540,7 +539,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/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..6ab0135be9 100644 --- a/arbos/l1pricing_test.go +++ b/arbos/l1pricing_test.go @@ -7,18 +7,21 @@ 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/cmd/chaininfo" "github.com/offchainlabs/nitro/util/arbmath" - - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbos/burn" ) type l1PricingTest struct { @@ -172,7 +175,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) @@ -315,7 +318,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/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..c5873b7e93 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,40 @@ 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(), + if evm.Context.ArbOSVersion < 30 && amount.Sign() == 0 { + evm.StateDB.CreateZombieIfDeleted(*from) } - info.MockCall([]byte{}, 0, *from, *to, amount) + evm.StateDB.SubBalance(*from, uint256.MustFromBig(amount), tracing.BalanceChangeTransfer) + } + 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/bold b/bold new file mode 160000 index 0000000000..d0a87de774 --- /dev/null +++ b/bold @@ -0,0 +1 @@ +Subproject commit d0a87de774aecfa97161efd1b0a924d4d5fbcf74 diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index 4e97ca8cd0..c4a3743276 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" @@ -129,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 @@ -298,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 } @@ -324,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 @@ -338,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) @@ -361,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/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index a499628cd5..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() @@ -138,7 +125,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 +142,7 @@ func TestInvalidSignature(t *testing.T) { nil, fatalErrChan, &badSequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -201,8 +193,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 +218,7 @@ func startMakeBroadcastClient(ctx context.Context, t *testing.T, clientConfig Co nil, feedErrChan, sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -313,6 +307,7 @@ func TestServerClientDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -384,6 +379,7 @@ func TestBroadcastClientConfirmedMessage(t *testing.T) { confirmedSequenceNumberListener, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -456,6 +452,7 @@ func TestServerIncorrectChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -515,6 +512,7 @@ func TestServerMissingChainId(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -572,6 +570,7 @@ func TestServerIncorrectFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -631,6 +630,7 @@ func TestServerMissingFeedServerVersion(t *testing.T) { nil, badFeedErrChan, &sequencerAddr, + t, ) Require(t, err) badBroadcastClient.Start(ctx) @@ -682,6 +682,7 @@ func TestBroadcastClientReconnectsOnServerDisconnect(t *testing.T) { nil, feedErrChan, &sequencerAddr, + t, ) Require(t, err) broadcastClient.Start(ctx) @@ -794,6 +795,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/chaininfo/arbitrum_chain_info.json b/cmd/chaininfo/arbitrum_chain_info.json index f862c6dfbf..fcfbb6e26a 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": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "deployed-at": 15411056 } }, @@ -90,6 +91,7 @@ "sequencer-inbox": "0x211e1c4c7f1bf5351ac850ed10fd68cffcf6c21b", "validator-utils": "0x2B081fbaB646D9013f2699BebEf62B7e7d7F0976", "validator-wallet-creator": "0xe05465Aab36ba1277dAE36aa27a7B74830e74DE4", + "stake-token": "0x765277eebeca2e31912c9946eae1021199b39c61", "deployed-at": 15016829 } }, diff --git a/cmd/chaininfo/chain_defaults.go b/cmd/chaininfo/chain_defaults.go new file mode 100644 index 0000000000..a69472cafc --- /dev/null +++ b/cmd/chaininfo/chain_defaults.go @@ -0,0 +1,141 @@ +// Copyright 2021-2024, 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_defaults_test.go b/cmd/chaininfo/chain_defaults_test.go new file mode 100644 index 0000000000..a19e5849a6 --- /dev/null +++ b/cmd/chaininfo/chain_defaults_test.go @@ -0,0 +1,17 @@ +// 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) { + 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) + } + } +} diff --git a/cmd/chaininfo/chain_info.go b/cmd/chaininfo/chain_info.go index 13e586ced2..35f28bebb9 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 } @@ -120,5 +120,6 @@ type RollupAddresses struct { UpgradeExecutor common.Address `json:"upgrade-executor"` ValidatorUtils common.Address `json:"validator-utils"` ValidatorWalletCreator common.Address `json:"validator-wallet-creator"` + StakeToken common.Address `json:"stake-token"` DeployedAt uint64 `json:"deployed-at"` } 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 d54d35bf4e..74bd89fd16 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"` @@ -48,6 +50,7 @@ var InitConfigDefault = InitConfig{ DownloadPoll: time.Minute, DevInit: false, DevInitAddress: "", + DevMaxCodeSize: 0, DevInitBlockNum: 0, Empty: false, ImportWasm: false, @@ -77,6 +80,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 a5a6ec4ca8..acad672bb0 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) } @@ -748,6 +750,9 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo 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 076ac66ec4..c0362ba050 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -59,7 +59,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" - "github.com/offchainlabs/nitro/staker" + legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/staker/validatorwallet" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/dbutil" @@ -257,7 +257,7 @@ func mainImpl() int { defaultL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain) nodeConfig.Node.Staker.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain) - defaultValidatorL1WalletConfig := staker.DefaultValidatorL1WalletConfig + defaultValidatorL1WalletConfig := legacystaker.DefaultValidatorL1WalletConfig defaultValidatorL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain) nodeConfig.Node.BatchPoster.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain) @@ -290,11 +290,11 @@ 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) } - if strategy != staker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator { + if strategy != legacystaker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator { nodeConfig.Node.BlockValidator.Enable = true } } @@ -466,24 +466,29 @@ func mainImpl() int { fatalErrChan := make(chan error, 10) - var blocksReExecutor *blocksreexecutor.BlocksReExecutor if nodeConfig.BlocksReExecutor.Enable && l2BlockChain != nil { - blocksReExecutor = blocksreexecutor.New(&nodeConfig.BlocksReExecutor, l2BlockChain, fatalErrChan) - 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 !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 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: } } @@ -635,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) 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.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 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..69535e82be 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,20 +27,22 @@ 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" "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" "github.com/offchainlabs/nitro/arbos/arbostypes" "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" @@ -901,7 +904,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/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/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 b1075d3786..4f47f4c6ea 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit b1075d3786b28a6a3a06fe0e0ab8d1cdecc72f55 +Subproject commit 4f47f4c6eafd81290d51a7f11fbd99bc2fc3c5a6 diff --git a/go.mod b/go.mod index 488d455f44..7a48b0520d 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ replace github.com/VictoriaMetrics/fastcache => ./fastcache replace github.com/ethereum/go-ethereum => ./go-ethereum +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 @@ -18,11 +20,11 @@ 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 - github.com/ethereum/go-ethereum v1.10.26 + github.com/ethereum/go-ethereum v1.13.15 github.com/fatih/structtag v1.2.0 github.com/gdamore/tcell/v2 v2.7.1 github.com/gobwas/httphead v0.1.0 @@ -36,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 @@ -44,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 @@ -58,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 @@ -65,21 +68,24 @@ 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 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 + gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( - github.com/DataDog/zstd v1.4.5 // indirect + github.com/DataDog/zstd v1.5.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.1 // indirect github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 // indirect @@ -98,17 +104,17 @@ require ( github.com/aws/smithy-go v1.22.0 // indirect 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.2.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash/v2 v2.3.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 @@ -117,13 +123,13 @@ 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 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 @@ -137,6 +143,7 @@ require ( github.com/google/flatbuffers v1.12.1 // indirect github.com/google/go-github/v62 v62.0.0 github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect + github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/graph-gophers/graphql-go v1.3.0 // indirect github.com/h2non/filetype v1.0.6 // indirect @@ -145,6 +152,7 @@ require ( github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect + github.com/jmoiron/sqlx v1.3.5 // indirect github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 // indirect github.com/juju/loggo v0.0.0-20180524022052-584905176618 // indirect github.com/klauspost/compress v1.17.2 // indirect @@ -154,7 +162,8 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/mattn/go-sqlite3 v1.14.6 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect @@ -163,14 +172,14 @@ require ( github.com/opentracing/opentracing-go v1.1.0 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/common v0.39.0 // indirect + github.com/prometheus/procfs v0.9.0 // indirect github.com/rhnvrm/simples3 v0.6.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/status-im/keycard-go v0.2.0 // indirect github.com/supranational/blst v0.3.11 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect @@ -181,11 +190,12 @@ require ( github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yuin/gopher-lua v1.1.1 // indirect + github.com/yusufpapurcu/wmi v1.2.2 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.22.0 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/go.sum b/go.sum index d11610724e..55ad86267a 100644 --- a/go.sum +++ b/go.sum @@ -1,75 +1,29 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= cloud.google.com/go/auth v0.6.1 h1:T0Zw1XM5c1GlpN2HYr2s+m3vr1p2wy+8VN+Z1FKxW38= cloud.google.com/go/auth v0.6.1/go.mod h1:eFHG7zDzbXHKmjJddFG/rBlcGp6t25SwRUiEQSlO4x4= cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/iam v1.1.8 h1:r7umDwhj+BQyz0ScZMp4QrGXjSTI3ZINnpgU2nlB/K0= cloud.google.com/go/iam v1.1.8/go.mod h1:GvE6lyMmfxXauzNq8NbgJbeVQNspG+tcdL/W8QO1+zE= cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuAKilhU= cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -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= cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs= cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0= -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/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= 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= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= 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= @@ -80,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= @@ -131,9 +84,6 @@ 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 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= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= @@ -143,12 +93,14 @@ 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.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= -github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +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= 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= @@ -164,37 +116,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= @@ -205,7 +150,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= @@ -224,18 +168,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= @@ -248,7 +188,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= @@ -257,82 +196,48 @@ 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/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= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +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-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 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.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +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= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= 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-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.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= github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -341,17 +246,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 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/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= @@ -360,40 +260,24 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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 v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg= github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b h1:RMpPgZTSApbPf7xaVel+QkoGPRLFLrwFO89uDUHEGf0= 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/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= @@ -402,12 +286,10 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= -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/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/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +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.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= @@ -430,7 +312,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= @@ -450,31 +331,15 @@ 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/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +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/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= @@ -487,26 +352,12 @@ 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/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/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= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= @@ -518,39 +369,28 @@ 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= 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/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/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/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= @@ -570,18 +410,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/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 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= @@ -590,7 +418,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= @@ -600,46 +427,26 @@ 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.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -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= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/r3labs/diff/v3 v3.0.1 h1:CBKqf3XmNRHXKmdU7mZP1w7TV0pDyVCis1AUHtA4Xtg= github.com/r3labs/diff/v3 v3.0.1/go.mod h1:f1S9bourRbiM66NskseyUdo0fTmEE0qKrikYJX63dgo= github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= @@ -652,46 +459,29 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= 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/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/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= -github.com/stretchr/objx v0.1.1/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/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= -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= @@ -709,47 +499,23 @@ 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.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= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= @@ -765,53 +531,20 @@ 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-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.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= 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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 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-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -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= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -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.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -820,56 +553,21 @@ 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-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= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 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= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/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-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -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-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-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.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= 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= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -878,78 +576,32 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-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= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= 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-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/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-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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-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= @@ -970,13 +622,10 @@ 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.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= -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= @@ -984,58 +633,17 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= 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-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.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= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -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.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= @@ -1045,87 +653,29 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= 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/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -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= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -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/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.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -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.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= @@ -1134,57 +684,36 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 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.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= 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/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= 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= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170712054546-1be3d31502d6/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= 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/nitro-testnode b/nitro-testnode index 72141dd495..fa19e22104 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 72141dd495ad965aa2a23723ea3e755037903ad7 +Subproject commit fa19e2210403ad24519ea46c2d337f54a9f47593 diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index 62ce177480..3feaca6279 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -12,9 +12,10 @@ 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" ) @@ -173,7 +174,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/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..51b2fc0cd9 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,17 +9,19 @@ 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" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -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 { @@ -180,7 +182,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/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 5a1f123693..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 ( @@ -1115,7 +1117,7 @@ func (v *BlockValidator) Reorg(ctx context.Context, count arbutil.MessageIndex) } v.validations.Delete(iPos) } - v.nextCreateStartGS = buildGlobalState(*res, endPosition) + v.nextCreateStartGS = BuildGlobalState(*res, endPosition) v.nextCreatePrevDelayed = msg.DelayedMessagesRead v.nextCreateBatchReread = true v.prevBatchCache = make(map[uint64][]byte) 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 new file mode 100644 index 0000000000..1a8eed80fa --- /dev/null +++ b/staker/bold/bold_staker.go @@ -0,0 +1,536 @@ +// Copyright 2023-2024, Offchain Labs, Inc. +// For license information, see https://github.com/offchainlabs/nitro/blob/main/LICENSE +package bold + +import ( + "context" + "errors" + "fmt" + "math/big" + "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" + "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" + 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" + "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" + "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" +) + +var assertionCreatedId common.Hash + +func init() { + rollupAbi, err := boldrollup.RollupCoreMetaData.GetAbi() + if err != nil { + panic(err) + } + assertionCreatedEvent, ok := rollupAbi.Events["AssertionCreated"] + if !ok { + panic("RollupCore ABI missing AssertionCreated event") + } + assertionCreatedId = assertionCreatedEvent.ID +} + +type BoldConfig struct { + 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. + AssertionScanningInterval time.Duration `koanf:"assertion-scanning-interval"` + // How often to confirm assertions onchain. + AssertionConfirmingInterval time.Duration `koanf:"assertion-confirming-interval"` + API bool `koanf:"api"` + APIHost string `koanf:"api-host"` + APIPort uint16 `koanf:"api-port"` + APIDBPath string `koanf:"api-db-path"` + TrackChallengeParentAssertionHashes []string `koanf:"track-challenge-parent-assertion-hashes"` + 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 { + // A name identifier for the validator for cosmetic purposes. + ValidatorName string `koanf:"validator-name"` + CheckBatchFinality bool `koanf:"check-batch-finality"` + // Path to a filesystem directory that will cache machine hashes for BOLD. + MachineLeavesCachePath string `koanf:"machine-leaves-cache-path"` +} + +var DefaultStateProviderConfig = StateProviderConfig{ + ValidatorName: "default-validator", + CheckBatchFinality: true, + MachineLeavesCachePath: "machine-hashes-cache", +} + +var DefaultBoldConfig = BoldConfig{ + Enable: false, + Strategy: "Watchtower", + AssertionPostingInterval: time.Minute * 15, + AssertionScanningInterval: time.Minute, + AssertionConfirmingInterval: time.Minute, + API: false, + APIHost: "127.0.0.1", + APIPort: 9393, + APIDBPath: "bold-api-db", + TrackChallengeParentAssertionHashes: []string{}, + CheckStakerSwitchInterval: time.Minute, // Every minute, check if the Nitro node staker should switch to using BOLD. + StateProviderConfig: DefaultStateProviderConfig, + StartValidationFromStaked: true, +} + +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+".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") + f.Duration(prefix+".check-staker-switch-interval", DefaultBoldConfig.CheckStakerSwitchInterval, "how often to check if staker can switch to bold") + f.Bool(prefix+".api", DefaultBoldConfig.API, "enable api") + f.String(prefix+".api-host", DefaultBoldConfig.APIHost, "bold api host") + f.Uint16(prefix+".api-port", DefaultBoldConfig.APIPort, "bold api port") + f.String(prefix+".api-db-path", DefaultBoldConfig.APIDBPath, "bold api db path") + f.StringSlice(prefix+".track-challenge-parent-assertion-hashes", DefaultBoldConfig.TrackChallengeParentAssertionHashes, "only track challenges/edges with these parent assertion hashes") + StateProviderConfigAddOptions(prefix+".state-provider-config", f) + f.Bool(prefix+".start-validation-from-staked", DefaultBoldConfig.StartValidationFromStaked, "assume staked nodes are valid") +} + +func StateProviderConfigAddOptions(prefix string, f *flag.FlagSet) { + f.String(prefix+".validator-name", DefaultStateProviderConfig.ValidatorName, "name identifier for cosmetic purposes") + f.Bool(prefix+".check-batch-finality", DefaultStateProviderConfig.CheckBatchFinality, "check batch finality") + f.String(prefix+".machine-leaves-cache-path", DefaultStateProviderConfig.MachineLeavesCachePath, "path to machine cache") +} + +type BOLDStaker struct { + stopwaiter.StopWaiter + config *BoldConfig + chalManager *challengemanager.Manager + blockValidator *staker.BlockValidator + statelessBlockValidator *staker.StatelessBlockValidator + rollupAddress common.Address + l1Reader *headerreader.HeaderReader + client protocol.ChainBackend + callOpts bind.CallOpts + wallet legacystaker.ValidatorWalletInterface + stakedNotifiers []legacystaker.LatestStakedNotifier + confirmedNotifiers []legacystaker.LatestConfirmedNotifier +} + +func NewBOLDStaker( + ctx context.Context, + stack *node.Node, + rollupAddress common.Address, + callOpts bind.CallOpts, + txOpts *bind.TransactOpts, + l1Reader *headerreader.HeaderReader, + blockValidator *staker.BlockValidator, + statelessBlockValidator *staker.StatelessBlockValidator, + config *BoldConfig, + dataPoster *dataposter.DataPoster, + wallet legacystaker.ValidatorWalletInterface, + 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, stack, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster) + if err != nil { + return nil, err + } + return &BOLDStaker{ + config: config, + chalManager: manager, + blockValidator: blockValidator, + statelessBlockValidator: statelessBlockValidator, + rollupAddress: rollupAddress, + l1Reader: l1Reader, + client: wrappedClient, + callOpts: callOpts, + wallet: wallet, + stakedNotifiers: stakedNotifiers, + confirmedNotifiers: confirmedNotifiers, + }, nil +} + +// 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 { + stakerAddr = b.wallet.DataPoster().Sender() + } + 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) + if err != nil { + return err + } + latestStaked, err := rollupUserLogic.LatestStakedAssertion(b.getCallOpts(ctx), walletAddressOrZero) + if err != nil { + return err + } + if latestStaked == [32]byte{} { + latestConfirmed, err := rollupUserLogic.LatestConfirmed(&bind.CallOpts{Context: ctx}) + if err != nil { + return err + } + latestStaked = latestConfirmed + } + assertion, err := readBoldAssertionCreationInfo( + ctx, + rollupUserLogic, + b.client, + b.rollupAddress, + latestStaked, + ) + if err != nil { + return err + } + afterState := protocol.GoGlobalStateFromSolidity(assertion.AfterState.GlobalState) + return b.blockValidator.InitAssumeValid(validator.GoGlobalState(afterState)) + } + return nil +} + +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) + } + + if agreedGlobalState != nil { + for _, notifier := range b.stakedNotifiers { + notifier.UpdateLatestStaked(agreedMsgCount, *agreedGlobalState) + } + } + confirmedMsgCount, confirmedGlobalState, err := b.getLatestState(ctx, true) + if err != nil { + log.Error("staker: error checking latest confirmed", "err", err) + } + + if confirmedGlobalState != nil { + for _, notifier := range b.confirmedNotifiers { + notifier.UpdateLatestConfirmed(confirmedMsgCount, *confirmedGlobalState) + } + } + return b.config.AssertionPostingInterval + }) +} + +func (b *BOLDStaker) getLatestState(ctx context.Context, confirmed bool) (arbutil.MessageIndex, *validator.GoGlobalState, error) { + var globalState protocol.GoGlobalState + var err error + if confirmed { + globalState, err = b.chalManager.LatestConfirmedState(ctx) + } else { + globalState, err = b.chalManager.LatestAgreedState(ctx) + } + var assertionType string + if confirmed { + assertionType = "confirmed" + } else { + assertionType = "agreed" + } + if err != nil { + return 0, nil, fmt.Errorf("error getting latest %s: %w", assertionType, err) + } + 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) + } + return 0, nil, fmt.Errorf("error getting message count: %w", err) + } + + if !caughtUp { + log.Info(fmt.Sprintf("latest %s assertion not yet in our node", assertionType), "state", globalState) + return 0, nil, nil + } + + processedCount, err := b.statelessBlockValidator.InboxStreamer().GetProcessedMessageCount() + if err != nil { + return 0, nil, err + } + + if processedCount < count { + log.Info("execution catching up to rollup", "rollupCount", count, "processedCount", processedCount) + return 0, nil, nil + } + + return count, (*validator.GoGlobalState)(&globalState), nil +} + +func (b *BOLDStaker) StopAndWait() { + b.chalManager.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 + return &opts +} + +// Sets up a BOLD challenge manager implementation by providing it with +// its necessary dependencies and configuration. The challenge manager can then be started, as it +// 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, + client protocol.ChainBackend, + blockValidator *staker.BlockValidator, + statelessBlockValidator *staker.StatelessBlockValidator, + config *BoldConfig, + dataPoster *dataposter.DataPoster, +) (*challengemanager.Manager, error) { + // Initializes the BOLD contract bindings and the assertion chain abstraction. + rollupBindings, err := boldrollup.NewRollupUserLogic(rollupAddress, client) + if err != nil { + return nil, fmt.Errorf("could not create rollup bindings: %w", err) + } + chalManager, err := rollupBindings.ChallengeManager(&bind.CallOpts{}) + 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) + } + + 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()) + + 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( + blockValidator, + statelessBlockValidator, + // Specify the height constants needed for the state provider. + // 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) + } + providerHeights := []l2stateprovider.Height{blockChallengeLeafHeight} + for i := uint8(0); i < numBigSteps; i++ { + providerHeights = append(providerHeights, bigStepHeight) + } + providerHeights = append(providerHeights, smallStepHeight) + provider := l2stateprovider.NewHistoryCommitmentProvider( + stateProvider, + stateProvider, + stateProvider, + providerHeights, + stateProvider, + nil, // Nil API database for the history commitment provider, as it will be provided later. TODO: Improve this dependency injection. + ) + // The interval at which the challenge manager will attempt to post assertions. + postingInterval := config.AssertionPostingInterval + // The interval at which the manager will scan for newly created assertions onchain. + scanningInterval := config.AssertionScanningInterval + // The interval at which the manager will attempt to confirm assertions. + confirmingInterval := config.AssertionConfirmingInterval + + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName(config.StateProviderConfig.ValidatorName), + challengemanager.StackWithMode(BoldModes[config.strategy]), + challengemanager.StackWithPollingInterval(scanningInterval), + 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) + stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, apiDBPath)) + } + + manager, err := challengemanager.NewChallengeStack( + assertionChain, + provider, + stackOpts..., + ) + if err != nil { + return nil, fmt.Errorf("could not create challenge manager: %w", err) + } + return manager, nil +} + +// Read the creation info for an assertion by looking up its creation +// event from the rollup contracts. +func readBoldAssertionCreationInfo( + ctx context.Context, + rollup *boldrollup.RollupUserLogic, + client bind.ContractFilterer, + rollupAddress common.Address, + assertionHash common.Hash, +) (*protocol.AssertionCreatedInfo, error) { + var creationBlock uint64 + var topics [][]common.Hash + if assertionHash == (common.Hash{}) { + rollupDeploymentBlock, err := rollup.RollupDeploymentBlock(&bind.CallOpts{Context: ctx}) + if err != nil { + return nil, err + } + if !rollupDeploymentBlock.IsUint64() { + return nil, errors.New("rollup deployment block was not a uint64") + } + creationBlock = rollupDeploymentBlock.Uint64() + } else { + var b [32]byte + copy(b[:], assertionHash[:]) + node, err := rollup.GetAssertion(&bind.CallOpts{Context: ctx}, b) + if err != nil { + return nil, err + } + creationBlock = node.CreatedAtBlock + } + topics = [][]common.Hash{{assertionCreatedId}, {assertionHash}} + var query = ethereum.FilterQuery{ + FromBlock: new(big.Int).SetUint64(creationBlock), + ToBlock: new(big.Int).SetUint64(creationBlock), + Addresses: []common.Address{rollupAddress}, + Topics: topics, + } + logs, err := client.FilterLogs(ctx, query) + if err != nil { + return nil, err + } + if len(logs) == 0 { + return nil, errors.New("no assertion creation logs found") + } + if len(logs) > 1 { + return nil, errors.New("found multiple instances of requested node") + } + ethLog := logs[0] + parsedLog, err := rollup.ParseAssertionCreated(ethLog) + if err != nil { + return nil, err + } + afterState := parsedLog.Assertion.AfterState + return &protocol.AssertionCreatedInfo{ + ConfirmPeriodBlocks: parsedLog.ConfirmPeriodBlocks, + RequiredStake: parsedLog.RequiredStake, + ParentAssertionHash: protocol.AssertionHash{Hash: parsedLog.ParentAssertionHash}, + BeforeState: parsedLog.Assertion.BeforeState, + AfterState: afterState, + InboxMaxCount: parsedLog.InboxMaxCount, + AfterInboxBatchAcc: parsedLog.AfterInboxBatchAcc, + AssertionHash: protocol.AssertionHash{Hash: parsedLog.AssertionHash}, + WasmModuleRoot: parsedLog.WasmModuleRoot, + ChallengeManager: parsedLog.ChallengeManager, + TransactionHash: ethLog.TxHash, + CreationBlock: ethLog.BlockNumber, + }, nil +} diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go new file mode 100644 index 0000000000..48b7cbd91e --- /dev/null +++ b/staker/bold/bold_state_provider.go @@ -0,0 +1,542 @@ +// Copyright 2023, Offchain Labs, Inc. +// For license information, see +// https://github.com/offchainlabs/bold/blob/main/LICENSE +package bold + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethdb" + "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" + "github.com/offchainlabs/nitro/validator" + "github.com/offchainlabs/nitro/validator/server_arb" +) + +var ( + _ l2stateprovider.ProofCollector = (*BOLDStateProvider)(nil) + _ l2stateprovider.L2MessageStateCollector = (*BOLDStateProvider)(nil) + _ l2stateprovider.MachineHashCollector = (*BOLDStateProvider)(nil) + _ l2stateprovider.ExecutionProvider = (*BOLDStateProvider)(nil) +) + +var executionNodeOfflineGauge = metrics.NewRegisteredGauge("arb/state_provider/execution_node_offline", nil) + +var ( + ErrChainCatchingUp = errors.New("chain catching up") +) + +type BOLDStateProvider struct { + validator *staker.BlockValidator + statelessValidator *staker.StatelessBlockValidator + historyCache challengecache.HistoryCommitmentCacher + blockChallengeLeafHeight l2stateprovider.Height + stateProviderConfig *StateProviderConfig + sync.RWMutex +} + +func NewBOLDStateProvider( + blockValidator *staker.BlockValidator, + statelessValidator *staker.StatelessBlockValidator, + blockChallengeLeafHeight l2stateprovider.Height, + stateProviderConfig *StateProviderConfig, + machineHashesCachePath string, +) (*BOLDStateProvider, error) { + historyCache, err := challengecache.New(machineHashesCachePath) + if err != nil { + return nil, err + } + sp := &BOLDStateProvider{ + validator: blockValidator, + statelessValidator: statelessValidator, + historyCache: historyCache, + blockChallengeLeafHeight: blockChallengeLeafHeight, + stateProviderConfig: stateProviderConfig, + } + return sp, nil +} + +// ExecutionStateAfterPreviousState Produces the L2 execution state for the next +// 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. +func (s *BOLDStateProvider) ExecutionStateAfterPreviousState( + ctx context.Context, + maxSeqInboxCount uint64, + previousGlobalState protocol.GoGlobalState, +) (*protocol.ExecutionState, error) { + if maxSeqInboxCount == 0 { + return nil, errors.New("max inbox count cannot be zero") + } + 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, maxSeqInboxCount) + } + 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, maxSeqInboxCount) + } + 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)) + 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. + stateValidatedAndMessageCountPastThreshold, err := s.isStateValidatedAndMessageCountPastThreshold(ctx, globalState, messageCount) + if err != nil { + return nil, err + } + if !stateValidatedAndMessageCountPastThreshold { + return nil, fmt.Errorf("%w: batch count %d", l2stateprovider.ErrChainCatchingUp, maxSeqInboxCount) + } + + executionState := &protocol.ExecutionState{ + GlobalState: protocol.GoGlobalState(globalState), + MachineStatus: protocol.MachineStatusFinished, + } + toBatch := executionState.GlobalState.Batch + historyCommitStates, _, err := s.StatesInBatchRange( + ctx, + previousGlobalState, + toBatch, + l2stateprovider.Height(maxNumberOfBlocks), + ) + if err != nil { + return nil, err + } + historyCommit, err := history.NewCommitment(historyCommitStates, maxNumberOfBlocks+1) + if err != nil { + return nil, err + } + executionState.EndHistoryRoot = historyCommit.Merkle + return executionState, nil +} + +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. + return true, nil + } + lastValidatedGs, err := s.validator.ReadLastValidatedInfo() + if err != nil { + return false, err + } + if lastValidatedGs == nil { + return false, ErrChainCatchingUp + } + stateValidated := gs.Batch < lastValidatedGs.GlobalState.Batch || (gs.Batch == lastValidatedGs.GlobalState.Batch && gs.PosInBatch <= lastValidatedGs.GlobalState.PosInBatch) + return stateValidated, nil +} + +func (s *BOLDStateProvider) StatesInBatchRange( + ctx context.Context, + fromState protocol.GoGlobalState, + batchLimit uint64, + toHeight l2stateprovider.Height, +) ([]common.Hash, []validator.GoGlobalState, error) { + // Check the integrity of the arguments. + 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 := uint64(toHeight + 1) + machineHashes := make([]common.Hash, 0) + states := make([]validator.GoGlobalState, 0) + + var prevBatchMsgCount arbutil.MessageIndex + var err error + 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 := 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() + } + executionResult, err := s.statelessValidator.InboxStreamer().ResultAtCount(arbutil.MessageIndex(pos)) + if err != nil { + return nil, nil, err + } + state := validator.GoGlobalState{ + BlockHash: executionResult.BlockHash, + SendRoot: executionResult.SendRoot, + Batch: batchNum, + PosInBatch: posInBatch, + } + states = append(states, state) + machineHashes = append(machineHashes, machineHash(state)) + if batchNum >= batchLimit { + break + } + // Check if the next message is in the next batch. + if uint64(pos+1) == uint64(currBatchMsgCount) { + 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. + if uint64(len(states)) < totalDesiredHashes && batchNum < batchLimit { + currBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(batchNum) + if err != nil { + return nil, nil, err + } + } + } else { + posInBatch++ + } + } + return machineHashes, states, nil +} + +func machineHash(gs validator.GoGlobalState) common.Hash { + return crypto.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) +} + +func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbutil.MessageIndex, batchIndex l2stateprovider.Batch) (validator.GoGlobalState, error) { + var prevBatchMsgCount arbutil.MessageIndex + var err error + if batchIndex > 0 { + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(batchIndex) - 1) + if err != nil { + return validator.GoGlobalState{}, err + } + if prevBatchMsgCount > count { + 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) + if err != nil { + return validator.GoGlobalState{}, fmt.Errorf("%s: could not check if we have result at count %d: %w", s.stateProviderConfig.ValidatorName, count, err) + } + return validator.GoGlobalState{ + BlockHash: res.BlockHash, + SendRoot: res.SendRoot, + Batch: uint64(batchIndex), + PosInBatch: uint64(count - prevBatchMsgCount), + }, 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. +func (s *BOLDStateProvider) L2MessageStatesUpTo( + ctx context.Context, + fromState protocol.GoGlobalState, + batchLimit l2stateprovider.Batch, + toHeight option.Option[l2stateprovider.Height], +) ([]common.Hash, error) { + var to l2stateprovider.Height + if !toHeight.IsNone() { + to = toHeight.Unwrap() + } else { + to = s.blockChallengeLeafHeight + } + items, _, err := s.StatesInBatchRange(ctx, fromState, uint64(batchLimit), to) + if err != nil { + return nil, err + } + return items, nil +} + +// 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() + batchLimit := cfg.AssertionMetadata.BatchLimit + messageNum, err := s.messageNum(cfg.AssertionMetadata, cfg.BlockChallengeHeight) + if err != nil { + return nil, err + } + // Check if we have a virtual global state. + vs, err := s.virtualState(messageNum, batchLimit) + if err != nil { + return nil, err + } + if vs.IsSome() { + m := server_arb.NewFinishedMachine(vs.Unwrap()) + 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) + } + messageResult, err := s.statelessValidator.InboxStreamer().ResultAtCount(arbutil.MessageIndex(messageNum + 1)) + if err != nil { + return nil, err + } + cacheKey := &challengecache.Key{ + RollupBlockHash: messageResult.BlockHash, + WavmModuleRoot: cfg.AssertionMetadata.WasmModuleRoot, + MessageHeight: uint64(messageNum), + StepHeights: stepHeights, + } + if s.historyCache != nil { + cachedRoots, err := s.historyCache.Get(cacheKey, cfg.NumDesiredHashes) + switch { + case err == nil: + log.Info( + "In collect machine hashes", + "cfg", fmt.Sprintf("%+v", cfg), + "firstHash", fmt.Sprintf("%#x", cachedRoots[0]), + "lastHash", fmt.Sprintf("%#x", cachedRoots[len(cachedRoots)-1]), + ) + return cachedRoots, nil + case !errors.Is(err, challengecache.ErrNotFoundInCache): + return nil, err + } + } + entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum) + if err != nil { + return nil, err + } + input, err := entry.ToInput([]ethdb.WasmTarget{rawdb.TargetWavm}) + if err != nil { + return nil, err + } + // TODO: Enable Redis streams. + wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx) + 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) + result, err := stepLeaves.Await(ctxCheckAlive) + if err != nil { + return nil, err + } + log.Info(fmt.Sprintf("Finished gathering machine hashes for request %+v", cfg)) + // 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 { + if !errors.Is(err, challengecache.ErrFileAlreadyExists) { + return nil, err + } + } + } + return result, nil +} + +// 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 + bNum := md.FromState.Batch + posInBatch := md.FromState.PosInBatch + if bNum > 0 { + var err error + prevBatchMsgCount, err = s.statelessValidator.InboxTracker().GetBatchMessageCount(uint64(bNum - 1)) + if err != nil { + return 0, fmt.Errorf("could not get prevBatchMsgCount at %d: %w", bNum-1, err) + } + } + return prevBatchMsgCount + arbutil.MessageIndex(posInBatch) + arbutil.MessageIndex(chalHeight), nil +} + +// 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. +// +// 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 gs, fmt.Errorf("could not get limitMsgCount at %d: %w", limit, err) + } + 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 +// 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. + ctx, cancel := context.WithCancel(ctxIn) + go func() { + // 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() + for { + select { + 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(ctx, 5*time.Second) + err := execRun.CheckAlive(ctxCheckAliveWithTimeout) + if err != nil { + executionNodeOfflineGauge.Inc(1) + cancelCheckAliveWithTimeout() + return + } + cancelCheckAliveWithTimeout() + } + } + }() + return ctx, cancel +} + +// CollectProof collects a one-step proof at a message number and OpcodeIndex. +func (s *BOLDStateProvider) CollectProof( + ctx context.Context, + assertionMetadata *l2stateprovider.AssociatedAssertionMetadata, + blockChallengeHeight l2stateprovider.Height, + 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 { + return nil, err + } + 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) + if err != nil { + return nil, err + } + input, err := entry.ToInput([]ethdb.WasmTarget{rawdb.TargetWavm}) + if err != nil { + return nil, err + } + log.Info( + "Getting machine OSP", + "fromBatch", assertionMetadata.FromState.Batch, + "fromPosInBatch", assertionMetadata.FromState.PosInBatch, + "blockChallengeHeight", blockChallengeHeight, + "messageNum", messageNum, + "machineIndex", machineIndex, + "startState", fmt.Sprintf("%+v", input.StartState), + ) + wasmModRoot := assertionMetadata.WasmModuleRoot + execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx) + if err != nil { + return nil, err + } + defer execRun.Close() + ctxCheckAlive, cancelCheckAlive := ctxWithCheckAlive(ctx, execRun) + defer cancelCheckAlive() + oneStepProofPromise := execRun.GetProofAt(uint64(machineIndex)) + return oneStepProofPromise.Await(ctxCheckAlive) +} diff --git a/staker/bold/data_poster_transactor.go b/staker/bold/data_poster_transactor.go new file mode 100644 index 0000000000..aa5f8d9768 --- /dev/null +++ b/staker/bold/data_poster_transactor.go @@ -0,0 +1,44 @@ +// 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() { + select { + case <-time.After(100 * time.Millisecond): + case <-ctx.Done(): + return nil, ctx.Err() + } + } + 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/challenge-cache/cache.go b/staker/challenge-cache/cache.go index 5dca2764e8..98310c742a 100644 --- a/staker/challenge-cache/cache.go +++ b/staker/challenge-cache/cache.go @@ -79,29 +79,21 @@ 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.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 // 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 @@ -217,11 +209,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 +228,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 40be627b7a..4328ceee12 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, @@ -212,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")) @@ -324,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{ @@ -424,8 +406,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 +415,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/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/block_challenge_backend.go b/staker/legacy/block_challenge_backend.go similarity index 96% rename from staker/block_challenge_backend.go rename to staker/legacy/block_challenge_backend.go index 0dd89865bd..969c482586 100644 --- a/staker/block_challenge_backend.go +++ b/staker/legacy/block_challenge_backend.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -13,19 +13,21 @@ 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" "github.com/offchainlabs/nitro/validator" ) type BlockChallengeBackend struct { - streamer TransactionStreamerInterface + streamer staker.TransactionStreamerInterface startMsgCount arbutil.MessageIndex startPosition uint64 endPosition uint64 startGs validator.GoGlobalState endGs validator.GoGlobalState - inboxTracker InboxTrackerInterface + inboxTracker staker.InboxTrackerInterface tooFarStartsAtPosition uint64 } @@ -35,8 +37,8 @@ var _ ChallengeBackend = (*BlockChallengeBackend)(nil) func NewBlockChallengeBackend( initialState *challengegen.ChallengeManagerInitiatedChallenge, maxBatchesRead uint64, - streamer TransactionStreamerInterface, - inboxTracker InboxTrackerInterface, + streamer staker.TransactionStreamerInterface, + inboxTracker staker.InboxTrackerInterface, ) (*BlockChallengeBackend, error) { startGs := validator.GoGlobalStateFromSolidity(initialState.StartState) diff --git a/staker/challenge_manager.go b/staker/legacy/challenge_manager.go similarity index 97% rename from staker/challenge_manager.go rename to staker/legacy/challenge_manager.go index 27cb92a5c7..1aa13a9e05 100644 --- a/staker/challenge_manager.go +++ b/staker/legacy/challenge_manager.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -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" @@ -19,8 +19,10 @@ 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/staker" "github.com/offchainlabs/nitro/validator" ) @@ -48,7 +50,7 @@ type ChallengeBackend interface { } // Assert that ExecutionChallengeBackend implements ChallengeBackend -var _ ChallengeBackend = (*ExecutionChallengeBackend)(nil) +var _ ChallengeBackend = (*staker.ExecutionChallengeBackend)(nil) type challengeCore struct { con *challengegen.ChallengeManager @@ -69,13 +71,13 @@ type ChallengeManager struct { blockChallengeBackend *BlockChallengeBackend // fields below are only used to create execution challenge from block challenge - validator *StatelessBlockValidator + validator *staker.StatelessBlockValidator maxBatchesRead uint64 wasmModuleRoot common.Hash // these fields are empty until working on execution challenge initialMachineMessageCount arbutil.MessageIndex - executionChallengeBackend *ExecutionChallengeBackend + executionChallengeBackend *staker.ExecutionChallengeBackend machineFinalStepCount uint64 } @@ -88,7 +90,7 @@ func NewChallengeManager( fromAddr common.Address, challengeManagerAddr common.Address, challengeIndex uint64, - val *StatelessBlockValidator, + val *staker.StatelessBlockValidator, startL1Block uint64, confirmationBlocks int64, ) (*ChallengeManager, error) { @@ -128,8 +130,8 @@ func NewChallengeManager( backend, err := NewBlockChallengeBackend( parsedLog, challengeInfo.MaxInboxMessages, - val.streamer, - val.inboxTracker, + val.InboxStreamer(), + val.InboxTracker(), ) if err != nil { return nil, fmt.Errorf("error creating block challenge backend for challenge %v: %w", challengeIndex, err) @@ -166,7 +168,7 @@ func NewExecutionChallengeManager( if err != nil { return nil, err } - backend, err := NewExecutionChallengeBackend(exec) + backend, err := staker.NewExecutionChallengeBackend(exec) if err != nil { return nil, err } @@ -481,9 +483,9 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint } input.BatchInfo = prunedBatches var execRun validator.ExecutionRun - for _, spawner := range m.validator.execSpawners { + for _, spawner := range m.validator.ExecutionSpawners() { if validator.SpawnerSupportsModule(spawner, m.wasmModuleRoot) { - execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input).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) } @@ -493,7 +495,7 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint if execRun == nil { return fmt.Errorf("did not find valid execution backend") } - backend, err := NewExecutionChallengeBackend(execRun) + backend, err := staker.NewExecutionChallengeBackend(execRun) if err != nil { return err } diff --git a/staker/challenge_test.go b/staker/legacy/challenge_test.go similarity index 93% rename from staker/challenge_test.go rename to staker/legacy/challenge_test.go index 33f1644c63..a34e4e885d 100644 --- a/staker/challenge_test.go +++ b/staker/legacy/challenge_test.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -17,9 +17,10 @@ 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" "github.com/offchainlabs/nitro/solgen/go/ospgen" "github.com/offchainlabs/nitro/validator" @@ -97,12 +98,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 +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) @@ -258,31 +259,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/staker/common_test.go b/staker/legacy/common_test.go similarity index 95% rename from staker/common_test.go rename to staker/legacy/common_test.go index eec6882fde..06ebeeffa3 100644 --- a/staker/common_test.go +++ b/staker/legacy/common_test.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "testing" diff --git a/staker/fast_confirm.go b/staker/legacy/fast_confirm.go similarity index 94% rename from staker/fast_confirm.go rename to staker/legacy/fast_confirm.go index 5dc7f01205..13ce32b849 100644 --- a/staker/fast_confirm.go +++ b/staker/legacy/fast_confirm.go @@ -1,7 +1,7 @@ // Copyright 2023-2024, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -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/l1_validator.go b/staker/legacy/l1_validator.go similarity index 90% rename from staker/l1_validator.go rename to staker/legacy/l1_validator.go index 5b0c211324..f88ab93d0e 100644 --- a/staker/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -10,19 +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 @@ -43,7 +44,7 @@ const ( ) type L1Validator struct { - rollup *RollupWatcher + rollup *staker.RollupWatcher rollupAddress common.Address validatorUtils *rollupgen.ValidatorUtils client *ethclient.Client @@ -51,9 +52,9 @@ type L1Validator struct { wallet ValidatorWalletInterface callOpts bind.CallOpts - inboxTracker InboxTrackerInterface - txStreamer TransactionStreamerInterface - blockValidator *BlockValidator + inboxTracker staker.InboxTrackerInterface + txStreamer staker.TransactionStreamerInterface + blockValidator *staker.BlockValidator lastWasmModuleRoot common.Hash } @@ -61,16 +62,17 @@ func NewL1Validator( client *ethclient.Client, wallet ValidatorWalletInterface, validatorUtilsAddress common.Address, + gasRefunder common.Address, callOpts bind.CallOpts, - inboxTracker InboxTrackerInterface, - txStreamer TransactionStreamerInterface, - blockValidator *BlockValidator, + 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 := NewRollupWatcher(wallet.RollupAddress(), builder, callOpts) + rollup, err := staker.NewRollupWatcher(wallet.RollupAddress(), wallet.L1Client(), callOpts) if err != nil { return nil, err } @@ -102,8 +104,7 @@ func (v *L1Validator) getCallOpts(ctx context.Context) *bind.CallOpts { } func (v *L1Validator) Initialize(ctx context.Context) error { - err := v.rollup.Initialize(ctx) - if err != nil { + if err := v.rollup.Initialize(ctx); err != nil { return err } return v.updateBlockValidatorModuleRoot(ctx) @@ -141,7 +142,7 @@ func (v *L1Validator) resolveTimedOutChallenges(ctx context.Context) (*types.Tra return v.wallet.TimeoutChallenges(ctx, challengesToEliminate) } -func (v *L1Validator) resolveNextNode(ctx context.Context, info *StakerInfo, latestConfirmedNode *uint64) (bool, error) { +func (v *L1Validator) resolveNextNode(ctx context.Context, info *staker.StakerInfo, latestConfirmedNode *uint64) (bool, error) { callOpts := v.getCallOpts(ctx) confirmType, err := v.validatorUtils.CheckDecidableNextNode(callOpts, v.rollupAddress) if err != nil { @@ -159,11 +160,7 @@ func (v *L1Validator) resolveNextNode(ctx context.Context, info *StakerInfo, lat 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 *StakerInfo, lat } 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 } @@ -205,7 +198,7 @@ func (v *L1Validator) isRequiredStakeElevated(ctx context.Context) (bool, error) } type createNodeAction struct { - assertion *Assertion + assertion *staker.Assertion prevInboxMaxCount *big.Int hash common.Hash } @@ -222,7 +215,7 @@ type OurStakerInfo struct { LatestStakedNodeHash common.Hash CanProgress bool StakeExists bool - *StakerInfo + *staker.StakerInfo } func (v *L1Validator) generateNodeAction( @@ -266,16 +259,16 @@ func (v *L1Validator) generateNodeAction( return nil, false, nil } - caughtUp, startCount, err := GlobalStateToMsgCount(v.inboxTracker, v.txStreamer, startState.GlobalState) + caughtUp, startCount, err := staker.GlobalStateToMsgCount(v.inboxTracker, v.txStreamer, startState.GlobalState) if err != nil { return nil, false, fmt.Errorf("start state not in chain: %w", err) } if !caughtUp { - target := GlobalStatePosition{ + target := staker.GlobalStatePosition{ BatchNumber: startState.GlobalState.Batch, PosInBatch: startState.GlobalState.PosInBatch, } - var current GlobalStatePosition + var current staker.GlobalStatePosition head, err := v.txStreamer.GetProcessedMessageCount() if err != nil { _, current, err = v.blockValidator.GlobalStatePositionsAtCount(head) @@ -296,7 +289,7 @@ func (v *L1Validator) generateNodeAction( return nil, false, err } validatedGlobalState = valInfo.GlobalState - caughtUp, validatedCount, err = GlobalStateToMsgCount( + caughtUp, validatedCount, err = staker.GlobalStateToMsgCount( v.inboxTracker, v.txStreamer, valInfo.GlobalState, ) if err != nil { @@ -355,11 +348,11 @@ func (v *L1Validator) generateNodeAction( if err != nil { return nil, false, err } - _, gsPos, err := GlobalStatePositionsAtCount(v.inboxTracker, validatedCount, batchNum) + _, gsPos, err := staker.GlobalStatePositionsAtCount(v.inboxTracker, validatedCount, batchNum) if err != nil { return nil, false, fmt.Errorf("%w: failed calculating GSposition for count %d", err, validatedCount) } - validatedGlobalState = buildGlobalState(*execResult, gsPos) + validatedGlobalState = staker.BuildGlobalState(*execResult, gsPos) } currentL1BlockNum, err := v.client.BlockNumber(ctx) @@ -426,8 +419,8 @@ func (v *L1Validator) generateNodeAction( log.Error("Found incorrect assertion: Machine status not finished", "node", nd.NodeNum, "machineStatus", nd.Assertion.AfterState.MachineStatus) continue } - caughtUp, nodeMsgCount, err := GlobalStateToMsgCount(v.inboxTracker, v.txStreamer, afterGS) - if errors.Is(err, ErrGlobalStateNotInChain) { + caughtUp, nodeMsgCount, err := staker.GlobalStateToMsgCount(v.inboxTracker, v.txStreamer, afterGS) + if errors.Is(err, staker.ErrGlobalStateNotInChain) { wrongNodesExist = true log.Error("Found incorrect assertion", "node", nd.NodeNum, "afterGS", afterGS, "err", err) continue @@ -510,7 +503,7 @@ func (v *L1Validator) createNewNodeAction( hasSiblingByte[0] = 1 } assertionNumBlocks := uint64(validatedCount - startCount) - assertion := &Assertion{ + assertion := &staker.Assertion{ BeforeState: startState, AfterState: &validator.ExecutionState{ GlobalState: validatedGS, @@ -540,13 +533,13 @@ func (v *L1Validator) createNewNodeAction( } // Returns (execution state, inbox max count, L1 block proposed, parent chain block proposed, error) -func lookupNodeStartState(ctx context.Context, rollup *RollupWatcher, nodeNum uint64, nodeHash common.Hash) (*validator.ExecutionState, *big.Int, uint64, uint64, error) { +func lookupNodeStartState(ctx context.Context, rollup *staker.RollupWatcher, nodeNum uint64, nodeHash common.Hash) (*validator.ExecutionState, *big.Int, uint64, uint64, error) { if nodeNum == 0 { creationEvent, err := rollup.LookupCreation(ctx) if err != nil { return nil, nil, 0, 0, fmt.Errorf("error looking up rollup creation event: %w", err) } - l1BlockNumber, err := arbutil.CorrespondingL1BlockNumber(ctx, rollup.client, creationEvent.Raw.BlockNumber) + l1BlockNumber, err := arbutil.CorrespondingL1BlockNumber(ctx, rollup.Client(), creationEvent.Raw.BlockNumber) if err != nil { return nil, nil, 0, 0, err } 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..a5dc5400a7 100644 --- a/validator/server_arb/mock_machine.go +++ b/staker/legacy/mock_machine_test.go @@ -1,33 +1,37 @@ // 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 +61,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/staker/staker.go b/staker/legacy/staker.go similarity index 92% rename from staker/staker.go rename to staker/legacy/staker.go index 45e6f6f551..fa74be327f 100644 --- a/staker/staker.go +++ b/staker/legacy/staker.go @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package staker +package legacystaker import ( "context" @@ -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,14 +22,12 @@ 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" "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/solgen/go/rollupgen" - "github.com/offchainlabs/nitro/staker/txbuilder" + "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" @@ -100,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": @@ -113,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) } } @@ -131,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 } @@ -143,7 +144,12 @@ func (c *L1ValidatorConfig) Validate() error { return nil } -type L1ValidatorConfigFetcher func() *L1ValidatorConfig +func (c *L1ValidatorConfig) GasRefunder() common.Address { + return c.gasRefunder +} +func (c *L1ValidatorConfig) StrategyType() StakerStrategy { + return c.strategy +} var DefaultL1ValidatorConfig = L1ValidatorConfig{ Enable: true, @@ -252,6 +258,8 @@ type validatedNode struct { hash common.Hash } +type L1ValidatorConfigFetcher func() *L1ValidatorConfig + type Staker struct { *L1Validator stopwaiter.StopWaiter @@ -266,8 +274,8 @@ type Staker struct { inactiveLastCheckedNode *nodeAndHash inactiveValidatedNodes *btree.BTreeG[validatedNode] bringActiveUntilNode uint64 - inboxReader InboxReaderInterface - statelessBlockValidator *StatelessBlockValidator + inboxReader staker.InboxReaderInterface + statelessBlockValidator *staker.StatelessBlockValidator fatalErr chan<- error fastConfirmSafe *FastConfirmSafe } @@ -283,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 @@ -298,8 +306,8 @@ func NewStaker( wallet ValidatorWalletInterface, callOpts bind.CallOpts, config L1ValidatorConfigFetcher, - blockValidator *BlockValidator, - statelessBlockValidator *StatelessBlockValidator, + blockValidator *staker.BlockValidator, + statelessBlockValidator *staker.StatelessBlockValidator, stakedNotifiers []LatestStakedNotifier, confirmedNotifiers []LatestConfirmedNotifier, validatorUtilsAddress common.Address, @@ -309,8 +317,8 @@ func NewStaker( return nil, err } client := l1Reader.Client() - val, err := NewL1Validator(client, wallet, validatorUtilsAddress, callOpts, - statelessBlockValidator.inboxTracker, statelessBlockValidator.streamer, blockValidator) + val, err := NewL1Validator(client, wallet, validatorUtilsAddress, config().GasRefunder(), callOpts, + statelessBlockValidator.InboxTracker(), statelessBlockValidator.InboxStreamer(), blockValidator) if err != nil { return nil, err } @@ -330,7 +338,7 @@ func NewStaker( config: config, highGasBlocksBuffer: big.NewInt(config().PostingStrategy.HighGasDelayBlocks), lastActCalledBlock: nil, - inboxReader: statelessBlockValidator.inboxReader, + inboxReader: statelessBlockValidator.InboxReader(), statelessBlockValidator: statelessBlockValidator, fatalErr: fatalErr, inactiveValidatedNodes: inactiveValidatedNodes, @@ -346,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 { @@ -406,7 +429,7 @@ func (s *Staker) setupFastConfirmation(ctx context.Context) error { fastConfirmer, s.builder, s.wallet, - cfg.gasRefunder, + cfg.GasRefunder(), s.l1Reader, ) if err != nil { @@ -443,23 +466,20 @@ 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 } -func (s *Staker) getLatestStakedState(ctx context.Context, staker common.Address) (uint64, arbutil.MessageIndex, *validator.GoGlobalState, error) { +func (s *Staker) getLatestStakedState(ctx context.Context, stakerAddress common.Address) (uint64, arbutil.MessageIndex, *validator.GoGlobalState, error) { callOpts := s.getCallOpts(ctx) if s.l1Reader.UseFinalityData() { callOpts.BlockNumber = big.NewInt(int64(rpc.FinalizedBlockNumber)) } - latestStaked, _, err := s.validatorUtils.LatestStaked(s.getCallOpts(ctx), s.rollupAddress, staker) + latestStaked, _, err := s.validatorUtils.LatestStaked(s.getCallOpts(ctx), s.rollupAddress, stakerAddress) if err != nil { - return 0, 0, nil, fmt.Errorf("couldn't get LatestStaked(%v): %w", staker, err) + return 0, 0, nil, fmt.Errorf("couldn't get LatestStaked(%v): %w", stakerAddress, err) } if latestStaked == 0 { return latestStaked, 0, nil, nil @@ -467,21 +487,21 @@ func (s *Staker) getLatestStakedState(ctx context.Context, staker common.Address stakedInfo, err := s.rollup.LookupNode(ctx, latestStaked) if err != nil { - return 0, 0, nil, fmt.Errorf("couldn't look up latest assertion of %v (%v): %w", staker, latestStaked, err) + return 0, 0, nil, fmt.Errorf("couldn't look up latest assertion of %v (%v): %w", stakerAddress, latestStaked, err) } globalState := stakedInfo.AfterState().GlobalState - caughtUp, count, err := GlobalStateToMsgCount(s.inboxTracker, s.txStreamer, globalState) + caughtUp, count, err := staker.GlobalStateToMsgCount(s.inboxTracker, s.txStreamer, globalState) if err != nil { - if errors.Is(err, ErrGlobalStateNotInChain) && s.fatalErr != nil { - fatal := fmt.Errorf("latest assertion of %v (%v) not in chain: %w", staker, latestStaked, err) + if errors.Is(err, staker.ErrGlobalStateNotInChain) && s.fatalErr != nil { + fatal := fmt.Errorf("latest assertion of %v (%v) not in chain: %w", stakerAddress, latestStaked, err) s.fatalErr <- fatal } - return 0, 0, nil, fmt.Errorf("latest assertion of %v (%v): %w", staker, latestStaked, err) + return 0, 0, nil, fmt.Errorf("latest assertion of %v (%v): %w", stakerAddress, latestStaked, err) } if !caughtUp { - log.Info("latest assertion not yet in our node", "staker", staker, "assertion", latestStaked, "state", globalState) + log.Info("latest assertion not yet in our node", "stakerAddress", stakerAddress, "assertion", latestStaked, "state", globalState) return latestStaked, 0, nil, nil } @@ -491,7 +511,7 @@ func (s *Staker) getLatestStakedState(ctx context.Context, staker common.Address } if processedCount < count { - log.Info("execution catching up to rollup", "staker", staker, "rollupCount", count, "processedCount", processedCount) + log.Info("execution catching up to rollup", "stakerAddress", stakerAddress, "rollupCount", count, "processedCount", processedCount) return latestStaked, 0, nil, nil } @@ -506,9 +526,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) @@ -606,7 +623,7 @@ func (s *Staker) Start(ctxIn context.Context) { }) } -func (s *Staker) IsWhitelisted(ctx context.Context) (bool, error) { +func (s *Staker) isWhitelisted(ctx context.Context) (bool, error) { callOpts := s.getCallOpts(ctx) whitelistDisabled, err := s.rollup.ValidatorWhitelistDisabled(callOpts) if err != nil { @@ -695,12 +712,12 @@ func (s *Staker) confirmDataPosterIsReady(ctx context.Context) error { func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { cfg := s.config() - if cfg.strategy != WatchtowerStrategy { + if cfg.StrategyType() != WatchtowerStrategy { err := s.confirmDataPosterIsReady(ctx) if err != nil { return nil, err } - whitelisted, err := s.IsWhitelisted(ctx) + whitelisted, err := s.isWhitelisted(ctx) if err != nil { return nil, fmt.Errorf("error checking if whitelisted: %w", err) } @@ -714,7 +731,7 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { } callOpts := s.getCallOpts(ctx) s.builder.ClearTransactions() - var rawInfo *StakerInfo + var rawInfo *staker.StakerInfo walletAddressOrZero := s.wallet.AddressOrZero() if walletAddressOrZero != (common.Address{}) { var err error @@ -750,7 +767,7 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { StakeExists: rawInfo != nil, } - effectiveStrategy := cfg.strategy + effectiveStrategy := cfg.StrategyType() nodesLinear, err := s.validatorUtils.AreUnresolvedNodesLinear(callOpts, s.rollupAddress) if err != nil { return nil, fmt.Errorf("error checking for rollup assertion fork: %w", err) @@ -817,7 +834,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) } } } @@ -887,24 +904,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) } } @@ -914,11 +924,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) } @@ -958,10 +964,10 @@ 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 *StakerInfo) error { +func (s *Staker) handleConflict(ctx context.Context, info *staker.StakerInfo) error { if info.CurrentChallenge == nil { s.activeChallenge = nil return nil @@ -977,8 +983,8 @@ func (s *Staker) handleConflict(ctx context.Context, info *StakerInfo) error { newChallengeManager, err := NewChallengeManager( ctx, - s.builder, - s.builder.BuilderAuth(), + s.client, + s.builder.Auth(context.TODO()), *s.builder.WalletAddress(), s.wallet.ChallengeManagerAddress(), *info.CurrentChallenge, @@ -1036,11 +1042,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) } @@ -1052,12 +1054,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, @@ -1090,11 +1088,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) } @@ -1106,12 +1100,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, ) @@ -1125,7 +1115,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv } } -func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { +func (s *Staker) createConflict(ctx context.Context, info *staker.StakerInfo) error { if info.CurrentChallenge != nil { return nil } @@ -1187,12 +1177,8 @@ func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { 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(), @@ -1211,10 +1197,10 @@ func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { } func (s *Staker) Strategy() StakerStrategy { - return s.config().strategy + return s.config().StrategyType() } -func (s *Staker) Rollup() *RollupWatcher { +func (s *Staker) Rollup() *staker.RollupWatcher { return s.rollup } diff --git a/staker/multi_protocol/multi_protocol_staker.go b/staker/multi_protocol/multi_protocol_staker.go new file mode 100644 index 0000000000..0c104094ed --- /dev/null +++ b/staker/multi_protocol/multi_protocol_staker.go @@ -0,0 +1,249 @@ +package multiprotocolstaker + +import ( + "context" + "fmt" + "time" + + "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" + "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" + "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/util/stopwaiter" +) + +const boldArt = ` + _______ __ _______ +/ \ / | / \ +$$$$$$$ | ______ $$ | $$$$$$$ | +$$ |__$$ | / \ $$ | $$ | $$ | +$$ $$< /$$$$$$ |$$ | $$ | $$ | +$$$$$$$ |$$ | $$ |$$ | $$ | $$ | +$$ |__$$ |$$ \__$$ |$$ |_____ $$ |__$$ | +$$ $$/ $$ $$/ $$ |$$ $$/ +$$$$$$$/ $$$$$$/ $$$$$$$$/ $$$$$$$/ +` + +type MultiProtocolStaker struct { + stopwaiter.StopWaiter + bridge *bridgegen.IBridge + oldStaker *legacystaker.Staker + boldStaker *boldstaker.BOLDStaker + legacyConfig legacystaker.L1ValidatorConfigFetcher + stakedNotifiers []legacystaker.LatestStakedNotifier + confirmedNotifiers []legacystaker.LatestConfirmedNotifier + statelessBlockValidator *staker.StatelessBlockValidator + wallet legacystaker.ValidatorWalletInterface + l1Reader *headerreader.HeaderReader + blockValidator *staker.BlockValidator + 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, + legacyConfig legacystaker.L1ValidatorConfigFetcher, + boldConfig *boldstaker.BoldConfig, + blockValidator *staker.BlockValidator, + statelessBlockValidator *staker.StatelessBlockValidator, + stakedNotifiers []legacystaker.LatestStakedNotifier, + stakeTokenAddress common.Address, + confirmedNotifiers []legacystaker.LatestConfirmedNotifier, + validatorUtilsAddress common.Address, + bridgeAddress common.Address, + fatalErr chan<- error, +) (*MultiProtocolStaker, error) { + if err := legacyConfig().Validate(); err != nil { + return nil, err + } + if legacyConfig().StartValidationFromStaked && blockValidator != nil { + stakedNotifiers = append(stakedNotifiers, blockValidator) + } + oldStaker, err := legacystaker.NewStaker( + l1Reader, + wallet, + callOpts, + legacyConfig, + blockValidator, + statelessBlockValidator, + stakedNotifiers, + confirmedNotifiers, + validatorUtilsAddress, + fatalErr, + ) + if err != nil { + return nil, err + } + bridge, err := bridgegen.NewIBridge(bridgeAddress, l1Reader.Client()) + if err != nil { + return nil, err + } + return &MultiProtocolStaker{ + oldStaker: oldStaker, + boldStaker: nil, + bridge: bridge, + legacyConfig: legacyConfig, + stakedNotifiers: stakedNotifiers, + confirmedNotifiers: confirmedNotifiers, + statelessBlockValidator: statelessBlockValidator, + wallet: wallet, + l1Reader: l1Reader, + blockValidator: blockValidator, + callOpts: callOpts, + boldConfig: boldConfig, + stakeTokenAddress: stakeTokenAddress, + stack: stack, + }, nil +} + +func (m *MultiProtocolStaker) Initialize(ctx context.Context) error { + boldActive, rollupAddress, err := m.isBoldActive(ctx) + if err != nil { + return err + } + if boldActive { + log.Info("BoLD protocol is active, initializing BoLD staker") + log.Info(boldArt) + if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { + return err + } + m.oldStaker = nil + return m.boldStaker.Initialize(ctx) + } + log.Info("BoLD protocol not detected on startup, using old staker until upgrade") + return m.oldStaker.Initialize(ctx) +} + +func (m *MultiProtocolStaker) Start(ctxIn context.Context) { + m.StopWaiter.Start(ctxIn, m) + m.wallet.Start(ctxIn) + if m.boldStaker != nil { + log.Info("Starting BOLD staker") + m.boldStaker.Start(ctxIn) + } else { + log.Info("Starting pre-BOLD staker") + m.oldStaker.Start(ctxIn) + stakerSwitchInterval := m.boldConfig.CheckStakerSwitchInterval + m.CallIteratively(func(ctx context.Context) time.Duration { + switchedToBoldProtocol, err := m.checkAndSwitchToBoldStaker(ctxIn) + if err != nil { + log.Warn("staker: error in checking switch to bold staker", "err", err) + return stakerSwitchInterval + } + if switchedToBoldProtocol { + log.Info("Detected BOLD protocol upgrade, stopping old staker and starting BOLD staker") + // Ready to stop the old staker. + m.oldStaker.StopOnly() + m.StopOnly() + } + return stakerSwitchInterval + }) + } +} + +func (m *MultiProtocolStaker) StopAndWait() { + if m.boldStaker != nil { + m.boldStaker.StopAndWait() + } + if m.oldStaker != nil { + m.oldStaker.StopAndWait() + } + m.StopWaiter.StopAndWait() +} + +func (m *MultiProtocolStaker) isBoldActive(ctx context.Context) (bool, common.Address, error) { + var addr common.Address + if !m.boldConfig.Enable { + return false, addr, nil + } + callOpts := m.getCallOpts(ctx) + rollupAddress, err := m.bridge.Rollup(callOpts) + if err != nil { + return false, addr, err + } + userLogic, err := boldrollup.NewRollupUserLogic(rollupAddress, m.l1Reader.Client()) + if err != nil { + 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 +} + +func (m *MultiProtocolStaker) checkAndSwitchToBoldStaker(ctx context.Context) (bool, error) { + shouldSwitch, rollupAddress, err := m.isBoldActive(ctx) + if err != nil { + return false, err + } + if !shouldSwitch { + return false, nil + } + if err := m.setupBoldStaker(ctx, rollupAddress); err != nil { + return false, err + } + if err = m.boldStaker.Initialize(ctx); err != nil { + return false, err + } + m.boldStaker.Start(ctx) + return true, nil +} + +func (m *MultiProtocolStaker) getCallOpts(ctx context.Context) *bind.CallOpts { + opts := m.callOpts + opts.Context = ctx + return &opts +} + +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 + } + boldStaker, err := boldstaker.NewBOLDStaker( + ctx, + m.stack, + rollupAddress, + m.callOpts, + txBuilder.SingleTxAuth(), + m.l1Reader, + m.blockValidator, + m.statelessBlockValidator, + m.boldConfig, + m.wallet.DataPoster(), + m.wallet, + m.stakedNotifiers, + m.confirmedNotifiers, + ) + if err != nil { + return err + } + m.boldStaker = boldStaker + return nil +} diff --git a/staker/rollup_watcher.go b/staker/rollup_watcher.go index 4d7db52322..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 @@ -137,6 +137,10 @@ func (r *RollupWatcher) Initialize(ctx context.Context) error { return err } +func (r *RollupWatcher) Client() RollupWatcherL1Interface { + return r.client +} + func (r *RollupWatcher) LookupCreation(ctx context.Context) (*rollupgen.RollupUserLogicRollupInitialized, error) { var query = ethereum.FilterQuery{ FromBlock: r.fromBlock, diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index d9c9c5446b..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 { @@ -69,6 +68,7 @@ type TransactionStreamerInterface interface { type InboxReaderInterface interface { GetSequencerMessageBytes(ctx context.Context, seqNum uint64) ([]byte, common.Hash, error) + GetFinalizedMsgCount(ctx context.Context) (arbutil.MessageIndex, error) } type GlobalStatePosition struct { @@ -282,6 +282,22 @@ func (v *StatelessBlockValidator) readPostedBatch(ctx context.Context, batchNum return postedData, err } +func (v *StatelessBlockValidator) InboxTracker() InboxTrackerInterface { + return v.inboxTracker +} + +func (v *StatelessBlockValidator) InboxReader() InboxReaderInterface { + return v.inboxReader +} + +func (v *StatelessBlockValidator) InboxStreamer() TransactionStreamerInterface { + return v.streamer +} + +func (v *StatelessBlockValidator) ExecutionSpawners() []validator.ExecutionSpawner { + return v.execSpawners +} + func (v *StatelessBlockValidator) readFullBatch(ctx context.Context, batchNum uint64) (bool, *FullBatchInfo, error) { batchCount, err := v.inboxTracker.GetBatchCount() if err != nil { @@ -380,7 +396,7 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e * return nil } -func buildGlobalState(res execution.MessageResult, pos GlobalStatePosition) validator.GoGlobalState { +func BuildGlobalState(res execution.MessageResult, pos GlobalStatePosition) validator.GoGlobalState { return validator.GoGlobalState{ BlockHash: res.BlockHash, SendRoot: res.SendRoot, @@ -432,8 +448,8 @@ func (v *StatelessBlockValidator) CreateReadyValidationEntry(ctx context.Context if err != nil { return nil, fmt.Errorf("failed calculating position for validation: %w", err) } - start := buildGlobalState(*prevResult, startPos) - end := buildGlobalState(*result, endPos) + start := BuildGlobalState(*prevResult, startPos) + end := BuildGlobalState(*result, endPos) found, fullBatchInfo, err := v.readFullBatch(ctx, start.Batch) if err != nil { return nil, err diff --git a/staker/txbuilder/builder.go b/staker/txbuilder/builder.go index f52b03a781..b352036c7a 100644 --- a/staker/txbuilder/builder.go +++ b/staker/txbuilder/builder.go @@ -5,59 +5,97 @@ 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 } -// 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 { - *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 +106,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 3202d58569..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" @@ -19,9 +20,9 @@ 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" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/headerreader" ) @@ -60,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), @@ -154,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, @@ -203,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 } @@ -268,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 } @@ -285,7 +268,6 @@ func (v *Contract) ExecuteTransactions(ctx context.Context, builder *txbuilder.B if err != nil { return nil, err } - builder.ClearTransactions() return arbTx, nil } @@ -310,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) @@ -350,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, @@ -364,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 { @@ -485,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 7c7f472579..80b805b396 100644 --- a/staker/validatorwallet/eoa.go +++ b/staker/validatorwallet/eoa.go @@ -11,12 +11,15 @@ 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" - "github.com/offchainlabs/nitro/staker/txbuilder" ) +// 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 @@ -80,21 +83,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 fec39ac2b1..b483927753 100644 --- a/staker/validatorwallet/noop.go +++ b/staker/validatorwallet/noop.go @@ -11,8 +11,8 @@ 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" ) // NoOp validator wallet is used for watchtower mode. @@ -38,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/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 new file mode 100644 index 0000000000..777817bf3e --- /dev/null +++ b/system_tests/bold_challenge_protocol_test.go @@ -0,0 +1,922 @@ +// Copyright 2023, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +//go:build challengetest && !race + +package arbtest + +import ( + "bytes" + "context" + "encoding/json" + "io" + "math/big" + "os" + "strings" + "testing" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "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/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" + "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" + 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" + butil "github.com/offchainlabs/bold/util" + "github.com/offchainlabs/nitro/arbcompress" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" + "github.com/offchainlabs/nitro/arbos" + "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/arbstate" + "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" + "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" +) + +func TestChallengeProtocolBOLDReadInboxChallenge(t *testing.T) { + testChallengeProtocolBOLD(t) +} + +func TestChallengeProtocolBOLDStartStepChallenge(t *testing.T) { + opts := []server_arb.SpawnerOption{ + server_arb.WithWrapper(func(inner server_arb.MachineInterface) server_arb.MachineInterface { + // 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...) +} + +func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOption) { + goodDir, err := os.MkdirTemp("", "good_*") + Require(t, err) + evilDir, err := os.MkdirTemp("", "evil_*") + Require(t, err) + t.Cleanup(func() { + Require(t, os.RemoveAll(goodDir)) + Require(t, os.RemoveAll(evilDir)) + }) + 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, + ) + 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, + sconf, + l2info, + ) + defer requireClose(t, l1stack) + defer l2nodeA.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) + + l2nodeConfig := arbnode.ConfigDefaultL1Test() + _, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol( + t, + ctx, + l2nodeA, + l1stack, + l1info, + &l2info.ArbInitData, + l2nodeConfig, + nil, + sconf, + 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) + TransferBalance(t, "Faucet", "EvilAsserter", balance, l1info, l1client, ctx) + + valCfg := valnode.TestValidationConfig + valCfg.UseJit = false + _, valStack := createTestValidationNode(t, ctx, &valCfg) + blockValidatorConfig := staker.TestBlockValidatorConfig + + statelessA, err := staker.NewStatelessBlockValidator( + l2nodeA.InboxReader, + l2nodeA.InboxTracker, + l2nodeA.TxStreamer, + l2nodeA.Execution, + l2nodeA.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = statelessA.Start(ctx) + Require(t, err) + _, valStackB := createTestValidationNode(t, ctx, &valCfg, spawnerOpts...) + + statelessB, err := staker.NewStatelessBlockValidator( + l2nodeB.InboxReader, + l2nodeB.InboxTracker, + l2nodeB.TxStreamer, + l2nodeB.Execution, + l2nodeB.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStackB, + ) + Require(t, err) + err = statelessB.Start(ctx) + Require(t, err) + + blockValidatorA, err := staker.NewBlockValidator( + statelessA, + l2nodeA.InboxTracker, + l2nodeA.TxStreamer, + StaticFetcherFrom(t, &blockValidatorConfig), + nil, + ) + Require(t, err) + Require(t, blockValidatorA.Initialize(ctx)) + Require(t, blockValidatorA.Start(ctx)) + + blockValidatorB, err := staker.NewBlockValidator( + statelessB, + l2nodeB.InboxTracker, + l2nodeB.TxStreamer, + StaticFetcherFrom(t, &blockValidatorConfig), + nil, + ) + Require(t, err) + Require(t, blockValidatorB.Initialize(ctx)) + Require(t, blockValidatorB.Start(ctx)) + + stateManager, err := bold.NewBOLDStateProvider( + blockValidatorA, + statelessA, + l2stateprovider.Height(blockChallengeLeafHeight), + &bold.StateProviderConfig{ + ValidatorName: "good", + MachineLeavesCachePath: goodDir, + CheckBatchFinality: false, + }, + goodDir, + ) + Require(t, err) + + stateManagerB, err := bold.NewBOLDStateProvider( + blockValidatorB, + statelessB, + l2stateprovider.Height(blockChallengeLeafHeight), + &bold.StateProviderConfig{ + ValidatorName: "evil", + MachineLeavesCachePath: evilDir, + CheckBatchFinality: false, + }, + evilDir, + ) + Require(t, err) + + Require(t, l2nodeA.Start(ctx)) + Require(t, l2nodeB.Start(ctx)) + + chalManagerAddr := assertionChain.SpecChallengeManager() + evilOpts := l1info.GetDefaultTransactOpts("EvilAsserter", ctx) + l1ChainId, err := l1client.ChainID(ctx) + Require(t, err) + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), + l2nodeB.L1Reader, + &evilOpts, + NewFetcherFromConfig(l2nodeConfig), + l2nodeB.SyncMonitor, + l1ChainId, + ) + Require(t, err) + chainB, err := solimpl.NewAssertionChain( + ctx, + assertionChain.RollupAddress(), + chalManagerAddr.Address(), + &evilOpts, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), + bold.NewDataPosterTransactor(dp), + solimpl.WithRpcHeadBlockNumber(rpc.LatestBlockNumber), + ) + Require(t, err) + + l2info.GenerateAccount("Destination") + sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + + honestSeqInbox := l1info.GetAddress("SequencerInbox") + evilSeqInbox := l1info.GetAddress("EvilSequencerInbox") + honestSeqInboxBinding, err := bridgegen.NewSequencerInbox(honestSeqInbox, l1client) + Require(t, err) + evilSeqInboxBinding, err := bridgegen.NewSequencerInbox(evilSeqInbox, l1client) + Require(t, err) + + // Post batches to the honest and evil sequencer inbox that are internally equal. + // This means the honest and evil sequencer inboxes will agree with all messages in the batch. + 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) + + evilUpgradeExec, err := mocksgen.NewUpgradeExecutorMock(l1info.GetAddress("EvilUpgradeExecutor"), l1client) + Require(t, err) + data, err = seqInboxABI.Pack( + "setIsBatchPoster", + sequencerTxOpts.From, + true, + ) + Require(t, err) + evilRollupOwnerOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx) + _, err = evilUpgradeExec.ExecuteCall(&evilRollupOwnerOpts, evilSeqInbox, data) + Require(t, err) + + totalMessagesPosted := int64(0) + numMessagesPerBatch := int64(5) + divergeAt := int64(-1) + makeBoldBatch(t, l2nodeA, l2info, l1client, &sequencerTxOpts, honestSeqInboxBinding, honestSeqInbox, numMessagesPerBatch, divergeAt) + l2info.Accounts["Owner"].Nonce.Store(0) + makeBoldBatch(t, l2nodeB, l2info, l1client, &sequencerTxOpts, evilSeqInboxBinding, evilSeqInbox, numMessagesPerBatch, divergeAt) + totalMessagesPosted += numMessagesPerBatch + + // Next, we post another batch, this time containing more messages. + // We diverge at message index 5 within the evil node's batch. + l2info.Accounts["Owner"].Nonce.Store(5) + numMessagesPerBatch = int64(10) + makeBoldBatch(t, l2nodeA, l2info, l1client, &sequencerTxOpts, honestSeqInboxBinding, honestSeqInbox, numMessagesPerBatch, divergeAt) + l2info.Accounts["Owner"].Nonce.Store(5) + divergeAt = int64(5) + makeBoldBatch(t, l2nodeB, l2info, l1client, &sequencerTxOpts, evilSeqInboxBinding, evilSeqInbox, numMessagesPerBatch, divergeAt) + totalMessagesPosted += numMessagesPerBatch + + bcA, err := l2nodeA.InboxTracker.GetBatchCount() + Require(t, err) + bcB, err := l2nodeB.InboxTracker.GetBatchCount() + Require(t, err) + msgA, err := l2nodeA.InboxTracker.GetBatchMessageCount(bcA - 1) + Require(t, err) + msgB, err := l2nodeB.InboxTracker.GetBatchMessageCount(bcB - 1) + Require(t, err) + + t.Logf("Node A batch count %d, msgs %d", bcA, msgA) + t.Logf("Node B batch count %d, msgs %d", bcB, msgB) + + // Wait for both nodes' chains to catch up. + nodeAExec, ok := l2nodeA.Execution.(*gethexec.ExecutionNode) + if !ok { + Fatal(t, "not geth execution node") + } + nodeBExec, ok := l2nodeB.Execution.(*gethexec.ExecutionNode) + if !ok { + Fatal(t, "not geth execution node") + } + for { + nodeALatest := nodeAExec.Backend.APIBackend().CurrentHeader() + nodeBLatest := nodeBExec.Backend.APIBackend().CurrentHeader() + isCaughtUp := nodeALatest.Number.Uint64() == uint64(totalMessagesPosted) + areEqual := nodeALatest.Number.Uint64() == nodeBLatest.Number.Uint64() + if isCaughtUp && areEqual { + if nodeALatest.Hash() == nodeBLatest.Hash() { + Fatal(t, "node A L2 hash", nodeALatest, "matches node B L2 hash", nodeBLatest) + } + break + } + } + + 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 validators have validated the batches. + for { + lastInfo, err := blockValidatorA.ReadLastValidatedInfo() + if lastInfo == nil || err != nil { + continue + } + t.Log(lastInfo.GlobalState.Batch, totalBatches-1) + if lastInfo.GlobalState.Batch >= totalBatches-1 { + break + } + time.Sleep(time.Millisecond * 200) + } + for { + lastInfo, err := blockValidatorB.ReadLastValidatedInfo() + if lastInfo == nil || err != nil { + continue + } + t.Log(lastInfo.GlobalState.Batch, 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(bigStepChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(smallStepChallengeLeafHeight), + }, + stateManager, + nil, // Api db + ) + + evilProvider := l2stateprovider.NewHistoryCommitmentProvider( + stateManagerB, + stateManagerB, + stateManagerB, + []l2stateprovider.Height{ + l2stateprovider.Height(blockChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(bigStepChallengeLeafHeight), + l2stateprovider.Height(smallStepChallengeLeafHeight), + }, + stateManagerB, + nil, // Api db + ) + + 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.NewChallengeStack( + assertionChain, + provider, + stackOpts..., + ) + Require(t, err) + + evilStackOpts := append(stackOpts, challengemanager.StackWithName("evil")) + + managerB, err := challengemanager.NewChallengeStack( + chainB, + evilProvider, + evilStackOpts..., + ) + Require(t, err) + + manager.Start(ctx) + managerB.Start(ctx) + + chalManager := assertionChain.SpecChallengeManager() + filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), l1client) + Require(t, err) + + fromBlock := uint64(0) + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + for { + 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.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 := l1client.TransactionByHash(ctx, it.Event.Raw.TxHash) + Require(t, err) + signer := types.NewCancunSigner(tx.ChainId()) + address, err := signer.Sender(tx) + Require(t, err) + 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()) + return + } + } + fromBlock = toBlock + case <-ctx.Done(): + return + } + } +} + +// 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, + isSequencer bool, + nodeConfig *arbnode.Config, + chainConfig *params.ChainConfig, + _ *node.Config, + rollupStackConf setup.RollupStackConfig, + l2infoIn info, +) ( + l2info info, currentNode *arbnode.Node, l2client *ethclient.Client, l2stack *node.Node, + l1info info, l1backend *eth.Ethereum, l1client *ethclient.Client, l1stack *node.Node, + assertionChain *solimpl.AssertionChain, stakeTokenAddr common.Address, +) { + if nodeConfig == nil { + nodeConfig = arbnode.ConfigDefaultL1Test() + } + nodeConfig.ParentChainReader.OldHeaderTimeout = time.Minute * 10 + if chainConfig == nil { + chainConfig = chaininfo.ArbitrumDevTestChainConfig() + } + nodeConfig.BatchPoster.DataPoster.MaxMempoolTransactions = 18 + fatalErrChan := make(chan error, 10) + l1info, l1client, l1backend, l1stack = createTestL1BlockChain(t, nil) + var l2chainDb ethdb.Database + var l2arbDb ethdb.Database + var l2blockchain *core.BlockChain + l2info = l2infoIn + if l2info == nil { + l2info = NewArbTestInfo(t, chainConfig.ChainID) + } + + l1info.GenerateAccount("RollupOwner") + l1info.GenerateAccount("Sequencer") + l1info.GenerateAccount("User") + l1info.GenerateAccount("Asserter") + l1info.GenerateAccount("EvilAsserter") + + SendWaitTestTransactions(t, ctx, l1client, []*types.Transaction{ + l1info.PrepareTx("Faucet", "RollupOwner", 30000, big.NewInt(9223372036854775807), nil), + l1info.PrepareTx("Faucet", "Sequencer", 30000, big.NewInt(9223372036854775807), nil), + l1info.PrepareTx("Faucet", "User", 30000, big.NewInt(9223372036854775807), nil), + l1info.PrepareTx("Faucet", "Asserter", 30000, big.NewInt(9223372036854775807), nil), + l1info.PrepareTx("Faucet", "EvilAsserter", 30000, big.NewInt(9223372036854775807), nil), + }) + + l1TransactionOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx) + stakeToken, tx, tokenBindings, err := mocksgen.DeployTestWETH9( + &l1TransactionOpts, + l1client, + "Weth", + "WETH", + ) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, l1client, tx) + Require(t, err) + stakeTokenAddr = stakeToken + value, ok := new(big.Int).SetString("10000", 10) + if !ok { + t.Fatal(t, "could not set value") + } + l1TransactionOpts.Value = value + tx, err = tokenBindings.Deposit(&l1TransactionOpts) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, l1client, tx) + Require(t, err) + l1TransactionOpts.Value = nil + + 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{}) + Require(t, err) + l1info.SetContract("Bridge", addresses.Bridge) + l1info.SetContract("SequencerInbox", addresses.SequencerInbox) + l1info.SetContract("Inbox", addresses.Inbox) + l1info.SetContract("Rollup", addresses.Rollup) + l1info.SetContract("UpgradeExecutor", addresses.UpgradeExecutor) + + execConfig := ExecConfigDefaultNonSequencerTest(t) + Require(t, execConfig.Validate()) + execConfig.Caching.StateScheme = rawdb.HashScheme + useWasmCache := uint32(1) + 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 { + sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + sequencerTxOptsPtr = &sequencerTxOpts + dataSigner = signature.DataSignerFromPrivateKey(l1info.GetInfoWithPrivKey("Sequencer").PrivateKey) + } + + if !isSequencer { + nodeConfig.BatchPoster.Enable = false + nodeConfig.DelayedSequencer.Enable = false + } + + AddValNodeIfNeeded(t, ctx, nodeConfig, true, "", "") + + execConfigFetcher := func() *gethexec.Config { return execConfig } + execNode, err := gethexec.CreateExecutionNode(ctx, l2stack, l2chainDb, l2blockchain, l1client, execConfigFetcher) + Require(t, err) + + parentChainId, err := l1client.ChainID(ctx) + Require(t, err) + currentNode, err = arbnode.CreateNode( + ctx, l2stack, execNode, l2arbDb, NewFetcherFromConfig(nodeConfig), l2blockchain.Config(), l1client, + addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, dataSigner, fatalErrChan, parentChainId, + nil, // Blob reader. + ) + Require(t, err) + + l2client = ClientForStack(t, l2stack) + + StartWatchChanErr(t, ctx, fatalErrChan, currentNode) + + opts := l1info.GetDefaultTransactOpts("Asserter", ctx) + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2arbDb, storage.StakerPrefix), + currentNode.L1Reader, + &opts, + NewFetcherFromConfig(nodeConfig), + currentNode.SyncMonitor, + parentChainId, + ) + Require(t, err) + assertionChainBindings, err := solimpl.NewAssertionChain( + ctx, + addresses.Rollup, + chalManagerAddr, + &opts, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), + bold.NewDataPosterTransactor(dp), + solimpl.WithRpcHeadBlockNumber(rpc.LatestBlockNumber), + ) + Require(t, err) + assertionChain = assertionChainBindings + + return +} + +func deployContractsOnly( + t *testing.T, + ctx context.Context, + l1info info, + backend *ethclient.Client, + chainId *big.Int, + rollupStackConf setup.RollupStackConfig, + stakeToken common.Address, +) *chaininfo.RollupAddresses { + l1TransactionOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx) + locator, err := server_common.NewMachineLocator("") + Require(t, err) + wasmModuleRoot := locator.LatestWasmModuleRoot() + + loserStakeEscrow := l1TransactionOpts.From + genesisExecutionState := rollupgen.AssertionState{ + GlobalState: rollupgen.GlobalState{}, + MachineStatus: 1, + EndHistoryRoot: [32]byte{}, + } + genesisInboxCount := big.NewInt(0) + anyTrustFastConfirmer := common.Address{} + miniStakeValues := []*big.Int{big.NewInt(5), big.NewInt(4), big.NewInt(3), big.NewInt(2), big.NewInt(1)} + cfg := challengetesting.GenerateRollupConfig( + false, + wasmModuleRoot, + l1TransactionOpts.From, + chainId, + loserStakeEscrow, + miniStakeValues, + stakeToken, + genesisExecutionState, + genesisInboxCount, + anyTrustFastConfirmer, + challengetesting.WithLayerZeroHeights(&protocol.LayerZeroHeights{ + 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(chaininfo.ArbitrumDevTestChainConfig()) + Require(t, err) + cfg.ChainConfig = string(config) + addresses, err := setup.DeployFullRollupStack( + ctx, + butil.NewBackendWrapper(backend, rpc.LatestBlockNumber), + &l1TransactionOpts, + l1info.GetAddress("Sequencer"), + cfg, + rollupStackConf, + ) + Require(t, err) + + asserter := l1info.GetDefaultTransactOpts("Asserter", ctx) + evilAsserter := l1info.GetDefaultTransactOpts("EvilAsserter", ctx) + userLogic, err := rollupgen.NewRollupUserLogic(addresses.Rollup, backend) + Require(t, err) + chalManagerAddr, err := userLogic.ChallengeManager(&bind.CallOpts{}) + Require(t, err) + seed, ok := new(big.Int).SetString("1000", 10) + if !ok { + t.Fatal("not ok") + } + value, ok := new(big.Int).SetString("10000", 10) + if !ok { + t.Fatal(t, "could not set value") + } + tokenBindings, err := mocksgen.NewTestWETH9(stakeToken, backend) + Require(t, err) + tx, err := tokenBindings.TestWETH9Transactor.Transfer(&l1TransactionOpts, asserter.From, seed) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + tx, err = tokenBindings.TestWETH9Transactor.Approve(&asserter, addresses.Rollup, value) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + tx, err = tokenBindings.TestWETH9Transactor.Approve(&asserter, chalManagerAddr, value) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + + tx, err = tokenBindings.TestWETH9Transactor.Transfer(&l1TransactionOpts, evilAsserter.From, seed) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + tx, err = tokenBindings.TestWETH9Transactor.Approve(&evilAsserter, addresses.Rollup, value) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + tx, err = tokenBindings.TestWETH9Transactor.Approve(&evilAsserter, chalManagerAddr, value) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + + return &chaininfo.RollupAddresses{ + Bridge: addresses.Bridge, + Inbox: addresses.Inbox, + SequencerInbox: addresses.SequencerInbox, + Rollup: addresses.Rollup, + ValidatorUtils: addresses.ValidatorUtils, + ValidatorWalletCreator: addresses.ValidatorWalletCreator, + DeployedAt: addresses.DeployedAt, + UpgradeExecutor: addresses.UpgradeExecutor, + } +} + +func create2ndNodeWithConfigForBoldProtocol( + t *testing.T, + ctx context.Context, + first *arbnode.Node, + l1stack *node.Node, + l1info *BlockchainTestInfo, + 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) + l1rpcClient := l1stack.Attach() + l1client := ethclient.NewClient(l1rpcClient) + firstExec, ok := first.Execution.(*gethexec.ExecutionNode) + if !ok { + Fatal(t, "not geth execution node") + } + chainConfig := firstExec.ArbInterface.BlockChain().Config() + addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, rollupStackConf, stakeTokenAddr) + + l1info.SetContract("EvilBridge", addresses.Bridge) + l1info.SetContract("EvilSequencerInbox", addresses.SequencerInbox) + l1info.SetContract("EvilInbox", addresses.Inbox) + l1info.SetContract("EvilRollup", addresses.Rollup) + l1info.SetContract("EvilUpgradeExecutor", addresses.UpgradeExecutor) + + if nodeConfig == nil { + nodeConfig = arbnode.ConfigDefaultL1NonSequencerTest() + } + nodeConfig.ParentChainReader.OldHeaderTimeout = 10 * time.Minute + nodeConfig.BatchPoster.DataPoster.MaxMempoolTransactions = 18 + if stackConfig == nil { + stackConfig = testhelpers.CreateStackConfigForTest(t.TempDir()) + } + l2stack, err := node.New(stackConfig) + Require(t, err) + + l2chainDb, err := l2stack.OpenDatabase("chaindb", 0, 0, "", false) + Require(t, err) + l2arbDb, err := l2stack.OpenDatabase("arbdb", 0, 0, "", false) + Require(t, err) + + AddValNodeIfNeeded(t, ctx, nodeConfig, true, "", "") + + dataSigner := signature.DataSignerFromPrivateKey(l1info.GetInfoWithPrivKey("Sequencer").PrivateKey) + txOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + + initReader := statetransfer.NewMemoryInitDataReader(l2InitData) + initMessage := getInitMessage(ctx, t, l1client, first.DeployInfo) + + execConfig := ExecConfigDefaultNonSequencerTest(t) + Require(t, execConfig.Validate()) + execConfig.Caching.StateScheme = rawdb.HashScheme + coreCacheConfig := gethexec.DefaultCacheConfigFor(l2stack, &execConfig.Caching) + l2blockchain, err := gethexec.WriteOrTestBlockChain(l2chainDb, coreCacheConfig, initReader, chainConfig, initMessage, execConfig.TxLookupLimit, 0) + Require(t, err) + + execConfigFetcher := func() *gethexec.Config { return execConfig } + execNode, err := gethexec.CreateExecutionNode(ctx, l2stack, l2chainDb, l2blockchain, l1client, execConfigFetcher) + Require(t, err) + l1ChainId, err := l1client.ChainID(ctx) + Require(t, err) + l2node, err := arbnode.CreateNode(ctx, l2stack, execNode, l2arbDb, NewFetcherFromConfig(nodeConfig), l2blockchain.Config(), l1client, addresses, &txOpts, &txOpts, dataSigner, fatalErrChan, l1ChainId, nil /* blob reader */) + Require(t, err) + + l2client := ClientForStack(t, l2stack) + + StartWatchChanErr(t, ctx, fatalErrChan, l2node) + + rollupUserLogic, err := rollupgen.NewRollupUserLogic(addresses.Rollup, l1client) + Require(t, err) + chalManagerAddr, err := rollupUserLogic.ChallengeManager(&bind.CallOpts{}) + Require(t, err) + evilOpts := l1info.GetDefaultTransactOpts("EvilAsserter", ctx) + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2arbDb, storage.StakerPrefix), + l2node.L1Reader, + &evilOpts, + NewFetcherFromConfig(nodeConfig), + l2node.SyncMonitor, + l1ChainId, + ) + Require(t, err) + assertionChain, err := solimpl.NewAssertionChain( + ctx, + addresses.Rollup, + chalManagerAddr, + &evilOpts, + butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber), + bold.NewDataPosterTransactor(dp), + ) + Require(t, err) + + return l2client, l2node, assertionChain +} + +func makeBoldBatch( + t *testing.T, + l2Node *arbnode.Node, + l2Info *BlockchainTestInfo, + backend *ethclient.Client, + sequencer *bind.TransactOpts, + seqInbox *bridgegen.SequencerInbox, + seqInboxAddr common.Address, + numMessages, + divergeAtIndex int64, +) { + ctx := context.Background() + + batchBuffer := bytes.NewBuffer([]byte{}) + for i := int64(0); i < numMessages; i++ { + value := i + if i == divergeAtIndex { + value++ + } + err := writeTxToBatchBold(batchBuffer, l2Info.PrepareTx("Owner", "Destination", 1000000, big.NewInt(value), []byte{})) + Require(t, err) + } + compressed, err := arbcompress.CompressWell(batchBuffer.Bytes()) + Require(t, err) + message := append([]byte{0}, compressed...) + + seqNum := new(big.Int).Lsh(common.Big1, 256) + seqNum.Sub(seqNum, common.Big1) + tx, err := seqInbox.AddSequencerL2BatchFromOrigin8f111f3c(sequencer, seqNum, message, big.NewInt(1), common.Address{}, big.NewInt(0), big.NewInt(0)) + Require(t, err) + receipt, err := EnsureTxSucceeded(ctx, backend, tx) + Require(t, err) + + nodeSeqInbox, err := arbnode.NewSequencerInbox(backend, seqInboxAddr, 0) + Require(t, err) + batches, err := nodeSeqInbox.LookupBatchesInRange(ctx, receipt.BlockNumber, receipt.BlockNumber) + Require(t, err) + if len(batches) == 0 { + Fatal(t, "batch not found after AddSequencerL2BatchFromOrigin") + } + err = l2Node.InboxTracker.AddSequencerBatches(ctx, backend, batches) + Require(t, err) + 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:") +} + +func writeTxToBatchBold(writer io.Writer, tx *types.Transaction) error { + txData, err := tx.MarshalBinary() + if err != nil { + return err + } + var segment []byte + segment = append(segment, arbstate.BatchSegmentKindL2Message) + segment = append(segment, arbos.L2MessageKind_SignedTx) + segment = append(segment, txData...) + err = rlp.Encode(writer, segment) + return err +} diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go new file mode 100644 index 0000000000..ad6e44bc71 --- /dev/null +++ b/system_tests/bold_new_challenge_test.go @@ -0,0 +1,358 @@ +// Copyright 2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +//go:build challengetest && !race + +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" + "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" + 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" + butil "github.com/offchainlabs/bold/util" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" + "github.com/offchainlabs/nitro/staker/bold" +) + +type incorrectBlockStateProvider struct { + honest BoldStateProviderInterface + chain protocol.AssertionChain + wrongAtFirstVirtual bool + wrongAtBlockHeight uint64 + honestMachineHash common.Hash + evilMachineHash common.Hash +} + +func (s *incorrectBlockStateProvider) ExecutionStateAfterPreviousState( + ctx context.Context, + maxInboxCount uint64, + 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))) + 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 + } + // 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)) + } + 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, + assertionMetadata *l2stateprovider.AssociatedAssertionMetadata, + blockChallengeHeight l2stateprovider.Height, + machineIndex l2stateprovider.OpcodeIndex, +) ([]byte, error) { + return s.honest.CollectProof(ctx, assertionMetadata, blockChallengeHeight, machineIndex) +} + +func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bool) { + 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 + builder.nodeConfig.BlockValidator.Enable = true + builder.valnodeConfig.UseJit = false + + cleanup := builder.Build(t) + defer cleanup() + + 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("HonestAsserter") + fundBoldStaker(t, ctx, builder, "HonestAsserter") + builder.L1Info.GenerateAccount("EvilAsserter") + fundBoldStaker(t, ctx, builder, "EvilAsserter") + + assertionChain, cleanupHonestChallengeManager := startBoldChallengeManager(t, ctx, builder, builder.L2, "HonestAsserter", nil) + defer cleanupHonestChallengeManager() + + _, cleanupEvilChallengeManager := startBoldChallengeManager(t, ctx, builder, evilNode, "EvilAsserter", func(stateManager BoldStateProviderInterface) BoldStateProviderInterface { + p := &incorrectBlockStateProvider{ + honest: stateManager, + chain: assertionChain, + wrongAtFirstVirtual: wrongAtFirstVirtual, + } + if !wrongAtFirstVirtual { + p.wrongAtBlockHeight = blockChallengeLeafHeight - 2 + } + return p + }) + defer cleanupEvilChallengeManager() + + 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 := assertionChain.SpecChallengeManager() + 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("HonestAsserter") { + 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 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) +} + +func TestChallengeProtocolBOLDNearLastVirtualBlock(t *testing.T) { + testChallengeProtocolBOLDVirtualBlocks(t, false) +} + +func TestChallengeProtocolBOLDFirstVirtualBlock(t *testing.T) { + testChallengeProtocolBOLDVirtualBlocks(t, true) +} + +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") + } + + 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: cacheDir, + CheckBatchFinality: false, + }, + cacheDir, + ) + Require(t, err) + + if mockStateProvider != nil { + stateManager = mockStateProvider(stateManager) + } + + 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, + butil.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber), + bold.NewDataPosterTransactor(dp), + ) + 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.NewChallengeStack( + assertionChain, + provider, + stackOpts..., + ) + Require(t, err) + + challengeManager.Start(ctx) + return assertionChain, challengeManager.StopAndWait +} diff --git a/system_tests/bold_state_provider_test.go b/system_tests/bold_state_provider_test.go new file mode 100644 index 0000000000..0ecce5ba64 --- /dev/null +++ b/system_tests/bold_state_provider_test.go @@ -0,0 +1,419 @@ +// Copyright 2023, Offchain Labs, Inc. +// For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE + +//go:build challengetest && !race + +package arbtest + +import ( + "context" + "errors" + "math/big" + "strings" + "testing" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi" + "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/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/cmd/chaininfo" + "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/bold" + "github.com/offchainlabs/nitro/util" + "github.com/offchainlabs/nitro/validator/valnode" + + 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/solgen/go/bridgegen" + "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) { + t.Parallel() + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator := setupBoldStateProvider(t, ctx, 1<<5) + defer requireClose(t, l1stack) + defer l2node.StopAndWait() + l2info.GenerateAccount("Destination") + sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + + seqInbox := l1info.GetAddress("SequencerInbox") + seqInboxBinding, err := bridgegen.NewSequencerInbox(seqInbox, l1client) + Require(t, err) + + 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, seqInbox, data) + Require(t, err) + + // 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) + numMessagesPerBatch = int64(10) + makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, seqInboxBinding, seqInbox, numMessagesPerBatch, divergeAt) + + 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() + 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 { + time.Sleep(time.Millisecond * 100) + lastInfo, err := blockValidator.ReadLastValidatedInfo() + if lastInfo == nil || err != nil { + continue + } + if lastInfo.GlobalState.Batch >= totalBatches { + break + } + batchMsgCount, err := l2node.InboxTracker.GetBatchMessageCount(lastInfo.GlobalState.Batch) + if err != nil { + continue + } + if batchMsgCount >= totalMessageCount { + break + } + } + + historyCommitter := l2stateprovider.NewHistoryCommitmentProvider( + stateManager, + stateManager, + stateManager, []l2stateprovider.Height{ + 1 << 5, + 1 << 5, + 1 << 5, + }, + stateManager, + nil, // api db + ) + bisectionHeight := l2stateprovider.Height(16) + request := &l2stateprovider.HistoryCommitmentRequest{ + AssertionMetadata: &l2stateprovider.AssociatedAssertionMetadata{ + FromState: protocol.GoGlobalState{ + Batch: 1, + }, + BatchLimit: 3, + WasmModuleRoot: common.Hash{}, + }, + UpperChallengeOriginHeights: []l2stateprovider.Height{}, + UpToHeight: option.Some(bisectionHeight), + } + bisectionCommitment, err := historyCommitter.HistoryCommitment(ctx, request) + Require(t, err) + + request.UpToHeight = option.None[l2stateprovider.Height]() + packedProof, err := historyCommitter.PrefixProof(ctx, request, bisectionHeight) + Require(t, err) + + dataItem, err := mockmanager.ProofArgs.Unpack(packedProof) + Require(t, err) + preExpansion, ok := dataItem[0].([][32]byte) + if !ok { + Fatal(t, "wrong type") + } + + hashes := make([]common.Hash, len(preExpansion)) + for i, h := range preExpansion { + hash := h + hashes[i] = hash + } + + computed, err := prefixproofs.Root(hashes) + Require(t, err) + if computed != bisectionCommitment.Merkle { + Fatal(t, "wrong commitment") + } +} + +func TestChallengeProtocolBOLD_StateProvider(t *testing.T) { + // t.Parallel() + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + 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") + sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) + + seqInbox := l1info.GetAddress("SequencerInbox") + seqInboxBinding, err := bridgegen.NewSequencerInbox(seqInbox, l1client) + Require(t, err) + + 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, seqInbox, data) + Require(t, err) + + // We will make two batches, with 5 messages in each batch. + numMessagesPerBatch := int64(5) + divergeAt := int64(-1) // No divergence. + makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, seqInboxBinding, seqInbox, numMessagesPerBatch, divergeAt) + makeBoldBatch(t, l2node, l2info, l1client, &sequencerTxOpts, seqInboxBinding, seqInbox, numMessagesPerBatch, divergeAt) + + 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() + totalMessageCount, err := l2node.InboxTracker.GetBatchMessageCount(totalBatches - 1) + Require(t, err) + + // Wait until the validator has validated the batches. + for { + time.Sleep(time.Millisecond * 100) + lastInfo, err := blockValidator.ReadLastValidatedInfo() + if lastInfo == nil || err != nil { + continue + } + if lastInfo.GlobalState.Batch >= totalBatches { + break + } + } + + t.Run("StatesInBatchRange", func(t *testing.T) { + toBatch := uint64(3) + 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 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 != 3 && lastState.PosInBatch != 0 { + Fatal(t, "wrong last state") + } + }) + t.Run("AgreesWithExecutionState", func(t *testing.T) { + // Non-zero position in batch should fail. + _, err = stateManager.ExecutionStateAfterPreviousState( + ctx, + 0, + protocol.GoGlobalState{ + Batch: 0, + PosInBatch: 1, + }, + ) + if err == nil { + Fatal(t, "should not agree with execution state") + } + if !strings.Contains(err.Error(), "max inbox count cannot be zero") { + Fatal(t, "wrong error message") + } + + // Always agrees with genesis. + genesis, err := stateManager.ExecutionStateAfterPreviousState( + ctx, + 1, + protocol.GoGlobalState{ + Batch: 0, + PosInBatch: 0, + }, + ) + Require(t, err) + if genesis == nil { + Fatal(t, "genesis should not be nil") + } + + // Always agrees with the init message. + first, err := stateManager.ExecutionStateAfterPreviousState( + ctx, + 2, + genesis.GlobalState, + ) + Require(t, err) + if first == nil { + Fatal(t, "genesis should not be nil") + } + + // Chain catching up if it has not seen batch 10. + _, err = stateManager.ExecutionStateAfterPreviousState( + ctx, + 10, + first.GlobalState, + ) + if err == nil { + Fatal(t, "should not agree with execution state") + } + if !errors.Is(err, l2stateprovider.ErrChainCatchingUp) { + Fatal(t, "wrong error") + } + + // Check if we agree with the last posted batch to the inbox. + result, err := l2node.TxStreamer.ResultAtCount(totalMessageCount) + Require(t, err) + _ = result + + state := protocol.GoGlobalState{ + BlockHash: result.BlockHash, + SendRoot: result.SendRoot, + Batch: 3, + } + got, err := stateManager.ExecutionStateAfterPreviousState(ctx, 3, first.GlobalState) + Require(t, err) + if state.Batch != got.GlobalState.Batch { + Fatal(t, "wrong batch") + } + if state.SendRoot != got.GlobalState.SendRoot { + Fatal(t, "wrong send root") + } + if state.BlockHash != got.GlobalState.BlockHash { + Fatal(t, "wrong batch") + } + + // See if we agree with one batch immediately after that and see that we fail with + // "ErrChainCatchingUp". + _, err = stateManager.ExecutionStateAfterPreviousState( + ctx, + state.Batch+1, + got.GlobalState, + ) + if err == nil { + Fatal(t, "should not agree with execution state") + } + if !errors.Is(err, l2stateprovider.ErrChainCatchingUp) { + Fatal(t, "wrong error") + } + }) + t.Run("ExecutionStateAfterBatchCount", func(t *testing.T) { + _, err = stateManager.ExecutionStateAfterPreviousState(ctx, 0, protocol.GoGlobalState{}) + if err == nil { + Fatal(t, "should have failed") + } + if !strings.Contains(err.Error(), "max inbox count cannot be zero") { + Fatal(t, "wrong error message", err) + } + + genesis, err := stateManager.ExecutionStateAfterPreviousState(ctx, 1, protocol.GoGlobalState{}) + Require(t, err) + execState, err := stateManager.ExecutionStateAfterPreviousState(ctx, totalBatches, genesis.GlobalState) + Require(t, err) + if execState == nil { + Fatal(t, "should not be nil") + } + }) +} + +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 := chaininfo.ArbitrumDevTestChainConfig() + l2info := NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(l2chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + 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, + sconf, + l2info, + ) + + valnode.TestValidationConfig.UseJit = false + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + 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) + Require(t, stateless.Start(ctx)) + + 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)) + + dir := t.TempDir() + stateManager, err := bold.NewBOLDStateProvider( + blockValidator, + stateless, + l2stateprovider.Height(blockChallengeHeight), + &bold.StateProviderConfig{ + ValidatorName: "", + MachineLeavesCachePath: dir, + CheckBatchFinality: false, + }, + dir, + ) + Require(t, err) + + Require(t, l2node.Start(ctx)) + return l2node, l1info, l2info, l1stack, l1client, stateManager, blockValidator +} diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 027a41d875..72d2645910 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" @@ -71,17 +51,42 @@ 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/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" + "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_arb" + "github.com/offchainlabs/nitro/validator/server_common" + "github.com/offchainlabs/nitro/validator/valnode" + rediscons "github.com/offchainlabs/nitro/validator/valnode/redis" ) type info = *BlockchainTestInfo @@ -237,6 +242,7 @@ type NodeBuilder struct { l2StackConfig *node.Config valnodeConfig *valnode.Config l3Config *NitroConfig + deployBold bool L1Info info L2Info info L3Info info @@ -286,7 +292,7 @@ func L3NitroConfigDefaultTest(t *testing.T) *NitroConfig { MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), - ArbitrumChainParams: params.ArbitrumDevTestParams(), + ArbitrumChainParams: chaininfo.ArbitrumDevTestParams(), Clique: ¶ms.CliqueConfig{ Period: 0, Epoch: 0, @@ -320,7 +326,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() @@ -345,6 +351,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 @@ -375,7 +386,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() @@ -413,6 +424,7 @@ func (b *NodeBuilder) BuildL1(t *testing.T) { locator.LatestWasmModuleRoot(), b.withProdConfirmPeriodBlocks, true, + b.deployBold, ) b.L1.cleanup = func() { requireClose(t, b.L1.Stack) } } @@ -516,6 +528,7 @@ func (b *NodeBuilder) BuildL3OnL2(t *testing.T) func() { locator.LatestWasmModuleRoot(), b.l3Config.withProdConfirmPeriodBlocks, false, + b.deployBold, ) b.L3 = buildOnParentChain( @@ -1079,7 +1092,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, spawnerOpts ...server_arb.SpawnerOption) (*valnode.ValidationNode, *node.Node) { stackConf := node.DefaultConfig stackConf.HTTPPort = 0 stackConf.DataDir = "" @@ -1096,7 +1109,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, spawnerOpts...) Require(t, err) err = stack.Start() @@ -1179,7 +1192,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) @@ -1196,6 +1209,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 +1220,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() @@ -1249,6 +1260,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, @@ -1259,6 +1276,7 @@ func deployOnParentChain( wasmModuleRoot common.Hash, prodConfirmPeriodBlocks bool, chainSupportsBlobs bool, + deployBold bool, ) (*chaininfo.RollupAddresses, *arbostypes.ParsedInitMessage) { parentChainInfo.GenerateAccount("RollupOwner") parentChainInfo.GenerateAccount("Sequencer") @@ -1283,18 +1301,88 @@ 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, + } + wrappedClient := butil.NewBackendWrapper(parentChainReader.Client(), rpc.LatestBlockNumber) + boldAddresses, err := setup.DeployFullRollupStack( + ctx, + wrappedClient, + &parentChainTransactionOpts, + parentChainInfo.GetAddress("Sequencer"), + cfg, + setup.RollupStackConfig{ + UseMockBridge: false, + UseMockOneStepProver: false, + MinimumAssertionPeriod: 0, + }, + ) + 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) @@ -1511,7 +1599,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 @@ -1519,10 +1607,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/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..306b8fada3 100644 --- a/system_tests/contract_tx_test.go +++ b/system_tests/contract_tx_test.go @@ -14,9 +14,10 @@ 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 +55,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 ed3844d528..52703c879d 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" @@ -20,17 +21,16 @@ 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/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" "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( @@ -201,7 +201,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) @@ -329,7 +329,7 @@ func TestDASBatchPosterFallback(t *testing.T) { // Setup L1 builder := NewNodeBuilder(ctx).DefaultConfig(t, true) - builder.chainConfig = params.ArbitrumDevTestDASChainConfig() + builder.chainConfig = chaininfo.ArbitrumDevTestDASChainConfig() builder.BuildL1(t) l1client := builder.L1.Client l1info := builder.L1Info 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/fast_confirm_test.go b/system_tests/fast_confirm_test.go index dae2699b9f..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" @@ -32,6 +33,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/staker" + legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/staker/validatorwallet" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/validator/valnode" @@ -94,7 +96,7 @@ func TestFastConfirmation(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - valConfig := staker.TestL1ValidatorConfig + valConfig := legacystaker.TestL1ValidatorConfig valConfig.EnableFastConfirmation = true parentChainID, err := builder.L1.Client.ChainID(ctx) if err != nil { @@ -156,11 +158,11 @@ func TestFastConfirmation(t *testing.T) { Require(t, err) err = valWallet.Initialize(ctx) Require(t, err) - stakerA, err := staker.NewStaker( + stakerA, err := legacystaker.NewStaker( l2node.L1Reader, valWallet, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfig }, + func() *legacystaker.L1ValidatorConfig { return &valConfig }, nil, stateless, nil, @@ -211,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)) } } @@ -293,7 +295,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { _, err = builder.L1.EnsureTxSucceeded(tx) Require(t, err) - valConfigA := staker.TestL1ValidatorConfig + valConfigA := legacystaker.TestL1ValidatorConfig valConfigA.EnableFastConfirmation = true parentChainID, err := builder.L1.Client.ChainID(ctx) @@ -357,11 +359,11 @@ func TestFastConfirmationWithSafe(t *testing.T) { Require(t, err) err = valWalletA.Initialize(ctx) Require(t, err) - stakerA, err := staker.NewStaker( + stakerA, err := legacystaker.NewStaker( l2nodeA.L1Reader, valWalletA, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfigA }, + func() *legacystaker.L1ValidatorConfig { return &valConfigA }, nil, statelessA, nil, @@ -391,7 +393,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { } valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) Require(t, err) - valConfigB := staker.TestL1ValidatorConfig + valConfigB := legacystaker.TestL1ValidatorConfig valConfigB.EnableFastConfirmation = true valConfigB.Strategy = "watchtower" statelessB, err := staker.NewStatelessBlockValidator( @@ -409,11 +411,11 @@ func TestFastConfirmationWithSafe(t *testing.T) { Require(t, err) err = valWalletB.Initialize(ctx) Require(t, err) - stakerB, err := staker.NewStaker( + stakerB, err := legacystaker.NewStaker( l2nodeB.L1Reader, valWalletB, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfigB }, + func() *legacystaker.L1ValidatorConfig { return &valConfigB }, nil, statelessB, nil, 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/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index bf30c928d8..4d902f87ba 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -32,6 +32,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/ospgen" "github.com/offchainlabs/nitro/solgen/go/yulgen" "github.com/offchainlabs/nitro/staker" + legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/validator" "github.com/offchainlabs/nitro/validator/server_common" ) @@ -101,8 +102,8 @@ func CreateChallenge( auth, wasmModuleRoot, [2]uint8{ - staker.StatusFinished, - staker.StatusFinished, + legacystaker.StatusFinished, + legacystaker.StatusFinished, }, [2]mocksgen.GlobalState{ { @@ -397,7 +398,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall Fatal(t, err) } defer asserterValidator.Stop() - asserterManager, err := staker.NewChallengeManager(ctx, l1Backend, &asserterTxOpts, asserterTxOpts.From, challengeManagerAddr, 1, asserterValidator, 0, 0) + asserterManager, err := legacystaker.NewChallengeManager(ctx, l1Backend, &asserterTxOpts, asserterTxOpts.From, challengeManagerAddr, 1, asserterValidator, 0, 0) if err != nil { Fatal(t, err) } @@ -414,7 +415,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall Fatal(t, err) } defer challengerValidator.Stop() - challengerManager, err := staker.NewChallengeManager(ctx, l1Backend, &challengerTxOpts, challengerTxOpts.From, challengeManagerAddr, 1, challengerValidator, 0, 0) + challengerManager, err := legacystaker.NewChallengeManager(ctx, l1Backend, &challengerTxOpts, challengerTxOpts.From, challengeManagerAddr, 1, challengerValidator, 0, 0) if err != nil { Fatal(t, err) } 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..4807a8e67a 100644 --- a/system_tests/initialization_test.go +++ b/system_tests/initialization_test.go @@ -10,7 +10,8 @@ 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 +51,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/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/mock_machine_test.go b/system_tests/mock_machine_test.go new file mode 100644 index 0000000000..ea7fcbaef1 --- /dev/null +++ b/system_tests/mock_machine_test.go @@ -0,0 +1,41 @@ +// 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/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..10d1ebec42 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" @@ -53,7 +54,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() diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go new file mode 100644 index 0000000000..c024a43070 --- /dev/null +++ b/system_tests/overflow_assertions_test.go @@ -0,0 +1,316 @@ +// 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/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. + goodDir, err := os.MkdirTemp("", "good_*") + Require(t, err) + t.Cleanup(func() { + Require(t, os.RemoveAll(goodDir)) + }) + 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 + _, valStack := createTestValidationNode(t, ctx, &valCfg) + 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: goodDir, + CheckBatchFinality: false, + }, + goodDir, + ) + 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. +} diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index e6751d347d..fc4b0e745e 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -13,8 +13,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/l1pricing" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) @@ -156,7 +157,7 @@ func TestArbOwnerDoesntRevert(t *testing.T) { arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) Require(t, err) - chainConfig := params.ArbitrumDevTestChainConfig() + chainConfig := chaininfo.ArbitrumDevTestChainConfig() chainConfig.ArbitrumChainParams.MaxCodeSize = 100 serializedChainConfig, err := json.Marshal(chainConfig) Require(t, err) diff --git a/system_tests/precompile_fuzz_test.go b/system_tests/precompile_fuzz_test.go index 8ab133cf58..82dd393ea2 100644 --- a/system_tests/precompile_fuzz_test.go +++ b/system_tests/precompile_fuzz_test.go @@ -12,10 +12,11 @@ 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 +33,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 9d5737c249..78f34df6c7 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -14,9 +14,10 @@ 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/l1pricing" + "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" @@ -37,7 +38,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()) } @@ -433,12 +434,15 @@ func TestGasAccountingParams(t *testing.T) { Require(t, err) arbGasInfoSpeedLimit, arbGasInfoPoolSize, arbGasInfoTxGasLimit, err := arbGasInfo.GetGasAccountingParams(&bind.CallOpts{Context: ctx}) Require(t, err) + // #nosec G115 if arbGasInfoSpeedLimit.Cmp(big.NewInt(int64(speedLimit))) != 0 { Fatal(t, "expected speed limit to be", speedLimit, "got", arbGasInfoSpeedLimit) } + // #nosec G115 if arbGasInfoPoolSize.Cmp(big.NewInt(int64(txGasLimit))) != 0 { Fatal(t, "expected pool size to be", txGasLimit, "got", arbGasInfoPoolSize) } + // #nosec G115 if arbGasInfoTxGasLimit.Cmp(big.NewInt(int64(txGasLimit))) != 0 { Fatal(t, "expected tx gas limit to be", txGasLimit, "got", arbGasInfoTxGasLimit) } diff --git a/system_tests/program_gas_test.go b/system_tests/program_gas_test.go index 119897cbfe..3450214a14 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" @@ -13,9 +14,11 @@ 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" + "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -23,6 +26,162 @@ import ( "github.com/offchainlabs/nitro/util/testhelpers" ) +const HOSTIO_INK = 8400 + +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) { + t.Parallel() + + builder := setupGasCostTest(t) + auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) + stylusProgram := deployWasm(t, builder.ctx, auth, builder.L2.Client, rustFile("hostio-test")) + + hostio := "write_result" + + // 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 + signature = "writeResult(uint256)" + 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)) +} + +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")) + + hostio := "read_args" + + 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)) +} + +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")) + + hostio := "msg_reentrant" + + signature := "writeResultEmpty()" + expectedInk := HOSTIO_INK + // #nosec G115 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) +} + +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")) + + hostio := "storage_cache_bytes32" + + signature := "storageCacheBytes32()" + expectedInk := HOSTIO_INK + (13440-HOSTIO_INK)*2 + // #nosec G115 + checkInkUsage(t, builder, stylusProgram, hostio, signature, nil, uint64(expectedInk)) +} + +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")) + + hostio := "pay_for_memory_grow" + 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)) +} + func TestProgramSimpleCost(t *testing.T) { builder := setupGasCostTest(t) auth := builder.L2Info.GetDefaultTransactOpts("Owner", builder.ctx) @@ -122,20 +281,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 +512,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 +522,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 +564,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..55d26c8372 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -16,13 +16,14 @@ 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/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/node_interfacegen" @@ -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/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/staker_test.go b/system_tests/staker_test.go index 67ce260529..69645d8878 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -33,6 +33,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/staker" + legacystaker "github.com/offchainlabs/nitro/staker/legacy" "github.com/offchainlabs/nitro/staker/validatorwallet" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -152,7 +153,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) validatorUtils, err := rollupgen.NewValidatorUtils(l2nodeA.DeployInfo.ValidatorUtils, builder.L1.Client) Require(t, err) - valConfigA := staker.TestL1ValidatorConfig + valConfigA := legacystaker.TestL1ValidatorConfig parentChainID, err := builder.L1.Client.ChainID(ctx) if err != nil { t.Fatalf("Failed to get parent chain id: %v", err) @@ -208,11 +209,11 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) Require(t, err) err = statelessA.Start(ctx) Require(t, err) - stakerA, err := staker.NewStaker( + stakerA, err := legacystaker.NewStaker( l2nodeA.L1Reader, valWalletA, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfigA }, + func() *legacystaker.L1ValidatorConfig { return &valConfigA }, nil, statelessA, nil, @@ -222,7 +223,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) ) Require(t, err) err = stakerA.Initialize(ctx) - if stakerA.Strategy() != staker.WatchtowerStrategy { + if stakerA.Strategy() != legacystaker.WatchtowerStrategy { err = valWalletA.Initialize(ctx) Require(t, err) } @@ -246,7 +247,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) } valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) Require(t, err) - valConfigB := staker.TestL1ValidatorConfig + valConfigB := legacystaker.TestL1ValidatorConfig valConfigB.Strategy = "MakeNodes" statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, @@ -261,11 +262,11 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) Require(t, err) err = statelessB.Start(ctx) Require(t, err) - stakerB, err := staker.NewStaker( + stakerB, err := legacystaker.NewStaker( l2nodeB.L1Reader, valWalletB, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfigB }, + func() *legacystaker.L1ValidatorConfig { return &valConfigB }, nil, statelessB, nil, @@ -276,18 +277,18 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) Require(t, err) err = stakerB.Initialize(ctx) Require(t, err) - if stakerB.Strategy() != staker.WatchtowerStrategy { + if stakerB.Strategy() != legacystaker.WatchtowerStrategy { err = valWalletB.Initialize(ctx) Require(t, err) } valWalletC := validatorwallet.NewNoOp(builder.L1.Client, l2nodeA.DeployInfo.Rollup) - valConfigC := staker.TestL1ValidatorConfig + valConfigC := legacystaker.TestL1ValidatorConfig valConfigC.Strategy = "Watchtower" - stakerC, err := staker.NewStaker( + stakerC, err := legacystaker.NewStaker( l2nodeA.L1Reader, valWalletC, bind.CallOpts{}, - func() *staker.L1ValidatorConfig { return &valConfigC }, + func() *legacystaker.L1ValidatorConfig { return &valConfigC }, nil, statelessA, nil, @@ -296,7 +297,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) nil, ) Require(t, err) - if stakerC.Strategy() != staker.WatchtowerStrategy { + if stakerC.Strategy() != legacystaker.WatchtowerStrategy { err = valWalletC.Initialize(ctx) Require(t, err) } @@ -409,7 +410,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) if faultyStaker { conflictInfo, err := validatorUtils.FindStakerConflict(&bind.CallOpts{}, l2nodeA.DeployInfo.Rollup, l1authA.From, srv.Address, big.NewInt(1024)) Require(t, err) - if staker.ConflictType(conflictInfo.Ty) == staker.CONFLICT_TYPE_FOUND { + if legacystaker.ConflictType(conflictInfo.Ty) == legacystaker.CONFLICT_TYPE_FOUND { cancelBackgroundTxs() } } diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index c8312350e6..8388e8417c 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" @@ -27,6 +28,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" ) @@ -135,7 +137,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) @@ -206,7 +208,7 @@ func FuzzStateTransition(f *testing.F) { } numberOfMessageRunModes := uint8(core.MessageReplayMode) + 1 // TODO update number of run modes when new mode is added runMode := core.MessageRunMode(runModeSeed % numberOfMessageRunModes) - _, err = BuildBlock(statedb, genesis, noopChainContext{}, params.ArbitrumOneChainConfig(), inbox, seqBatch, runMode) + _, err = BuildBlock(statedb, genesis, noopChainContext{}, chaininfo.ArbitrumOneChainConfig(), inbox, seqBatch, runMode) 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. 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..98dab7ad39 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 { @@ -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, _ bool) containers.PromiseInterface[validator.ExecutionRun] { s.ExecSpawned = append(s.ExecSpawned, input.Id) return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{ startState: input.StartState, @@ -155,6 +155,10 @@ func (r *mockExecRun) PrepareRange(uint64, uint64) containers.PromiseInterface[s return containers.NewReadyPromise[struct{}](struct{}{}, nil) } +func (r *mockExecRun) CheckAlive(ctx context.Context) error { + return nil +} + func (r *mockExecRun) Close() {} func createMockValidationNode(t *testing.T, ctx context.Context, config *server_arb.ArbitratorSpawnerConfig) (*mockSpawner, *node.Node) { @@ -256,7 +260,7 @@ func TestValidationServerAPI(t *testing.T) { if res != endState { t.Error("unexpected mock validation run") } - execRun, err := client.CreateExecutionRun(wasmRoot, &valInput).Await(ctx) + execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx) Require(t, err) step0 := execRun.GetStepAt(0) step0Res, err := step0.Await(ctx) @@ -381,9 +385,9 @@ func TestExecutionKeepAlive(t *testing.T) { Require(t, err) valInput := validator.ValidationInput{} - runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput).Await(ctx) + runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx) Require(t, err) - runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput).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/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/redisutil.go b/util/redisutil/redisutil.go index 01ba836d5b..fafb816b8a 100644 --- a/util/redisutil/redisutil.go +++ b/util/redisutil/redisutil.go @@ -1,14 +1,231 @@ 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) 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: %w", 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 +} 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..c242ac26ab 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" ) @@ -95,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. @@ -125,9 +118,15 @@ func getAllStackTraces() string { } func (s *StopWaiterSafe) stopAndWaitImpl(warningTimeout time.Duration) error { - if !s.stopOnly() { + 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 5319927887..68e49ac2be 100644 --- a/util/stopwaiter/stopwaiter_test.go +++ b/util/stopwaiter/stopwaiter_test.go @@ -5,10 +5,12 @@ package stopwaiter import ( "context" + "sync/atomic" "testing" "time" "github.com/ethereum/go-ethereum/log" + "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -72,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") + } +} 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 934362f00a..c04817d654 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 { @@ -155,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 } @@ -196,6 +198,10 @@ func (r *ExecutionClientRun) SendKeepAlive(ctx context.Context) time.Duration { return time.Minute // TODO: configurable } +func (r *ExecutionClientRun) CheckAlive(ctx context.Context) error { + return r.client.client.CallContext(ctx, nil, server_api.Namespace+"_checkAlive", r.id) +} + func (r *ExecutionClientRun) Start(ctx_in context.Context) { r.StopWaiter.Start(ctx_in, r) r.CallIteratively(r.SendKeepAlive) diff --git a/validator/execution_state.go b/validator/execution_state.go index 092fbe2908..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" ) @@ -18,6 +19,13 @@ type GoGlobalState struct { PosInBatch uint64 } +func (g GoGlobalState) String() string { + return fmt.Sprintf( + "BlockHash: %s, SendRoot: %s, Batch: %d, PosInBatch: %d", + g.BlockHash.Hex(), g.SendRoot.Hex(), g.Batch, g.PosInBatch, + ) +} + type MachineStatus uint8 const ( diff --git a/validator/interface.go b/validator/interface.go index 9fb831ca0d..249cf1b1c3 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" ) @@ -25,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] } @@ -36,4 +37,5 @@ type ExecutionRun interface { GetProofAt(uint64) containers.PromiseInterface[[]byte] PrepareRange(uint64, uint64) containers.PromiseInterface[struct{}] Close() + CheckAlive(ctx context.Context) error } 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/bold_machine.go b/validator/server_arb/bold_machine.go new file mode 100644 index 0000000000..6ca48ba228 --- /dev/null +++ b/validator/server_arb/bold_machine.go @@ -0,0 +1,145 @@ +package server_arb + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + + "github.com/offchainlabs/nitro/validator" +) + +// boldMachine wraps a server_arb.MachineInterface. +type BoldMachine struct { + inner MachineInterface + zeroMachine *ArbitratorMachine + hasStepped bool +} + +// Ensure boldMachine implements server_arb.MachineInterface. +var _ MachineInterface = (*BoldMachine)(nil) + +func newBoldMachine(inner MachineInterface) *BoldMachine { + z := 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 BoldMachineWrapper(inner MachineInterface) MachineInterface { + return newBoldMachine(inner) +} + +// CloneMachineInterface returns a new boldMachine with the same inner machine. +func (m *BoldMachine) CloneMachineInterface() 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() +} diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index d29a88d34d..66d8e158d0 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -10,9 +10,8 @@ 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" "github.com/offchainlabs/nitro/util/stopwaiter" "github.com/offchainlabs/nitro/validator" @@ -25,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), @@ -105,21 +105,9 @@ func (e *executionRun) machineHashesWithStepSize( if err != nil { return nil, err } - log.Debug(fmt.Sprintf("Advanced machine to index %d, beginning hash computation", machineStartIndex)) - - // 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. - var machineHashes []common.Hash - if machineStartIndex == 0 { - gs := machine.GetGlobalState() - log.Debug(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()) - } + log.Info("Advanced WASM machine index, beginning challenge hash computation", "machineStartIndex", machineStartIndex) + + machineHashes := []common.Hash{machine.Hash()} startHash := machineHashes[0] // If we only want 1 hash, we can return early. @@ -195,6 +183,6 @@ func (e *executionRun) GetLastStep() containers.PromiseInterface[*validator.Mach return e.GetStepAt(^uint64(0)) } -func machineFinishedHash(gs validator.GoGlobalState) common.Hash { - return crypto.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) +func (e *executionRun) CheckAlive(ctx context.Context) error { + return nil } diff --git a/validator/server_arb/execution_run_test.go b/validator/server_arb/execution_run_test.go index 479db58515..381cfa63a8 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" ) @@ -15,9 +16,6 @@ type mockMachine struct { } func (m *mockMachine) Hash() common.Hash { - if m.gs.PosInBatch == m.totalSteps-1 { - return machineFinishedHash(m.gs) - } return m.gs.Hash() } @@ -47,6 +45,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 } @@ -102,7 +103,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") } @@ -136,7 +137,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{ @@ -181,7 +182,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{ @@ -190,10 +191,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") } diff --git a/validator/server_arb/machine.go b/validator/server_arb/machine.go index 1e73e6b212..09a00635fb 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" @@ -37,6 +39,7 @@ type MachineInterface interface { CloneMachineInterface() MachineInterface GetStepCount() uint64 IsRunning() bool + IsErrored() bool ValidForStep(uint64) bool Status() uint8 Step(context.Context, uint64) error @@ -51,16 +54,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 +90,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 { @@ -101,6 +118,14 @@ func LoadSimpleMachine(wasm string, libraries []string, debugChain bool) (*Arbit return machineFromPointer(mach), nil } +func NewFinishedMachine(gs validator.GoGlobalState) *ArbitratorMachine { + mach := C.arbitrator_new_finished(GlobalStateToC(gs)) + if mach == nil { + return nil + } + return machineFromPointer(mach) +} + func (m *ArbitratorMachine) Freeze() { m.frozen = true } @@ -112,6 +137,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 +385,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 +422,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/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..76c19dc8f2 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()) @@ -56,20 +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 - 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) (*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), - config: config, + locator: locator, + machineLoader: NewArbMachineLoader(&DefaultArbitratorMachineConfig, locator), + machineWrappers: make([]MachineWrapper, 0), + config: config, + } + for _, opt := range opts { + opt(spawner) } return spawner, nil } @@ -159,12 +181,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 + for _, wrapper := range v.machineWrappers { + mach = wrapper(mach) + } var steps uint64 for mach.IsRunning() { var count uint64 = 500000000 @@ -206,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 { @@ -218,7 +244,16 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input machine.Destroy() return nil, err } - return machine, nil + var wrapped MachineInterface + if useBoldMachine { + wrapped = BoldMachineWrapper(machine) + } else { + 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/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/validation_api.go b/validator/valnode/validation_api.go index ef3e1b2c49..dab74f6e29 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -80,12 +80,16 @@ 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, useBoldMachineOptional *bool) (uint64, error) { input, err := server_api.ValidationInputFromJson(jsonInput) if err != nil { return 0, err } - execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input).Await(ctx) + useBoldMachine := false + if useBoldMachineOptional != nil { + useBoldMachine = *useBoldMachineOptional + } + execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input, useBoldMachine).Await(ctx) if err != nil { return 0, err } @@ -187,6 +191,14 @@ func (a *ExecServerAPI) ExecKeepAlive(ctx context.Context, execid uint64) error return nil } +func (a *ExecServerAPI) CheckAlive(ctx context.Context, execid uint64) error { + run, err := a.getRun(execid) + if err != nil { + return err + } + return run.CheckAlive(ctx) +} + func (a *ExecServerAPI) CloseExec(execid uint64) { a.runIdLock.Lock() defer a.runIdLock.Unlock() diff --git a/validator/valnode/valnode.go b/validator/valnode/valnode.go index 972e11189d..e3bf662aaa 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 { @@ -93,7 +94,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, spawnerOpts ...server_arb.SpawnerOption) (*ValidationNode, error) { config := configFetcher() locator, err := server_common.NewMachineLocator(config.Wasm.RootPath) if err != nil { @@ -102,7 +103,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, spawnerOpts...) if err != nil { return nil, err } 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..40ceb3e5bf 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() { @@ -136,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) 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"