-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat(sequencer): add transaction status ABCI query #1955
Conversation
crates/astria-sequencer/CHANGELOG.md
Outdated
- Change sequencer client to poll transaction status ABCI query so that it doesn't | ||
loop indefinitely [#1955](https://github.com/astriaorg/astria/pull/1955). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this is the correct place for this? There's no changelog for Sequencer Client.
enum TransactionStatus { | ||
TRANSACTION_STATUS_UNSPECIFIED = 0; | ||
TRANSACTION_STATUS_PARKED = 1; | ||
TRANSACTION_STATUS_PENDING = 2; | ||
TRANSACTION_STATUS_REMOVAL_CACHE = 3; | ||
TRANSACTION_STATUS_UNKNOWN = 4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is useful. It's represented as an i32 in Rust anyways, and the domain TransactionStatus
conversion is done directly from i32. Could be nice for the API, though.
RemovalReason::NonceStale => write!(f, "transaction nonce is lower than current nonce"), | ||
RemovalReason::LowerNonceInvalidated => write!( | ||
f, | ||
"previous transaction was not executed, to this transaction's nonce has become \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"previous transaction was not executed, to this transaction's nonce has become \ | |
"previous transaction was not executed, so this transaction's nonce has become \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in cdb152e. Thanks for reviewing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this got missed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not handled by the looks of it :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, only have a few minor suggestions!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I think we need to make the locking in the mempool more coarse-grained in order to allow the new query to give reliable results. Basically, the four collections comprising the mempool need to be updated atomically.
RemovalReason::NonceStale => write!(f, "transaction nonce is lower than current nonce"), | ||
RemovalReason::LowerNonceInvalidated => write!( | ||
f, | ||
"previous transaction was not executed, to this transaction's nonce has become \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this got missed?
let height = match storage.latest_snapshot().get_block_height().await { | ||
Ok(height) => height, | ||
Err(err) => { | ||
return response::Query { | ||
code: Code::Err(AbciErrorCode::INTERNAL_ERROR.value()), | ||
info: "failed getting block height".into(), | ||
log: format!("{err:?}"), | ||
..response::Query::default() | ||
}; | ||
} | ||
}; | ||
|
||
let height = match height.try_into() { | ||
Ok(height) => height, | ||
Err(err) => { | ||
return response::Query { | ||
code: Code::Err(AbciErrorCode::INTERNAL_ERROR.value()), | ||
info: "failed converting `u64` block height to type `tendermint::block::Height`" | ||
.into(), | ||
log: format!("{err:?}"), | ||
..response::Query::default() | ||
}; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need to provide this or if we can just use height 0 or 1 (the default).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty non-opinionated on this, but I lean slightly the opposite way just because of the fact that if the height is a part of the message, we should be providing the accurate height for which the response was for, even if unnecessary or unrelated. This might be the wrong mindset, though, so happy to change if you think we should
Co-authored-by: Fraser Hutchison <[email protected]>
After offline discussion, the decision was made to close this in favor of a timeout approach in #2048. This is because we firstly want to move towards gRPC instead of ABCI queries, and secondly since this approach will pretty much only return correct transaction statuses when querying a validator node. |
Summary
Added a transaction status ABCI query to the sequencer and changed the Sequencer Client to poll that instead of CometBFT's
tx
RPC.Background
The Sequencer Client's method
wait_for_tx_inclusion
previously polled CometBFT'stx
endpoint, which would return an error no matter whether the transaction was pending, failed, or never submitted in the first place. Because of this lack of distinction, the method would poll indefinitely if a transaction failed for some reason. This is similar to the issue mentioned in #1936.Changes
MempoolInner
, removing theArc<RwLock<>>
around the different caches.Mempool
to be a wrapper forArc<RwLock<MempoolInner>>
so that we don't end up with lock-step issues where, for instance, a transaction status call might fail in between when the transaction is removed fromPending
and placed inRemovalCache
.get_transaction_status
method to mempool, returning eitherPending
,Parked
,RemovalCache
, orUnknown
.TransactionStatus
andTransactionStatusResponse
.wait_for_tx_inclusion
toconfirm_tx_inclusion
, and changed the logic to continue looping after receiving aPending
orParked
response. IfUnknown
, it will poll untilMAX_WAIT_TIME_UNKNOWN
has elapsed, and will then return an error. If it receivesRemovalCache
, it will try CometBFT'stx
RPC for a short time before erroring if there is no response.Testing
get_transaction_status
method.confirm_tx_inclusion
method.Changelogs
Changelod updated
Breaking Changelist
Related Issues
closes #1949