Setup essential Nitro config
This commit is contained in:
parent
1af95d35ab
commit
b205f31605
@ -35,3 +35,21 @@ func addDatabaseFlags(command *cobra.Command) {
|
||||
viper.BindPFlag("database.user", command.PersistentFlags().Lookup("database-user"))
|
||||
viper.BindPFlag("database.password", command.PersistentFlags().Lookup("database-password"))
|
||||
}
|
||||
|
||||
func addNitroFlags(command *cobra.Command) {
|
||||
// nitro flags
|
||||
command.PersistentFlags().String("nitro-pk", "", "nitro pk")
|
||||
command.PersistentFlags().String("nitro-chainPk", "", "nitro chainPk")
|
||||
command.PersistentFlags().String("nitro-chainUrl", "", "nitro chainUrl")
|
||||
command.PersistentFlags().String("nitro-naAddress", "", "nitro naAddress")
|
||||
command.PersistentFlags().String("nitro-vpaAddress", "", "nitro vpaAddress")
|
||||
command.PersistentFlags().String("nitro-caAddress", "", "nitro caAddress")
|
||||
|
||||
// nitro flag bindings
|
||||
viper.BindPFlag("nitro.pk", command.PersistentFlags().Lookup("nitro-pk"))
|
||||
viper.BindPFlag("nitro.chainPk", command.PersistentFlags().Lookup("nitro-chainPk"))
|
||||
viper.BindPFlag("nitro.chainUrl", command.PersistentFlags().Lookup("nitro-chainUrl"))
|
||||
viper.BindPFlag("nitro.naAddress", command.PersistentFlags().Lookup("nitro-naAddress"))
|
||||
viper.BindPFlag("nitro.vpaAddress", command.PersistentFlags().Lookup("nitro-vpaAddress"))
|
||||
viper.BindPFlag("nitro.caAddress", command.PersistentFlags().Lookup("nitro-caAddress"))
|
||||
}
|
||||
|
18
cmd/serve.go
18
cmd/serve.go
@ -85,7 +85,7 @@ func serve() {
|
||||
server.Serve(wg)
|
||||
|
||||
// TODO: Create required config for Nitro node
|
||||
nitroNode, err := initializeNitroNode()
|
||||
nitroNode, err := initializeNitroNode(serverConfig.Nitro)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -290,6 +290,8 @@ func init() {
|
||||
|
||||
addDatabaseFlags(serveCmd)
|
||||
|
||||
addNitroFlags(serveCmd)
|
||||
|
||||
// flags for all config variables
|
||||
// eth graphql and json-rpc parameters
|
||||
serveCmd.PersistentFlags().Bool("server-graphql", false, "turn on the eth graphql server")
|
||||
@ -370,19 +372,19 @@ func init() {
|
||||
viper.BindPFlag("validator.everyNthBlock", serveCmd.PersistentFlags().Lookup("validator-every-nth-block"))
|
||||
}
|
||||
|
||||
func initializeNitroNode() (*nitroNode.Node, error) {
|
||||
func initializeNitroNode(nitroConfig *s.NitroConfig) (*nitroNode.Node, error) {
|
||||
// TODO: Configure
|
||||
pkString := ""
|
||||
pkString := nitroConfig.Pk
|
||||
useDurableStore := true
|
||||
durableStoreFolder := "./data/nitro-store"
|
||||
msgPort := 3005
|
||||
wsMsgPort := 5005
|
||||
chainUrl := "ws://127.0.0.1:8545"
|
||||
chainUrl := nitroConfig.ChainUrl
|
||||
chainStartBlock := uint64(0)
|
||||
chainPk := ""
|
||||
naAddress := ""
|
||||
vpaAddress := ""
|
||||
caAddress := ""
|
||||
chainPk := nitroConfig.ChainPk
|
||||
naAddress := nitroConfig.NaAddress
|
||||
vpaAddress := nitroConfig.VpaAddress
|
||||
caAddress := nitroConfig.CaAddress
|
||||
|
||||
chainAuthToken := ""
|
||||
publicIp := "0.0.0.0"
|
||||
|
4
go.mod
4
go.mod
@ -11,7 +11,6 @@ require (
|
||||
github.com/ethereum/go-ethereum v1.12.0 // TODO: Investigate
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/graph-gophers/graphql-go v1.3.0
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/jmoiron/sqlx v1.3.5
|
||||
github.com/joho/godotenv v1.4.0
|
||||
@ -92,6 +91,7 @@ require (
|
||||
github.com/hashicorp/go-bexpr v0.1.12 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
|
||||
github.com/holiman/uint256 v1.2.3 // indirect
|
||||
@ -300,4 +300,4 @@ replace (
|
||||
github.com/cerc-io/ipfs-ethdb/v5 => git.vdb.to/deep-stack/ipfs-ethdb/v5 v5.0.1-alpha.0.20231003124335-b6cf70668a07
|
||||
)
|
||||
|
||||
replace github.com/statechannels/go-nitro v0.1.1 => github.com/cerc-io/go-nitro v0.1.2-0.20231012043644-1b31b5133214
|
||||
replace github.com/statechannels/go-nitro v0.1.1 => github.com/cerc-io/go-nitro v0.1.2-0.20231012062355-dc2cb28411a5
|
||||
|
4
go.sum
4
go.sum
@ -116,8 +116,8 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/ceramicnetwork/go-dag-jose v0.1.0 h1:yJ/HVlfKpnD3LdYP03AHyTvbm3BpPiz2oZiOeReJRdU=
|
||||
github.com/ceramicnetwork/go-dag-jose v0.1.0/go.mod h1:qYA1nYt0X8u4XoMAVoOV3upUVKtrxy/I670Dg5F0wjI=
|
||||
github.com/cerc-io/go-nitro v0.1.2-0.20231012043644-1b31b5133214 h1:nrkG2Rym9jOpIFD9MyVLTkfrxyG3Uf0ibusIHeQDKQk=
|
||||
github.com/cerc-io/go-nitro v0.1.2-0.20231012043644-1b31b5133214/go.mod h1:gkKL37JcSo54ybLTI6VJRmP75bWEu9i1kc9RYmQLp+I=
|
||||
github.com/cerc-io/go-nitro v0.1.2-0.20231012062355-dc2cb28411a5 h1:wMrhik+HPv/cdhyWL0nUImZ0XGFZ0el4eSY7QjwH0aA=
|
||||
github.com/cerc-io/go-nitro v0.1.2-0.20231012062355-dc2cb28411a5/go.mod h1:gkKL37JcSo54ybLTI6VJRmP75bWEu9i1kc9RYmQLp+I=
|
||||
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
||||
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
|
@ -81,6 +81,15 @@ const (
|
||||
DATABASE_MAX_CONN_LIFETIME = "DATABASE_MAX_CONN_LIFETIME"
|
||||
)
|
||||
|
||||
type NitroConfig struct {
|
||||
Pk string
|
||||
ChainPk string
|
||||
ChainUrl string
|
||||
NaAddress string
|
||||
VpaAddress string
|
||||
CaAddress string
|
||||
}
|
||||
|
||||
// Config struct
|
||||
type Config struct {
|
||||
DB *sqlx.DB
|
||||
@ -116,6 +125,8 @@ type Config struct {
|
||||
|
||||
StateValidationEnabled bool
|
||||
StateValidationEveryNthBlock uint64
|
||||
|
||||
Nitro *NitroConfig
|
||||
}
|
||||
|
||||
// NewConfig is used to initialize a watcher config from a .toml file
|
||||
@ -248,6 +259,8 @@ func NewConfig() (*Config, error) {
|
||||
|
||||
c.loadValidatorConfig()
|
||||
|
||||
c.loadNitroConfig()
|
||||
|
||||
return c, err
|
||||
}
|
||||
|
||||
@ -280,6 +293,17 @@ func (c *Config) dbInit() {
|
||||
c.DBConfig.MaxConnLifetime = time.Duration(viper.GetInt("database.maxLifetime"))
|
||||
}
|
||||
|
||||
func (c *Config) loadNitroConfig() {
|
||||
c.Nitro = &NitroConfig{}
|
||||
|
||||
c.Nitro.Pk = viper.GetString("nitro.pk")
|
||||
c.Nitro.ChainPk = viper.GetString("nitro.chainPk")
|
||||
c.Nitro.ChainUrl = viper.GetString("nitro.chainUrl")
|
||||
c.Nitro.NaAddress = viper.GetString("nitro.naAddress")
|
||||
c.Nitro.VpaAddress = viper.GetString("nitro.vpaAddress")
|
||||
c.Nitro.CaAddress = viper.GetString("nitro.caAddress")
|
||||
}
|
||||
|
||||
func (c *Config) loadGroupCacheConfig() {
|
||||
viper.BindEnv("groupcache.pool.enabled", ethServerShared.GcachePoolEnabled)
|
||||
viper.BindEnv("groupcache.pool.httpEndpoint", ethServerShared.GcachePoolHttpPath)
|
||||
|
Loading…
Reference in New Issue
Block a user