Integrate go-nitro node for payments (#256)

Part of [Support running go-nitro node in/out of process in ipld-eth-server](https://www.notion.so/Support-running-go-nitro-node-in-out-of-process-in-ipld-eth-server-f592e29f0e5b474aa65db1509e5ddf1b)

- Added in-process go-nitro node support
- To be handled in upcoming PRs:
  - Out of process go-nitro node support to be added in an upcoming PR
  - Refactoring and remaining todos

Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: cerc-io/ipld-eth-server#256
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
This commit is contained in:
2023-10-13 09:03:09 +00:00
committed by ashwin
co-authored by prathamesh
parent a295e7d4b2
commit ebaacb3733
8 changed files with 272 additions and 11 deletions
+46
View File
@@ -79,8 +79,28 @@ const (
DATABASE_MAX_IDLE_CONNECTIONS = "DATABASE_MAX_IDLE_CONNECTIONS"
DATABASE_MAX_OPEN_CONNECTIONS = "DATABASE_MAX_OPEN_CONNECTIONS"
DATABASE_MAX_CONN_LIFETIME = "DATABASE_MAX_CONN_LIFETIME"
NITRO_PK = "NITRO_PK"
NITRO_CHAIN_PK = "NITRO_CHAIN_PK"
NITRO_CHAIN_URL = "NITRO_CHAIN_URL"
NITRO_NA_ADDRESS = "NITRO_NA_ADDRESS"
NITRO_VPA_ADDRESS = "NITRO_VPA_ADDRESS"
NITRO_CA_ADDRESS = "NITRO_CA_ADDRESS"
NITRO_USE_DURABLE_STORE = "NITRO_USE_DURABLE_STORE"
NITRO_DURABLE_STORE_FOLDER = "NITRO_DURABLE_STORE_FOLDER"
)
type NitroConfig struct {
Pk string
ChainPk string
ChainUrl string
NaAddress string
VpaAddress string
CaAddress string
UseDurableStore bool
DurableStoreFolder string
}
// Config struct
type Config struct {
DB *sqlx.DB
@@ -116,6 +136,8 @@ type Config struct {
StateValidationEnabled bool
StateValidationEveryNthBlock uint64
Nitro *NitroConfig
}
// NewConfig is used to initialize a watcher config from a .toml file
@@ -248,6 +270,8 @@ func NewConfig() (*Config, error) {
c.loadValidatorConfig()
c.loadNitroConfig()
return c, err
}
@@ -280,6 +304,28 @@ func (c *Config) dbInit() {
c.DBConfig.MaxConnLifetime = time.Duration(viper.GetInt("database.maxLifetime"))
}
func (c *Config) loadNitroConfig() {
c.Nitro = &NitroConfig{}
viper.BindEnv("nitro.pk", NITRO_PK)
viper.BindEnv("nitro.chainPk", NITRO_CHAIN_PK)
viper.BindEnv("nitro.chainUrl", NITRO_CHAIN_URL)
viper.BindEnv("nitro.naAddress", NITRO_NA_ADDRESS)
viper.BindEnv("nitro.vpaAddress", NITRO_VPA_ADDRESS)
viper.BindEnv("nitro.caAddress", NITRO_CA_ADDRESS)
viper.BindEnv("nitro.useDurableStore", NITRO_USE_DURABLE_STORE)
viper.BindEnv("nitro.durableStoreFolder", NITRO_DURABLE_STORE_FOLDER)
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")
c.Nitro.UseDurableStore = viper.GetBool("nitro.useDurableStore")
c.Nitro.DurableStoreFolder = viper.GetString("nitro.durableStoreFolder")
}
func (c *Config) loadGroupCacheConfig() {
viper.BindEnv("groupcache.pool.enabled", ethServerShared.GcachePoolEnabled)
viper.BindEnv("groupcache.pool.httpEndpoint", ethServerShared.GcachePoolHttpPath)