Fix pubsub issues
This commit is contained in:
parent
2526f65825
commit
b04ba982a9
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,4 +22,6 @@ eth-contracts/node_modules
|
||||
/.dione-config.toml
|
||||
/.dione-config-2.toml
|
||||
/.dione-config-3.toml
|
||||
/.dione-config-4.toml
|
||||
.bootstrap_privkey
|
||||
eth-contracts/build
|
@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/Secured-Finance/dione/beacon"
|
||||
"github.com/Secured-Finance/dione/contracts/oracleEmitter"
|
||||
oracleEmitter "github.com/Secured-Finance/dione/contracts/oracleemitter"
|
||||
"github.com/Secured-Finance/dione/solana"
|
||||
solTypes "github.com/Secured-Finance/dione/solana/types"
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/Secured-Finance/dione/contracts/aggregator"
|
||||
"github.com/Secured-Finance/dione/contracts/dioneStaking"
|
||||
stakingContract "github.com/Secured-Finance/dione/contracts/dioneStaking"
|
||||
oracleEmitter "github.com/Secured-Finance/dione/contracts/oracleEmitter"
|
||||
oracleEmitter "github.com/Secured-Finance/dione/contracts/oracleemitter"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
@ -81,7 +81,7 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
TransactOpts: bind.TransactOpts{
|
||||
From: authTransactor.From,
|
||||
Signer: authTransactor.Signer,
|
||||
GasLimit: 0, // 0 automatically estimates gas limit
|
||||
GasLimit: 200000, // 0 automatically estimates gas limit
|
||||
GasPrice: nil, // nil automatically suggests gas price
|
||||
Context: context.Background(),
|
||||
},
|
||||
@ -96,7 +96,7 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
TransactOpts: bind.TransactOpts{
|
||||
From: authTransactor.From,
|
||||
Signer: authTransactor.Signer,
|
||||
GasLimit: 0, // 0 automatically estimates gas limit
|
||||
GasLimit: 200000, // 0 automatically estimates gas limit
|
||||
GasPrice: nil, // nil automatically suggests gas price
|
||||
Context: context.Background(),
|
||||
},
|
||||
@ -111,8 +111,8 @@ func (c *EthereumClient) Initialize(ctx context.Context, url, privateKey, oracle
|
||||
TransactOpts: bind.TransactOpts{
|
||||
From: authTransactor.From,
|
||||
Signer: authTransactor.Signer,
|
||||
GasLimit: 0, // 0 automatically estimates gas limit
|
||||
GasPrice: nil, // nil automatically suggests gas price
|
||||
GasLimit: 200000, // 0 automatically estimates gas limit
|
||||
GasPrice: big.NewInt(1860127603), // nil automatically suggests gas price
|
||||
Context: context.Background(),
|
||||
},
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package node
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Secured-Finance/dione/consensus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -23,21 +22,24 @@ func (n *Node) subscribeOnEthContracts(ctx context.Context) {
|
||||
if err != nil {
|
||||
logrus.Fatal("Error with mining algorithm, exiting... ", err)
|
||||
}
|
||||
if task == nil {
|
||||
continue
|
||||
}
|
||||
logrus.Info("BlockHash for Solana transaction: ", task.BlockHash)
|
||||
logrus.Info("Started new consensus round with ID: ", task.BlockHash)
|
||||
n.ConsensusManager.NewTestConsensus(string(task.BlockHash), task.BlockHash, func(finalData string) {
|
||||
if finalData != string(task.BlockHash) {
|
||||
logrus.Warn("Expected final data to be %s, not %s", finalData)
|
||||
logrus.Warnf("Expected final data to be %s, not %s", task.BlockHash, finalData)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
if n.ConsensusManager.Consensuses[task.BlockHash].State == consensus.ConsensusCommitted {
|
||||
logrus.Info("Consensus ID: ", task.BlockHash, " was successfull")
|
||||
logrus.Info("Submitting on-chain result: ", task.BlockHash, "for consensus ID: ", task.BlockHash)
|
||||
if task.Miner == n.Host.ID() {
|
||||
if err := n.Ethereum.SubmitRequestAnswer(event.RequestID, task.BlockHash, event.CallbackAddress, event.CallbackMethodID); err != nil {
|
||||
logrus.Warn("Can't submit request to ethereum chain: ", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
case <-ctx.Done():
|
||||
break EventLoop
|
||||
|
25
node/node.go
25
node/node.go
@ -5,6 +5,8 @@ import (
|
||||
"crypto/rand"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Secured-Finance/dione/solana"
|
||||
@ -31,7 +33,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultPEXUpdateTime = 1 * time.Minute
|
||||
DefaultPEXUpdateTime = 6 * time.Second
|
||||
)
|
||||
|
||||
type Node struct {
|
||||
@ -240,22 +242,37 @@ func Start() error {
|
||||
if *verbose {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
} else {
|
||||
logrus.SetLevel(logrus.InfoLevel)
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
if err != nil {
|
||||
logrus.Panic(err)
|
||||
}
|
||||
|
||||
privKey, err := generatePrivateKey()
|
||||
var privateKey crypto.PrivKey
|
||||
|
||||
if node.Config.IsBootstrap {
|
||||
if _, err := os.Stat(".bootstrap_privkey"); os.IsNotExist(err) {
|
||||
privateKey, err = generatePrivateKey()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
f, _ := os.Create(".bootstrap_privkey")
|
||||
r, _ := privateKey.Raw()
|
||||
f.Write(r)
|
||||
} else {
|
||||
pkey, _ := ioutil.ReadFile(".bootstrap_privkey")
|
||||
privateKey, _ = crypto.UnmarshalEd25519PrivateKey(pkey)
|
||||
}
|
||||
} else {
|
||||
privateKey, err = generatePrivateKey()
|
||||
}
|
||||
|
||||
ctx, ctxCancel := context.WithCancel(context.Background())
|
||||
node.GlobalCtx = ctx
|
||||
node.GlobalCtxCancel = ctxCancel
|
||||
|
||||
node.setupNode(ctx, privKey, DefaultPEXUpdateTime)
|
||||
node.setupNode(ctx, privateKey, DefaultPEXUpdateTime)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -30,7 +30,7 @@ func NewPubSubRouter(h host.Host, oracleTopic string) *PubSubRouter {
|
||||
handlers: make(map[string][]Handler),
|
||||
}
|
||||
|
||||
pb, err := pubsub.NewGossipSub(
|
||||
pb, err := pubsub.NewFloodSub(
|
||||
context.TODO(),
|
||||
psr.node, //pubsub.WithMessageSigning(true),
|
||||
//pubsub.WithStrictSignatureVerification(true),
|
||||
|
Loading…
Reference in New Issue
Block a user