Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix asynchronous transaction rejections. #3817

Merged
merged 3 commits into from
Oct 15, 2019
Merged

Fix asynchronous transaction rejections. #3817

merged 3 commits into from
Oct 15, 2019

Conversation

tomusdrw
Copy link
Contributor

Before #3650 the transactions were imported to the pool in a synchronous manner,. Because of that it was simple for submit_and_watch_extrinsic subscription to return an error if the transaction was rejected, instead of starting the subscription.

The async refactoring missed one case that handles the asynchronous verification in the pool - errors in that verification only lead to a warning and the subscription was started anyway, but never produced any message.

This PR fixes this behavior. CC @jacogr

@@ -31,6 +31,9 @@ use test_client::{
self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys}, DefaultTestClientBuilderExt,
TestClientBuilderExt,
};
use rpc::futures::{
Copy link
Member

Choose a reason for hiding this comment

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

The curly braces can be removed.

subscriptions: Subscriptions::new(Arc::new(runtime.executor())),
keystore: keystore.clone(),
};
let (subscriber, id_rx, _data) = ::jsonrpc_pubsub::typed::Subscriber::new_test("test");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let (subscriber, id_rx, _data) = ::jsonrpc_pubsub::typed::Subscriber::new_test("test");
let (subscriber, id_rx, _data) = jsonrpc_pubsub::typed::Subscriber::new_test("test");

.map(|res| res.map_err(|e|
e.into_pool_error()
.map(error::Error::from)
.unwrap_or_else(|e| error::Error::Verification(Box::new(e)).into())
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use a second map_err here?
We could also just make one map_err that outputs the correct error directly.

core/rpc/src/author/tests.rs Show resolved Hide resolved
@jacogr
Copy link
Contributor

jacogr commented Oct 15, 2019

Tested this branch, and it fixes the issue, actual RPC outputs with a previous failure -

2019-10-15 10:41:49          API-WS: calling author_submitAndWatchExtrinsic {"id":10,"jsonrpc":"2.0","method":"author_submitAndWatchExtrinsic","params":["0x350283ff0c9f6509b840bea296f9e75a9c730be8b07c4ba6b1d4449e991c97c2b158ad4e00a167c64820acc31551c49f2425aa914b137a351bb11e558f995777e40f774b1b8a3636c15a0b06004dff3d570792a2d31804cef33820af76471f1341421f0c850100000600ff8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a483a85f102"]}
2019-10-15 10:41:49          API-WS: received {"jsonrpc":"2.0","error":{"code":1010,"message":"Invalid Transaction","data":"Payment"},"id":10}

(Previously, as well as on Kusama, used to get a subscription id back, not the actual error)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants