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

EVM execution error should not result in DispatchError #188

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

sorpaas
Copy link
Member

@sorpaas sorpaas commented Nov 3, 2020

fixes #178

Even if the EVM execution fails, it should not result in DispatchError, because the state is still changed. The error should be communicated via a Substrate event.

@sorpaas sorpaas merged commit e7a4478 into master Nov 3, 2020
@sorpaas sorpaas deleted the sp-fix-handle-exec branch November 3, 2020 12:53
@JoshOrndorff
Copy link
Contributor

it should not result in DispatchError, because the state is still changed

I also struggled with this. I know it is generally a Substrate best practice to "verify first, write last". But I thought that's because it is almost always the right thing to do. Like we wouldn't want someone to cast a vote twice or have a partial token transfer or something.

I was thinking in this case it might actually make sense to mutate anyway.

I'm fine with this fix, but I would like to hear your thoughts whether "verify first, write last" is an absolutely always rule or if there might be exceptions (like using unsafe Rust is sometimes okay).

@sorpaas
Copy link
Member Author

sorpaas commented Nov 3, 2020

@JoshOrndorff I think this is an absolutely-always rule. Otherwise many assumptions within runtime will break. I remember @shawntabrizi once corrected me on this point.

@JoshOrndorff
Copy link
Contributor

I was thinking about this more, and I think the way pallet-ethereum uses runtime storage is pretty unique. We don't actually persist any state between blocks. All the state is transient, and used only to store data in a particular block. Then it is reset at the beginning of the next block (this is similar to how events are stored in frame system).

Because we use storage in this transient way, I think it would be okay to use it even when the transaction fails.

(Again, I'm fine with how this PR ended. Just having more of an architectural discussion.)

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.

Pallet ethereum does not write transactions that revert to its Pending storage item
2 participants