Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Allow evm to call native modules through logs #417

Merged
merged 14 commits into from
Sep 2, 2021

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Aug 9, 2021

Closes #416

Description

  • Add EvmHooks, currently only single api PostTxProcessing.
  • implements a BankSendHook which can send native coins, but not enabled in app by default.
    function test() public {
        emit __CosmosNativeBankSend(msg.sender, 10, "aphoton");
    }

For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@yihuang yihuang marked this pull request as draft August 9, 2021 10:09
@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #417 (0fc6b8f) into main (b76d024) will increase coverage by 0.12%.
The diff coverage is 72.41%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   50.41%   50.53%   +0.12%     
==========================================
  Files          57       58       +1     
  Lines        5465     5495      +30     
==========================================
+ Hits         2755     2777      +22     
- Misses       2594     2600       +6     
- Partials      116      118       +2     
Impacted Files Coverage Δ
x/evm/types/errors.go 100.00% <ø> (ø)
x/evm/keeper/state_transition.go 73.12% <45.45%> (-1.16%) ⬇️
x/evm/keeper/keeper.go 66.96% <80.00%> (+0.60%) ⬆️
x/evm/keeper/hooks.go 100.00% <100.00%> (ø)

@fedekunze
Copy link
Contributor

@yihuang let's create an ADR for this that leverages Hooks. See the governance hooks for reference

@yihuang yihuang marked this pull request as ready for review August 11, 2021 04:20
@yihuang yihuang mentioned this pull request Aug 11, 2021
11 tasks
@netlify
Copy link

netlify bot commented Aug 11, 2021

✔️ Deploy Preview for stoic-ritchie-0f4a47 ready!

🔨 Explore the source changes: 87130edb959b8f1f469814c44b70c30a53b79b3d

🔍 Inspect the deploy log: https://app.netlify.com/sites/stoic-ritchie-0f4a47/deploys/6113fe699f783100085b611c

😎 Browse the preview: https://deploy-preview-417--stoic-ritchie-0f4a47.netlify.app

@orijbot
Copy link

orijbot commented Aug 30, 2021

x/evm/types/expected_keepers.go Outdated Show resolved Hide resolved
x/evm/types/hooks.go Outdated Show resolved Hide resolved
x/evm/types/hooks.go Outdated Show resolved Hide resolved
x/evm/types/hooks.go Outdated Show resolved Hide resolved
x/evm/types/hooks.go Outdated Show resolved Hide resolved
x/evm/types/hooks.go Outdated Show resolved Hide resolved
x/evm/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Outdated Show resolved Hide resolved
Closes #416

comment

add txHash parameter

review suggestions

add hooks test
Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final pass. Great work! Can you also add a new Features entry on the Changelog? 🙏

x/evm/keeper/hooks.go Outdated Show resolved Hide resolved
x/evm/keeper/hooks_test.go Outdated Show resolved Hide resolved
x/evm/keeper/hooks_test.go Outdated Show resolved Hide resolved
x/evm/keeper/keeper.go Outdated Show resolved Hide resolved
x/evm/keeper/keeper.go Outdated Show resolved Hide resolved
x/evm/keeper/keeper.go Outdated Show resolved Hide resolved
x/evm/keeper/state_transition.go Show resolved Hide resolved

// EvmHooks event hooks for evm tx processing
type EvmHooks interface {
// Must be called after tx is processed, if failed, the whole evm transaction is reverted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the warning that we discussed in the Negative consequences section of the ADR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that negative consequence is about the use case of utilizing the hook to process logs, not about the hook interface in general.

Copy link
Contributor Author

@yihuang yihuang Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the use case context to consequences in the ADR.

yihuang and others added 8 commits September 2, 2021 15:47
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
@yihuang
Copy link
Contributor Author

yihuang commented Sep 2, 2021

Final pass. Great work! Can you also add a new Features entry on the Changelog? 🙏

changelog added.

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 💯

CHANGELOG.md Outdated Show resolved Hide resolved
@fedekunze fedekunze enabled auto-merge (squash) September 2, 2021 12:21
@fedekunze fedekunze added the automerge Automatically merge PR once all prerequisites pass. label Sep 2, 2021
@fedekunze fedekunze merged commit 089afe4 into evmos:main Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow evm to call native modules through logs
3 participants