diff --git a/consensus/consensus.go b/consensus/consensus.go index 1f21b93..2de6369 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -169,7 +169,7 @@ func (pcm *PBFTConsensusManager) handleCommit(message *types.Message) { return } - err = pcm.ethereumClient.SubmitRequestAnswer(reqID, callbackAddress, request.RequestParams, request.Deadline, consensusMsg.Task.Payload) + err = pcm.ethereumClient.SubmitRequestAnswer(reqID, callbackAddress, request.CallbackMethodID, request.RequestParams, request.Deadline, consensusMsg.Task.Payload) if err != nil { logrus.Errorf("Failed to submit on-chain result: %v", err) } @@ -180,10 +180,12 @@ func (pcm *PBFTConsensusManager) handleCommit(message *types.Message) { } func (pcm *PBFTConsensusManager) createConsensusInfo(task *types2.DioneTask, isLeader bool) { - pcm.consensusMap[task.ConsensusID] = &Consensus{ - IsCurrentMinerLeader: isLeader, - Task: task, - Finished: false, + if _, ok := pcm.consensusMap[task.ConsensusID]; !ok { + pcm.consensusMap[task.ConsensusID] = &Consensus{ + IsCurrentMinerLeader: isLeader, + Task: task, + Finished: false, + } } } diff --git a/consensus/miner.go b/consensus/miner.go index 73ccb5c..f6da045 100644 --- a/consensus/miner.go +++ b/consensus/miner.go @@ -134,16 +134,20 @@ func (m *Miner) MineTask(ctx context.Context, event *dioneOracle.DioneOracleNewO } return &types.DioneTask{ - OriginChain: event.OriginChain, - RequestType: event.RequestType, - RequestParams: event.RequestParams, - Miner: m.address, - MinerEth: m.ethAddress.Hex(), - Ticket: ticket, - ElectionProof: winner, - BeaconEntries: beaconValues, - Payload: res, - DrandRound: types.DrandRound(randomBase.Round), + OriginChain: event.OriginChain, + RequestType: event.RequestType, + RequestParams: event.RequestParams, + RequestID: event.ReqID.String(), + ConsensusID: event.ReqID.String(), + CallbackAddress: event.CallbackAddress.Bytes(), + CallbackMethodID: event.CallbackMethodID[:], + Miner: m.address, + MinerEth: m.ethAddress.Hex(), + Ticket: ticket, + ElectionProof: winner, + BeaconEntries: beaconValues, + Payload: res, + DrandRound: types.DrandRound(randomBase.Round), }, nil } diff --git a/consensus/utils.go b/consensus/utils.go index 62895e1..9e2a22e 100644 --- a/consensus/utils.go +++ b/consensus/utils.go @@ -10,7 +10,7 @@ import ( ) func verifyTaskSignature(msg types.ConsensusMessage) error { - cHash, err := hashstructure.Hash(msg, hashstructure.FormatV2, nil) + cHash, err := hashstructure.Hash(msg.Task, hashstructure.FormatV2, nil) if err != nil { return err } diff --git a/ethclient/ethereum.go b/ethclient/ethereum.go index 3769973..794d024 100644 --- a/ethclient/ethereum.go +++ b/ethclient/ethereum.go @@ -184,8 +184,8 @@ func (c *EthereumClient) SubscribeOnOracleEvents(ctx context.Context) (chan *dio return resChan, subscription, err } -func (c *EthereumClient) SubmitRequestAnswer(reqID *big.Int, callbackAddress common.Address, requestParams string, requestDeadline *big.Int, data []byte) error { - _, err := c.dioneOracle.SubmitOracleRequest(requestParams, callbackAddress, [4]byte{}, reqID, requestDeadline, data) +func (c *EthereumClient) SubmitRequestAnswer(reqID *big.Int, callbackAddress common.Address, callbackMethodID [4]byte, requestParams string, requestDeadline *big.Int, data []byte) error { + _, err := c.dioneOracle.SubmitOracleRequest(requestParams, callbackAddress, callbackMethodID, reqID, requestDeadline, data) if err != nil { return err } diff --git a/node/node.go b/node/node.go index 251aa81..942a1f7 100644 --- a/node/node.go +++ b/node/node.go @@ -307,6 +307,7 @@ func (n *Node) setupRPCClients() error { fc := filecoin.NewLotusClient() rpc.RegisterRPC(rtypes.RPCTypeFilecoin, map[string]func(string) ([]byte, error){ "getTransaction": fc.GetTransaction, + "getBlock": fc.GetBlock, }) sl := solana2.NewSolanaClient()