diff --git a/resource/ckb.toml b/resource/ckb.toml index 77f8082878..7cb1f2321d 100644 --- a/resource/ckb.toml +++ b/resource/ckb.toml @@ -132,9 +132,8 @@ enable_deprecated_rpc = false # {{ # }} [tx_pool] -max_mem_size = 20_000_000 # 20mb -max_cycles = 200_000_000_000 -min_fee_rate = 1_000 # shannons/KB +max_tx_pool_size = 180_000_000 # 180mb +min_fee_rate = 1_000 # Here fee_rate are calculated directly using size in units of shannons/KB max_tx_verify_cycles = 70_000_000 max_ancestors_count = 25 diff --git a/rpc/README.md b/rpc/README.md index c1cba7f132..2a99fb7f50 100644 --- a/rpc/README.md +++ b/rpc/README.md @@ -4435,14 +4435,16 @@ Response "jsonrpc": "2.0", "result": { "last_txs_updated_at": "0x0", - "min_fee_rate": "0x0", + "min_fee_rate": "0x3e8", + "max_tx_pool_size": "0xaba9500", "orphan": "0x0", "pending": "0x1", "proposed": "0x0", "tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", "tip_number": "0x400", "total_tx_cycles": "0x219", - "total_tx_size": "0x112" + "total_tx_size": "0x112", + "tx_size_limit": "0x7d000" } } ``` @@ -4986,6 +4988,10 @@ For example, a cellbase transaction is not allowed in `send_transaction` RPC. (-1109): The transaction is expired from tx-pool after `expiry_hours`. +### Error `PoolRejectedTransactionBySizeLimit` + +(-1110): The transaction exceeded maximum size limit. + ### Error `Indexer` (-1200): The indexer error. @@ -6329,14 +6335,15 @@ TX reject message `PoolTransactionReject` is a JSON object with following fields. -* `type`: `"LowFeeRate" | "ExceededMaximumAncestorsCount" | "Full" | "Duplicated" | "Malformed" | "DeclaredWrongCycles" | "Resolve" | "Verification" | "Expiry"` - Reject type. +* `type`: `"LowFeeRate" | "ExceededMaximumAncestorsCount" | "ExceededTransactionSizeLimit" | "Full" | "Duplicated" | "Malformed" | "DeclaredWrongCycles" | "Resolve" | "Verification" | "Expiry"` - Reject type. * `description`: `string` - Detailed description about why the transaction is rejected. Different reject types: * `LowFeeRate`: Transaction fee lower than config * `ExceededMaximumAncestorsCount`: Transaction exceeded maximum ancestors count limit -* `Full`: Transaction pool exceeded maximum size or cycles limit, +* `ExceededTransactionSizeLimit`: Transaction exceeded maximum size limit +* `Full`: Transaction are replaced because the pool is full * `Duplicated`: Transaction already exist in transaction_pool * `Malformed`: Malformed transaction * `DeclaredWrongCycles`: Declared wrong cycles @@ -6911,6 +6918,12 @@ Transaction pool information. * `last_txs_updated_at`: [`Timestamp`](#type-timestamp) - Last updated time. This is the Unix timestamp in milliseconds. +* `tx_size_limit`: [`Uint64`](#type-uint64) - Limiting transactions to tx_size_limit + + Transactions with a large size close to the block size limit may not be packaged, because the block header and cellbase are occupied, so the tx-pool is limited to accepting transaction up to tx_size_limit. + +* `max_tx_pool_size`: [`Uint64`](#type-uint64) - Total limit on the size of transactions in the tx-pool + ### Type `TxStatus` diff --git a/rpc/src/error.rs b/rpc/src/error.rs index 869e19333f..1f86db9b72 100644 --- a/rpc/src/error.rs +++ b/rpc/src/error.rs @@ -110,6 +110,8 @@ pub enum RPCError { PoolRejectedMalformedTransaction = -1108, /// (-1109): The transaction is expired from tx-pool after `expiry_hours`. TransactionExpired = -1109, + /// (-1110): The transaction exceeded maximum size limit. + PoolRejectedTransactionBySizeLimit = -1110, /// (-1200): The indexer error. Indexer = -1200, } @@ -165,12 +167,15 @@ impl RPCError { Reject::ExceededMaximumAncestorsCount => { RPCError::PoolRejectedTransactionByMaxAncestorsCountLimit } - Reject::Full(_, _) => RPCError::PoolIsFull, + Reject::Full(_) => RPCError::PoolIsFull, Reject::Duplicated(_) => RPCError::PoolRejectedDuplicatedTransaction, Reject::Malformed(_) => RPCError::PoolRejectedMalformedTransaction, Reject::DeclaredWrongCycles(..) => RPCError::PoolRejectedMalformedTransaction, Reject::Resolve(_) => RPCError::TransactionFailedToResolve, Reject::Verification(_) => RPCError::TransactionFailedToVerify, + Reject::ExceededTransactionSizeLimit(_, _) => { + RPCError::PoolRejectedTransactionBySizeLimit + } Reject::Expiry(_) => RPCError::TransactionExpired, }; RPCError::custom_with_error(code, reject) diff --git a/rpc/src/module/pool.rs b/rpc/src/module/pool.rs index 7013787e37..d2832c734b 100644 --- a/rpc/src/module/pool.rs +++ b/rpc/src/module/pool.rs @@ -161,14 +161,16 @@ pub trait PoolRpc { /// "jsonrpc": "2.0", /// "result": { /// "last_txs_updated_at": "0x0", - /// "min_fee_rate": "0x0", + /// "min_fee_rate": "0x3e8", + /// "max_tx_pool_size": "0xaba9500", /// "orphan": "0x0", /// "pending": "0x1", /// "proposed": "0x0", /// "tip_hash": "0xa5f5c85987a15de25661e5a214f2c1449cd803f071acc7999820f25246471f40", /// "tip_number": "0x400", /// "total_tx_cycles": "0x219", - /// "total_tx_size": "0x112" + /// "total_tx_size": "0x112", + /// "tx_size_limit": "0x7d000" /// } /// } /// ``` @@ -276,7 +278,6 @@ pub trait PoolRpc { pub(crate) struct PoolRpcImpl { shared: Shared, - min_fee_rate: core::FeeRate, well_known_lock_scripts: Vec, well_known_type_scripts: Vec, } @@ -284,7 +285,6 @@ pub(crate) struct PoolRpcImpl { impl PoolRpcImpl { pub fn new( shared: Shared, - min_fee_rate: core::FeeRate, mut extra_well_known_lock_scripts: Vec, mut extra_well_known_type_scripts: Vec, ) -> PoolRpcImpl { @@ -298,7 +298,6 @@ impl PoolRpcImpl { PoolRpcImpl { shared, - min_fee_rate, well_known_lock_scripts, well_known_type_scripts, } @@ -449,17 +448,7 @@ impl PoolRpc for PoolRpcImpl { let tx_pool_info = get_tx_pool_info.unwrap(); - Ok(TxPoolInfo { - tip_hash: tx_pool_info.tip_hash.unpack(), - tip_number: tx_pool_info.tip_number.into(), - pending: (tx_pool_info.pending_size as u64).into(), - proposed: (tx_pool_info.proposed_size as u64).into(), - orphan: (tx_pool_info.orphan_size as u64).into(), - total_tx_size: (tx_pool_info.total_tx_size as u64).into(), - total_tx_cycles: tx_pool_info.total_tx_cycles.into(), - min_fee_rate: self.min_fee_rate.as_u64().into(), - last_txs_updated_at: tx_pool_info.last_txs_updated_at.into(), - }) + Ok(tx_pool_info.into()) } fn clear_tx_pool(&self) -> Result<()> { diff --git a/rpc/src/service_builder.rs b/rpc/src/service_builder.rs index c72953d0ef..19372ce8a0 100644 --- a/rpc/src/service_builder.rs +++ b/rpc/src/service_builder.rs @@ -15,7 +15,7 @@ use ckb_network_alert::{notifier::Notifier as AlertNotifier, verifier::Verifier use ckb_pow::Pow; use ckb_shared::shared::Shared; use ckb_sync::SyncShared; -use ckb_types::{core::FeeRate, packed::Script}; +use ckb_types::packed::Script; use ckb_util::Mutex; use jsonrpc_core::RemoteProcedure; use std::sync::Arc; @@ -52,13 +52,11 @@ impl<'a> ServiceBuilder<'a> { pub fn enable_pool( mut self, shared: Shared, - min_fee_rate: FeeRate, extra_well_known_lock_scripts: Vec