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

Always revert state upon encountering Result::Err #975

Merged
merged 6 commits into from
Oct 21, 2021
Merged

Conversation

Robbepop
Copy link
Collaborator

@Robbepop Robbepop commented Oct 21, 2021

This fixes some misconception between ink! and SEAL.

Brought up by @xgreenx in this comment first: #641 (comment)

This fixes some misconception between ink! and SEAL.
@Robbepop Robbepop requested a review from athei October 21, 2021 14:00
@athei
Copy link
Contributor

athei commented Oct 21, 2021

Don't you need to change the call site, too? So that the error is decoded and returned to the caller when a seal_call reverted and returned an Err?

@xgreenx
Copy link
Collaborator

xgreenx commented Oct 21, 2021

Don't you need to change the call site, too? So that the error is decoded and returned to the caller when a seal_call reverted and returned an Err?

Yea, you are right.
@Robbepop Let me describe the issue again=) We have contract A and contract B. Contract A called some method X of contract B. Contract B reverted his call with return_value. The cotract-pallet returns CalleeReverted but fills the output buffer.
Here seal_call returns an error CalleeReverted and it is a VALID use case. Here we need to decode the output buffer and return Ok(decoded) instead of returning of CalleeReverted.

Copy link
Contributor

@athei athei 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. Now the errors should be properly forwarded to the caller.

@codecov-commenter
Copy link

Codecov Report

Merging #975 (5de41d6) into master (764a44a) will increase coverage by 0.81%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
+ Coverage   62.78%   63.60%   +0.81%     
==========================================
  Files         244      244              
  Lines        9148     9149       +1     
==========================================
+ Hits         5744     5819      +75     
+ Misses       3404     3330      -74     
Impacted Files Coverage Δ
crates/lang/codegen/src/generator/dispatch.rs 0.00% <ø> (ø)
crates/lang/src/codegen/dispatch/execution.rs 0.00% <0.00%> (ø)
crates/allocator/src/bump.rs 62.50% <0.00%> (-4.17%) ⬇️
crates/env/src/api.rs 36.36% <0.00%> (+4.54%) ⬆️
crates/env/src/engine/off_chain/test_api.rs 80.85% <0.00%> (+6.38%) ⬆️
crates/env/src/engine/off_chain/impls.rs 42.98% <0.00%> (+9.64%) ⬆️
crates/env/src/engine/off_chain/db/debug_buf.rs 26.31% <0.00%> (+10.52%) ⬆️
crates/env/src/engine/off_chain/mod.rs 89.61% <0.00%> (+11.68%) ⬆️
crates/env/src/engine/off_chain/db/events.rs 100.00% <0.00%> (+12.12%) ⬆️
crates/storage/src/collections/vec/fuzz_tests.rs 100.00% <0.00%> (+15.87%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 764a44a...5de41d6. Read the comment docs.

@Robbepop Robbepop merged commit ddf40e9 into master Oct 21, 2021
@Robbepop Robbepop deleted the robin-fix-revert branch October 21, 2021 15:46
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.

4 participants