Skip to content

Commit 5a4ab97

Browse files
committed
Add gnosis-access-node subcommand boilerplate
1 parent 313f2b3 commit 5a4ab97

File tree

8 files changed

+200
-0
lines changed

8 files changed

+200
-0
lines changed

rolling-shutter/cmd/command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/chain"
88
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/collator"
99
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/cryptocmd"
10+
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/gnosisaccessnode"
1011
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/gnosiskeyper"
1112
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/mocknode"
1213
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/mocksequencer"
@@ -31,6 +32,7 @@ func Subcommands() []*cobra.Command {
3132
snapshot.Cmd(),
3233
snapshotkeyper.Cmd(),
3334
gnosiskeyper.Cmd(),
35+
gnosisaccessnode.Cmd(),
3436
cryptocmd.Cmd(),
3537
proxy.Cmd(),
3638
mocksequencer.Cmd(),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package gnosisaccessnode
2+
3+
import (
4+
"context"
5+
6+
"github.com/rs/zerolog/log"
7+
"github.com/spf13/cobra"
8+
9+
"github.com/shutter-network/rolling-shutter/rolling-shutter/cmd/shversion"
10+
"github.com/shutter-network/rolling-shutter/rolling-shutter/gnosisaccessnode"
11+
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/configuration/command"
12+
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
13+
)
14+
15+
func Cmd() *cobra.Command {
16+
builder := command.Build(
17+
main,
18+
command.Usage(
19+
"Run an access node for the keyper network of Shutterized Gnosis Chain",
20+
`This command runs a node that only relays messages, but doesn't create any on
21+
its own. It is intended to be a stable node to connect to to receive messages.`,
22+
),
23+
command.WithGenerateConfigSubcommand(),
24+
command.WithDumpConfigSubcommand(),
25+
)
26+
return builder.Command()
27+
}
28+
29+
func main(config *gnosisaccessnode.Config) error {
30+
log.Info().
31+
Str("version", shversion.Version()).
32+
Msg("starting access node")
33+
34+
accessNode := gnosisaccessnode.New(config)
35+
return service.RunWithSighandler(context.Background(), accessNode)
36+
}

rolling-shutter/docs/rolling-shutter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A collection of commands to run and interact with Rolling Shutter nodes
1717
* [rolling-shutter chain](rolling-shutter_chain.md) - Run a node for Shutter's Tendermint chain
1818
* [rolling-shutter collator](rolling-shutter_collator.md) - Run a collator node
1919
* [rolling-shutter crypto](rolling-shutter_crypto.md) - CLI tool to access crypto functions
20+
* [rolling-shutter gnosis-access-node](rolling-shutter_gnosis-access-node.md) - Run an access node for the keyper network of Shutterized Gnosis Chain
2021
* [rolling-shutter gnosiskeyper](rolling-shutter_gnosiskeyper.md) - Run a Shutter keyper for Gnosis Chain
2122
* [rolling-shutter keyper](rolling-shutter_keyper.md) - Run a Shutter keyper node
2223
* [rolling-shutter mocknode](rolling-shutter_mocknode.md) - Run a Shutter mock node
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## rolling-shutter gnosis-access-node
2+
3+
Run an access node for the keyper network of Shutterized Gnosis Chain
4+
5+
### Synopsis
6+
7+
This command runs a node that only relays messages, but doesn't create any on
8+
its own. It is intended to be a stable node to connect to to receive messages.
9+
10+
```
11+
rolling-shutter gnosis-access-node [flags]
12+
```
13+
14+
### Options
15+
16+
```
17+
--config string config file
18+
-h, --help help for gnosis-access-node
19+
```
20+
21+
### Options inherited from parent commands
22+
23+
```
24+
--logformat string set log format, possible values: min, short, long, max (default "long")
25+
--loglevel string set log level, possible values: warn, info, debug (default "info")
26+
--no-color do not write colored logs
27+
```
28+
29+
### SEE ALSO
30+
31+
* [rolling-shutter](rolling-shutter.md) - A collection of commands to run and interact with Rolling Shutter nodes
32+
* [rolling-shutter gnosis-access-node dump-config](rolling-shutter_gnosis-access-node_dump-config.md) - Dump a 'gnosis-access-node' configuration file, based on given config and env vars
33+
* [rolling-shutter gnosis-access-node generate-config](rolling-shutter_gnosis-access-node_generate-config.md) - Generate a 'gnosis-access-node' configuration file
34+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## rolling-shutter gnosis-access-node dump-config
2+
3+
Dump a 'gnosis-access-node' configuration file, based on given config and env vars
4+
5+
```
6+
rolling-shutter gnosis-access-node dump-config [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
--config string config file
13+
-h, --help help for dump-config
14+
--output string output file
15+
```
16+
17+
### Options inherited from parent commands
18+
19+
```
20+
--logformat string set log format, possible values: min, short, long, max (default "long")
21+
--loglevel string set log level, possible values: warn, info, debug (default "info")
22+
--no-color do not write colored logs
23+
```
24+
25+
### SEE ALSO
26+
27+
* [rolling-shutter gnosis-access-node](rolling-shutter_gnosis-access-node.md) - Run an access node for the keyper network of Shutterized Gnosis Chain
28+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## rolling-shutter gnosis-access-node generate-config
2+
3+
Generate a 'gnosis-access-node' configuration file
4+
5+
```
6+
rolling-shutter gnosis-access-node generate-config [flags]
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for generate-config
13+
--output string output file
14+
```
15+
16+
### Options inherited from parent commands
17+
18+
```
19+
--config string config file
20+
--logformat string set log format, possible values: min, short, long, max (default "long")
21+
--loglevel string set log level, possible values: warn, info, debug (default "info")
22+
--no-color do not write colored logs
23+
```
24+
25+
### SEE ALSO
26+
27+
* [rolling-shutter gnosis-access-node](rolling-shutter_gnosis-access-node.md) - Run an access node for the keyper network of Shutterized Gnosis Chain
28+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package gnosisaccessnode
2+
3+
import (
4+
"io"
5+
6+
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/metricsserver"
7+
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2p"
8+
)
9+
10+
type Config struct {
11+
InstanceID uint64
12+
13+
P2P *p2p.Config
14+
Metrics *metricsserver.MetricsConfig
15+
16+
MaxNumKeysPerMessage uint64
17+
}
18+
19+
func (c *Config) Init() {
20+
c.P2P = p2p.NewConfig()
21+
c.Metrics = metricsserver.NewConfig()
22+
}
23+
24+
func (c *Config) Name() string {
25+
return "gnosis-access-node"
26+
}
27+
28+
func (c *Config) Validate() error {
29+
if err := c.P2P.Validate(); err != nil {
30+
return err
31+
}
32+
if err := c.Metrics.Validate(); err != nil {
33+
return err
34+
}
35+
return nil
36+
}
37+
38+
func (c *Config) SetDefaultValues() error {
39+
return nil
40+
}
41+
42+
func (c *Config) SetExampleValues() error { //nolint:unparam
43+
c.InstanceID = 1000
44+
c.MaxNumKeysPerMessage = 500
45+
return nil
46+
}
47+
48+
func (c *Config) TOMLWriteHeader(_ io.Writer) (int, error) {
49+
return 0, nil
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package gnosisaccessnode
2+
3+
import (
4+
"context"
5+
6+
"github.com/shutter-network/rolling-shutter/rolling-shutter/medley/service"
7+
)
8+
9+
type GnosisAccessNode struct {
10+
config *Config
11+
}
12+
13+
func New(config *Config) *GnosisAccessNode {
14+
return &GnosisAccessNode{
15+
config: config,
16+
}
17+
}
18+
19+
func (node *GnosisAccessNode) Start(ctx context.Context, runner service.Runner) error {
20+
return nil
21+
}

0 commit comments

Comments
 (0)