Skip to content

Commit

Permalink
feat(all): moonchain protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
luanxu-mxc committed Sep 2, 2024
1 parent c65e9b9 commit 416f797
Show file tree
Hide file tree
Showing 26 changed files with 1,461 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Push docker image to GAR"

on:
push:
branches: [ taiko ]
branches: [ moonchain-geneva ]
tags:
- "v*"

Expand Down
1 change: 1 addition & 0 deletions beacon/engine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type ExecutableData struct {
TxHash common.Hash `json:"txHash"` // CHANGE(taiko): allow passing txHash directly instead of transactions list
WithdrawalsHash common.Hash `json:"withdrawalsHash"` // CHANGE(taiko): allow passing WithdrawalsHash directly instead of withdrawals
TaikoBlock bool // CHANGE(taiko): whether this is a Taiko L2 block, only used by ExecutableDataToBlock
MoonchainBlock bool // CHANGE(moonchain): whether this is a Mxc L2 block, only used by ExecutableDataToBlock
}

// JSON type overrides for executableData.
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {

// CHANGE(TAIKO): register Taiko RPC APIs.
utils.RegisterTaikoAPIs(stack, &cfg.Eth, eth)
// CHANGE(MOONCHAIN): register Mxc RPC APIs.
utils.RegisterMoonchainAPIs(stack, &cfg.Eth, eth)

// Create gauge with geth system and build information
if eth != nil { // The 'eth' backend may be nil in light mode
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func init() {
)
// CHANGE(taiko): append Taiko flags into the original GETH flags
app.Flags = append(app.Flags, &utils.TaikoFlag)
// CHANGE(moonchain): append Mxc flags into the original GETH falgs
app.Flags = append(app.Flags, &utils.MoonchainFlag)

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

Expand Down
3 changes: 3 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
// Override any default configs for hard coded networks.
switch {
// CHANGE(moonchain): when --moonchain flag is set, use the Taiko genesis.
case ctx.IsSet(MoonchainFlag.Name):
cfg.Genesis = core.MoonchainGenesisBlock(cfg.NetworkId)
// CHANGE(taiko): when --taiko flag is set, use the Taiko genesis.
case ctx.IsSet(TaikoFlag.Name):
cfg.Genesis = core.TaikoGenesisBlock(cfg.NetworkId)
Expand Down
41 changes: 41 additions & 0 deletions cmd/utils/moonchain_flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package utils

import (
"os"

"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli/v2"
)

var (
MoonchainFlag = cli.BoolFlag{
Name: "mxc",
Usage: "Moonchain zkEVM network",
}
)

// RegisterMoonchainAPIs initializes and registers the Taiko RPC APIs.
func RegisterMoonchainAPIs(stack *node.Node, cfg *ethconfig.Config, backend *eth.Ethereum) {
if os.Getenv("MOONCHAIN_TEST") != "" {
return
}
// Add methods under "taiko_" RPC namespace to the available APIs list
stack.RegisterAPIs([]rpc.API{
{
Namespace: "moonchain",
Version: params.VersionWithMeta,
Service: eth.NewMoonchainAPIBackend(backend),
Public: true,
},
{
Namespace: "moonchainAuth",
Version: params.VersionWithMeta,
Service: eth.NewMoonchainAuthAPIBackend(backend),
Authenticated: true,
},
})
}
Loading

0 comments on commit 416f797

Please sign in to comment.