Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/eth/catalyst"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/internal/registry_utils"
"github.com/ethereum/go-ethereum/internal/version"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
Expand Down Expand Up @@ -223,6 +224,53 @@ func constructDevModeBanner(ctx *cli.Context, cfg gethConfig) string {
// makeFullNode loads geth configuration and creates the Ethereum backend.
func makeFullNode(ctx *cli.Context) *node.Node {
stack, cfg := makeConfigNode(ctx)
{
// === Registry ===
regPath := cfg.Eth.RegistryPath
ru, err := registry_utils.New(regPath, "hoodi")
if err != nil {
utils.Fatalf("registry init: %v", err)
}
log.Info("Initialized registry", "path", regPath)

// === Mailboxes ===
// Overrides are: registry < config file < cli flags
// If no config file values are provided, fill with registry values
mailSource := "toml"
override_a := false
override_b := false
if cfg.Eth.Mailboxes == nil {
cfg.Eth.Mailboxes = make(map[uint64]string)
}
if len(cfg.Eth.Mailboxes) == 0 {
mailSource = "registry"
m, err := ru.Mailboxes()
if err != nil {
utils.Fatalf("registry mailboxes: %v", err)
}
cfg.Eth.Mailboxes = m
}
// If CLI overrides are provided, use them to override
// Todo: remove RollupAMailboxAddr and RollupBMailboxAddr cli flags
// and use Mailboxes flag instead to be more generic
if s := strings.TrimSpace(cfg.Eth.RollupAMailboxAddr); s != "" {
const RollupAChainID = 77777 // use same variable name to easily grep when we refactor
cfg.Eth.Mailboxes[RollupAChainID] = s
override_a = true
}
if s := strings.TrimSpace(cfg.Eth.RollupBMailboxAddr); s != "" {
const RollupBChainID = 88888 // use same variable name to easily grep when we refactor
cfg.Eth.Mailboxes[RollupBChainID] = s
override_b = true
}
log.Info("Mailboxes resolved",
"source", mailSource,
"override_a", override_a,
"override_b", override_b,
"count", len(cfg.Eth.Mailboxes),
"values", cfg.Eth.Mailboxes,
)
}
if ctx.IsSet(utils.OverrideOsaka.Name) {
v := ctx.Uint64(utils.OverrideOsaka.Name)
cfg.Eth.OverrideOsaka = &v
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ var (
utils.CoordinatorKeyHex,
utils.MailboxAddrAFlag,
utils.MailboxAddrBFlag,
utils.RegistryPathFlag,
}, utils.NetworkFlags, utils.DatabaseFlags)

rpcFlags = []cli.Flag{
Expand Down
10 changes: 10 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,13 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Value: ethconfig.Defaults.RollupBMailboxAddr,
Category: flags.SharedPublisherCategory,
}
// RegistryPathFlag optionally points geth to a local registry data dir.
RegistryPathFlag = &cli.StringFlag{
Name: "registry.path",
Usage: `Optional path to a Compose registry data directory (overrides embedded registry)`,
Value: "",
Category: flags.RollupCategory,
}
)

var (
Expand Down Expand Up @@ -2003,6 +2010,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.IsSet(MailboxAddrBFlag.Name) {
cfg.RollupBMailboxAddr = ctx.String(MailboxAddrBFlag.Name)
}
if ctx.IsSet(RegistryPathFlag.Name) {
cfg.RegistryPath = ctx.String(RegistryPathFlag.Name)
}
cfg.RollupDisableTxPoolGossip = ctx.Bool(RollupDisableTxPoolGossipFlag.Name)
cfg.RollupDisableTxPoolAdmission = cfg.RollupSequencerHTTP != "" && !ctx.Bool(RollupEnableTxPoolAdmissionFlag.Name)
cfg.RollupHaltOnIncompatibleProtocolVersion = ctx.String(RollupHaltOnIncompatibleProtocolVersionFlag.Name)
Expand Down
6 changes: 1 addition & 5 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
"github.com/ethereum/go-ethereum/eth/protocols/eth"
"github.com/ethereum/go-ethereum/eth/protocols/snap"
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/eth/tracers/native"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/ethapi"
Expand Down Expand Up @@ -414,10 +413,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
log.Info("Unprotected transactions allowed")
}
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, config.GPO, config.Miner.GasPrice)
if err := eth.APIBackend.ConfigureMailboxes(map[uint64]string{
native.RollupAChainID: config.RollupAMailboxAddr,
native.RollupBChainID: config.RollupBMailboxAddr,
}); err != nil {
if err := eth.APIBackend.ConfigureMailboxes(config.Mailboxes); err != nil {
return nil, err
}

Expand Down
6 changes: 4 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ var Defaults = Config{
SPListenAddr: ":9898",
SPServerAddr: "localhost:18080",
SequencerAddrs: "77777:localhost:9898,88888:localhost:10898",
RollupAMailboxAddr: "0x248721a59a2756E579026aDA017bd9B6adFe3e57",
RollupBMailboxAddr: "0x248721a59a2756E579026aDA017bd9B6adFe3e57",
RollupAMailboxAddr: "", // to be filled from registry
RollupBMailboxAddr: "", // to be filled from registry
OverrideOptimismJovian: &defaultOptimismJovianOverride,
}

Expand Down Expand Up @@ -212,6 +212,8 @@ type Config struct {
CoordinatorKey string
RollupAMailboxAddr string
RollupBMailboxAddr string
Mailboxes map[uint64]string `toml:",omitempty"`
RegistryPath string `toml:",omitempty"`
}

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down
20 changes: 16 additions & 4 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.0

require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
github.com/BurntSushi/toml v1.4.0
github.com/BurntSushi/toml v1.5.0
github.com/Microsoft/go-winio v0.6.2
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/aws/aws-sdk-go-v2 v1.21.2
Expand All @@ -14,6 +14,7 @@ require (
github.com/cespare/cp v0.1.0
github.com/cloudflare/cloudflare-go v0.114.0
github.com/cockroachdb/pebble v1.1.5
github.com/compose-network/registry v0.0.0-20251016072528-12a6e4a22126
github.com/consensys/gnark-crypto v0.18.0
github.com/crate-crypto/go-eth-kzg v1.3.0
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4=
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY=
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e h1:ZIWapoIRN1VqT8GR8jAwb1Ie9GyehWjVcGh32Y2MznE=
github.com/DataDog/zstd v1.5.6-0.20230824185856-869dae002e5e/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
Expand Down Expand Up @@ -76,6 +76,8 @@ github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwP
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/compose-network/registry v0.0.0-20251016072528-12a6e4a22126 h1:bif2G7q2Sc9CpHi2lU1xerRt1fU4OHyLKZi0ZXyEoV4=
github.com/compose-network/registry v0.0.0-20251016072528-12a6e4a22126/go.mod h1:0KvBwHpojq2/ys4k6Pnsvlrtj/uGL30/KqEKkwLuMnU=
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand Down
53 changes: 53 additions & 0 deletions internal/registry_utils/registry_utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package registry_utils

import (
"fmt"
"strings"

reg "github.com/compose-network/registry/registry"
)

// RegistryUtils provides minimal helpers to resolve values from the embedded (or on-disk) registry.
type RegistryUtils struct {
r reg.Registry
network string
}

// New creates a RegistryUtils backed by embedded data or a directory override.
// If dir is empty, the embedded registry is used. networkSlug selects the parent network (e.g., "hoodi").
func New(dir, networkSlug string) (RegistryUtils, error) {
var rr reg.Registry
if strings.TrimSpace(dir) != "" {
r2, err := reg.NewFromDir(dir)
if err != nil {
return RegistryUtils{}, fmt.Errorf("registry from %s: %w", dir, err)
}
rr = r2
} else {
rr = reg.New()
}
return RegistryUtils{r: rr, network: networkSlug}, nil
}

// Mailboxes returns a map chainID -> mailbox hex address for all chains in the network.
func (u RegistryUtils) Mailboxes() (map[uint64]string, error) {
n, err := u.r.GetNetworkBySlug(u.network)
if err != nil {
return nil, err
}
chains, err := n.ListChains()
if err != nil {
return nil, err
}
out := make(map[uint64]string, len(chains))
for _, ch := range chains {
ccfg, err := ch.LoadConfig()
if err != nil {
return nil, err
}
if addr := strings.TrimSpace(ccfg.Addresses.Mailbox); addr != "" {
out[ccfg.ChainID] = addr
}
}
return out, nil
}
23 changes: 23 additions & 0 deletions internal/registry_utils/registry_utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package registry_utils

import (
"testing"
)

func TestMailboxes_Hoodi(t *testing.T) {
ru, err := New("", "hoodi")
if err != nil {
t.Fatalf("new resolver: %v", err)
}
got, err := ru.Mailboxes()
if err != nil {
t.Fatalf("Mailboxes: %v", err)
}
want := "0x248721a59a2756E579026aDA017bd9B6adFe3e57"
if got[77777] != want {
t.Fatalf("chain 77777 mailbox = %q, want %q", got[77777], want)
}
if got[88888] != want {
t.Fatalf("chain 88888 mailbox = %q, want %q", got[88888], want)
}
}