From 84521a55fad45a3df17457ea8f24c899d50fe59a Mon Sep 17 00:00:00 2001 From: homura Date: Thu, 30 May 2024 15:13:01 +0900 Subject: [PATCH] BREAKING CHANGE: update tx_pool_info and get_transaction response (#696) --- .changeset/chilly-lies-punch.md | 5 +++ .changeset/funny-foxes-fetch.md | 5 +++ .changeset/good-donkeys-speak.md | 5 +++ .changeset/lucky-pillows-argue.md | 5 +++ packages/base/src/api.ts | 5 +++ .../ckb-indexer/src/transaction_collector.ts | 2 + packages/ckb-indexer/tests/test_cases.js | 40 ++++++++++++++----- .../tests/transaction_collector.unit.test.ts | 2 + .../transaction_collector_unit_test_case.ts | 4 ++ packages/hd-cache/tests/cache.test.ts | 4 ++ packages/rpc/src/resultFormatter.ts | 10 +++++ packages/rpc/src/types/rpc.ts | 5 +++ packages/testkit/src/mock-ckb-jsonrpc.ts | 5 ++- website/docs/migrations/migrate-to-v0.23.md | 18 +++++++++ 14 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 .changeset/chilly-lies-punch.md create mode 100644 .changeset/funny-foxes-fetch.md create mode 100644 .changeset/good-donkeys-speak.md create mode 100644 .changeset/lucky-pillows-argue.md diff --git a/.changeset/chilly-lies-punch.md b/.changeset/chilly-lies-punch.md new file mode 100644 index 000000000..8a2b8dfbd --- /dev/null +++ b/.changeset/chilly-lies-punch.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/base": minor +--- + +feat: update `TxPoolInfo` structure nervosnetwork/ckb#3894 diff --git a/.changeset/funny-foxes-fetch.md b/.changeset/funny-foxes-fetch.md new file mode 100644 index 000000000..4b8234687 --- /dev/null +++ b/.changeset/funny-foxes-fetch.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/base": minor +--- + +feat: update `TransactionWithStatus` structure nervosnetwork/ckb#4108 diff --git a/.changeset/good-donkeys-speak.md b/.changeset/good-donkeys-speak.md new file mode 100644 index 000000000..b305a3cd5 --- /dev/null +++ b/.changeset/good-donkeys-speak.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/rpc": minor +--- + +**BREAKING CHANGE**: update `txPoolInfo` response nervosnetwork/ckb#3894 diff --git a/.changeset/lucky-pillows-argue.md b/.changeset/lucky-pillows-argue.md new file mode 100644 index 000000000..61d5c7ec0 --- /dev/null +++ b/.changeset/lucky-pillows-argue.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/rpc": minor +--- + +**BREAKING CHANGE**: update `get_transaction` response nervosnetwork/ckb#4108 diff --git a/packages/base/src/api.ts b/packages/base/src/api.ts index 94cf2dc6b..a350afdec 100644 --- a/packages/base/src/api.ts +++ b/packages/base/src/api.ts @@ -97,6 +97,8 @@ export interface TransactionWithStatus { txStatus: TxStatus; timeAddedToPool: Uint64 | null; cycles: Uint64 | null; + fee: Uint64 | null; + minReplaceFee: Uint64 | null; } export interface Cell { @@ -321,6 +323,9 @@ export interface TxPoolInfo { totalTxCycles: HexNumber; minFeeRate: HexNumber; lastTxsUpdatedAt: HexNumber; + minRbfRate: HexNumber; + maxTxPoolSize: HexNumber; + txSizeLimit: HexNumber; } export interface TxPoolIds { diff --git a/packages/ckb-indexer/src/transaction_collector.ts b/packages/ckb-indexer/src/transaction_collector.ts index 4515590a9..cdee63ff2 100644 --- a/packages/ckb-indexer/src/transaction_collector.ts +++ b/packages/ckb-indexer/src/transaction_collector.ts @@ -179,6 +179,8 @@ export class CKBIndexerTransactionCollector extends BaseIndexerModule.Transactio txStatus: tx.txStatus, cycles: tx.cycles, timeAddedToPool: tx.timeAddedToPool, + minReplaceFee: tx.minReplaceFee, + fee: tx.fee, }) ); return objects; diff --git a/packages/ckb-indexer/tests/test_cases.js b/packages/ckb-indexer/tests/test_cases.js index d914b1ca1..920c5999c 100644 --- a/packages/ckb-indexer/tests/test_cases.js +++ b/packages/ckb-indexer/tests/test_cases.js @@ -7082,7 +7082,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7120,7 +7122,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7158,7 +7162,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7196,7 +7202,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7234,7 +7242,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7272,7 +7282,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7310,7 +7322,9 @@ const transactionByLock = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, ] @@ -7398,7 +7412,9 @@ const transactionsByType = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null }, { transaction: { @@ -7464,7 +7480,9 @@ const transactionsByType = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null } ]; @@ -7533,7 +7551,9 @@ const transactionsByLockAndType = [ status: 'committed', }, cycles: null, - timeAddedToPool: null + timeAddedToPool: null, + fee: null, + minReplaceFee: null } ]; diff --git a/packages/ckb-indexer/tests/transaction_collector.unit.test.ts b/packages/ckb-indexer/tests/transaction_collector.unit.test.ts index 300eafdaf..95340e062 100644 --- a/packages/ckb-indexer/tests/transaction_collector.unit.test.ts +++ b/packages/ckb-indexer/tests/transaction_collector.unit.test.ts @@ -310,5 +310,7 @@ function mockTxWithStatus({ txStatus: { status: "committed" }, timeAddedToPool: null, cycles: null, + fee: null, + minReplaceFee: null, }; } diff --git a/packages/ckb-indexer/tests/transaction_collector_unit_test_case.ts b/packages/ckb-indexer/tests/transaction_collector_unit_test_case.ts index dbcac57f2..743ebde88 100644 --- a/packages/ckb-indexer/tests/transaction_collector_unit_test_case.ts +++ b/packages/ckb-indexer/tests/transaction_collector_unit_test_case.ts @@ -166,6 +166,8 @@ export const unresolvedTransaction: TransactionWithStatus = { }, cycles: null, timeAddedToPool: null, + fee: null, + minReplaceFee: null, }; export const unresolvedTransactionList: TransactionWithStatus[] = [ unresolvedTransaction, @@ -253,6 +255,8 @@ export const resolvedTransaction: TransactionWithStatus = { }, cycles: null, timeAddedToPool: null, + fee: null, + minReplaceFee: null, }; export const batchRequestTransaction = [ diff --git a/packages/hd-cache/tests/cache.test.ts b/packages/hd-cache/tests/cache.test.ts index 4db4f8ccb..2540d8357 100644 --- a/packages/hd-cache/tests/cache.test.ts +++ b/packages/hd-cache/tests/cache.test.ts @@ -58,6 +58,8 @@ const mockTxs: TransactionWithStatus[] = [ }, timeAddedToPool: null, cycles: null, + fee: null, + minReplaceFee: null, }, { transaction: { @@ -124,6 +126,8 @@ const mockTxs: TransactionWithStatus[] = [ }, timeAddedToPool: null, cycles: null, + fee: null, + minReplaceFee: null, }, ]; const headerData = { diff --git a/packages/rpc/src/resultFormatter.ts b/packages/rpc/src/resultFormatter.ts index f4c765116..141be2d26 100644 --- a/packages/rpc/src/resultFormatter.ts +++ b/packages/rpc/src/resultFormatter.ts @@ -243,6 +243,9 @@ const toTxPoolInfo = (info: RPC.TxPoolInfo): CKBComponents.TxPoolInfo => { total_tx_cycles: totalTxCycles, total_tx_size: totalTxSize, min_fee_rate: minFeeRate, + min_rbf_rate: minRbfRate, + tx_size_limit: txSizeLimit, + max_tx_pool_size: maxTxPoolSize, ...rest } = info; return { @@ -252,6 +255,9 @@ const toTxPoolInfo = (info: RPC.TxPoolInfo): CKBComponents.TxPoolInfo => { totalTxCycles, totalTxSize, minFeeRate, + minRbfRate, + txSizeLimit, + maxTxPoolSize, ...rest, }; }; @@ -326,6 +332,8 @@ const toTransactionWithStatus = ( transaction, tx_status: { block_hash: blockHash, status }, time_added_to_pool, + min_replace_fee, + fee, ...rest } = txWithStatus; return { @@ -338,6 +346,8 @@ const toTransactionWithStatus = ( : {}), }, timeAddedToPool: time_added_to_pool, + minReplaceFee: min_replace_fee, + fee, ...rest, }; }; diff --git a/packages/rpc/src/types/rpc.ts b/packages/rpc/src/types/rpc.ts index 3eaff27ba..a940aa54c 100644 --- a/packages/rpc/src/types/rpc.ts +++ b/packages/rpc/src/types/rpc.ts @@ -129,6 +129,8 @@ export namespace RPC { }; time_added_to_pool: Uint64 | null; cycles: Uint64 | null; + fee: Capacity | null; + min_replace_fee: Capacity | null; } export interface TransactionPoint { @@ -236,6 +238,9 @@ export namespace RPC { tip_number: BlockNumber; total_tx_cycles: Cycles; total_tx_size: Size; + min_rbf_rate: Uint64; + tx_size_limit: Uint64; + max_tx_pool_size: Uint64; } export interface Epoch { diff --git a/packages/testkit/src/mock-ckb-jsonrpc.ts b/packages/testkit/src/mock-ckb-jsonrpc.ts index e67ddca87..ee6104d95 100644 --- a/packages/testkit/src/mock-ckb-jsonrpc.ts +++ b/packages/testkit/src/mock-ckb-jsonrpc.ts @@ -105,6 +105,8 @@ export function createCKBMockRPC(options: Options): Express { }, time_added_to_pool: null, cycles: null, + min_replace_fee: null, + fee: null, }; } ); @@ -140,7 +142,8 @@ export function createCKBMockRPC(options: Options): Express { if (jsonRPCResponse) { res.json(jsonRPCResponse); } else { - res.sendStatus(204); + const HTTP_NO_CONTENT = 204; + res.sendStatus(HTTP_NO_CONTENT); } }); } diff --git a/website/docs/migrations/migrate-to-v0.23.md b/website/docs/migrations/migrate-to-v0.23.md index b062d63bb..8e297db5d 100644 --- a/website/docs/migrations/migrate-to-v0.23.md +++ b/website/docs/migrations/migrate-to-v0.23.md @@ -28,6 +28,24 @@ Please migrate to `loadFromKeystoreJson` + JSON.parse(fs.readFileSync(path).toString()) ``` +### RPC `getTransaction`'s Response Has Been Updated + +```diff +-min_replace_fee ++minReplaceFee +``` + +### RPC `get_`'s Response Has Been Updated + +```diff +-min_rbf_rate +-tx_size_limit +-max_tx_pool_size ++minRbfRate ++txSizeLimit ++MaxTxPoolSize +``` + --- ## Common Methods For CKB-Related Objects