Skip to content

Commit 515e912

Browse files
committed
StateDB: add TryGetActivatedWasm
If not found in db - returns an error instead of marking state for revertion
1 parent 0380e22 commit 515e912

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/state/statedb_arbitrum.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ func (s *StateDB) ActivateWasm(moduleHash common.Hash, asm, module []byte) {
8989
})
9090
}
9191

92-
func (s *StateDB) GetActivatedAsm(moduleHash common.Hash) []byte {
92+
func (s *StateDB) TryGetActivatedAsm(moduleHash common.Hash) ([]byte, error) {
9393
info, exists := s.arbExtraData.activatedWasms[moduleHash]
9494
if exists {
95-
return info.Asm
95+
return info.Asm, nil
9696
}
97-
asm, err := s.db.ActivatedAsm(moduleHash)
97+
return s.db.ActivatedAsm(moduleHash)
98+
}
99+
100+
func (s *StateDB) GetActivatedAsm(moduleHash common.Hash) []byte {
101+
asm, err := s.TryGetActivatedAsm(moduleHash)
98102
if err != nil {
99103
s.setError(fmt.Errorf("failed to load asm for %x: %v", moduleHash, err))
100104
}

core/vm/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type StateDB interface {
3131
// Arbitrum: manage Stylus wasms
3232
ActivateWasm(moduleHash common.Hash, asm, module []byte)
3333
GetActivatedAsm(moduleHash common.Hash) (asm []byte)
34+
TryGetActivatedAsm(moduleHash common.Hash) (asm []byte, err error)
3435
GetActivatedModule(moduleHash common.Hash) (module []byte)
3536
RecordCacheWasm(wasm state.CacheWasm)
3637
RecordEvictWasm(wasm state.EvictWasm)

0 commit comments

Comments
 (0)