node/node: move wormchainConn to GuardianOptionAccountant

This commit is contained in:
tbjump 2023-06-08 21:12:54 +00:00 committed by tbjump
parent 4274115cc3
commit 8e72f1200d
3 changed files with 8 additions and 13 deletions

View File

@ -1361,13 +1361,12 @@ func runNode(cmd *cobra.Command, args []string) {
guardianNode := node.NewGuardianNode(
env,
gk,
wormchainConn,
)
guardianOptions := []*node.GuardianOption{
node.GuardianOptionDatabase(db),
node.GuardianOptionWatchers(watcherConfigs, ibcWatcherConfig),
node.GuardianOptionAccountant(*accountantContract, *accountantWS, *accountantCheckEnabled),
node.GuardianOptionAccountant(*accountantContract, *accountantWS, *accountantCheckEnabled, wormchainConn),
node.GuardianOptionGovernor(*chainGovernorEnabled),
node.GuardianOptionAdminService(*adminSocketPath, ethRPC, ethContract, rpcMap),
node.GuardianOptionP2P(p2pKey, *p2pNetworkID, *p2pBootstrap, *nodeName, *disableHeartbeatVerify, *p2pPort, ibc.GetFeatures),

View File

@ -87,7 +87,7 @@ func GuardianOptionP2P(p2pKey libp2p_crypto.PrivKey, networkId string, bootstrap
// GuardianOptionAccountant configures the Accountant module.
// Requires: wormchainConn
func GuardianOptionAccountant(contract string, websocket string, enforcing bool) *GuardianOption {
func GuardianOptionAccountant(contract string, websocket string, enforcing bool, wormchainConn *wormconn.ClientConn) *GuardianOption {
return &GuardianOption{
name: "accountant",
dependencies: []string{"db"},
@ -104,7 +104,7 @@ func GuardianOptionAccountant(contract string, websocket string, enforcing bool)
if websocket == "" {
return errors.New("acct: if accountantContract is specified, accountantWS is required")
}
if g.wormchainConn == nil {
if wormchainConn == nil {
return errors.New("acct: if accountantContract is specified, the wormchain sending connection must be enabled before.")
}
if enforcing {
@ -120,7 +120,7 @@ func GuardianOptionAccountant(contract string, websocket string, enforcing bool)
g.obsvReqC.writeC,
contract,
websocket,
g.wormchainConn,
wormchainConn,
enforcing,
g.gk,
g.gst,
@ -450,7 +450,6 @@ type G struct {
acct *accountant.Accountant
gov *governor.ChainGovernor
attestationEvents *reporter.AttestationEventReporter
wormchainConn *wormconn.ClientConn
publicrpcServer *grpc.Server
// runnables
@ -481,12 +480,10 @@ type G struct {
func NewGuardianNode(
env common.Environment,
gk *ecdsa.PrivateKey,
wormchainConn *wormconn.ClientConn, // TODO does this need to be here?
) *G {
g := G{
env: env,
gk: gk,
wormchainConn: wormchainConn,
env: env,
gk: gk,
}
return &g
}

View File

@ -155,8 +155,8 @@ func mockGuardianRunnable(gs []*mockGuardian, mockGuardianIndex uint, obsDb mock
guardianOptions := []*GuardianOption{
GuardianOptionDatabase(db),
GuardianOptionWatchers(watcherConfigs, nil),
GuardianOptionAccountant("", "", false), // effectively disable accountant
GuardianOptionGovernor(false), // disable governor
GuardianOptionAccountant("", "", false, nil), // effectively disable accountant
GuardianOptionGovernor(false), // disable governor
GuardianOptionP2P(gs[mockGuardianIndex].p2pKey, networkID, bootstrapPeers, nodeName, false, p2pPort, func() string { return "" }),
GuardianOptionPublicRpcSocket(publicSocketPath, common.GrpcLogDetailFull),
GuardianOptionPublicrpcTcpService(publicRpc, common.GrpcLogDetailFull),
@ -168,7 +168,6 @@ func mockGuardianRunnable(gs []*mockGuardian, mockGuardianIndex uint, obsDb mock
guardianNode := NewGuardianNode(
env,
gs[mockGuardianIndex].gk,
nil,
)
if err = supervisor.Run(ctx, "g", guardianNode.Run(ctxCancel, guardianOptions...)); err != nil {