From 5eb9704138f997a7b76f1ebf18745116f4ed2c68 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Mon, 9 Dec 2024 15:46:36 -0600 Subject: [PATCH 1/7] Allow waiting for a minimum amount of time since parent assertion was created to post a new assertion --- arbnode/node.go | 2 ++ bold | 2 +- staker/bold/bold_staker.go | 7 ++++++- system_tests/bold_challenge_protocol_test.go | 1 + system_tests/bold_new_challenge_test.go | 1 + system_tests/overflow_assertions_test.go | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arbnode/node.go b/arbnode/node.go index f2e3433ecd..48920cdbdd 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -212,6 +212,7 @@ func ConfigDefaultL1NonSequencerTest() *Config { config.Staker = legacystaker.TestL1ValidatorConfig config.Staker.Enable = false config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}} + config.Bold.MinimumGapToParentAssertion = 0 return &config } @@ -230,6 +231,7 @@ func ConfigDefaultL2Test() *Config { config.Staker.Enable = false config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}} config.TransactionStreamer = DefaultTransactionStreamerConfig + config.Bold.MinimumGapToParentAssertion = 0 return &config } diff --git a/bold b/bold index d0a87de774..1b1c34c319 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit d0a87de774aecfa97161efd1b0a924d4d5fbcf74 +Subproject commit 1b1c34c31967242a492d29925640ede98d921fca diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index 1a8eed80fa..ad0e24e338 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -57,7 +57,9 @@ type BoldConfig struct { // 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"` + AssertionConfirmingInterval time.Duration `koanf:"assertion-confirming-interval"` + // How long to wait since parent assertion was created to post a new assertion + MinimumGapToParentAssertion time.Duration `koanf:"minimum-gap-to-parent-assertion"` API bool `koanf:"api"` APIHost string `koanf:"api-host"` APIPort uint16 `koanf:"api-port"` @@ -98,6 +100,7 @@ var DefaultBoldConfig = BoldConfig{ AssertionPostingInterval: time.Minute * 15, AssertionScanningInterval: time.Minute, AssertionConfirmingInterval: time.Minute, + MinimumGapToParentAssertion: time.Minute, // Correct default? API: false, APIHost: "127.0.0.1", APIPort: 9393, @@ -121,6 +124,7 @@ func BoldConfigAddOptions(prefix string, f *flag.FlagSet) { 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+".minimum-gap-to-parent-assertion", DefaultBoldConfig.MinimumGapToParentAssertion, "minimum duration to wait since the parent assertion was created to post a new assertion") 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") @@ -448,6 +452,7 @@ func newBOLDChallengeManager( challengemanager.StackWithPollingInterval(scanningInterval), challengemanager.StackWithPostingInterval(postingInterval), challengemanager.StackWithConfirmationInterval(confirmingInterval), + challengemanager.StackWithMinimumGapToParentAssertion(config.MinimumGapToParentAssertion), challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), challengemanager.StackWithHeaderProvider(l1Reader), } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 777817bf3e..3677021c00 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -417,6 +417,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp challengemanager.StackWithMode(modes.MakeMode), challengemanager.StackWithPostingInterval(time.Second * 3), challengemanager.StackWithPollingInterval(time.Second), + challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), challengemanager.StackWithAverageBlockCreationTime(time.Second), } diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index ad6e44bc71..eb452ca5d4 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -344,6 +344,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB challengemanager.StackWithPostingInterval(time.Second * 3), challengemanager.StackWithPollingInterval(time.Second), challengemanager.StackWithAverageBlockCreationTime(time.Second), + challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), } challengeManager, err := challengemanager.NewChallengeStack( diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index c024a43070..848c61e7d3 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -224,6 +224,7 @@ func TestOverflowAssertions(t *testing.T) { challengemanager.StackWithPostingInterval(time.Second), challengemanager.StackWithPollingInterval(time.Millisecond * 500), challengemanager.StackWithAverageBlockCreationTime(time.Second), + challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), } manager, err := challengemanager.NewChallengeStack( From 81dcb5a01589dcb58fd009fd622af1aef38f8e1a Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Mon, 9 Dec 2024 16:23:57 -0600 Subject: [PATCH 2/7] minor fix --- system_tests/bold_challenge_protocol_test.go | 2 +- system_tests/bold_new_challenge_test.go | 2 +- system_tests/overflow_assertions_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 3677021c00..83700fc838 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -417,7 +417,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp challengemanager.StackWithMode(modes.MakeMode), challengemanager.StackWithPostingInterval(time.Second * 3), challengemanager.StackWithPollingInterval(time.Second), - challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), + challengemanager.StackWithMinimumGapToParentAssertion(0), challengemanager.StackWithAverageBlockCreationTime(time.Second), } diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index eb452ca5d4..fae4a57deb 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -344,7 +344,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB challengemanager.StackWithPostingInterval(time.Second * 3), challengemanager.StackWithPollingInterval(time.Second), challengemanager.StackWithAverageBlockCreationTime(time.Second), - challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), + challengemanager.StackWithMinimumGapToParentAssertion(0), } challengeManager, err := challengemanager.NewChallengeStack( diff --git a/system_tests/overflow_assertions_test.go b/system_tests/overflow_assertions_test.go index 848c61e7d3..eb2bb01470 100644 --- a/system_tests/overflow_assertions_test.go +++ b/system_tests/overflow_assertions_test.go @@ -224,7 +224,7 @@ func TestOverflowAssertions(t *testing.T) { challengemanager.StackWithPostingInterval(time.Second), challengemanager.StackWithPollingInterval(time.Millisecond * 500), challengemanager.StackWithAverageBlockCreationTime(time.Second), - challengemanager.StackWithMinimumGapToParentAssertionCreationTime(0), + challengemanager.StackWithMinimumGapToParentAssertion(0), } manager, err := challengemanager.NewChallengeStack( From 231da30980575693c2c9f6d7be127ac77772cc9d Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 10 Dec 2024 10:52:02 -0600 Subject: [PATCH 3/7] update bold pin --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 1b1c34c319..81f1b421b2 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 1b1c34c31967242a492d29925640ede98d921fca +Subproject commit 81f1b421b2dbbf96c7a2b427a9458667b07b0b27 From d3de311d8ac5153ee4299b0053d7a93d84e735b3 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 2 Jan 2025 13:51:48 -0700 Subject: [PATCH 4/7] remove most occurences of log.Crit --- arbos/arbosState/arbosstate.go | 7 ++-- arbos/arbosState/initialize.go | 4 +-- arbos/programs/api.go | 10 +++--- arbos/programs/native_api.go | 5 ++- arbos/programs/programs.go | 2 +- arbstate/inbox.go | 6 ++-- precompiles/context.go | 7 ++-- precompiles/precompile.go | 59 ++++++++++++++++------------------ precompiles/precompile_test.go | 9 ------ system_tests/staker_test.go | 2 +- 10 files changed, 46 insertions(+), 65 deletions(-) diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index 5ee070f942..de1a970b87 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -13,7 +13,6 @@ 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/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" @@ -123,13 +122,13 @@ func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { db := state.NewDatabaseWithConfig(raw, trieConfig) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { - log.Crit("failed to init empty statedb", "error", err) + panic("failed to init empty statedb: " + err.Error()) } burner := burn.NewSystemBurner(nil, false) chainConfig := chaininfo.ArbitrumDevTestChainConfig() newState, err := InitializeArbosState(statedb, burner, chainConfig, arbostypes.TestInitMessage) if err != nil { - log.Crit("failed to open the ArbOS state", "error", err) + panic("failed to open the ArbOS state: " + err.Error()) } return newState, statedb } @@ -139,7 +138,7 @@ func ArbOSVersion(stateDB vm.StateDB) uint64 { backingStorage := storage.NewGeth(stateDB, burn.NewSystemBurner(nil, false)) arbosVersion, err := backingStorage.GetUint64ByUint64(uint64(versionOffset)) if err != nil { - log.Crit("failed to get the ArbOS version", "error", err) + panic("failed to get the ArbOS version: " + err.Error()) } return arbosVersion } diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 8fd417c2b2..840204382c 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -66,7 +66,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, }() statedb, err := state.New(common.Hash{}, stateDatabase, nil) if err != nil { - log.Crit("failed to init empty statedb", "error", err) + panic("failed to init empty statedb :" + err.Error()) } noStateTrieChangesToCommitError := regexp.MustCompile("^triedb layer .+ is disk layer$") @@ -96,7 +96,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, burner := burn.NewSystemBurner(nil, false) arbosState, err := InitializeArbosState(statedb, burner, chainConfig, initMessage) if err != nil { - log.Crit("failed to open the ArbOS state", "error", err) + panic("failed to open the ArbOS state :" + err.Error()) } chainOwner, err := initData.GetChainOwner() diff --git a/arbos/programs/api.go b/arbos/programs/api.go index d8f12ffbd3..cd2143f5d0 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -9,7 +9,6 @@ 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/log" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/util" @@ -151,7 +150,7 @@ func newApiClosures( case vm.STATICCALL: ret, returnGas, err = evm.StaticCall(scope.Contract, contract, input, gas) default: - log.Crit("unsupported call type", "opcode", opcode) + panic("unsupported call type: " + opcode.String()) } interpreter.SetReturnData(ret) @@ -266,7 +265,7 @@ func newApiClosures( original := input crash := func(reason string) { - log.Crit("bad API call", "reason", reason, "request", req, "len", len(original), "remaining", len(input)) + panic("bad API call reason: " + reason + " request: " + string(req) + " len: " + string(len(original)) + " remaining: " + string(len(input))) } takeInput := func(needed int, reason string) []byte { if len(input) < needed { @@ -338,7 +337,7 @@ func newApiClosures( case StaticCall: opcode = vm.STATICCALL default: - log.Crit("unsupported call type", "opcode", opcode) + panic("unsupported call type opcode: " + opcode.String()) } contract := takeAddress() value := takeU256() @@ -414,8 +413,7 @@ func newApiClosures( captureHostio(name, args, outs, startInk, endInk) return []byte{}, nil, 0 default: - log.Crit("unsupported call type", "req", req) - return []byte{}, nil, 0 + panic("unsupported call type: " + string(req)) } } } diff --git a/arbos/programs/native_api.go b/arbos/programs/native_api.go index ab15800ef9..bf9cda658d 100644 --- a/arbos/programs/native_api.go +++ b/arbos/programs/native_api.go @@ -29,7 +29,6 @@ import ( "sync/atomic" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbutil" @@ -69,11 +68,11 @@ func newApi( func getApi(id usize) NativeApi { any, ok := apiObjects.Load(uintptr(id)) if !ok { - log.Crit("failed to load stylus Go API", "id", id) + panic("failed to load stylus Go API id: " + string(id)) } api, ok := any.(NativeApi) if !ok { - log.Crit("wrong type for stylus Go API", "id", id) + panic("wrong type for stylus Go API id: " + string(id)) } return api } diff --git a/arbos/programs/programs.go b/arbos/programs/programs.go index 06ba6ead8c..6b2a0c318b 100644 --- a/arbos/programs/programs.go +++ b/arbos/programs/programs.go @@ -219,7 +219,7 @@ func (p Programs) CallProgram( localAsm, err := getLocalAsm(statedb, moduleHash, contract.Address(), contract.Code, contract.CodeHash, params.PageLimit, evm.Context.Time, debugMode, program) if err != nil { - log.Crit("failed to get local wasm for activated program", "program", contract.Address()) + panic("failed to get local wasm for activated program: " + contract.Address().Hex()) return nil, err } diff --git a/arbstate/inbox.go b/arbstate/inbox.go index b58a7420b7..5539a75ce1 100644 --- a/arbstate/inbox.go +++ b/arbstate/inbox.go @@ -85,11 +85,11 @@ func parseSequencerMessage(ctx context.Context, batchNum uint64, batchBlockHash // Matches the way keyset validation was done inside DAS readers i.e logging the error // But other daproviders might just want to return the error if errors.Is(err, daprovider.ErrSeqMsgValidation) && daprovider.IsDASMessageHeaderByte(payload[0]) { - logLevel := log.Error if keysetValidationMode == daprovider.KeysetPanicIfInvalid { - logLevel = log.Crit + panic(err.Error()) + } else { + log.Error(err.Error()) } - logLevel(err.Error()) } else { return nil, err } diff --git a/precompiles/context.go b/precompiles/context.go index 670ffa7443..86e56ffbff 100644 --- a/precompiles/context.go +++ b/precompiles/context.go @@ -9,7 +9,6 @@ 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/log" "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbosState" @@ -58,7 +57,7 @@ func (c *Context) GasLeft() *uint64 { } func (c *Context) Restrict(err error) { - log.Crit("A metered burner was used for access-controlled work", "error", err) + panic("A metered burner was used for access-controlled work :" + err.Error()) } func (c *Context) HandleError(err error) error { @@ -88,13 +87,13 @@ func testContext(caller addr, evm mech) *Context { } state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracingInfo, false)) if err != nil { - log.Crit("unable to open arbos state", "error", err) + panic("unable to open arbos state :" + err.Error()) } ctx.State = state var ok bool ctx.txProcessor, ok = evm.ProcessingHook.(*arbos.TxProcessor) if !ok { - log.Crit("must have tx processor") + panic("must have tx processor") } return ctx } diff --git a/precompiles/precompile.go b/precompiles/precompile.go index 54d18a0cc9..f34c418313 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -120,7 +120,7 @@ func (e *SolError) Error() string { func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Precompile) { source, err := abi.JSON(strings.NewReader(metadata.ABI)) if err != nil { - log.Crit("Bad ABI") + panic("Bad ABI") } implementerType := reflect.TypeOf(implementer) @@ -128,12 +128,12 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr _, ok := implementerType.Elem().FieldByName("Address") if !ok { - log.Crit("Implementer for precompile ", contract, " is missing an Address field") + panic("Implementer for precompile " + contract + " is missing an Address field") } address, ok := reflect.ValueOf(implementer).Elem().FieldByName("Address").Interface().(addr) if !ok { - log.Crit("Implementer for precompile ", contract, "'s Address field has the wrong type") + panic("Implementer for precompile " + contract + "'s Address field has the wrong type") } gethAbiFuncTypeEquality := func(actual, geth reflect.Type) bool { @@ -167,7 +167,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr name = capitalize + name[1:] if len(method.ID) != 4 { - log.Crit("Method ID isn't 4 bytes") + panic("Method ID isn't 4 bytes") } id := *(*[4]byte)(method.ID) @@ -175,7 +175,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr handler, ok := implementerType.MethodByName(name) if !ok { - log.Crit("Precompile " + contract + " must implement " + name) + panic("Precompile " + contract + " must implement " + name) } var needs = []reflect.Type{ @@ -199,7 +199,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr needs = append(needs, reflect.TypeOf(&big.Int{})) purity = payable default: - log.Crit("Unknown state mutability ", method.StateMutability) + panic("Unknown state mutability " + method.StateMutability) } for _, arg := range method.Inputs { @@ -215,10 +215,9 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr expectedHandlerType := reflect.FuncOf(needs, outputs, false) if !gethAbiFuncTypeEquality(handler.Type, expectedHandlerType) { - log.Crit( - "Precompile "+contract+"'s "+name+"'s implementer has the wrong type\n", - "\texpected:\t", expectedHandlerType, "\n\tbut have:\t", handler.Type, - ) + panic( + "Precompile " + contract + "'s " + name + "'s implementer has the wrong type\n" + + "\texpected:\t" + expectedHandlerType.String() + "\n\tbut have:\t" + handler.Type.String()) } method := PrecompileMethod{ @@ -237,7 +236,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr method := implementerType.Method(i) name := method.Name if method.IsExported() && methodsByName[name] == nil { - log.Crit(contract + " is missing a solidity interface for " + name) + panic(contract + " is missing a solidity interface for " + name) } } @@ -269,11 +268,10 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr if arg.Indexed { _, ok := supportedIndices[arg.Type.String()] if !ok { - log.Crit( - "Please change the solidity for precompile ", contract, - "'s event ", name, ":\n\tEvent indices of type ", - arg.Type.String(), " are not supported", - ) + panic( + "Please change the solidity for precompile " + contract + + "'s event " + name + ":\n\tEvent indices of type " + + arg.Type.String() + " are not supported") } } } @@ -288,23 +286,21 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr field, ok := implementerType.Elem().FieldByName(name) if !ok { - log.Crit(missing, "event ", name, " of type\n\t", expectedFieldType) + panic(missing + "event " + name + " of type\n\t" + expectedFieldType.String()) } costField, ok := implementerType.Elem().FieldByName(name + "GasCost") if !ok { - log.Crit(missing, "event ", name, "'s GasCost of type\n\t", expectedCostType) + panic(missing + "event " + name + "'s GasCost of type\n\t" + expectedCostType.String()) } if !gethAbiFuncTypeEquality(field.Type, expectedFieldType) { - log.Crit( - context, "'s field for event ", name, " has the wrong type\n", - "\texpected:\t", expectedFieldType, "\n\tbut have:\t", field.Type, - ) + panic( + context + "'s field for event " + name + " has the wrong type\n" + + "\texpected:\t" + expectedFieldType.String() + "\n\tbut have:\t" + field.Type.String()) } if !gethAbiFuncTypeEquality(costField.Type, expectedCostType) { - log.Crit( - context, "'s field for event ", name, "GasCost has the wrong type\n", - "\texpected:\t", expectedCostType, "\n\tbut have:\t", costField.Type, - ) + panic( + context + "'s field for event " + name + "GasCost has the wrong type\n" + + "\texpected:\t" + expectedCostType.String() + "\n\tbut have:\t" + costField.Type.String()) } structFields := reflect.ValueOf(implementer).Elem() @@ -464,13 +460,12 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr field, ok := implementerType.Elem().FieldByName(name + "Error") if !ok { - log.Crit(missing, "custom error ", name, "Error of type\n\t", expectedFieldType) + panic(missing + "custom error " + name + "Error of type\n\t" + expectedFieldType.String()) } if field.Type != expectedFieldType { - log.Crit( - context, "'s field for error ", name, "Error has the wrong type\n", - "\texpected:\t", expectedFieldType, "\n\tbut have:\t", field.Type, - ) + panic( + context + "'s field for error " + name + "Error has the wrong type\n" + + "\texpected:\t" + expectedFieldType.String() + "\n\tbut have:\t" + field.Type.String()) } structFields := reflect.ValueOf(implementer).Elem() @@ -756,7 +751,7 @@ func (p *Precompile) Call( reflectArgs = append(reflectArgs, reflect.ValueOf(evm)) reflectArgs = append(reflectArgs, reflect.ValueOf(value)) default: - log.Crit("Unknown state mutability ", method.purity) + panic("Unknown state mutability " + string(method.purity)) } args, err := method.template.Inputs.Unpack(input[4:]) diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index 75fed711eb..183ec1f083 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -5,15 +5,12 @@ package precompiles import ( "fmt" - "io" "math/big" - "os" "testing" "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" @@ -183,12 +180,6 @@ func TestEventCosts(t *testing.T) { } func TestPrecompilesPerArbosVersion(t *testing.T) { - // Set up a logger in case log.Crit is called by Precompiles() - glogger := log.NewGlogHandler( - log.NewTerminalHandler(io.Writer(os.Stderr), false)) - glogger.Verbosity(log.LevelWarn) - log.SetDefault(log.NewLogger(glogger)) - expectedNewMethodsPerArbosVersion := map[uint64]int{ 0: 89, params.ArbosVersion_5: 3, diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 69645d8878..55c13d664d 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -504,7 +504,7 @@ func TestGetValidatorWalletContractWithDataposterOnlyUsedToCreateValidatorWallet parentChainID, ) if err != nil { - log.Crit("error creating data poster to create validator wallet contract", "err", err) + Fatal(t, "error creating data poster to create validator wallet contract", "err", err) } getExtraGas := func() uint64 { return builder.nodeConfig.Staker.ExtraGas } From 468d6892432b23af5a77db119ab510f1541d52f4 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 2 Jan 2025 18:58:56 -0700 Subject: [PATCH 5/7] fix int to string conversions --- arbos/programs/api.go | 6 ++++-- arbos/programs/native_api.go | 5 +++-- precompiles/precompile.go | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arbos/programs/api.go b/arbos/programs/api.go index cd2143f5d0..a622f55397 100644 --- a/arbos/programs/api.go +++ b/arbos/programs/api.go @@ -4,6 +4,8 @@ package programs import ( + "strconv" + "github.com/holiman/uint256" "github.com/ethereum/go-ethereum/common" @@ -265,7 +267,7 @@ func newApiClosures( original := input crash := func(reason string) { - panic("bad API call reason: " + reason + " request: " + string(req) + " len: " + string(len(original)) + " remaining: " + string(len(input))) + panic("bad API call reason: " + reason + " request: " + strconv.Itoa(int(req)) + " len: " + strconv.Itoa(len(original)) + " remaining: " + strconv.Itoa(len(input))) } takeInput := func(needed int, reason string) []byte { if len(input) < needed { @@ -413,7 +415,7 @@ func newApiClosures( captureHostio(name, args, outs, startInk, endInk) return []byte{}, nil, 0 default: - panic("unsupported call type: " + string(req)) + panic("unsupported call type: " + strconv.Itoa(int(req))) } } } diff --git a/arbos/programs/native_api.go b/arbos/programs/native_api.go index bf9cda658d..ad8cc0477b 100644 --- a/arbos/programs/native_api.go +++ b/arbos/programs/native_api.go @@ -25,6 +25,7 @@ import "C" import ( "runtime" + "strconv" "sync" "sync/atomic" @@ -68,11 +69,11 @@ func newApi( func getApi(id usize) NativeApi { any, ok := apiObjects.Load(uintptr(id)) if !ok { - panic("failed to load stylus Go API id: " + string(id)) + panic("failed to load stylus Go API id: " + strconv.Itoa(int(id))) } api, ok := any.(NativeApi) if !ok { - panic("wrong type for stylus Go API id: " + string(id)) + panic("wrong type for stylus Go API id: " + strconv.Itoa(int(id))) } return api } diff --git a/precompiles/precompile.go b/precompiles/precompile.go index f34c418313..7ca9d409c6 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -751,7 +751,7 @@ func (p *Precompile) Call( reflectArgs = append(reflectArgs, reflect.ValueOf(evm)) reflectArgs = append(reflectArgs, reflect.ValueOf(value)) default: - panic("Unknown state mutability " + string(method.purity)) + panic("Unknown state mutability " + strconv.Itoa(int(method.purity))) } args, err := method.template.Inputs.Unpack(input[4:]) From 89516a0075cb11a17b48b5ab2d9829062ffcb32a Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 2 Jan 2025 19:32:49 -0700 Subject: [PATCH 6/7] remove dead code --- arbos/programs/programs.go | 1 - 1 file changed, 1 deletion(-) diff --git a/arbos/programs/programs.go b/arbos/programs/programs.go index 6b2a0c318b..4c81de1308 100644 --- a/arbos/programs/programs.go +++ b/arbos/programs/programs.go @@ -220,7 +220,6 @@ func (p Programs) CallProgram( localAsm, err := getLocalAsm(statedb, moduleHash, contract.Address(), contract.Code, contract.CodeHash, params.PageLimit, evm.Context.Time, debugMode, program) if err != nil { panic("failed to get local wasm for activated program: " + contract.Address().Hex()) - return nil, err } evmData := &EvmData{ From 830a9245293f296cf9bcd16286abeb4c31dd5279 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Fri, 3 Jan 2025 10:00:08 -0600 Subject: [PATCH 7/7] update bold pin to latest commit on main --- bold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bold b/bold index 81f1b421b2..cb6922fb4f 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 81f1b421b2dbbf96c7a2b427a9458667b07b0b27 +Subproject commit cb6922fb4f50d1cdb12af467a18ecee6f1c688a4