Skip to content

Commit 211bbc9

Browse files
AlexRamRamHalosGhost
authored andcommitted
Fix eth_getTransactionCount behavior for unknown acccounts
Return starting account nonce for unknown accounts instead of error Signed-off-by: Alexander Jung <[email protected]>
1 parent 8628691 commit 211bbc9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/parsec/agent/runners/evm/http_server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ namespace cbdc::parsec::agent::rpc {
384384
auto& updates = std::get<return_type>(res);
385385
auto it = updates.find(runner_params);
386386

387-
if(it == updates.end()) {
387+
if(it == updates.end() || it->second.size() == 0) {
388388
// For accounts that don't exist yet, return 1
389389
ret["result"] = to_hex_trimmed(evmc::uint256be(1));
390390
callback(ret);

tests/integration/parsec_evm_end_to_end_test.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,15 @@ TEST_F(parsec_evm_end_to_end_test, erc20_all) {
697697
m_acct1_privkey,
698698
evmc::uint256be{});
699699
}
700+
701+
TEST_F(parsec_evm_end_to_end_test, test_new_account_transaction_count) {
702+
// Do not re-use this test address within this module:
703+
const evmc::address new_test_addr{0xff0000};
704+
const auto new_acct_nonce
705+
= m_rpc_client->get_transaction_count(new_test_addr);
706+
707+
// This value to be updated if/when the system default nonce changes to 0:
708+
const auto parsec_default_acct_nonce = evmc::uint256be(1);
709+
710+
ASSERT_EQ(new_acct_nonce, parsec_default_acct_nonce);
711+
}

0 commit comments

Comments
 (0)