Skip to content

Conversation

@rodiazet
Copy link
Member

@rodiazet rodiazet commented Aug 9, 2023

No description provided.

@rodiazet rodiazet requested review from chfast and gumb0 August 9, 2023 14:22
Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

All of this looks to be done in a wrong place. We should check it in validate_transaction() where we inspect sender's nonce already.

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #685 (39419a7) into master (1d0c994) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #685      +/-   ##
==========================================
+ Coverage   97.48%   97.52%   +0.04%     
==========================================
  Files          85       86       +1     
  Lines        8182     8208      +26     
==========================================
+ Hits         7976     8005      +29     
+ Misses        206      203       -3     
Flag Coverage Δ
blockchaintests 62.71% <ø> (ø)
statetests 74.12% <66.66%> (-0.10%) ⬇️
statetests-silkpre 23.23% <34.78%> (-0.02%) ⬇️
unittests 95.11% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
test/state/state.hpp 100.00% <ø> (ø)
test/unittests/state_transition.hpp 0.00% <ø> (ø)
test/state/errors.hpp 30.55% <100.00%> (+18.05%) ⬆️
test/state/state.cpp 98.59% <100.00%> (+0.04%) ⬆️
test/statetest/statetest_loader.cpp 90.17% <100.00%> (+0.04%) ⬆️
test/unittests/state_tx_test.cpp 100.00% <100.00%> (ø)
test/unittests/statetest_loader_test.cpp 100.00% <100.00%> (ø)

@rodiazet rodiazet changed the title Blockchain tests fixing: Add nonce value verification Blockchain tests support: Add nonce value verification Aug 17, 2023
Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

Why are many state tests failing?

@rodiazet
Copy link
Member Author

rodiazet commented Aug 17, 2023

Why are many state tests failing?

Because tx which is built by statetest_runner has nonce == 0 when the sender nonce == 1. It's because we have a bug in static void from_json(const json::json& j, TestMultiTransaction& o) . It does not read nonce from json test file.

Fixed with additional commit.

{
o.sender = from_json<evmc::address>(j.at("sender"));

if (const auto nonce_it = j.find("nonce"); nonce_it != j.end())
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the nonce always expected there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Our load_minimal_test test does not define nonce. So we can add that it's mandatory or we load it only when it's defined.

Copy link
Member

Choose a reason for hiding this comment

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

Should be mandatory

@rodiazet rodiazet force-pushed the verify-nonce branch 2 times, most recently from 6eaedc2 to 601416c Compare August 17, 2023 15:46

using namespace evmone::state;

TEST(transaction, validate_transaction)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
TEST(transaction, validate_transaction)
TEST(state_tx, validate_nonce)

Also change file name to state_tx_test.cpp


{
const auto res = validate_transaction(acc, bi, tx, EVMC_BERLIN);
ASSERT_TRUE(holds_alternative<int64_t>(res)) << std::get<std::error_code>(res).message();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ASSERT_TRUE(holds_alternative<int64_t>(res)) << std::get<std::error_code>(res).message();
EXPECT_FALSE(holds_alternative<std::error_code>(res)) << std::get<std::error_code>(res).message();

{
const auto res = validate_transaction(acc, bi, tx, EVMC_BERLIN);
ASSERT_TRUE(holds_alternative<std::error_code>(res))
<< make_error_code(ErrorCode::NONCE_TOO_LOW).message();
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this additional message?

Copy link
Member Author

Choose a reason for hiding this comment

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

No we don't. I will add also checking the error code returned.

@rodiazet rodiazet force-pushed the verify-nonce branch 16 times, most recently from 7c5d040 to 32c1434 Compare August 18, 2023 10:56
@rodiazet rodiazet requested a review from chfast August 18, 2023 11:08

const BlockInfo bi{.gas_limit = 0x989680,
.coinbase = 0x01_address,
.prev_randao = {},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.prev_randao = {},

I think you can skip default initialized fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

No I cannot. CI complains during build.

@rodiazet rodiazet merged commit 7cef356 into master Aug 18, 2023
@rodiazet rodiazet deleted the verify-nonce branch August 18, 2023 11:43
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.

3 participants