Skip to content

feat: Added implementation support for movePrecompileToAddress#8086

Closed
pr9t wants to merge 1 commit intobesu-eth:mainfrom
pr9t:movePrecompileToAddressInAccountOverrides
Closed

feat: Added implementation support for movePrecompileToAddress#8086
pr9t wants to merge 1 commit intobesu-eth:mainfrom
pr9t:movePrecompileToAddressInAccountOverrides

Conversation

@pr9t
Copy link
Copy Markdown
Contributor

@pr9t pr9t commented Jan 7, 2025

PR description

Fixed Issue(s)

fixes #8031

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

Signed-off-by: Preeti <35308865+pr9t@users.noreply.github.com>
@macfarla
Copy link
Copy Markdown
Contributor

macfarla commented Jan 8, 2025

@pr9t this is great as a first step but it doesn't completely fix #8031 since the value isn't used in the simulation - that can be a follow-on PR if you like

@pr9t
Copy link
Copy Markdown
Contributor Author

pr9t commented Jan 8, 2025

Hey @macfarla, to use the value in the simulation, do I need to add it to this code?

protected void applyOverrides(final MutableAccount account, final AccountOverride override) {
    LOG.debug("applying overrides to state for account {}", account.getAddress());
    override.getNonce().ifPresent(account::setNonce);
    if (override.getBalance().isPresent()) {
      account.setBalance(override.getBalance().get());
    }
    override.getCode().ifPresent(n -> account.setCode(Bytes.fromHexString(n)));
    override
        .getStateDiff()
        .ifPresent(
            d ->
                d.forEach(
                    (key, value) ->
                        account.setStorageValue(
                            UInt256.fromHexString(key), UInt256.fromHexString(value))));
  }

@macfarla
Copy link
Copy Markdown
Contributor

Hey @macfarla, to use the value in the simulation, do I need to add it to this code?

protected void applyOverrides(final MutableAccount account, final AccountOverride override) {
    LOG.debug("applying overrides to state for account {}", account.getAddress());
    override.getNonce().ifPresent(account::setNonce);
    if (override.getBalance().isPresent()) {
      account.setBalance(override.getBalance().get());
    }
    override.getCode().ifPresent(n -> account.setCode(Bytes.fromHexString(n)));
    override
        .getStateDiff()
        .ifPresent(
            d ->
                d.forEach(
                    (key, value) ->
                        account.setStorageValue(
                            UInt256.fromHexString(key), UInt256.fromHexString(value))));
  }

Kind of - you're definitely on the right track! Have a look at #8115 from @Gabriel-Trintinalia which takes it a bit further. Precompiles are handled a bit differently to other addresses so there's some extra complexity.

@macfarla
Copy link
Copy Markdown
Contributor

@pr9t I'm going to close this PR as #8115 covers this functionality. Feel free to pick up another issue!

@macfarla macfarla closed this Jan 15, 2025
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.

Simulation - implement movePrecompileToAddress in account overrides

2 participants