Update Nitro node initialization
This commit is contained in:
parent
ebaacb3733
commit
fe1f4718e2
40
cmd/serve.go
40
cmd/serve.go
@ -16,6 +16,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -35,10 +36,9 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
"github.com/statechannels/go-nitro/node/engine"
|
||||
"github.com/statechannels/go-nitro/node/engine/chainservice"
|
||||
"github.com/statechannels/go-nitro/node/engine/store"
|
||||
nitroStore "github.com/statechannels/go-nitro/node/engine/store"
|
||||
"github.com/statechannels/go-nitro/paymentsmanager"
|
||||
"github.com/statechannels/go-nitro/rpc/transport"
|
||||
"github.com/tidwall/buntdb"
|
||||
"golang.org/x/exp/slog"
|
||||
|
||||
"github.com/cerc-io/ipld-eth-server/v5/pkg/graphql"
|
||||
@ -114,7 +114,15 @@ func serve() {
|
||||
|
||||
// TODO: Read from config file
|
||||
rpcPort := 4005
|
||||
nitroRpcServer, err := initializeNitroRpcServer(nitroNode, rpcPort)
|
||||
tlsCertFilepath := "./nitroTLS/statechannels.org.pem"
|
||||
tlsKeyFilepath := "./nitroTLS/statechannels.org_key.pem"
|
||||
|
||||
cert, err := tls.LoadX509KeyPair(tlsCertFilepath, tlsKeyFilepath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
nitroRpcServer, err := initializeNitroRpcServer(nitroNode, pm, &cert, rpcPort)
|
||||
if err != nil {
|
||||
logWithCommand.Fatal(err)
|
||||
}
|
||||
@ -418,14 +426,28 @@ func initializeNitroNode(nitroConfig *s.NitroConfig) (*nitroNode.Node, error) {
|
||||
CaAddress: common.HexToAddress(caAddress),
|
||||
}
|
||||
|
||||
ourStore, err := store.NewStore(common.Hex2Bytes(pkString), useDurableStore, durableStoreFolder, buntdb.Config{})
|
||||
storeOpts := nitroStore.StoreOpts{
|
||||
PkBytes: common.Hex2Bytes(pkString),
|
||||
UseDurableStore: useDurableStore,
|
||||
DurableStoreFolder: durableStoreFolder,
|
||||
}
|
||||
|
||||
bootPeers := []string{}
|
||||
messageOpts := nitrop2pms.MessageOpts{
|
||||
PkBytes: common.Hex2Bytes(pkString),
|
||||
TcpPort: msgPort,
|
||||
WsMsgPort: wsMsgPort,
|
||||
BootPeers: bootPeers,
|
||||
PublicIp: publicIp,
|
||||
}
|
||||
|
||||
ourStore, err := nitroStore.NewStore(storeOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bootPeers := []string{}
|
||||
log.Info("Initializing message service...", " tcp port=", msgPort, " web socket port=", wsMsgPort)
|
||||
messageService := nitrop2pms.NewMessageService(publicIp, msgPort, wsMsgPort, *ourStore.GetAddress(), common.Hex2Bytes(pkString), bootPeers)
|
||||
messageService := nitrop2pms.NewMessageService(messageOpts)
|
||||
|
||||
// Compare chainOpts.ChainStartBlock to lastBlockNum seen in store. The larger of the two
|
||||
// gets passed as an argument when creating NewEthChainService
|
||||
@ -453,17 +475,17 @@ func initializeNitroNode(nitroConfig *s.NitroConfig) (*nitroNode.Node, error) {
|
||||
return &node, nil
|
||||
}
|
||||
|
||||
func initializeNitroRpcServer(node *nitroNode.Node, rpcPort int) (*nitroRpc.RpcServer, error) {
|
||||
func initializeNitroRpcServer(node *nitroNode.Node, pm paymentsmanager.PaymentsManager, cert *tls.Certificate, rpcPort int) (*nitroRpc.RpcServer, error) {
|
||||
var transport transport.Responder
|
||||
var err error
|
||||
|
||||
slog.Info("Initializing Nitro HTTP RPC transport...")
|
||||
transport, err = nitroHttpTransport.NewHttpTransportAsServer(fmt.Sprint(rpcPort))
|
||||
transport, err = nitroHttpTransport.NewHttpTransportAsServer(fmt.Sprint(rpcPort), cert)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcServer, err := nitroRpc.NewRpcServer(node, transport)
|
||||
rpcServer, err := nitroRpc.NewRpcServer(pm, node, transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
4
go.mod
4
go.mod
@ -24,7 +24,6 @@ require (
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/spf13/viper v1.11.0
|
||||
github.com/statechannels/go-nitro v0.1.1
|
||||
github.com/tidwall/buntdb v1.2.10
|
||||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
|
||||
gorm.io/driver/postgres v1.3.7
|
||||
gorm.io/gorm v1.23.5
|
||||
@ -235,6 +234,7 @@ require (
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
|
||||
github.com/thoas/go-funk v0.9.3 // indirect
|
||||
github.com/tidwall/btree v1.6.0 // indirect
|
||||
github.com/tidwall/buntdb v1.2.10 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/tidwall/grect v0.1.4 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
@ -302,4 +302,4 @@ replace (
|
||||
github.com/cerc-io/ipfs-ethdb/v5 => github.com/cerc-io/ipfs-ethdb/v5 v5.0.1-alpha.0.20231013070931-0b1a36562a28
|
||||
)
|
||||
|
||||
replace github.com/statechannels/go-nitro v0.1.1 => github.com/cerc-io/go-nitro v0.1.1-ts-port-0.1.7
|
||||
replace github.com/statechannels/go-nitro v0.1.1 => github.com/deep-stack/go-nitro v0.0.0-20231016053556-1aa955e958a8
|
||||
|
4
go.sum
4
go.sum
@ -114,8 +114,6 @@ github.com/ceramicnetwork/go-dag-jose v0.1.0 h1:yJ/HVlfKpnD3LdYP03AHyTvbm3BpPiz2
|
||||
github.com/ceramicnetwork/go-dag-jose v0.1.0/go.mod h1:qYA1nYt0X8u4XoMAVoOV3upUVKtrxy/I670Dg5F0wjI=
|
||||
github.com/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha.0.20231013075659-56aa03028c43 h1:pkGCN+VWo5Qmu4iDjA7noGrE6wM8VOVeX1Mn6ucYhPg=
|
||||
github.com/cerc-io/eth-ipfs-state-validator/v5 v5.1.1-alpha.0.20231013075659-56aa03028c43/go.mod h1:snThUFpyCrpZhTuz3HibJRLL2XaS+lKNsM3XAE0gB/4=
|
||||
github.com/cerc-io/go-nitro v0.1.1-ts-port-0.1.7 h1:moqgKEUH9EtnyBgEQH65JrD8Q94abj+r6zGT6BJsU90=
|
||||
github.com/cerc-io/go-nitro v0.1.1-ts-port-0.1.7/go.mod h1:gkKL37JcSo54ybLTI6VJRmP75bWEu9i1kc9RYmQLp+I=
|
||||
github.com/cerc-io/ipfs-ethdb/v5 v5.0.1-alpha.0.20231013070931-0b1a36562a28 h1:5FXtMuZXTIXjjzzLdqgyzx9pjD22FB5os2vXayRn+BQ=
|
||||
github.com/cerc-io/ipfs-ethdb/v5 v5.0.1-alpha.0.20231013070931-0b1a36562a28/go.mod h1:W1C6qTXGsPcsK1HKUYPsXmBORjO2ekdm+101sJkpdNI=
|
||||
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
|
||||
@ -186,6 +184,8 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
|
||||
github.com/deep-stack/go-nitro v0.0.0-20231016053556-1aa955e958a8 h1:vQgSbAAEtf+34DKfvCeOPQKhcigcTaRCSfaVD/sn/JA=
|
||||
github.com/deep-stack/go-nitro v0.0.0-20231016053556-1aa955e958a8/go.mod h1:gkKL37JcSo54ybLTI6VJRmP75bWEu9i1kc9RYmQLp+I=
|
||||
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
|
||||
github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU=
|
||||
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
|
||||
|
27
nitroTLS/statechannels.org.pem
Normal file
27
nitroTLS/statechannels.org.pem
Normal file
@ -0,0 +1,27 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEiDCCAvCgAwIBAgIQPlCU2DUdJh7VqNh6ZiVLPDANBgkqhkiG9w0BAQsFADCB
|
||||
kzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTQwMgYDVQQLDCtwcmF0
|
||||
aGFtZXNoQHByYXRoYW1lc2gtdml2b2Jvb2sgKFByYXRoYW1lc2gpMTswOQYDVQQD
|
||||
DDJta2NlcnQgcHJhdGhhbWVzaEBwcmF0aGFtZXNoLXZpdm9ib29rIChQcmF0aGFt
|
||||
ZXNoKTAeFw0yMzEwMTYwNjQ1MDhaFw0yNjAxMTYwNjQ1MDhaMF8xJzAlBgNVBAoT
|
||||
Hm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTE0MDIGA1UECwwrcHJhdGhh
|
||||
bWVzaEBwcmF0aGFtZXNoLXZpdm9ib29rIChQcmF0aGFtZXNoKTCCASIwDQYJKoZI
|
||||
hvcNAQEBBQADggEPADCCAQoCggEBAMqlT68BfYkBtS7nqtUH+ri6tXp8TnA54hy/
|
||||
DFwMrWVTmFne01iOGhZt35ks9QYg/koFShHnuilILAY6aVMPDE6Dy7CQtphdewH3
|
||||
uy9o7yf4Jz2kk/aVdZ19XaxH5dsCvE6HmySxuvS0w0dy+vCdQT4dSG6Zmf8JCbdy
|
||||
NZ5SrJjQV3HuhUNJciVqZyNLMJjtLzDSLlY3lCBxb4lhXEhaNd0adFpwE/OQvxnj
|
||||
UKL6SC+jmDw7wT+wjt1Xpse0cy5+0fGU/EUivH7VTN+v5MTTTixI73PWchRGW1O5
|
||||
Ia/vajFQJSW97EgJIKK20lSkBwCM/PKfefXZDab2z77RW2dLDK0CAwEAAaOBijCB
|
||||
hzAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwHwYDVR0jBBgw
|
||||
FoAU2rF6BBoAppflaW38nCNXY+VyluowPwYDVR0RBDgwNoIRc3RhdGVjaGFubmVs
|
||||
cy5vcmeCCWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAATANBgkqhkiG
|
||||
9w0BAQsFAAOCAYEAAnb6QMo5hY0ZZAzhLO1V2qmQnY47roxW4zbZGM5bfXvdRfKq
|
||||
h2JKN5etL5RZaQTTVDs/6azI4Y7fcoL/DVdgcEvlZ5eCJi8WKE/AYfnjB/PBBNZC
|
||||
eYuezviPDoxvOo3jtwv5F/5wqgmY1qWxzMcrOpFbn3ctQ6lNdfIReZU/Fgr9FqMV
|
||||
EUj2j7HPvWpQT7O6p4ffrlAggGvqfIhW1tzJ8VzlrCQ9ZlbIMFhVWYJ3XSPnfidY
|
||||
xxJyFAHyMU+fDIaLSZ/axv2aNsyjpE58sICSnXl/DZ6BjYWVOtUcUDfDxpN5XvhF
|
||||
Toq7isUTdSUsFT2ySFuUn7iuU7N4gPIwn1AhwBa6wpSnL/uJ4tGCs3elNkNkJD7G
|
||||
QIsj65wQ3pXmTWl1+eQOdoGaoi1kkOymRY5nCygYsz/EXw6Za3rjtOTKb82+rpTn
|
||||
f/twbw5TrdRiTEt2otJSSWL3DBK5ccXFOqbu36w0vQOhS+pN0TxGxaZL7ebximxV
|
||||
nK23S80ITTPWgZMC
|
||||
-----END CERTIFICATE-----
|
28
nitroTLS/statechannels.org_key.pem
Normal file
28
nitroTLS/statechann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DwfqO73dJnhQhA4OrOjPGEtJRHOzA3t/c7
|
||||
89mDXwk6ZnF8GHpPcLkE/hxzi76yuujAWX2AH9Flcozz0MukRMtjyDrOPJ3OmCE5
|
||||
vyLIXPI/HqUsc2M79Mk+u8eQWdplscAd59bnv7KfYyizftwyNAb2d4mz93yOp2PI
|
||||
QBmGrTFMHQKBgHbYCIooSzPeNFTQF0vf8ROS6/hVoRz5vihNeYms0kNeyUbhbCN2
|
||||
l0WRA97P88GuGWsoBApTVVxbZqHagOUS6NwepOU4YF4hgIl8PZaZioVn8O3nwuCZ
|
||||
n2EJvpaxGn/GpL2x7HBSmWLdygafePNDOW5jmqk1MeEUDPgsKMplvDfxAoGBAIuN
|
||||
INup2ybgxipHmVkj5h3YX1Z6HP+oC5nJZUVbB1LRETcuSQMB6QrhnYba51x1IwxC
|
||||
oZWQYQSaFPqCBTkcBl2vWZhFCllQY69LnxZfAN7pnHUPu9yVrZVuh13XFej+3Pk9
|
||||
h7HQxgjBFGQb0BB9qjCoqso4aRmqPjd8IpPIuhttAoGBAMnbZklrMcRVqW8mzhVe
|
||||
ukqOoV+lZy9yGO0WKLO4IG7YZ7ZikXwRLJ76kKCODEFnciyAyzB9hvlfOUTCLVf5
|
||||
5qQ2R3GO0SCht0xUrVU8FWC6+sLtUX5zAGk50EXAmL8arU5TXlj/VeAE5NE15ay3
|
||||
yvZZBmyWBhY4FcW8xBzBxYaU
|
||||
-----END PRIVATE KEY-----
|
Loading…
Reference in New Issue
Block a user