evm: implement ADR-002 EVM Hooks (#417)

* Allow evm to call native modules through logs

Closes #416

comment

add txHash parameter

review suggestions

add hooks test

* Update x/evm/keeper/hooks.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/evm/keeper/hooks_test.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/evm/keeper/keeper.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/evm/keeper/keeper.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* Update x/evm/keeper/keeper.go

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>

* use table tests

* update adr comment

* update adr

* changelog

* Update CHANGELOG.md

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
yihuang
2021-09-02 12:36:33 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer
parent b76d024225
commit 089afe41a8
8 changed files with 161 additions and 3 deletions
+3 -3
View File
@@ -49,7 +49,7 @@ func (k *EvmKeeper) SetHooks(eh types.EvmHooks) *Keeper;
The EVM state transition method `ApplyTransaction` should be changed like this:
```golang
// Create cached context which convers both the tx processing and post processing
// Need to create a snapshot explicitly to cover both tx processing and post processing logic
revision := k.Snapshot()
res, err := k.ApplyMessage(evm, msg, ethCfg, false)
@@ -186,12 +186,12 @@ The proposed ADR is backward compatible.
### Negative
- It's possible that some contracts accidentally define a log with the same signature and cause an unintentional result.
- On the use case of native call: It's possible that some contracts accidentally define a log with the same signature and cause an unintentional result.
To mitigate this, the implementor could whitelist contracts that are allowed to invoke native calls.
### Neutral
- The contract can only call native modules asynchronously, which means it can neither get the result nor handle the error.
- On the use case of native call: The contract can only call native modules asynchronously, which means it can neither get the result nor handle the error.
## Further Discussions