* use stack of contexts to implement snapshot revert
Closes#338
add exception revert test case
verify partial revert
mutate state after the reverted subcall
polish
update comments
name the module after the type name
remove the unnecessary Snapshot in outer layer
and add snapshot unit test
assert context stack is clean after tx processing
cleanups
fix context revert
fix comments
update comments
it's ok to commit in failed case too
Update x/evm/keeper/context_stack.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Update x/evm/keeper/context_stack.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Update x/evm/keeper/context_stack.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
update comment and error message
add comment to cacheContext
k -> cs
Update x/evm/keeper/context_stack.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
evm can handle state revert
renames and unit tests
* use table driven tests
* keep all the cosmos events
* changelog
* check for if commit function is nil
* fix changelog
* Update x/evm/keeper/context_stack.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* keep the original context for GetCommittedState api
* fix method mutation
* keep estimateGas consistant
* added test after the original context is recovered
* add integration test for the gas consumption of sstore
* test the committed case
* move methods to keeper module
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* return geth error format
* fix format in gasestimate
* deal with other evm errors
* fix import
* fix lint
* add test
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* add some unit tests for estimateGas
Also add some test environment setup, Closes#323
test estimateGas of erc20 token transfer
fix failed test case
the trick is to keep a clean transient store, by doing a commit
put artifacts to external file
* fix test failure
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
The previous code is not incorrect since the method `SetBlockBloom` use the `ctx` passed in rather than the `k.ctx`.
It's confusing that sometimes methods use ctx in parameter, sometimes use `k.ctx`, but that's another issue.
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* do binary search to estimate gas
Closes#268
- Also refactor ApplyMessage to be more reuseable
move binary search to rpc api side to have a clean context each try
remove EstimateGas grpc api
* extract BinSearch function and add unit test
* do estimateGas in grpc query
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* fix evm set parameters
* recompute header hash only if its not set
* Update x/evm/keeper/state_transition.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
* clean up logic by ignoring cosmos gas meter
* set gas used in txResponse
* reset and set the gas in context
* rename ante handler
* fix refundedgas logic
* remove gas update logic in keeper
* update context in keeper
* add test for EthSetupContextDecorator
* fix broken test due to gas logic change
* fix `AddLog` unmarshaling tx
Closes#187
* use cosmos tx in AddLog unit test
* Apply suggestions from code review
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>