From f3b06106937970e573690ccf2c4feed6b04cf774 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sun, 28 Jan 2024 11:12:37 -0700 Subject: [PATCH] Support and test ArbOS 20 --- arbos/arbosState/arbosstate.go | 34 ++++++++++++++++------------ execution/gethexec/tx_pre_checker.go | 5 ++++ go-ethereum | 2 +- system_tests/block_validator_test.go | 1 + system_tests/estimation_test.go | 17 ++++++++++++++ 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index caf44e2a99..7fdb61aba2 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -277,14 +277,13 @@ func (state *ArbosState) UpgradeArbosVersion( } } - switch state.arbosVersion { - case 1: - ensure(state.l1PricingState.SetLastSurplus(common.Big0, 1)) + nextArbosVersion := state.arbosVersion + 1 + switch nextArbosVersion { case 2: + ensure(state.l1PricingState.SetLastSurplus(common.Big0, 1)) + case 3: ensure(state.l1PricingState.SetPerBatchGasCost(0)) ensure(state.l1PricingState.SetAmortizedCostCapBips(math.MaxUint64)) - case 3: - // no state changes needed case 4: // no state changes needed case 5: @@ -296,10 +295,12 @@ func (state *ArbosState) UpgradeArbosVersion( case 8: // no state changes needed case 9: + // no state changes needed + case 10: ensure(state.l1PricingState.SetL1FeesAvailable(stateDB.GetBalance( l1pricing.L1PricerFundsPoolAddress, ))) - case 10: + case 11: // Update the PerBatchGasCost to a more accurate value compared to the old v6 default. ensure(state.l1PricingState.SetPerBatchGasCost(l1pricing.InitialPerBatchGasCostV12)) @@ -316,26 +317,29 @@ func (state *ArbosState) UpgradeArbosVersion( ensure(state.chainOwners.ClearList()) } // ArbOS versions 12 through 19 are left to Orbit chains for custom upgrades. - // TODO: currently you can't get to ArbOS 20 without hitting the default case. - case 19: + case 20: if !chainConfig.DebugMode() { // This upgrade isn't finalized so we only want to support it for testing return fmt.Errorf( "the chain is upgrading to unsupported ArbOS version %v, %w", - state.arbosVersion+1, + nextArbosVersion, ErrFatalNodeOutOfDate, ) } // Update Brotli compression level for fast compression from 0 to 1 ensure(state.SetBrotliCompressionLevel(1)) default: - return fmt.Errorf( - "the chain is upgrading to unsupported ArbOS version %v, %w", - state.arbosVersion+1, - ErrFatalNodeOutOfDate, - ) + if nextArbosVersion >= 12 && state.arbosVersion < 20 { + // ArbOS versions 12 through 19 are left to Orbit chains for custom upgrades. + } else { + return fmt.Errorf( + "the chain is upgrading to unsupported ArbOS version %v, %w", + nextArbosVersion, + ErrFatalNodeOutOfDate, + ) + } } - state.arbosVersion++ + state.arbosVersion = nextArbosVersion } if firstTime && upgradeTo >= 6 { diff --git a/execution/gethexec/tx_pre_checker.go b/execution/gethexec/tx_pre_checker.go index 51ba88fec8..cff8b04d32 100644 --- a/execution/gethexec/tx_pre_checker.go +++ b/execution/gethexec/tx_pre_checker.go @@ -116,6 +116,11 @@ func PreCheckTx(bc *core.BlockChain, chainConfig *params.ChainConfig, header *ty if tx.Gas() < params.TxGas { return core.ErrIntrinsicGas } + if tx.Type() >= types.ArbitrumDepositTxType || tx.Type() == types.BlobTxType { + // Should be unreachable for Arbitrum types due to UnmarshalBinary not accepting Arbitrum internal txs + // and we want to disallow BlobTxType since Arbitrum doesn't support EIP-4844 txs yet. + return types.ErrTxTypeNotSupported + } sender, err := types.Sender(types.MakeSigner(chainConfig, header.Number, header.Time), tx) if err != nil { return err diff --git a/go-ethereum b/go-ethereum index 214d1c1c9b..1acd9c64ac 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 214d1c1c9b6ef7830dfb22c3bba7563b89d18960 +Subproject commit 1acd9c64ac5804729475ef60aa578b4ec52fa0e6 diff --git a/system_tests/block_validator_test.go b/system_tests/block_validator_test.go index e2e4227bf6..1fcf2bab34 100644 --- a/system_tests/block_validator_test.go +++ b/system_tests/block_validator_test.go @@ -93,6 +93,7 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops contractCode = append(contractCode, byte(vm.PUSH0)) contractCode = append(contractCode, byte(vm.CODECOPY)) contractCode = append(contractCode, byte(vm.PUSH0)) + contractCode = append(contractCode, byte(vm.BLOBHASH)) contractCode = append(contractCode, byte(vm.RETURN)) basefee := builder.L2.GetBaseFee(t) var err error diff --git a/system_tests/estimation_test.go b/system_tests/estimation_test.go index eda7fb449f..6f47c14f1f 100644 --- a/system_tests/estimation_test.go +++ b/system_tests/estimation_test.go @@ -12,6 +12,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/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -180,6 +181,22 @@ func TestDifficultyForArbOSTen(t *testing.T) { } } +func TestBlobBasefeeReverts(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, false) + cleanup := builder.Build(t) + defer cleanup() + + _, err := builder.L2.Client.CallContract(ctx, ethereum.CallMsg{ + Data: []byte{byte(vm.BLOBBASEFEE)}, + }, nil) + if err == nil { + t.Error("Expected BLOBBASEFEE to revert") + } +} + func TestComponentEstimate(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel()