Skip to content

Commit

Permalink
BREAKING CHANGE: update tx_pool_info and get_transaction response (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
homura authored May 30, 2024
1 parent 40e12a9 commit 84521a5
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-lies-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/base": minor
---

feat: update `TxPoolInfo` structure nervosnetwork/ckb#3894
5 changes: 5 additions & 0 deletions .changeset/funny-foxes-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/base": minor
---

feat: update `TransactionWithStatus` structure nervosnetwork/ckb#4108
5 changes: 5 additions & 0 deletions .changeset/good-donkeys-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/rpc": minor
---

**BREAKING CHANGE**: update `txPoolInfo` response nervosnetwork/ckb#3894
5 changes: 5 additions & 0 deletions .changeset/lucky-pillows-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/rpc": minor
---

**BREAKING CHANGE**: update `get_transaction` response nervosnetwork/ckb#4108
5 changes: 5 additions & 0 deletions packages/base/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export interface TransactionWithStatus<Tx = Transaction> {
txStatus: TxStatus;
timeAddedToPool: Uint64 | null;
cycles: Uint64 | null;
fee: Uint64 | null;
minReplaceFee: Uint64 | null;
}

export interface Cell {
Expand Down Expand Up @@ -321,6 +323,9 @@ export interface TxPoolInfo {
totalTxCycles: HexNumber;
minFeeRate: HexNumber;
lastTxsUpdatedAt: HexNumber;
minRbfRate: HexNumber;
maxTxPoolSize: HexNumber;
txSizeLimit: HexNumber;
}

export interface TxPoolIds {
Expand Down
2 changes: 2 additions & 0 deletions packages/ckb-indexer/src/transaction_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 30 additions & 10 deletions packages/ckb-indexer/tests/test_cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -7082,7 +7082,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7120,7 +7122,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7158,7 +7162,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7196,7 +7202,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7234,7 +7242,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7272,7 +7282,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7310,7 +7322,9 @@ const transactionByLock = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
]

Expand Down Expand Up @@ -7398,7 +7412,9 @@ const transactionsByType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
},
{
transaction: {
Expand Down Expand Up @@ -7464,7 +7480,9 @@ const transactionsByType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
}
];

Expand Down Expand Up @@ -7533,7 +7551,9 @@ const transactionsByLockAndType = [
status: 'committed',
},
cycles: null,
timeAddedToPool: null
timeAddedToPool: null,
fee: null,
minReplaceFee: null
}
];

Expand Down
2 changes: 2 additions & 0 deletions packages/ckb-indexer/tests/transaction_collector.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,7 @@ function mockTxWithStatus({
txStatus: { status: "committed" },
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export const unresolvedTransaction: TransactionWithStatus = {
},
cycles: null,
timeAddedToPool: null,
fee: null,
minReplaceFee: null,
};
export const unresolvedTransactionList: TransactionWithStatus[] = [
unresolvedTransaction,
Expand Down Expand Up @@ -253,6 +255,8 @@ export const resolvedTransaction: TransactionWithStatus = {
},
cycles: null,
timeAddedToPool: null,
fee: null,
minReplaceFee: null,
};

export const batchRequestTransaction = [
Expand Down
4 changes: 4 additions & 0 deletions packages/hd-cache/tests/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const mockTxs: TransactionWithStatus[] = [
},
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
},
{
transaction: {
Expand Down Expand Up @@ -124,6 +126,8 @@ const mockTxs: TransactionWithStatus[] = [
},
timeAddedToPool: null,
cycles: null,
fee: null,
minReplaceFee: null,
},
];
const headerData = {
Expand Down
10 changes: 10 additions & 0 deletions packages/rpc/src/resultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -252,6 +255,9 @@ const toTxPoolInfo = (info: RPC.TxPoolInfo): CKBComponents.TxPoolInfo => {
totalTxCycles,
totalTxSize,
minFeeRate,
minRbfRate,
txSizeLimit,
maxTxPoolSize,
...rest,
};
};
Expand Down Expand Up @@ -326,6 +332,8 @@ const toTransactionWithStatus = <Tx>(
transaction,
tx_status: { block_hash: blockHash, status },
time_added_to_pool,
min_replace_fee,
fee,
...rest
} = txWithStatus;
return {
Expand All @@ -338,6 +346,8 @@ const toTransactionWithStatus = <Tx>(
: {}),
},
timeAddedToPool: time_added_to_pool,
minReplaceFee: min_replace_fee,
fee,
...rest,
};
};
Expand Down
5 changes: 5 additions & 0 deletions packages/rpc/src/types/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion packages/testkit/src/mock-ckb-jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export function createCKBMockRPC(options: Options): Express {
},
time_added_to_pool: null,
cycles: null,
min_replace_fee: null,
fee: null,
};
}
);
Expand Down Expand Up @@ -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);
}
});
}
Expand Down
18 changes: 18 additions & 0 deletions website/docs/migrations/migrate-to-v0.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 84521a5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 New canary release: 0.0.0-canary-84521a5-20240530061434

npm install @ckb-lumos/[email protected]

Please sign in to comment.