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

Feat/juno on sedge #333

Open
wants to merge 54 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cc0373a
providing juno support on sedge
Tomi-3-0 Oct 21, 2023
12fb8b8
added starknet to list of supported clients to show in cli
Tomi-3-0 Oct 24, 2023
7c947a6
supporting docs for juno#2
Tomi-3-0 Oct 25, 2023
cb298e3
removed a comment
Tomi-3-0 Oct 25, 2023
c7466a6
support for generating consensus and execution clients together with …
Tomi-3-0 Nov 7, 2023
3427601
Add: check for EC_API_URL for 'sedge generate starknet' command
Nov 19, 2023
237f6bd
Add: added to list of ports for juno.tmpl
Nov 20, 2023
9b6459f
Add: Juno uri validator for Eth1 endpoint
Nov 20, 2023
11f64e6
Add:support for Eth-1-endpoint
Nov 20, 2023
f98cbea
fix: enabled http
Nov 21, 2023
b46454f
fix: add starknet template to env_base in goerli
Nov 21, 2023
f8fd0d9
fix:changed host endpoint
Nov 21, 2023
c06c0bc
fix: expose ports
Nov 22, 2023
93498dd
fix: corrected L2WSPort to L2WsPort
Nov 22, 2023
0539407
removed flags for ports
Nov 23, 2023
0152aa2
Add: modify EC_API_URL endpoint to use for Juno node
Nov 23, 2023
649d743
fix:added value for pending poll interval
Nov 23, 2023
7211573
added: nginx service for proxying requests
Nov 23, 2023
55971b9
fix:added appropriate directory for nginx config file
Nov 23, 2023
2350c2a
fix:added appropriate directory for nginx config file
Nov 23, 2023
dedb67f
fix:added appropriate volumes mapping for nginx
Nov 23, 2023
81c37e6
attempted fix: configuration for websocket
Nov 26, 2023
c8eaa64
fix: with fullstarknetflag mode
Nov 26, 2023
ff6f7be
fix: with full flag func, removed reverse proxy logic
Nov 27, 2023
b096abb
docs: updated readme with starknet client
Nov 27, 2023
57f480c
test: tests for scripts generation for starknet client using sedge cl…
Nov 28, 2023
b3eb852
test: added tests for starknet client
Nov 28, 2023
30a3c87
docs: added a running starknet node guide file
Nov 30, 2023
196a83d
fix: docs:updated flags for starknet in generate.mdx
Nov 30, 2023
4d07486
fix: support for specifying exact node name for starknet command
Dec 4, 2023
b75111c
test: added tests generate_tests for starknet
Dec 4, 2023
739beb3
tests: more tests for starknet
Dec 4, 2023
0d4ac91
fix:revert
Tomi-3-0 Dec 7, 2023
0a9878e
Merge branch 'main' into feat/juno-on-sedge
Tomi-3-0 Dec 7, 2023
bdfc4d0
resolve merge conflicts
Tomi-3-0 Dec 7, 2023
b0371cb
test: added test for full starknet node with execution and consensus
Tomi-3-0 Dec 8, 2023
183a2d0
Juno support for Sepolia and deprecated Goerli
Tomi-3-0 Dec 8, 2023
724102c
fix: resolve merge conflicts
Tomi-3-0 Dec 8, 2023
d19bb62
updated juno node version
Tomi-3-0 Dec 8, 2023
cf714c6
add: added flags for juno v0.8.0 and supporting test
Tomi-3-0 Dec 9, 2023
5ef4129
fix: execution api url output
Tomi-3-0 Dec 9, 2023
d44b103
fix: envs test for sepolia starknet
Tomi-3-0 Dec 9, 2023
480b963
style
Tomi-3-0 Dec 9, 2023
275e7a9
style: after running gofumpt -l -w . command
Tomi-3-0 Dec 9, 2023
b33324e
removed --remote-db flag for juno
Tomi-3-0 Dec 10, 2023
f938a31
style
Tomi-3-0 Dec 10, 2023
15f4128
test: TestGenerateComoposeServices test for starknet
Tomi-3-0 Dec 12, 2023
95c930d
Merge branch 'develop' into feat/juno-on-sedge
stdevMac Dec 14, 2023
1253443
removed empty templates for unsupported clients, and added starknet …
Tomi-3-0 Dec 15, 2023
df8b8c9
Merge branch 'feat/juno-on-sedge' of https://github.com/Tomi-3-0/sedg…
Tomi-3-0 Dec 15, 2023
0107080
fix: print sedge clients even for empty with non-existent starknet te…
Tomi-3-0 Dec 15, 2023
5be74eb
remove ldog info statemeent
Tomi-3-0 Dec 18, 2023
96d5a31
revert previous commit
Tomi-3-0 Dec 18, 2023
527f3b0
Add: removed executionApiUrl flag for Starknet and replaced with ethN…
Tomi-3-0 Dec 26, 2023
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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ Users acknowledge that no warranty is being made of a successful installation. S

### Mainnet

| Execution | Consensus | Validator |
| ---------- | ---------- | ---------- |
| Geth | Lighthouse | Lighthouse |
| Nethermind | Lodestar | Lodestar |
| Erigon | Prysm | Prysm |
| Besu | Teku | Teku |
| Execution | Consensus | Validator | Starknet |
| ---------- | ---------- | ---------- |---------- |
| Geth | Lighthouse | Lighthouse | Juno |
| Nethermind | Lodestar | Lodestar | |
| Erigon | Prysm | Prysm | |
| Besu | Teku | Teku | |

### Sepolia

Expand All @@ -150,12 +150,12 @@ Users acknowledge that no warranty is being made of a successful installation. S

### Goerli

| Execution | Consensus | Validator |
| ---------- | ---------- | ---------- |
| Geth | Lighthouse | Lighthouse |
| Nethermind | Lodestar | Lodestar |
| Erigon | Prysm | Prysm |
| Besu | Teku | Teku |
| Execution | Consensus | Validator | Starknet |
| ---------- | ---------- | ---------- | ---------- |
| Geth | Lighthouse | Lighthouse | Juno |
| Nethermind | Lodestar | Lodestar | |
| Erigon | Prysm | Prysm | |
| Besu | Teku | Teku | |

### Holesky

Expand Down
3 changes: 3 additions & 0 deletions cli/actions/getContainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (actions *sedgeActions) GetContainersData(options GetContainersDataOptions)
if composeData.Services.Validator != nil && composeData.Services.Validator.ContainerName != "" {
containersNames = append(containersNames, composeData.Services.Validator.ContainerName)
}
if composeData.Services.Starknet != nil && composeData.Services.Starknet.ContainerName != "" {
containersNames = append(containersNames, composeData.Services.Starknet.ContainerName)
}

outputData := ContainersData{}
outputData.Containers = make([]ContainerData, 0, len(containersNames))
Expand Down
4 changes: 4 additions & 0 deletions cli/actions/getContainers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
consensusNotFoundContainerName = "sedge-execution-client-nf"
validatorContainerName = "sedge-validator-client"
validatorNotFoundContainerName = "sedge-validator-client-nf"
starknetContainerName = "sedge-starknet-client"
starknetNotFoundContainerName = "sedge-starknet-client-nf"
mevBoostContainerName = "sedge-mev-boost"

executionContainerIp = "192.168.1.1"
Expand All @@ -51,6 +53,8 @@ const (
validatorContainerImage = "consensys/teku"
mevBoostContainerIp = "192.168.1.4"
mevBoostContainerImage = "flashbots/mev-boost"
starknetContainerIp = "192.168.1.5"
starknetContainerImage = "nethermind/juno"
Tomi-3-0 marked this conversation as resolved.
Show resolved Hide resolved

executionNotFoundErrorMsg = "execution container not found"
consensusNotFoundErrorMsg = "consensus container not found"
Expand Down
14 changes: 7 additions & 7 deletions cli/actions/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func TestSetupContainers(t *testing.T) {
name: "with services",
options: actions.SetupContainersOptions{
GenerationPath: filepath.Join("a", "b", "c", "d"),
Services: []string{"validator", "consensus", "execution"},
Services: []string{"validator", "consensus", "execution", "starknet"},
},
expectedBuildCmd: fmt.Sprintf("docker compose -f %s build validator consensus execution", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedPullCmd: fmt.Sprintf("docker compose -f %s pull validator consensus execution", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedCreateCmd: fmt.Sprintf("docker compose -f %s create validator consensus execution", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedBuildCmd: fmt.Sprintf("docker compose -f %s build validator consensus execution starknet", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedPullCmd: fmt.Sprintf("docker compose -f %s pull validator consensus execution starknet", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedCreateCmd: fmt.Sprintf("docker compose -f %s create validator consensus execution starknet", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
},
{
name: "without services",
Expand All @@ -58,12 +58,12 @@ func TestSetupContainers(t *testing.T) {
name: "skip-pull",
options: actions.SetupContainersOptions{
GenerationPath: filepath.Join("a", "b", "c", "d"),
Services: []string{"execution", "consensus"},
Services: []string{"execution", "consensus", "starknet"},
SkipPull: true,
},
expectedBuildCmd: fmt.Sprintf("docker compose -f %s build execution consensus", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedBuildCmd: fmt.Sprintf("docker compose -f %s build execution consensus starknet", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedPullCmd: "",
expectedCreateCmd: fmt.Sprintf("docker compose -f %s create execution consensus", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
expectedCreateCmd: fmt.Sprintf("docker compose -f %s create execution consensus starknet", filepath.Join("a", "b", "c", "d", "docker-compose.yml")),
},
}
for _, tc := range tests {
Expand Down
131 changes: 130 additions & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
NodeTypeExecution = "execution"
NodeTypeConsensus = "consensus"
NodeTypeValidator = "validator"
NodeTypeStarknet = "starknet"

Randomize = "randomize"

Expand All @@ -67,6 +68,7 @@ type CliCmdOptions struct {
generationPath string
nodeType string
withValidator bool
withFullL1Node bool
withMevBoost bool
importSlashingProtection bool
slashingProtectionFrom string
Expand Down Expand Up @@ -97,6 +99,7 @@ func CliCmd(p ui.Prompter, actions actions.SedgeActions, depsMgr dependencies.De
- Execution Node
- Consensus Node
- Validator Node
- Starknet Node

Follow the prompts to select the options you want for your node. At the end of the process, you will
be asked to run the generated setup or not. If you chose to run the setup, it will be executed for you
Expand All @@ -120,6 +123,8 @@ using docker compose command behind the scenes.
return setupConsensusNode(p, o, actions, depsMgr)
case NodeTypeValidator:
return setupValidatorNode(p, o, actions, depsMgr)
case NodeTypeStarknet:
return setupStarknetNode(p, o, actions, depsMgr)
}
return nil
},
Expand Down Expand Up @@ -313,6 +318,61 @@ func setupValidatorNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions,
return postGenerate(p, o, a, depsManager)
}

// setup a starknet node
func setupStarknetNode(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, depsManager dependencies.DependenciesManager) (err error) {
o.genData.Services = []string{"starknet"}
if err := selectStarknetClient(p, o); err != nil {
return err
}
if err := confirmWithFullStarknetNode(p, o); err != nil {
return err
}
if o.genData.Network == NetworkCustom {
if err := runPromptActions(p, o,
inputCustomNetworkConfig,
inputCustomChainSpec,
inputCustomGenesis,
inputCustomDeployBlock,
); err != nil {
return err
}
}
if o.withFullL1Node {
o.genData.Services = append(o.genData.Services, "execution", "consensus")

if err := runPromptActions(p, o,
selectExecutionClient,
selectConsensusClient,
inputStarknetGracePeriod,
inputCheckpointSyncURL,
inputFeeRecipientNoValidator,
); err != nil {
return err
}
} else {
if err := runPromptActions(p, o,
inputEthNode,
); err != nil {
return err
}
}
if err := confirmExposeAllPorts(p, o); err != nil {
return err
}
if err := setupJWT(p, o, false); err != nil {
return err
}
// Call generate action
o.genData, err = a.Generate(actions.GenerateOptions{
GenerationData: o.genData,
GenerationPath: o.generationPath,
})
if err != nil {
return err
}
return postGenerate(p, o, a, depsManager)
}

func setupJWT(p ui.Prompter, o *CliCmdOptions, skip bool) error {
if skip {
if err := selectJWTSourceOrSkip(p, o); err != nil {
Expand Down Expand Up @@ -361,6 +421,8 @@ func postGenerate(p ui.Prompter, o *CliCmdOptions, a actions.SedgeActions, depsM
services = []string{"consensus"}
case NodeTypeValidator:
services = []string{"validator"}
case NodeTypeStarknet:
services = []string{"starknet"}
}
run, err := p.Confirm("Run services now?", false)
if err != nil {
Expand Down Expand Up @@ -615,6 +677,11 @@ func runPromptActions(p ui.Prompter, o *CliCmdOptions, actions ...promptAction)
return nil
}

// check if network is mainnet or sepolia for starknet
func networkNotMainnetOrSepolia(o *CliCmdOptions) bool {
return o.genData.Network != NetworkMainnet && o.genData.Network != NetworkSepolia
}

func selectNetwork(p ui.Prompter, o *CliCmdOptions) error {
options := []string{NetworkMainnet, NetworkGoerli, NetworkSepolia, NetworkGnosis, NetworkChiado, NetworkHolesky}
index, err := p.Select("Select network", "", options)
Expand All @@ -625,8 +692,22 @@ func selectNetwork(p ui.Prompter, o *CliCmdOptions) error {
return nil
}

func removeFromNodeType(options []string, optionToRemove string) []string {
newSlice := make([]string, 0)
for _, item := range options {
if item != optionToRemove {
newSlice = append(newSlice, item)
}
}
return newSlice
}

func selectNodeType(p ui.Prompter, o *CliCmdOptions) error {
options := []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator}
options := []string{NodeTypeFullNode, NodeTypeExecution, NodeTypeConsensus, NodeTypeValidator, NodeTypeStarknet}
// check if mainnet or goerli was selected, if not omit starknet
if networkNotMainnetOrSepolia(o) {
options = removeFromNodeType(options, NodeTypeStarknet)
}
index, err := p.Select("Select node type", "", options)
if err != nil {
return err
Expand Down Expand Up @@ -722,6 +803,35 @@ func selectValidatorClient(p ui.Prompter, o *CliCmdOptions) (err error) {
return nil
}

func selectStarknetClient(p ui.Prompter, o *CliCmdOptions) (err error) {
c := clients.ClientInfo{Network: o.genData.Network}
supportedClients, err := c.SupportedClients(starknet)
if err != nil {
return err
}
options := append(supportedClients, Randomize)
index, err := p.Select("Select starknet client", "", options)
if err != nil {
return err
}
selectedStarknetClient := options[index]
// In case random is selected, select a random client
if selectedStarknetClient == Randomize {
randomName, err := clients.RandomClientName(supportedClients)
if err != nil {
return err
}
selectedStarknetClient = randomName
log.Info("Random starknet client selected: ", selectedStarknetClient)
}
o.genData.StarknetClient = &clients.Client{
Name: selectedStarknetClient,
Type: "starknet",
}
o.genData.StarknetClient.SetImageOrDefault("")
return nil
}

func selectJWTSource(p ui.Prompter, o *CliCmdOptions) error {
options := []string{SourceTypeCreate, SourceTypeExisting}
index, err := p.Select("Select JWT source", "", options)
Expand Down Expand Up @@ -777,6 +887,11 @@ func confirmWithValidator(p ui.Prompter, o *CliCmdOptions) (err error) {
return
}

func confirmWithFullStarknetNode(p ui.Prompter, o *CliCmdOptions) (err error) {
o.withFullL1Node, err = p.Confirm("Do you want to set up a full starknet node (with execution and consensus)?", true)
return
}

func confirmExposeAllPorts(p ui.Prompter, o *CliCmdOptions) (err error) {
o.genData.MapAllPorts, err = p.Confirm("Do you want to expose all ports?", false)
return
Expand Down Expand Up @@ -889,6 +1004,15 @@ func inputValidatorGracePeriod(p ui.Prompter, o *CliCmdOptions) (err error) {
return nil
}

func inputStarknetGracePeriod(p ui.Prompter, o *CliCmdOptions) (err error) {
epochs, err := p.InputInt64("Starknet grace period. This is the number of epochs the starknet client will wait before starting", 1)
if err != nil {
return err
}
o.genData.SLStartGracePeriod = uint((configs.NetworkEpochTime(o.genData.Network) * time.Duration(epochs)).Seconds())
return nil
}

func inputGenerationPath(p ui.Prompter, o *CliCmdOptions) (err error) {
o.generationPath, err = p.Input("Generation path", configs.DefaultAbsSedgeDataPath, false, nil)
if err != nil {
Expand Down Expand Up @@ -980,6 +1104,11 @@ func inputContainerTag(p ui.Prompter, o *CliCmdOptions) (err error) {
return
}

func inputEthNode(p ui.Prompter, o *CliCmdOptions) (err error) {
o.genData.ExecutionApiUrl, err = p.InputURL("Input Eth 1 Endpoint", "", true)
return
}

func absPathInPlace(path *string) error {
absPath, err := filepath.Abs(*path)
if err != nil {
Expand Down
Loading
Loading