Bug #1384: Deadlock with pending older transactions (#1455)

* don't use nonce in tx reducer

* remove displaying of pending status if tx has no confirmations

* Fix test for transactions pending status

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
Mikhail Mikheev 2020-10-16 15:23:07 +04:00 committed by GitHub
parent b04ec4337b
commit 396f6dd99b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 17 deletions

View File

@ -572,18 +572,6 @@ describe('calculateTransactionStatus', () => {
// then
expect(result).toBe(TransactionStatus.PENDING)
})
it('It should return PENDING if the tx has no confirmations', () => {
// given
const transaction = makeTransaction({ confirmations: List(), isPending: false })
const safe = makeSafe({ threshold: 3 })
const currentUser = safeAddress
// when
const result = calculateTransactionStatus(transaction, safe, currentUser)
// then
expect(result).toBe(TransactionStatus.PENDING)
})
it('It should return AWAITING_CONFIRMATIONS if the tx has confirmations bellow the threshold, the user is owner and signed', () => {
// given
const userAddress = 'address1'

View File

@ -175,20 +175,20 @@ export const isTransactionCancelled = (
export const calculateTransactionStatus = (
tx: Transaction,
{ owners, threshold }: SafeRecord,
{ owners, threshold, nonce }: SafeRecord,
currentUser?: string | null,
): TransactionStatusValues => {
let txStatus
if (tx.isExecuted && tx.isSuccessful) {
txStatus = TransactionStatus.SUCCESS
} else if (tx.cancelled) {
} else if (tx.cancelled || nonce > tx.nonce) {
txStatus = TransactionStatus.CANCELLED
} else if (tx.confirmations.size === threshold) {
txStatus = TransactionStatus.AWAITING_EXECUTION
} else if (tx.creationTx) {
txStatus = TransactionStatus.SUCCESS
} else if (!tx.confirmations.size || !!tx.isPending) {
} else if (!!tx.isPending) {
txStatus = TransactionStatus.PENDING
} else {
const userConfirmed = tx.confirmations.filter((conf) => conf.owner === currentUser).size === 1

View File

@ -31,6 +31,7 @@ export const makeTransaction = Record<TransactionProps>({
isCancellationTx: false,
isCollectibleTransfer: false,
isExecuted: false,
isPending: false,
isSuccessful: true,
isTokenTransfer: false,
masterCopy: '',

View File

@ -21,7 +21,7 @@ export default handleActions(
if (stateTransactionsList) {
const txsToStore = stateTransactionsList.withMutations((txsList) => {
transactions.forEach((updateTx) => {
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.nonce === updateTx.nonce)
const storedTxIndex = txsList.findIndex((txIterator) => txIterator.safeTxHash === updateTx.safeTxHash)
if (storedTxIndex !== -1) {
// Update

View File

@ -114,7 +114,6 @@ const OwnersColumn = ({
}: ownersColumnProps): React.ReactElement => {
const classes = useStyles()
let showOlderTxAnnotation
if (tx.isExecuted || cancelTx.isExecuted) {
showOlderTxAnnotation = false
} else {