diff --git a/arbitrum/recordingdb.go b/arbitrum/recordingdb.go index 5f8a27d0af75..7c71a7a7b076 100644 --- a/arbitrum/recordingdb.go +++ b/arbitrum/recordingdb.go @@ -54,10 +54,11 @@ func (db *RecordingKV) Get(key []byte) ([]byte, error) { // Retrieving code copy(hash[:], key[len(rawdb.CodePrefix):]) res, err = db.diskDb.Get(key) - } else if ok, _, _ := rawdb.IsCompiledWasmCodeKey(key); ok { - // Arbitrum: - // Just return the compiled wasm without recording it since it's not in consensus - // and the replay will regenerate it + } else if ok, _ := rawdb.IsActivatedAsmKey(key); ok { + // Arbitrum: the asm is non-consensus + return db.diskDb.Get(key) + } else if ok, _ := rawdb.IsActivatedModuleKey(key); ok { + // Arbitrum: the module is non-consensus (only its hash is) return db.diskDb.Get(key) } else { err = fmt.Errorf("recording KV attempted to access non-hash key %v", hex.EncodeToString(key)) diff --git a/core/rawdb/accessors_state_arbitrum.go b/core/rawdb/accessors_state_arbitrum.go index 21dfe43a064b..32ccb1c94d4b 100644 --- a/core/rawdb/accessors_state_arbitrum.go +++ b/core/rawdb/accessors_state_arbitrum.go @@ -22,10 +22,15 @@ import ( "github.com/ethereum/go-ethereum/log" ) -// WriteCompiledWasmCode writes the provided contract compiled wasm code database. -func WriteCompiledWasmCode(db ethdb.KeyValueWriter, version uint16, hash common.Hash, code []byte) { - key := CompiledWasmCodeKey(version, hash) - if err := db.Put(key[:], code); err != nil { - log.Crit("Failed to store compiled wasm contract code", "err", err) +// Stores the activated asm and module for a given codeHash +func WriteActivation(db ethdb.KeyValueWriter, moduleHash common.Hash, asm, module []byte) { + key := ActivatedAsmKey(moduleHash) + if err := db.Put(key[:], asm); err != nil { + log.Crit("Failed to store activated wasm asm", "err", err) + } + + key = ActivatedModuleKey(moduleHash) + if err := db.Put(key[:], module); err != nil { + log.Crit("Failed to store activated wasm module", "err", err) } } diff --git a/core/rawdb/schema_arbitrum.go b/core/rawdb/schema_arbitrum.go index e91ccea231db..72a3f755bb3f 100644 --- a/core/rawdb/schema_arbitrum.go +++ b/core/rawdb/schema_arbitrum.go @@ -20,38 +20,47 @@ package rawdb import ( "bytes" - "encoding/binary" "github.com/ethereum/go-ethereum/common" ) var ( - CompiledWasmCodePrefix = []byte{0x00, 'w'} // (prefix, version, code_hash) -> account compiled wasm code + activatedAsmPrefix = []byte{0x00, 'w', 'a'} // (prefix, moduleHash) -> stylus asm + activatedModulePrefix = []byte{0x00, 'w', 'm'} // (prefix, moduleHash) -> stylus module ) -// CompiledWasmCodeKey = CompiledWasmCodePrefix + version + hash -const WasmKeyLen = 2 + 2 + 32 +// WasmKeyLen = CompiledWasmCodePrefix + moduleHash +const WasmKeyLen = 3 + 32 type WasmKey = [WasmKeyLen]byte -// CompiledWasmCodeKey = CompiledWasmCodePrefix + version + hash -func CompiledWasmCodeKey(version uint16, hash common.Hash) WasmKey { +func ActivatedAsmKey(moduleHash common.Hash) WasmKey { + return newWasmKey(activatedAsmPrefix, moduleHash) +} + +func ActivatedModuleKey(moduleHash common.Hash) WasmKey { + return newWasmKey(activatedModulePrefix, moduleHash) +} + +// key = prefix + moduleHash +func newWasmKey(prefix []byte, moduleHash common.Hash) WasmKey { var key WasmKey - copy(key[:2], CompiledWasmCodePrefix) - binary.BigEndian.PutUint16(key[2:4], version) - copy(key[4:], hash[:]) + copy(key[:3], prefix) + copy(key[3:], moduleHash[:]) return key } -// IsCompiledWasmCodeKey reports whether the given byte slice is the key of compiled wasm contract code, -// if so return the raw code hash and version as well. -func IsCompiledWasmCodeKey(key []byte) (bool, common.Hash, uint16) { - start := len(CompiledWasmCodePrefix) +func IsActivatedAsmKey(key []byte) (bool, common.Hash) { + return extractWasmKey(activatedAsmPrefix, key) +} + +func IsActivatedModuleKey(key []byte) (bool, common.Hash) { + return extractWasmKey(activatedModulePrefix, key) +} - if bytes.HasPrefix(key, CompiledWasmCodePrefix) && len(key) == WasmKeyLen { - version := binary.BigEndian.Uint16(key[start : start+2]) - codeHash := common.BytesToHash(key[start+2:]) - return true, codeHash, version +func extractWasmKey(prefix, key []byte) (bool, common.Hash) { + if !bytes.HasPrefix(key, prefix) || len(key) != WasmKeyLen { + return false, common.Hash{} } - return false, common.Hash{}, 0 + return true, common.BytesToHash(key[len(prefix):]) } diff --git a/core/state/database.go b/core/state/database.go index 94f971fdf941..1e97945763e7 100644 --- a/core/state/database.go +++ b/core/state/database.go @@ -31,7 +31,7 @@ import ( const ( // Arbitrum: Cache size granted for caching clean compiled wasm code. - compiledWasmCodeCacheSize = 64 * 1024 * 1024 + activatedWasmCacheSize = 64 * 1024 * 1024 // Number of codehash->size associations to keep. codeSizeCacheSize = 100000 @@ -42,10 +42,9 @@ const ( // Database wraps access to tries and contract code. type Database interface { - // Arbitrum: CompiledWasmContractCode retrieves a particular contract's user wasm code. - CompiledWasmContractCode(version uint16, codeHash common.Hash) ([]byte, error) - // Arbitrum: SetCompiledWasmContractCode sets a user wasm code. - SetCompiledWasmContractCode(version uint16, codeHash common.Hash, code []byte) error + // Arbitrum: Read activated Stylus contracts + ActivatedAsm(moduleHash common.Hash) (asm []byte, err error) + ActivatedModule(moduleHash common.Hash) (module []byte, err error) // OpenTrie opens the main account trie. OpenTrie(root common.Hash) (Trie, error) @@ -147,7 +146,8 @@ func NewDatabase(db ethdb.Database) Database { func NewDatabaseWithConfig(db ethdb.Database, config *trie.Config) Database { cdb := &cachingDB{ // Arbitrum only - compiledWasmCache: lru.NewSizeConstrainedCache[rawdb.WasmKey, []byte](compiledWasmCodeCacheSize), + activatedAsmCache: lru.NewSizeConstrainedCache[common.Hash, []byte](activatedWasmCacheSize), + activatedModuleCache: lru.NewSizeConstrainedCache[common.Hash, []byte](activatedWasmCacheSize), disk: db, codeSizeCache: lru.NewCache[common.Hash, int](codeSizeCacheSize), @@ -161,7 +161,8 @@ func NewDatabaseWithConfig(db ethdb.Database, config *trie.Config) Database { func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database { cdb := &cachingDB{ // Arbitrum only - compiledWasmCache: lru.NewSizeConstrainedCache[rawdb.WasmKey, []byte](compiledWasmCodeCacheSize), + activatedAsmCache: lru.NewSizeConstrainedCache[common.Hash, []byte](activatedWasmCacheSize), + activatedModuleCache: lru.NewSizeConstrainedCache[common.Hash, []byte](activatedWasmCacheSize), disk: db, codeSizeCache: lru.NewCache[common.Hash, int](codeSizeCacheSize), @@ -173,7 +174,8 @@ func NewDatabaseWithNodeDB(db ethdb.Database, triedb *trie.Database) Database { type cachingDB struct { // Arbitrum - compiledWasmCache *lru.SizeConstrainedCache[rawdb.WasmKey, []byte] + activatedAsmCache *lru.SizeConstrainedCache[common.Hash, []byte] + activatedModuleCache *lru.SizeConstrainedCache[common.Hash, []byte] disk ethdb.KeyValueStore codeSizeCache *lru.Cache[common.Hash, int] diff --git a/core/state/database_arbitrum.go b/core/state/database_arbitrum.go index a188b31719d5..6e545eb0a017 100644 --- a/core/state/database_arbitrum.go +++ b/core/state/database_arbitrum.go @@ -7,27 +7,34 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" ) -func (db *cachingDB) CompiledWasmContractCode(version uint16, codeHash common.Hash) ([]byte, error) { - wasmKey := rawdb.CompiledWasmCodeKey(version, codeHash) - if code, _ := db.compiledWasmCache.Get(wasmKey); len(code) > 0 { - return code, nil +func (db *cachingDB) ActivatedAsm(moduleHash common.Hash) ([]byte, error) { + if asm, _ := db.activatedAsmCache.Get(moduleHash); len(asm) > 0 { + return asm, nil } - code, err := db.disk.Get(wasmKey[:]) + wasmKey := rawdb.ActivatedAsmKey(moduleHash) + asm, err := db.disk.Get(wasmKey[:]) if err != nil { return nil, err } - if len(code) > 0 { - db.compiledWasmCache.Add(wasmKey, code) - return code, nil + if len(asm) > 0 { + db.activatedAsmCache.Add(moduleHash, asm) + return asm, nil } return nil, errors.New("not found") } -func (db *cachingDB) SetCompiledWasmContractCode(version uint16, codeHash common.Hash, code []byte) error { - wasmKey := rawdb.CompiledWasmCodeKey(version, codeHash) - if code, _ := db.compiledWasmCache.Get(wasmKey); len(code) > 0 { - return nil +func (db *cachingDB) ActivatedModule(moduleHash common.Hash) ([]byte, error) { + if module, _ := db.activatedModuleCache.Get(moduleHash); len(module) > 0 { + return module, nil } - db.compiledWasmCache.Add(wasmKey, code) - return nil + wasmKey := rawdb.ActivatedModuleKey(moduleHash) + module, err := db.disk.Get(wasmKey[:]) + if err != nil { + return nil, err + } + if len(module) > 0 { + db.activatedModuleCache.Add(moduleHash, module) + return module, nil + } + return nil, errors.New("not found") } diff --git a/core/state/journal_arbitrum.go b/core/state/journal_arbitrum.go index cf97b713b854..939b0167bbc9 100644 --- a/core/state/journal_arbitrum.go +++ b/core/state/journal_arbitrum.go @@ -2,15 +2,14 @@ package state import "github.com/ethereum/go-ethereum/common" -type wasmCodeChange struct { - account *common.Address - version uint16 +type wasmActivation struct { + moduleHash common.Hash } -func (ch wasmCodeChange) revert(s *StateDB) { - s.getStateObject(*ch.account).setWASMCode(nil, ch.version) +func (ch wasmActivation) revert(s *StateDB) { + delete(s.activatedWasms, ch.moduleHash) } -func (ch wasmCodeChange) dirtied() *common.Address { - return ch.account +func (ch wasmActivation) dirtied() *common.Address { + return nil } diff --git a/core/state/state_object.go b/core/state/state_object.go index 426ba97c6bef..47ba46e0787c 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -62,9 +62,6 @@ func (s Storage) Copy() Storage { // Account values can be accessed and modified through the object. // Finally, call commitTrie to write the modified storage trie into a database. type stateObject struct { - // Arbitrum: write caches and cache flags - compiledWasmCode CompiledWasms // compiled wasm bytecode which gets set when wasm is loaded - address common.Address addrHash common.Hash // hash of ethereum address of the account data types.StateAccount @@ -110,9 +107,6 @@ func newObject(db *StateDB, address common.Address, data types.StateAccount) *st originStorage: make(Storage), pendingStorage: make(Storage), dirtyStorage: make(Storage), - - // Arbitrum Only - compiledWasmCode: make(CompiledWasms), } } @@ -435,9 +429,6 @@ func (s *stateObject) deepCopy(db *StateDB) *stateObject { stateObject.dirtyCode = s.dirtyCode stateObject.deleted = s.deleted - // Arbitrum Only - stateObject.compiledWasmCode = s.compiledWasmCode.Copy() - return stateObject } diff --git a/core/state/state_object_arbitrum.go b/core/state/state_object_arbitrum.go deleted file mode 100644 index 228e26c3c5f8..000000000000 --- a/core/state/state_object_arbitrum.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2014 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package state - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/common" -) - -type CompiledWasmCache struct { - code Code - dirty bool -} -type CompiledWasms map[uint16]CompiledWasmCache - -func (c CompiledWasms) Copy() CompiledWasms { - cpy := make(CompiledWasms, len(c)) - for key, value := range c { - cpy[key] = value - } - - return cpy -} - -// CompiledWasmCode returns the user wasm contract code associated with this object, if any. -func (s *stateObject) CompiledWasmCode(db Database, version uint16) []byte { - if wasm, ok := s.compiledWasmCode[version]; ok { - return wasm.code - } - if version == 0 { - return nil - } - compiledWasmCode, err := db.CompiledWasmContractCode(version, common.BytesToHash(s.CodeHash())) - if err != nil { - s.db.setError(fmt.Errorf("can't load code hash %x: %v", s.CodeHash(), err)) - } - s.compiledWasmCode[version] = CompiledWasmCache{ - code: compiledWasmCode, - dirty: false, - } - return compiledWasmCode -} - -func (s *stateObject) SetCompiledWasmCode(db Database, code []byte, version uint16) { - // Can only be compiled once, so if it's being compiled, it was previous empty - s.db.journal.append(wasmCodeChange{ - account: &s.address, - version: version, - }) - s.setWASMCode(code, version) - if err := db.SetCompiledWasmContractCode(version, common.BytesToHash(s.CodeHash()), code); err != nil { - s.db.setError(fmt.Errorf("cannot set compiled wasm contract code %x: %v", s.CodeHash(), err)) - } -} - -func (s *stateObject) setWASMCode(code []byte, version uint16) { - s.compiledWasmCode[version] = CompiledWasmCache{ - code: code, - dirty: true, - } -} diff --git a/core/state/statedb.go b/core/state/statedb.go index 71bd71c2420a..cc4f158aefb9 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -64,11 +64,12 @@ func (n *proofList) Delete(key []byte) error { // * Accounts type StateDB struct { // Arbitrum - unexpectedBalanceDelta *big.Int // total balance change across all accounts - userWasms UserWasms // user wasms encountered during execution - openWasmPages uint16 // number of pages currently open - everWasmPages uint16 // largest number of pages ever allocated during this tx's execution - deterministic bool // whether the order in which deletes are committed should be deterministic + unexpectedBalanceDelta *big.Int // total balance change across all accounts + userWasms UserWasms // user wasms encountered during execution + openWasmPages uint16 // number of pages currently open + everWasmPages uint16 // largest number of pages ever allocated during this tx's execution + deterministic bool // whether the order in which deletes are committed should be deterministic + activatedWasms map[common.Hash]*ActivatedWasm // newly activated WASMs db Database prefetcher *triePrefetcher @@ -149,9 +150,9 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error) } sdb := &StateDB{ unexpectedBalanceDelta: new(big.Int), - userWasms: make(UserWasms), openWasmPages: 0, everWasmPages: 0, + activatedWasms: make(map[common.Hash]*ActivatedWasm), db: db, trie: tr, @@ -732,7 +733,7 @@ func (s *StateDB) Copy() *StateDB { // Copy all the basic fields, initialize the memory ones state := &StateDB{ unexpectedBalanceDelta: new(big.Int).Set(s.unexpectedBalanceDelta), - userWasms: make(UserWasms, len(s.userWasms)), + activatedWasms: make(map[common.Hash]*ActivatedWasm, len(s.activatedWasms)), openWasmPages: s.openWasmPages, everWasmPages: s.everWasmPages, @@ -806,9 +807,16 @@ func (s *StateDB) Copy() *StateDB { state.accessList = s.accessList.Copy() state.transientStorage = s.transientStorage.Copy() - // Arbitrum: copy wasm calls - for call, wasm := range s.userWasms { - state.userWasms[call] = wasm + // Arbitrum: copy wasm calls and activated WASMs + if s.userWasms != nil { + state.userWasms = make(UserWasms, len(s.userWasms)) + for call, wasm := range s.userWasms { + state.userWasms[call] = wasm + } + } + for moduleHash, info := range s.activatedWasms { + // It's fine to skip a deep copy since activations are immutable. + state.activatedWasms[moduleHash] = info } // If there's a prefetcher running, make an inactive copy of it that can @@ -1044,15 +1052,6 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { obj.dirtyCode = false } - // Arbitrum Only - for version, wasm := range obj.compiledWasmCode { - if wasm.dirty { - codeHash := common.BytesToHash(obj.CodeHash()) - rawdb.WriteCompiledWasmCode(codeWriter, version, codeHash, wasm.code) - wasm.dirty = false - } - } - // Write any storage changes in the state object to its storage trie set, err := obj.commitTrie(s.db) if err != nil { @@ -1078,6 +1077,15 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { if len(s.stateObjectsDirty) > 0 { s.stateObjectsDirty = make(map[common.Address]struct{}) } + + // Arbitrum: write Stylus programs to disk + for moduleHash, info := range s.activatedWasms { + rawdb.WriteActivation(codeWriter, moduleHash, info.Asm, info.Module) + } + if len(s.activatedWasms) > 0 { + s.activatedWasms = make(map[common.Hash]*ActivatedWasm) + } + if codeWriter.ValueSize() > 0 { if err := codeWriter.Write(); err != nil { log.Crit("Failed to commit dirty codes", "error", err) diff --git a/core/state/statedb_arbitrum.go b/core/state/statedb_arbitrum.go index 6eea8fb336f7..cfa8aa7074d0 100644 --- a/core/state/statedb_arbitrum.go +++ b/core/state/statedb_arbitrum.go @@ -18,15 +18,14 @@ package state import ( - "encoding/binary" + "bytes" + "fmt" "math/big" "errors" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/log" ) var ( @@ -44,14 +43,19 @@ var ( StylusPrefix = []byte{stylusEOFMagic, stylusEOFMagicSuffix, stylusEOFVersion} ) +type ActivatedWasm struct { + Asm []byte + Module []byte +} + // IsStylusProgram checks if a specified bytecode is a user-submitted WASM program. // Stylus differentiates WASMs from EVM bytecode via the prefix 0xEFF000 which will safely fail // to pass through EVM-bytecode EOF validation rules. func IsStylusProgram(b []byte) bool { - if len(b) < 3 { + if len(b) < len(StylusPrefix) { return false } - return b[0] == stylusEOFMagic && b[1] == stylusEOFMagicSuffix && b[2] == stylusEOFVersion + return bytes.Equal(b[:3], StylusPrefix) } // StripStylusPrefix if the specified input is a stylus program. @@ -62,19 +66,42 @@ func StripStylusPrefix(b []byte) ([]byte, error) { return b[3:], nil } -func (s *StateDB) GetCompiledWasmCode(addr common.Address, version uint16) []byte { - stateObject := s.getStateObject(addr) - if stateObject != nil { - return stateObject.CompiledWasmCode(s.db, version) +func (s *StateDB) ActivateWasm(moduleHash common.Hash, asm, module []byte) { + _, exists := s.activatedWasms[moduleHash] + if exists { + return + } + s.activatedWasms[moduleHash] = &ActivatedWasm{ + Asm: asm, + Module: module, } - return nil + s.journal.append(wasmActivation{ + moduleHash: moduleHash, + }) } -func (s *StateDB) SetCompiledWasmCode(addr common.Address, code []byte, version uint16) { - stateObject := s.GetOrNewStateObject(addr) - if stateObject != nil { - stateObject.SetCompiledWasmCode(s.db, code, version) +func (s *StateDB) GetActivatedAsm(moduleHash common.Hash) []byte { + info, exists := s.activatedWasms[moduleHash] + if exists { + return info.Asm + } + asm, err := s.db.ActivatedAsm(moduleHash) + if err != nil { + s.setError(fmt.Errorf("failed to load asm for %x: %v", moduleHash, err)) + } + return asm +} + +func (s *StateDB) GetActivatedModule(moduleHash common.Hash) []byte { + info, exists := s.activatedWasms[moduleHash] + if exists { + return info.Module + } + code, err := s.db.ActivatedModule(moduleHash) + if err != nil { + s.setError(fmt.Errorf("failed to load module for %x: %v", moduleHash, err)) } + return code } func (s *StateDB) GetStylusPages() (uint16, uint16) { @@ -137,61 +164,22 @@ func (s *StateDB) GetSuicides() []common.Address { return suicides } -type UserWasms map[WasmCall]*UserWasm -type UserWasm struct { - NoncanonicalHash common.Hash - CompressedWasm []byte - Wasm []byte - CodeHash common.Hash // TODO: remove this field -} -type WasmCall struct { - Version uint16 - CodeHash common.Hash -} +// maps moduleHash to activation info +type UserWasms map[common.Hash]ActivatedWasm func (s *StateDB) StartRecording() { s.userWasms = make(UserWasms) } -func (s *StateDB) RecordProgram(program common.Address, codeHash common.Hash, version uint16) { +func (s *StateDB) RecordProgram(moduleHash common.Hash) { if s.userWasms != nil { - call := WasmCall{ - Version: version, - CodeHash: codeHash, - } - if _, ok := s.userWasms[call]; ok { - return - } - storedCodeHash := s.GetCodeHash(program) - if storedCodeHash != codeHash { - log.Error( - "Wrong recorded codehash for program at addr %#x, got codehash %#x in DB, specified codehash %#x to record", - program, - storedCodeHash, - codeHash, - ) - return - } - rawCode := s.GetCode(program) - compressedWasm, err := StripStylusPrefix(rawCode) - if err != nil { - log.Error("Could not strip stylus program prefix from raw code: %v", err) - return - } - s.userWasms[call] = &UserWasm{ - NoncanonicalHash: s.NoncanonicalProgramHash(codeHash, version), - CompressedWasm: compressedWasm, - CodeHash: codeHash, + s.userWasms[moduleHash] = ActivatedWasm{ + Asm: s.GetActivatedAsm(moduleHash), + Module: s.GetActivatedModule(moduleHash), } } } -func (s *StateDB) NoncanonicalProgramHash(codeHash common.Hash, version uint16) common.Hash { - prefix := make([]byte, 2) - binary.BigEndian.PutUint16(prefix, version) - return crypto.Keccak256Hash(prefix, codeHash.Bytes()) -} - func (s *StateDB) UserWasms() UserWasms { return s.userWasms } diff --git a/core/vm/interface.go b/core/vm/interface.go index 4118cd589df7..b01fab9c49ce 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -28,8 +28,9 @@ import ( // StateDB is an EVM database for full state querying. type StateDB interface { // Arbitrum: manage compiled wasms - GetCompiledWasmCode(addr common.Address, version uint16) []byte - SetCompiledWasmCode(addr common.Address, code []byte, version uint16) + ActivateWasm(moduleHash common.Hash, asm, module []byte) + GetActivatedAsm(moduleHash common.Hash) (asm []byte) + GetActivatedModule(moduleHash common.Hash) (module []byte) // Arbitrum: track stylus's memory footprint GetStylusPages() (uint16, uint16) @@ -38,7 +39,6 @@ type StateDB interface { AddStylusPages(new uint16) (uint16, uint16) AddStylusPagesEver(new uint16) - NoncanonicalProgramHash(codeHash common.Hash, version uint16) common.Hash Deterministic() bool Database() state.Database diff --git a/light/trie_arbitrum.go b/light/trie_arbitrum.go index c27f994d9f15..413db805d996 100644 --- a/light/trie_arbitrum.go +++ b/light/trie_arbitrum.go @@ -22,10 +22,14 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func (db *odrDatabase) CompiledWasmContractCode(version uint16, codeHash common.Hash) ([]byte, error) { +func (db *odrDatabase) ActivateWasm(moduleHash common.Hash, asm, module []byte) error { + return errors.New("setting compiled wasm not supported in light client") +} + +func (db *odrDatabase) ActivatedAsm(moduleHash common.Hash) ([]byte, error) { return nil, errors.New("retreiving compiled wasm not supported in light client") } -func (db *odrDatabase) SetCompiledWasmContractCode(version uint16, codeHash common.Hash, code []byte) error { - return errors.New("setting compiled wasm not supported in light client") +func (db *odrDatabase) ActivatedModule(moduleHash common.Hash) ([]byte, error) { + return nil, errors.New("retreiving compiled wasm not supported in light client") }