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 reported extrinsic hash #629

Merged
merged 5 commits into from
Jul 25, 2023
Merged

Fix reported extrinsic hash #629

merged 5 commits into from
Jul 25, 2023

Conversation

haerdib
Copy link
Contributor

@haerdib haerdib commented Jul 24, 2023

The problem was that we encoded the extrinsic twice: T::Hasher::hash_of(..) encodes the input automatically. We therefore need to use T::Hasher::hash(..) for the already encoded extrinsic.

The extrinsic hash can be manually checked by:

closes #621

@haerdib haerdib self-assigned this Jul 24, 2023
@haerdib haerdib added the F2-bug Something isn't working label Jul 24, 2023
@haerdib haerdib marked this pull request as ready for review July 24, 2023 15:55
@haerdib haerdib requested a review from echevrier July 24, 2023 15:56
@@ -100,7 +100,6 @@ async fn main() {
println!("[+] Extrinsic with hash {extrinsic_hash:?} was successfully executed.",);
println!("[+] Extrinsic got included in block with hash {block_hash:?}");
println!("[+] Watched extrinsic until it reached the status {extrinsic_status:?}");
println!("[+] The following events were thrown when the extrinsic was executed: {extrinsic_events:?}");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this line because the printing was way too verbose.

@haerdib
Copy link
Contributor Author

haerdib commented Jul 24, 2023

Manual test:

[+] Alice's Free Balance is 1000000000000000000000

[+] Bob's Free Balance is 1000000000000000000000

[+] Composed extrinsic: UncheckedExtrinsic(Some((MultiAddress::Id(d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d (5GrwvaEF...)), GenericSignedExtra { era: Era::Immortal, nonce: 0, tip: AssetTip { tip: 0, asset: None } })), ([6, 0], MultiAddress::Id(8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48 (5FHneW46...)), 1000000000000000000000))

[+] Sent the transfer extrinsic. Result Err(Dispatch(Token(FundsUnavailable)))
[+] Couldn't execute the extrinsic due to Dispatch(Token(FundsUnavailable))

[+] Bob's Free Balance is now 1000000000000000000000

[+] Alice's Free Balance is now 999999998499691475905

[+] Sent the transfer extrinsic.
[+] Extrinsic with hash 0xe9a21b8daa1f3da00802306bf9f369b7e99f4e3326e612e2427183410fed7b33 was successfully executed.
[+] Extrinsic got included in block with hash 0x0d10b319e2971eb2b94d372b60f387be56edd3b03de3faef5d993f9a744ecb83
[+] Watched extrinsic until it reached the status InBlock(0x0d10b319e2971eb2b94d372b60f387be56edd3b03de3faef5d993f9a744ecb83)
[+] Bob's Free Balance is now 1000000000000000001000

Polkadot.js:
(check block hash and extrinsic_hash)

grafik

Copy link
Contributor

@echevrier echevrier left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for the manual test results.

let report = api.submit_and_watch_extrinsic_until(xt2, XtStatus::Ready).unwrap();
assert_eq!(extrinsic_hash, report.extrinsic_hash);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@haerdib haerdib merged commit 8e92465 into master Jul 25, 2023
@haerdib haerdib deleted the bh/fix-xt-hash branch July 25, 2023 08:33
echevrier pushed a commit that referenced this pull request Jul 26, 2023
* fix xt_hash

* fix clippy

* fix unit test

* fix author tests

* remove too verbose println

(cherry picked from commit 8e92465)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E1-breaksnothing F2-bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reported extrinsic hash in ExtrinsicReport seems to be wrong
2 participants