Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support and test ArbOS 20 #2108

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions arbos/arbosState/arbosstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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))

Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions execution/gethexec/tx_pre_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
1 change: 1 addition & 0 deletions system_tests/block_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions system_tests/estimation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
Loading