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

statetest: Reuse Transaction loading in TestMultiTransaction #556

Merged
merged 4 commits into from
Feb 14, 2023
Merged

Conversation

chfast
Copy link
Member

@chfast chfast commented Feb 8, 2023

No description provided.

@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov Report

Merging #556 (8749c51) into master (676027e) will increase coverage by 0.37%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #556      +/-   ##
==========================================
+ Coverage   97.03%   97.41%   +0.37%     
==========================================
  Files          66       67       +1     
  Lines        6138     6183      +45     
==========================================
+ Hits         5956     6023      +67     
+ Misses        182      160      -22     
Flag Coverage Δ
blockchaintests 76.96% <ø> (ø)
statetests 71.79% <47.61%> (+0.34%) ⬆️
unittests 93.33% <100.00%> (+0.55%) ⬆️

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

Impacted Files Coverage Δ
test/statetest/statetest_loader.cpp 78.10% <100.00%> (+12.40%) ⬆️
test/unittests/statetest_loader_tx_test.cpp 100.00% <100.00%> (ø)

@chfast chfast marked this pull request as draft February 11, 2023 11:19
@chfast chfast marked this pull request as ready for review February 11, 2023 17:58
EXPECT_EQ(tx.sender, 0xa0a1_address);
EXPECT_FALSE(tx.to.has_value());
EXPECT_EQ(tx.max_gas_price, 0x7071);
EXPECT_EQ(tx.max_priority_gas_price, 0x7071);
Copy link
Member

Choose a reason for hiding this comment

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

Hm, are these correct? Are they both set to gasPrice? I thought the logic is more complex.

Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out you can you EIP-1559 logic this way also for legacy transactions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the logic is as simple as that in https://eips.ethereum.org/EIPS/eip-1559:

	def normalize_transaction(self, transaction: Transaction, signer_address: int) -> NormalizedTransaction:
		# legacy transactions
		if isinstance(transaction, TransactionLegacy):
			return NormalizedTransaction(
				signer_address = signer_address,
				signer_nonce = transaction.signer_nonce,
				gas_limit = transaction.gas_limit,
				max_priority_fee_per_gas = transaction.gas_price,
				max_fee_per_gas = transaction.gas_price,
				destination = transaction.destination,
				amount = transaction.amount,
				payload = transaction.payload,
				access_list = [],
			)

]
})";

const auto tx = test::from_json<state::Transaction>(json::json::parse(input));
Copy link
Member

Choose a reason for hiding this comment

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

Technically could add the checks for each of the zero values.

Copy link
Member

Choose a reason for hiding this comment

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

Extended tests.


using namespace evmone;

TEST(statetest_loader, tx_create_legacy)
Copy link
Member

Choose a reason for hiding this comment

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

Should probably add a test where both gasPrice and maxFeePerGas is present.

Copy link
Member Author

Choose a reason for hiding this comment

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

What should happen then?

Copy link
Member

Choose a reason for hiding this comment

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

Just fail, pushed my version.

@axic axic requested a review from rodiazet February 13, 2023 20:49
@axic
Copy link
Member

axic commented Feb 13, 2023

I'll squash some commits, once these changes are accepted.

EXPECT_EQ(analysis.instrs[2].fn, op_tbl[OP_DUP1].fn);
EXPECT_EQ(analysis.instrs[8].fn, op_tbl[OP_POP].fn);
EXPECT_EQ(analysis.instrs[18].fn, op_tbl[OP_PUSH1].fn);
EXPECT_EQ(analysis.instrs[1].fn, op_tbl[evmone::OP_DUP2].fn);
Copy link
Member

Choose a reason for hiding this comment

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

Need to remove all these changes, needed locally in order to compile and managed to commit in.

@gumb0
Copy link
Member

gumb0 commented Feb 14, 2023

Looks good to me, need to remove all evmone:: additions

@axic axic force-pushed the tx_json branch 3 times, most recently from 82d64ba to 18b83a3 Compare February 14, 2023 17:04
o.max_priority_gas_price = o.max_gas_price;
if (j.contains("maxFeePerGas") || j.contains("maxPriorityFeePerGas"))
throw std::invalid_argument(
Copy link
Member

Choose a reason for hiding this comment

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

This could be in braces {}, because multi-line.

Copy link
Member

Choose a reason for hiding this comment

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

Changed.

@axic axic merged commit 95a34db into master Feb 14, 2023
@axic axic deleted the tx_json branch February 14, 2023 17:15
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.

4 participants