-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Return error if RLP size of transaction exceeds the limit #8473
Changes from 1 commit
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 |
---|---|---|
|
@@ -48,6 +48,7 @@ use header::{Header, BlockNumber}; | |
use miner; | ||
use miner::pool_client::{PoolClient, CachedNonceClient}; | ||
use receipt::{Receipt, RichReceipt}; | ||
use rlp::Encodable; | ||
use spec::Spec; | ||
use state::State; | ||
|
||
|
@@ -768,6 +769,11 @@ impl miner::MinerService for Miner { | |
|
||
trace!(target: "own_tx", "Importing transaction: {:?}", pending); | ||
|
||
// Verify RLP payload first | ||
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'd see it more in the RPC layer than here. 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 didn't put it into RPC dispatcher, because import_own_transaction called not only from RPC. There are at least 2 other usages (in private transactions and in secret store). IMHO these cases (when transactions are created not from RPC but by some logic) also should be guarded with this check. 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. It should be part of verification pipeline then + the additional check for all external transactions to avoid RLP decoding them and hashing large amounts of data. |
||
if let Err(err) = self.engine.decode_transaction(pending.transaction.rlp_bytes().to_vec()) { | ||
return Err(err); | ||
} | ||
|
||
let client = self.pool_client(chain); | ||
let imported = self.transaction_queue.import( | ||
client, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,6 +338,8 @@ pub fn transaction_message(error: &TransactionError) -> String { | |
RecipientBanned => "Recipient is banned in local queue.".into(), | ||
CodeBanned => "Code is banned in local queue.".into(), | ||
NotAllowed => "Transaction is not permitted.".into(), | ||
TooBig => "Transaction is too big for transmition, see chain specification for the limit.".into(), | ||
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.
|
||
InvalidRlp(ref descr) => format!("Invalid RLP data: {}", descr), | ||
} | ||
} | ||
|
||
|
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.
Let's use
&[u8]
here to avoid unnecessary copying.