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

import rpc transactions sequentially #10051

Merged
merged 7 commits into from
Jan 22, 2019
Merged

Conversation

seunlanlege
Copy link
Member

Previously the ProspectiveSigner marks nonces as used even though they weren't successfully imported into the transaction queue
which caused issues like: #9040

This PR auguments the nonce reservation system such that a reserved nonce is only marked as used if
the PostSign action executes successfully eg transaction is successfully imported into the tx queue

@parity-cla-bot
Copy link

It looks like @seunlanlege signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
@seunlanlege
Copy link
Member Author

There should be some tests that affirm this new behaviour, just how to design them properly 🤔

Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

I don't like the fact that now we have logic splitted into multiple places. Also I think ProspectiveDispatcher is uneccessary complication - let's just add PostSign to ProspectiveSigner instead.

I think PostSign should allow custom IntoFuture to be returned.
The result of that future should then be returned as ProspectiveSigner result.

That would simplify the API, the goal would be to have:

let dispatch_result = dispatcher.sign(accounts, filled, password, |transaction| {
  dispatcher.dispatch(transaction) // this returns a future
});
// in dispatch_result we have whatever was returned by `dispatcher.dispatch`.

rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@tomusdrw tomusdrw 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! Couple of minor nitpicks

rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
ready: Option<nonce::Ready>,
post_sign: Option<P>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know that it's aligned with how currently the state is passed in the ProspectiveSigner, but we might consider refactoring this in a way that the required items are passed in the ProspectiveSignerState enum instead to avoid so many Option< and .expects().
Not required for this PR (or not required at all), unless someone wants to pick it up :)

rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Outdated Show resolved Hide resolved
rpc/src/v1/helpers/dispatch.rs Show resolved Hide resolved
rpc/src/v1/impls/personal.rs Show resolved Hide resolved
rpc/src/v1/impls/personal.rs Show resolved Hide resolved
@@ -491,6 +554,8 @@ impl ProspectiveSigner {
},
prospective: None,
ready: None,
post_sign: Some(post_sign),
Copy link
Collaborator

@niklasad1 niklasad1 Jan 21, 2019

Choose a reason for hiding this comment

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

It doesn't make sense that post_sign is an Option anymore because poll assumes that it is always is Some otherwise panic and new requires it too!

Then we can get rid of a couple of expect's

Copy link
Member Author

Choose a reason for hiding this comment

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

the execute method on PostSign takes self, so inorder to take ownership of post_sign from ProspectiveSigner it needs to be an option. refer to this line

https://github.com/paritytech/parity-ethereum/blob/001a42a98a557edc7c602265a580dd552c871a1d/rpc/src/v1/helpers/dispatch.rs#L592-L599

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks for clarifying missed that 👍

niklasad1
niklasad1 previously approved these changes Jan 21, 2019
Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

LGTM, but still I would like the field post_sign in ProspectiveSigner struct not to be an Option

@niklasad1 niklasad1 added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Jan 21, 2019
@5chdn 5chdn dismissed niklasad1’s stale review January 21, 2019 11:19

You cannot approve and tag it as "grumble" at the same time. Either tag it as "grumble" or approve it and say "mustntgrumble" ... Dismissing this review.

@niklasad1 niklasad1 added A8-looksgood 🦄 Pull request is reviewed well. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Jan 22, 2019
@tomusdrw tomusdrw merged commit c35abe4 into master Jan 22, 2019
@tomusdrw tomusdrw deleted the rpc-sequential-tx-import branch January 22, 2019 08:34
@jam10o-new
Copy link
Contributor

@5chdn we have had many users running into related issues, do you think we could backport this for this or next release?

@5chdn
Copy link
Contributor

5chdn commented Jan 23, 2019

yes, label at will

@5chdn 5chdn added B1-patch-beta 🕷🕷 B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. labels Jan 23, 2019
@seunlanlege seunlanlege restored the rpc-sequential-tx-import branch February 7, 2019 13:56
@seunlanlege seunlanlege deleted the rpc-sequential-tx-import branch February 7, 2019 13:58
@5chdn 5chdn mentioned this pull request Feb 12, 2019
14 tasks
5chdn pushed a commit that referenced this pull request Feb 12, 2019
* import rpc transactions sequentially

* use impl trait in argument position, renamed ProspectiveDispatcher to WithPostSign

* grouped imports

* integrates PostSign with ProspectiveSigner

* fix spaces, removed unnecessary type cast and duplicate polling

* clean up code style

* Apply suggestions from code review
@5chdn 5chdn mentioned this pull request Feb 12, 2019
18 tasks
5chdn pushed a commit that referenced this pull request Feb 12, 2019
* import rpc transactions sequentially

* use impl trait in argument position, renamed ProspectiveDispatcher to WithPostSign

* grouped imports

* integrates PostSign with ProspectiveSigner

* fix spaces, removed unnecessary type cast and duplicate polling

* clean up code style

* Apply suggestions from code review
5chdn added a commit that referenced this pull request Feb 13, 2019
* version: bump stable to 2.2.10

* import rpc transactions sequentially (#10051)

* import rpc transactions sequentially

* use impl trait in argument position, renamed ProspectiveDispatcher to WithPostSign

* grouped imports

* integrates PostSign with ProspectiveSigner

* fix spaces, removed unnecessary type cast and duplicate polling

* clean up code style

* Apply suggestions from code review

* Additional tests for uint deserialization. (#10279)

* Don't run the CPP example on CI (#10285)

* Don't run the CPP example on CI

* Add comment

* CI optimizations (#10297)

* CI optimizations

* fix stripping

* new dockerfile

* no need n submodule upd

* review

* moved dockerfile

* it becomes large

* onchain update depends on s3

* fix dependency

* fix cache status

* fix cache status

* new cache status

* fix publish job (#10317)

* fix publish job

* dashes and colonels

* Add Statetest support for Constantinople Fix (#10323)

* Update Ethereum tests repo to v6.0.0-beta.3 tag

* Add spec for St.Peter's / ConstantinopleFix statetests

* fix(add helper for timestamp overflows) (#10330)

* fix(add helper timestamp overflows)

* fix(simplify code)

* fix(make helper private)

* fix(docker): fix not receives SIGINT (#10059)

* fix(docker): fix not receives SIGINT

* fix: update with reviews

* update with review

* update

* update

* snap: official image / test (#10168)

* official image / test

* fix / test

* bit more necromancy

* fix paths

* add source bin/df /test

* add source bin/df /test2

* something w paths /test

* something w paths /test

* add source-type /test

* show paths /test

* copy plugin /test

* plugin -> nil

* install rhash

* no questions while installing rhash

* publish snap only for release

* Don't add discovery initiators to the node table (#10305)

* Don't add discovery initiators to the node table

* Use enums for tracking state of the nodes in discovery

* Dont try to ping ourselves

* Fix minor nits

* Update timeouts when observing an outdated node

* Extracted update_bucket_record from update_node

* Fixed typo

* Fix two final nits from @todr

* change docker image based on debian instead of ubuntu due to the chan… (#10336)

* change docker image based on debian instead of ubuntu due to the changes of the build container

* role back docker build image and docker deploy image to ubuntu:xenial based (#10338)

* perform stripping during build (#10208)

* perform stripping during build (#10208)

* perform stripping during build

* var RUSTFLAGS

* fix(docker-aarch64) : cross-compile config (#9798)

* fix(docker-aarch64) : cross-compile config (#9798)

* ci: remove trailing double newline from dockerfile
5chdn added a commit that referenced this pull request Feb 13, 2019
* version: bump beta to 2.3.3

* import rpc transactions sequentially (#10051)

* import rpc transactions sequentially

* use impl trait in argument position, renamed ProspectiveDispatcher to WithPostSign

* grouped imports

* integrates PostSign with ProspectiveSigner

* fix spaces, removed unnecessary type cast and duplicate polling

* clean up code style

* Apply suggestions from code review

* Fix Windows build (#10284)

* Don't run the CPP example on CI (#10285)

* Don't run the CPP example on CI

* Add comment

* CI optimizations (#10297)

* CI optimizations

* fix stripping

* new dockerfile

* no need n submodule upd

* review

* moved dockerfile

* it becomes large

* onchain update depends on s3

* fix dependency

* fix cache status

* fix cache status

* new cache status

* fix publish job (#10317)

* fix publish job

* dashes and colonels

* Add Statetest support for Constantinople Fix (#10323)

* Update Ethereum tests repo to v6.0.0-beta.3 tag

* Add spec for St.Peter's / ConstantinopleFix statetests

* Properly handle check_epoch_end_signal errors (#10015)

* Make check_epoch_end_signal to only use immutable data

* Move check_epoch_end_signals out of commit_block

* Make check_epoch_end_signals possible to fail

* Actually return the error from check_epoch_end_signals

* Remove a clone

* Fix import error

* cargo: fix compilation

* fix(add helper for timestamp overflows) (#10330)

* fix(add helper timestamp overflows)

* fix(simplify code)

* fix(make helper private)

* Remove CallContract and RegistryInfo re-exports from `ethcore/client` (#10205)

* Remove re-export of `CallContract` and `RegistryInfo` from `ethcore/client`

* Remove CallContract and RegistryInfo re-exports again

This was missed while fixing merge conflicts

* fix(docker): fix not receives SIGINT (#10059)

* fix(docker): fix not receives SIGINT

* fix: update with reviews

* update with review

* update

* update

* snap: official image / test (#10168)

* official image / test

* fix / test

* bit more necromancy

* fix paths

* add source bin/df /test

* add source bin/df /test2

* something w paths /test

* something w paths /test

* add source-type /test

* show paths /test

* copy plugin /test

* plugin -> nil

* install rhash

* no questions while installing rhash

* publish snap only for release

* Don't add discovery initiators to the node table (#10305)

* Don't add discovery initiators to the node table

* Use enums for tracking state of the nodes in discovery

* Dont try to ping ourselves

* Fix minor nits

* Update timeouts when observing an outdated node

* Extracted update_bucket_record from update_node

* Fixed typo

* Fix two final nits from @todr

* Extract CallContract and RegistryInfo traits into their own crate (#10178)

* Create call-contract crate

* Add license

* First attempt at using extracted CallContract trait

* Remove unneeded `extern crate` calls

* Move RegistryInfo trait into call-contract crate

* Move service-transaction-checker from ethcore to ethcore-miner

* Update Cargo.lock file

* Re-export call_contract

* Merge CallContract and RegistryInfo imports

* Remove commented code

* Add documentation to call_contract crate

* Add TODO for removal of re-exports

* Update call-contract crate description

Co-Authored-By: HCastano <HCastano@users.noreply.github.com>

* Rename call-contract crate to ethcore-call-contract

* Remove CallContract and RegistryInfo re-exports from `ethcore/client` (#10205)

* Remove re-export of `CallContract` and `RegistryInfo` from `ethcore/client`

* Remove CallContract and RegistryInfo re-exports again

This was missed while fixing merge conflicts

* fixed: types::transaction::SignedTransaction; (#10229)

* fix daemonize dependency

* fix build

* change docker image based on debian instead of ubuntu due to the chan… (#10336)

* change docker image based on debian instead of ubuntu due to the changes of the build container

* role back docker build image and docker deploy image to ubuntu:xenial based (#10338)

* perform stripping during build (#10208)

* perform stripping during build (#10208)

* perform stripping during build

* var RUSTFLAGS
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants