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

CANCUN: EIP-1153 Transient Storage #916

Merged
merged 8 commits into from
Feb 26, 2025

Conversation

pldespaigne
Copy link
Contributor

@pldespaigne pldespaigne commented Aug 26, 2024

EIP 1153 Transient Storage

This is the first PR aiming to bring the Yellow Paper up to date with Cancun update

This PR translate EIP-1553 into the Yellow Paper.
Here is the PDF version of those changes: Paper.pdf

Definition

We formally define the Transient Storage as θ (symbol not already used in the paper), in section 6. Transaction Execution.

Screenshot

0_after

Updating functions Θ , Λ and Ξ

We updated every occurrence of the Message Call function Θ to incorporate transient storage θ as the second parameter and new resultant transient storage θ as the last returned parameter.

Screenshot

3_after

We updated every occurrence of the Create function Λ to incorporate transient storage θ as the second parameter and new resultant transient storage θ as the last returned parameter.

Screenshot

2_after

We updated every occurrence of the Execution function Ξ to incorporate transient storage θ as the second parameter and new resultant transient storage θ as the last returned parameter.

Screenshot

4_after

STATICCALL Exception

We added T S T O R E to the list of forbidden opocodes during a static execution.

Screenshot

5_after

Gas cost

We added T L O A D and T S T O R E to gas opcode categories.

Screenshot

8_after

We added a new fee tier for that category.

Screenshot

6_after

Finally, we updated the gas cost function C to handle those new opcodes.

Screenshot

7_after

Opcodes Definition

We added T L O A D and T S T O R E to the list of opcodes.

Screenshot

9_after

@pldespaigne
Copy link
Contributor Author

@yperbasis could you create a cancun branch please, so that I can update the target branch of the PR and mark it as ready to review 🙏

@yperbasis
Copy link
Member

@yperbasis could you create a cancun branch please, so that I can update the target branch of the PR and mark it as ready to review 🙏

done

@pldespaigne pldespaigne changed the base branch from master to cancun August 27, 2024 08:03
@pldespaigne pldespaigne marked this pull request as ready for review August 27, 2024 08:03
@pldespaigne
Copy link
Contributor Author

Thanks!
PR is now ready to review!

@alexprut @benjaminion @RenanSouza2 @timbeiko @alexkroeger any feedback on that will be highly appreciated as well 🙏

@RenanSouza2
Copy link
Contributor

Hey, I‘m not sure why I was mentionend but I have two suggestions,

the first one is to simplify the section 6.2 to
'The transient storage (eip1153), fomrally ...‘

the second one is to use Gwarmaccess in the gas formula instead of creating a new category

@pldespaigne
Copy link
Contributor Author

pldespaigne commented Aug 29, 2024

Thanks for your feedback!

  • What needs to be simplified in section 6.2 for you? Would you avoid to formally define the transient storage and simply says that it behave almost as the regular storage, like the EIP-1153 does?

  • I did it this way so it's more future proof if one of those gas category change, but yeah it doesn't look clean, and I think I like it better using only G w a r m a c c e s s .

@RenanSouza2
Copy link
Contributor

I have one more suggestion, to move the definition from section 6 (transaction execution) to section 9 (Execution model),

this could be integrated in 9.1 (basics), or there could be a revamp and expand the explanation of memory, storage,

my previous suggestion was to remove the sentences 'introduced by eip 1153, during the cancun update' and start by 'the transient storage (eip1153)[authors], formally ...'

@pldespaigne
Copy link
Contributor Author

pldespaigne commented Aug 30, 2024

From what I understand, section 9 describe thing relative to a single execution context (such as memory, environment, etc...).

Structures used for the whole transaction (such as accrued sub-state) are defined in section 6.

Since transient storage is created at the beginning of the tx (and destroy at the end) and persist across contexts, I find it more logical to put it in section 6.
Again that's just my opinion, I'm happy to discuss this further and make that update if everybody agrees on it.

Thanks again for the feedbacks!

@RenanSouza2
Copy link
Contributor

makes sense, 6.1 is substate and 6.2 is transient storage

* style: add a missing "be".

* style: add a missing "it is".

* refactor: clearer sentence
Paper.tex Outdated
@@ -780,6 +780,27 @@ \subsection{Substate} \label{ch:substate}
\end{equation}
where $\hyperlink{precompiled_set}{\pi}$ is the set of all precompiled addresses.

\subsection{Transient Storage}
Introduced by EIP-1153 (\cite{EIP-1153}) during the Cancun update, the transient storage, formally $\boldsymbol{\theta}$, is a volatile version of the world state account storage $\boldsymbol{\sigma}[a]_s$.
It's a mapping between addresses (160-bit identifiers) and storage (another mapping between 256-bit integer values).
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe adding: bi-dimentional mapping?

No strong opinions, up to you.

Paper.tex Outdated
@@ -780,6 +780,27 @@ \subsection{Substate} \label{ch:substate}
\end{equation}
where $\hyperlink{precompiled_set}{\pi}$ is the set of all precompiled addresses.

\subsection{Transient Storage}
Introduced by EIP-1153 (\cite{EIP-1153}) during the Cancun update, the transient storage, formally $\boldsymbol{\theta}$, is a volatile version of the world state account storage $\boldsymbol{\sigma}[a]_s$.
It's a mapping between addresses (160-bit identifiers) and storage (another mapping between 256-bit integer values).
Copy link
Contributor

Choose a reason for hiding this comment

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

The definition of an address is already defined in multiple places, such as formula (97), for simplicity maybe the piece (160-bit identifiers) could be removed.

\end{equation}
where:
\begin{equation}
a \in \mathbb{B}_{160} \quad \wedge \quad k \in \mathbb{B}_{32} \quad \wedge \quad v \in \mathbb{N}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, a \in \mathbb{B}_{160} could be moved to formula (97)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to leave it there to make the definition more standalone

stehled and others added 3 commits November 4, 2024 10:50
Co-authored-by: rahul <[email protected]>
@pldespaigne
Copy link
Contributor Author

As suggested by @RenanSouza2 & @alexprut, I've updated the definition paragraph of the Transient storage.

image

@yperbasis Could you have a look when you have some time please, and if everything is ok for you, merge into cancun branch, so that I can start the next EIP 🙏

@pldespaigne
Copy link
Contributor Author

Tagging EIP authors to help review if they want/can 🙏
@AlexeyAkhunov, @moodysalem

@moodysalem
Copy link

moodysalem commented Jan 20, 2025

If mentioning that it's cheaper because it never has to be persisted, I might also add that it's also cheaper because it never has to read from the storage trie either since all slots start at zero. Otherwise, looks good!

@pldespaigne
Copy link
Contributor Author

@yperbasis If everything is fine for you, could you merge to the cancun branch so I can move to the next EIP?

Copy link
Member

@yperbasis yperbasis left a comment

Choose a reason for hiding this comment

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

Please make the following changes:

  1. In some functions theta is the last return parameter and in others it's the second return parameters. Please make it consistent (probably the second return place is better so that it follows sigma).
  2. The cost should be defined as G_warmaccess, not independently, since that's how the EIP defines it.

@pldespaigne
Copy link
Contributor Author

pldespaigne commented Feb 21, 2025

Hey @yperbasis!
Thanks a lot for your time reviewing my PR!

I totally agree with the requested changes, however changing the order of returns parameters will require to update this part of YP as well (section 6.3.)

What do you think?

image

@yperbasis
Copy link
Member

@pldespaigne Ah, I see. Then it makes sense to have theta as the last output. But then I'd make it the last output of Xi as well for consistency.

@pldespaigne
Copy link
Contributor Author

@yperbasis done!
Everything should be ok now

Copy link
Member

@yperbasis yperbasis left a comment

Choose a reason for hiding this comment

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

LGTM except for the small "finals represents" typo

@pldespaigne
Copy link
Contributor Author

Done!
Could you merge it into the cancun branch please 🙏
I'll now move on to EIP-4844

@yperbasis yperbasis merged commit fc185c5 into ethereum:cancun Feb 26, 2025
1 check passed
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.

None yet

8 participants