Skip to content

Commit b5f289c

Browse files
authored
Merge pull request #3275 from Pana/op/errorMessage
op: optimize FutureTxType error message
2 parents 9928b33 + 5389410 commit b5f289c

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

crates/cfxcore/core/src/transaction_pool/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl From<TransactionPoolError> for EthApiError {
6767
TransactionError::TooBig => Self::InvalidTransaction(RpcInvalidTransactionError::MaxInitCodeSizeExceeded),
6868
TransactionError::InvalidRlp(_) => Self::FailedToDecodeSignedTransaction,
6969
TransactionError::ZeroGasPrice => Self::PoolError(RpcPoolError::Underpriced),
70-
TransactionError::FutureTransactionType => Self::InvalidTransaction(RpcInvalidTransactionError::TxTypeNotSupported),
70+
TransactionError::FutureTransactionType { .. } => Self::InvalidTransaction(RpcInvalidTransactionError::TxTypeNotSupported),
7171
TransactionError::InvalidReceiver => Self::Other("Invalid receiver".to_string()),
7272
TransactionError::TooLargeNonce => Self::InvalidTransaction(RpcInvalidTransactionError::NonceMaxValue),
7373
TransactionError::CreateInitCodeSizeLimit => Self::InvalidTransaction(RpcInvalidTransactionError::MaxInitCodeSizeExceeded),

crates/cfxcore/core/src/verification.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use primitives::{
2727
block_header::compute_next_price_tuple,
2828
transaction::{
2929
native_transaction::TypedNativeTransaction, TransactionError,
30+
EIP1559_TYPE, EIP7702_TYPE, LEGACY_TX_TYPE,
3031
},
3132
Action, Block, BlockHeader, BlockReceipts, MerkleHash, Receipt,
3233
SignedTransaction, Transaction, TransactionWithSignature,
@@ -777,15 +778,27 @@ impl VerificationConfig {
777778
}
778779

779780
if !Self::check_eip155_transaction(tx, cip90a, &mode) {
780-
bail!(TransactionError::FutureTransactionType);
781+
bail!(TransactionError::FutureTransactionType {
782+
tx_type: LEGACY_TX_TYPE,
783+
current_height: height,
784+
enable_height: transitions.cip90a,
785+
});
781786
}
782787

783788
if !Self::check_eip1559_transaction(tx, cip1559, &mode) {
784-
bail!(TransactionError::FutureTransactionType)
789+
bail!(TransactionError::FutureTransactionType {
790+
tx_type: EIP1559_TYPE,
791+
current_height: height,
792+
enable_height: transitions.cip1559,
793+
})
785794
}
786795

787796
if !Self::check_eip7702_transaction(tx, cip7702, &mode) {
788-
bail!(TransactionError::FutureTransactionType)
797+
bail!(TransactionError::FutureTransactionType {
798+
tx_type: EIP7702_TYPE,
799+
current_height: height,
800+
enable_height: transitions.cip7702,
801+
})
789802
}
790803

791804
if !Self::check_eip3860(tx, cip645) {

crates/primitives/src/transaction/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ pub enum TransactionError {
131131
InvalidRlp(String),
132132
ZeroGasPrice,
133133
/// Transaction types have not been activated
134-
FutureTransactionType,
134+
FutureTransactionType {
135+
tx_type: u8,
136+
enable_height: u64,
137+
current_height: u64,
138+
},
135139
/// Create transaction with too large init code size,
136140
CreateInitCodeSizeLimit,
137141
/// Receiver with invalid type bit.
@@ -203,7 +207,7 @@ impl fmt::Display for TransactionError {
203207
format!("Transaction has invalid RLP structure: {}.", err)
204208
}
205209
ZeroGasPrice => "Zero gas price is not allowed".into(),
206-
FutureTransactionType => "Ethereum like transaction should have u64::MAX storage limit".into(),
210+
FutureTransactionType {tx_type, current_height, enable_height} => format!("Transaction type {tx_type} is not enabled, current height {current_height}, enable height {enable_height}"),
207211
InvalidReceiver => "Sending transaction to invalid address. The first four bits of address must be 0x0, 0x1, or 0x8.".into(),
208212
TooLargeNonce => "Transaction nonce is too large.".into(),
209213
CreateInitCodeSizeLimit => "Transaction initcode is too large.".into(),

0 commit comments

Comments
 (0)