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

Fix for initialization and finalization sections #1657

Merged

Conversation

lorenzogentile404
Copy link
Collaborator

@lorenzogentile404 lorenzogentile404 commented Dec 13, 2024

@lorenzogentile404 lorenzogentile404 linked an issue Dec 13, 2024 that may be closed by this pull request
this.addFragments(
ImcFragment.forTxInit(hub), ContextFragment.initializeExecutionContext(hub), txFragment);

boolean isRevertedTransaction = false; // TODO: how to get this?
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have to defer to post transaction to finish the initialization section.

@Getter private final AccountSnapshot senderAfterPayingForTransaction;
@Getter private final AccountSnapshot senderAfterPayingForGas;
@Getter private final AccountSnapshot senderAfterPayingForValue;
@Getter private final AccountSnapshot senderAfterPayingForGasAndValue;
Copy link
Collaborator

@OlivierBBB OlivierBBB Dec 14, 2024

Choose a reason for hiding this comment

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

I would suggest, for the sheer purpose of readability, to have the following snapshots be part of the class definition

private final AccountSnapshot senderGasPayment
private final AccountSnapshot senderGasPaymentNew
private final AccountSnapshot senderValueTransfer
private final AccountSnapshot senderValueTransferNew
private final AccountSnapshot recipientValueReception
private final AccountSnapshot recipientValueReceptionNew
private AccountSnapshot senderUndoingValueTransfer
private AccountSnapshot senderUndoingValueTransferNew
private AccountSnapshot recipientUndoingValueReception
private AccountSnapshot recipientUndoingValueReceptionNew

I've started explicitly introducing all required AccountSnapshot's as it became unmanageable otherwise in other sections (CallSection or CreateSection for instance.) As we handle a couple of hundred transactions total at a time max this isn't too much of an imposition on memory etc. And it makes intent more clear.

Copy link
Collaborator Author

@lorenzogentile404 lorenzogentile404 Dec 15, 2024

Choose a reason for hiding this comment

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

Do we actually need all of them? senderGasPaymentNew and senderValueTransfer should be the same. Also, I find clearer the notation "before" and "after". Anyway, let's discuss it tomorrow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, senderValueTransferNew and senderUndoingValueTransfer, recipientValueReceptionNew and recipientUndoingValueReception should be the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: whenever variables represent the same thing, create a deep copy of the underlying objects.

@@ -37,7 +37,9 @@

public class TxInitializationSection extends TraceSection {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has to implements PostTransactionDefer or whatever it's called.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For this it would be ideal if we could get access to the refunded gas from Besu directly. I'm not sure we have it available here, or how, but we would need the values that are available here https://github.com/hyperledger/besu/blob/98780efd15ee3223de2c0cf2d144c8aaee30d5db/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java#L502

Copy link
Collaborator

Choose a reason for hiding this comment

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

The outermost frame should give you the refunds I believe, would need to double check it. It also gives you the selfDestructs and you can infer the maths as in the class you posted there.
I don't think you care about code delegation since you are on the London fork

@OlivierBBB
Copy link
Collaborator

For ignored tests of commit 76bbf00 see #1578

@OlivierBBB OlivierBBB changed the title 1648 initialization and finalization sections fix Fix for initialization and finalization sections Jan 7, 2025
Copy link

cla-assistant bot commented Jan 7, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

cla-assistant bot commented Jan 7, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ lorenzogentile404
❌ OlivierBBB
You have signed the CLA already but the status is still pending? Let us recheck it.

OlivierBBB and others added 20 commits January 7, 2025 21:19
This boolean records the warmth of the coinbase address at transaction
end. The old way of doing things didn't work with

  BlockchainReferenceTest_331/randomStatetest643

where sender == coinbase. And likely this would have blown up in general
with consistency constraints on.
We now extract the coinbase address from a MessageFrame. This ought to
fix an issue with replay tests with a TX_SKIP type of transaction.
Indeed, for some reason (maybe related to using clique and this changing
the "miner" field of the block header) running

  block.getCoinbaseAddress()

or so returned 0x00 rather than the expected 0x8f8.

Also greatly simplified this TraceSection.
also moving address comparison methods
  from TransactionProcessingMetadata
  to TxSkipSection
This updates the self-hosted runner instance for the
`go-corset-replay-tests` job from `large` to `xxl`.  This seems
necessary as the large instance appears to be running out of memory.
This also updates the self-hosted runner instance from large to xxl for
the `corset-unit-tests`, `go-corset-unit-tests` and the
`corset-replay-tests` jobs.  Specifically, the unit tests are taking a
fair amount of time, so this seems sensible.
@OlivierBBB OlivierBBB self-requested a review January 10, 2025 13:16
@OlivierBBB OlivierBBB merged commit 0c942f1 into arith-dev Jan 10, 2025
7 of 8 checks passed
@OlivierBBB OlivierBBB deleted the 1648-initialization-and-finalization-sections-fix branch January 10, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialization and finalization sections fix
4 participants