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

Specification for the gas fee of System operations #889

Open
cuongquangnam opened this issue Jul 20, 2023 · 1 comment
Open

Specification for the gas fee of System operations #889

cuongquangnam opened this issue Jul 20, 2023 · 1 comment

Comments

@cuongquangnam
Copy link

In the execution model, the remaining gas after executing an operation is defined as:
image
And then in appendix H we have:
image
and in the definition for CALL opcode, we have
Screenshot 2023-07-20 at 12 30 14 PM
However, there is also definition for the cost below:
image
Therefore, is it that
${\mu'}_g = {\mu}_g - C_{CALLGAS}({\sigma},{\mu}, A) + g' = {\mu}_g - C({\sigma},{\mu}, A,I)= {\mu}_g - C_{mem}({\mu_{i}'}) + C_{mem}({\mu_{i}}) - C_{CALL}({\sigma},{\mu}, A)$
I really doubt it is the case, can anyone help explain this?
For me, the more intuitive equation should be:
${\mu'}_g = {\mu}_g - C_{mem}({\mu_{i}'}) + C_{mem}({\mu_{i}}) - C_{CALL}({\sigma},{\mu}, A) + g' = {\mu}_g - C({\sigma},{\mu}, A,I) + g'$
and
$C_{CALL}({\sigma, \mu, A }) = C_{CALLGAS}({\sigma, \mu, A }) + C_{EXTRA}({\sigma, \mu, A })$
Therefore, it seems that for the case of system operation (e.g. CALL), we should add g' to ${\mu'_g}$ (to take back the gas remaining after the execution of that operation)

@kodyfanz
Copy link
Contributor

kodyfanz commented Feb 6, 2024

First:

$\boldsymbol{\mu}'_g \equiv \boldsymbol{\mu}_g - C(\boldsymbol{\sigma}, \boldsymbol{\mu}, A, I)$

$C(\boldsymbol{\sigma}, \boldsymbol{\mu}, A, I)$ in this formula represents a general description for cases involving gas costs, depending on the world-state $\boldsymbol{\sigma}$, machine-state $\boldsymbol{\mu}$, the accrued substate $A$, and the instruction $I$.

$C(\boldsymbol{\sigma},\boldsymbol{\mu},A,I) \equiv C_{mem}(\boldsymbol{\mu}_ i')-C_{mem}(\boldsymbol{\mu}_ i)+C_{\text{CALL}}(\boldsymbol{\sigma},\boldsymbol{\mu},A)$ if $w \in W_{call}$

The above formula is specified in the case where the instruction $I$ belongs to the set of CALL instructions, again:

$C_{\text{CALL}}(\boldsymbol{\sigma}, \boldsymbol{\mu}, A) \equiv C_{\text{CALLGAS}}(\boldsymbol{\sigma},\boldsymbol{\mu}, A) - g'$

where $g'$ is the amount of gas refunded after the execution of the CALL instruction.

Thus, there is no contradiction in the yellow paper here.

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

No branches or pull requests

2 participants