Reusing the same nonce twice after contract deployment
bryanwee023 opened this issue ยท 2 comments
bryanwee023 commented
๐ Bug Report for hardhat-zksync plugins
๐ฅ Plugin name
hardhat-zksync-node
๐ Description
After deploying a contract, subsequent transactions return "Reusing the same nonce twice"
.
๐ Reproduction Steps
- Set up a zksync Hardhat project with a minimal contract.
//SPDX-License-Identifier: MIT pragma solidity ^0.8.19; contract Counter { uint256 public count; function increment() public { count++; } }
- Add a test into the
test/
folder.describe("Nonce Reuse", function() { it("Should increment twice", async function() { const provider = new Provider("http://127.0.0.1:8011"); const user = new Wallet("0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3", provider); const counter = await deployContract( "Counter", [], { wallet: user, silent: true } ); await counter.waitForDeployment(); let tx = await counter.connect(user).increment(); await tx.wait(); }); });
- Run the test with
npm run test
๐ค Expected Behavior
The counter contract should be deployed and then incremented once.
๐ฏ Current Behavior
The counter contract is deployed, but when user
tries to increment the contract, an error is returned: Account validation error: Reusing the same nonce twice"
.
๐ฅ๏ธ Environment
- Node version: Node 20.3.1
- Operating System & Version: macOS, 13.2, M1 Pro
- Node dependencies:
"devDependencies": { "@matterlabs/hardhat-zksync-deploy": "^1.1.2", "@matterlabs/hardhat-zksync-node": "^1.0.1", "@matterlabs/hardhat-zksync-solc": "^1.0.6", "@matterlabs/zksync-contracts": "^0.6.1", "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", "chai": "^4.3.7", "ethers": "^6.9.2", "hardhat": "^2.12.4", "mocha": "^10.2.0", "ts-node": "^10.9.2", "typescript": "^4.9.5", "zksync-ethers": "^6.0.0" }
๐ Additional Context
Consecutive transactions work. This error seems to happen only after the account deploys a contract.
๐ Log Output
1) Transfer Ether
Should increment twice:
Error: could not coalesce error (error={ "code": 3, "data": "0x9f39af0917c1cddd2b50e4b6494b7d656f70364eee633388b70df4a7f9f38107", "message": "Execution error: Transaction HALT: Account validation error: Reusing the same nonce twice" }, payload={ "id": 33, "jsonrpc": "2.0", "method": "eth_sendRawTransaction", "params": [ "0xf86a80840ee6b280830a21cd948b6e8186de74fe0128c0a6a3b2733c1365f4c9e28084d09de08a82022ba0ba6e72db1f1f281f3d3e38d14c203180c88aa6aa3f626901fca698aedb82a572a079f094e45cee3a5bf92ef7a43dcce1e06249d26b2f43c65fb4e501d4f50a333d" ] }, code=UNKNOWN_ERROR, version=6.10.0)
nikola-bozin-txfusion commented
Hi @bryanwee023, this is related to this issue with the era-test-node. We will let you know when this is resolved.
uF4No commented
Just for visibility, see the workaround for this issue