-
Notifications
You must be signed in to change notification settings - Fork 51
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
session_nonces increment issue #9
Comments
I was able to just override var originalSignFn = keystore.signTransaction.bind(keystore);
keystore.signTransaction = function(txParams, callback) {
web3.eth.getTransactionCount(txParams.from, 'pending', function(err, result) {
txParams.nonce = Web3.prototype.toHex(result);
originalSignFn(txParams, callback);
});
}; |
The problem with always getting the pending transaction count is that you might send multiple transactions in quick succession- the first tx gets signed and sent, but before it's queued the second tx is signed, at which point the pending tx count is the same as before, meaning you send multiple different transactions with the same nonce (which, i've observed, on geth at least, raises no error from sendTransaction, and only one of the transactions actually ends up getting mined, the other completely disappears with no error). Incrementing the nonce anywhere in the signing hook is a problem, because it doesn't take into account the possibility that the node will reject the transaction before queueing it, even if the signing hook has completed successfully (in which case the next transaction must have the same nonce as before, or it'll cause a nonce gap and a jammed account). The only safe way I can see to do this is to:
|
I saw that session_nonce and global nonce for a Sender X was incremented even if you enter a wrong password or if you cancel the transaction. This causes that your next transaction will be always queued.
I MOVED the row:
AFTER (row 169):
and it solves for me.
Look at our version on github for complete file:
https://github.com/inzhoop-co/LETH/blob/master/www/lib/thirdparty/hooked-web3-provider.js
The text was updated successfully, but these errors were encountered: