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

drop transactions who's nonce is lower then the known network nonce but were not included in a block #6388

Merged
merged 8 commits into from
May 16, 2019

Conversation

frankiebee
Copy link
Contributor

@frankiebee frankiebee commented Apr 2, 2019

fixes #5031

@frankiebee frankiebee added the DO-NOT-MERGE Pull requests that should not be merged label Apr 2, 2019
@frankiebee
Copy link
Contributor Author

frankiebee commented Apr 2, 2019

the do not merge label will get removed by EOD

@metamaskbot
Copy link
Collaborator

Builds ready [173b9bc]: chrome, firefox, edge, opera

@frankiebee frankiebee removed the DO-NOT-MERGE Pull requests that should not be merged label Apr 2, 2019
@frankiebee
Copy link
Contributor Author

would like qa for this

app/scripts/controllers/transactions/pending-tx-tracker.js Outdated Show resolved Hide resolved
const nonceTakenErr = new Error('Another transaction with this nonce has been mined.')
nonceTakenErr.name = 'NonceTakenErr'
return this.emit('tx:failed', txId, nonceTakenErr)
return this.emit('tx:dropped', txId)
Copy link
Contributor

Choose a reason for hiding this comment

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

emitting "dropped" here and _checkIftxWasDropped,
suggest to move all of that logic into one function or break the nonceIsTaken into a different status?

app/scripts/controllers/transactions/index.js Outdated Show resolved Hide resolved
@@ -542,6 +542,15 @@ class TransactionController extends EventEmitter {
})
this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
this.pendingTxTracker.on('tx:confirmed', (txId) => this.confirmTransaction(txId))
this.pendingTxTracker.on('tx:dropped', (txId) => {
const txMeta = this.txStateManager.getTx(txId)
if (!txMeta.dropBlockBuffer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this get set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the line bellow

Copy link
Contributor

Choose a reason for hiding this comment

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

i meant what is the case in which this code path is not always true?
i'm confused on the flow, it seems:
on tx:dropped, update the txMeta with a tx:drop-update
then on another dropped event for the same tx, we setTxStatusDropped?

are we expecting multiple dropped events for the same tx?

@metamaskbot
Copy link
Collaborator

Builds ready [c271857]: chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [bfd2d2c]: chrome, firefox, edge, opera

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

A few small comments

app/scripts/controllers/transactions/pending-tx-tracker.js Outdated Show resolved Hide resolved
test/unit/app/controllers/transactions/pending-tx-test.js Outdated Show resolved Hide resolved
})

pendingTxTracker._checkPendingTx(txMeta).then(() => {
pendingTxTracker._checkPendingTx(txMeta).catch(done)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we ignoring the returned promise? Should we be returning it to the chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test: should emit tx:dropped with the txMetas id only after the second call

so we are testing the emit's logic here

@whymarrh whymarrh requested a review from tmashuang April 11, 2019 01:31
@whymarrh
Copy link
Contributor

would like qa for this

@tmashuang do you know of a way to easily induce dropped txs?

@bdresser
Copy link
Contributor

@tmashuang any ideas on how we can qa this?

@tmashuang
Copy link
Contributor

Wouldn't reproduction just be sending two transactions with the same nonce? Probably sending a transaction on two computers with the same account? Currently, we do the nonce check on the Confirm Transaction Screen, and shows an error if there is. Now, we are able to send the transaction at the same time to race. Is that the goal?

whymarrh and others added 2 commits April 25, 2019 16:10
Co-Authored-By: frankiebee <frankie.diamond@gmail.com>
@metamaskbot
Copy link
Collaborator

Builds ready [14a8992]: chrome, firefox, edge, opera

@metamaskbot
Copy link
Collaborator

Builds ready [11aae3c]: chrome, firefox, edge, opera

@bdresser bdresser added this to the Backend Sprint 11 [April 29] milestone Apr 29, 2019
@tmashuang
Copy link
Contributor

@whymarrh is the changes sufficient enough, is this good to go?

@bdresser bdresser requested a review from whymarrh May 6, 2019 17:14
Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

Two small comments but otherwise LGTM

},
rawTx: '0xf86c808504a817c800827b0d940c62bb85faa3311a998d3aba8098c1235c564966880de0b6b3a7640000802aa08ff665feb887a25d4099e40e11f0fef93ee9608f404bd3f853dd9e84ed3317a6a02ec9d3d1d6e176d4d2593dd760e74ccac753e6a0ea0d00cc9789d0d7ff1f471d',
}
it('should return false', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update this test title to include the condition when it returns false, e.g.,

should return false when ...

}).catch(done)
})

it('should return true', function (done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update this test title to include the condition when it returns true, e.g.,

should return true when ...

@metamaskbot
Copy link
Collaborator

Builds ready [0f05011]: chrome, firefox, edge, opera

@tmashuang tmashuang requested a review from whymarrh May 14, 2019 19:36
@frankiebee frankiebee merged commit a341039 into develop May 16, 2019
@frankiebee frankiebee deleted the i#5031 branch May 16, 2019 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if known nonce is higher than pending tx
6 participants