From aa44bd44e00be7e5689aea3b63d8907cd3686540 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Fri, 16 Aug 2024 01:42:54 +0200 Subject: [PATCH] add LocalTarget() to rawdb, use LocalTarget() in EvictWasm.Revert --- core/rawdb/accessors_state_arbitrum.go | 13 +++++++++++++ core/state/journal_arbitrum.go | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/rawdb/accessors_state_arbitrum.go b/core/rawdb/accessors_state_arbitrum.go index 2c4175379c..7ff21efd84 100644 --- a/core/rawdb/accessors_state_arbitrum.go +++ b/core/rawdb/accessors_state_arbitrum.go @@ -18,6 +18,7 @@ package rawdb import ( "fmt" + "runtime" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" @@ -33,6 +34,18 @@ const ( TargetHost Target = "host" ) +func LocalTarget() Target { + if runtime.GOOS == "linux" { + switch runtime.GOARCH { + case "arm64": + return TargetArm64 + case "amd64": + return TargetAmd64 + } + } + return TargetHost +} + func (t Target) keyPrefix() ([]byte, error) { var prefix []byte switch t { diff --git a/core/state/journal_arbitrum.go b/core/state/journal_arbitrum.go index 0207fa2bbf..d074d6df7c 100644 --- a/core/state/journal_arbitrum.go +++ b/core/state/journal_arbitrum.go @@ -37,7 +37,6 @@ func (ch CacheWasm) dirtied() *common.Address { } type EvictWasm struct { - Target rawdb.Target ModuleHash common.Hash Version uint16 Tag uint32 @@ -45,7 +44,7 @@ type EvictWasm struct { } func (ch EvictWasm) revert(s *StateDB) { - asm, err := s.TryGetActivatedAsm(ch.Target, ch.ModuleHash) // only happens in native mode + asm, err := s.TryGetActivatedAsm(rawdb.LocalTarget(), ch.ModuleHash) // only happens in native mode if err == nil && len(asm) != 0 { //if we failed to get it - it's not in the current rust cache CacheWasmRust(asm, ch.ModuleHash, ch.Version, ch.Tag, ch.Debug)