-
Notifications
You must be signed in to change notification settings - Fork 878
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
Pectra devnet 5: 7702 changes #8118
Merged
siladu
merged 10 commits into
hyperledger:main
from
daniellehrner:feat/issue-7948/7702-devnet-5
Jan 16, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de23259
first draft for 7702 changes for pectra-devnet5
daniellehrner 8c67e36
Merge branch 'main' into feat/issue-7948/7702-devnet-5
daniellehrner 2b43a6b
spotless, javadoc
daniellehrner cba12c4
fixed get code in call operations
daniellehrner e715b57
Merge branch 'main' into feat/issue-7948/7702-devnet-5
daniellehrner e489fb6
allow code delegation chain id to be up to 2^256-1
daniellehrner 59bcb29
set code for delegated accounts correctly in the initialFrame of the …
daniellehrner e418116
Merge branch 'main' into feat/issue-7948/7702-devnet-5
daniellehrner 0a041e6
delegated accounts return empty bytes for the code if the target does…
daniellehrner 0573483
Merge branch 'main' into feat/issue-7948/7702-devnet-5
siladu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,7 +15,6 @@ | |||||
package org.hyperledger.besu.evm.operation; | ||||||
|
||||||
import static org.hyperledger.besu.evm.internal.Words.clampedToLong; | ||||||
import static org.hyperledger.besu.evm.worldstate.DelegatedCodeGasCostHelper.deductDelegatedCodeGasCost; | ||||||
|
||||||
import org.hyperledger.besu.datatypes.Address; | ||||||
import org.hyperledger.besu.datatypes.Wei; | ||||||
|
@@ -192,13 +191,24 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { | |||||
|
||||||
final Account contract = frame.getWorldUpdater().get(to); | ||||||
|
||||||
if (contract != null) { | ||||||
final DelegatedCodeGasCostHelper.Result result = | ||||||
deductDelegatedCodeGasCost(frame, gasCalculator(), contract); | ||||||
if (result.status() != DelegatedCodeGasCostHelper.Status.SUCCESS) { | ||||||
if (contract != null && contract.hasDelegatedCode()) { | ||||||
if (contract.getDelegatedCode().isEmpty()) { | ||||||
throw new RuntimeException("A delegated code account must have delegated code"); | ||||||
} | ||||||
|
||||||
if (contract.getDelegatedCodeHash().isEmpty()) { | ||||||
throw new RuntimeException("A delegated code account must have a delegated code hash"); | ||||||
} | ||||||
|
||||||
final long delegatedCodeResolutionGas = | ||||||
DelegatedCodeGasCostHelper.delegatedCodeGasCost(frame, gasCalculator(), contract); | ||||||
|
||||||
if (frame.getRemainingGas() < delegatedCodeResolutionGas) { | ||||||
return new Operation.OperationResult( | ||||||
result.gasCost(), ExceptionalHaltReason.INSUFFICIENT_GAS); | ||||||
delegatedCodeResolutionGas, ExceptionalHaltReason.INSUFFICIENT_GAS); | ||||||
} | ||||||
|
||||||
frame.decrementRemainingGas(delegatedCodeResolutionGas); | ||||||
} | ||||||
|
||||||
final Account account = frame.getWorldUpdater().get(frame.getRecipientAddress()); | ||||||
|
@@ -218,10 +228,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { | |||||
|
||||||
final Bytes inputData = frame.readMutableMemory(inputDataOffset(frame), inputDataLength(frame)); | ||||||
|
||||||
final Code code = | ||||||
contract == null | ||||||
? CodeV0.EMPTY_CODE | ||||||
: evm.getCode(contract.getCodeHash(), contract.getCode()); | ||||||
final Code code = getCode(evm, contract); | ||||||
|
||||||
// invalid code results in a quick exit | ||||||
if (!code.isValid()) { | ||||||
|
@@ -337,4 +344,23 @@ Bytes getCallResultStackItem(final MessageFrame childFrame) { | |||||
return LEGACY_FAILURE_STACK_ITEM; | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Gets the code from the contract or EOA with delegated code. | ||||||
* | ||||||
* @param evm the evm | ||||||
* @param account the account which needs to be retrieved | ||||||
* @return the code | ||||||
*/ | ||||||
protected static Code getCode(final EVM evm, final Account account) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (account == null) { | ||||||
return CodeV0.EMPTY_CODE; | ||||||
} | ||||||
|
||||||
if (account.hasDelegatedCode()) { | ||||||
return evm.getCode(account.getDelegatedCodeHash().get(), account.getDelegatedCode().get()); | ||||||
} | ||||||
|
||||||
return evm.getCode(account.getCodeHash(), account.getCode()); | ||||||
} | ||||||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.