-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow disabling local-by-default for transactions with new config entry #8882
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,10 @@ impl<C: miner::BlockChainClient, M: MinerService> FullDispatcher<C, M> { | |
pub fn dispatch_transaction(client: &C, miner: &M, signed_transaction: PendingTransaction) -> Result<H256> { | ||
let hash = signed_transaction.transaction.hash(); | ||
|
||
miner.import_own_transaction(client, signed_transaction) | ||
// 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @XertroV Can we only use
A simple way may be just to add a boolean param in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah okay. I'm not too familiar with how all of this connects together, FYI. Also going to add this flag to |
||
.map_err(errors::transaction) | ||
.map(|_| hash) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,21 @@ impl MinerService for TestMinerService { | |
Ok(()) | ||
} | ||
|
||
/// 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe just call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that today and couldn't figure out how to do it (calling the instance of Eventually I realised that |
||
-> Result<(), transaction::Error> { | ||
|
||
// keep the pending nonces up to date | ||
let sender = pending.transaction.sender(); | ||
let nonce = self.next_nonce(chain, &sender); | ||
self.next_nonces.write().insert(sender, nonce); | ||
|
||
// lets assume that all txs are valid | ||
self.imported_transactions.lock().push(pending.transaction); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Called when blocks are imported to chain, updates transactions queue. | ||
fn chain_new_blocks<C>(&self, _chain: &C, _imported: &[H256], _invalid: &[H256], _enacted: &[H256], _retracted: &[H256], _is_internal: bool) { | ||
unimplemented!(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we:
import_own_transaction
unchanged.import_local_or_external_transaction
(or maybe a better name, can't think of right now), which dispatch toimport_own_transaction
orimport_external_transactions
.eth_submitRawTransaction
call that function instead, throughDispatcher
.The issue is that
import_own_transaction
is used in many other places inethcore
, and this change may break some of the previous assumptions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, agreed. Much more elegant . Will get on that tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does
import_foreign_transaction
sound? Or maybe justimport_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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both sound fine to me. :)