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

Initialization section fix #11

Open
10 of 11 tasks
OlivierBBB opened this issue Nov 28, 2024 · 4 comments · May be fixed by #12
Open
10 of 11 tasks

Initialization section fix #11

OlivierBBB opened this issue Nov 28, 2024 · 4 comments · May be fixed by #12
Assignees
Labels
bug Something isn't working

Comments

@OlivierBBB
Copy link
Collaborator

OlivierBBB commented Nov 28, 2024

  • spec fix @OlivierBBB
    • re-architecture initialization section TX_INIT
      • split initial transfer in gas then value
      • add undoing rows
      • capture misc/CCSR / misc/CCRS
    • update finalization section TX_FINL
      • introduce new offset $7 < \varepsilon_{\text{revert}} < {\color{green}\varepsilon_{\text{finl}}} < \varepsilon_{\text{selfdestruct}} < \lambda$ or $\tau$
      • in all cases only repay gas to sender / coinbase at offset ${\color{green}\varepsilon_{\text{finl}}}$
    • introduce new finalizationDomSubStamp shorthands
  • constraints update @OlivierBBB, Implementation of TX_INIT and TX_FINL fix linea-constraints#517
  • tracer update @lorenzogentile404
@OlivierBBB OlivierBBB added the bug Something isn't working label Nov 28, 2024
@OlivierBBB OlivierBBB self-assigned this Nov 28, 2024
@OlivierBBB OlivierBBB linked a pull request Nov 28, 2024 that will close this issue
@lorenzogentile404
Copy link
Contributor

lorenzogentile404 commented Dec 2, 2024

@lorenzogentile404 re-implement initialization and finalization sections. The new implementation is not that different from the new one, so take a look to it especially wrt address collisions (e.g., if an address sends funds to itself).

@OlivierBBB
Copy link
Collaborator Author

OlivierBBB commented Dec 2, 2024

In the initialization section you have 2 cases:

  • sender ≠ recipient
0th account row: sender:
balance = b  // from state
balance_new = b - gasCost

1st account row: sender:
balance = b - gasCost
balance_new = (b - gasCost) - value

2nd account row: recipient:
balance = b'  // from state
balance_new = b' + value
  • sender = recipient
0th account row: sender:
balance = b  // from state
balance_new = b - gasCost

1st account row: sender:
balance = b - gasCost
balance_new = (b - gasCost) - value

2nd account row: sender:
balance = b - value // you don't get from the state
balance_new = ((b - gasCost) - value) + value

You have to schedule the initialization section for transaction end. So that if there is a roll back you can insert the extra 2 account rows below.

Reverted transactions

You then have 2 extra account rows where you decrement the tx.value from the recipient and you increment the balance of the sender by tx.value

3rd account row: sender:
balance = b'' = last valid balance (depending on address collision or not) in the initialization section
balance_new = b'' + value

4th account row: recipient:
balance = b''' = last valid balance (depending on address collision or not) in the initialization section
balance_new = b''' - value
  • sender ≠ recipient
3rd account row: sender:
balance = (b - gasCost) - value
balance_new = ((b - gasCost) - value) + value

4th account row: recipient:
balance = b' + value
balance_new = (b' + value) - value
  • sender = recipient
// "this happens second"
3rd account row: sender:
balance = (b - gasCost) - value
balance_new = ((b - gasCost) - value) + value

// "this happens first"
4th account row: recipient:
balance = b - gasCost
balance_new = (b - gasCost) - value

@OlivierBBB
Copy link
Collaborator Author

In the finalization section you have 2 cases:

  • sender ≠ coinbase
0th account row: sender:
balance = b  // from state, prior to traceEndTransaction (no refunds have taken place)
balance_new = b + gasRefund

1st account row: coinbase:
balance = b'  // from state, prior to traceEndTransaction (no rewards have taken place)
balance_new = b' + gasReward
  • sender = coinbase
0th account row: sender:
balance = b  // from state, prior to traceEndTransaction (no refunds have taken place)
balance_new = b + gasRefund

1st account row: coinbase:
balance = b + gasRefund  // from state, prior to traceEndTransaction (no rewards have taken place)
balance_new = (b + gasRefund) + gasReward

@OlivierBBB
Copy link
Collaborator Author

You have to add finalizationDomSubStamps for the finalization section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants