-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fn queue_transactions accepts UnverifiedTransactions #10887
Changes from all 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 |
---|---|---|
|
@@ -2217,22 +2217,22 @@ impl BlockChainClient for Client { | |
} | ||
|
||
impl IoClient for Client { | ||
fn queue_transactions(&self, transactions: Vec<Bytes>, peer_id: usize) { | ||
fn queue_transactions(&self, transactions: Vec<UnverifiedTransaction>, peer_id: usize) { | ||
trace_time!("queue_transactions"); | ||
let len = transactions.len(); | ||
self.queue_transactions.queue(&self.io_channel.read(), len, move |client| { | ||
trace_time!("import_queued_transactions"); | ||
|
||
let txs: Vec<UnverifiedTransaction> = transactions | ||
.iter() | ||
.filter_map(|bytes| client.engine.decode_transaction(bytes).ok()) | ||
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. this verification is performed by a miner 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. So we previous ignored invalid rlps and now we return an err 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.
Yes
No, it was a regression introduced very recently 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. This closure is invoked in a |
||
.collect(); | ||
|
||
let hashes: Vec<_> = transactions.iter().map(UnverifiedTransaction::hash).collect(); | ||
client.notify(|notify| { | ||
notify.transactions_received(&txs, peer_id); | ||
notify.transactions_received(&hashes, peer_id); | ||
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 we should move this notification after miner imports the transactions? cause those transactions may be invalid 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. AFAIR this notification only updates |
||
}); | ||
|
||
client.importer.miner.import_external_transactions(client, txs); | ||
// TODO: queue_transactions.queue, should accept FnOnce, so it can capture outer variables | ||
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. could you open an issue? 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 wanted to do it initially, but it requires reworking |
||
for res in client.importer.miner.import_external_transactions(client, transactions.clone()) { | ||
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. This is unacceptable, it means you clone ~4MB a second. |
||
if let Err(e) = res { | ||
debug!(target: "client", "Import of external transaction has failed: {}", e); | ||
} | ||
} | ||
}).unwrap_or_else(|e| { | ||
debug!(target: "client", "Ignoring {} transactions: {}", len, e); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -541,9 +541,13 @@ pub trait Engine: Sync + Send { | |
self.machine().verify_transaction_basic(t, header) | ||
} | ||
|
||
/// Performs pre-validation of RLP decoded transaction before other processing | ||
fn decode_transaction(&self, transaction: &[u8]) -> Result<UnverifiedTransaction, transaction::Error> { | ||
self.machine().decode_transaction(transaction) | ||
/// Verifies len of transaction RLP | ||
fn verify_transaction_len(&self, transaction: &[u8]) -> Result<(), transaction::Error> { | ||
if transaction.len() > self.params().max_transaction_size { | ||
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.
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. No we can't just remove it. We need a way to tell users that their transaction is not being accepted to the pool and will never be propagated. We can obviously hardcode that into a miner, but it feels like a regression. |
||
return Err(transaction::Error::TooBig) | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -673,8 +673,7 @@ impl SyncHandler { | |
trace!(target: "sync", "{:02} -> Transactions ({} entries)", peer_id, item_count); | ||
let mut transactions = Vec::with_capacity(item_count); | ||
for i in 0 .. item_count { | ||
let rlp = r.at(i)?; | ||
let tx = rlp.as_raw().to_vec(); | ||
let tx = r.val_at(i)?; | ||
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. The whole point of passing |
||
transactions.push(tx); | ||
} | ||
io.chain().queue_transactions(transactions, peer_id); | ||
|
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.
This looks like a regression. Luckily it's only a light client, so we shouldn't have many transactions but you may end up cloning a lot of data.