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

Tests transaction receipts for reverted evm execution #184

Merged

Conversation

JoshOrndorff
Copy link
Contributor

@JoshOrndorff JoshOrndorff commented Oct 30, 2020

This PR adds an integration test that demonstrates missing transaction receipts when transactions are reverted as described in #178. It also makes an attempt to solve that issue, by delaying the error handling in pallet_ethereum's transact until after the Pending storage item has been written.

I do have some open questions about this work:

  • Why there no status in the transaction receipts (whether it is reverted or not)
  • Why is the gas used different when the transaction reverts vs when it doesn't
  • Is it acceptable to write to runtime storage (Pending) even when the transaction is going to fail? It seems like the correct thing in this case, but it is contrary to "normal" best practices "verify first, then write".

@JoshOrndorff JoshOrndorff marked this pull request as ready for review October 30, 2020 20:33
@JoshOrndorff JoshOrndorff changed the title Add test for missing transaction receipt Generate transaction receipts for reverted transactions Nov 2, 2020
});
});

it("should provide a tx receipt after failed deployment", async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, those tests should be split in 2:

  • should provide a tx receipt after failed deployment (verify the result is valid)
  • should store the tx after reverted (verify querying the receipt returns the valid data)

);

expect(
await customRequest(context.web3, "eth_sendRawTransaction", [tx.rawTransaction])
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use context.web3.eth.sendRawTransaction ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the style of the existing tests.

@@ -210,6 +210,8 @@ decl_module! {

Pending::append((transaction, status, receipt));

Self::handle_exec(exit_reason)?;
Copy link
Member

Choose a reason for hiding this comment

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

We actually still cannot return error here. It must succeed, because at this stage the runtime state has already changed.

@sorpaas
Copy link
Member

sorpaas commented Nov 3, 2020

@JoshOrndorff Can you pull master? It should fix the DispatchError issue, and the tests you added are really useful.

@JoshOrndorff
Copy link
Contributor Author

Okay, so the desired behaviour is that calls to transact should succeed even if the evm execution fails? That fine, but a bit unintuitive.

So I'll revert my changes to the rust code, merge master, and keep this PR open for the tests.

@JoshOrndorff JoshOrndorff changed the title Generate transaction receipts for reverted transactions Tests transaction receipts for reverted evm execution Nov 3, 2020
@sorpaas sorpaas merged commit 80069ed into polkadot-evm:master Nov 3, 2020
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* lots of debugging lines

* Add integration test to demonstrate the issue

* Revert "lots of debugging lines"

This reverts commit 0d125a2.

* One possible fix for the bug

* Fix constants in tests

* Fix warning

* Fix runtime test

* revert my attempt to fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants