diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index a21cdd8f1d..080dfea391 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -188,6 +188,7 @@ type BatchPosterConfig struct { UseEscapeHatch bool `koanf:"use-escape-hatch"` EspressoTxnsPollingInterval time.Duration `koanf:"espresso-txns-polling-interval"` EspressoSwitchDelayThreshold uint64 `koanf:"espresso-switch-delay-threshold"` + EspressoTEEVerifierAddress string `koanf:"espresso-tee-verifier-address"` } func (c *BatchPosterConfig) Validate() error { @@ -249,6 +250,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".use-escape-hatch", DefaultBatchPosterConfig.UseEscapeHatch, "if true, batches will be posted without doing the espresso verification when hotshot is down. If false, wait for hotshot being up") f.Duration(prefix+".espresso-txns-polling-interval", DefaultBatchPosterConfig.EspressoTxnsPollingInterval, "interval between polling for transactions to be included in the block") f.Uint64(prefix+".espresso-switch-delay-threshold", DefaultBatchPosterConfig.EspressoSwitchDelayThreshold, "specifies the switch delay threshold used to determine hotshot liveness") + f.String(prefix+".espresso-tee-verifier-address", DefaultBatchPosterConfig.EspressoTEEVerifierAddress, "") redislock.AddConfigOptions(prefix+".redis-lock", f) dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfig) genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultBatchPosterConfig.ParentChainWallet.Pathname) @@ -287,6 +289,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{ EspressoSwitchDelayThreshold: 350, LightClientAddress: "", HotShotUrl: "", + EspressoTEEVerifierAddress: "", } var DefaultBatchPosterL1WalletConfig = genericconf.WalletConfig{ @@ -387,6 +390,7 @@ func NewBatchPoster(ctx context.Context, opts *BatchPosterOpts) (*BatchPoster, e opts.Streamer.UseEscapeHatch = opts.Config().UseEscapeHatch opts.Streamer.espressoTxnsPollingInterval = opts.Config().EspressoTxnsPollingInterval opts.Streamer.espressoSwitchDelayThreshold = opts.Config().EspressoSwitchDelayThreshold + opts.Streamer.espressoTEEVerifierAddress = common.HexToAddress(opts.Config().EspressoTEEVerifierAddress) } b := &BatchPoster{ @@ -1827,15 +1831,6 @@ func (b *BatchPoster) Start(ctxIn context.Context) { } b.CallIteratively(func(ctx context.Context) time.Duration { var err error - espresso, _ := b.streamer.isEspressoMode() - if !espresso { - if b.streamer.lightClientReader != nil && b.streamer.espressoClient != nil { - // This mostly happens when a non-espresso nitro is upgrading to espresso nitro. - // The batch poster is set a espresso client and a light client reader, but waiting - // for the upgrade action - return b.config().PollInterval - } - } if common.HexToAddress(b.config().GasRefunderAddress) != (common.Address{}) { gasRefunderBalance, err := b.l1Reader.Client().BalanceAt(ctx, common.HexToAddress(b.config().GasRefunderAddress), nil) if err != nil { diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 4a7296caf5..7ce33d47c5 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -84,8 +84,9 @@ type TransactionStreamer struct { espressoTxnsPollingInterval time.Duration espressoSwitchDelayThreshold uint64 // Public these fields for testing - HotshotDown bool - UseEscapeHatch bool + HotshotDown bool + UseEscapeHatch bool + espressoTEEVerifierAddress common.Address } type TransactionStreamerConfig struct { @@ -670,21 +671,6 @@ func (s *TransactionStreamer) AddFakeInitMessage() error { }}) } -func (s *TransactionStreamer) isEspressoMode() (bool, error) { - config, err := s.exec.GetArbOSConfigAtHeight(0) // Pass 0 to get the ArbOS config at current block height. - if err != nil { - return false, fmt.Errorf("error obtaining arbos config: %w", err) - } - if config == nil { - return false, fmt.Errorf("arbos config is not defined") - } - isSetInConfig := config.ArbitrumChainParams.EspressoTEEVerifierAddress != common.Address{} - if !isSetInConfig { - return false, nil - } - return true, nil -} - // Used in redis tests func (s *TransactionStreamer) GetMessageCountSync(t *testing.T) (arbutil.MessageIndex, error) { s.insertionMutex.Lock() @@ -1777,10 +1763,7 @@ func getLogLevel(err error) func(string, ...interface{}) { func (s *TransactionStreamer) espressoSwitch(ctx context.Context, ignored struct{}) time.Duration { retryRate := s.espressoTxnsPollingInterval * 50 - enabledEspresso, err := s.isEspressoMode() - if err != nil { - return retryRate - } + enabledEspresso := s.espressoTEEVerifierAddress != common.Address{} if enabledEspresso { err := s.toggleEscapeHatch(ctx) if err != nil { diff --git a/system_tests/espresso_arbos_test.go b/system_tests/espresso_arbos_test.go deleted file mode 100644 index 91474e132a..0000000000 --- a/system_tests/espresso_arbos_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package arbtest - -import ( - "context" - "encoding/json" - "fmt" - "math/big" - "testing" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/solgen/go/precompilesgen" -) - -func EspressoArbOSTestChainConfig() *params.ChainConfig { - return ¶ms.ChainConfig{ - ChainID: big.NewInt(412346), - HomesteadBlock: big.NewInt(0), - DAOForkBlock: nil, - DAOForkSupport: true, - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArbitrumChainParams: EspressoTestChainParams(), - Clique: ¶ms.CliqueConfig{ - Period: 0, - Epoch: 0, - }, - } -} -func EspressoTestChainParams() params.ArbitrumChainParams { - return params.ArbitrumChainParams{ - EnableArbOS: true, - AllowDebugPrecompiles: true, - DataAvailabilityCommittee: false, - InitialArbOSVersion: 31, - InitialChainOwner: common.Address{}, - EspressoTEEVerifierAddress: common.Address{}, - } -} - -func waitForConfigUpdate(t *testing.T, ctx context.Context, builder *NodeBuilder) error { - - return waitForWith(ctx, 120*time.Second, 1*time.Second, func() bool { - newArbOSConfig, err := builder.L2.ExecNode.GetArbOSConfigAtHeight(0) - Require(t, err) - - emptyAddress := common.Address{} - if newArbOSConfig.ArbitrumChainParams.EspressoTEEVerifierAddress != emptyAddress { - return false - } - Require(t, err) - return true - }) -} - -func TestEspressoArbOSConfig(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - builder, cleanup := createL1AndL2Node(ctx, t, true) - defer cleanup() - - err := waitForL1Node(ctx) - Require(t, err) - - cleanEspresso := runEspresso() - defer cleanEspresso() - - // wait for the builder - err = waitForEspressoNode(ctx) - Require(t, err) - - l2Node := builder.L2 - - // Wait for the initial message - expected := arbutil.MessageIndex(1) - err = waitFor(ctx, func() bool { - msgCnt, err := l2Node.ConsensusNode.TxStreamer.GetMessageCount() - if err != nil { - panic(err) - } - - validatedCnt := l2Node.ConsensusNode.BlockValidator.Validated(t) - return msgCnt >= expected && validatedCnt >= expected - }) - Require(t, err) - - initialArbOSConfig, err := builder.L2.ExecNode.GetArbOSConfigAtHeight(0) - Require(t, err) - - // assert that espresso is initially enabled - if initialArbOSConfig.ArbitrumChainParams.EspressoTEEVerifierAddress != common.HexToAddress(verifierAddress) { - err = fmt.Errorf("Initial config should have EspressoTEEVerifierAddress == common.HexToAddress(verifierAddress)!") - - } - Require(t, err) - - newArbOwner, err := precompilesgen.NewArbOwner(common.HexToAddress("0x070"), builder.L2.Client) - Require(t, err) - - newArbDebug, err := precompilesgen.NewArbDebug(common.HexToAddress("0xff"), builder.L2.Client) - Require(t, err) - - l2auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) - - _, err = newArbDebug.BecomeChainOwner(&l2auth) - Require(t, err) - chainConfig, err := json.Marshal(EspressoArbOSTestChainConfig()) - Require(t, err) - - chainConfigString := string(chainConfig) - - _, err = newArbOwner.SetChainConfig(&l2auth, chainConfigString) - Require(t, err) - // check if chain config is updated TODO replace this with a wait for with to poll for some time potentially - - err = waitForConfigUpdate(t, ctx, builder) - Require(t, err) -} diff --git a/system_tests/espresso_sovereign_sequencer_test.go b/system_tests/espresso_sovereign_sequencer_test.go index 3d203cf20c..f532b7e4be 100644 --- a/system_tests/espresso_sovereign_sequencer_test.go +++ b/system_tests/espresso_sovereign_sequencer_test.go @@ -25,7 +25,6 @@ func createL1AndL2Node( builder.l1StackConfig.WSHost = "0.0.0.0" builder.l1StackConfig.DataDir = t.TempDir() builder.l1StackConfig.WSModules = append(builder.l1StackConfig.WSModules, "eth") - builder.chainConfig.ArbitrumChainParams.EspressoTEEVerifierAddress = common.HexToAddress(verifierAddress) // poster config builder.nodeConfig.BatchPoster.Enable = true @@ -35,6 +34,7 @@ func createL1AndL2Node( builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour builder.nodeConfig.BatchPoster.LightClientAddress = lightClientAddress builder.nodeConfig.BatchPoster.HotShotUrl = hotShotUrl + builder.nodeConfig.BatchPoster.EspressoTEEVerifierAddress = verifierAddress // validator config builder.nodeConfig.BlockValidator.Enable = true