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

Blockchain tests support: Fix tx receipt rlp encoding #680

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

rodiazet
Copy link
Collaborator

@rodiazet rodiazet commented Aug 9, 2023

  • Encode cumulative_gas_used instead of gas_used
  • Support tx receipt format for pre Byzantium

@rodiazet rodiazet requested review from chfast and gumb0 August 9, 2023 13:26
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #680 (70f083f) into master (4b2db8b) will decrease coverage by 0.01%.
The diff coverage is 96.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
- Coverage   97.54%   97.53%   -0.01%     
==========================================
  Files          86       86              
  Lines        8215     8236      +21     
==========================================
+ Hits         8013     8033      +20     
- Misses        202      203       +1     
Flag Coverage Δ
blockchaintests 62.71% <ø> (ø)
statetests 73.94% <10.00%> (-0.17%) ⬇️
statetests-silkpre 23.18% <4.16%> (-0.06%) ⬇️
unittests 95.12% <96.55%> (+<0.01%) ⬆️

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/state/state.cpp 97.95% <90.90%> (-0.64%) ⬇️
test/unittests/state_mpt_hash_test.cpp 99.04% <100.00%> (+0.17%) ⬆️

@rodiazet rodiazet changed the title Blockchain tests fixing: Fix tx receipt rlp encoding Blockchain tests support: Fix tx receipt rlp encoding Aug 17, 2023
@rodiazet rodiazet force-pushed the fix-tx-receipt-rlp-encoding branch 2 times, most recently from 1e4836f to 6483ab1 Compare August 18, 2023 12:33
test/state/state.cpp Show resolved Hide resolved
test/state/state.cpp Outdated Show resolved Hide resolved
test/state/state.hpp Show resolved Hide resolved
// Block taken from Ethereum mainnet
// https://etherscan.io/txs?block=4276370

TransactionReceipt receipt0{};
Copy link
Member

Choose a reason for hiding this comment

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

I think you can use designated initializers: receipt0{.type=...}.

test/state/state.cpp Show resolved Hide resolved
test/state/state.cpp Show resolved Hide resolved
test/t8n/t8n.cpp Show resolved Hide resolved
test/t8n/t8n.cpp Show resolved Hide resolved
test/state/state.hpp Show resolved Hide resolved
@rodiazet rodiazet force-pushed the fix-tx-receipt-rlp-encoding branch 4 times, most recently from 3f843bb to 837061d Compare August 21, 2023 08:51
@rodiazet rodiazet requested a review from chfast August 21, 2023 09:01
@@ -212,7 +213,9 @@ std::variant<TransactionReceipt, std::error_code> transition(State& state, const
std::erase_if(state.get_accounts(),
[](const std::pair<const address, Account>& p) noexcept { return p.second.destructed; });

auto receipt = TransactionReceipt{tx.type, result.status_code, gas_used, host.take_logs(), {}};
// Cumulative gas used is unknown in this scope.
auto receipt =
Copy link
Member

Choose a reason for hiding this comment

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

Use simpler syntax.

Suggested change
auto receipt =
TransactionReceipt receipt{...};

test/state/state.cpp Show resolved Hide resolved
test/state/state.hpp Show resolved Hide resolved
test/state/state.hpp Show resolved Hide resolved
std::vector<Log> logs;
BloomFilter logs_bloom_filter;
/// Root hash of the state after this transaction. It's used in old pre-Byzantium 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
/// Root hash of the state after this transaction. It's used in old pre-Byzantium transaction
/// Root hash of the state after this transaction. Used only in old pre-Byzantium transactions.

@@ -138,9 +138,15 @@ struct TransactionReceipt
{
Copy link
Member

Choose a reason for hiding this comment

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

Add documentation of TransactionReceipt.

/// Transaction Receipt
///
/// This struct is used in two contexts:
/// 1. As the formally specified, RLP-encode transaction receipt included in the Ethereum blocks.
/// 2. As the internal representation of the transaction execution result.
/// These both roles share most, but not all the information. There are some fields that cannot be assigned in the single transaction execution context. There are also fields that are not a part of the RLP-encoded transaction receipts.
/// TODO: Consider splitting the struct into two based on the duality explained above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@rodiazet rodiazet force-pushed the fix-tx-receipt-rlp-encoding branch 2 times, most recently from cbc36c8 to 619afad Compare August 21, 2023 16:12
@rodiazet rodiazet force-pushed the fix-tx-receipt-rlp-encoding branch from 619afad to 70f083f Compare August 22, 2023 08:37
@rodiazet rodiazet merged commit 0068ddf into master Aug 22, 2023
@rodiazet rodiazet deleted the fix-tx-receipt-rlp-encoding branch August 22, 2023 08:47
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.

2 participants