Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Filter past events related to tbtc specific actions #608

Merged
merged 11 commits into from
Nov 18, 2020
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/ipfs/go-log v1.0.4
github.com/keep-network/keep-common v1.2.1-0.20201117163745-878626866ba7
github.com/keep-network/keep-core v1.3.2-0.20201117170744-88a808971677
github.com/keep-network/tbtc v1.1.1-0.20201026093513-cb9246987718
github.com/keep-network/tbtc v1.1.1-0.20201117095624-38508bdb562e
github.com/pkg/errors v0.9.1
github.com/urfave/cli v1.22.1
)
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,13 @@ github.com/keep-network/cli v1.20.0 h1:mEufpPsovOVdduTTkk+a2CxS3crIrGFqUsvs58gSi
github.com/keep-network/cli v1.20.0/go.mod h1:nzsst4JjU+rGE8Q5J839fYxectxWHpLhxKNohQWtQhA=
github.com/keep-network/go-libp2p-bootstrap v0.0.0-20200423153828-ed815bc50aec h1:2pXAsi4OUUjZKr5ds5UOF2IxXN+jVW0WetVO+czkf+A=
github.com/keep-network/go-libp2p-bootstrap v0.0.0-20200423153828-ed815bc50aec/go.mod h1:xR8jf3/VJAjh3nWu5tFe8Yxnt2HvWsqZHfGef1P5oDk=
github.com/keep-network/keep-common v1.2.1-0.20201020114759-19c123cbd4f4 h1:CivupPSFswHACua5xZGKdeYxsCQ2cmRomTIBh8kfk70=
github.com/keep-network/keep-common v1.2.1-0.20201020114759-19c123cbd4f4/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo=
github.com/keep-network/keep-common v1.2.1-0.20201116151638-8af057907255/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo=
github.com/keep-network/keep-common v1.2.1-0.20201117163745-878626866ba7 h1:bmyyWcrg7dZ2TcgEIPV3d5uUrpoOncz9gEGBNg9eMHA=
github.com/keep-network/keep-common v1.2.1-0.20201117163745-878626866ba7/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo=
github.com/keep-network/keep-core v1.3.2-0.20201117170744-88a808971677 h1:rOdyRpHh8pj5TW9OOk0oB2WOAfARbzkWM6AACx4StKw=
github.com/keep-network/keep-core v1.3.2-0.20201117170744-88a808971677/go.mod h1:SlbEjr3r6alzEB5raBFCT8z7RJjEy/2MQjBWuyL1jkg=
github.com/keep-network/tbtc v1.1.1-0.20201026093513-cb9246987718 h1:/ZNMBY7y6hfzCYA8mgtHnspGO26OmWV3sDehyGnqRyY=
github.com/keep-network/tbtc v1.1.1-0.20201026093513-cb9246987718/go.mod h1:igBF2MPTFkzOdZ3gcwt8h0Zb5pZaHnij/iPZoMB9IKM=
github.com/keep-network/tbtc v1.1.1-0.20201117095624-38508bdb562e h1:go3irX4olJUZOi59gaBX7iYIFFbJEV5/zbfCG4tOPaQ=
github.com/keep-network/tbtc v1.1.1-0.20201117095624-38508bdb562e/go.mod h1:LS1zQDXTJrP5f6AHFQKw6/iJPdfV+WqUCfh6GTfC6Rs=
github.com/keep-network/toml v0.3.0 h1:G+NJwWR/ZiORqeLBsDXDchYoL29PXHdxOPcCueA7ctE=
github.com/keep-network/toml v0.3.0/go.mod h1:Zeyd3lxbIlMYLREho3UK1dMP2xjqt2gLkQ5E5vM6K38=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
Expand Down
13 changes: 4 additions & 9 deletions pkg/chain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"sort"
"time"

"github.com/keep-network/keep-ecdsa/pkg/chain/gen/eventlog"

"github.com/ethereum/go-ethereum/common"

"github.com/ipfs/go-log"
Expand Down Expand Up @@ -523,17 +521,14 @@ func (ec *EthereumChain) PastSignatureSubmittedEvents(
if !common.IsHexAddress(keepAddress) {
return nil, fmt.Errorf("invalid keep address: [%v]", keepAddress)
}

keepContractEventLog, err := eventlog.NewBondedECDSAKeepEventLog(
common.HexToAddress(keepAddress),
ec.client,
)
keepContract, err := ec.getKeepContract(common.HexToAddress(keepAddress))
if err != nil {
return nil, err
}

events, err := keepContractEventLog.PastSignatureSubmittedEvents(
events, err := keepContract.PastSignatureSubmittedEvents(
startBlock,
nil, // latest block
nil,
)
if err != nil {
Expand All @@ -548,7 +543,7 @@ func (ec *EthereumChain) PastSignatureSubmittedEvents(
R: event.R,
S: event.S,
RecoveryID: event.RecoveryID,
BlockNumber: event.BlockNumber,
BlockNumber: event.Raw.BlockNumber,
})
}

Expand Down
22 changes: 6 additions & 16 deletions pkg/chain/ethereum/tbtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/keep-network/keep-common/pkg/subscription"
"github.com/keep-network/tbtc/pkg/chain/ethereum/gen/contract"
"github.com/keep-network/tbtc/pkg/chain/ethereum/gen/eventlog"
)

// TBTCEthereumChain represents an Ethereum chain handle with
Expand All @@ -19,7 +18,6 @@ type TBTCEthereumChain struct {
*EthereumChain

tbtcSystemContract *contract.TBTCSystem
tbtcSystemEventLog *eventlog.TBTCSystemEventLog
}

// WithTBTCExtension extends the Ethereum chain handle with
Expand All @@ -44,18 +42,9 @@ func WithTBTCExtension(
return nil, err
}

tbtcSystemEventLog, err := eventlog.NewTBTCSystemEventLog(
common.HexToAddress(tbtcSystemContractAddress),
ethereumChain.client,
)
if err != nil {
return nil, err
}

return &TBTCEthereumChain{
EthereumChain: ethereumChain,
tbtcSystemContract: tbtcSystemContract,
tbtcSystemEventLog: tbtcSystemEventLog,
}, nil
}

Expand Down Expand Up @@ -192,18 +181,19 @@ func (tec *TBTCEthereumChain) OnDepositRedeemed(
// events for the given deposit which occurred after the provided start block.
// Returned events are sorted by the block number in the ascending order.
func (tec *TBTCEthereumChain) PastDepositRedemptionRequestedEvents(
depositAddress string,
startBlock uint64,
depositAddress string,
) ([]*chain.DepositRedemptionRequestedEvent, error) {
if !common.IsHexAddress(depositAddress) {
return nil, fmt.Errorf("incorrect deposit contract address")
}

events, err := tec.tbtcSystemEventLog.PastRedemptionRequestedEvents(
events, err := tec.tbtcSystemContract.PastRedemptionRequestedEvents(
startBlock,
nil,
[]common.Address{
common.HexToAddress(depositAddress),
},
startBlock,
nil,
nil,
)
if err != nil {
Expand All @@ -221,7 +211,7 @@ func (tec *TBTCEthereumChain) PastDepositRedemptionRequestedEvents(
RedeemerOutputScript: event.RedeemerOutputScript,
RequestedFee: event.RequestedFee,
Outpoint: event.Outpoint,
BlockNumber: event.BlockNumber,
BlockNumber: event.Raw.BlockNumber,
})
}

Expand Down
Loading