From cd189bdf3ec22e6f5557e031e06d00046173c682 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:25:33 +0800 Subject: [PATCH 1/5] feat: add labels (#74) * add labels * add labels --- metric/metric_service.go | 78 ++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/metric/metric_service.go b/metric/metric_service.go index 2af359c..f4ed69f 100644 --- a/metric/metric_service.go +++ b/metric/metric_service.go @@ -2,10 +2,10 @@ package metric import ( "fmt" - "net/http" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" + "net/http" + "strconv" "github.com/bnb-chain/greenfield-relayer/config" ) @@ -34,92 +34,108 @@ type MetricService struct { func NewMetricService(config *config.Config) *MetricService { ms := make(map[string]prometheus.Metric, 0) + labels := map[string]string{ + "gnfdChainId": config.GreenfieldConfig.ChainIdString, + "bscChainId": strconv.FormatUint(config.BSCConfig.ChainId, 10), + } // Greenfield gnfdSavedBlockMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameGnfdSavedBlock, - Help: "Saved block height for Greenfield in Database", + Name: MetricNameGnfdSavedBlock, + Help: "Saved block height for Greenfield in Database", + ConstLabels: labels, }) ms[MetricNameGnfdSavedBlock] = gnfdSavedBlockMetric prometheus.MustRegister(gnfdSavedBlockMetric) gnfdProcessedBlockMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameGnfdProcessedBlock, - Help: "Processed block height for Greenfield in Database", + Name: MetricNameGnfdProcessedBlock, + Help: "Processed block height for Greenfield in Database", + ConstLabels: labels, }) ms[MetricNameGnfdProcessedBlock] = gnfdProcessedBlockMetric prometheus.MustRegister(gnfdProcessedBlockMetric) gnfdIsInturnRelayerMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameIsGnfdInturnRelayer, - Help: "Whether relayer is inturn to relay transaction from BSC to Greenfield", + Name: MetricNameIsGnfdInturnRelayer, + Help: "Whether relayer is inturn to relay transaction from BSC to Greenfield", + ConstLabels: labels, }) ms[MetricNameIsGnfdInturnRelayer] = gnfdIsInturnRelayerMetric prometheus.MustRegister(gnfdIsInturnRelayerMetric) // Greenfield relayer(BSC -> Greenfield) relay interval metrics gnfdRelayerStartTimeMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameGnfdRelayerStartTime, - Help: "inturn gnfd relayer start time or out-turn relayer previous start time", + Name: MetricNameGnfdRelayerStartTime, + Help: "inturn gnfd relayer start time or out-turn relayer previous start time", + ConstLabels: labels, }) ms[MetricNameGnfdRelayerStartTime] = gnfdRelayerStartTimeMetric prometheus.MustRegister(gnfdRelayerStartTimeMetric) gnfdRelayerEndTimeMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameGnfdRelayerEndTime, - Help: "inturn gnfd relayer end time or out-turn relayer previous end time", + Name: MetricNameGnfdRelayerEndTime, + Help: "inturn gnfd relayer end time or out-turn relayer previous end time", + ConstLabels: labels, }) ms[MetricNameGnfdRelayerEndTime] = gnfdRelayerEndTimeMetric prometheus.MustRegister(gnfdRelayerEndTimeMetric) // BSC bscSavedBlockMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameBSCSavedBlock, - Help: "Saved block height for BSC in Database", + Name: MetricNameBSCSavedBlock, + Help: "Saved block height for BSC in Database", + ConstLabels: labels, }) ms[MetricNameBSCSavedBlock] = bscSavedBlockMetric prometheus.MustRegister(bscSavedBlockMetric) bscProcessedBlockMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameBSCProcessedBlock, - Help: "Processed block height for BSC in Database", + Name: MetricNameBSCProcessedBlock, + Help: "Processed block height for BSC in Database", + ConstLabels: labels, }) ms[MetricNameBSCProcessedBlock] = bscProcessedBlockMetric prometheus.MustRegister(bscProcessedBlockMetric) bscIsInturnRelayerMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameIsBSCInturnRelayer, - Help: "Whether relayer is inturn to relay transaction from Greenfield to BSC", + Name: MetricNameIsBSCInturnRelayer, + Help: "Whether relayer is inturn to relay transaction from Greenfield to BSC", + ConstLabels: labels, }) ms[MetricNameIsBSCInturnRelayer] = bscIsInturnRelayerMetric prometheus.MustRegister(bscIsInturnRelayerMetric) // BSC relayer(Greenfield -> BSC) relay interval metrics bscRelayerStartTimeMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameBSCRelayerStartTime, - Help: "inturn BSC relayer start time or out-turn relayer previous start time", + Name: MetricNameBSCRelayerStartTime, + Help: "inturn BSC relayer start time or out-turn relayer previous start time", + ConstLabels: labels, }) ms[MetricNameBSCRelayerStartTime] = bscRelayerStartTimeMetric prometheus.MustRegister(bscRelayerStartTimeMetric) bscRelayerEndTimeMetric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: MetricNameBSCRelayerEndTime, - Help: "inturn BSC relayer end time or out-turn relayer previous end time", + Name: MetricNameBSCRelayerEndTime, + Help: "inturn BSC relayer end time or out-turn relayer previous end time", + ConstLabels: labels, }) ms[MetricNameBSCRelayerEndTime] = bscRelayerEndTimeMetric prometheus.MustRegister(bscRelayerEndTimeMetric) // register greenfield oracle channel nextSendOracleSeq := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, 0), - Help: "Next Send Oracle sequence", + Name: fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, 0), + Help: "Next Send Oracle sequence", + ConstLabels: labels, }) ms[fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, 0)] = nextSendOracleSeq prometheus.MustRegister(nextSendOracleSeq) nextReceiveOracleSeq := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, 0), - Help: "Next Delivery Oracle sequence", + Name: fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, 0), + Help: "Next Delivery Oracle sequence", + ConstLabels: labels, }) ms[fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, 0)] = nextReceiveOracleSeq prometheus.MustRegister(nextReceiveOracleSeq) @@ -127,15 +143,17 @@ func NewMetricService(config *config.Config) *MetricService { // register gnfd -> bsc channels for _, c := range config.GreenfieldConfig.MonitorChannelList { nextSendSeq := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, c), - Help: fmt.Sprintf("Next Send sequence for channel %d", c), + Name: fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, c), + Help: fmt.Sprintf("Next Send sequence for channel %d", c), + ConstLabels: labels, }) ms[fmt.Sprintf("%s_%d", MetricNameNextSendSequenceForChannel, c)] = nextSendSeq prometheus.MustRegister(nextSendSeq) nextReceiveSeq := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, c), - Help: fmt.Sprintf("Next delivery sequence for channel %d", c), + Name: fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, c), + Help: fmt.Sprintf("Next delivery sequence for channel %d", c), + ConstLabels: labels, }) ms[fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, c)] = nextReceiveSeq prometheus.MustRegister(nextReceiveSeq) From 8d2950ec2bcaea7999422e1546c6a9ff80d3033d Mon Sep 17 00:00:00 2001 From: dylanhuang Date: Fri, 11 Aug 2023 18:32:32 +0800 Subject: [PATCH 2/5] chore: add issue template (#70) --- .github/ISSUE_TEMPLATE/bug.md | 30 ++++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature.md | 17 +++++++++++++++++ .github/ISSUE_TEMPLATE/question.md | 9 +++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/feature.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..1bfa2e8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,30 @@ +--- +name: Report a bug +about: Something with greenfield-relayer is not working as expected +title: '' +labels: 'type:bug' +assignees: '' +--- + +#### System information + +Relayer version: (if getting from release page) +OS & Version: Windows/Linux/OSX +Commit hash : (if `develop`) + +#### Expected behaviour + + +#### Actual behaviour + + +#### Steps to reproduce the behaviour + + +#### Backtrace + +```` +[backtrace] +```` + +When submitting logs: please submit them as text and not screenshots. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 0000000..aacd885 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,17 @@ +--- +name: Request a feature +about: Report a missing feature - e.g. as a step before submitting a PR +title: '' +labels: 'type:feature' +assignees: '' +--- + +# Rationale + +Why should this feature exist? +What are the use-cases? + +# Implementation + +Do you have ideas regarding the implementation of this feature? +Are you willing to implement this feature? \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..f2f3022 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,9 @@ +--- +name: Ask a question +about: Something is unclear +title: '' +labels: 'type:docs' +assignees: '' +--- + +This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/bnbchain). From 64201876bf867b055ee9a01803e2bc494b99ba9d Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:23:57 +0800 Subject: [PATCH 3/5] feat: add jobs for monitoring bsc balance and rewards, cleaning DB (#71) * add jobs for monitoring bsc balance and rewards, cleaning DB * add jobs for monitoring bsc balance and rewards, cleaning DB * enrich the clean job * lint * add logging * change parameter * change parameter * limit number of item to be deleted * add comments * modify sql --- .github/workflows/lint.yml | 15 +- app/app.go | 6 +- assembler/bsc_assembler.go | 5 +- config/config.go | 1 + .../crosschain/crosschain.abi | 0 .../crosschain/crosschain.go | 0 .../greenfieldlightclient.abi | 0 .../greenfieldlightclient.go | 0 contract/relayerhub/relayerhub.abi | 364 +++++ contract/relayerhub/relayerhub.go | 1277 +++++++++++++++++ db/dao/bsc_dao.go | 32 + db/dao/greenfield_dao.go | 32 + db/dao/vote_dao.go | 10 + db/model/votepool_model.go | 1 + executor/bsc_executor.go | 110 +- executor/bsc_executor_test.go | 2 +- executor/const.go | 7 + executor/greenfield_executor.go | 2 +- executor/test_util.go | 2 +- integrationtest/config/config_test.json | 2 +- listener/bsc_listener.go | 33 +- listener/const.go | 10 + listener/greenfield_listener.go | 31 + metric/{metric_service.go => service.go} | 17 + relayer/bsc_relayer.go | 10 + relayer/greenfield_relayer.go | 5 + vote/bsc_vote_processor.go | 4 +- vote/converter.go | 3 +- vote/greenfield_vote_processor.go | 4 +- 29 files changed, 1952 insertions(+), 33 deletions(-) rename {executor => contract}/crosschain/crosschain.abi (100%) rename {executor => contract}/crosschain/crosschain.go (100%) rename {executor => contract}/greenfieldlightclient/greenfieldlightclient.abi (100%) rename {executor => contract}/greenfieldlightclient/greenfieldlightclient.go (100%) create mode 100644 contract/relayerhub/relayerhub.abi create mode 100644 contract/relayerhub/relayerhub.go create mode 100644 listener/const.go rename metric/{metric_service.go => service.go} (94%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 14d6520..f3a64f8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,9 +5,6 @@ on: - master - develop pull_request: - branches: - - master - - develop permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. @@ -15,11 +12,17 @@ permissions: jobs: golangci: name: golangci-lint - runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.20.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + env: + GOPRIVATE: github.com/bnb-chain steps: - uses: actions/setup-go@v3 with: - go-version: [1.20.x] + go-version: ${{ matrix.go-version }} - uses: actions/checkout@v3 - run: go env -w GOPRIVATE="github.com/bnb-chain/*" @@ -47,6 +50,6 @@ jobs: uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.50.0 + version: latest skip-pkg-cache: true args: --timeout=99m diff --git a/app/app.go b/app/app.go index b5ecf84..f053761 100644 --- a/app/app.go +++ b/app/app.go @@ -76,19 +76,19 @@ func NewApp(cfg *config.Config) *App { model.InitGreenfieldTables(db) model.InitVoteTables(db) + metricService := metric.NewMetricService(cfg) + greenfieldDao := dao.NewGreenfieldDao(db) bscDao := dao.NewBSCDao(db) voteDao := dao.NewVoteDao(db) daoManager := dao.NewDaoManager(greenfieldDao, bscDao, voteDao) greenfieldExecutor := executor.NewGreenfieldExecutor(cfg) - bscExecutor := executor.NewBSCExecutor(cfg) + bscExecutor := executor.NewBSCExecutor(cfg, metricService) greenfieldExecutor.SetBSCExecutor(bscExecutor) bscExecutor.SetGreenfieldExecutor(greenfieldExecutor) - metricService := metric.NewMetricService(cfg) - // vote signer signer := vote.NewVoteSigner(greenfieldExecutor.BlsPrivateKey) diff --git a/assembler/bsc_assembler.go b/assembler/bsc_assembler.go index 47ba6b8..365e384 100644 --- a/assembler/bsc_assembler.go +++ b/assembler/bsc_assembler.go @@ -2,12 +2,13 @@ package assembler import ( "bytes" - "cosmossdk.io/errors" "encoding/hex" "fmt" + "time" + + "cosmossdk.io/errors" sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" oracletypes "github.com/cosmos/cosmos-sdk/x/oracle/types" - "time" "github.com/bnb-chain/greenfield-relayer/common" "github.com/bnb-chain/greenfield-relayer/config" diff --git a/config/config.go b/config/config.go index 259d305..0bda292 100644 --- a/config/config.go +++ b/config/config.go @@ -118,6 +118,7 @@ type RelayConfig struct { CrossChainPackageEventHex string `json:"cross_chain_package_event_hex"` CrossChainContractAddr string `json:"cross_chain_contract_addr"` GreenfieldLightClientContractAddr string `json:"greenfield_light_client_contract_addr"` + RelayerHubContractAddr string `json:"relayer_hub_contract_addr"` } func (cfg *RelayConfig) Validate() { diff --git a/executor/crosschain/crosschain.abi b/contract/crosschain/crosschain.abi similarity index 100% rename from executor/crosschain/crosschain.abi rename to contract/crosschain/crosschain.abi diff --git a/executor/crosschain/crosschain.go b/contract/crosschain/crosschain.go similarity index 100% rename from executor/crosschain/crosschain.go rename to contract/crosschain/crosschain.go diff --git a/executor/greenfieldlightclient/greenfieldlightclient.abi b/contract/greenfieldlightclient/greenfieldlightclient.abi similarity index 100% rename from executor/greenfieldlightclient/greenfieldlightclient.abi rename to contract/greenfieldlightclient/greenfieldlightclient.abi diff --git a/executor/greenfieldlightclient/greenfieldlightclient.go b/contract/greenfieldlightclient/greenfieldlightclient.go similarity index 100% rename from executor/greenfieldlightclient/greenfieldlightclient.go rename to contract/greenfieldlightclient/greenfieldlightclient.go diff --git a/contract/relayerhub/relayerhub.abi b/contract/relayerhub/relayerhub.abi new file mode 100644 index 0000000..4f9f68b --- /dev/null +++ b/contract/relayerhub/relayerhub.abi @@ -0,0 +1,364 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ClaimedReward", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardToRelayer", + "type": "event" + }, + { + "inputs": [], + "name": "BUCKET_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "BUCKET_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "CROSS_CHAIN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "ConfigSlots", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GOV_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GROUP_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "GROUP_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "LIGHT_CLIENT", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OBJECT_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OBJECT_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PROXY_ADMIN", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYER_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "REWARD_RATIO_SCALE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TOKEN_HUB", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_IN_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_OUT_CHANNEL_ID", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_relayer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_reward", + "type": "uint256" + } + ], + "name": "addReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_relayer", + "type": "address" + } + ], + "name": "claimReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "rewardMap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "versionInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "version", + "type": "uint256" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ] \ No newline at end of file diff --git a/contract/relayerhub/relayerhub.go b/contract/relayerhub/relayerhub.go new file mode 100644 index 0000000..95370ce --- /dev/null +++ b/contract/relayerhub/relayerhub.go @@ -0,0 +1,1277 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package relayerhub + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// RelayerhubMetaData contains all meta data concerning the Relayerhub contract. +var RelayerhubMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"relayer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ClaimedReward\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"relayer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RewardToRelayer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BUCKET_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"BUCKET_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"CROSS_CHAIN\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"ConfigSlots\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOV_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOV_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GROUP_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GROUP_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"LIGHT_CLIENT\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"OBJECT_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"OBJECT_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PROXY_ADMIN\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RELAYER_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REWARD_RATIO_SCALE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TOKEN_HUB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_IN_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_OUT_CHANNEL_ID\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_relayer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_reward\",\"type\":\"uint256\"}],\"name\":\"addReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"_relayer\",\"type\":\"address\"}],\"name\":\"claimReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"rewardMap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"versionInfo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", +} + +// RelayerhubABI is the input ABI used to generate the binding from. +// Deprecated: Use RelayerhubMetaData.ABI instead. +var RelayerhubABI = RelayerhubMetaData.ABI + +// Relayerhub is an auto generated Go binding around an Ethereum contract. +type Relayerhub struct { + RelayerhubCaller // Read-only binding to the contract + RelayerhubTransactor // Write-only binding to the contract + RelayerhubFilterer // Log filterer for contract events +} + +// RelayerhubCaller is an auto generated read-only Go binding around an Ethereum contract. +type RelayerhubCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RelayerhubTransactor is an auto generated write-only Go binding around an Ethereum contract. +type RelayerhubTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RelayerhubFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type RelayerhubFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RelayerhubSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type RelayerhubSession struct { + Contract *Relayerhub // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// RelayerhubCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type RelayerhubCallerSession struct { + Contract *RelayerhubCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// RelayerhubTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type RelayerhubTransactorSession struct { + Contract *RelayerhubTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// RelayerhubRaw is an auto generated low-level Go binding around an Ethereum contract. +type RelayerhubRaw struct { + Contract *Relayerhub // Generic contract binding to access the raw methods on +} + +// RelayerhubCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type RelayerhubCallerRaw struct { + Contract *RelayerhubCaller // Generic read-only contract binding to access the raw methods on +} + +// RelayerhubTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type RelayerhubTransactorRaw struct { + Contract *RelayerhubTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewRelayerhub creates a new instance of Relayerhub, bound to a specific deployed contract. +func NewRelayerhub(address common.Address, backend bind.ContractBackend) (*Relayerhub, error) { + contract, err := bindRelayerhub(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Relayerhub{RelayerhubCaller: RelayerhubCaller{contract: contract}, RelayerhubTransactor: RelayerhubTransactor{contract: contract}, RelayerhubFilterer: RelayerhubFilterer{contract: contract}}, nil +} + +// NewRelayerhubCaller creates a new read-only instance of Relayerhub, bound to a specific deployed contract. +func NewRelayerhubCaller(address common.Address, caller bind.ContractCaller) (*RelayerhubCaller, error) { + contract, err := bindRelayerhub(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &RelayerhubCaller{contract: contract}, nil +} + +// NewRelayerhubTransactor creates a new write-only instance of Relayerhub, bound to a specific deployed contract. +func NewRelayerhubTransactor(address common.Address, transactor bind.ContractTransactor) (*RelayerhubTransactor, error) { + contract, err := bindRelayerhub(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &RelayerhubTransactor{contract: contract}, nil +} + +// NewRelayerhubFilterer creates a new log filterer instance of Relayerhub, bound to a specific deployed contract. +func NewRelayerhubFilterer(address common.Address, filterer bind.ContractFilterer) (*RelayerhubFilterer, error) { + contract, err := bindRelayerhub(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &RelayerhubFilterer{contract: contract}, nil +} + +// bindRelayerhub binds a generic wrapper to an already deployed contract. +func bindRelayerhub(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := RelayerhubMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Relayerhub *RelayerhubRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Relayerhub.Contract.RelayerhubCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Relayerhub *RelayerhubRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Relayerhub.Contract.RelayerhubTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Relayerhub *RelayerhubRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Relayerhub.Contract.RelayerhubTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Relayerhub *RelayerhubCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Relayerhub.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Relayerhub *RelayerhubTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Relayerhub.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Relayerhub *RelayerhubTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Relayerhub.Contract.contract.Transact(opts, method, params...) +} + +// BUCKETCHANNELID is a free data retrieval call binding the contract method 0x73f1e3c3. +// +// Solidity: function BUCKET_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) BUCKETCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "BUCKET_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// BUCKETCHANNELID is a free data retrieval call binding the contract method 0x73f1e3c3. +// +// Solidity: function BUCKET_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) BUCKETCHANNELID() (uint8, error) { + return _Relayerhub.Contract.BUCKETCHANNELID(&_Relayerhub.CallOpts) +} + +// BUCKETCHANNELID is a free data retrieval call binding the contract method 0x73f1e3c3. +// +// Solidity: function BUCKET_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) BUCKETCHANNELID() (uint8, error) { + return _Relayerhub.Contract.BUCKETCHANNELID(&_Relayerhub.CallOpts) +} + +// BUCKETHUB is a free data retrieval call binding the contract method 0x7afffdd2. +// +// Solidity: function BUCKET_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) BUCKETHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "BUCKET_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// BUCKETHUB is a free data retrieval call binding the contract method 0x7afffdd2. +// +// Solidity: function BUCKET_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) BUCKETHUB() (common.Address, error) { + return _Relayerhub.Contract.BUCKETHUB(&_Relayerhub.CallOpts) +} + +// BUCKETHUB is a free data retrieval call binding the contract method 0x7afffdd2. +// +// Solidity: function BUCKET_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) BUCKETHUB() (common.Address, error) { + return _Relayerhub.Contract.BUCKETHUB(&_Relayerhub.CallOpts) +} + +// CROSSCHAIN is a free data retrieval call binding the contract method 0x557cf477. +// +// Solidity: function CROSS_CHAIN() view returns(address) +func (_Relayerhub *RelayerhubCaller) CROSSCHAIN(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "CROSS_CHAIN") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// CROSSCHAIN is a free data retrieval call binding the contract method 0x557cf477. +// +// Solidity: function CROSS_CHAIN() view returns(address) +func (_Relayerhub *RelayerhubSession) CROSSCHAIN() (common.Address, error) { + return _Relayerhub.Contract.CROSSCHAIN(&_Relayerhub.CallOpts) +} + +// CROSSCHAIN is a free data retrieval call binding the contract method 0x557cf477. +// +// Solidity: function CROSS_CHAIN() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) CROSSCHAIN() (common.Address, error) { + return _Relayerhub.Contract.CROSSCHAIN(&_Relayerhub.CallOpts) +} + +// ConfigSlots is a free data retrieval call binding the contract method 0xb76e4aca. +// +// Solidity: function ConfigSlots(uint256 ) view returns(uint256) +func (_Relayerhub *RelayerhubCaller) ConfigSlots(opts *bind.CallOpts, arg0 *big.Int) (*big.Int, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "ConfigSlots", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ConfigSlots is a free data retrieval call binding the contract method 0xb76e4aca. +// +// Solidity: function ConfigSlots(uint256 ) view returns(uint256) +func (_Relayerhub *RelayerhubSession) ConfigSlots(arg0 *big.Int) (*big.Int, error) { + return _Relayerhub.Contract.ConfigSlots(&_Relayerhub.CallOpts, arg0) +} + +// ConfigSlots is a free data retrieval call binding the contract method 0xb76e4aca. +// +// Solidity: function ConfigSlots(uint256 ) view returns(uint256) +func (_Relayerhub *RelayerhubCallerSession) ConfigSlots(arg0 *big.Int) (*big.Int, error) { + return _Relayerhub.Contract.ConfigSlots(&_Relayerhub.CallOpts, arg0) +} + +// GOVCHANNELID is a free data retrieval call binding the contract method 0x81d91480. +// +// Solidity: function GOV_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) GOVCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "GOV_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// GOVCHANNELID is a free data retrieval call binding the contract method 0x81d91480. +// +// Solidity: function GOV_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) GOVCHANNELID() (uint8, error) { + return _Relayerhub.Contract.GOVCHANNELID(&_Relayerhub.CallOpts) +} + +// GOVCHANNELID is a free data retrieval call binding the contract method 0x81d91480. +// +// Solidity: function GOV_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) GOVCHANNELID() (uint8, error) { + return _Relayerhub.Contract.GOVCHANNELID(&_Relayerhub.CallOpts) +} + +// GOVHUB is a free data retrieval call binding the contract method 0xa9dae71c. +// +// Solidity: function GOV_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) GOVHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "GOV_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GOVHUB is a free data retrieval call binding the contract method 0xa9dae71c. +// +// Solidity: function GOV_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) GOVHUB() (common.Address, error) { + return _Relayerhub.Contract.GOVHUB(&_Relayerhub.CallOpts) +} + +// GOVHUB is a free data retrieval call binding the contract method 0xa9dae71c. +// +// Solidity: function GOV_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) GOVHUB() (common.Address, error) { + return _Relayerhub.Contract.GOVHUB(&_Relayerhub.CallOpts) +} + +// GROUPCHANNELID is a free data retrieval call binding the contract method 0xe02e86b0. +// +// Solidity: function GROUP_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) GROUPCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "GROUP_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// GROUPCHANNELID is a free data retrieval call binding the contract method 0xe02e86b0. +// +// Solidity: function GROUP_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) GROUPCHANNELID() (uint8, error) { + return _Relayerhub.Contract.GROUPCHANNELID(&_Relayerhub.CallOpts) +} + +// GROUPCHANNELID is a free data retrieval call binding the contract method 0xe02e86b0. +// +// Solidity: function GROUP_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) GROUPCHANNELID() (uint8, error) { + return _Relayerhub.Contract.GROUPCHANNELID(&_Relayerhub.CallOpts) +} + +// GROUPHUB is a free data retrieval call binding the contract method 0x46934fc8. +// +// Solidity: function GROUP_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) GROUPHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "GROUP_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GROUPHUB is a free data retrieval call binding the contract method 0x46934fc8. +// +// Solidity: function GROUP_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) GROUPHUB() (common.Address, error) { + return _Relayerhub.Contract.GROUPHUB(&_Relayerhub.CallOpts) +} + +// GROUPHUB is a free data retrieval call binding the contract method 0x46934fc8. +// +// Solidity: function GROUP_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) GROUPHUB() (common.Address, error) { + return _Relayerhub.Contract.GROUPHUB(&_Relayerhub.CallOpts) +} + +// LIGHTCLIENT is a free data retrieval call binding the contract method 0xe613ae00. +// +// Solidity: function LIGHT_CLIENT() view returns(address) +func (_Relayerhub *RelayerhubCaller) LIGHTCLIENT(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "LIGHT_CLIENT") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// LIGHTCLIENT is a free data retrieval call binding the contract method 0xe613ae00. +// +// Solidity: function LIGHT_CLIENT() view returns(address) +func (_Relayerhub *RelayerhubSession) LIGHTCLIENT() (common.Address, error) { + return _Relayerhub.Contract.LIGHTCLIENT(&_Relayerhub.CallOpts) +} + +// LIGHTCLIENT is a free data retrieval call binding the contract method 0xe613ae00. +// +// Solidity: function LIGHT_CLIENT() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) LIGHTCLIENT() (common.Address, error) { + return _Relayerhub.Contract.LIGHTCLIENT(&_Relayerhub.CallOpts) +} + +// OBJECTCHANNELID is a free data retrieval call binding the contract method 0xeac78b33. +// +// Solidity: function OBJECT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) OBJECTCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "OBJECT_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// OBJECTCHANNELID is a free data retrieval call binding the contract method 0xeac78b33. +// +// Solidity: function OBJECT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) OBJECTCHANNELID() (uint8, error) { + return _Relayerhub.Contract.OBJECTCHANNELID(&_Relayerhub.CallOpts) +} + +// OBJECTCHANNELID is a free data retrieval call binding the contract method 0xeac78b33. +// +// Solidity: function OBJECT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) OBJECTCHANNELID() (uint8, error) { + return _Relayerhub.Contract.OBJECTCHANNELID(&_Relayerhub.CallOpts) +} + +// OBJECTHUB is a free data retrieval call binding the contract method 0x7d2e3084. +// +// Solidity: function OBJECT_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) OBJECTHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "OBJECT_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// OBJECTHUB is a free data retrieval call binding the contract method 0x7d2e3084. +// +// Solidity: function OBJECT_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) OBJECTHUB() (common.Address, error) { + return _Relayerhub.Contract.OBJECTHUB(&_Relayerhub.CallOpts) +} + +// OBJECTHUB is a free data retrieval call binding the contract method 0x7d2e3084. +// +// Solidity: function OBJECT_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) OBJECTHUB() (common.Address, error) { + return _Relayerhub.Contract.OBJECTHUB(&_Relayerhub.CallOpts) +} + +// PROXYADMIN is a free data retrieval call binding the contract method 0xed9bc82a. +// +// Solidity: function PROXY_ADMIN() view returns(address) +func (_Relayerhub *RelayerhubCaller) PROXYADMIN(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "PROXY_ADMIN") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// PROXYADMIN is a free data retrieval call binding the contract method 0xed9bc82a. +// +// Solidity: function PROXY_ADMIN() view returns(address) +func (_Relayerhub *RelayerhubSession) PROXYADMIN() (common.Address, error) { + return _Relayerhub.Contract.PROXYADMIN(&_Relayerhub.CallOpts) +} + +// PROXYADMIN is a free data retrieval call binding the contract method 0xed9bc82a. +// +// Solidity: function PROXY_ADMIN() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) PROXYADMIN() (common.Address, error) { + return _Relayerhub.Contract.PROXYADMIN(&_Relayerhub.CallOpts) +} + +// RELAYERHUB is a free data retrieval call binding the contract method 0xb9d86913. +// +// Solidity: function RELAYER_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) RELAYERHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "RELAYER_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// RELAYERHUB is a free data retrieval call binding the contract method 0xb9d86913. +// +// Solidity: function RELAYER_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) RELAYERHUB() (common.Address, error) { + return _Relayerhub.Contract.RELAYERHUB(&_Relayerhub.CallOpts) +} + +// RELAYERHUB is a free data retrieval call binding the contract method 0xb9d86913. +// +// Solidity: function RELAYER_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) RELAYERHUB() (common.Address, error) { + return _Relayerhub.Contract.RELAYERHUB(&_Relayerhub.CallOpts) +} + +// REWARDRATIOSCALE is a free data retrieval call binding the contract method 0x132f2adb. +// +// Solidity: function REWARD_RATIO_SCALE() view returns(uint256) +func (_Relayerhub *RelayerhubCaller) REWARDRATIOSCALE(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "REWARD_RATIO_SCALE") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// REWARDRATIOSCALE is a free data retrieval call binding the contract method 0x132f2adb. +// +// Solidity: function REWARD_RATIO_SCALE() view returns(uint256) +func (_Relayerhub *RelayerhubSession) REWARDRATIOSCALE() (*big.Int, error) { + return _Relayerhub.Contract.REWARDRATIOSCALE(&_Relayerhub.CallOpts) +} + +// REWARDRATIOSCALE is a free data retrieval call binding the contract method 0x132f2adb. +// +// Solidity: function REWARD_RATIO_SCALE() view returns(uint256) +func (_Relayerhub *RelayerhubCallerSession) REWARDRATIOSCALE() (*big.Int, error) { + return _Relayerhub.Contract.REWARDRATIOSCALE(&_Relayerhub.CallOpts) +} + +// TOKENHUB is a free data retrieval call binding the contract method 0x6d3358a1. +// +// Solidity: function TOKEN_HUB() view returns(address) +func (_Relayerhub *RelayerhubCaller) TOKENHUB(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "TOKEN_HUB") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TOKENHUB is a free data retrieval call binding the contract method 0x6d3358a1. +// +// Solidity: function TOKEN_HUB() view returns(address) +func (_Relayerhub *RelayerhubSession) TOKENHUB() (common.Address, error) { + return _Relayerhub.Contract.TOKENHUB(&_Relayerhub.CallOpts) +} + +// TOKENHUB is a free data retrieval call binding the contract method 0x6d3358a1. +// +// Solidity: function TOKEN_HUB() view returns(address) +func (_Relayerhub *RelayerhubCallerSession) TOKENHUB() (common.Address, error) { + return _Relayerhub.Contract.TOKENHUB(&_Relayerhub.CallOpts) +} + +// TRANSFERINCHANNELID is a free data retrieval call binding the contract method 0xcc12eabc. +// +// Solidity: function TRANSFER_IN_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) TRANSFERINCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "TRANSFER_IN_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// TRANSFERINCHANNELID is a free data retrieval call binding the contract method 0xcc12eabc. +// +// Solidity: function TRANSFER_IN_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) TRANSFERINCHANNELID() (uint8, error) { + return _Relayerhub.Contract.TRANSFERINCHANNELID(&_Relayerhub.CallOpts) +} + +// TRANSFERINCHANNELID is a free data retrieval call binding the contract method 0xcc12eabc. +// +// Solidity: function TRANSFER_IN_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) TRANSFERINCHANNELID() (uint8, error) { + return _Relayerhub.Contract.TRANSFERINCHANNELID(&_Relayerhub.CallOpts) +} + +// TRANSFEROUTCHANNELID is a free data retrieval call binding the contract method 0x618d569c. +// +// Solidity: function TRANSFER_OUT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCaller) TRANSFEROUTCHANNELID(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "TRANSFER_OUT_CHANNEL_ID") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// TRANSFEROUTCHANNELID is a free data retrieval call binding the contract method 0x618d569c. +// +// Solidity: function TRANSFER_OUT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubSession) TRANSFEROUTCHANNELID() (uint8, error) { + return _Relayerhub.Contract.TRANSFEROUTCHANNELID(&_Relayerhub.CallOpts) +} + +// TRANSFEROUTCHANNELID is a free data retrieval call binding the contract method 0x618d569c. +// +// Solidity: function TRANSFER_OUT_CHANNEL_ID() view returns(uint8) +func (_Relayerhub *RelayerhubCallerSession) TRANSFEROUTCHANNELID() (uint8, error) { + return _Relayerhub.Contract.TRANSFEROUTCHANNELID(&_Relayerhub.CallOpts) +} + +// RewardMap is a free data retrieval call binding the contract method 0x83d44339. +// +// Solidity: function rewardMap(address ) view returns(uint256) +func (_Relayerhub *RelayerhubCaller) RewardMap(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "rewardMap", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// RewardMap is a free data retrieval call binding the contract method 0x83d44339. +// +// Solidity: function rewardMap(address ) view returns(uint256) +func (_Relayerhub *RelayerhubSession) RewardMap(arg0 common.Address) (*big.Int, error) { + return _Relayerhub.Contract.RewardMap(&_Relayerhub.CallOpts, arg0) +} + +// RewardMap is a free data retrieval call binding the contract method 0x83d44339. +// +// Solidity: function rewardMap(address ) view returns(uint256) +func (_Relayerhub *RelayerhubCallerSession) RewardMap(arg0 common.Address) (*big.Int, error) { + return _Relayerhub.Contract.RewardMap(&_Relayerhub.CallOpts, arg0) +} + +// VersionInfo is a free data retrieval call binding the contract method 0xa21d1354. +// +// Solidity: function versionInfo() pure returns(uint256 version, string name, string description) +func (_Relayerhub *RelayerhubCaller) VersionInfo(opts *bind.CallOpts) (struct { + Version *big.Int + Name string + Description string +}, error) { + var out []interface{} + err := _Relayerhub.contract.Call(opts, &out, "versionInfo") + + outstruct := new(struct { + Version *big.Int + Name string + Description string + }) + if err != nil { + return *outstruct, err + } + + outstruct.Version = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.Name = *abi.ConvertType(out[1], new(string)).(*string) + outstruct.Description = *abi.ConvertType(out[2], new(string)).(*string) + + return *outstruct, err + +} + +// VersionInfo is a free data retrieval call binding the contract method 0xa21d1354. +// +// Solidity: function versionInfo() pure returns(uint256 version, string name, string description) +func (_Relayerhub *RelayerhubSession) VersionInfo() (struct { + Version *big.Int + Name string + Description string +}, error) { + return _Relayerhub.Contract.VersionInfo(&_Relayerhub.CallOpts) +} + +// VersionInfo is a free data retrieval call binding the contract method 0xa21d1354. +// +// Solidity: function versionInfo() pure returns(uint256 version, string name, string description) +func (_Relayerhub *RelayerhubCallerSession) VersionInfo() (struct { + Version *big.Int + Name string + Description string +}, error) { + return _Relayerhub.Contract.VersionInfo(&_Relayerhub.CallOpts) +} + +// AddReward is a paid mutator transaction binding the contract method 0x9feb8f50. +// +// Solidity: function addReward(address _relayer, uint256 _reward) returns() +func (_Relayerhub *RelayerhubTransactor) AddReward(opts *bind.TransactOpts, _relayer common.Address, _reward *big.Int) (*types.Transaction, error) { + return _Relayerhub.contract.Transact(opts, "addReward", _relayer, _reward) +} + +// AddReward is a paid mutator transaction binding the contract method 0x9feb8f50. +// +// Solidity: function addReward(address _relayer, uint256 _reward) returns() +func (_Relayerhub *RelayerhubSession) AddReward(_relayer common.Address, _reward *big.Int) (*types.Transaction, error) { + return _Relayerhub.Contract.AddReward(&_Relayerhub.TransactOpts, _relayer, _reward) +} + +// AddReward is a paid mutator transaction binding the contract method 0x9feb8f50. +// +// Solidity: function addReward(address _relayer, uint256 _reward) returns() +func (_Relayerhub *RelayerhubTransactorSession) AddReward(_relayer common.Address, _reward *big.Int) (*types.Transaction, error) { + return _Relayerhub.Contract.AddReward(&_Relayerhub.TransactOpts, _relayer, _reward) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0xd279c191. +// +// Solidity: function claimReward(address _relayer) returns() +func (_Relayerhub *RelayerhubTransactor) ClaimReward(opts *bind.TransactOpts, _relayer common.Address) (*types.Transaction, error) { + return _Relayerhub.contract.Transact(opts, "claimReward", _relayer) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0xd279c191. +// +// Solidity: function claimReward(address _relayer) returns() +func (_Relayerhub *RelayerhubSession) ClaimReward(_relayer common.Address) (*types.Transaction, error) { + return _Relayerhub.Contract.ClaimReward(&_Relayerhub.TransactOpts, _relayer) +} + +// ClaimReward is a paid mutator transaction binding the contract method 0xd279c191. +// +// Solidity: function claimReward(address _relayer) returns() +func (_Relayerhub *RelayerhubTransactorSession) ClaimReward(_relayer common.Address) (*types.Transaction, error) { + return _Relayerhub.Contract.ClaimReward(&_Relayerhub.TransactOpts, _relayer) +} + +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_Relayerhub *RelayerhubTransactor) Initialize(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Relayerhub.contract.Transact(opts, "initialize") +} + +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_Relayerhub *RelayerhubSession) Initialize() (*types.Transaction, error) { + return _Relayerhub.Contract.Initialize(&_Relayerhub.TransactOpts) +} + +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_Relayerhub *RelayerhubTransactorSession) Initialize() (*types.Transaction, error) { + return _Relayerhub.Contract.Initialize(&_Relayerhub.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Relayerhub *RelayerhubTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Relayerhub.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Relayerhub *RelayerhubSession) Receive() (*types.Transaction, error) { + return _Relayerhub.Contract.Receive(&_Relayerhub.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Relayerhub *RelayerhubTransactorSession) Receive() (*types.Transaction, error) { + return _Relayerhub.Contract.Receive(&_Relayerhub.TransactOpts) +} + +// RelayerhubClaimedRewardIterator is returned from FilterClaimedReward and is used to iterate over the raw logs and unpacked data for ClaimedReward events raised by the Relayerhub contract. +type RelayerhubClaimedRewardIterator struct { + Event *RelayerhubClaimedReward // 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 *RelayerhubClaimedRewardIterator) 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(RelayerhubClaimedReward) + 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(RelayerhubClaimedReward) + 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 *RelayerhubClaimedRewardIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *RelayerhubClaimedRewardIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// RelayerhubClaimedReward represents a ClaimedReward event raised by the Relayerhub contract. +type RelayerhubClaimedReward struct { + Relayer common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterClaimedReward is a free log retrieval operation binding the contract event 0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3. +// +// Solidity: event ClaimedReward(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) FilterClaimedReward(opts *bind.FilterOpts) (*RelayerhubClaimedRewardIterator, error) { + + logs, sub, err := _Relayerhub.contract.FilterLogs(opts, "ClaimedReward") + if err != nil { + return nil, err + } + return &RelayerhubClaimedRewardIterator{contract: _Relayerhub.contract, event: "ClaimedReward", logs: logs, sub: sub}, nil +} + +// WatchClaimedReward is a free log subscription operation binding the contract event 0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3. +// +// Solidity: event ClaimedReward(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) WatchClaimedReward(opts *bind.WatchOpts, sink chan<- *RelayerhubClaimedReward) (event.Subscription, error) { + + logs, sub, err := _Relayerhub.contract.WatchLogs(opts, "ClaimedReward") + 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(RelayerhubClaimedReward) + if err := _Relayerhub.contract.UnpackLog(event, "ClaimedReward", 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 +} + +// ParseClaimedReward is a log parse operation binding the contract event 0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3. +// +// Solidity: event ClaimedReward(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) ParseClaimedReward(log types.Log) (*RelayerhubClaimedReward, error) { + event := new(RelayerhubClaimedReward) + if err := _Relayerhub.contract.UnpackLog(event, "ClaimedReward", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// RelayerhubInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Relayerhub contract. +type RelayerhubInitializedIterator struct { + Event *RelayerhubInitialized // 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 *RelayerhubInitializedIterator) 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(RelayerhubInitialized) + 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(RelayerhubInitialized) + 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 *RelayerhubInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *RelayerhubInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// RelayerhubInitialized represents a Initialized event raised by the Relayerhub contract. +type RelayerhubInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Relayerhub *RelayerhubFilterer) FilterInitialized(opts *bind.FilterOpts) (*RelayerhubInitializedIterator, error) { + + logs, sub, err := _Relayerhub.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &RelayerhubInitializedIterator{contract: _Relayerhub.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Relayerhub *RelayerhubFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *RelayerhubInitialized) (event.Subscription, error) { + + logs, sub, err := _Relayerhub.contract.WatchLogs(opts, "Initialized") + 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(RelayerhubInitialized) + if err := _Relayerhub.contract.UnpackLog(event, "Initialized", 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 +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Relayerhub *RelayerhubFilterer) ParseInitialized(log types.Log) (*RelayerhubInitialized, error) { + event := new(RelayerhubInitialized) + if err := _Relayerhub.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// RelayerhubRewardToRelayerIterator is returned from FilterRewardToRelayer and is used to iterate over the raw logs and unpacked data for RewardToRelayer events raised by the Relayerhub contract. +type RelayerhubRewardToRelayerIterator struct { + Event *RelayerhubRewardToRelayer // 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 *RelayerhubRewardToRelayerIterator) 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(RelayerhubRewardToRelayer) + 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(RelayerhubRewardToRelayer) + 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 *RelayerhubRewardToRelayerIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *RelayerhubRewardToRelayerIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// RelayerhubRewardToRelayer represents a RewardToRelayer event raised by the Relayerhub contract. +type RelayerhubRewardToRelayer struct { + Relayer common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRewardToRelayer is a free log retrieval operation binding the contract event 0xcc3341048e8fd1ed288bcd99bd6231605849b6301fe5ae9170850a29d9b1c2dd. +// +// Solidity: event RewardToRelayer(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) FilterRewardToRelayer(opts *bind.FilterOpts) (*RelayerhubRewardToRelayerIterator, error) { + + logs, sub, err := _Relayerhub.contract.FilterLogs(opts, "RewardToRelayer") + if err != nil { + return nil, err + } + return &RelayerhubRewardToRelayerIterator{contract: _Relayerhub.contract, event: "RewardToRelayer", logs: logs, sub: sub}, nil +} + +// WatchRewardToRelayer is a free log subscription operation binding the contract event 0xcc3341048e8fd1ed288bcd99bd6231605849b6301fe5ae9170850a29d9b1c2dd. +// +// Solidity: event RewardToRelayer(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) WatchRewardToRelayer(opts *bind.WatchOpts, sink chan<- *RelayerhubRewardToRelayer) (event.Subscription, error) { + + logs, sub, err := _Relayerhub.contract.WatchLogs(opts, "RewardToRelayer") + 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(RelayerhubRewardToRelayer) + if err := _Relayerhub.contract.UnpackLog(event, "RewardToRelayer", 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 +} + +// ParseRewardToRelayer is a log parse operation binding the contract event 0xcc3341048e8fd1ed288bcd99bd6231605849b6301fe5ae9170850a29d9b1c2dd. +// +// Solidity: event RewardToRelayer(address relayer, uint256 amount) +func (_Relayerhub *RelayerhubFilterer) ParseRewardToRelayer(log types.Log) (*RelayerhubRewardToRelayer, error) { + event := new(RelayerhubRewardToRelayer) + if err := _Relayerhub.contract.UnpackLog(event, "RewardToRelayer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/db/dao/bsc_dao.go b/db/dao/bsc_dao.go index a4c738a..f93b47e 100644 --- a/db/dao/bsc_dao.go +++ b/db/dao/bsc_dao.go @@ -155,3 +155,35 @@ func (d *BSCDao) DeleteBlockAndPackagesAtHeight(height uint64) error { return nil }) } + +func (d *BSCDao) DeleteBlocksBelowHeight(threshHold int64) error { + return d.DB.Transaction(func(dbTx *gorm.DB) error { + err := dbTx.Where("height < ?", threshHold).Delete(model.BscBlock{}).Error + if err != nil { + return err + } + return nil + }) +} + +func (d *BSCDao) DeletePackagesBelowHeightWithLimit(threshHold int64, limit int) error { + return d.DB.Transaction(func(dbTx *gorm.DB) error { + err := dbTx.Where("height < ?", threshHold).Delete(model.BscRelayPackage{}).Limit(limit).Error + if err != nil { + return err + } + return nil + }) +} + +func (d *BSCDao) ExistsUnprocessedPackage(threshHold int64) (bool, error) { + tx := model.BscRelayPackage{} + err := d.DB.Model(model.BscRelayPackage{}).Where("status = ? or status = ? and height < ?", db.Saved, db.SelfVoted, threshHold).Take(&tx).Error + if err != nil { + if err == gorm.ErrRecordNotFound { + return false, nil + } + return false, err + } + return true, nil +} diff --git a/db/dao/greenfield_dao.go b/db/dao/greenfield_dao.go index e4b480e..b7aa051 100644 --- a/db/dao/greenfield_dao.go +++ b/db/dao/greenfield_dao.go @@ -135,3 +135,35 @@ func (d *GreenfieldDao) GetLatestSyncedTransaction() (*model.SyncLightBlockTrans } return &tx, nil } + +func (d *GreenfieldDao) DeleteBlocksBelowHeight(threshHold int64) error { + return d.DB.Transaction(func(dbTx *gorm.DB) error { + err := dbTx.Where("height < ?", threshHold).Delete(model.GreenfieldBlock{}).Error + if err != nil { + return err + } + return nil + }) +} + +func (d *GreenfieldDao) DeleteTransactionsBelowHeightWithLimit(threshHold int64, limit int) error { + return d.DB.Transaction(func(dbTx *gorm.DB) error { + err := dbTx.Where("height < ?", threshHold).Delete(model.GreenfieldRelayTransaction{}).Limit(limit).Error + if err != nil { + return err + } + return nil + }) +} + +func (d *GreenfieldDao) ExistsUnprocessedTransaction(threshHold int64) (bool, error) { + tx := model.GreenfieldRelayTransaction{} + err := d.DB.Model(model.GreenfieldRelayTransaction{}).Where("status = ? or status = ? and height < ?", db.Saved, db.SelfVoted, threshHold).Take(&tx).Error + if err != nil { + if err == gorm.ErrRecordNotFound { + return false, nil + } + return false, err + } + return true, nil +} diff --git a/db/dao/vote_dao.go b/db/dao/vote_dao.go index 98f93e2..f206f5c 100644 --- a/db/dao/vote_dao.go +++ b/db/dao/vote_dao.go @@ -80,3 +80,13 @@ func (d *VoteDao) SaveBatchVotes(votes []*model.Vote) error { return dbTx.Create(votes).Error }) } + +func (d *VoteDao) DeleteVotesBelowHeightWithLimit(threshHold int64, eventType uint32, limit int) error { + return d.DB.Transaction(func(dbTx *gorm.DB) error { + err := dbTx.Where("event_type = ? and height < ?", eventType, threshHold).Delete(model.Vote{}).Limit(limit).Error + if err != nil { + return err + } + return nil + }) +} diff --git a/db/model/votepool_model.go b/db/model/votepool_model.go index 1982112..57d7647 100644 --- a/db/model/votepool_model.go +++ b/db/model/votepool_model.go @@ -6,6 +6,7 @@ import ( type Vote struct { Id int64 + Height int64 `gorm:"NOT NULL;index:idx_vote_height"` Signature string `gorm:"NOT NULL"` EventType uint32 `gorm:"NOT NULL"` ClaimPayload []byte `gorm:"NOT NULL"` diff --git a/executor/bsc_executor.go b/executor/bsc_executor.go index 8e85b0c..4d0f69a 100644 --- a/executor/bsc_executor.go +++ b/executor/bsc_executor.go @@ -20,9 +20,11 @@ import ( relayercommon "github.com/bnb-chain/greenfield-relayer/common" "github.com/bnb-chain/greenfield-relayer/config" - "github.com/bnb-chain/greenfield-relayer/executor/crosschain" - "github.com/bnb-chain/greenfield-relayer/executor/greenfieldlightclient" + "github.com/bnb-chain/greenfield-relayer/contract/crosschain" + "github.com/bnb-chain/greenfield-relayer/contract/greenfieldlightclient" + "github.com/bnb-chain/greenfield-relayer/contract/relayerhub" "github.com/bnb-chain/greenfield-relayer/logging" + "github.com/bnb-chain/greenfield-relayer/metric" rtypes "github.com/bnb-chain/greenfield-relayer/types" ) @@ -30,13 +32,13 @@ type BSCClient struct { rpcClient *ethclient.Client crossChainClient *crosschain.Crosschain greenfieldLightClient *greenfieldlightclient.Greenfieldlightclient + relayerHub *relayerhub.Relayerhub provider string height uint64 updatedAt time.Time } type BSCExecutor struct { - gasPriceMutex sync.RWMutex mutex sync.RWMutex GreenfieldExecutor *GreenfieldExecutor clientIdx int @@ -46,6 +48,7 @@ type BSCExecutor struct { txSender common.Address gasPrice *big.Int relayers []rtypes.Validator // cached relayers + metricService *metric.MetricService } func initBSCClients(config *config.Config) []*BSCClient { @@ -68,10 +71,17 @@ func initBSCClients(config *config.Config) []*BSCClient { if err != nil { panic("new greenfield light client error") } + relayerHub, err := relayerhub.NewRelayerhub( + common.HexToAddress(config.RelayConfig.RelayerHubContractAddr), + rpcClient) + if err != nil { + panic("new relayer hub error") + } bscClients = append(bscClients, &BSCClient{ rpcClient: rpcClient, crossChainClient: crossChainClient, greenfieldLightClient: greenfieldLightClient, + relayerHub: relayerHub, provider: provider, updatedAt: time.Now(), }) @@ -101,7 +111,7 @@ func getBscPrivateKey(cfg *config.BSCConfig) string { return privateKey } -func NewBSCExecutor(cfg *config.Config) *BSCExecutor { +func NewBSCExecutor(cfg *config.Config, metricService *metric.MetricService) *BSCExecutor { privKey := viper.GetString(config.FlagConfigPrivateKey) if privKey == "" { privKey = getBscPrivateKey(&cfg.BSCConfig) @@ -124,12 +134,13 @@ func NewBSCExecutor(cfg *config.Config) *BSCExecutor { initGasPrice = big.NewInt(int64(cfg.BSCConfig.GasPrice)) } return &BSCExecutor{ - clientIdx: 0, - bscClients: initBSCClients(cfg), - privateKey: ecdsaPrivKey, - txSender: txSender, - config: cfg, - gasPrice: initGasPrice, + clientIdx: 0, + bscClients: initBSCClients(cfg), + privateKey: ecdsaPrivKey, + txSender: txSender, + config: cfg, + gasPrice: initGasPrice, + metricService: metricService, } } @@ -155,6 +166,12 @@ func (e *BSCExecutor) getGreenfieldLightClient() *greenfieldlightclient.Greenfie return e.bscClients[e.clientIdx].greenfieldLightClient } +func (e *BSCExecutor) getRelayerHub() *relayerhub.Relayerhub { + e.mutex.RLock() + defer e.mutex.RUnlock() + return e.bscClients[e.clientIdx].relayerHub +} + func (e *BSCExecutor) SwitchClient() { e.mutex.Lock() defer e.mutex.Unlock() @@ -322,8 +339,6 @@ func (e *BSCExecutor) getTransactor(nonce uint64) (*bind.TransactOpts, error) { } func (e *BSCExecutor) getGasPrice() *big.Int { - e.gasPriceMutex.RLock() - defer e.gasPriceMutex.RUnlock() return e.gasPrice } @@ -488,3 +503,74 @@ func (e *BSCExecutor) GetInturnRelayer() (*rtypes.InturnRelayer, error) { End: r.End.Uint64(), }, nil } + +func (e *BSCExecutor) getRelayerBalance() (*big.Int, error) { + ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) + defer cancel() + return e.GetRpcClient().BalanceAt(ctx, e.txSender, nil) +} + +func (e *BSCExecutor) claimReward() (common.Hash, error) { + ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) + defer cancel() + nonce, err := e.GetRpcClient().PendingNonceAt(ctx, e.txSender) + if err != nil { + return common.Hash{}, err + } + txOpts, err := e.getTransactor(nonce) + if err != nil { + return common.Hash{}, err + } + txResp, err := e.getRelayerHub().ClaimReward(txOpts, e.txSender) + if err != nil { + return common.Hash{}, err + } + return txResp.Hash(), nil +} + +func (e *BSCExecutor) getRewardBalance() (*big.Int, error) { + ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) + defer cancel() + callOpts := &bind.CallOpts{ + Pending: true, + Context: ctx, + } + return e.getRelayerHub().RewardMap(callOpts, e.txSender) +} + +// ClaimRewardLoop relayer would claim the reward if its balance is below 1BNB and the Reward is over 0.1BNB. +// if after refilled with the rewards, its balance is still lower than 1BNB, it will keep alerting +func (e *BSCExecutor) ClaimRewardLoop() { + ticker := time.NewTicker(ClaimRewardInterval) + for range ticker.C { + logging.Logger.Info("starting claiming rewards loop") + balance, err := e.getRelayerBalance() + if err != nil { + logging.Logger.Errorf("failed to get relayer balance err=%s", err.Error()) + continue + } + logging.Logger.Infof("current relayer balance is %v", balance) + + // should not claim if balance > 1 BNB + if balance.Cmp(BSCBalanceThreshold) > 0 { + e.metricService.SetBSCLowBalance(false) + continue + } + rewardBalance, err := e.getRewardBalance() + if err != nil { + logging.Logger.Errorf("failed to get relayer reward balance err=%s", err.Error()) + continue + } + logging.Logger.Infof("current relayer reward balance is %v", balance) + if rewardBalance.Cmp(BSCRewardThreshold) <= 0 { + e.metricService.SetBSCLowBalance(true) + continue + } + // > 0.1 BNB + txHash, err := e.claimReward() + if err != nil { + logging.Logger.Errorf("failed to claim reward, txHash=%s, err=%s", txHash, err.Error()) + } + logging.Logger.Infof("claimed rewards, txHash is %s", txHash) + } +} diff --git a/executor/bsc_executor_test.go b/executor/bsc_executor_test.go index e0be686..67d1780 100644 --- a/executor/bsc_executor_test.go +++ b/executor/bsc_executor_test.go @@ -13,7 +13,7 @@ import ( func InitBSCExecutor() *BSCExecutor { cfg := GetTestConfig() - return NewBSCExecutor(cfg) + return NewBSCExecutor(cfg, nil) } func TestGetBlockHeight(t *testing.T) { diff --git a/executor/const.go b/executor/const.go index c75032d..a38c25b 100644 --- a/executor/const.go +++ b/executor/const.go @@ -1,6 +1,7 @@ package executor import ( + "math/big" "time" ) @@ -12,4 +13,10 @@ const ( RPCTimeout = 3 * time.Second RelayerBytesLength = 48 UpdateCachedValidatorsInterval = 1 * time.Minute + ClaimRewardInterval = 1 * time.Minute +) + +var ( + BSCBalanceThreshold = big.NewInt(1000000000000000000) // when relayer is lower than 1BNB, it should try to claim rewards + BSCRewardThreshold = big.NewInt(100000000000000000) // if reward is lower than 0.1 BNB, it will not be claimed. ) diff --git a/executor/greenfield_executor.go b/executor/greenfield_executor.go index 9f963d6..22937b2 100644 --- a/executor/greenfield_executor.go +++ b/executor/greenfield_executor.go @@ -12,6 +12,7 @@ import ( tmtypes "github.com/cometbft/cometbft/types" "github.com/cometbft/cometbft/votepool" sdk "github.com/cosmos/cosmos-sdk/types" + sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" oracletypes "github.com/cosmos/cosmos-sdk/x/oracle/types" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/prysmaticlabs/prysm/crypto/bls/blst" @@ -23,7 +24,6 @@ import ( "github.com/bnb-chain/greenfield-relayer/logging" "github.com/bnb-chain/greenfield-relayer/types" gnfdsdktypes "github.com/bnb-chain/greenfield/sdk/types" - sdkErrors "github.com/cosmos/cosmos-sdk/types/errors" ) type GreenfieldExecutor struct { diff --git a/executor/test_util.go b/executor/test_util.go index 70ea185..5ae2b09 100644 --- a/executor/test_util.go +++ b/executor/test_util.go @@ -17,7 +17,7 @@ func GetTestConfig() *config.Config { func InitExecutors() (*BSCExecutor, *GreenfieldExecutor) { cfg := GetTestConfig() gnfdExecutor := NewGreenfieldExecutor(cfg) - bscExecutor := NewBSCExecutor(cfg) + bscExecutor := NewBSCExecutor(cfg, nil) gnfdExecutor.SetBSCExecutor(bscExecutor) bscExecutor.SetGreenfieldExecutor(gnfdExecutor) return bscExecutor, gnfdExecutor diff --git a/integrationtest/config/config_test.json b/integrationtest/config/config_test.json index c171b64..3599cf8 100644 --- a/integrationtest/config/config_test.json +++ b/integrationtest/config/config_test.json @@ -29,7 +29,7 @@ ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 diff --git a/listener/bsc_listener.go b/listener/bsc_listener.go index 45dd5f0..92a3ef8 100644 --- a/listener/bsc_listener.go +++ b/listener/bsc_listener.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/cometbft/cometbft/votepool" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" ethcommon "github.com/ethereum/go-ethereum/common" @@ -13,10 +14,10 @@ import ( "github.com/bnb-chain/greenfield-relayer/common" "github.com/bnb-chain/greenfield-relayer/config" + "github.com/bnb-chain/greenfield-relayer/contract/crosschain" "github.com/bnb-chain/greenfield-relayer/db/dao" "github.com/bnb-chain/greenfield-relayer/db/model" "github.com/bnb-chain/greenfield-relayer/executor" - "github.com/bnb-chain/greenfield-relayer/executor/crosschain" "github.com/bnb-chain/greenfield-relayer/logging" "github.com/bnb-chain/greenfield-relayer/metric" rtypes "github.com/bnb-chain/greenfield-relayer/types" @@ -180,3 +181,33 @@ func (l *BSCListener) getCrossChainPackageEventHash() ethcommon.Hash { func (l *BSCListener) getCrossChainContractAddress() ethcommon.Address { return ethcommon.HexToAddress(l.config.RelayConfig.CrossChainContractAddr) } + +func (l *BSCListener) PurgeLoop() { + ticker := time.NewTicker(PurgeJobInterval) + for range ticker.C { + latestBscBlock, err := l.DaoManager.BSCDao.GetLatestBlock() + if err != nil { + logging.Logger.Errorf("failed to get latest DB BSC block, err=%s", err.Error()) + continue + } + blockHeightThreshHold := int64(latestBscBlock.Height) - NumOfHistoricalBlocks + if blockHeightThreshHold <= 0 { + continue + } + if err = l.DaoManager.BSCDao.DeleteBlocksBelowHeight(blockHeightThreshHold); err != nil { + logging.Logger.Errorf("failed to delete Bsc blocks, err=%s", err.Error()) + continue + } + exists, err := l.DaoManager.BSCDao.ExistsUnprocessedPackage(blockHeightThreshHold) + if err != nil || exists { + continue + } + if err = l.DaoManager.BSCDao.DeletePackagesBelowHeightWithLimit(blockHeightThreshHold, DeletionLimit); err != nil { + logging.Logger.Errorf("failed to delete bsc packages, err=%s", err.Error()) + continue + } + if err = l.DaoManager.VoteDao.DeleteVotesBelowHeightWithLimit(blockHeightThreshHold, uint32(votepool.FromBscCrossChainEvent), DeletionLimit); err != nil { + logging.Logger.Errorf("failed to delete votes, err=%s", err.Error()) + } + } +} diff --git a/listener/const.go b/listener/const.go new file mode 100644 index 0000000..d52e01d --- /dev/null +++ b/listener/const.go @@ -0,0 +1,10 @@ +package listener + +import "time" + +const ( + NumOfHistoricalBlocks = int64(10000) // NumOfHistoricalBlocks is the number of blocks will be kept in DB, all transactions and votes also kept within this range + PurgeJobInterval = time.Minute * 1 + + DeletionLimit = 10000 +) diff --git a/listener/greenfield_listener.go b/listener/greenfield_listener.go index c24bedd..ae653dc 100644 --- a/listener/greenfield_listener.go +++ b/listener/greenfield_listener.go @@ -10,6 +10,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" ctypes "github.com/cometbft/cometbft/rpc/core/types" tmtypes "github.com/cometbft/cometbft/types" + "github.com/cometbft/cometbft/votepool" "github.com/bnb-chain/greenfield-relayer/common" "github.com/bnb-chain/greenfield-relayer/config" @@ -317,3 +318,33 @@ func constructRelayTx(event abci.Event, height uint64) (*model.GreenfieldRelayTr relayTx.UpdatedTime = time.Now().Unix() return &relayTx, nil } + +func (l *GreenfieldListener) PurgeLoop() { + ticker := time.NewTicker(PurgeJobInterval) + for range ticker.C { + latestGnfdBlock, err := l.DaoManager.GreenfieldDao.GetLatestBlock() + if err != nil { + logging.Logger.Errorf("failed to get latest DB BSC block, err=%s", err.Error()) + continue + } + threshHold := int64(latestGnfdBlock.Height) - NumOfHistoricalBlocks + if threshHold <= 0 { + continue + } + if err = l.DaoManager.GreenfieldDao.DeleteBlocksBelowHeight(threshHold); err != nil { + logging.Logger.Errorf("failed to delete gnfd blocks, err=%s", err.Error()) + continue + } + exists, err := l.DaoManager.GreenfieldDao.ExistsUnprocessedTransaction(threshHold) + if err != nil || exists { + continue + } + if err = l.DaoManager.GreenfieldDao.DeleteTransactionsBelowHeightWithLimit(threshHold, DeletionLimit); err != nil { + logging.Logger.Errorf("failed to delete gnfd transactions, err=%s", err.Error()) + continue + } + if err = l.DaoManager.VoteDao.DeleteVotesBelowHeightWithLimit(threshHold, uint32(votepool.ToBscCrossChainEvent), DeletionLimit); err != nil { + logging.Logger.Errorf("failed to delete votes, err=%s", err.Error()) + } + } +} diff --git a/metric/metric_service.go b/metric/service.go similarity index 94% rename from metric/metric_service.go rename to metric/service.go index f4ed69f..fbb0be7 100644 --- a/metric/metric_service.go +++ b/metric/service.go @@ -25,6 +25,8 @@ const ( MetricNameNextSendSequenceForChannel = "next_send_seq_for_channel" MetricNameNextReceiveSequenceForChannel = "next_receive_seq_for_channel" + + MetricNameBSCLowBalance = "bsc_low_balance" ) type MetricService struct { @@ -159,6 +161,13 @@ func NewMetricService(config *config.Config) *MetricService { prometheus.MustRegister(nextReceiveSeq) } + bscLowBalanceMetric := prometheus.NewGauge(prometheus.GaugeOpts{ + Name: MetricNameBSCLowBalance, + Help: "BSC relayer balance is lower than 1BNB, and not enoght reward(<0.1BNB)", + }) + ms[MetricNameBSCLowBalance] = bscLowBalanceMetric + prometheus.MustRegister(bscLowBalanceMetric) + return &MetricService{ MetricsMap: ms, cfg: config, @@ -240,3 +249,11 @@ func (m *MetricService) SetNextSendSequenceForChannel(channel uint8, seq uint64) func (m *MetricService) SetNextReceiveSequenceForChannel(channel uint8, seq uint64) { m.MetricsMap[fmt.Sprintf("%s_%d", MetricNameNextReceiveSequenceForChannel, channel)].(prometheus.Gauge).Set(float64(seq)) } + +func (m *MetricService) SetBSCLowBalance(isLow bool) { + var flag float64 + if isLow { + flag = 1 + } + m.MetricsMap[MetricNameBSCLowBalance].(prometheus.Gauge).Set(flag) +} diff --git a/relayer/bsc_relayer.go b/relayer/bsc_relayer.go index 6992b89..a608712 100644 --- a/relayer/bsc_relayer.go +++ b/relayer/bsc_relayer.go @@ -34,6 +34,8 @@ func (r *BSCRelayer) Start() { go r.AssemblePackagesLoop() go r.UpdateCachedLatestValidatorsLoop() go r.UpdateClientLoop() + go r.ClaimRewardLoop() + go r.PurgeLoop() } // MonitorEventsLoop will monitor cross chain events for every block and persist into DB @@ -60,3 +62,11 @@ func (r *BSCRelayer) UpdateCachedLatestValidatorsLoop() { func (r *BSCRelayer) UpdateClientLoop() { r.bscExecutor.UpdateClientLoop() } + +func (r *BSCRelayer) ClaimRewardLoop() { + r.bscExecutor.ClaimRewardLoop() +} + +func (r *BSCRelayer) PurgeLoop() { + r.Listener.PurgeLoop() +} diff --git a/relayer/greenfield_relayer.go b/relayer/greenfield_relayer.go index 27c1ef4..889ece3 100644 --- a/relayer/greenfield_relayer.go +++ b/relayer/greenfield_relayer.go @@ -32,6 +32,7 @@ func (r *GreenfieldRelayer) Start() { go r.CollectVotesLoop() go r.AssembleTransactionsLoop() go r.UpdateCachedLatestValidatorsLoop() + go r.PurgeLoop() } // MonitorEventsLoop will monitor cross chain events for every block and persist into DB @@ -54,3 +55,7 @@ func (r *GreenfieldRelayer) AssembleTransactionsLoop() { func (r *GreenfieldRelayer) UpdateCachedLatestValidatorsLoop() { r.GreenfieldExecutor.UpdateCachedLatestValidatorsLoop() // cache validators queried from greenfield, update it every 1 minute } + +func (r *GreenfieldRelayer) PurgeLoop() { + r.Listener.PurgeLoop() +} diff --git a/vote/bsc_vote_processor.go b/vote/bsc_vote_processor.go index 4dd19e8..a585feb 100644 --- a/vote/bsc_vote_processor.go +++ b/vote/bsc_vote_processor.go @@ -160,7 +160,7 @@ func (p *BSCVoteProcessor) signAndBroadcast() error { return e } if !exist { - e = dao.SaveVote(dbTx, EntityToDto(v, uint8(channelId), seq, encodedPayload)) + e = dao.SaveVote(dbTx, EntityToDto(v, uint8(channelId), seq, encodedPayload, int64(leastSavedPkgHeight))) if e != nil { return e } @@ -323,7 +323,7 @@ func (p *BSCVoteProcessor) queryMoreThanTwoThirdValidVotes(localVote *model.Vote validVotesCntPerReq-- continue } - if err = p.daoManager.VoteDao.SaveVote(EntityToDto(v, channelId, seq, localVote.ClaimPayload)); err != nil { + if err = p.daoManager.VoteDao.SaveVote(EntityToDto(v, channelId, seq, localVote.ClaimPayload, localVote.Height)); err != nil { return err } } diff --git a/vote/converter.go b/vote/converter.go index c28580b..be1f1ca 100644 --- a/vote/converter.go +++ b/vote/converter.go @@ -26,8 +26,9 @@ func DtoToEntity(v *model.Vote) (*votepool.Vote, error) { return &res, nil } -func EntityToDto(from *votepool.Vote, channelId uint8, sequence uint64, payload []byte) *model.Vote { +func EntityToDto(from *votepool.Vote, channelId uint8, sequence uint64, payload []byte, height int64) *model.Vote { v := model.Vote{ + Height: height, PubKey: hex.EncodeToString(from.PubKey[:]), Signature: hex.EncodeToString(from.Signature[:]), EventType: uint32(from.EventType), diff --git a/vote/greenfield_vote_processor.go b/vote/greenfield_vote_processor.go index b89fb9c..4c98d06 100644 --- a/vote/greenfield_vote_processor.go +++ b/vote/greenfield_vote_processor.go @@ -127,7 +127,7 @@ func (p *GreenfieldVoteProcessor) signAndBroadcast() error { return e } if !exist { - if e = dao.SaveVote(dbTx, EntityToDto(v, tx.ChannelId, tx.Sequence, aggregatedPayload)); e != nil { + if e = dao.SaveVote(dbTx, EntityToDto(v, tx.ChannelId, tx.Sequence, aggregatedPayload, int64(tx.Height))); e != nil { return e } } @@ -285,7 +285,7 @@ func (p *GreenfieldVoteProcessor) queryMoreThanTwoThirdVotesForTx(localVote *mod continue } // a vote result persisted into DB should be valid, unique. - if err = p.daoManager.VoteDao.SaveVote(EntityToDto(v, channelId, seq, localVote.ClaimPayload)); err != nil { + if err = p.daoManager.VoteDao.SaveVote(EntityToDto(v, channelId, seq, localVote.ClaimPayload, localVote.Height)); err != nil { return err } } From 1dce7fc3291ec66feb3e5f1a16c42477bcecf233 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:52:03 +0800 Subject: [PATCH 4/5] feat: get latest finalized block in BSC (#63) * get latest finalized block in BSC * remove unused test * code clean * fix import --- README.md | 7 +- config/config.go | 32 +++---- config/config.json | 7 +- config/local/config_local_0.json | 7 +- config/local/config_local_1.json | 7 +- config/local/config_local_2.json | 7 +- executor/bsc_executor.go | 98 ++++++++++++++-------- executor/bsc_executor_test.go | 9 +- go.mod | 33 +++++--- go.sum | 103 +++++++++++++++-------- integrationtest/bsc_relayer_test.go | 107 ------------------------ integrationtest/config/config_test.json | 14 ++-- integrationtest/test_app.go | 50 ----------- listener/bsc_listener.go | 30 +------ listener/const.go | 4 +- metric/service.go | 5 +- util/util.go | 19 ----- util/util_test.go | 8 -- vote/bsc_vote_processor.go | 10 +-- vote/greenfield_vote_processor.go | 14 ---- vote/test_util.go | 64 -------------- vote/vote_signer.go | 5 +- 22 files changed, 210 insertions(+), 430 deletions(-) delete mode 100644 integrationtest/bsc_relayer_test.go delete mode 100644 integrationtest/test_app.go delete mode 100644 vote/test_util.go diff --git a/README.md b/README.md index 4822133..cfc303c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ Go version above 1.20 "bls_private_key": "your_private_key", "chain_id": 18, // greenfield oracle module defines this "start_height": 1, - "number_of_blocks_for_finality": 0, "monitor_channel_list": [1,2,3,4,5,6], "gas_limit": 1000, "fee_amount": 5000000000000, @@ -64,7 +63,7 @@ Go version above 1.20 ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 @@ -74,8 +73,8 @@ Go version above 1.20 2. Config crosschain and greenfield light client smart contracts addresses, others can keep default value. ``` "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/config/config.go b/config/config.go index 0bda292..9e4a640 100644 --- a/config/config.go +++ b/config/config.go @@ -28,21 +28,20 @@ func (cfg *AdminConfig) Validate() { } type GreenfieldConfig struct { - KeyType string `json:"key_type"` - AWSRegion string `json:"aws_region"` - AWSSecretName string `json:"aws_secret_name"` - AWSBlsSecretName string `json:"aws_bls_secret_name"` - RPCAddrs []string `json:"rpc_addrs"` - PrivateKey string `json:"private_key"` - BlsPrivateKey string `json:"bls_private_key"` - ChainId uint64 `json:"chain_id"` - StartHeight uint64 `json:"start_height"` - NumberOfBlocksForFinality uint64 `json:"number_of_blocks_for_finality"` - MonitorChannelList []uint8 `json:"monitor_channel_list"` - GasLimit int64 `json:"gas_limit"` - FeeAmount int64 `json:"fee_amount"` - ChainIdString string `json:"chain_id_string"` - UseWebsocket bool `json:"use_websocket"` + KeyType string `json:"key_type"` + AWSRegion string `json:"aws_region"` + AWSSecretName string `json:"aws_secret_name"` + AWSBlsSecretName string `json:"aws_bls_secret_name"` + RPCAddrs []string `json:"rpc_addrs"` + PrivateKey string `json:"private_key"` + BlsPrivateKey string `json:"bls_private_key"` + ChainId uint64 `json:"chain_id"` + StartHeight uint64 `json:"start_height"` + MonitorChannelList []uint8 `json:"monitor_channel_list"` + GasLimit int64 `json:"gas_limit"` + FeeAmount int64 `json:"fee_amount"` + ChainIdString string `json:"chain_id_string"` + UseWebsocket bool `json:"use_websocket"` } func (cfg *GreenfieldConfig) Validate() { @@ -106,6 +105,9 @@ func (cfg *BSCConfig) Validate() { if cfg.GasLimit == 0 { panic("gas_limit of BNB Smart Chain should be larger than 0") } + if cfg.NumberOfBlocksForFinality < 2 || cfg.NumberOfBlocksForFinality > 21 { + panic("NumberOfBlocksForFinality should be [2, 21]") + } } type RelayConfig struct { diff --git a/config/config.json b/config/config.json index 9bf37b6..9eccf04 100644 --- a/config/config.json +++ b/config/config.json @@ -11,7 +11,6 @@ "bls_private_key": "your_private_key", "chain_id": 1, "start_height": 1, - "number_of_blocks_for_finality": 0, "monitor_channel_list": [1,2,3,4,5,6], "gas_limit": 1000, "fee_amount": 5000000000000, @@ -27,14 +26,14 @@ ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 }, "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/config/local/config_local_0.json b/config/local/config_local_0.json index 93878c8..1cef2ad 100644 --- a/config/local/config_local_0.json +++ b/config/local/config_local_0.json @@ -11,7 +11,6 @@ "bls_private_key": "your_private_key", "chain_id": 18, "start_height": 1, - "number_of_blocks_for_finality": 0, "monitor_channel_list": [1,2,3,4,5,6], "gas_limit": 1000, "fee_amount": 5000000000000, @@ -26,14 +25,14 @@ ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 }, "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/config/local/config_local_1.json b/config/local/config_local_1.json index 0d5b63a..47150fd 100644 --- a/config/local/config_local_1.json +++ b/config/local/config_local_1.json @@ -11,7 +11,6 @@ "bls_private_key": "your_private_key", "chain_id": 18, "start_height": 1, - "number_of_blocks_for_finality": 0, "monitor_channel_list": [1,2,3,4,5,6], "gas_limit": 1000, "fee_amount": 5000000000000, @@ -26,14 +25,14 @@ ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 }, "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/config/local/config_local_2.json b/config/local/config_local_2.json index 153d129..2abda5c 100644 --- a/config/local/config_local_2.json +++ b/config/local/config_local_2.json @@ -11,7 +11,6 @@ "bls_private_key": "your_private_key", "chain_id": 18, "start_height": 1, - "number_of_blocks_for_finality": 0, "monitor_channel_list": [1,2,3,4,5,6], "gas_limit": 1000, "fee_amount": 5000000000000, @@ -26,14 +25,14 @@ ], "private_key": "your_private_key", "gas_limit": 4700000, - "gas_price": 20000000000, + "gas_price": 10000000000, "number_of_blocks_for_finality": 2, "start_height": 0, "chain_id": 714 }, "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/executor/bsc_executor.go b/executor/bsc_executor.go index 4d0f69a..9e1d55c 100644 --- a/executor/bsc_executor.go +++ b/executor/bsc_executor.go @@ -11,11 +11,13 @@ import ( "time" "github.com/avast/retry-go/v4" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/rpc" "github.com/spf13/viper" relayercommon "github.com/bnb-chain/greenfield-relayer/common" @@ -29,7 +31,8 @@ import ( ) type BSCClient struct { - rpcClient *ethclient.Client + rpcClient *rpc.Client // for apis eth_getFinalizedBlock and eth_getFinalizedHeader usage, supported by BSC + ethClient *ethclient.Client crossChainClient *crosschain.Crosschain greenfieldLightClient *greenfieldlightclient.Greenfieldlightclient relayerHub *relayerhub.Relayerhub @@ -38,47 +41,38 @@ type BSCClient struct { updatedAt time.Time } -type BSCExecutor struct { - mutex sync.RWMutex - GreenfieldExecutor *GreenfieldExecutor - clientIdx int - bscClients []*BSCClient - config *config.Config - privateKey *ecdsa.PrivateKey - txSender common.Address - gasPrice *big.Int - relayers []rtypes.Validator // cached relayers - metricService *metric.MetricService -} - -func initBSCClients(config *config.Config) []*BSCClient { +func newBSCClients(config *config.Config) []*BSCClient { bscClients := make([]*BSCClient, 0) - for _, provider := range config.BSCConfig.RPCAddrs { - rpcClient, err := ethclient.Dial(provider) + rpcClient, err := rpc.DialContext(context.Background(), provider) + if err != nil { + panic("new rpc client error") + } + ethClient, err := ethclient.Dial(provider) if err != nil { panic("new eth client error") } greenfieldLightClient, err := greenfieldlightclient.NewGreenfieldlightclient( common.HexToAddress(config.RelayConfig.GreenfieldLightClientContractAddr), - rpcClient) + ethClient) if err != nil { panic("new crossChain client error") } crossChainClient, err := crosschain.NewCrosschain( common.HexToAddress(config.RelayConfig.CrossChainContractAddr), - rpcClient) + ethClient) if err != nil { panic("new greenfield light client error") } relayerHub, err := relayerhub.NewRelayerhub( common.HexToAddress(config.RelayConfig.RelayerHubContractAddr), - rpcClient) + ethClient) if err != nil { panic("new relayer hub error") } bscClients = append(bscClients, &BSCClient{ rpcClient: rpcClient, + ethClient: ethClient, crossChainClient: crossChainClient, greenfieldLightClient: greenfieldLightClient, relayerHub: relayerHub, @@ -89,6 +83,19 @@ func initBSCClients(config *config.Config) []*BSCClient { return bscClients } +type BSCExecutor struct { + mutex sync.RWMutex + GreenfieldExecutor *GreenfieldExecutor + clientIdx int + bscClients []*BSCClient + config *config.Config + privateKey *ecdsa.PrivateKey + txSender common.Address + gasPrice *big.Int + relayers []rtypes.Validator // cached relayers + metricService *metric.MetricService +} + func getBscPrivateKey(cfg *config.BSCConfig) string { var privateKey string if cfg.KeyType == config.KeyTypeAWSPrivateKey { @@ -135,7 +142,7 @@ func NewBSCExecutor(cfg *config.Config, metricService *metric.MetricService) *BS } return &BSCExecutor{ clientIdx: 0, - bscClients: initBSCClients(cfg), + bscClients: newBSCClients(cfg), privateKey: ecdsaPrivKey, txSender: txSender, config: cfg, @@ -148,12 +155,18 @@ func (e *BSCExecutor) SetGreenfieldExecutor(ge *GreenfieldExecutor) { e.GreenfieldExecutor = ge } -func (e *BSCExecutor) GetRpcClient() *ethclient.Client { +func (e *BSCExecutor) GetRpcClient() *rpc.Client { e.mutex.RLock() defer e.mutex.RUnlock() return e.bscClients[e.clientIdx].rpcClient } +func (e *BSCExecutor) GetEthClient() *ethclient.Client { + e.mutex.RLock() + defer e.mutex.RUnlock() + return e.bscClients[e.clientIdx].ethClient +} + func (e *BSCExecutor) getCrossChainClient() *crosschain.Crosschain { e.mutex.RLock() defer e.mutex.RUnlock() @@ -182,13 +195,17 @@ func (e *BSCExecutor) SwitchClient() { logging.Logger.Infof("switch to provider: %s", e.config.BSCConfig.RPCAddrs[e.clientIdx]) } +func (e *BSCExecutor) GetLatestFinalizedBlockHeightWithRetry() (latestHeight uint64, err error) { + return e.getLatestBlockHeightWithRetry(e.GetEthClient(), e.GetRpcClient(), true) +} + func (e *BSCExecutor) GetLatestBlockHeightWithRetry() (latestHeight uint64, err error) { - return e.getLatestBlockHeightWithRetry(e.GetRpcClient()) + return e.getLatestBlockHeightWithRetry(e.GetEthClient(), e.GetRpcClient(), false) } -func (e *BSCExecutor) getLatestBlockHeightWithRetry(client *ethclient.Client) (latestHeight uint64, err error) { +func (e *BSCExecutor) getLatestBlockHeightWithRetry(ethClient *ethclient.Client, rpcClient *rpc.Client, finalized bool) (latestHeight uint64, err error) { return latestHeight, retry.Do(func() error { - latestHeight, err = e.getLatestBlockHeight(client) + latestHeight, err = e.getLatestBlockHeight(ethClient, rpcClient, finalized) return err }, relayercommon.RtyAttem, relayercommon.RtyDelay, @@ -198,14 +215,17 @@ func (e *BSCExecutor) getLatestBlockHeightWithRetry(client *ethclient.Client) (l })) } -func (e *BSCExecutor) getLatestBlockHeight(client *ethclient.Client) (uint64, error) { +func (e *BSCExecutor) getLatestBlockHeight(client *ethclient.Client, rpcClient *rpc.Client, finalized bool) (uint64, error) { ctxWithTimeout, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - block, err := client.BlockByNumber(ctxWithTimeout, nil) + if finalized { + return e.getFinalizedBlockHeight(ctxWithTimeout, rpcClient) + } + header, err := client.HeaderByNumber(ctxWithTimeout, nil) if err != nil { return 0, err } - return block.Number().Uint64(), nil + return header.Number.Uint64(), nil } func (e *BSCExecutor) UpdateClientLoop() { @@ -219,7 +239,7 @@ func (e *BSCExecutor) UpdateClientLoop() { config.SendTelegramMessage(e.config.AlertConfig.Identity, e.config.AlertConfig.TelegramBotId, e.config.AlertConfig.TelegramChatId, msg) } - height, err := e.getLatestBlockHeight(bscClient.rpcClient) + height, err := e.getLatestBlockHeight(bscClient.ethClient, bscClient.rpcClient, true) if err != nil { logging.Logger.Errorf("get latest block height error, err=%s", err.Error()) continue @@ -248,7 +268,7 @@ func (e *BSCExecutor) UpdateClientLoop() { func (e *BSCExecutor) GetBlockHeaderAtHeight(height uint64) (*types.Header, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - header, err := e.GetRpcClient().HeaderByNumber(ctx, big.NewInt(int64(height))) + header, err := e.GetEthClient().HeaderByNumber(ctx, big.NewInt(int64(height))) if err != nil { return nil, err } @@ -345,7 +365,7 @@ func (e *BSCExecutor) getGasPrice() *big.Int { func (e *BSCExecutor) SyncTendermintLightBlock(height uint64) (common.Hash, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - nonce, err := e.GetRpcClient().PendingNonceAt(ctx, e.txSender) + nonce, err := e.GetEthClient().PendingNonceAt(ctx, e.txSender) if err != nil { return common.Hash{}, err } @@ -395,7 +415,7 @@ func (e *BSCExecutor) QueryLatestTendermintHeaderWithRetry() (lightBlock []byte, func (e *BSCExecutor) GetNonce() (uint64, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - return e.GetRpcClient().PendingNonceAt(ctx, e.txSender) + return e.GetEthClient().PendingNonceAt(ctx, e.txSender) } func (e *BSCExecutor) CallBuildInSystemContract(blsSignature []byte, validatorSet *big.Int, msgBytes []byte, nonce uint64) (common.Hash, error) { @@ -507,13 +527,13 @@ func (e *BSCExecutor) GetInturnRelayer() (*rtypes.InturnRelayer, error) { func (e *BSCExecutor) getRelayerBalance() (*big.Int, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - return e.GetRpcClient().BalanceAt(ctx, e.txSender, nil) + return e.GetEthClient().BalanceAt(ctx, e.txSender, nil) } func (e *BSCExecutor) claimReward() (common.Hash, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() - nonce, err := e.GetRpcClient().PendingNonceAt(ctx, e.txSender) + nonce, err := e.GetEthClient().PendingNonceAt(ctx, e.txSender) if err != nil { return common.Hash{}, err } @@ -574,3 +594,13 @@ func (e *BSCExecutor) ClaimRewardLoop() { logging.Logger.Infof("claimed rewards, txHash is %s", txHash) } } + +// getFinalizedBlockHeight gets the finalizedBlockHeight, which is the larger one between (fastFinalizedBlockHeight, NumberOfBlocksForFinality from config). +func (e *BSCExecutor) getFinalizedBlockHeight(ctx context.Context, rpcClient *rpc.Client) (uint64, error) { + var head *types.Header + err := rpcClient.CallContext(ctx, &head, "eth_getFinalizedHeader", e.config.BSCConfig.NumberOfBlocksForFinality) + if err == nil && head == nil { + return 0, ethereum.NotFound + } + return head.Number.Uint64(), nil +} diff --git a/executor/bsc_executor_test.go b/executor/bsc_executor_test.go index 67d1780..dc68fab 100644 --- a/executor/bsc_executor_test.go +++ b/executor/bsc_executor_test.go @@ -20,6 +20,9 @@ func TestGetBlockHeight(t *testing.T) { height, err := InitBSCExecutor().GetLatestBlockHeightWithRetry() require.NoError(t, err) t.Log(height) + finalizedHeight, err := InitBSCExecutor().GetLatestFinalizedBlockHeightWithRetry() + require.NoError(t, err) + t.Log(finalizedHeight) } func TestGetNextReceiveSequence(t *testing.T) { @@ -36,7 +39,7 @@ func TestGetNextSendOracleSequence(t *testing.T) { func TestGetBlockHeader(t *testing.T) { e := InitBSCExecutor() - height, err := e.GetLatestBlockHeightWithRetry() + height, err := e.GetLatestFinalizedBlockHeightWithRetry() require.NoError(t, err) header, err := e.GetBlockHeaderAtHeight(height) require.NoError(t, err) @@ -77,8 +80,8 @@ func TestSyncTendermintHeader(t *testing.T) { func TestGetLogsFromHeader(t *testing.T) { e := InitBSCExecutor() - client := e.GetRpcClient() - height, err := e.GetLatestBlockHeightWithRetry() + client := e.GetEthClient() + height, err := e.GetLatestFinalizedBlockHeightWithRetry() require.NoError(t, err) header, err := e.GetBlockHeaderAtHeight(height) require.NoError(t, err) diff --git a/go.mod b/go.mod index e5906f6..02fd8d2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.1 github.com/cometbft/cometbft v0.37.1 github.com/cosmos/cosmos-sdk v0.47.3 - github.com/ethereum/go-ethereum v1.10.26 + github.com/ethereum/go-ethereum v1.11.3 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.15.0 @@ -34,20 +34,20 @@ require ( github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect + github.com/VictoriaMetrics/fastcache v1.12.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/bnb-chain/greenfield-common/go v0.0.0-20230809025353-fd0519705054 // indirect github.com/btcsuite/btcd v0.23.3 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/btcsuite/btcd/btcutil v1.1.2 // indirect + github.com/btcsuite/btcd/btcutil v1.1.3 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect - github.com/consensys/gnark-crypto v0.7.0 // indirect + github.com/consensys/gnark-crypto v0.9.1-0.20230105202408-1a7a29904a7c // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect @@ -57,13 +57,14 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/deckarep/golang-set v1.8.0 // indirect + github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect + github.com/edsrzf/mmap-go v1.1.0 // indirect github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -71,7 +72,7 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-sql-driver/mysql v1.7.0 // indirect - github.com/go-stack/stack v1.8.0 // indirect + github.com/go-stack/stack v1.8.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.0 // indirect @@ -107,6 +108,7 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mattn/go-sqlite3 v1.14.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect @@ -114,6 +116,8 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/onsi/ginkgo v1.16.5 // indirect + github.com/onsi/gomega v1.24.0 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -122,11 +126,11 @@ require ( github.com/prometheus/procfs v0.9.0 // indirect github.com/prysmaticlabs/eth2-types v0.0.0-20210303084904-c9735a06829d // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rjeczalik/notify v0.9.2 // indirect + github.com/rivo/uniseg v0.4.3 // indirect github.com/rs/zerolog v1.29.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.9.3 // indirect github.com/spf13/cast v1.5.0 // indirect @@ -134,17 +138,18 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/syndtr/goleveldb v1.0.1 // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect github.com/tidwall/btree v1.6.0 // indirect - github.com/tklauser/go-sysconf v0.3.10 // indirect - github.com/tklauser/numcpus v0.4.0 // indirect - github.com/urfave/cli/v2 v2.10.2 // indirect + github.com/tklauser/go-sysconf v0.3.11 // indirect + github.com/tklauser/numcpus v0.6.0 // indirect + github.com/urfave/cli/v2 v2.23.7 // indirect github.com/wealdtech/go-bytesutil v1.1.1 // indirect github.com/wealdtech/go-eth2-types/v2 v2.5.2 // indirect github.com/wealdtech/go-eth2-util v1.6.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect + github.com/yusufpapurcu/wmi v1.2.2 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect @@ -161,6 +166,7 @@ require ( gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + nhooyr.io/websocket v1.8.7 // indirect pgregory.net/rapid v0.5.5 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) @@ -170,7 +176,10 @@ replace ( cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 + github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 + github.com/consensys/gnark-crypto => github.com/consensys/gnark-crypto v0.7.0 github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 + ) diff --git a/go.sum b/go.sum index bc1a967..e4075a6 100644 --- a/go.sum +++ b/go.sum @@ -84,6 +84,7 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= @@ -94,10 +95,10 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.26.1/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 h1:5sXbqlSomvdjlRbWyNqkPsJ3Fg+tQZCbgeX1VGljbQY= github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= +github.com/VictoriaMetrics/fastcache v1.12.0 h1:vnVi/y9yKDcD9akmc4NqAoqgQhJrOwUF+j9LTgn4QDE= +github.com/VictoriaMetrics/fastcache v1.12.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= @@ -193,8 +194,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= -github.com/btcsuite/btcd/btcutil v1.1.2/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= @@ -223,6 +224,7 @@ github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= @@ -242,11 +244,12 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/pebble v0.0.0-20230226194802-02d779ffbc46 h1:yMaoO76pV9knZ6bzEwzPSHnPSCTnrJohwkIQirmii70= +github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= -github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= -github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= -github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= +github.com/consensys/bavard v0.1.10/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.7.0 h1:rwdy8+ssmLYRqKp+ryRRgQJl/rCq2uv+n83cOydm5UE= github.com/consensys/gnark-crypto v0.7.0/go.mod h1:KPSuJzyxkJA8xZ/+CV47tyqkr9MmpZA3PXivK4VPrVg= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -262,6 +265,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= +github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= +github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -293,8 +298,8 @@ github.com/davidlazar/go-crypto v0.0.0-20170701192655-dcfb0a7ac018/go.mod h1:rQY github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= +github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= @@ -335,8 +340,9 @@ github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= -github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ= +github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/dot v0.11.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -349,8 +355,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.10.13/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw= -github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= -github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/ethereum/go-ethereum v1.11.3 h1:uuBkYUJW9aY5JYi3+sqLHz+XWyo5fmn/ab9XcbtVDTU= +github.com/ethereum/go-ethereum v1.11.3/go.mod h1:rBUvAl5cdVrAei9q5lgOU7RSEuPJk1nlBDnS/YSoKQE= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= @@ -382,8 +388,11 @@ github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8x github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= @@ -418,19 +427,28 @@ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1 github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= @@ -536,6 +554,7 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -559,6 +578,7 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -624,6 +644,7 @@ github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3s github.com/herumi/bls-eth-go-binary v0.0.0-20210130185500-57372fb27371/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e h1:wCMygKUQhmcQAjlk2Gquzq6dLmyMv2kF+llRspoRgrk= github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= @@ -745,6 +766,7 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.1/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= @@ -776,11 +798,13 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/libp2p/go-addr-util v0.0.2/go.mod h1:Ecd6Fb3yIuLzq4bD7VcywcVSBtefcAwnUISBM3WG15E= @@ -945,7 +969,8 @@ github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= @@ -991,6 +1016,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -1075,8 +1102,9 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -1085,7 +1113,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/onsi/gomega v1.20.2 h1:8uQq0zMgLEfa0vRrrBgaJF2gyW9Da9BmfGV+OyUzfkY= +github.com/onsi/gomega v1.24.0 h1:+0glovB9Jd6z3VR+ScSwQqXVTIfJcGA9UBM8yzQxhqg= +github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c/go.mod h1:t+O9It+LKzfOAhKTT5O0ehDix+MTqbtT0T9t+7zzOvc= @@ -1184,7 +1213,6 @@ github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJf github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/prom2json v1.3.0/go.mod h1:rMN7m0ApCowcoDlypBHlkNbp5eJQf/+1isKykIP5ZnM= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4= github.com/prysmaticlabs/eth2-types v0.0.0-20210303084904-c9735a06829d h1:1dN7YAqMN3oAJ0LceWcyv/U4jHLh+5urnSnr4br6zg4= github.com/prysmaticlabs/eth2-types v0.0.0-20210303084904-c9735a06829d/go.mod h1:kOmQ/zdobQf7HUohDTifDNFEZfNaSCIY5fkONPL+dWU= @@ -1203,10 +1231,10 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5X github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= -github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -1230,8 +1258,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= +github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= @@ -1301,8 +1330,8 @@ github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 h1:Oo2KZNP70KE0+IUJSidPj/BFS/RXNHmKIJOdckzml2E= github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -1343,11 +1372,11 @@ github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EU github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tjfoc/gmsm v1.3.0/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= -github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= -github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= +github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= -github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= -github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= +github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/trailofbits/go-mutexasserts v0.0.0-20200708152505-19999e7d3cef/go.mod h1:+SV/613m53DNAmlXPTWGZhIyt4E/qDvn9g/lOPRiy0A= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -1355,12 +1384,14 @@ github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:s github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= -github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= -github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= +github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY= +github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -1399,6 +1430,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= @@ -1480,6 +1513,7 @@ golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5 golang.org/x/crypto v0.0.0-20210813211128-0a44fdfbc16e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1625,7 +1659,6 @@ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1704,7 +1737,6 @@ golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1719,12 +1751,14 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220405052023-b1e9470b6e64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2030,7 +2064,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= k8s.io/api v0.18.3/go.mod h1:UOaMwERbqJMfeeeHc8XJKawj4P9TgDRnViIqqBeH2QA= k8s.io/apimachinery v0.18.3/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= k8s.io/client-go v0.18.3/go.mod h1:4a/dpQEvzAhT1BbuWW09qvIaGw6Gbu1gZYiQZIi1DMw= @@ -2043,13 +2076,15 @@ k8s.io/klog/v2 v2.3.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20200520001619-278ece378a50/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= +nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= +nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/integrationtest/bsc_relayer_test.go b/integrationtest/bsc_relayer_test.go deleted file mode 100644 index d10dc57..0000000 --- a/integrationtest/bsc_relayer_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package integrationtest - -import ( - "encoding/hex" - "math/big" - "sort" - "testing" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - - "github.com/bnb-chain/greenfield-relayer/db" - "github.com/bnb-chain/greenfield-relayer/db/model" - "github.com/bnb-chain/greenfield-relayer/types" - "github.com/bnb-chain/greenfield-relayer/vote" -) - -const ( - // Change your relayers Bls private key when integration test using local env - Relayer1HexBlsPrivKey = "3a1055a667eddef7405a554f2994aedea43c8258712a013b3a61532e8cd0f032" // for test only - Relayer2HexBlsPrivKey = "139ace9a52fa78b9f4dc2f151231225f9503d60f3aefeef89a1ee82d6d48ef9a" -) - -func TestClaimPackagesSucceed(t *testing.T) { - app := InitTestApp() - go app.BSCRelayer.SignAndBroadcastVoteLoop() - go app.BSCRelayer.CollectVotesLoop() - go app.BSCRelayer.AssemblePackagesLoop() - - greenfieldExecutor := app.BSCRelayer.GreenfieldExecutor - daoManager := app.BSCRelayer.Listener.DaoManager - - // Given: Prepare cross-chain packages to be sent. Define the channel id, oracle sequence and package sequence are - // retrieved from destination chain(Greenfield), - channelId := uint8(1) - oracleSeq, err := greenfieldExecutor.GetNextReceiveOracleSequence() - require.NoError(t, err) - packageStartSeq, err := greenfieldExecutor.GetNextReceiveSequenceForChannel(types.ChannelId(channelId)) - require.NoError(t, err) - - relayPkgs := make([]*model.BscRelayPackage, 0) - ts := time.Now().Unix() - - packagesSize := uint64(2) - endSeq := packageStartSeq + (packagesSize - 1) - - // TODO Use cli to send cross-chain tx from BSC so that there is no need to mock votes - txIndex := 0 - for i := packageStartSeq; i <= endSeq; i++ { - relayPkg := model.BscRelayPackage{} - relayPkg.ChannelId = channelId - relayPkg.OracleSequence = oracleSeq - relayPkg.PackageSequence = i - relayPkg.PayLoad = hex.EncodeToString(getPayload(uint64(ts))) - relayPkg.Height = 1 - relayPkg.TxHash = "testHash" - relayPkg.TxIndex = uint(txIndex) - relayPkg.Status = db.Saved - relayPkg.TxTime = ts - relayPkg.UpdatedTime = ts - relayPkgs = append(relayPkgs, &relayPkg) - txIndex++ - } - - // When: Save packages with status 'Saved' into Database, there are processes to aggregate packages to submit vote to - // Greenfield Votepool, gathering votes from votepool, and assembler them to claim in Greenfield. - err = daoManager.BSCDao.SaveBatchPackages(relayPkgs) - require.NoError(t, err) - - // This is needed in local testing, if move to use testnet, can trigger transaction use cli. - go vote.BroadcastVotesFromOtherRelayers( - []string{Relayer1HexBlsPrivKey, Relayer2HexBlsPrivKey}, - daoManager, app.BSCRelayer.GreenfieldExecutor, channelId, oracleSeq, 2) - - // The first in-turn relayer has 40 seconds relaying window, so that need to wait for a while if current one is not the first in-turn. - // sleep for all processes have done their work, if there are more validators, might need to set this larger due to - // it takes time for current relayer to be in-turn. - time.Sleep(60 * time.Second) - - // Then: the oracle sequence is filled, sequences for cross-chain packages are all filled - pkgs, err := daoManager.BSCDao.GetPackagesByStatus(db.Delivered) - require.NoError(t, err) - sort.Slice(pkgs, func(i, j int) bool { - return pkgs[i].PackageSequence < pkgs[j].PackageSequence - }) - require.EqualValues(t, packageStartSeq, pkgs[0].PackageSequence) - require.EqualValues(t, endSeq, pkgs[packagesSize-1].PackageSequence) - - nextSeq, err := greenfieldExecutor.GetNextReceiveSequenceForChannel(types.ChannelId(channelId)) - require.NoError(t, err) - require.EqualValues(t, endSeq+1, nextSeq) - nextOracleSeq, err := greenfieldExecutor.GetNextReceiveOracleSequence() - require.NoError(t, err) - require.EqualValues(t, oracleSeq+1, nextOracleSeq) -} - -func getPayload(ts uint64) []byte { - payloadHeader := sdk.EncodePackageHeader(sdk.PackageHeader{ - PackageType: sdk.SynCrossChainPackageType, - Timestamp: ts, - RelayerFee: big.NewInt(1), - AckRelayerFee: big.NewInt(1), - }) - payloadHeader = append(payloadHeader, []byte("test payload")...) - return payloadHeader -} diff --git a/integrationtest/config/config_test.json b/integrationtest/config/config_test.json index 3599cf8..58a8818 100644 --- a/integrationtest/config/config_test.json +++ b/integrationtest/config/config_test.json @@ -7,17 +7,13 @@ "rpc_addrs": [ "http://127.0.0.1:26750" ], - "grpc_addrs": [ - "localhost:9090" - ], "private_key": "your_private_key", "bls_private_key": "your_private_key", "chain_id": 18, "start_height": 1, - "number_of_blocks_for_finality": 0, - "monitor_channel_list": [1,2,3], - "gas_limit": 30000, - "fee_amount": 150000000000000, + "monitor_channel_list": [1,2,3,4,5,6], + "gas_limit": 1000, + "fee_amount": 5000000000000, "chain_id_string": "greenfield_9000-121" }, "bsc_config": { @@ -35,8 +31,8 @@ "chain_id": 714 }, "relay_config": { - "bsc_to_greenfield_inturn_relayer_timeout": 90, - "greenfield_to_bsc_inturn_relayer_timeout": 45, + "bsc_to_greenfield_inturn_relayer_timeout": 40, + "greenfield_to_bsc_inturn_relayer_timeout": 30, "greenfield_sequence_update_latency": 8, "bsc_sequence_update_latency": 12, "greenfield_event_type_cross_chain": "cosmos.crosschain.v1.EventCrossChain", diff --git a/integrationtest/test_app.go b/integrationtest/test_app.go deleted file mode 100644 index f740f90..0000000 --- a/integrationtest/test_app.go +++ /dev/null @@ -1,50 +0,0 @@ -package integrationtest - -import ( - "fmt" - - "github.com/spf13/viper" - "gorm.io/driver/mysql" - "gorm.io/gorm" - - "github.com/bnb-chain/greenfield-relayer/app" - "github.com/bnb-chain/greenfield-relayer/config" - "github.com/bnb-chain/greenfield-relayer/db/model" -) - -func InitTestApp() app.App { - cfg := GetTestConfig() - username := cfg.DBConfig.Username - password := viper.GetString(config.FlagConfigDbPass) - url := cfg.DBConfig.Url - dbPath := fmt.Sprintf("%s:%s@%s", username, password, url) - db, err := gorm.Open(mysql.Open(dbPath), &gorm.Config{}) - if err != nil { - panic(fmt.Sprintf("open db error, err=%s", err.Error())) - } - err = db.Migrator().DropTable(&model.BscRelayPackage{}) - if err != nil { - panic(err) - } - err = db.Migrator().DropTable(&model.BscBlock{}) - if err != nil { - panic(err) - } - err = db.Migrator().DropTable(&model.Vote{}) - if err != nil { - panic(err) - } - err = db.Migrator().DropTable(&model.GreenfieldRelayTransaction{}) - if err != nil { - panic(err) - } - err = db.Migrator().DropTable(&model.GreenfieldBlock{}) - if err != nil { - panic(err) - } - return *app.NewApp(cfg) -} - -func GetTestConfig() *config.Config { - return config.ParseConfigFromFile("config/config_test.json") -} diff --git a/listener/bsc_listener.go b/listener/bsc_listener.go index 92a3ef8..e28e811 100644 --- a/listener/bsc_listener.go +++ b/listener/bsc_listener.go @@ -70,7 +70,7 @@ func (l *BSCListener) poll() error { nextHeight = latestPolledBlockHeight + 1 } - latestBlockHeight, err := l.bscExecutor.GetLatestBlockHeightWithRetry() + latestBlockHeight, err := l.bscExecutor.GetLatestFinalizedBlockHeightWithRetry() if err != nil { logging.Logger.Errorf("failed to get latest blockHeight, error: %s", err.Error()) return err @@ -80,7 +80,7 @@ func (l *BSCListener) poll() error { return nil } } - if err = l.monitorCrossChainPkgAt(nextHeight, latestPolledBlock); err != nil { + if err = l.monitorCrossChainPkgAt(nextHeight); err != nil { logging.Logger.Errorf("encounter error when monitor cross-chain packages at blockHeight=%d, err=%s", nextHeight, err.Error()) return err } @@ -91,7 +91,7 @@ func (l *BSCListener) getLatestPolledBlock() (*model.BscBlock, error) { return l.DaoManager.BSCDao.GetLatestBlock() } -func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64, latestPolledBlock *model.BscBlock) error { +func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64) error { nextHeightBlockHeader, err := l.bscExecutor.GetBlockHeaderAtHeight(nextHeight) if err != nil { return err @@ -101,14 +101,6 @@ func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64, latestPolledBloc return nil } logging.Logger.Infof("retrieved BSC block header at height=%d", nextHeight) - // check if the latest polled block in DB is forked, if so, delete it. - isForked, err := l.isForkedBlockAndDelete(latestPolledBlock, nextHeight, nextHeightBlockHeader.ParentHash) - if err != nil { - return err - } - if isForked { - return fmt.Errorf("there is fork at block height=%d", latestPolledBlock.Height) - } logs, err := l.queryCrossChainLogs(nextHeightBlockHeader.Hash()) if err != nil { return fmt.Errorf("failed to get logs from block at height=%d, err=%s", nextHeight, err.Error()) @@ -147,7 +139,7 @@ func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64, latestPolledBloc } func (l *BSCListener) queryCrossChainLogs(blockHash ethcommon.Hash) ([]types.Log, error) { - client := l.bscExecutor.GetRpcClient() + client := l.bscExecutor.GetEthClient() topics := [][]ethcommon.Hash{{l.getCrossChainPackageEventHash()}} logs, err := client.FilterLogs(context.Background(), ethereum.FilterQuery{ BlockHash: &blockHash, @@ -160,20 +152,6 @@ func (l *BSCListener) queryCrossChainLogs(blockHash ethcommon.Hash) ([]types.Log return logs, nil } -func (l *BSCListener) isForkedBlockAndDelete(latestPolledBlock *model.BscBlock, nextHeight uint64, parentHash ethcommon.Hash) (bool, error) { - if latestPolledBlock.Height != 0 && - latestPolledBlock.Height+1 == nextHeight && - parentHash.String() != latestPolledBlock.BlockHash { - // delete latestPolledBlock and its cross-chain packages from DB - if err := l.DaoManager.BSCDao.DeleteBlockAndPackagesAtHeight(latestPolledBlock.Height); err != nil { - return true, err - } - logging.Logger.Infof("deleted block at height=%d from DB due to it is forked", latestPolledBlock.Height) - return true, nil - } - return false, nil -} - func (l *BSCListener) getCrossChainPackageEventHash() ethcommon.Hash { return ethcommon.HexToHash(l.config.RelayConfig.CrossChainPackageEventHex) } diff --git a/listener/const.go b/listener/const.go index d52e01d..ed9af7a 100644 --- a/listener/const.go +++ b/listener/const.go @@ -1,6 +1,8 @@ package listener -import "time" +import ( + "time" +) const ( NumOfHistoricalBlocks = int64(10000) // NumOfHistoricalBlocks is the number of blocks will be kept in DB, all transactions and votes also kept within this range diff --git a/metric/service.go b/metric/service.go index fbb0be7..d8d8d70 100644 --- a/metric/service.go +++ b/metric/service.go @@ -2,11 +2,12 @@ package metric import ( "fmt" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" "net/http" "strconv" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" + "github.com/bnb-chain/greenfield-relayer/config" ) diff --git a/util/util.go b/util/util.go index 56cfaaa..dd4e4bd 100644 --- a/util/util.go +++ b/util/util.go @@ -5,28 +5,9 @@ import ( "math/big" "strconv" - "github.com/ethereum/go-ethereum/common" - "github.com/prysmaticlabs/prysm/crypto/bls/blst" "github.com/willf/bitset" ) -func IndexOf(element string, data []string) int { - for i, v := range data { - if element == v { - return i - } - } - return -1 -} - -func BlsPubKeyFromPrivKeyStr(privKeyStr string) []byte { - privKey, err := blst.SecretKeyFromBytes(common.Hex2Bytes(privKeyStr)) - if err != nil { - panic(err) - } - return privKey.PublicKey().Marshal() -} - // QuotedStrToIntWithBitSize convert a QuoteStr ""6"" to int 6 func QuotedStrToIntWithBitSize(str string, bitSize int) (uint64, error) { s, err := strconv.Unquote(str) diff --git a/util/util_test.go b/util/util_test.go index b72aea4..0cd29c0 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -1,20 +1,12 @@ package util import ( - "encoding/hex" "testing" "github.com/stretchr/testify/require" "github.com/willf/bitset" ) -func TestGetBlsPubKeyFromPrivKeyStr(t *testing.T) { - privKeyStr := "1afd9371ebe27dc75face6fb3602fc6d8b93bbd885d81bfcdac7ec2db8246f6f" - expectedPubKeyStr := "8ec21505e290d7c15f789c7b4c522179bb7d70171319bfe2d6b2aae2461a1279566782907593cc526a5f2611c0721d60" - pubKeyBts := BlsPubKeyFromPrivKeyStr(privKeyStr) - require.Equal(t, expectedPubKeyStr, hex.EncodeToString(pubKeyBts)) -} - func TestQuotedStrToInt(t *testing.T) { num, err := QuotedStrToIntWithBitSize("\"666666\"", 64) require.NoError(t, err) diff --git a/vote/bsc_vote_processor.go b/vote/bsc_vote_processor.go index a585feb..f475063 100644 --- a/vote/bsc_vote_processor.go +++ b/vote/bsc_vote_processor.go @@ -57,21 +57,13 @@ func (p *BSCVoteProcessor) SignAndBroadcastVoteLoop() { // SignAndBroadcastVoteLoop signs using the bls private key, and broadcast the vote to votepool func (p *BSCVoteProcessor) signAndBroadcast() error { - latestHeight, err := p.bscExecutor.GetLatestBlockHeightWithRetry() - if err != nil { - logging.Logger.Errorf("failed to get latest block height, error: %s", err.Error()) - return err - } + // need to keep track of the height so that make sure that we aggregate packages are from only 1 block. leastSavedPkgHeight, err := p.daoManager.BSCDao.GetLeastSavedPackagesHeight() if err != nil { logging.Logger.Errorf("failed to get least saved packages' height, error: %s", err.Error()) return err } - - if leastSavedPkgHeight+p.config.BSCConfig.NumberOfBlocksForFinality > latestHeight { - return nil - } pkgs, err := p.daoManager.BSCDao.GetPackagesByHeightAndStatus(db.Saved, leastSavedPkgHeight) if err != nil { logging.Logger.Errorf("failed to get packages at height %d from db, error: %s", leastSavedPkgHeight, err.Error()) diff --git a/vote/greenfield_vote_processor.go b/vote/greenfield_vote_processor.go index 4c98d06..495f164 100644 --- a/vote/greenfield_vote_processor.go +++ b/vote/greenfield_vote_processor.go @@ -58,20 +58,6 @@ func (p *GreenfieldVoteProcessor) SignAndBroadcastLoop() { } func (p *GreenfieldVoteProcessor) signAndBroadcast() error { - latestHeight, err := p.greenfieldExecutor.GetLatestBlockHeight() - if err != nil { - logging.Logger.Errorf("failed to get latest block height, error: %s", err.Error()) - return err - } - - leastSavedTxHeight, err := p.daoManager.GreenfieldDao.GetLeastSavedTransactionHeight() - if err != nil { - logging.Logger.Errorf("failed to get least saved tx height, error: %s", err.Error()) - return err - } - if leastSavedTxHeight+p.config.GreenfieldConfig.NumberOfBlocksForFinality > latestHeight { - return nil - } txs, err := p.daoManager.GreenfieldDao.GetTransactionsByStatusWithLimit(db.Saved, p.config.VotePoolConfig.VotesBatchMaxSizePerInterval) if err != nil { logging.Logger.Errorf("failed to get transactions from db, error: %s", err.Error()) diff --git a/vote/test_util.go b/vote/test_util.go deleted file mode 100644 index 4ba3e6a..0000000 --- a/vote/test_util.go +++ /dev/null @@ -1,64 +0,0 @@ -package vote - -import ( - "encoding/hex" - "time" - - "github.com/cometbft/cometbft/votepool" - "github.com/ethereum/go-ethereum/common" - "github.com/prysmaticlabs/prysm/crypto/bls/blst" - - "github.com/bnb-chain/greenfield-relayer/db/dao" - "github.com/bnb-chain/greenfield-relayer/db/model" - "github.com/bnb-chain/greenfield-relayer/executor" - "github.com/bnb-chain/greenfield-relayer/util" -) - -const ( - LocalRelayerHexBlsPrivKey = "your_private_key" -) - -// PrivKeys Bls Private keys from other mock relayers -var PrivKeys = []string{ - "your_private_key", - "your_private_key", -} - -// BroadcastVotesFromOtherRelayers for mimic multi relayers when bsc -> gnfd -func BroadcastVotesFromOtherRelayers( - privateKeysList []string, - daoManager *dao.DaoManager, - gnfdExecutor *executor.GreenfieldExecutor, channelId uint8, seq uint64, eventType uint8) { - var vote *model.Vote - // retry to query vote from local DB - for { - localVote, err := daoManager.VoteDao.GetVoteByChannelIdAndSequenceAndPubKey(channelId, - seq, hex.EncodeToString(util.BlsPubKeyFromPrivKeyStr(LocalRelayerHexBlsPrivKey))) - if err != nil { - time.Sleep(1 * time.Second) - continue - } - vote = localVote - break - } - - for _, pk := range privateKeysList { - secretKey, err := blst.SecretKeyFromBytes(common.Hex2Bytes(pk)) - if err != nil { - panic(err) - } - pubKey := secretKey.PublicKey() - sign := secretKey.Sign(vote.EventHash[:]).Marshal() - - mockVoteFromRelayer := &votepool.Vote{ - PubKey: pubKey.Marshal(), - Signature: sign, - EventType: votepool.EventType(eventType), - EventHash: vote.EventHash[:], - } - err = gnfdExecutor.BroadcastVote(mockVoteFromRelayer) - if err != nil { - panic(err) - } - } -} diff --git a/vote/vote_signer.go b/vote/vote_signer.go index 5ef7950..d060f91 100644 --- a/vote/vote_signer.go +++ b/vote/vote_signer.go @@ -25,7 +25,6 @@ func NewVoteSigner(pk []byte) *VoteSigner { // SignVote signs a vote by relayer's private key func (signer *VoteSigner) SignVote(vote *votepool.Vote) { - vote.PubKey = append(vote.PubKey, signer.pubKey.Marshal()...) - signature := signer.privKey.Sign(vote.EventHash[:]) - vote.Signature = append(vote.Signature, signature.Marshal()...) + vote.PubKey = signer.pubKey.Marshal() + vote.Signature = signer.privKey.Sign(vote.EventHash[:]).Marshal() } From d35e3c09b83eeb9be3966526cc1616808b0b1d78 Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:22:58 +0800 Subject: [PATCH 5/5] bump version (#75) --- README.md | 2 +- assembler/bsc_assembler.go | 11 ++++++++--- assembler/greenfield_assembler.go | 9 +++++++-- executor/bsc_executor.go | 9 +++++---- executor/greenfield_executor.go | 13 ++++++++----- executor/greenfield_executor_test.go | 5 +++-- go.mod | 17 ++++++++--------- go.sum | 28 ++++++++++++++-------------- listener/bsc_listener.go | 6 +++--- listener/event_parser.go | 5 +++-- vote/bsc_vote_processor.go | 6 +++++- 11 files changed, 65 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index cfc303c..600a4c3 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ docker run --name gnfd-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:8 Create schema in MySQL client: -```shell +```mysql CREATE SCHEMA IF NOT EXISTS `greenfield-relayer` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; ``` diff --git a/assembler/bsc_assembler.go b/assembler/bsc_assembler.go index 365e384..7d986c6 100644 --- a/assembler/bsc_assembler.go +++ b/assembler/bsc_assembler.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "time" "cosmossdk.io/errors" @@ -89,7 +90,7 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { } return nil } - inTurnRelayerStartSeq, err := a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry() + inTurnRelayerStartSeq, err := a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry(a.getChainId()) if err != nil { return err } @@ -106,7 +107,7 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { a.inturnRelayerSequenceStatus.HasRetrieved = false // non-inturn relayer retries every 10 second, gets the sequence from chain time.Sleep(time.Duration(a.config.RelayConfig.GreenfieldSequenceUpdateLatency) * time.Second) - startSeq, err = a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry() + startSeq, err = a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry(a.getChainId()) if err != nil { return err } @@ -172,7 +173,7 @@ func (a *BSCAssembler) process(channelId types.ChannelId) error { return nonceErr } a.relayerNonce = newNonce - newNextDeliveryOracleSeq, seqErr := a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry() + newNextDeliveryOracleSeq, seqErr := a.bscExecutor.GetNextDeliveryOracleSequenceWithRetry(a.getChainId()) if seqErr != nil { return seqErr } @@ -239,3 +240,7 @@ func (a *BSCAssembler) updateMetrics(channelId uint8, nextDeliveryOracleSeq uint a.metricService.SetNextSendSequenceForChannel(channelId, nextSendOracleSeq) return nil } + +func (a *BSCAssembler) getChainId() sdk.ChainID { + return sdk.ChainID(a.config.BSCConfig.ChainId) +} diff --git a/assembler/greenfield_assembler.go b/assembler/greenfield_assembler.go index 2c2bbd4..aecaee8 100644 --- a/assembler/greenfield_assembler.go +++ b/assembler/greenfield_assembler.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "sync" "time" @@ -148,7 +149,7 @@ func (a *GreenfieldAssembler) process(channelId types.ChannelId, inturnRelayer * return nil } } else { - endSeq, err := a.greenfieldExecutor.GetNextSendSequenceForChannelWithRetry(channelId) + endSeq, err := a.greenfieldExecutor.GetNextSendSequenceForChannelWithRetry(a.getDestChainId(), channelId) if err != nil { return err } @@ -233,10 +234,14 @@ func (a *GreenfieldAssembler) getMonitorChannels() []uint8 { func (a *GreenfieldAssembler) updateMetrics(channelId types.ChannelId, nextDeliverySeq uint64) error { a.metricService.SetNextReceiveSequenceForChannel(uint8(channelId), nextDeliverySeq) - nextSendSeq, err := a.greenfieldExecutor.GetNextSendSequenceForChannelWithRetry(channelId) + nextSendSeq, err := a.greenfieldExecutor.GetNextSendSequenceForChannelWithRetry(a.getDestChainId(), channelId) if err != nil { return err } a.metricService.SetNextSendSequenceForChannel(uint8(channelId), nextSendSeq) return nil } + +func (a *GreenfieldAssembler) getDestChainId() sdk.ChainID { + return sdk.ChainID(a.config.BSCConfig.ChainId) +} diff --git a/executor/bsc_executor.go b/executor/bsc_executor.go index 9e1d55c..c3406fe 100644 --- a/executor/bsc_executor.go +++ b/executor/bsc_executor.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "math/big" "sync" "time" @@ -326,9 +327,9 @@ func (e *BSCExecutor) getNextSendOracleSequence() (sequence uint64, err error) { } // GetNextDeliveryOracleSequenceWithRetry gets the next delivery Oracle sequence from Greenfield -func (e *BSCExecutor) GetNextDeliveryOracleSequenceWithRetry() (sequence uint64, err error) { +func (e *BSCExecutor) GetNextDeliveryOracleSequenceWithRetry(chainId sdk.ChainID) (sequence uint64, err error) { return sequence, retry.Do(func() error { - sequence, err = e.getNextDeliveryOracleSequence() + sequence, err = e.getNextDeliveryOracleSequence(chainId) return err }, relayercommon.RtyAttem, relayercommon.RtyDelay, @@ -338,8 +339,8 @@ func (e *BSCExecutor) GetNextDeliveryOracleSequenceWithRetry() (sequence uint64, })) } -func (e *BSCExecutor) getNextDeliveryOracleSequence() (uint64, error) { - sequence, err := e.GreenfieldExecutor.GetNextReceiveOracleSequence() +func (e *BSCExecutor) getNextDeliveryOracleSequence(chainId sdk.ChainID) (uint64, error) { + sequence, err := e.GreenfieldExecutor.GetNextReceiveOracleSequence(chainId) if err != nil { return 0, err } diff --git a/executor/greenfield_executor.go b/executor/greenfield_executor.go index 22937b2..968bf6a 100644 --- a/executor/greenfield_executor.go +++ b/executor/greenfield_executor.go @@ -182,9 +182,9 @@ func (e *GreenfieldExecutor) getNextDeliverySequenceForChannel(channelID types.C } // GetNextSendSequenceForChannelWithRetry gets the next send sequence of a specified channel from Greenfield -func (e *GreenfieldExecutor) GetNextSendSequenceForChannelWithRetry(channelID types.ChannelId) (sequence uint64, err error) { +func (e *GreenfieldExecutor) GetNextSendSequenceForChannelWithRetry(destChainID sdk.ChainID, channelID types.ChannelId) (sequence uint64, err error) { return sequence, retry.Do(func() error { - sequence, err = e.getNextSendSequenceForChannel(channelID) + sequence, err = e.getNextSendSequenceForChannel(destChainID, channelID) return err }, relayercommon.RtyAttem, relayercommon.RtyDelay, @@ -194,31 +194,34 @@ func (e *GreenfieldExecutor) GetNextSendSequenceForChannelWithRetry(channelID ty })) } -func (e *GreenfieldExecutor) getNextSendSequenceForChannel(channelId types.ChannelId) (uint64, error) { +func (e *GreenfieldExecutor) getNextSendSequenceForChannel(destChainId sdk.ChainID, channelId types.ChannelId) (uint64, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() return e.GetGnfdClient().GetChannelSendSequence( ctx, + destChainId, uint32(channelId), ) } // GetNextReceiveOracleSequence gets the next receive Oracle sequence from Greenfield -func (e *GreenfieldExecutor) GetNextReceiveOracleSequence() (uint64, error) { +func (e *GreenfieldExecutor) GetNextReceiveOracleSequence(destChainId sdk.ChainID) (uint64, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() return e.GetGnfdClient().GetChannelReceiveSequence( ctx, + destChainId, uint32(relayercommon.OracleChannelId), ) } // GetNextReceiveSequenceForChannel gets the sequence specifically for bsc -> gnfd package's channel from Greenfield -func (e *GreenfieldExecutor) GetNextReceiveSequenceForChannel(channelId types.ChannelId) (uint64, error) { +func (e *GreenfieldExecutor) GetNextReceiveSequenceForChannel(destChainId sdk.ChainID, channelId types.ChannelId) (uint64, error) { ctx, cancel := context.WithTimeout(context.Background(), RPCTimeout) defer cancel() return e.GetGnfdClient().GetChannelReceiveSequence( ctx, + destChainId, uint32(channelId), ) } diff --git a/executor/greenfield_executor_test.go b/executor/greenfield_executor_test.go index e727bbb..8c0f57d 100644 --- a/executor/greenfield_executor_test.go +++ b/executor/greenfield_executor_test.go @@ -3,6 +3,7 @@ package executor import ( "context" "encoding/hex" + sdk "github.com/cosmos/cosmos-sdk/types" "testing" cbfttypes "github.com/cometbft/cometbft/types" @@ -24,14 +25,14 @@ func TestGetLatestBlockHeightWithRetry(t *testing.T) { func TestGetNextReceiveOracleSequence(t *testing.T) { e := GnfdExecutor() - oracleSeq, err := e.GetNextReceiveOracleSequence() + oracleSeq, err := e.GetNextReceiveOracleSequence(sdk.ChainID(e.config.BSCConfig.ChainId)) require.NoError(t, err) t.Log(oracleSeq) } func TestGetNextSendSequenceForChannel(t *testing.T) { e := GnfdExecutor() - sendSeq, err := e.GetNextSendSequenceForChannelWithRetry(1) + sendSeq, err := e.GetNextSendSequenceForChannelWithRetry(sdk.ChainID(e.config.BSCConfig.ChainId), 1) require.NoError(t, err) t.Log(sendSeq) } diff --git a/go.mod b/go.mod index 02fd8d2..bbb38c1 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ require ( cosmossdk.io/errors v1.0.0-beta.7 github.com/avast/retry-go/v4 v4.3.1 github.com/aws/aws-sdk-go v1.40.45 - github.com/bnb-chain/greenfield v0.2.4-alpha.1 - github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.1 - github.com/cometbft/cometbft v0.37.1 + github.com/bnb-chain/greenfield v0.2.4-alpha.2 + github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.2 + github.com/cometbft/cometbft v0.37.2 github.com/cosmos/cosmos-sdk v0.47.3 github.com/ethereum/go-ethereum v1.11.3 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 @@ -172,14 +172,13 @@ require ( ) replace ( - cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 - cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 - github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2 + cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 + cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 + github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3-alpha.1 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 github.com/consensys/gnark-crypto => github.com/consensys/gnark-crypto v0.7.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 - github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.2 + github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - ) diff --git a/go.sum b/go.sum index e4075a6..ede4c33 100644 --- a/go.sum +++ b/go.sum @@ -158,24 +158,24 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/bnb-chain/greenfield v0.2.4-alpha.1 h1:ZiIHVLPWodpwkX7bid7E3lYtYDpYeTlrBOPHbwfeFOA= -github.com/bnb-chain/greenfield v0.2.4-alpha.1/go.mod h1:L0xqATrpTBtFgGc2o3hLsRoa6wG86bke+KIrgUcieUY= -github.com/bnb-chain/greenfield-cometbft v0.0.2 h1:bRamS8Lq1lA3ttRLZBha22uiNG5tqN+diD3hapdUCYI= -github.com/bnb-chain/greenfield-cometbft v0.0.2/go.mod h1:EBmwmUdaNbGPyGjf1cMuoN3pAeM2tQu7Lfg95813EAw= +github.com/bnb-chain/greenfield v0.2.4-alpha.2 h1:l/GkTKN3M6TnxC3Ak9Tm8Yd/6qW9bxSMc+/pUGvLgTU= +github.com/bnb-chain/greenfield v0.2.4-alpha.2/go.mod h1:rqUmxfdTvIwqa56H9QASdKQ7zrytbEY3zLMQAl2FMiU= +github.com/bnb-chain/greenfield-cometbft v0.0.3-alpha.1 h1:nCLXxYdkDIh5bQMxtb14TBwiut/xq2e0DqPVTLy9vtI= +github.com/bnb-chain/greenfield-cometbft v0.0.3-alpha.1/go.mod h1:3nGT4Z9fHwgRlBY/rofn0rSarnIcNbuhz/eq0XlLlkg= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI= github.com/bnb-chain/greenfield-common/go v0.0.0-20230809025353-fd0519705054 h1:74pdUdHjo9QNgjSifIgzbDcloqFJ2I+qo715tOXy/oM= github.com/bnb-chain/greenfield-common/go v0.0.0-20230809025353-fd0519705054/go.mod h1:GEjCahULmz99qx5k8WGWa7cTXIUjoNMNW+J92I+kTWg= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1 h1:SpkwHzAjIllIQG8av7MybFjJ8mhW1ZZ+P9JqJIsENxI= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.1/go.mod h1:vyZi5fr4gZBVbhV/TLxbm6T8vylHXbfqQmDCUCUPPfo= -github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ= -github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw= -github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s= -github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= -github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.1 h1:ZR4RZC46W9Izf3hRLkmc3X6EXt41fcJxSJWTV7OKt90= -github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.1/go.mod h1:sDg+JXw9BA3PYaK2anb7pFAp+/ltbuBWWOjzsUofRNQ= -github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1 h1:ZnIcvkkQVurg0OaAwmUGn2cK5bZbffjVChFyhh86HMk= -github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.2 h1:mCojTDXd//s34SiHqRolG7saZSG9YHQ9WzPFF8rL4Zo= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4-alpha.2/go.mod h1:2jk2ijERIAv8wxQ/IJSmzQKazCnR6YGvICk4O1YrT9M= +github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 h1:GHPbV2bC+gmuO6/sG0Tm8oGal3KKSRlyE+zPscDjlA8= +github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210/go.mod h1:vhsZxXE9tYJeYB5JR4hPhd6Pc/uPf7j1T8IJ7p9FdeM= +github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 h1:FLVOn4+OVbsKi2+YJX5kmD27/4dRu4FW7xCXFhzDO5s= +github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM= +github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.2 h1:lxrcKghW/Qz8mRvLti5R6/VGTpl4O8hd+xhtnr5EL58= +github.com/bnb-chain/greenfield-go-sdk v0.2.4-alpha.2/go.mod h1:PO+JKqXkzk2hjC8UDVFExGkscCwmOdAIzNTnQiGrUBU= +github.com/bnb-chain/greenfield-iavl v0.20.1 h1:y3L64GU99otNp27/xLVBTDbv4eroR6CzoYz0rbaVotM= +github.com/bnb-chain/greenfield-iavl v0.20.1/go.mod h1:oLksTs8dfh7DYIKBro7hbRQ+ewls7ghJ27pIXlbEXyI= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= diff --git a/listener/bsc_listener.go b/listener/bsc_listener.go index e28e811..5d62bc4 100644 --- a/listener/bsc_listener.go +++ b/listener/bsc_listener.go @@ -3,6 +3,7 @@ package listener import ( "context" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "strings" "time" @@ -20,7 +21,6 @@ import ( "github.com/bnb-chain/greenfield-relayer/executor" "github.com/bnb-chain/greenfield-relayer/logging" "github.com/bnb-chain/greenfield-relayer/metric" - rtypes "github.com/bnb-chain/greenfield-relayer/types" ) type BSCListener struct { @@ -110,8 +110,8 @@ func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64) error { logging.Logger.Infof("get log: %d, %s, %s", log.BlockNumber, log.Topics[0].String(), log.TxHash.String()) relayPkg, err := ParseRelayPackage(&l.crossChainAbi, &log, nextHeightBlockHeader.Time, - rtypes.ChainId(l.config.GreenfieldConfig.ChainId), - rtypes.ChainId(l.config.BSCConfig.ChainId), + sdk.ChainID(l.config.GreenfieldConfig.ChainId), + sdk.ChainID(l.config.BSCConfig.ChainId), &l.config.RelayConfig, ) if err != nil { diff --git a/listener/event_parser.go b/listener/event_parser.go index 3231e4d..82cf4c9 100644 --- a/listener/event_parser.go +++ b/listener/event_parser.go @@ -3,6 +3,7 @@ package listener import ( "encoding/hex" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "math/big" "github.com/ethereum/go-ethereum/accounts/abi" @@ -14,12 +15,12 @@ import ( rtypes "github.com/bnb-chain/greenfield-relayer/types" ) -func ParseRelayPackage(abi *abi.ABI, log *types.Log, timestamp uint64, greenfieldChainId, bscChainId rtypes.ChainId, config *config.RelayConfig) (*model.BscRelayPackage, error) { +func ParseRelayPackage(abi *abi.ABI, log *types.Log, timestamp uint64, greenfieldChainId, bscChainId sdk.ChainID, config *config.RelayConfig) (*model.BscRelayPackage, error) { ev, err := parseCrossChainPackageEvent(abi, log, config) if err != nil { return nil, err } - if rtypes.ChainId(ev.SrcChainId) != bscChainId || rtypes.ChainId(ev.DstChainId) != greenfieldChainId { + if sdk.ChainID(ev.SrcChainId) != bscChainId || sdk.ChainID(ev.DstChainId) != greenfieldChainId { return nil, fmt.Errorf("event log's chain id(s) not expected, SrcChainId=%d, DstChainId=%d", ev.SrcChainId, ev.DstChainId) } var p model.BscRelayPackage diff --git a/vote/bsc_vote_processor.go b/vote/bsc_vote_processor.go index f475063..6792cd0 100644 --- a/vote/bsc_vote_processor.go +++ b/vote/bsc_vote_processor.go @@ -353,7 +353,7 @@ func (p *BSCVoteProcessor) isVotePubKeyValid(v *votepool.Vote, validators []*tmt } func (p *BSCVoteProcessor) isOracleSequenceFilled(seq uint64) (bool, error) { - nextDeliverySeqOnGreenfield, err := p.bscExecutor.GetNextDeliveryOracleSequenceWithRetry() + nextDeliverySeqOnGreenfield, err := p.bscExecutor.GetNextDeliveryOracleSequenceWithRetry(p.getChainId()) if err != nil { return false, err } @@ -367,3 +367,7 @@ func (p *BSCVoteProcessor) reBroadcastVote(localVote *model.Vote) error { } return p.bscExecutor.GreenfieldExecutor.BroadcastVote(v) } + +func (p *BSCVoteProcessor) getChainId() sdk.ChainID { + return sdk.ChainID(p.config.BSCConfig.ChainId) +}