From c74ec4db26d137f578ddb8520eac4cfed1c3c314 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Tue, 27 Apr 2021 01:01:04 +0300 Subject: [PATCH] Remove callback address/method id from NewOracleRequest event properties --- consensus/consensus.go | 2 - consensus/miner.go | 26 ++- consensus/pre_prepare_pool.go | 9 +- contracts/dioneOracle/dione_oracle.go | 254 ++---------------------- eth-contracts/contracts/DioneOracle.sol | 4 +- ethclient/ethereum.go | 7 - types/task.go | 28 ++- 7 files changed, 41 insertions(+), 289 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index c340415..1bf54f8 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -61,8 +61,6 @@ func (pcm *PBFTConsensusManager) Propose(task types2.DioneTask, requestEvent *di prePrepareMsg, err := pcm.prePreparePool.CreatePrePrepare( &task, requestEvent.ReqID.String(), - requestEvent.CallbackAddress.Bytes(), - requestEvent.CallbackMethodID[:], pcm.privKey, ) if err != nil { diff --git a/consensus/miner.go b/consensus/miner.go index f6da045..c7247bf 100644 --- a/consensus/miner.go +++ b/consensus/miner.go @@ -134,20 +134,18 @@ func (m *Miner) MineTask(ctx context.Context, event *dioneOracle.DioneOracleNewO } return &types.DioneTask{ - 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), + OriginChain: event.OriginChain, + RequestType: event.RequestType, + RequestParams: event.RequestParams, + RequestID: event.ReqID.String(), + ConsensusID: event.ReqID.String(), + 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/pre_prepare_pool.go b/consensus/pre_prepare_pool.go index c2893d1..a9e5a06 100644 --- a/consensus/pre_prepare_pool.go +++ b/consensus/pre_prepare_pool.go @@ -1,7 +1,6 @@ package consensus import ( - "bytes" "fmt" "sync" @@ -34,14 +33,12 @@ func NewPrePreparePool(miner *Miner, evc cache.EventCache) *PrePreparePool { } } -func (pp *PrePreparePool) CreatePrePrepare(task *types.DioneTask, requestID string, callbackAddress, callbackMethodID, privateKey []byte) (*types2.Message, error) { +func (pp *PrePreparePool) CreatePrePrepare(task *types.DioneTask, requestID string, privateKey []byte) (*types2.Message, error) { var message types2.Message message.Type = types2.MessageTypePrePrepare var consensusMsg types2.ConsensusMessage consensusMsg.Task.ConsensusID = requestID consensusMsg.Task.RequestID = requestID - consensusMsg.Task.CallbackAddress = callbackAddress - consensusMsg.Task.CallbackMethodID = callbackMethodID consensusMsg.Task = *task cHash, err := hashstructure.Hash(task, hashstructure.FormatV2, nil) if err != nil { @@ -88,9 +85,7 @@ func (ppp *PrePreparePool) IsValidPrePrepare(prePrepare *types2.Message) bool { logrus.Errorf("the incoming request task event doesn't exist in the EVC, or is broken: %v", err) return false } - if bytes.Compare(requestEvent.CallbackAddress.Bytes(), consensusMsg.Task.CallbackAddress) != 0 || - bytes.Compare(requestEvent.CallbackMethodID[:], consensusMsg.Task.CallbackMethodID) != 0 || - requestEvent.OriginChain != consensusMsg.Task.OriginChain || + if requestEvent.OriginChain != consensusMsg.Task.OriginChain || requestEvent.RequestType != consensusMsg.Task.RequestType || requestEvent.RequestParams != consensusMsg.Task.RequestParams { diff --git a/contracts/dioneOracle/dione_oracle.go b/contracts/dioneOracle/dione_oracle.go index 51ad762..1bc0823 100644 --- a/contracts/dioneOracle/dione_oracle.go +++ b/contracts/dioneOracle/dione_oracle.go @@ -27,7 +27,7 @@ var ( ) // DioneOracleABI is the input ABI used to generate the binding from. -const DioneOracleABI = "[{\"inputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"_dioneStaking\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"}],\"name\":\"CancelOracleRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"originChain\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestParams\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"callbackAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"callbackMethodID\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"NewOracleRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"SubmittedOracleRequest\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAXIMUM_DELAY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_reqID\",\"type\":\"uint256\"}],\"name\":\"cancelOracleRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dioneStaking\",\"outputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumDisputeFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_originChain\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"_requestType\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_requestParams\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"_callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"requestOracles\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_reqID\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"submitOracleRequest\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" +const DioneOracleABI = "[{\"inputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"_dioneStaking\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"}],\"name\":\"CancelOracleRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"originChain\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestType\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"requestParams\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"}],\"name\":\"NewOracleRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reqID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"SubmittedOracleRequest\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAXIMUM_DELAY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_reqID\",\"type\":\"uint256\"}],\"name\":\"cancelOracleRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"dioneStaking\",\"outputs\":[{\"internalType\":\"contractIDioneStaking\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimumDisputeFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"_originChain\",\"type\":\"uint8\"},{\"internalType\":\"string\",\"name\":\"_requestType\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_requestParams\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"_callbackAddress\",\"type\":\"address\"},{\"internalType\":\"bytes4\",\"name\":\"_callbackMethodID\",\"type\":\"bytes4\"}],\"name\":\"requestOracles\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_reqID\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"submitOracleRequest\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" // DioneOracle is an auto generated Go binding around an Ethereum contract. type DioneOracle struct { @@ -264,37 +264,6 @@ func (_DioneOracle *DioneOracleCallerSession) MinimumDisputeFee() (*big.Int, err return _DioneOracle.Contract.MinimumDisputeFee(&_DioneOracle.CallOpts) } -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_DioneOracle *DioneOracleCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _DioneOracle.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_DioneOracle *DioneOracleSession) Owner() (common.Address, error) { - return _DioneOracle.Contract.Owner(&_DioneOracle.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_DioneOracle *DioneOracleCallerSession) Owner() (common.Address, error) { - return _DioneOracle.Contract.Owner(&_DioneOracle.CallOpts) -} - // CancelOracleRequest is a paid mutator transaction binding the contract method 0x1d2a198a. // // Solidity: function cancelOracleRequest(uint256 _reqID) returns() @@ -316,27 +285,6 @@ func (_DioneOracle *DioneOracleTransactorSession) CancelOracleRequest(_reqID *bi return _DioneOracle.Contract.CancelOracleRequest(&_DioneOracle.TransactOpts, _reqID) } -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_DioneOracle *DioneOracleTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _DioneOracle.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_DioneOracle *DioneOracleSession) RenounceOwnership() (*types.Transaction, error) { - return _DioneOracle.Contract.RenounceOwnership(&_DioneOracle.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_DioneOracle *DioneOracleTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _DioneOracle.Contract.RenounceOwnership(&_DioneOracle.TransactOpts) -} - // RequestOracles is a paid mutator transaction binding the contract method 0xe7c3712a. // // Solidity: function requestOracles(uint8 _originChain, string _requestType, string _requestParams, address _callbackAddress, bytes4 _callbackMethodID) returns(uint256) @@ -379,27 +327,6 @@ func (_DioneOracle *DioneOracleTransactorSession) SubmitOracleRequest(_reqID *bi return _DioneOracle.Contract.SubmitOracleRequest(&_DioneOracle.TransactOpts, _reqID, _data) } -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_DioneOracle *DioneOracleTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _DioneOracle.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_DioneOracle *DioneOracleSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _DioneOracle.Contract.TransferOwnership(&_DioneOracle.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_DioneOracle *DioneOracleTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _DioneOracle.Contract.TransferOwnership(&_DioneOracle.TransactOpts, newOwner) -} - // DioneOracleCancelOracleRequestIterator is returned from FilterCancelOracleRequest and is used to iterate over the raw logs and unpacked data for CancelOracleRequest events raised by the DioneOracle contract. type DioneOracleCancelOracleRequestIterator struct { Event *DioneOracleCancelOracleRequest // Event containing the contract specifics and raw log @@ -603,19 +530,17 @@ func (it *DioneOracleNewOracleRequestIterator) Close() error { // DioneOracleNewOracleRequest represents a NewOracleRequest event raised by the DioneOracle contract. type DioneOracleNewOracleRequest struct { - OriginChain uint8 - RequestType string - RequestParams string - CallbackAddress common.Address - CallbackMethodID [4]byte - ReqID *big.Int - Deadline *big.Int - Raw types.Log // Blockchain specific contextual infos + OriginChain uint8 + RequestType string + RequestParams string + ReqID *big.Int + Deadline *big.Int + Raw types.Log // Blockchain specific contextual infos } -// FilterNewOracleRequest is a free log retrieval operation binding the contract event 0xef9801b1c3f147f0bb627cb55d33a9041af7356287b3a228398453318128b65d. +// FilterNewOracleRequest is a free log retrieval operation binding the contract event 0xf2736922e09befc7bb0c19052cc9b530a5d9a696b3db44a29814ac8a4335aa08. // -// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 reqID, uint256 deadline) +// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, uint256 reqID, uint256 deadline) func (_DioneOracle *DioneOracleFilterer) FilterNewOracleRequest(opts *bind.FilterOpts) (*DioneOracleNewOracleRequestIterator, error) { logs, sub, err := _DioneOracle.contract.FilterLogs(opts, "NewOracleRequest") @@ -625,9 +550,9 @@ func (_DioneOracle *DioneOracleFilterer) FilterNewOracleRequest(opts *bind.Filte return &DioneOracleNewOracleRequestIterator{contract: _DioneOracle.contract, event: "NewOracleRequest", logs: logs, sub: sub}, nil } -// WatchNewOracleRequest is a free log subscription operation binding the contract event 0xef9801b1c3f147f0bb627cb55d33a9041af7356287b3a228398453318128b65d. +// WatchNewOracleRequest is a free log subscription operation binding the contract event 0xf2736922e09befc7bb0c19052cc9b530a5d9a696b3db44a29814ac8a4335aa08. // -// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 reqID, uint256 deadline) +// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, uint256 reqID, uint256 deadline) func (_DioneOracle *DioneOracleFilterer) WatchNewOracleRequest(opts *bind.WatchOpts, sink chan<- *DioneOracleNewOracleRequest) (event.Subscription, error) { logs, sub, err := _DioneOracle.contract.WatchLogs(opts, "NewOracleRequest") @@ -662,9 +587,9 @@ func (_DioneOracle *DioneOracleFilterer) WatchNewOracleRequest(opts *bind.WatchO }), nil } -// ParseNewOracleRequest is a log parse operation binding the contract event 0xef9801b1c3f147f0bb627cb55d33a9041af7356287b3a228398453318128b65d. +// ParseNewOracleRequest is a log parse operation binding the contract event 0xf2736922e09befc7bb0c19052cc9b530a5d9a696b3db44a29814ac8a4335aa08. // -// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, address callbackAddress, bytes4 callbackMethodID, uint256 reqID, uint256 deadline) +// Solidity: event NewOracleRequest(uint8 originChain, string requestType, string requestParams, uint256 reqID, uint256 deadline) func (_DioneOracle *DioneOracleFilterer) ParseNewOracleRequest(log types.Log) (*DioneOracleNewOracleRequest, error) { event := new(DioneOracleNewOracleRequest) if err := _DioneOracle.contract.UnpackLog(event, "NewOracleRequest", log); err != nil { @@ -674,159 +599,6 @@ func (_DioneOracle *DioneOracleFilterer) ParseNewOracleRequest(log types.Log) (* return event, nil } -// DioneOracleOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the DioneOracle contract. -type DioneOracleOwnershipTransferredIterator struct { - Event *DioneOracleOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *DioneOracleOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(DioneOracleOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(DioneOracleOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *DioneOracleOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *DioneOracleOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// DioneOracleOwnershipTransferred represents a OwnershipTransferred event raised by the DioneOracle contract. -type DioneOracleOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_DioneOracle *DioneOracleFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*DioneOracleOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _DioneOracle.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &DioneOracleOwnershipTransferredIterator{contract: _DioneOracle.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_DioneOracle *DioneOracleFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *DioneOracleOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _DioneOracle.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(DioneOracleOwnershipTransferred) - if err := _DioneOracle.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_DioneOracle *DioneOracleFilterer) ParseOwnershipTransferred(log types.Log) (*DioneOracleOwnershipTransferred, error) { - event := new(DioneOracleOwnershipTransferred) - if err := _DioneOracle.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // DioneOracleSubmittedOracleRequestIterator is returned from FilterSubmittedOracleRequest and is used to iterate over the raw logs and unpacked data for SubmittedOracleRequest events raised by the DioneOracle contract. type DioneOracleSubmittedOracleRequestIterator struct { Event *DioneOracleSubmittedOracleRequest // Event containing the contract specifics and raw log diff --git a/eth-contracts/contracts/DioneOracle.sol b/eth-contracts/contracts/DioneOracle.sol index 18a96e3..9909e71 100644 --- a/eth-contracts/contracts/DioneOracle.sol +++ b/eth-contracts/contracts/DioneOracle.sol @@ -36,8 +36,6 @@ contract DioneOracle { uint8 originChain, string requestType, string requestParams, - address callbackAddress, - bytes4 callbackMethodID, uint256 reqID, uint256 deadline ); @@ -76,7 +74,7 @@ contract DioneOracle { data: new bytes(0) }); - emit NewOracleRequest(_originChain, _requestType, _requestParams, _callbackAddress, _callbackMethodID, requestCounter, requestDeadline); + emit NewOracleRequest(_originChain, _requestType, _requestParams, requestCounter, requestDeadline); return requestCounter; } diff --git a/ethclient/ethereum.go b/ethclient/ethereum.go index 584c9e4..f5dc312 100644 --- a/ethclient/ethereum.go +++ b/ethclient/ethereum.go @@ -31,13 +31,6 @@ type EthereumClient struct { dioneOracle *dioneOracle.DioneOracleSession } -type OracleEvent struct { - RequestType string - CallbackAddress common.Address - CallbackMethodID [4]byte - RequestID *big.Int -} - type Ethereum interface { Initialize(ctx context.Context, url, connectionType, privateKey, oracleEmitterContractAddress, aggregatorContractAddress string) error Balance(context.Context, string) (*big.Int, error) diff --git a/types/task.go b/types/task.go index c7ede67..cfd1a82 100644 --- a/types/task.go +++ b/types/task.go @@ -19,21 +19,19 @@ func (e DrandRound) String() string { // DioneTask represents the values of task computation type DioneTask struct { - OriginChain uint8 - RequestType string - RequestParams string - Miner peer.ID - MinerEth string - Ticket *Ticket - ElectionProof *ElectionProof - BeaconEntries []BeaconEntry - DrandRound DrandRound - Payload []byte - RequestID string - CallbackAddress []byte - CallbackMethodID []byte - ConsensusID string - Signature []byte `hash:"-"` + OriginChain uint8 + RequestType string + RequestParams string + Miner peer.ID + MinerEth string + Ticket *Ticket + ElectionProof *ElectionProof + BeaconEntries []BeaconEntry + DrandRound DrandRound + Payload []byte + RequestID string + ConsensusID string + Signature []byte `hash:"-"` } func NewDioneTask(