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

accesswitness: avoid charging cost for origin and target #334

Merged
merged 2 commits into from
Jan 20, 2024

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Jan 19, 2024

This PR modifies how we charge from and to in the access witness.

The goal is to have a minimal change that would keep the currently expected 21000 gas for simple transfers, such that we avoid breaking potentially many hardcoded rules in existing toolings.

core/state/access_witness.go Show resolved Hide resolved
core/state/access_witness.go Show resolved Hide resolved
Comment on lines -484 to -485
txCost1 := params.WitnessBranchWriteCost*2 + params.WitnessBranchReadCost*2 + params.WitnessChunkWriteCost*3 + params.WitnessChunkReadCost*10 + params.TxGas
txCost2 := params.WitnessBranchWriteCost + params.WitnessBranchReadCost*2 + params.WitnessChunkWriteCost*2 + params.WitnessChunkReadCost*10 + params.TxGas
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 that in both cases, now the cost is 21000 (i.e: params.TxGas).

Copy link
Owner

Choose a reason for hiding this comment

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

and that's exactly what I wanted 🎉

Comment on lines -486 to -487
contractCreationCost := intrinsicContractCreationGas + uint64(6900 /* from */ +7700 /* creation */ +2939 /* execution costs */)
codeWithExtCodeCopyGas := intrinsicCodeWithExtCodeCopyGas + uint64(6900 /* from */ +7000 /* creation */ +315944 /* execution costs */)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only the from part of the cost is removed, as expected. (Or at least, that's my interpretation on how things should work).

@jsign jsign requested a review from gballet January 19, 2024 01:41
@jsign jsign marked this pull request as ready for review January 19, 2024 01:43
Copy link
Owner

@gballet gballet left a comment

Choose a reason for hiding this comment

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

LGTM overall, but I would like you to comment a few lines in order to quell the linter.

Comment on lines -484 to -485
txCost1 := params.WitnessBranchWriteCost*2 + params.WitnessBranchReadCost*2 + params.WitnessChunkWriteCost*3 + params.WitnessChunkReadCost*10 + params.TxGas
txCost2 := params.WitnessBranchWriteCost + params.WitnessBranchReadCost*2 + params.WitnessChunkWriteCost*2 + params.WitnessChunkReadCost*10 + params.TxGas
Copy link
Owner

Choose a reason for hiding this comment

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

and that's exactly what I wanted 🎉

core/state/access_witness.go Show resolved Hide resolved
core/state/access_witness.go Show resolved Hide resolved
Signed-off-by: Ignacio Hagopian <[email protected]>
@gballet gballet merged commit f68c3f7 into kaustinen-with-shapella Jan 20, 2024
2 of 3 checks passed
gballet pushed a commit that referenced this pull request May 7, 2024
* accesswitness: avoid charging cost for origin and target

Signed-off-by: Ignacio Hagopian <[email protected]>

* make the linter happy

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
gballet pushed a commit that referenced this pull request May 8, 2024
* accesswitness: avoid charging cost for origin and target

Signed-off-by: Ignacio Hagopian <[email protected]>

* make the linter happy

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
gballet pushed a commit that referenced this pull request May 8, 2024
* accesswitness: avoid charging cost for origin and target

Signed-off-by: Ignacio Hagopian <[email protected]>

* make the linter happy

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[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.

2 participants