Allow disabling local-by-default for transactions with new config entry#8882
Conversation
|
It looks like @XertroV signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
|
@5chdn - Do you guys want this to be squashed into one commit? I know some communities like that. (Note: asking you because you just added the tag) |
|
Yes, we squash-merge :) |
|
@5chdn - if you don't mind my bothering you, is there any way to quickly run a test? I haven't actually gotten to the point of running my test until https://gitlab.parity.io/parity/parity/-/jobs/89906 showed me the failure. have tried I'm not sure if I need to Edit: just realised that ethcore is it's own package/cargo-thing, so trying to run tests from within that directory instead of root. anyway feels like I'm making progress finally. Edit2: YES! Great success - |
- Previous commit messages: dispatcher checks if we have the sender account Add `tx_queue_allow_unknown_local` to MinerOptions Add `tx_queue_allow_unknown_local` to config fix order in MinerOptions to match Configuration add cli flag for tx_queue_allow_unknown_local Update refs to `tx_queue_allow_unknown_local` Add tx_queue_allow_unknown_local to config test revert changes to dispatcher Move tx_queue_allow_unknown_local to `import_own_transaction` Fix var name if statement should return the values derp de derp derp derp semicolons Reset dispatch file to how it was before fix compile issues + change from FLAG to ARG add test and use `into` import MinerOptions, clone the secret Fix tests? Compiler/linter issues fixed Fix linter msg - case of constants IT LIVES refactor to omit yucky explict return update comments Fix based on diff AccountProvider.has_account method
|
Sweet - I think we're good to go. Thanks for being super on top of labels and such @5chdn. Parity really is one of the most functional and responsive github orgs I've ever come across. Massive props 👏. Notes:
Bonus fun fact: this is the first work I've done relating to anything core to Ethereum since February 2014. |
Haha, wait till you (eventually) get a review. 🤣 |
Heh, I guess I haven't had the full experience yet 😛, but I also get that merging code fast-and-loose into something like parity is probably not very wise. Totally happy if that part takes a bit. On that note, also happy to rework things to bring it up to Parity's standards. |
sorpaas
left a comment
There was a problem hiding this comment.
I think we should wrap import_own_transaction rather than modifying it, as it may break some previous assumptions for this function used elsewhere. Other comments are just minor grumbles.
|
|
||
|
|
||
| imported | ||
| } else { |
There was a problem hiding this comment.
I would suggest we:
- Leave
import_own_transactionunchanged. - Create another function, probably called
import_local_or_external_transaction(or maybe a better name, can't think of right now), which dispatch toimport_own_transactionorimport_external_transactions. - Make
eth_submitRawTransactioncall that function instead, throughDispatcher.
The issue is that import_own_transaction is used in many other places in ethcore, and this change may break some of the previous assumptions.
There was a problem hiding this comment.
Yup, agreed. Much more elegant . Will get on that tomorrow.
There was a problem hiding this comment.
How does import_foreign_transaction sound? Or maybe just import_unknown_local_transaction, which corresponds to the argument name very well.
On the one hand introducing a new term is not good, but coming up with a good name is hard. Maybe normalise_unknown_local? like mixing them in with external instead of treating like known locals. I think the External/Local thing makes sense and should be left how it is (no redefining what a local tx is). (though maybe better names would be Indirect/Direct transactions (either that you get them second-hand or directly.)
There was a problem hiding this comment.
Both sound fine to me. :)
| } else { | ||
| // We want to replicate behaviour for external transactions if we're not going to treat | ||
| // this as local. This is important with regards to sealing blocks | ||
| self.import_external_transactions(chain, vec![pending.transaction.into()]) |
There was a problem hiding this comment.
Should be <whitespace> not <tab> right before vec![.
| assert!(miner.submit_seal(hash, vec![]).is_ok()); | ||
| } | ||
|
|
||
| fn default_miner_opts() -> MinerOptions { |
There was a problem hiding this comment.
Extra whitespace after fn.
| tx_gas_limit: U256::max_value(), | ||
| }, | ||
| }, | ||
| default_miner_opts(), |
There was a problem hiding this comment.
Why having an extra default_miner_opts? I think this may be confusing as MinerOptions already implements Default trait.
There was a problem hiding this comment.
Yup, it is confusing. The config returned is the default used in testing (which is not Default:: default()).
probs better to extract config from the miner produced by miner(). (I need to change just one config item)
There was a problem hiding this comment.
Alternative is to rename it to something like std_test_miner_opts
| "--tx-queue-strategy=[S]", | ||
| "Prioritization strategy used to order transactions in the queue. S may be: gas_price - Prioritize txs with high gas price", | ||
|
|
||
| ARG arg_tx_queue_allow_unknown_local: (bool) = true, or |c: &Config| c.mining.as_ref()?.tx_queue_allow_unknown_local.clone(), |
There was a problem hiding this comment.
Maybe change this to a flag, as it is a boolean?
There was a problem hiding this comment.
I wanted the default (for the flag/arg) to be true, which I can't do with a flag (seems like default must be false?) Also, unknown_local was the simplest name I could come up with that also explains the concept, and keeps all the flags/config items the same name (not negations). Length was also a cosideration. If there's a better name happy to change it.
(Like: allow_unknown_local is better than disallow_unknown_local (or deny_...), less thinking to do about what it means. and unknown_local is not great to start with, so already takes some thinking. Not super happy with the name, tbh)
There was a problem hiding this comment.
We have many "negative" flags already in cli, like --no-warp, --no-discovery, etc. And I searched the code, we don't have any boolean arg. So I still think that flag may be better for consistency, like --disallow-unknown-local/--demote-unkown-local-transactions or something like that.
Or maybe like you said, we can set --allow-unknown-local default to false? I can't think of any case where this may break existing usages -- eth_submitRawTransaction specification doesn't require giving special promotion to the submitted transaction.
|
@sorpaas - The best name I think I've come up with is something like |
|
In our current transaction pool implementation (in But I think that's just a minor naming issue and both sound fine to me. :) |
|
@sorpaas - Fixed up as per above. Note I went with |
c69582c to
2cc5e5e
Compare
|
So I seem to be getting this error the last two gitlab-build-tests that have run: Ideas? |
fix arg name Note: force commit to try and get gitlab tests working again 😠
| // use `import_claimed_local_transaction` so we can decide (based on config flags) if we want to treat | ||
| // it as local or not. Nodes with public RPC interfaces will want these transactions to be treated like | ||
| // external transactions. | ||
| miner.import_claimed_local_transaction(client, signed_transaction) |
There was a problem hiding this comment.
@XertroV Can we only use import_claimed_local_transaction for eth_sendRawTransaction? I'm worried about a race condition where:
- A new transaction, from a vault account, is sent through
eth_sendTransaction. - Before the dispatcher gets a chance, the vault is closed, and thus the account is removed from address list.
- The dispatcher gives the transaction to miner. Miner doesn't find it in the account list, so it's imported as external transaction -- clearly this is not what we want.
A simple way may be just to add a boolean param in dispatch_transaction, and only set that to true for eth_sendRawTransaction.
There was a problem hiding this comment.
Yeah okay. I'm not too familiar with how all of this connects together, FYI.
What I'm doing atm is adding a trusted: bool param to dispatch_transaction that gets called with false from eth_sendRawTx and true from the other uses of dispatch_transaction (which seems to be called from personal.rs or signer.rs. That should mean all RPC methods that involve signing get a free pass regardless of config options.
Also going to add this flag to import_claimed_local_transaction.
| } | ||
|
|
||
| /// Imports transactions to queue - treats as local based on config and tx source | ||
| fn import_claimed_local_transaction<C: Nonce + Sync>(&self, chain: &C, pending: PendingTransaction) |
There was a problem hiding this comment.
Maybe just call import_own_transaction below. The function body looks duplicate.
There was a problem hiding this comment.
I tried that today and couldn't figure out how to do it (calling the instance of import_own_transaction above it).
The compiler told me to add BlockChainClient to C because self.import_own_transaction is called on MinerService not TestMinerService, but that didn't feel right.
Eventually I realised that TestMinerService::import_own_transaction isn't actually called anymore, so have left the body in my function and added unimplemented!() to import_own_transaction.
| }.sign(keypair.secret(), Some(chain_id)) | ||
| } | ||
|
|
||
| fn post_tx_assertions( |
There was a problem hiding this comment.
This test refactor isn't correct.
- refactor the miner tests a bit to cut down on code reuse - add `trusted` param to dispatch_transaction and import_claimed_local_transaction Add param to `import_claimed_local_transaction` Fix fn sig in tests
|
Needs a 2nd review. |
| &self, | ||
| chain: &C, | ||
| pending: PendingTransaction, | ||
| pending: PendingTransaction |
There was a problem hiding this comment.
We prefer to keep trailing commas in general.
There was a problem hiding this comment.
Ahh cool, I removed it because I presumed I added it while copy-pasting. My bad.
…ry (#8882) * Add tx_queue_allow_unknown_local config option - Previous commit messages: dispatcher checks if we have the sender account Add `tx_queue_allow_unknown_local` to MinerOptions Add `tx_queue_allow_unknown_local` to config fix order in MinerOptions to match Configuration add cli flag for tx_queue_allow_unknown_local Update refs to `tx_queue_allow_unknown_local` Add tx_queue_allow_unknown_local to config test revert changes to dispatcher Move tx_queue_allow_unknown_local to `import_own_transaction` Fix var name if statement should return the values derp de derp derp derp semicolons Reset dispatch file to how it was before fix compile issues + change from FLAG to ARG add test and use `into` import MinerOptions, clone the secret Fix tests? Compiler/linter issues fixed Fix linter msg - case of constants IT LIVES refactor to omit yucky explict return update comments Fix based on diff AccountProvider.has_account method * Refactor flag name + don't change import_own_tx behaviour fix arg name Note: force commit to try and get gitlab tests working again 😠 * Add fn to TestMinerService * Avoid race condition from trusted sources - refactor the miner tests a bit to cut down on code reuse - add `trusted` param to dispatch_transaction and import_claimed_local_transaction Add param to `import_claimed_local_transaction` Fix fn sig in tests
…ry (#8882) * Add tx_queue_allow_unknown_local config option - Previous commit messages: dispatcher checks if we have the sender account Add `tx_queue_allow_unknown_local` to MinerOptions Add `tx_queue_allow_unknown_local` to config fix order in MinerOptions to match Configuration add cli flag for tx_queue_allow_unknown_local Update refs to `tx_queue_allow_unknown_local` Add tx_queue_allow_unknown_local to config test revert changes to dispatcher Move tx_queue_allow_unknown_local to `import_own_transaction` Fix var name if statement should return the values derp de derp derp derp semicolons Reset dispatch file to how it was before fix compile issues + change from FLAG to ARG add test and use `into` import MinerOptions, clone the secret Fix tests? Compiler/linter issues fixed Fix linter msg - case of constants IT LIVES refactor to omit yucky explict return update comments Fix based on diff AccountProvider.has_account method * Refactor flag name + don't change import_own_tx behaviour fix arg name Note: force commit to try and get gitlab tests working again 😠 * Add fn to TestMinerService * Avoid race condition from trusted sources - refactor the miner tests a bit to cut down on code reuse - add `trusted` param to dispatch_transaction and import_claimed_local_transaction Add param to `import_claimed_local_transaction` Fix fn sig in tests
* `duration_ns: u64 -> duration: Duration` (#8457) * duration_ns: u64 -> duration: Duration * format on millis {:.2} -> {} * Keep all enacted blocks notify in order (#8524) * Keep all enacted blocks notify in order * Collect is unnecessary * Update ChainNotify to use ChainRouteType * Fix all ethcore fn defs * Wrap the type within ChainRoute * Fix private-tx and sync api * Fix secret_store API * Fix updater API * Fix rpc api * Fix informant api * Eagerly cache enacted/retracted and remove contain_enacted/retracted * Fix indent * tests: should use full expr form for struct constructor * Use into_enacted_retracted to further avoid copy * typo: not a function * rpc/tests: ChainRoute -> ChainRoute::new * Handle removed logs in filter changes and add geth compatibility field (#8796) * Add removed geth compatibility field in log * Fix mocked tests * Add field block hash in PollFilter * Store last block hash info for log filters * Implement canon route * Use canon logs for fetching reorg logs Light client removed logs fetching is disabled. It looks expensive. * Make sure removed flag is set * Address grumbles * Fixed AuthorityRound deadlock on shutdown, closes #8088 (#8803) * CI: Fix docker tags (#8822) * scripts: enable docker builds for beta and stable * scripts: docker latest should be beta not master * scripts: docker latest is master * ethcore: fix ancient block error msg handling (#8832) * Disable parallel verification and skip verifiying already imported txs. (#8834) * Reject transactions that are already in pool without verifying them. * Avoid verifying already imported transactions. * Fix concurrent access to signer queue (#8854) * Fix concurrent access to signer queue * Put request back to the queue if confirmation failed * typo: fix docs and rename functions to be more specific `request_notify` does not need to be public, and it's renamed to `notify_result`. `notify` is renamed to `notify_message`. * Change trace info "Transaction" -> "Request" * Don't allocate in expect_valid_rlp unless necessary (#8867) * don't allocate via format! in case there's no error * fix test? * fixed ipc leak, closes #8774 (#8876) * Add new ovh bootnodes and fix port for foundation bootnode 3.2 (#8886) * Add new ovh bootnodes and fix port for foundation bootnode 3.2 * Remove old bootnodes. * Remove duplicate 1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082 * Block 0 is valid in queries (#8891) Early exit for block nr 0 leads to spurious error about pruning: `…your node is running with state pruning…`. Fixes #7547, #8762 * Add ETC Cooperative-run load balanced parity node (#8892) * Minor fix in chain supplier and light provider (#8906) * fix chain supplier increment * fix light provider block_headers * Check whether we need resealing in miner and unwrap has_account in account_provider (#8853) * Remove unused Result wrap in has_account * Check whether we need to reseal for external transactions * Fix reference to has_account interface * typo: missing ) * Refactor duplicates to prepare_and_update_sealing * Fix build * Allow disabling local-by-default for transactions with new config entry (#8882) * Add tx_queue_allow_unknown_local config option - Previous commit messages: dispatcher checks if we have the sender account Add `tx_queue_allow_unknown_local` to MinerOptions Add `tx_queue_allow_unknown_local` to config fix order in MinerOptions to match Configuration add cli flag for tx_queue_allow_unknown_local Update refs to `tx_queue_allow_unknown_local` Add tx_queue_allow_unknown_local to config test revert changes to dispatcher Move tx_queue_allow_unknown_local to `import_own_transaction` Fix var name if statement should return the values derp de derp derp derp semicolons Reset dispatch file to how it was before fix compile issues + change from FLAG to ARG add test and use `into` import MinerOptions, clone the secret Fix tests? Compiler/linter issues fixed Fix linter msg - case of constants IT LIVES refactor to omit yucky explict return update comments Fix based on diff AccountProvider.has_account method * Refactor flag name + don't change import_own_tx behaviour fix arg name Note: force commit to try and get gitlab tests working again 😠 * Add fn to TestMinerService * Avoid race condition from trusted sources - refactor the miner tests a bit to cut down on code reuse - add `trusted` param to dispatch_transaction and import_claimed_local_transaction Add param to `import_claimed_local_transaction` Fix fn sig in tests
* master: ethstore: retry deduplication of wallet file names until success (#8910) Update ropsten.json (#8926) Include node identity in the P2P advertised client version. (#8830) Allow disabling local-by-default for transactions with new config entry (#8882) Allow Poll Lifetime to be configured via CLI (#8885)
…rp_sync_on_light_client * 'master' of https://github.com/paritytech/parity: Include node identity in the P2P advertised client version. (openethereum#8830) Allow disabling local-by-default for transactions with new config entry (openethereum#8882) Allow Poll Lifetime to be configured via CLI (openethereum#8885) cleanup nibbleslice (openethereum#8915) Hardware-wallets `Clean up things I missed in the latest PR` (openethereum#8890) Remove debian/.deb and centos/.rpm packaging scripts (openethereum#8887) Remove a weird emoji in new_social docs (openethereum#8913) Minor fix in chain supplier and light provider (openethereum#8906)

Fix #8820
Transactions submitted through
import_own_transactionare checked to see if we have the account (provided thetx_queue_allow_unknown_localflag is false).The exact logic is:
BTW - I've never written Rust before, so please check this twice to make sure it is any good.
I'm also not sure if I should add any tests and/or where.