Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the timestamp of the transaction in tx-pool through rpc #3938

Closed
quake opened this issue Apr 14, 2023 · 4 comments · Fixed by #3949
Closed

Show the timestamp of the transaction in tx-pool through rpc #3938

quake opened this issue Apr 14, 2023 · 4 comments · Fixed by #3949
Assignees
Labels
t:enhancement Type: Feature, refactoring.

Comments

@quake
Copy link
Member

quake commented Apr 14, 2023

#3894 added a timestamp to record the transaction when it entering the tx-pool, suggest to display this field in theget_transaction rpc, it's helpful to debug or re-send a long pending tx by checking this timestamp.

@quake quake added the t:enhancement Type: Feature, refactoring. label Apr 14, 2023
@eval-exec
Copy link
Collaborator

eval-exec commented Apr 14, 2023

The current TxStatus definition is this:

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TxStatus {
/// Status "pending". The transaction is in the pool, and not proposed yet.
Pending,
/// Status "proposed". The transaction is in the pool and has been proposed.
Proposed,
/// Status "committed". The transaction has been committed to the canonical chain.
Committed(H256),
/// Status "unknown". The node has not seen the transaction,
/// or it should be rejected but was cleared due to storage limitations.
Unknown,
/// Status "rejected". The transaction has been recently removed from the pool.
/// Due to storage limitations, the node can only hold the most recently removed transactions.
Rejected(String),
}

I think we can change TxStatus to this:
change Pending to Pending(u64), change Proposed to Proposed(u64).
(just add a inner u64 value in Pending and Proposed to represent the timestamp when the tx was enter the tx-pool.)

/// Tx-pool transaction status
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TxStatus {
    /// Status "pending". The transaction is in the pool, and not proposed yet.
    Pending(u64),  // inner value is the timestamp when the tx enter the pool

    /// Status "proposed". The transaction is in the pool and has been proposed.
    Proposed(u64), // inner value is the timestamp when the tx enter the pool

    /// Status "committed". The transaction has been committed to the canonical chain.
    Committed(H256),
    /// Status "unknown". The node has not seen the transaction,
    /// or it should be rejected but was cleared due to storage limitations.
    Unknown,
    /// Status "rejected". The transaction has been recently removed from the pool.
    /// Due to storage limitations, the node can only hold the most recently removed transactions.
    Rejected(String),
}

Cc. @zhangsoledad

@doitian
Copy link
Member

doitian commented Apr 14, 2023

I would suggest adding an RPC like Bitcoin getmempoolentry.

@eval-exec
Copy link
Collaborator

I would suggest adding an RPC like Bitcoin getmempoolentry.

Agree, I would like to work on this.

@eval-exec eval-exec moved this to 🏗 In progress in CKB Kanban Apr 21, 2023
@eval-exec eval-exec moved this from 🏗 In progress to 📋 Backlog in CKB Kanban Apr 21, 2023
@zhangsoledad
Copy link
Member

zhangsoledad commented Apr 21, 2023

@eval-exec

I recommend adding a field

#[derive(Clone, Debug)]
pub struct TransactionWithStatus {
    /// The transaction.
    ......
    pub cycles: Option<core::Cycle>.
    pub timestamp: Option<u64>.
}

Instead of modifying the structure of TxStatus

For json parser,
adding a filed is much more friendly than modifying the object's structure.

@eval-exec eval-exec self-assigned this Apr 21, 2023
@eval-exec eval-exec moved this from 📋 Backlog to 🏗 In progress in CKB Kanban Apr 21, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in CKB Kanban Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:enhancement Type: Feature, refactoring.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants