-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2689 from jorgemmsilva/fix/nonce-evm-isc
Fix: nonce evm isc sync
- Loading branch information
Showing
10 changed files
with
119 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0x574c6f091ebf2eb2110d557bb491976007d71882be47cb3baf5f81f6ea46243a | ||
0xf3074fae5eb6e9c78e8a56b3a478c5140a419e812d789165dfefc66456c055b8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package evmimpl | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/iotaledger/wasp/packages/kv" | ||
"github.com/iotaledger/wasp/packages/kv/subrealm" | ||
"github.com/iotaledger/wasp/packages/vm/core/evm/emulator" | ||
) | ||
|
||
func Nonce(state kv.KVStoreReader, addr common.Address) uint64 { | ||
emulatorState := evmStateSubrealmR(state) | ||
stateDBStore := subrealm.NewReadOnly(emulatorState, emulator.KeyStateDB) | ||
return emulator.GetNonce(stateDBStore, addr) | ||
} | ||
|
||
func CheckNonce(state kv.KVStore, addr common.Address, nonce uint64) error { | ||
expected := Nonce(state, addr) | ||
if nonce != expected { | ||
return fmt.Errorf("Invalid nonce, expected %d, got %d", expected, nonce) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package evmimpl | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/iotaledger/wasp/packages/kv" | ||
"github.com/iotaledger/wasp/packages/kv/subrealm" | ||
"github.com/iotaledger/wasp/packages/vm/core/evm" | ||
) | ||
|
||
type StateAccess struct { | ||
state kv.KVStoreReader | ||
} | ||
|
||
func NewStateAccess(store kv.KVStoreReader) *StateAccess { | ||
contractState := subrealm.NewReadOnly(store, kv.Key(evm.Contract.Hname().Bytes())) | ||
return &StateAccess{state: contractState} | ||
} | ||
|
||
func (sa *StateAccess) Nonce(addr common.Address) uint64 { | ||
return Nonce(sa.state, addr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters