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

[Arbitrum][Integrate]RIP-7728 #10

Open
wants to merge 1 commit into
base: arbitrum
Choose a base branch
from

Conversation

mralj
Copy link
Collaborator

@mralj mralj commented Oct 11, 2024

Integrates RIP-7728 implemented in #2 to "arbitrum-geth".

RIP-7728

This proposal introduces a new precompiled contract, L1SLOAD, that loads several storage slots from L1, requiring a contract address, storage keys, and RPC connection to L1.

Implementation details

To leverage this precompile node runner on L2; it must have the following:

  1. Some Notion of latest L1 block
  2. RPC connection to L1 node, preferably "fast one" since we are making L1 RPC call during EVM precompile execution.

Our rollup-geth has a flag --rollup.l1.rpc_endpoint from which it reads the URL of the required L1 RPC.
But, since Arbitrum injects geth execution client during the nitro setup, we cannot leverage this flag. I propose to extend the nitro so that:

  1. It accepts the L1 RPC URL flag
  2. During Nitro node setup, it establishes a connection to L1 RPC
  3. It injects this connection to the evm
// In  cmd/nitro/nitro.go
client, err := ethclient.Dial(nodeConfig.Rpc.L1Url)
if err != nil {
    log.Error("Could not dial provided L1 RPC client")
    }
vm.SetVmL1RpcClient(client)

Overriding the default config

Out of the box, rollup-geth provides the following method for "dealing" with the latest L1 block:

var defaultRollupPrecompilesConfig RollupPrecompileActivationConfig = RollupPrecompileActivationConfig{
	L1SLoad: L1SLoad{
		GetLatestL1BlockNumber: LetRPCDecideLatestL1Number, // CHANGE THIS METHOD
	},
}

The code is located in core/vm/contracts_rollup_overrides. We should pass into the GetLatestL1BlockNumber appropriate method for providing the latest L1 block on the Arbitrum blockchain.

commit 237b78f
Author: mralj <[email protected]>
Date:   Fri Oct 11 12:46:51 2024 +0200

    removed unnecessary call to  vm.SetVmL1RpcClient

commit d4cd646
Author: mralj <[email protected]>
Date:   Fri Oct 11 12:16:24 2024 +0200

    rollup precompile config is glob. variable

    I decided to implement it this way after trying to integrate code with Arbitrum and having a better understanding of the calls that are made to the NewEvm
    This approach makes it easier to both override the default config, and to have the option to "not to think about it"

commit 42855ae
Author: mralj <[email protected]>
Date:   Wed Oct 9 10:10:44 2024 +0200

    concurrent map r/w bugfix

commit 128b120
Author: mralj <[email protected]>
Date:   Mon Oct 7 14:00:57 2024 +0200

    removed unused import - popped up after rebasing

commit ee58cfe
Author: mralj <[email protected]>
Date:   Mon Oct 7 13:00:42 2024 +0200

    missed cleanup of ActivePrecompiles

commit d409ef8
Author: mralj <[email protected]>
Date:   Mon Oct 7 12:02:42 2024 +0200

    bugfixes - l1rpc activated at proper point and precompile address

commit bdd7b7d
Author: mralj <[email protected]>
Date:   Mon Oct 7 10:57:48 2024 +0200

    ethclient moved to node.Node

commit bd56bdc
Author: mralj <[email protected]>
Date:   Fri Oct 4 17:36:36 2024 +0200

    code cleanup after trying to merge into arb/op-geth

commit 76a2339
Author: mralj <[email protected]>
Date:   Tue Oct 1 10:43:04 2024 +0200

    internal/ethapi and tracers use pre-existing function call

commit b72098e
Author: mralj <[email protected]>
Date:   Mon Sep 30 10:20:37 2024 +0200

    added missing "," - fixed comptime bug

commit 1ccbc95
Author: mralj <[email protected]>
Date:   Mon Sep 30 10:13:45 2024 +0200

    simplified the code

commit 0f74390
Author: mralj <[email protected]>
Date:   Sun Sep 29 13:12:00 2024 +0200

    cleaned up code & created more rollup specific files

commit 2a7b7d7
Author: mralj <[email protected]>
Date:   Sun Sep 29 11:45:34 2024 +0200

    cmd - rollup specific files

commit ef91bcd
Author: mralj <[email protected]>
Date:   Fri Sep 27 13:10:01 2024 +0200

    implements L1SLOAD contract

commit 6a98534
Author: mralj <[email protected]>
Date:   Thu Sep 26 13:22:58 2024 +0200

    added L1SLoad sekelton

commit 5f039c5
Merge: 204ef24 56c1f67
Author: mralj <[email protected]>
Date:   Mon Oct 7 13:09:06 2024 +0200

    Merge pull request #4 from NethermindEth/core/rip/7728-precompile-impl

    [P2] Implements RIP-7728

commit 56c1f67
Author: mralj <[email protected]>
Date:   Sat Sep 28 13:00:06 2024 +0200

    added missing mocks for tests

commit e9a5c28
Author: mralj <[email protected]>
Date:   Fri Sep 27 22:44:44 2024 +0200

    added test for too long input edgecase

commit bea23a3
Author: mralj <[email protected]>
Date:   Fri Sep 27 22:40:37 2024 +0200

    added batch call for StoragesAt as well as tests

commit c4b24af
Author: mralj <[email protected]>
Date:   Fri Sep 27 13:32:52 2024 +0200

    added rpc call timeout strategy

commit f0dd217
Author: mralj <[email protected]>
Date:   Fri Sep 27 13:10:01 2024 +0200

    implements L1SLOAD contract

commit 759dda7
Author: mralj <[email protected]>
Date:   Thu Sep 26 13:22:58 2024 +0200

    added L1SLoad sekelton

commit 204ef24
Author: mralj <[email protected]>
Date:   Thu Sep 26 20:21:47 2024 +0200

    added example how code in overrides would change

commit a24608e
Author: mralj <[email protected]>
Date:   Thu Sep 26 19:48:47 2024 +0200

    added ability to activate rollup precompiles from eth/internal and eth/tracers

commit 99ccaf7
Author: mralj <[email protected]>
Date:   Thu Sep 26 13:26:08 2024 +0200

    bugfix

commit 1974d92
Author: mralj <[email protected]>
Date:   Thu Sep 26 13:22:58 2024 +0200

    added L1SLoad sekelton

commit 0ae7e7b
Author: mralj <[email protected]>
Date:   Wed Sep 25 19:08:40 2024 +0200

    dial L1 RPC client passed via required flag

# Conflicts:
#	cmd/geth/config.go
#	core/vm/evm.go
#	core/vm/interpreter.go
#	core/vm/runtime/runtime.go
#	eth/backend.go
#	eth/tracers/api.go
#	eth/tracers/js/goja.go
#	eth/tracers/native/4byte.go
#	eth/tracers/native/call_flat.go
#	internal/ethapi/api.go
#	internal/ethapi/simulate.go
#	node/node.go
#	params/config.go
#	tests/state_test.go
@mralj mralj marked this pull request as ready for review October 12, 2024 11:21
@mralj mralj self-assigned this Oct 12, 2024
Copy link
Member

@jmederosalvarado jmederosalvarado left a comment

Choose a reason for hiding this comment

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

lgtm

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