Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tm2/gnovm): multi-msg overwrites previous event(s) #2030

Conversation

r3v4s
Copy link
Contributor

@r3v4s r3v4s commented May 3, 2024

Closes #2028

root cause: defer was used inside of loop that handles multi-msg. It was causing vm to use only last appended event value


AS-IS

{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "height": "43",
    "results": {
      "deliver_tx": [
        {
          "ResponseBase": {
            "Error": null,
            "Data": null,
            "Events": [
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event",
                "type": "other",
                "func": "Other",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              },
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event",
                "type": "other",
                "func": "Other",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              }
            ],
            "Log": "msg:0,success:true,log:,events:[]\nmsg:1,success:true,log:,events:[]",
            "Info": ""
          },
          "GasWanted": "2000000",
          "GasUsed": "270168"
        }
      ],
      "end_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        },
        "ValidatorUpdates": null,
        "ConsensusParams": null,
        "Events": null
      },
      "begin_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        }
      }
    }
  }
}

TO-BE (in this PR)

{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "height": "6",
    "results": {
      "deliver_tx": [
        {
          "ResponseBase": {
            "Error": null,
            "Data": null,
            "Events": [
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event2",
                "type": "t",
                "func": "inner",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              },
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event2",
                "type": "t",
                "func": "Hello",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              },
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event",
                "type": "t",
                "func": "inner",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              },
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event",
                "type": "t",
                "func": "Hello",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              },
              {
                "@type": "/tm.gnoEvent",
                "pkg_path": "gno.land/r/demo/event",
                "type": "other",
                "func": "Other",
                "attrs": [
                  {
                    "key": "k",
                    "value": "v"
                  }
                ]
              }
            ],
            "Log": "msg:0,success:true,log:,events:[{gno.land/r/demo/event2 t inner [{k v}] \u003cnil\u003e} {gno.land/r/demo/event2 t Hello [{k v}] \u003cnil\u003e} {gno.land/r/demo/event t inner [{k v}] \u003cnil\u003e} {gno.land/r/demo/event t Hello [{k v}] \u003cnil\u003e}]\nmsg:1,success:true,log:,events:[{gno.land/r/demo/event2 t inner [{k v}] \u003cnil\u003e} {gno.land/r/demo/event2 t Hello [{k v}] \u003cnil\u003e} {gno.land/r/demo/event t inner [{k v}] \u003cnil\u003e} {gno.land/r/demo/event t Hello [{k v}] \u003cnil\u003e} {gno.land/r/demo/event other Other [{k v}] \u003cnil\u003e}]",
            "Info": ""
          },
          "GasWanted": "2000000",
          "GasUsed": "270168"
        }
      ],
      "end_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        },
        "ValidatorUpdates": null,
        "ConsensusParams": null,
        "Events": null
      },
      "begin_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        }
      }
    }
  }
}

FYI, unable to provide any test cases(unit test, integration test or txtar) due to lack of multi-msg testing.


Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@r3v4s r3v4s requested a review from notJoon May 3, 2024 10:53
@r3v4s r3v4s requested a review from leohhhn May 3, 2024 10:53
@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label May 3, 2024
Copy link

codecov bot commented May 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.26%. Comparing base (f3ddc44) to head (c990b49).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2030      +/-   ##
==========================================
+ Coverage   49.14%   49.26%   +0.11%     
==========================================
  Files         576      576              
  Lines       77597    78318     +721     
==========================================
+ Hits        38137    38585     +448     
- Misses      36368    36611     +243     
- Partials     3092     3122      +30     
Flag Coverage Δ
gno.land 61.38% <ø> (-0.31%) ⬇️
gnovm 42.20% <ø> (+0.01%) ⬆️
tm2 54.62% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leohhhn leohhhn changed the title fix: multi-msg overwrites previous event(s) fix(tm2/gnovm): multi-msg overwrites previous event(s) May 3, 2024
@leohhhn
Copy link
Contributor

leohhhn commented May 3, 2024

@r3v4s

Can you provide the code you used to get the block output from the PR description?

@r3v4s
Copy link
Contributor Author

r3v4s commented May 3, 2024

@r3v4s

Can you provide the code you used to get the block output from the PR description?

oh result is actual chain result (:26657/block_results)

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looks good 💯

@zivkovicmilos zivkovicmilos requested a review from moul May 13, 2024 08:34
@ajnavarro
Copy link
Contributor

Could you add a test verifying the behavior? Thanks!

@r3v4s r3v4s requested review from gfanton and a team as code owners May 16, 2024 09:16
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 ⛰️ gno.land Issues or PRs gno.land package related labels May 16, 2024
@r3v4s r3v4s force-pushed the fix/multi-msg-overwrites-previous-event branch from 2fffb57 to 6c292a2 Compare May 23, 2024 15:57
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

okay, I'm very confused by the baseapp code deleted but I think that if it was guarding against some important scenario then it should have had a test case. please fix the test and we're good to go.

gno.land/pkg/gnoclient/integration_test.go Outdated Show resolved Hide resolved
@r3v4s r3v4s requested a review from a team as a code owner May 24, 2024 06:34
@zivkovicmilos zivkovicmilos merged commit a548238 into gnolang:master May 24, 2024
52 checks passed
@zivkovicmilos zivkovicmilos deleted the fix/multi-msg-overwrites-previous-event branch May 24, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

bug(tm2/gnovm): multi-msg call overwrites previous event
7 participants