Skip to content

Commit 416f797

Browse files
committed
feat(all): moonchain protocol
1 parent c65e9b9 commit 416f797

26 files changed

+1461
-10
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "Push docker image to GAR"
22

33
on:
44
push:
5-
branches: [ taiko ]
5+
branches: [ moonchain-geneva ]
66
tags:
77
- "v*"
88

beacon/engine/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type ExecutableData struct {
105105
TxHash common.Hash `json:"txHash"` // CHANGE(taiko): allow passing txHash directly instead of transactions list
106106
WithdrawalsHash common.Hash `json:"withdrawalsHash"` // CHANGE(taiko): allow passing WithdrawalsHash directly instead of withdrawals
107107
TaikoBlock bool // CHANGE(taiko): whether this is a Taiko L2 block, only used by ExecutableDataToBlock
108+
MoonchainBlock bool // CHANGE(moonchain): whether this is a Mxc L2 block, only used by ExecutableDataToBlock
108109
}
109110

110111
// JSON type overrides for executableData.

cmd/geth/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
181181

182182
// CHANGE(TAIKO): register Taiko RPC APIs.
183183
utils.RegisterTaikoAPIs(stack, &cfg.Eth, eth)
184+
// CHANGE(MOONCHAIN): register Mxc RPC APIs.
185+
utils.RegisterMoonchainAPIs(stack, &cfg.Eth, eth)
184186

185187
// Create gauge with geth system and build information
186188
if eth != nil { // The 'eth' backend may be nil in light mode

cmd/geth/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ func init() {
252252
)
253253
// CHANGE(taiko): append Taiko flags into the original GETH flags
254254
app.Flags = append(app.Flags, &utils.TaikoFlag)
255+
// CHANGE(moonchain): append Mxc flags into the original GETH falgs
256+
app.Flags = append(app.Flags, &utils.MoonchainFlag)
255257

256258
flags.AutoEnvVars(app.Flags, "GETH")
257259

cmd/utils/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17401740
}
17411741
// Override any default configs for hard coded networks.
17421742
switch {
1743+
// CHANGE(moonchain): when --moonchain flag is set, use the Taiko genesis.
1744+
case ctx.IsSet(MoonchainFlag.Name):
1745+
cfg.Genesis = core.MoonchainGenesisBlock(cfg.NetworkId)
17431746
// CHANGE(taiko): when --taiko flag is set, use the Taiko genesis.
17441747
case ctx.IsSet(TaikoFlag.Name):
17451748
cfg.Genesis = core.TaikoGenesisBlock(cfg.NetworkId)

cmd/utils/moonchain_flags.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package utils
2+
3+
import (
4+
"os"
5+
6+
"github.com/ethereum/go-ethereum/eth"
7+
"github.com/ethereum/go-ethereum/eth/ethconfig"
8+
"github.com/ethereum/go-ethereum/node"
9+
"github.com/ethereum/go-ethereum/params"
10+
"github.com/ethereum/go-ethereum/rpc"
11+
"github.com/urfave/cli/v2"
12+
)
13+
14+
var (
15+
MoonchainFlag = cli.BoolFlag{
16+
Name: "mxc",
17+
Usage: "Moonchain zkEVM network",
18+
}
19+
)
20+
21+
// RegisterMoonchainAPIs initializes and registers the Taiko RPC APIs.
22+
func RegisterMoonchainAPIs(stack *node.Node, cfg *ethconfig.Config, backend *eth.Ethereum) {
23+
if os.Getenv("MOONCHAIN_TEST") != "" {
24+
return
25+
}
26+
// Add methods under "taiko_" RPC namespace to the available APIs list
27+
stack.RegisterAPIs([]rpc.API{
28+
{
29+
Namespace: "moonchain",
30+
Version: params.VersionWithMeta,
31+
Service: eth.NewMoonchainAPIBackend(backend),
32+
Public: true,
33+
},
34+
{
35+
Namespace: "moonchainAuth",
36+
Version: params.VersionWithMeta,
37+
Service: eth.NewMoonchainAuthAPIBackend(backend),
38+
Authenticated: true,
39+
},
40+
})
41+
}

0 commit comments

Comments
 (0)