From f5600147e5b4720bd553f1e0ca091c22d127317f Mon Sep 17 00:00:00 2001 From: Tyler <48813565+technicallyty@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:35:24 -0700 Subject: [PATCH] fix: use unix nano in mempool for unordered nonces (#24579) --- types/mempool/priority_nonce.go | 4 ++-- types/mempool/sender_nonce.go | 4 ++-- types/tx_msg.go | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/mempool/priority_nonce.go b/types/mempool/priority_nonce.go index 4d0735cfd8..abecfb1432 100644 --- a/types/mempool/priority_nonce.go +++ b/types/mempool/priority_nonce.go @@ -226,7 +226,7 @@ func (mp *PriorityNonceMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error // if it's an unordered tx, we use the timeout timestamp instead of the nonce if unordered, ok := tx.(sdk.TxWithUnordered); ok && unordered.GetUnordered() { - timestamp := unordered.GetTimeoutTimeStamp().Unix() + timestamp := unordered.GetTimeoutTimeStamp().UnixNano() if timestamp < 0 { return errors.New("invalid timestamp value") } @@ -471,7 +471,7 @@ func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { // if it's an unordered tx, we use the timeout timestamp instead of the nonce if unordered, ok := tx.(sdk.TxWithUnordered); ok && unordered.GetUnordered() { - timestamp := unordered.GetTimeoutTimeStamp().Unix() + timestamp := unordered.GetTimeoutTimeStamp().UnixNano() if timestamp < 0 { return errors.New("invalid timestamp value") } diff --git a/types/mempool/sender_nonce.go b/types/mempool/sender_nonce.go index 4d4d33e545..2623fefd95 100644 --- a/types/mempool/sender_nonce.go +++ b/types/mempool/sender_nonce.go @@ -143,7 +143,7 @@ func (snm *SenderNonceMempool) Insert(_ context.Context, tx sdk.Tx) error { // if it's an unordered tx, we use the timeout timestamp instead of the nonce if unordered, ok := tx.(sdk.TxWithUnordered); ok && unordered.GetUnordered() { - timestamp := unordered.GetTimeoutTimeStamp().Unix() + timestamp := unordered.GetTimeoutTimeStamp().UnixNano() if timestamp < 0 { return errors.New("invalid timestamp value") } @@ -240,7 +240,7 @@ func (snm *SenderNonceMempool) Remove(tx sdk.Tx) error { // if it's an unordered tx, we use the timeout timestamp instead of the nonce if unordered, ok := tx.(sdk.TxWithUnordered); ok && unordered.GetUnordered() { - timestamp := unordered.GetTimeoutTimeStamp().Unix() + timestamp := unordered.GetTimeoutTimeStamp().UnixNano() if timestamp < 0 { return errors.New("invalid timestamp value") } diff --git a/types/tx_msg.go b/types/tx_msg.go index 6e014f8265..965554bee0 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -77,6 +77,8 @@ type ( TxWithTimeoutTimeStamp interface { Tx + // GetTimeoutTimeStamp gets the timeout timestamp for the tx. + // IMPORTANT: when the uint value is needed here, you MUST use UnixNano. GetTimeoutTimeStamp() time.Time }