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

Feature/geth like system tx #7252

Merged
merged 30 commits into from
Sep 9, 2024
Merged

Conversation

LukaszRozmej
Copy link
Member

Changes

  • Decouples system transaction from normal transaction processing
  • Makes system transaction support Aura and non-Aura versions
  • Moves BeaconBlockRootHandler to use system transactions

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Sync some Aura chains in archive.

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

/// Hacky flag to execution options, to pass information how original validate should behave.
/// Needed to decide if we need to subtract transaction value.
/// </summary>
private const int OriginalValidate = 2 << 30;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it needed? I don't understand the idea

Copy link
Contributor

Choose a reason for hiding this comment

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

in what conditions value should be subtract in system calls?

Copy link
Member Author

Choose a reason for hiding this comment

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

estimateGas

// If sender is SystemUser subtracting value will cause InsufficientBalanceException
if (validate || !tx.IsSystem())
WorldState.SubtractFromBalance(tx.SenderAddress, tx.Value, spec);
PayValue(tx, spec, opts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check NoValidation options in PayValue in SystemTransactionProcessor instead of OriginalValidate?

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, as we force NoValidation

Comment on lines -459 to -462
// Fixes eth_estimateGas.
// If sender is SystemUser subtracting value will cause InsufficientBalanceException
if (validate || !tx.IsSystem())
WorldState.SubtractFromBalance(tx.SenderAddress, tx.Value, spec);
Copy link
Member Author

Choose a reason for hiding this comment

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

OriginalValidate was introduced due to this condition. For every other condition validation off is equivalent with transaction being system transaction, but for this one condition we need to decouple this logic, and even if it is system transaction validation can be on/off independently, this is used in eth_estimateGas

Copy link
Contributor

@MarekM25 MarekM25 Aug 15, 2024

Choose a reason for hiding this comment

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

Ok, thanks. I understand the logic. On the other hand, this logic assumes that there are sysCalls that pay values. Based on my quick check, that’s not the case. In sysCalls, we set Value = 0. This means we could simplify the original check and remove that hacky edge case flag.

So original logic could be:
if (validate && !tx.IsSystem())
then we don't need the OriginalValidate at all

/// Hacky flag to execution options, to pass information how original validate should behave.
/// Needed to decide if we need to subtract transaction value.
/// </summary>
private const int OriginalValidate = 2 << 30;
Copy link
Member Author

Choose a reason for hiding this comment

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

estimateGas

// If sender is SystemUser subtracting value will cause InsufficientBalanceException
if (validate || !tx.IsSystem())
WorldState.SubtractFromBalance(tx.SenderAddress, tx.Value, spec);
PayValue(tx, spec, opts);
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, as we force NoValidation

@MarekM25
Copy link
Contributor

@kamilchodola this PR will need a special attention from QA team (pls don't start now, wait for green-light). We will have to test AuRa sys calls.

Recommended things:

  • resync our gnosis archive
  • sync Energyweb/volta archive/non-archive
  • sync Chiado
  • perhaps, update validators (but could be done with normal cycle)

If we have any working Posdao tests than we could use it, but I guess it's not possible

@benaadams
Copy link
Member

Aura failure looks legit (after a number of reruns)

Failed priority_should_return_correctly [77 ms]
Error Message:
Expected root to be a collection with 3 item(s), but {[email protected], [email protected]}
contains 1 item(s) less than
{[email protected], [email protected], [email protected]}.

@LukaszRozmej LukaszRozmej changed the base branch from master to fix/overridable-release-spe-eip158 August 21, 2024 13:02
@LukaszRozmej LukaszRozmej marked this pull request as ready for review August 21, 2024 13:02
@LukaszRozmej LukaszRozmej changed the base branch from fix/overridable-release-spe-eip158 to master August 22, 2024 00:31
@MarekM25 MarekM25 self-requested a review August 22, 2024 09:07
Copy link
Contributor

@tanishqjasoria tanishqjasoria left a comment

Choose a reason for hiding this comment

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

I still do not understand the use of OriginalValidate, is it supposed to be for a case in future where we transfer value in SystemTransaction? because AFAIK we dont do that right now?

@LukaszRozmej LukaszRozmej merged commit 268625b into master Sep 9, 2024
66 checks passed
@LukaszRozmej LukaszRozmej deleted the feature/geth-like-system-tx branch September 9, 2024 09:53
rjnrohit pushed a commit that referenced this pull request Sep 12, 2024
Co-authored-by: MarekM25 <[email protected]>
Co-authored-by: Ahmad Bitar <[email protected]>
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.

6 participants