Skip to content

Commit

Permalink
add flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rian committed May 20, 2024
1 parent c4b6718 commit d886635
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
44 changes: 24 additions & 20 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const (
corsEnableF = "rpc-cors-enable"
seqEnF = "seq-enable"
seqBlockTimeF = "seq-block-time"
seqBootstrapToBlockF = "seq-bootstrap-to-block"
genesisFileF = "genesis-file"

defaultConfig = ""
Expand Down Expand Up @@ -122,6 +123,7 @@ const (
defaultCorsEnable = false
defaultSeqEn = false
defaultSeqBlockTime = 60
defaultSeqBootstrapToBlock = 0
defaultGenesisFile = ""

configFlagUsage = "The YAML configuration file."
Expand Down Expand Up @@ -154,26 +156,27 @@ const (
"These peers can be either Feeder or regular nodes."
p2pFeederNodeUsage = "EXPERIMENTAL: Run juno as a feeder node which will only sync from feeder gateway and gossip the new" +
" blocks to the network."
p2pPrivateKeyUsage = "EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve."
metricsUsage = "Enables the Prometheus metrics endpoint on the default port."
metricsHostUsage = "The interface on which the Prometheus endpoint will listen for requests."
metricsPortUsage = "The port on which the Prometheus endpoint will listen for requests."
grpcUsage = "Enable the HTTP gRPC server on the default port."
grpcHostUsage = "The interface on which the gRPC server will listen for requests."
grpcPortUsage = "The port on which the gRPC server will listen for requests."
maxVMsUsage = "Maximum number for VM instances to be used for RPC calls concurrently"
maxVMQueueUsage = "Maximum number for requests to queue after reaching max-vms before starting to reject incoming requests"
remoteDBUsage = "gRPC URL of a remote Juno node"
rpcMaxBlockScanUsage = "Maximum number of blocks scanned in single starknet_getEvents call"
dbCacheSizeUsage = "Determines the amount of memory (in megabytes) allocated for caching data in the database."
dbMaxHandlesUsage = "A soft limit on the number of open files that can be used by the DB"
gwAPIKeyUsage = "API key for gateway endpoints to avoid throttling" //nolint: gosec
gwTimeoutUsage = "Timeout for requests made to the gateway" //nolint: gosec
callMaxStepsUsage = "Maximum number of steps to be executed in starknet_call requests"
corsEnableUsage = "Enable CORS on RPC endpoints"
seqEnUsage = "Enables sequencer mode of operation"
seqBlockTimeUsage = "Time to build a block, in seconds"
genesisFileUsage = "Path to the genesis file"
p2pPrivateKeyUsage = "EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve."
metricsUsage = "Enables the Prometheus metrics endpoint on the default port."
metricsHostUsage = "The interface on which the Prometheus endpoint will listen for requests."
metricsPortUsage = "The port on which the Prometheus endpoint will listen for requests."
grpcUsage = "Enable the HTTP gRPC server on the default port."
grpcHostUsage = "The interface on which the gRPC server will listen for requests."
grpcPortUsage = "The port on which the gRPC server will listen for requests."
maxVMsUsage = "Maximum number for VM instances to be used for RPC calls concurrently"
maxVMQueueUsage = "Maximum number for requests to queue after reaching max-vms before starting to reject incoming requests"
remoteDBUsage = "gRPC URL of a remote Juno node"
rpcMaxBlockScanUsage = "Maximum number of blocks scanned in single starknet_getEvents call"
dbCacheSizeUsage = "Determines the amount of memory (in megabytes) allocated for caching data in the database."
dbMaxHandlesUsage = "A soft limit on the number of open files that can be used by the DB"
gwAPIKeyUsage = "API key for gateway endpoints to avoid throttling" //nolint: gosec
gwTimeoutUsage = "Timeout for requests made to the gateway" //nolint: gosec
callMaxStepsUsage = "Maximum number of steps to be executed in starknet_call requests"
corsEnableUsage = "Enable CORS on RPC endpoints"
seqEnUsage = "Enables sequencer mode of operation"
seqBlockTimeUsage = "Time to build a block, in seconds"
seqBootstrapToBlockUsage = "How many blocks to sycn from network before running sequencer"
genesisFileUsage = "Path to the genesis file"
)

var Version string
Expand Down Expand Up @@ -357,6 +360,7 @@ func NewCmd(config *node.Config, run func(*cobra.Command, []string) error) *cobr
junoCmd.AddCommand(GenP2PKeyPair())
junoCmd.Flags().Bool(seqEnF, defaultSeqEn, seqEnUsage)
junoCmd.Flags().Uint(seqBlockTimeF, defaultSeqBlockTime, seqBlockTimeUsage)
junoCmd.Flags().Uint(seqBootstrapToBlockF, defaultSeqBootstrapToBlock, seqBootstrapToBlockUsage)
junoCmd.Flags().String(genesisFileF, defaultGenesisFile, genesisFileUsage)

return junoCmd
Expand Down
9 changes: 5 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ type Config struct {
GatewayAPIKey string `mapstructure:"gw-api-key"`
GatewayTimeout time.Duration `mapstructure:"gw-timeout"`

Sequencer bool `mapstructure:"seq-enable"`
SeqBlockTime uint `mapstructure:"seq-block-time"`
GenesisFile string `mapstructure:"genesis-file"`
Sequencer bool `mapstructure:"seq-enable"`
SeqBlockTime uint `mapstructure:"seq-block-time"`
SeqBootstrapToBlock uint64 `mapstructure:"seq-bootstrap-to-block"`
GenesisFile string `mapstructure:"genesis-file"`
}

type Node struct {
Expand Down Expand Up @@ -163,7 +164,7 @@ func New(cfg *Config, version string) (*Node, error) { //nolint:gocyclo,funlen
poolDB, _ := pebble.NewMem()
p := mempool.New(poolDB)
sequencer := builder.New(pKey, new(felt.Felt).SetUint64(1337), chain, nodeVM, time.Second*time.Duration(cfg.SeqBlockTime), p, //nolint: gomnd,lll
log).WithBootstrap(true).WithStarknetData(starknetData).WithBootstrapToBlock(2)
log).WithBootstrap(true).WithStarknetData(starknetData).WithBootstrapToBlock(cfg.SeqBootstrapToBlock)
rpcHandler = rpc.New(chain, sequencer, throttledVM, version, &cfg.Network, log).WithMempool(p)
services = append(services, sequencer)
} else {
Expand Down

0 comments on commit d886635

Please sign in to comment.