diff --git a/node/node.go b/node/node.go index 1658f792815..7d9c548dae6 100644 --- a/node/node.go +++ b/node/node.go @@ -379,7 +379,7 @@ func NewNodeWithContext(ctx context.Context, } // Make OracleReactor - oracleReactor := oracle.NewReactor(config.Oracle, pubKey, privValidator) + oracleReactor := oracle.NewReactor(config.Oracle, pubKey, privValidator, proxyApp.Consensus()) oracleInfo := oracleReactor.OracleInfo // make block executor for consensus and blocksync reactors to execute blocks diff --git a/oracle/reactor.go b/oracle/reactor.go index 4a3f42e0826..67239c48b16 100644 --- a/oracle/reactor.go +++ b/oracle/reactor.go @@ -8,6 +8,7 @@ import ( "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/crypto/sr25519" + "github.com/cometbft/cometbft/proxy" "github.com/sirupsen/logrus" // cfg "github.com/cometbft/cometbft/config" @@ -48,7 +49,7 @@ type Reactor struct { } // NewReactor returns a new Reactor with the given config and mempool. -func NewReactor(config *config.OracleConfig, pubKey crypto.PubKey, privValidator types.PrivValidator) *Reactor { +func NewReactor(config *config.OracleConfig, pubKey crypto.PubKey, privValidator types.PrivValidator, proxyApp proxy.AppConnConsensus) *Reactor { gossipVoteBuffer := &oracletypes.GossipVoteBuffer{ Buffer: make(map[string]*oracleproto.GossipVote), } @@ -64,6 +65,7 @@ func NewReactor(config *config.OracleConfig, pubKey crypto.PubKey, privValidator SignVotesChan: make(chan *oracleproto.Vote), PubKey: pubKey, PrivValidator: privValidator, + ProxyApp: proxyApp, } oracleR := &Reactor{ diff --git a/oracle/service/runner/runner.go b/oracle/service/runner/runner.go index 726d1ad1635..5689d8570d7 100644 --- a/oracle/service/runner/runner.go +++ b/oracle/service/runner/runner.go @@ -1,7 +1,8 @@ package runner import ( - "io/ioutil" + "context" + "io" "net/http" "time" @@ -12,6 +13,7 @@ import ( "github.com/cometbft/cometbft/oracle/service/types" + abcitypes "github.com/cometbft/cometbft/abci/types" oracleproto "github.com/cometbft/cometbft/proto/tendermint/oracle" ) @@ -152,21 +154,19 @@ func Run(oracleInfo *types.OracleInfo) { log.Info("[oracle] Service started.") waitForGrpc(oracleInfo.Config.GrpcAddress) waitForRestAPI(oracleInfo.Config.RestApiAddress) - count := 0 RunProcessSignVoteQueue(oracleInfo) PruneUnsignedVoteBuffer(oracleInfo) PruneGossipVoteBuffer(oracleInfo) // start to take votes from app for { - if count == 0 { // on init, and every minute + res, err := oracleInfo.ProxyApp.PrepareOracleVotes(context.Background(), &abcitypes.RequestPrepareOracleVotes{}) + if err != nil { + log.Error(err) } - time.Sleep(100 * time.Millisecond) + log.Infof("RESULTS: %v", res.Votes) - count++ - if count > 600 { // 600 * 0.1s = 60s = every minute - count = 0 - } + time.Sleep(100 * time.Millisecond) } } @@ -240,7 +240,7 @@ func HTTPRequest(url string, timeout uint64) []byte { defer response.Body.Close() - body, readErr := ioutil.ReadAll(response.Body) + body, readErr := io.ReadAll(response.Body) if readErr != nil { return []byte{} diff --git a/oracle/service/types/info.go b/oracle/service/types/info.go index d2540a089e6..2a98b9b654c 100644 --- a/oracle/service/types/info.go +++ b/oracle/service/types/info.go @@ -5,6 +5,7 @@ import ( "github.com/cometbft/cometbft/crypto" cmtsync "github.com/cometbft/cometbft/libs/sync" oracleproto "github.com/cometbft/cometbft/proto/tendermint/oracle" + "github.com/cometbft/cometbft/proxy" "github.com/cometbft/cometbft/types" ) @@ -17,6 +18,7 @@ type OracleInfo struct { PubKey crypto.PubKey PrivValidator types.PrivValidator StopChannel chan int + ProxyApp proxy.AppConnConsensus } type UnsignedVotes struct {