Skip to content

Commit

Permalink
Merge pull request #106 from bnb-chain/hotfix-filterlog
Browse files Browse the repository at this point in the history
fix: fix filter log compatibility
  • Loading branch information
alexgao001 authored Apr 17, 2024
2 parents 18c6820 + 7fef769 commit 2951ad6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions listener/bsc_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package listener
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"math/big"
"strings"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cometbft/cometbft/votepool"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -116,7 +118,7 @@ func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64, latestPolledBloc
}
}

logs, err := l.queryCrossChainLogs(nextHeightBlockHeader.Hash())
logs, err := l.queryCrossChainLogs(nextHeight)
if err != nil {
return fmt.Errorf("failed to get logs from block at height=%d, err=%s", nextHeight, err.Error())
}
Expand Down Expand Up @@ -151,11 +153,12 @@ func (l *BSCListener) monitorCrossChainPkgAt(nextHeight uint64, latestPolledBloc
return nil
}

func (l *BSCListener) queryCrossChainLogs(blockHash ethcommon.Hash) ([]types.Log, error) {
func (l *BSCListener) queryCrossChainLogs(height uint64) ([]types.Log, error) {
client := l.bscExecutor.GetEthClient()
topics := [][]ethcommon.Hash{{l.getCrossChainPackageEventHash()}}
logs, err := client.FilterLogs(context.Background(), ethereum.FilterQuery{
BlockHash: &blockHash,
FromBlock: big.NewInt(int64(height)),
ToBlock: big.NewInt(int64(height)),
Topics: topics,
Addresses: []ethcommon.Address{l.getCrossChainContractAddress()},
})
Expand Down

0 comments on commit 2951ad6

Please sign in to comment.