From 99a97fb149913f13ed2012031228f2df8517a022 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 25 Jan 2021 20:50:46 +0100 Subject: [PATCH 01/11] tbtc dependency version updated for development Updated tbtc dependency version to the one with regenerated contract bindings with keep-common changes about resubscription and background subscription monitoring process. --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index f29b83e81..3b76ce8df 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/ipfs/go-log v1.0.4 github.com/keep-network/keep-common v1.3.1-0.20210122143623-90288e13a93d github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb - github.com/keep-network/tbtc v1.1.1-0.20201117095624-38508bdb562e + github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 github.com/pkg/errors v0.9.1 github.com/urfave/cli v1.22.1 ) diff --git a/go.sum b/go.sum index d5a821175..889b288f6 100644 --- a/go.sum +++ b/go.sum @@ -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.20201116151638-8af057907255/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-common v1.3.0/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-common v1.3.1-0.20210122143623-90288e13a93d h1:S/N7f1rP2hDdKYqRndKP0wsDljRgSeY8CTUt6Kzjjg0= github.com/keep-network/keep-common v1.3.1-0.20210122143623-90288e13a93d/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb h1:pDhLagUiOYWOn72UiG3jSDVDXZ4dYlsfRa0ToF/ru18= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb/go.mod h1:4KezOJWc//c5lbtAE1ob7qYE/Gs5+a1QTjGBzzv2tu8= -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/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 h1:uw6ZmFbtoqfmx0bfE4bWZtiSyG1uD6o/h0DF0wy/Mhw= +github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12/go.mod h1:nLHbMHv4PiuJutvGYUPxl7Q2O8xrsIGtVibAqWD04Is= 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= From c39c103353b1f01faa2a6b6588c82e9408cfda2d Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 25 Jan 2021 21:59:14 +0100 Subject: [PATCH 02/11] updated event subscription API in tBTC ethereum extension Adjusted the code to the regenerated Go contract bindings in tbtc repository. The regenerated bindings contains keep-common improvements around event resubscription mechanism and background event monitoring loop fetching events from the chain periodically in case some event was dropped by websocket subscription. --- cmd/start.go | 9 +- pkg/chain/ethereum/tbtc.go | 162 ++++++++++++--------------- pkg/chain/local/tbtc.go | 20 ++-- pkg/chain/tbtc.go | 10 +- pkg/extensions/tbtc/tbtc.go | 109 +++++------------- pkg/extensions/tbtc/tbtc_test.go | 183 +++++++++---------------------- 6 files changed, 164 insertions(+), 329 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index 1d4be87e6..19d10c39a 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -216,14 +216,7 @@ func initializeExtensions( return } - err = tbtc.Initialize(ctx, tbtcEthereumChain) - if err != nil { - logger.Errorf( - "could not initialize tbtc extension: [%v]", - err, - ) - return - } + tbtc.Initialize(ctx, tbtcEthereumChain) } } diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index e5e44a5f7..45ddec02a 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -36,6 +36,7 @@ func WithTBTCExtension( ethereumChain.client, ethereumChain.nonceManager, ethereumChain.miningWaiter, + ethereumChain.blockCounter, ethereumChain.transactionMutex, ) if err != nil { @@ -52,129 +53,109 @@ func WithTBTCExtension( // on-chain notification of a new deposit creation is seen. func (tec *TBTCEthereumChain) OnDepositCreated( handler func(depositAddress string), -) (subscription.EventSubscription, error) { - return tec.tbtcSystemContract.WatchCreated( - func( - DepositContractAddress common.Address, - KeepAddress common.Address, - Timestamp *big.Int, - blockNumber uint64, - ) { - handler(DepositContractAddress.Hex()) - }, - func(err error) error { - return fmt.Errorf("watch deposit created failed: [%v]", err) - }, +) subscription.EventSubscription { + onEvent := func( + DepositContractAddress common.Address, + KeepAddress common.Address, + Timestamp *big.Int, + blockNumber uint64, + ) { + handler(DepositContractAddress.Hex()) + } + + return tec.tbtcSystemContract.Created( nil, nil, - ) + nil, + ).OnEvent(onEvent) } // OnDepositRegisteredPubkey installs a callback that is invoked when an // on-chain notification of a deposit's pubkey registration is seen. func (tec *TBTCEthereumChain) OnDepositRegisteredPubkey( handler func(depositAddress string), -) (subscription.EventSubscription, error) { - return tec.tbtcSystemContract.WatchRegisteredPubkey( - func( - DepositContractAddress common.Address, - SigningGroupPubkeyX [32]uint8, - SigningGroupPubkeyY [32]uint8, - Timestamp *big.Int, - blockNumber uint64, - ) { - handler(DepositContractAddress.Hex()) - }, - func(err error) error { - return fmt.Errorf( - "watch deposit registered pubkey failed: [%v]", - err, - ) - }, - nil, - ) +) subscription.EventSubscription { + onEvent := func( + DepositContractAddress common.Address, + SigningGroupPubkeyX [32]uint8, + SigningGroupPubkeyY [32]uint8, + Timestamp *big.Int, + blockNumber uint64, + ) { + handler(DepositContractAddress.Hex()) + } + + return tec.tbtcSystemContract.RegisteredPubkey(nil, nil).OnEvent(onEvent) } // OnDepositRedemptionRequested installs a callback that is invoked when an // on-chain notification of a deposit redemption request is seen. func (tec *TBTCEthereumChain) OnDepositRedemptionRequested( handler func(depositAddress string), -) (subscription.EventSubscription, error) { - return tec.tbtcSystemContract.WatchRedemptionRequested( - func( - DepositContractAddress common.Address, - Requester common.Address, - Digest [32]uint8, - UtxoValue *big.Int, - RedeemerOutputScript []uint8, - RequestedFee *big.Int, - Outpoint []uint8, - blockNumber uint64, - ) { - handler(DepositContractAddress.Hex()) - }, - func(err error) error { - return fmt.Errorf( - "watch deposit redemption requested failed: [%v]", - err, - ) - }, +) subscription.EventSubscription { + onEvent := func( + DepositContractAddress common.Address, + Requester common.Address, + Digest [32]uint8, + UtxoValue *big.Int, + RedeemerOutputScript []uint8, + RequestedFee *big.Int, + Outpoint []uint8, + blockNumber uint64, + ) { + handler(DepositContractAddress.Hex()) + } + + return tec.tbtcSystemContract.RedemptionRequested( nil, nil, nil, - ) + nil, + ).OnEvent(onEvent) } // OnDepositGotRedemptionSignature installs a callback that is invoked when an // on-chain notification of a deposit receiving a redemption signature is seen. func (tec *TBTCEthereumChain) OnDepositGotRedemptionSignature( handler func(depositAddress string), -) (subscription.EventSubscription, error) { - return tec.tbtcSystemContract.WatchGotRedemptionSignature( - func( - DepositContractAddress common.Address, - Digest [32]uint8, - R [32]uint8, - S [32]uint8, - Timestamp *big.Int, - blockNumber uint64, - ) { - handler(DepositContractAddress.Hex()) - }, - func(err error) error { - return fmt.Errorf( - "watch deposit got redemption signature failed: [%v]", - err, - ) - }, +) subscription.EventSubscription { + onEvent := func( + DepositContractAddress common.Address, + Digest [32]uint8, + R [32]uint8, + S [32]uint8, + Timestamp *big.Int, + blockNumber uint64, + ) { + handler(DepositContractAddress.Hex()) + } + + return tec.tbtcSystemContract.GotRedemptionSignature( nil, nil, - ) + nil, + ).OnEvent(onEvent) } // OnDepositRedeemed installs a callback that is invoked when an // on-chain notification of a deposit redemption is seen. func (tec *TBTCEthereumChain) OnDepositRedeemed( handler func(depositAddress string), -) (subscription.EventSubscription, error) { - return tec.tbtcSystemContract.WatchRedeemed( - func( - DepositContractAddress common.Address, - Txid [32]uint8, - Timestamp *big.Int, - blockNumber uint64, - ) { - handler(DepositContractAddress.Hex()) - }, - func(err error) error { - return fmt.Errorf( - "watch deposit redeemed failed: [%v]", - err, - ) - }, +) subscription.EventSubscription { + onEvent := func( + DepositContractAddress common.Address, + Txid [32]uint8, + Timestamp *big.Int, + blockNumber uint64, + ) { + handler(DepositContractAddress.Hex()) + } + + return tec.tbtcSystemContract.Redeemed( nil, nil, - ) + nil, + ).OnEvent(onEvent) } // PastDepositRedemptionRequestedEvents returns all redemption requested @@ -384,6 +365,7 @@ func (tec *TBTCEthereumChain) getDepositContract( tec.client, tec.nonceManager, tec.miningWaiter, + tec.blockCounter, tec.transactionMutex, ) if err != nil { diff --git a/pkg/chain/local/tbtc.go b/pkg/chain/local/tbtc.go index 02c046de6..0a0efe9ad 100644 --- a/pkg/chain/local/tbtc.go +++ b/pkg/chain/local/tbtc.go @@ -138,7 +138,7 @@ func (tlc *TBTCLocalChain) CreateDeposit( func (tlc *TBTCLocalChain) OnDepositCreated( handler func(depositAddress string), -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { tlc.tbtcLocalChainMutex.Lock() defer tlc.tbtcLocalChainMutex.Unlock() @@ -151,12 +151,12 @@ func (tlc *TBTCLocalChain) OnDepositCreated( defer tlc.tbtcLocalChainMutex.Unlock() delete(tlc.depositCreatedHandlers, handlerID) - }), nil + }) } func (tlc *TBTCLocalChain) OnDepositRegisteredPubkey( handler func(depositAddress string), -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { tlc.tbtcLocalChainMutex.Lock() defer tlc.tbtcLocalChainMutex.Unlock() @@ -169,7 +169,7 @@ func (tlc *TBTCLocalChain) OnDepositRegisteredPubkey( defer tlc.tbtcLocalChainMutex.Unlock() delete(tlc.depositRegisteredPubkeyHandlers, handlerID) - }), nil + }) } func (tlc *TBTCLocalChain) RedeemDeposit(depositAddress string) error { @@ -240,7 +240,7 @@ func (tlc *TBTCLocalChain) RedeemDeposit(depositAddress string) error { func (tlc *TBTCLocalChain) OnDepositRedemptionRequested( handler func(depositAddress string), -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { tlc.tbtcLocalChainMutex.Lock() defer tlc.tbtcLocalChainMutex.Unlock() @@ -253,12 +253,12 @@ func (tlc *TBTCLocalChain) OnDepositRedemptionRequested( defer tlc.tbtcLocalChainMutex.Unlock() delete(tlc.depositRedemptionRequestedHandlers, handlerID) - }), nil + }) } func (tlc *TBTCLocalChain) OnDepositGotRedemptionSignature( handler func(depositAddress string), -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { tlc.tbtcLocalChainMutex.Lock() defer tlc.tbtcLocalChainMutex.Unlock() @@ -271,12 +271,12 @@ func (tlc *TBTCLocalChain) OnDepositGotRedemptionSignature( defer tlc.tbtcLocalChainMutex.Unlock() delete(tlc.depositGotRedemptionSignatureHandlers, handlerID) - }), nil + }) } func (tlc *TBTCLocalChain) OnDepositRedeemed( handler func(depositAddress string), -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { tlc.tbtcLocalChainMutex.Lock() defer tlc.tbtcLocalChainMutex.Unlock() @@ -289,7 +289,7 @@ func (tlc *TBTCLocalChain) OnDepositRedeemed( defer tlc.tbtcLocalChainMutex.Unlock() delete(tlc.depositRedeemedHandlers, handlerID) - }), nil + }) } func (tlc *TBTCLocalChain) PastDepositRedemptionRequestedEvents( diff --git a/pkg/chain/tbtc.go b/pkg/chain/tbtc.go index 84dea7389..e6a69a07a 100644 --- a/pkg/chain/tbtc.go +++ b/pkg/chain/tbtc.go @@ -66,32 +66,32 @@ type TBTCSystem interface { // on-chain notification of a new deposit creation is seen. OnDepositCreated( handler func(depositAddress string), - ) (subscription.EventSubscription, error) + ) subscription.EventSubscription // OnDepositRegisteredPubkey installs a callback that is invoked when an // on-chain notification of a deposit's pubkey registration is seen. OnDepositRegisteredPubkey( handler func(depositAddress string), - ) (subscription.EventSubscription, error) + ) subscription.EventSubscription // OnDepositRedemptionRequested installs a callback that is invoked when an // on-chain notification of a deposit redemption request is seen. OnDepositRedemptionRequested( handler func(depositAddress string), - ) (subscription.EventSubscription, error) + ) subscription.EventSubscription // OnDepositGotRedemptionSignature installs a callback that is invoked // when an on-chain notification of a deposit receiving a redemption // signature is seen. OnDepositGotRedemptionSignature( handler func(depositAddress string), - ) (subscription.EventSubscription, error) + ) subscription.EventSubscription // OnDepositRedeemed installs a callback that is invoked when an // on-chain notification of a deposit redemption is seen. OnDepositRedeemed( handler func(depositAddress string), - ) (subscription.EventSubscription, error) + ) subscription.EventSubscription // PastDepositRedemptionRequestedEvents returns all redemption requested // events for the given deposit which occurred after the provided start block. diff --git a/pkg/extensions/tbtc/tbtc.go b/pkg/extensions/tbtc/tbtc.go index 1ff21a95e..f5f68e22a 100644 --- a/pkg/extensions/tbtc/tbtc.go +++ b/pkg/extensions/tbtc/tbtc.go @@ -50,52 +50,30 @@ const ( // TODO: Resume monitoring after client restart // Initialize initializes extension specific to the TBTC application. -func Initialize(ctx context.Context, chain chain.TBTCHandle) error { +func Initialize(ctx context.Context, chain chain.TBTCHandle) { logger.Infof("initializing tbtc extension") tbtc := newTBTC(chain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, exponentialBackoff, 165*time.Minute, // 15 minutes before the 3 hours on-chain timeout ) - if err != nil { - return fmt.Errorf( - "could not initialize retrieve pubkey monitoring: [%v]", - err, - ) - } - err = tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, exponentialBackoff, 105*time.Minute, // 15 minutes before the 2 hours on-chain timeout ) - if err != nil { - return fmt.Errorf( - "could not initialize provide redemption "+ - "signature monitoring: [%v]", - err, - ) - } - err = tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, exponentialBackoff, 345*time.Minute, // 15 minutes before the 6 hours on-chain timeout ) - if err != nil { - return fmt.Errorf( - "could not initialize provide redemption "+ - "proof monitoring: [%v]", - err, - ) - } logger.Infof("tbtc extension has been initialized") - - return nil } type tbtc struct { @@ -121,18 +99,18 @@ func (t *tbtc) monitorRetrievePubKey( ctx context.Context, actBackoffFn backoffFn, timeout time.Duration, -) error { +) { initialDepositState := chain.AwaitingSignerSetup monitoringStartFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { return t.chain.OnDepositCreated(handler) } monitoringStopFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { return t.chain.OnDepositRegisteredPubkey(func(depositAddress string) { if t.waitDepositStateChangeConfirmation( depositAddress, @@ -175,7 +153,7 @@ func (t *tbtc) monitorRetrievePubKey( return timeout + actionDelay, nil } - monitoringSubscription, err := t.monitorAndAct( + monitoringSubscription := t.monitorAndAct( ctx, "retrieve pubkey", t.shouldMonitorDeposit, @@ -186,9 +164,6 @@ func (t *tbtc) monitorRetrievePubKey( actBackoffFn, timeoutFn, ) - if err != nil { - return err - } go func() { <-ctx.Done() @@ -197,20 +172,18 @@ func (t *tbtc) monitorRetrievePubKey( }() logger.Infof("retrieve pubkey monitoring initialized") - - return nil } func (t *tbtc) monitorProvideRedemptionSignature( ctx context.Context, actBackoffFn backoffFn, timeout time.Duration, -) error { +) { initialDepositState := chain.AwaitingWithdrawalSignature monitoringStartFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { // Start right after a redemption has been requested or the redemption // fee has been increased. return t.chain.OnDepositRedemptionRequested(handler) @@ -218,9 +191,9 @@ func (t *tbtc) monitorProvideRedemptionSignature( monitoringStopFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { // Stop in case the redemption signature has been provided by someone else. - signatureSubscription, err := t.chain.OnDepositGotRedemptionSignature( + signatureSubscription := t.chain.OnDepositGotRedemptionSignature( func(depositAddress string) { if t.waitDepositStateChangeConfirmation( depositAddress, @@ -237,12 +210,9 @@ func (t *tbtc) monitorProvideRedemptionSignature( } }, ) - if err != nil { - return nil, err - } // Stop in case the redemption proof has been provided by someone else. - redeemedSubscription, err := t.chain.OnDepositRedeemed( + redeemedSubscription := t.chain.OnDepositRedeemed( func(depositAddress string) { if t.waitDepositStateChangeConfirmation( depositAddress, @@ -259,16 +229,13 @@ func (t *tbtc) monitorProvideRedemptionSignature( } }, ) - if err != nil { - return nil, err - } return subscription.NewEventSubscription( func() { signatureSubscription.Unsubscribe() redeemedSubscription.Unsubscribe() }, - ), nil + ) } actFn := func(depositAddress string) error { @@ -354,7 +321,7 @@ func (t *tbtc) monitorProvideRedemptionSignature( return timeout + actionDelay, nil } - monitoringSubscription, err := t.monitorAndAct( + monitoringSubscription := t.monitorAndAct( ctx, "provide redemption signature", t.shouldMonitorDeposit, @@ -365,9 +332,6 @@ func (t *tbtc) monitorProvideRedemptionSignature( actBackoffFn, timeoutFn, ) - if err != nil { - return err - } go func() { <-ctx.Done() @@ -376,29 +340,27 @@ func (t *tbtc) monitorProvideRedemptionSignature( }() logger.Infof("provide redemption signature monitoring initialized") - - return nil } func (t *tbtc) monitorProvideRedemptionProof( ctx context.Context, actBackoffFn backoffFn, timeout time.Duration, -) error { +) { initialDepositState := chain.AwaitingWithdrawalProof monitoringStartFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { // Start right after a redemption signature has been provided. return t.chain.OnDepositGotRedemptionSignature(handler) } monitoringStopFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { // Stop in case the redemption fee has been increased by someone else. - redemptionRequestedSubscription, err := t.chain.OnDepositRedemptionRequested( + redemptionRequestedSubscription := t.chain.OnDepositRedemptionRequested( func(depositAddress string) { if t.waitDepositStateChangeConfirmation( depositAddress, @@ -415,12 +377,9 @@ func (t *tbtc) monitorProvideRedemptionProof( } }, ) - if err != nil { - return nil, err - } // Stop in case the redemption proof has been provided by someone else. - redeemedSubscription, err := t.chain.OnDepositRedeemed( + redeemedSubscription := t.chain.OnDepositRedeemed( func(depositAddress string) { if t.waitDepositStateChangeConfirmation( depositAddress, @@ -437,16 +396,13 @@ func (t *tbtc) monitorProvideRedemptionProof( } }, ) - if err != nil { - return nil, err - } return subscription.NewEventSubscription( func() { redemptionRequestedSubscription.Unsubscribe() redeemedSubscription.Unsubscribe() }, - ), nil + ) } actFn := func(depositAddress string) error { @@ -564,7 +520,7 @@ func (t *tbtc) monitorProvideRedemptionProof( return (timeout - timeoutShift) + actionDelay, nil } - monitoringSubscription, err := t.monitorAndAct( + monitoringSubscription := t.monitorAndAct( ctx, "provide redemption proof", t.shouldMonitorDeposit, @@ -575,9 +531,6 @@ func (t *tbtc) monitorProvideRedemptionProof( actBackoffFn, timeoutFn, ) - if err != nil { - return err - } go func() { <-ctx.Done() @@ -586,8 +539,6 @@ func (t *tbtc) monitorProvideRedemptionProof( }() logger.Infof("provide redemption proof monitoring initialized") - - return nil } type shouldMonitorDepositFn func(depositAddress string) bool @@ -596,7 +547,7 @@ type depositEventHandler func(depositAddress string) type watchDepositEventFn func( handler depositEventHandler, -) (subscription.EventSubscription, error) +) subscription.EventSubscription type watchKeepClosedFn func(depositAddress string) ( keepClosedChan chan struct{}, @@ -620,7 +571,7 @@ func (t *tbtc) monitorAndAct( actFn submitDepositTxFn, actBackoffFn backoffFn, timeoutFn timeoutFn, -) (subscription.EventSubscription, error) { +) subscription.EventSubscription { handleStartEvent := func(depositAddress string) { if !shouldMonitorFn(depositAddress) { return @@ -644,23 +595,13 @@ func (t *tbtc) monitorAndAct( stopEventChan := make(chan struct{}) - stopEventSubscription, err := monitoringStopFn( + stopEventSubscription := monitoringStopFn( func(stopEventDepositAddress string) { if depositAddress == stopEventDepositAddress { stopEventChan <- struct{}{} } }, ) - if err != nil { - logger.Errorf( - "could not setup stop event handler for [%v] "+ - "monitoring for deposit [%v]: [%v]", - monitoringName, - depositAddress, - err, - ) - return - } defer stopEventSubscription.Unsubscribe() keepClosedChan, keepClosedUnsubscribe, err := keepClosedFn( diff --git a/pkg/extensions/tbtc/tbtc_test.go b/pkg/extensions/tbtc/tbtc_test.go index 8673a769f..270039c38 100644 --- a/pkg/extensions/tbtc/tbtc_test.go +++ b/pkg/extensions/tbtc/tbtc_test.go @@ -42,14 +42,11 @@ func TestRetrievePubkey_TimeoutElapsed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -106,14 +103,11 @@ func TestRetrievePubkey_StopEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -180,14 +174,11 @@ func TestRetrievePubkey_KeepClosedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -196,7 +187,7 @@ func TestRetrievePubkey_KeepClosedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -251,14 +242,11 @@ func TestRetrievePubkey_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -267,7 +255,7 @@ func TestRetrievePubkey_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -322,14 +310,11 @@ func TestRetrievePubkey_ActionFailed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -366,14 +351,11 @@ func TestRetrievePubkey_ContextCancelled_WithoutWorkingMonitoring(t *testing.T) tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } // cancel the context before any start event occurs cancelCtx() @@ -410,14 +392,11 @@ func TestRetrievePubkey_ContextCancelled_WithWorkingMonitoring(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -460,14 +439,11 @@ func TestRetrievePubkey_OperatorNotInSigningGroup(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorRetrievePubKey( + tbtc.monitorRetrievePubKey( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := local.RandomSigningGroup(3) @@ -499,14 +475,11 @@ func TestProvideRedemptionSignature_TimeoutElapsed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -515,7 +488,7 @@ func TestProvideRedemptionSignature_TimeoutElapsed(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -578,14 +551,11 @@ func TestProvideRedemptionSignature_StopEventOccurred_DepositGotRedemptionSignat tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -594,7 +564,7 @@ func TestProvideRedemptionSignature_StopEventOccurred_DepositGotRedemptionSignat tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -672,14 +642,11 @@ func TestProvideRedemptionSignature_StopEventOccurred_DepositRedeemed( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -688,7 +655,7 @@ func TestProvideRedemptionSignature_StopEventOccurred_DepositRedeemed( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -757,14 +724,11 @@ func TestProvideRedemptionSignature_KeepClosedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -773,7 +737,7 @@ func TestProvideRedemptionSignature_KeepClosedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -839,14 +803,11 @@ func TestProvideRedemptionSignature_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -855,7 +816,7 @@ func TestProvideRedemptionSignature_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -921,14 +882,11 @@ func TestProvideRedemptionSignature_ActionFailed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -937,7 +895,7 @@ func TestProvideRedemptionSignature_ActionFailed(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -983,14 +941,11 @@ func TestProvideRedemptionSignature_ContextCancelled_WithoutWorkingMonitoring( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } // cancel the context before any start event occurs cancelCtx() @@ -1002,7 +957,7 @@ func TestProvideRedemptionSignature_ContextCancelled_WithoutWorkingMonitoring( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1040,14 +995,11 @@ func TestProvideRedemptionSignature_ContextCancelled_WithWorkingMonitoring( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1056,7 +1008,7 @@ func TestProvideRedemptionSignature_ContextCancelled_WithWorkingMonitoring( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1102,20 +1054,17 @@ func TestProvideRedemptionSignature_OperatorNotInSigningGroup( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionSignature( + tbtc.monitorProvideRedemptionSignature( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := local.RandomSigningGroup(3) tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1156,14 +1105,11 @@ func TestProvideRedemptionProof_TimeoutElapsed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1172,7 +1118,7 @@ func TestProvideRedemptionProof_TimeoutElapsed(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1259,14 +1205,11 @@ func TestProvideRedemptionProof_StopEventOccurred_DepositRedemptionRequested( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1275,7 +1218,7 @@ func TestProvideRedemptionProof_StopEventOccurred_DepositRedemptionRequested( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1373,14 +1316,11 @@ func TestProvideRedemptionProof_StopEventOccurred_DepositRedeemed( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1389,7 +1329,7 @@ func TestProvideRedemptionProof_StopEventOccurred_DepositRedeemed( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1467,14 +1407,11 @@ func TestProvideRedemptionProof_KeepClosedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1483,7 +1420,7 @@ func TestProvideRedemptionProof_KeepClosedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1566,14 +1503,11 @@ func TestProvideRedemptionProof_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1582,7 +1516,7 @@ func TestProvideRedemptionProof_KeepTerminatedEventOccurred(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1665,14 +1599,11 @@ func TestProvideRedemptionProof_ActionFailed(t *testing.T) { tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1681,7 +1612,7 @@ func TestProvideRedemptionProof_ActionFailed(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1736,14 +1667,11 @@ func TestProvideRedemptionProof_ContextCancelled_WithoutWorkingMonitoring( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } // cancel the context before any start event occurs cancelCtx() @@ -1755,7 +1683,7 @@ func TestProvideRedemptionProof_ContextCancelled_WithoutWorkingMonitoring( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1807,14 +1735,11 @@ func TestProvideRedemptionProof_ContextCancelled_WithWorkingMonitoring( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := append( []common.Address{tbtcChain.Address()}, @@ -1823,7 +1748,7 @@ func TestProvideRedemptionProof_ContextCancelled_WithWorkingMonitoring( tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1883,20 +1808,17 @@ func TestProvideRedemptionProof_OperatorNotInSigningGroup( tbtcChain := local.NewTBTCLocalChain(ctx) tbtc := newTestTBTC(tbtcChain) - err := tbtc.monitorProvideRedemptionProof( + tbtc.monitorProvideRedemptionProof( ctx, constantBackoff, timeout, ) - if err != nil { - t.Fatal(err) - } signers := local.RandomSigningGroup(3) tbtcChain.CreateDeposit(depositAddress, signers) - _, err = submitKeepPublicKey(depositAddress, tbtcChain) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) if err != nil { t.Fatal(err) } @@ -1954,18 +1876,18 @@ func TestMonitorAndActDeduplication(t *testing.T) { monitoringStartFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { + ) subscription.EventSubscription { for i := 0; i < 5; i++ { handler("deposit") // simulate multiple start events } - return subscription.NewEventSubscription(func() {}), nil + return subscription.NewEventSubscription(func() {}) } monitoringStopFn := func( handler depositEventHandler, - ) (subscription.EventSubscription, error) { - return subscription.NewEventSubscription(func() {}), nil + ) subscription.EventSubscription { + return subscription.NewEventSubscription(func() {}) } keepClosedFn := func(depositAddress string) (chan struct{}, func(), error) { @@ -1982,7 +1904,7 @@ func TestMonitorAndActDeduplication(t *testing.T) { return timeout, nil } - monitoringSubscription, err := tbtc.monitorAndAct( + monitoringSubscription := tbtc.monitorAndAct( ctx, monitoringName, shouldMonitorFn, @@ -1993,9 +1915,6 @@ func TestMonitorAndActDeduplication(t *testing.T) { constantBackoff, timeoutFn, ) - if err != nil { - t.Fatal(err) - } defer monitoringSubscription.Unsubscribe() // wait a bit longer than the monitoring timeout From 952f43e1fd1a971af4dfc4e62389902edada9781 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Tue, 26 Jan 2021 20:32:06 +0100 Subject: [PATCH 03/11] Default backoff for confirm function Provided ConfirmWithTimeoutDefaultBackoff function that will let us use default values for backoff and max backoff, similarly to how we do with DoWithDefaultRetry. Increased timeout for redemption signature state check from 30 seconds to 60 seconds, just in case. --- pkg/client/client.go | 12 ++++++-- pkg/client/event_deduplicator.go | 7 ++--- pkg/client/event_deduplicator_test.go | 39 ++++++++++++++++++++++---- pkg/utils/wrappers.go | 40 ++++++++++++++++++++++++--- 4 files changed, 82 insertions(+), 16 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index b885489d1..f53bb458a 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -547,7 +547,11 @@ func monitorSigningRequests( utils.DoWithDefaultRetry( clientConfig.GetSigningTimeout(), func(ctx context.Context) error { - shouldHandle, err := eventDeduplicator.notifySigningStarted(keepAddress, event.Digest) + shouldHandle, err := eventDeduplicator.notifySigningStarted( + 60*time.Second, + keepAddress, + event.Digest, + ) if err != nil { logger.Errorf( "could not deduplicate signing request event: [%v]", @@ -654,7 +658,11 @@ func checkAwaitingSignature( utils.DoWithDefaultRetry( clientConfig.GetSigningTimeout(), func(ctx context.Context) error { - shouldHandle, err := eventDeduplicator.notifySigningStarted(keepAddress, latestDigest) + shouldHandle, err := eventDeduplicator.notifySigningStarted( + 60*time.Second, + keepAddress, + latestDigest, + ) if err != nil { logger.Errorf( "could not deduplicate signing request event: [%v]", diff --git a/pkg/client/event_deduplicator.go b/pkg/client/event_deduplicator.go index 892b34fe3..82895e1ca 100644 --- a/pkg/client/event_deduplicator.go +++ b/pkg/client/event_deduplicator.go @@ -111,6 +111,7 @@ func (ed *eventDeduplicator) notifyKeyGenCompleted(keepAddress common.Address) { // notifySigningCompleted once the protocol completes, no matter if it failed or // succeeded. func (ed *eventDeduplicator) notifySigningStarted( + timeout time.Duration, keepAddress common.Address, digest [32]byte, ) (bool, error) { @@ -120,10 +121,8 @@ func (ed *eventDeduplicator) notifySigningStarted( // repeat the check in case of a small chain reorg or if chain nodes // are out of sync - isAwaitingSignature, err := utils.ConfirmWithTimeout( - 10*time.Second, - 10*time.Second, - 30*time.Second, + isAwaitingSignature, err := utils.ConfirmWithTimeoutDefaultBackoff( + timeout, func(ctx context.Context) (bool, error) { return ed.chain.IsAwaitingSignature(keepAddress, digest) }, diff --git a/pkg/client/event_deduplicator_test.go b/pkg/client/event_deduplicator_test.go index f86c6cf37..5f97b9112 100644 --- a/pkg/client/event_deduplicator_test.go +++ b/pkg/client/event_deduplicator_test.go @@ -6,12 +6,15 @@ import ( "crypto/sha256" "math/big" "testing" + "time" "github.com/ethereum/go-ethereum/common" "github.com/keep-network/keep-ecdsa/pkg/chain/local" "github.com/keep-network/keep-ecdsa/pkg/ecdsa" ) +const signStateConfirmTimeout = 10 * time.Second + var keepAddress = common.HexToAddress("0x4e09cadc7037afa36603138d1c0b76fe2aa5039c") var digest = sha256.Sum256([]byte("Do or do not. There is no try.")) @@ -78,7 +81,11 @@ func TestDoSign(t *testing.T) { t.Fatal(err) } - canSign, err := deduplicator.notifySigningStarted(keepAddress, digest) + canSign, err := deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) if err != nil { t.Fatal(err) } @@ -108,9 +115,17 @@ func TestDoNotSignIfCurrentlySigning(t *testing.T) { t.Fatal(err) } - deduplicator.notifySigningStarted(keepAddress, digest) + deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) - canSign, err := deduplicator.notifySigningStarted(keepAddress, digest) + canSign, err := deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) if err != nil { t.Fatal(err) } @@ -135,7 +150,11 @@ func TestDoNotSignIfNotAwaitingASignature(t *testing.T) { t.Fatal(err) } - canSign, err := deduplicator.notifySigningStarted(keepAddress, digest) + canSign, err := deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) if err != nil { t.Fatal(err) } @@ -168,7 +187,11 @@ func TestDoSignOneMoreTime(t *testing.T) { t.Fatal(err) } - canSign, err := deduplicator.notifySigningStarted(keepAddress, digest) + canSign, err := deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) if err != nil { t.Fatal(err) } @@ -197,7 +220,11 @@ func TestDoSignOneMoreTime(t *testing.T) { t.Fatal(err) } - canSign, err = deduplicator.notifySigningStarted(keepAddress, digest) + canSign, err = deduplicator.notifySigningStarted( + signStateConfirmTimeout, + keepAddress, + digest, + ) if err != nil { t.Fatal(err) } diff --git a/pkg/utils/wrappers.go b/pkg/utils/wrappers.go index d2eee1690..1b79572b8 100644 --- a/pkg/utils/wrappers.go +++ b/pkg/utils/wrappers.go @@ -8,7 +8,7 @@ import ( // DoWithRetry executes the provided doFn as long as it returns an error or until // a timeout is hit. It applies exponential backoff wait of backoffTime * 2^n -// before n retry of doFn. In case the calculated backoff is longer than +// before nth retry of doFn. In case the calculated backoff is longer than // backoffMax, the backoffMax wait is applied. func DoWithRetry( backoffTime time.Duration, @@ -54,7 +54,7 @@ const ( // DoWithDefaultRetry executes the provided doFn as long as it returns an error or // until a timeout is hit. It applies exponential backoff wait of -// DefaultBackoffTime * 2^n before n retry of doFn. In case the calculated +// DefaultBackoffTime * 2^n before nth retry of doFn. In case the calculated // backoff is longer than DefaultMaxBackoffTime, the DefaultMaxBackoffTime is // applied. func DoWithDefaultRetry( @@ -71,8 +71,8 @@ func DoWithDefaultRetry( // ConfirmWithTimeout executes the provided confirmFn until it returns true or // until it fails or until a timeout is hit. It applies exponential backoff wait -// of backoffTime * 2^n before n retry of confirmFn. In case the calculated -// backoff is longer than backoffMax, the backoffMax is applied. +// of backoffTime * 2^n before nth execution of confirmFn. In case the +// calculated backoff is longer than backoffMax, the backoffMax is applied. // In case confirmFn returns an error, ConfirmWithTimeout exits with the same // error immediately. This is different from DoWithRetry behavior as the use // case for this function is different. ConfirmWithTimeout is intended to be @@ -113,6 +113,38 @@ func ConfirmWithTimeout( } } +const ( + // DefaultConfirmBackoffTime is the default value of backoff time used by + // ConfirmWithDefaultTimeout function. + DefaultConfirmBackoffTime = 5 * time.Second + + // DefaultConfirmMaxBackoffTime is the default value of max backoff time + // used by ConfirmWithDefaultTimeout function. + DefaultConfirmMaxBackoffTime = 10 * time.Second +) + +// ConfirmWithTimeoutDefaultBackoff executed the provided confirmFn until it +// returnstrue or until it fails or until timeout is hit. It applies +// backoff wait of DefaultConfirmBackoffTime * 2^n before nth execution of +// confirmFn. In case the calculated backoff is longer than +// DefaultConfirmMaxBackoffTime, DefaultConfirmMaxBackoffTime is applied. +// In case confirmFn returns an error, ConfirmWithTimeoutDefaultBackoff exits +// with the same error immediately. This is different from DoWithDefaultRetry +// behavior as the use case for this function is different. +// ConfirmWithTimeoutDefaultBackoff is intended to be used to confirm a chain +// state and not to try to enforce a successful execution of some function. +func ConfirmWithTimeoutDefaultBackoff( + timeout time.Duration, + confirmFn func(ctx context.Context) (bool, error), +) (bool, error) { + return ConfirmWithTimeout( + DefaultConfirmBackoffTime, + DefaultConfirmMaxBackoffTime, + timeout, + confirmFn, + ) +} + func backoffWait(ctx context.Context, waitTime time.Duration) bool { timer := time.NewTimer(waitTime) defer timer.Stop() From ff611ec3432f3ad152204a0f378e62fa298cff5a Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Tue, 26 Jan 2021 20:36:12 +0100 Subject: [PATCH 04/11] Confirm deposit state before starting monitoring After Ethereum event subscription refactoring, it may happen that the same event is emitted multiple times. A duplicate can be emitted right after the original event or a long time after the original event has been emitted. The original version of tBTC deposit monitoring code - without the modification here - was mostly safe. There is 24 hours monitoring period eliminating duplicate events within this time frame. Just to be absolutely safe, in case 24 hours time period is exceeded for a duplicate, we are adding initial state check. Before monitoring starts on start function signal, we check the initial deposit state whether it's an expected one. If not, we do not start the monitoring. --- pkg/extensions/tbtc/tbtc.go | 75 +++++++++++++++++++++-- pkg/extensions/tbtc/tbtc_test.go | 101 ++++++++++++++++++++++++++++--- 2 files changed, 163 insertions(+), 13 deletions(-) diff --git a/pkg/extensions/tbtc/tbtc.go b/pkg/extensions/tbtc/tbtc.go index f5f68e22a..1b30cd24b 100644 --- a/pkg/extensions/tbtc/tbtc.go +++ b/pkg/extensions/tbtc/tbtc.go @@ -21,6 +21,7 @@ import ( "github.com/keep-network/keep-common/pkg/chain/chainutil" "github.com/keep-network/keep-common/pkg/subscription" chain "github.com/keep-network/keep-ecdsa/pkg/chain" + "github.com/keep-network/keep-ecdsa/pkg/utils" ) var logger = log.Logger("tbtc-extension") @@ -46,6 +47,10 @@ const ( // to avoid all signers executing the same action for deposit at the // same time. defaultSignerActionDelayStep = 5 * time.Minute + + // The timeout for confirming initial state of the deposit upon receiving + // start signal but before setting up monitoring. + confirmInitialStateTimeout = 30 * time.Second ) // TODO: Resume monitoring after client restart @@ -108,6 +113,14 @@ func (t *tbtc) monitorRetrievePubKey( return t.chain.OnDepositCreated(handler) } + shouldMonitorFn := func(depositAddress string) bool { + return t.shouldMonitorDeposit( + confirmInitialStateTimeout, + depositAddress, + initialDepositState, + ) + } + monitoringStopFn := func( handler depositEventHandler, ) subscription.EventSubscription { @@ -156,7 +169,7 @@ func (t *tbtc) monitorRetrievePubKey( monitoringSubscription := t.monitorAndAct( ctx, "retrieve pubkey", - t.shouldMonitorDeposit, + shouldMonitorFn, monitoringStartFn, monitoringStopFn, t.watchKeepClosed, @@ -189,6 +202,14 @@ func (t *tbtc) monitorProvideRedemptionSignature( return t.chain.OnDepositRedemptionRequested(handler) } + shouldMonitorFn := func(depositAddress string) bool { + return t.shouldMonitorDeposit( + confirmInitialStateTimeout, + depositAddress, + initialDepositState, + ) + } + monitoringStopFn := func( handler depositEventHandler, ) subscription.EventSubscription { @@ -324,7 +345,7 @@ func (t *tbtc) monitorProvideRedemptionSignature( monitoringSubscription := t.monitorAndAct( ctx, "provide redemption signature", - t.shouldMonitorDeposit, + shouldMonitorFn, monitoringStartFn, monitoringStopFn, t.watchKeepClosed, @@ -356,6 +377,14 @@ func (t *tbtc) monitorProvideRedemptionProof( return t.chain.OnDepositGotRedemptionSignature(handler) } + shouldMonitorFn := func(depositAddress string) bool { + return t.shouldMonitorDeposit( + confirmInitialStateTimeout, + depositAddress, + initialDepositState, + ) + } + monitoringStopFn := func( handler depositEventHandler, ) subscription.EventSubscription { @@ -523,7 +552,7 @@ func (t *tbtc) monitorProvideRedemptionProof( monitoringSubscription := t.monitorAndAct( ctx, "provide redemption proof", - t.shouldMonitorDeposit, + shouldMonitorFn, monitoringStartFn, monitoringStopFn, t.watchKeepClosed, @@ -760,7 +789,11 @@ func (t *tbtc) watchKeepClosed( return signalChan, unsubscribe, nil } -func (t *tbtc) shouldMonitorDeposit(depositAddress string) bool { +func (t *tbtc) shouldMonitorDeposit( + confirmStateTimeout time.Duration, + depositAddress string, + expectedInitialState chain.DepositState, +) bool { t.monitoredDepositsCache.Sweep() t.notMonitoredDepositsCache.Sweep() @@ -780,7 +813,39 @@ func (t *tbtc) shouldMonitorDeposit(depositAddress string) bool { depositAddress, err, ) - return false // return false but don't cache the result in case of error + // return false but don't cache the result in case of an error; + // it gives a chance to retry the monitoring later but sooner + // than notMonitoredDepositsCache caching period. + return false + } + + hasInitialState, err := utils.ConfirmWithTimeoutDefaultBackoff( + confirmStateTimeout, + func(ctx context.Context) (bool, error) { + currentState, err := t.chain.CurrentState(depositAddress) + if err != nil { + return false, err + } + + return currentState == expectedInitialState, nil + }, + ) + if err != nil { + logger.Errorf( + "could not check if deposit [%v] should be monitored: "+ + "failed to confirm initial state: [%v]", + depositAddress, + err, + ) + // return false but don't cache the result in case of an error; + // it gives a chance to retry the monitoring later but sooner + // than notMonitoredDepositsCache caching period. + return false + } + if !hasInitialState { + // false start signal, probably an old event + t.notMonitoredDepositsCache.Add(depositAddress) + return false } if signerIndex < 0 { diff --git a/pkg/extensions/tbtc/tbtc_test.go b/pkg/extensions/tbtc/tbtc_test.go index 270039c38..5c89db839 100644 --- a/pkg/extensions/tbtc/tbtc_test.go +++ b/pkg/extensions/tbtc/tbtc_test.go @@ -2005,6 +2005,67 @@ func TestReleaseMonitoringLock_WhenEmpty(t *testing.T) { } } +func TestShouldMonitorDeposit_ExpectedInitialState(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + + tbtcChain := local.NewTBTCLocalChain(ctx) + tbtc := newTestTBTC(tbtcChain) + + // create a signing group which contains the operator + signers := append( + []common.Address{tbtcChain.Address()}, + local.RandomSigningGroup(2)..., + ) + + tbtcChain.CreateDeposit(depositAddress, signers) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) + if err != nil { + t.Fatal(err) + } + tbtcChain.RetrieveSignerPubkey(depositAddress) + + shouldMonitor := tbtc.shouldMonitorDeposit( + 5*time.Second, + depositAddress, + chain.AwaitingBtcFundingProof, + ) + if !shouldMonitor { + t.Errorf("should monitor the deposit") + } +} + +func TestShouldMonitorDeposit_UnexpectedInitialState(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + + tbtcChain := local.NewTBTCLocalChain(ctx) + tbtc := newTestTBTC(tbtcChain) + + // create a signing group which contains the operator + signers := append( + []common.Address{tbtcChain.Address()}, + local.RandomSigningGroup(2)..., + ) + + tbtcChain.CreateDeposit(depositAddress, signers) + + _, err := submitKeepPublicKey(depositAddress, tbtcChain) + if err != nil { + t.Fatal(err) + } + tbtcChain.RetrieveSignerPubkey(depositAddress) + + shouldMonitor := tbtc.shouldMonitorDeposit( + 5*time.Second, + depositAddress, + chain.AwaitingSignerSetup, + ) + if shouldMonitor { + t.Errorf("should not monitor the deposit") + } +} + func TestShouldMonitorDeposit_PositiveResultCache(t *testing.T) { ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() @@ -2021,9 +2082,22 @@ func TestShouldMonitorDeposit_PositiveResultCache(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) // all calls should be `true` - call1 := tbtc.shouldMonitorDeposit(depositAddress) - call2 := tbtc.shouldMonitorDeposit(depositAddress) - call3 := tbtc.shouldMonitorDeposit(depositAddress) + const stateConfirmTimeout = 1 * time.Second + call1 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) + call2 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) + call3 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) if !(call1 && call2 && call3) { t.Errorf("should monitor deposit calls results are not same") @@ -2040,7 +2114,6 @@ func TestShouldMonitorDeposit_PositiveResultCache(t *testing.T) { actualChainCalls, ) } - } func TestShouldMonitorDeposit_NegativeResultCache(t *testing.T) { @@ -2056,9 +2129,22 @@ func TestShouldMonitorDeposit_NegativeResultCache(t *testing.T) { tbtcChain.CreateDeposit(depositAddress, signers) // all calls should be `false` - call1 := tbtc.shouldMonitorDeposit(depositAddress) - call2 := tbtc.shouldMonitorDeposit(depositAddress) - call3 := tbtc.shouldMonitorDeposit(depositAddress) + const stateConfirmTimeout = 1 * time.Second + call1 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) + call2 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) + call3 := tbtc.shouldMonitorDeposit( + stateConfirmTimeout, + depositAddress, + chain.AwaitingSignerSetup, + ) if call1 || call2 || call3 { t.Errorf("should monitor deposit calls results are not same") @@ -2075,7 +2161,6 @@ func TestShouldMonitorDeposit_NegativeResultCache(t *testing.T) { actualChainCalls, ) } - } func TestGetSignerActionDelay(t *testing.T) { From 9ec4096988532070401f5edb7f459d9ea57e40c5 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Fri, 29 Jan 2021 16:59:13 +0100 Subject: [PATCH 05/11] Updated keep-common version to the most recent one --- go.mod | 2 +- go.sum | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1b31d56c2..fe1e9629f 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/gogo/protobuf v1.3.1 github.com/google/gofuzz v1.1.0 github.com/ipfs/go-log v1.0.4 - github.com/keep-network/keep-common v1.3.1-0.20210128105431-b3b56f6f88c8 + github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019 github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 5675ed6a7..f94e29383 100644 --- a/go.sum +++ b/go.sum @@ -332,8 +332,9 @@ github.com/keep-network/cli v1.20.0/go.mod h1:nzsst4JjU+rGE8Q5J839fYxectxWHpLhxK 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.3.0/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= -github.com/keep-network/keep-common v1.3.1-0.20210128105431-b3b56f6f88c8 h1:yo2Gj5Wwc+oU+IeGlF0shiVMth4C3gfQzQXUowLj5MQ= -github.com/keep-network/keep-common v1.3.1-0.20210128105431-b3b56f6f88c8/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= +github.com/keep-network/keep-common v1.3.1-0.20210122143623-90288e13a93d/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= +github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019 h1:WBq6cP/N3PFPo25k6AVuM1Hh46GL8DRPr2YzV97quuc= +github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb h1:pDhLagUiOYWOn72UiG3jSDVDXZ4dYlsfRa0ToF/ru18= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb/go.mod h1:4KezOJWc//c5lbtAE1ob7qYE/Gs5+a1QTjGBzzv2tu8= github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 h1:uw6ZmFbtoqfmx0bfE4bWZtiSyG1uD6o/h0DF0wy/Mhw= From fee380185b6b3d61fa98dabf4295dba35f3c7967 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 1 Feb 2021 11:05:53 +0100 Subject: [PATCH 06/11] Updated tbtc dependency to the most recent version The most recent version contains updates to Go contract bindings applied during the review process. --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fe1e9629f..224ada8cb 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/ipfs/go-log v1.0.4 github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019 github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb - github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 + github.com/keep-network/tbtc v1.1.1-0.20210128164215-c03b8cf351f0 github.com/pkg/errors v0.9.1 github.com/urfave/cli v1.22.1 ) diff --git a/go.sum b/go.sum index f94e29383..f69c7d4af 100644 --- a/go.sum +++ b/go.sum @@ -332,13 +332,12 @@ github.com/keep-network/cli v1.20.0/go.mod h1:nzsst4JjU+rGE8Q5J839fYxectxWHpLhxK 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.3.0/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= -github.com/keep-network/keep-common v1.3.1-0.20210122143623-90288e13a93d/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019 h1:WBq6cP/N3PFPo25k6AVuM1Hh46GL8DRPr2YzV97quuc= github.com/keep-network/keep-common v1.3.1-0.20210128152700-34905d2fe019/go.mod h1:emxogTbBdey7M3jOzfxZOdfn139kN2mI2b2wA6AHKKo= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb h1:pDhLagUiOYWOn72UiG3jSDVDXZ4dYlsfRa0ToF/ru18= github.com/keep-network/keep-core v1.3.2-0.20201229154408-59ac640ed0cb/go.mod h1:4KezOJWc//c5lbtAE1ob7qYE/Gs5+a1QTjGBzzv2tu8= -github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12 h1:uw6ZmFbtoqfmx0bfE4bWZtiSyG1uD6o/h0DF0wy/Mhw= -github.com/keep-network/tbtc v1.1.1-0.20210125121025-bc83d3a40e12/go.mod h1:nLHbMHv4PiuJutvGYUPxl7Q2O8xrsIGtVibAqWD04Is= +github.com/keep-network/tbtc v1.1.1-0.20210128164215-c03b8cf351f0 h1:zXW/085lHEs1NppQKZ+oOSnOWGxT4JlYelnChNML4WU= +github.com/keep-network/tbtc v1.1.1-0.20210128164215-c03b8cf351f0/go.mod h1:lIFIL8HRHTibQVzE0GoWdGZVfoc19KuJUbhk4W4XNT0= 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= From 9b29ac7db2583cbf37e767251761cff84fb70c27 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 1 Feb 2021 11:06:56 +0100 Subject: [PATCH 07/11] Regenerated method and contract bindings --- pkg/chain/gen/cmd/BondedECDSAKeep.go | 310 ++-- pkg/chain/gen/cmd/BondedECDSAKeepFactory.go | 626 +++---- pkg/chain/gen/cmd/BondedECDSAKeepVendor.go | 106 +- pkg/chain/gen/contract/BondedECDSAKeep.go | 1484 ++++++++--------- .../gen/contract/BondedECDSAKeepFactory.go | 946 +++++------ .../gen/contract/BondedECDSAKeepVendor.go | 304 ++-- 6 files changed, 1888 insertions(+), 1888 deletions(-) diff --git a/pkg/chain/gen/cmd/BondedECDSAKeep.go b/pkg/chain/gen/cmd/BondedECDSAKeep.go index 2390e144a..13c831945 100644 --- a/pkg/chain/gen/cmd/BondedECDSAKeep.go +++ b/pkg/chain/gen/cmd/BondedECDSAKeep.go @@ -52,6 +52,13 @@ func init() { Usage: `Provides access to the BondedECDSAKeep contract.`, Description: bondedECDSAKeepDescription, Subcommands: []cli.Command{{ + Name: "owner", + Usage: "Calls the constant method owner on the BondedECDSAKeep contract.", + ArgsUsage: "", + Action: becdsakOwner, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, + }, { Name: "digest", Usage: "Calls the constant method digest on the BondedECDSAKeep contract.", ArgsUsage: "", @@ -59,24 +66,24 @@ func init() { Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "honest-threshold", - Usage: "Calls the constant method honestThreshold on the BondedECDSAKeep contract.", + Name: "get-opened-timestamp", + Usage: "Calls the constant method getOpenedTimestamp on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakHonestThreshold, + Action: becdsakGetOpenedTimestamp, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "get-owner", - Usage: "Calls the constant method getOwner on the BondedECDSAKeep contract.", + Name: "is-closed", + Usage: "Calls the constant method isClosed on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakGetOwner, + Action: becdsakIsClosed, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "members", - Usage: "Calls the constant method members on the BondedECDSAKeep contract.", - ArgsUsage: "[arg0] ", - Action: becdsakMembers, + Name: "get-member-e-t-h-balance", + Usage: "Calls the constant method getMemberETHBalance on the BondedECDSAKeep contract.", + ArgsUsage: "[_member] ", + Action: becdsakGetMemberETHBalance, Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { @@ -87,39 +94,39 @@ func init() { Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "public-key", - Usage: "Calls the constant method publicKey on the BondedECDSAKeep contract.", + Name: "is-terminated", + Usage: "Calls the constant method isTerminated on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakPublicKey, + Action: becdsakIsTerminated, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "get-opened-timestamp", - Usage: "Calls the constant method getOpenedTimestamp on the BondedECDSAKeep contract.", + Name: "member-stake", + Usage: "Calls the constant method memberStake on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakGetOpenedTimestamp, + Action: becdsakMemberStake, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "is-terminated", - Usage: "Calls the constant method isTerminated on the BondedECDSAKeep contract.", + Name: "get-owner", + Usage: "Calls the constant method getOwner on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakIsTerminated, + Action: becdsakGetOwner, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "owner", - Usage: "Calls the constant method owner on the BondedECDSAKeep contract.", + Name: "honest-threshold", + Usage: "Calls the constant method honestThreshold on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakOwner, + Action: becdsakHonestThreshold, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "get-member-e-t-h-balance", - Usage: "Calls the constant method getMemberETHBalance on the BondedECDSAKeep contract.", - ArgsUsage: "[_member] ", - Action: becdsakGetMemberETHBalance, - Before: cmd.ArgCountChecker(1), + Name: "get-members", + Usage: "Calls the constant method getMembers on the BondedECDSAKeep contract.", + ArgsUsage: "", + Action: becdsakGetMembers, + Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { Name: "get-public-key", @@ -129,10 +136,17 @@ func init() { Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "is-closed", - Usage: "Calls the constant method isClosed on the BondedECDSAKeep contract.", + Name: "members", + Usage: "Calls the constant method members on the BondedECDSAKeep contract.", + ArgsUsage: "[arg0] ", + Action: becdsakMembers, + Before: cmd.ArgCountChecker(1), + Flags: cmd.ConstFlags, + }, { + Name: "public-key", + Usage: "Calls the constant method publicKey on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakIsClosed, + Action: becdsakPublicKey, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { @@ -142,20 +156,6 @@ func init() { Action: becdsakCheckBondAmount, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, - }, { - Name: "get-members", - Usage: "Calls the constant method getMembers on the BondedECDSAKeep contract.", - ArgsUsage: "", - Action: becdsakGetMembers, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, - }, { - Name: "member-stake", - Usage: "Calls the constant method memberStake on the BondedECDSAKeep contract.", - ArgsUsage: "", - Action: becdsakMemberStake, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, }, { Name: "distribute-e-t-h-reward", Usage: "Calls the payable method distributeETHReward on the BondedECDSAKeep contract.", @@ -163,6 +163,13 @@ func init() { Action: becdsakDistributeETHReward, Before: cli.BeforeFunc(cmd.PayableArgsChecker.AndThen(cmd.ArgCountChecker(0))), Flags: cmd.PayableFlags, + }, { + Name: "seize-signer-bonds", + Usage: "Calls the method seizeSignerBonds on the BondedECDSAKeep contract.", + ArgsUsage: "", + Action: becdsakSeizeSignerBonds, + Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(0))), + Flags: cmd.NonConstFlags, }, { Name: "withdraw", Usage: "Calls the method withdraw on the BondedECDSAKeep contract.", @@ -171,11 +178,11 @@ func init() { Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, }, { - Name: "close-keep", - Usage: "Calls the method closeKeep on the BondedECDSAKeep contract.", - ArgsUsage: "", - Action: becdsakCloseKeep, - Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(0))), + Name: "submit-public-key", + Usage: "Calls the method submitPublicKey on the BondedECDSAKeep contract.", + ArgsUsage: "[_publicKey] ", + Action: becdsakSubmitPublicKey, + Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, }, { Name: "distribute-e-r-c20-reward", @@ -192,32 +199,25 @@ func init() { Before: cli.BeforeFunc(cmd.PayableArgsChecker.AndThen(cmd.ArgCountChecker(0))), Flags: cmd.PayableFlags, }, { - Name: "seize-signer-bonds", - Usage: "Calls the method seizeSignerBonds on the BondedECDSAKeep contract.", + Name: "close-keep", + Usage: "Calls the method closeKeep on the BondedECDSAKeep contract.", ArgsUsage: "", - Action: becdsakSeizeSignerBonds, + Action: becdsakCloseKeep, Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(0))), Flags: cmd.NonConstFlags, - }, { - Name: "submit-public-key", - Usage: "Calls the method submitPublicKey on the BondedECDSAKeep contract.", - ArgsUsage: "[_publicKey] ", - Action: becdsakSubmitPublicKey, - Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), - Flags: cmd.NonConstFlags, }}, }) } /// ------------------- Const methods ------------------- -func becdsakDigest(c *cli.Context) error { +func becdsakOwner(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.DigestAtBlock( + result, err := contract.OwnerAtBlock( cmd.BlockFlagValue.Uint, ) @@ -231,13 +231,13 @@ func becdsakDigest(c *cli.Context) error { return nil } -func becdsakHonestThreshold(c *cli.Context) error { +func becdsakDigest(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.HonestThresholdAtBlock( + result, err := contract.DigestAtBlock( cmd.BlockFlagValue.Uint, ) @@ -251,13 +251,13 @@ func becdsakHonestThreshold(c *cli.Context) error { return nil } -func becdsakGetOwner(c *cli.Context) error { +func becdsakGetOpenedTimestamp(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.GetOwnerAtBlock( + result, err := contract.GetOpenedTimestampAtBlock( cmd.BlockFlagValue.Uint, ) @@ -271,21 +271,13 @@ func becdsakGetOwner(c *cli.Context) error { return nil } -func becdsakMembers(c *cli.Context) error { +func becdsakIsClosed(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - arg0, err := hexutil.DecodeBig(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg0, a uint256, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.MembersAtBlock( - arg0, + result, err := contract.IsClosedAtBlock( cmd.BlockFlagValue.Uint, ) @@ -299,13 +291,21 @@ func becdsakMembers(c *cli.Context) error { return nil } -func becdsakIsActive(c *cli.Context) error { +func becdsakGetMemberETHBalance(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } + _member, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _member, a address, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.IsActiveAtBlock( + result, err := contract.GetMemberETHBalanceAtBlock( + _member, cmd.BlockFlagValue.Uint, ) @@ -319,13 +319,13 @@ func becdsakIsActive(c *cli.Context) error { return nil } -func becdsakPublicKey(c *cli.Context) error { +func becdsakIsActive(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.PublicKeyAtBlock( + result, err := contract.IsActiveAtBlock( cmd.BlockFlagValue.Uint, ) @@ -339,13 +339,13 @@ func becdsakPublicKey(c *cli.Context) error { return nil } -func becdsakGetOpenedTimestamp(c *cli.Context) error { +func becdsakIsTerminated(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.GetOpenedTimestampAtBlock( + result, err := contract.IsTerminatedAtBlock( cmd.BlockFlagValue.Uint, ) @@ -359,13 +359,13 @@ func becdsakGetOpenedTimestamp(c *cli.Context) error { return nil } -func becdsakIsTerminated(c *cli.Context) error { +func becdsakMemberStake(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.IsTerminatedAtBlock( + result, err := contract.MemberStakeAtBlock( cmd.BlockFlagValue.Uint, ) @@ -379,13 +379,13 @@ func becdsakIsTerminated(c *cli.Context) error { return nil } -func becdsakOwner(c *cli.Context) error { +func becdsakGetOwner(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.OwnerAtBlock( + result, err := contract.GetOwnerAtBlock( cmd.BlockFlagValue.Uint, ) @@ -399,21 +399,13 @@ func becdsakOwner(c *cli.Context) error { return nil } -func becdsakGetMemberETHBalance(c *cli.Context) error { +func becdsakHonestThreshold(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - _member, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _member, a address, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.GetMemberETHBalanceAtBlock( - _member, + result, err := contract.HonestThresholdAtBlock( cmd.BlockFlagValue.Uint, ) @@ -427,13 +419,13 @@ func becdsakGetMemberETHBalance(c *cli.Context) error { return nil } -func becdsakGetPublicKey(c *cli.Context) error { +func becdsakGetMembers(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.GetPublicKeyAtBlock( + result, err := contract.GetMembersAtBlock( cmd.BlockFlagValue.Uint, ) @@ -447,13 +439,13 @@ func becdsakGetPublicKey(c *cli.Context) error { return nil } -func becdsakIsClosed(c *cli.Context) error { +func becdsakGetPublicKey(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.IsClosedAtBlock( + result, err := contract.GetPublicKeyAtBlock( cmd.BlockFlagValue.Uint, ) @@ -467,13 +459,21 @@ func becdsakIsClosed(c *cli.Context) error { return nil } -func becdsakCheckBondAmount(c *cli.Context) error { +func becdsakMembers(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } + arg0, err := hexutil.DecodeBig(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg0, a uint256, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.CheckBondAmountAtBlock( + result, err := contract.MembersAtBlock( + arg0, cmd.BlockFlagValue.Uint, ) @@ -487,13 +487,13 @@ func becdsakCheckBondAmount(c *cli.Context) error { return nil } -func becdsakGetMembers(c *cli.Context) error { +func becdsakPublicKey(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.GetMembersAtBlock( + result, err := contract.PublicKeyAtBlock( cmd.BlockFlagValue.Uint, ) @@ -507,13 +507,13 @@ func becdsakGetMembers(c *cli.Context) error { return nil } -func becdsakMemberStake(c *cli.Context) error { +func becdsakCheckBondAmount(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - result, err := contract.MemberStakeAtBlock( + result, err := contract.CheckBondAmountAtBlock( cmd.BlockFlagValue.Uint, ) @@ -563,6 +563,39 @@ func becdsakDistributeETHReward(c *cli.Context) error { return nil } +func becdsakSeizeSignerBonds(c *cli.Context) error { + contract, err := initializeBondedECDSAKeep(c) + if err != nil { + return err + } + + var ( + transaction *types.Transaction + ) + + if c.Bool(cmd.SubmitFlag) { + // Do a regular submission. Take payable into account. + transaction, err = contract.SeizeSignerBonds() + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash) + } else { + // Do a call. + err = contract.CallSeizeSignerBonds( + cmd.BlockFlagValue.Uint, + ) + if err != nil { + return err + } + + cmd.PrintOutput(nil) + } + + return nil +} + func becdsakWithdraw(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { @@ -607,19 +640,29 @@ func becdsakWithdraw(c *cli.Context) error { return nil } -func becdsakCloseKeep(c *cli.Context) error { +func becdsakSubmitPublicKey(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } + _publicKey, err := hexutil.Decode(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _publicKey, a bytes, from passed value %v", + c.Args()[0], + ) + } + var ( transaction *types.Transaction ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.CloseKeep() + transaction, err = contract.SubmitPublicKey( + _publicKey, + ) if err != nil { return err } @@ -627,7 +670,8 @@ func becdsakCloseKeep(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallCloseKeep( + err = contract.CallSubmitPublicKey( + _publicKey, cmd.BlockFlagValue.Uint, ) if err != nil { @@ -728,62 +772,19 @@ func becdsakReturnPartialSignerBonds(c *cli.Context) error { return nil } -func becdsakSeizeSignerBonds(c *cli.Context) error { - contract, err := initializeBondedECDSAKeep(c) - if err != nil { - return err - } - - var ( - transaction *types.Transaction - ) - - if c.Bool(cmd.SubmitFlag) { - // Do a regular submission. Take payable into account. - transaction, err = contract.SeizeSignerBonds() - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash) - } else { - // Do a call. - err = contract.CallSeizeSignerBonds( - cmd.BlockFlagValue.Uint, - ) - if err != nil { - return err - } - - cmd.PrintOutput(nil) - } - - return nil -} - -func becdsakSubmitPublicKey(c *cli.Context) error { +func becdsakCloseKeep(c *cli.Context) error { contract, err := initializeBondedECDSAKeep(c) if err != nil { return err } - _publicKey, err := hexutil.Decode(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _publicKey, a bytes, from passed value %v", - c.Args()[0], - ) - } - var ( transaction *types.Transaction ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitPublicKey( - _publicKey, - ) + transaction, err = contract.CloseKeep() if err != nil { return err } @@ -791,8 +792,7 @@ func becdsakSubmitPublicKey(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallSubmitPublicKey( - _publicKey, + err = contract.CallCloseKeep( cmd.BlockFlagValue.Uint, ) if err != nil { diff --git a/pkg/chain/gen/cmd/BondedECDSAKeepFactory.go b/pkg/chain/gen/cmd/BondedECDSAKeepFactory.go index 1e54cb7da..1ded9055d 100644 --- a/pkg/chain/gen/cmd/BondedECDSAKeepFactory.go +++ b/pkg/chain/gen/cmd/BondedECDSAKeepFactory.go @@ -52,31 +52,17 @@ func init() { Usage: `Provides access to the BondedECDSAKeepFactory contract.`, Description: bondedECDSAKeepFactoryDescription, Subcommands: []cli.Command{{ - Name: "get-keep-count", - Usage: "Calls the constant method getKeepCount on the BondedECDSAKeepFactory contract.", - ArgsUsage: "", - Action: becdsakfGetKeepCount, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, - }, { - Name: "get-sortition-pool-weight", - Usage: "Calls the constant method getSortitionPoolWeight on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_application] ", - Action: becdsakfGetSortitionPoolWeight, - Before: cmd.ArgCountChecker(1), - Flags: cmd.ConstFlags, - }, { - Name: "minimum-bond", - Usage: "Calls the constant method minimumBond on the BondedECDSAKeepFactory contract.", + Name: "master-keep-address", + Usage: "Calls the constant method masterKeepAddress on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfMinimumBond, + Action: becdsakfMasterKeepAddress, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "new-entry-fee-estimate", - Usage: "Calls the constant method newEntryFeeEstimate on the BondedECDSAKeepFactory contract.", + Name: "open-keep-fee-estimate", + Usage: "Calls the constant method openKeepFeeEstimate on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfNewEntryFeeEstimate, + Action: becdsakfOpenKeepFeeEstimate, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { @@ -94,33 +80,33 @@ func init() { Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "get-keep-opened-timestamp", - Usage: "Calls the constant method getKeepOpenedTimestamp on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_keep] ", - Action: becdsakfGetKeepOpenedTimestamp, - Before: cmd.ArgCountChecker(1), - Flags: cmd.ConstFlags, - }, { - Name: "new-group-selection-seed-fee", - Usage: "Calls the constant method newGroupSelectionSeedFee on the BondedECDSAKeepFactory contract.", + Name: "group-selection-seed", + Usage: "Calls the constant method groupSelectionSeed on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfNewGroupSelectionSeedFee, + Action: becdsakfGroupSelectionSeed, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "open-keep-fee-estimate", - Usage: "Calls the constant method openKeepFeeEstimate on the BondedECDSAKeepFactory contract.", - ArgsUsage: "", - Action: becdsakfOpenKeepFeeEstimate, - Before: cmd.ArgCountChecker(0), + Name: "has-minimum-stake", + Usage: "Calls the constant method hasMinimumStake on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_operator] ", + Action: becdsakfHasMinimumStake, + Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "callback-gas", - Usage: "Calls the constant method callbackGas on the BondedECDSAKeepFactory contract.", + Name: "reseed-pool", + Usage: "Calls the constant method reseedPool on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfCallbackGas, + Action: becdsakfReseedPool, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, + }, { + Name: "balance-of", + Usage: "Calls the constant method balanceOf on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_operator] ", + Action: becdsakfBalanceOf, + Before: cmd.ArgCountChecker(1), + Flags: cmd.ConstFlags, }, { Name: "is-operator-authorized", Usage: "Calls the constant method isOperatorAuthorized on the BondedECDSAKeepFactory contract.", @@ -129,10 +115,38 @@ func init() { Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "get-sortition-pool", - Usage: "Calls the constant method getSortitionPool on the BondedECDSAKeepFactory contract.", + Name: "is-operator-registered", + Usage: "Calls the constant method isOperatorRegistered on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_operator] [_application] ", + Action: becdsakfIsOperatorRegistered, + Before: cmd.ArgCountChecker(2), + Flags: cmd.ConstFlags, + }, { + Name: "minimum-bond", + Usage: "Calls the constant method minimumBond on the BondedECDSAKeepFactory contract.", + ArgsUsage: "", + Action: becdsakfMinimumBond, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, + }, { + Name: "new-entry-fee-estimate", + Usage: "Calls the constant method newEntryFeeEstimate on the BondedECDSAKeepFactory contract.", + ArgsUsage: "", + Action: becdsakfNewEntryFeeEstimate, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, + }, { + Name: "new-group-selection-seed-fee", + Usage: "Calls the constant method newGroupSelectionSeedFee on the BondedECDSAKeepFactory contract.", + ArgsUsage: "", + Action: becdsakfNewGroupSelectionSeedFee, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, + }, { + Name: "get-sortition-pool-weight", + Usage: "Calls the constant method getSortitionPoolWeight on the BondedECDSAKeepFactory contract.", ArgsUsage: "[_application] ", - Action: becdsakfGetSortitionPool, + Action: becdsakfGetSortitionPoolWeight, Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { @@ -149,20 +163,6 @@ func init() { Action: becdsakfIsOperatorUpToDate, Before: cmd.ArgCountChecker(2), Flags: cmd.ConstFlags, - }, { - Name: "group-selection-seed", - Usage: "Calls the constant method groupSelectionSeed on the BondedECDSAKeepFactory contract.", - ArgsUsage: "", - Action: becdsakfGroupSelectionSeed, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, - }, { - Name: "is-operator-registered", - Usage: "Calls the constant method isOperatorRegistered on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_operator] [_application] ", - Action: becdsakfIsOperatorRegistered, - Before: cmd.ArgCountChecker(2), - Flags: cmd.ConstFlags, }, { Name: "keeps", Usage: "Calls the constant method keeps on the BondedECDSAKeepFactory contract.", @@ -171,40 +171,33 @@ func init() { Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "master-keep-address", - Usage: "Calls the constant method masterKeepAddress on the BondedECDSAKeepFactory contract.", - ArgsUsage: "", - Action: becdsakfMasterKeepAddress, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, - }, { - Name: "has-minimum-stake", - Usage: "Calls the constant method hasMinimumStake on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_operator] ", - Action: becdsakfHasMinimumStake, + Name: "get-keep-opened-timestamp", + Usage: "Calls the constant method getKeepOpenedTimestamp on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_keep] ", + Action: becdsakfGetKeepOpenedTimestamp, Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "reseed-pool", - Usage: "Calls the constant method reseedPool on the BondedECDSAKeepFactory contract.", + Name: "callback-gas", + Usage: "Calls the constant method callbackGas on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfReseedPool, + Action: becdsakfCallbackGas, Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "balance-of", - Usage: "Calls the constant method balanceOf on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_operator] ", - Action: becdsakfBalanceOf, + Name: "get-sortition-pool", + Usage: "Calls the constant method getSortitionPool on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_application] ", + Action: becdsakfGetSortitionPool, Before: cmd.ArgCountChecker(1), Flags: cmd.ConstFlags, }, { - Name: "request-new-group-selection-seed", - Usage: "Calls the payable method requestNewGroupSelectionSeed on the BondedECDSAKeepFactory contract.", + Name: "get-keep-count", + Usage: "Calls the constant method getKeepCount on the BondedECDSAKeepFactory contract.", ArgsUsage: "", - Action: becdsakfRequestNewGroupSelectionSeed, - Before: cli.BeforeFunc(cmd.PayableArgsChecker.AndThen(cmd.ArgCountChecker(0))), - Flags: cmd.PayableFlags, + Action: becdsakfGetKeepCount, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, }, { Name: "open-keep", Usage: "Calls the payable method openKeep on the BondedECDSAKeepFactory contract.", @@ -213,19 +206,12 @@ func init() { Before: cli.BeforeFunc(cmd.PayableArgsChecker.AndThen(cmd.ArgCountChecker(5))), Flags: cmd.PayableFlags, }, { - Name: "register-member-candidate", - Usage: "Calls the method registerMemberCandidate on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_application] ", - Action: becdsakfRegisterMemberCandidate, + Name: "beacon-callback", + Usage: "Calls the method beaconCallback on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_relayEntry] ", + Action: becdsakfBeaconCallback, Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, - }, { - Name: "set-minimum-bondable-value", - Usage: "Calls the method setMinimumBondableValue on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_minimumBondableValue] [_groupSize] [_honestThreshold] ", - Action: becdsakfSetMinimumBondableValue, - Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(3))), - Flags: cmd.NonConstFlags, }, { Name: "is-recognized", Usage: "Calls the method isRecognized on the BondedECDSAKeepFactory contract.", @@ -234,10 +220,17 @@ func init() { Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, }, { - Name: "beacon-callback", - Usage: "Calls the method beaconCallback on the BondedECDSAKeepFactory contract.", - ArgsUsage: "[_relayEntry] ", - Action: becdsakfBeaconCallback, + Name: "request-new-group-selection-seed", + Usage: "Calls the payable method requestNewGroupSelectionSeed on the BondedECDSAKeepFactory contract.", + ArgsUsage: "", + Action: becdsakfRequestNewGroupSelectionSeed, + Before: cli.BeforeFunc(cmd.PayableArgsChecker.AndThen(cmd.ArgCountChecker(0))), + Flags: cmd.PayableFlags, + }, { + Name: "create-sortition-pool", + Usage: "Calls the method createSortitionPool on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_application] ", + Action: becdsakfCreateSortitionPool, Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, }, { @@ -248,25 +241,32 @@ func init() { Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(2))), Flags: cmd.NonConstFlags, }, { - Name: "create-sortition-pool", - Usage: "Calls the method createSortitionPool on the BondedECDSAKeepFactory contract.", + Name: "register-member-candidate", + Usage: "Calls the method registerMemberCandidate on the BondedECDSAKeepFactory contract.", ArgsUsage: "[_application] ", - Action: becdsakfCreateSortitionPool, + Action: becdsakfRegisterMemberCandidate, Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(1))), Flags: cmd.NonConstFlags, + }, { + Name: "set-minimum-bondable-value", + Usage: "Calls the method setMinimumBondableValue on the BondedECDSAKeepFactory contract.", + ArgsUsage: "[_minimumBondableValue] [_groupSize] [_honestThreshold] ", + Action: becdsakfSetMinimumBondableValue, + Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(3))), + Flags: cmd.NonConstFlags, }}, }) } /// ------------------- Const methods ------------------- -func becdsakfGetKeepCount(c *cli.Context) error { +func becdsakfMasterKeepAddress(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - result, err := contract.GetKeepCountAtBlock( + result, err := contract.MasterKeepAddressAtBlock( cmd.BlockFlagValue.Uint, ) @@ -280,21 +280,13 @@ func becdsakfGetKeepCount(c *cli.Context) error { return nil } -func becdsakfGetSortitionPoolWeight(c *cli.Context) error { +func becdsakfOpenKeepFeeEstimate(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _application, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _application, a address, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.GetSortitionPoolWeightAtBlock( - _application, + result, err := contract.OpenKeepFeeEstimateAtBlock( cmd.BlockFlagValue.Uint, ) @@ -308,13 +300,13 @@ func becdsakfGetSortitionPoolWeight(c *cli.Context) error { return nil } -func becdsakfMinimumBond(c *cli.Context) error { +func becdsakfPoolStakeWeightDivisor(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - result, err := contract.MinimumBondAtBlock( + result, err := contract.PoolStakeWeightDivisorAtBlock( cmd.BlockFlagValue.Uint, ) @@ -328,13 +320,21 @@ func becdsakfMinimumBond(c *cli.Context) error { return nil } -func becdsakfNewEntryFeeEstimate(c *cli.Context) error { +func becdsakfGetKeepAtIndex(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } + index, err := hexutil.DecodeBig(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter index, a uint256, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.NewEntryFeeEstimateAtBlock( + result, err := contract.GetKeepAtIndexAtBlock( + index, cmd.BlockFlagValue.Uint, ) @@ -348,13 +348,13 @@ func becdsakfNewEntryFeeEstimate(c *cli.Context) error { return nil } -func becdsakfPoolStakeWeightDivisor(c *cli.Context) error { +func becdsakfGroupSelectionSeed(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - result, err := contract.PoolStakeWeightDivisorAtBlock( + result, err := contract.GroupSelectionSeedAtBlock( cmd.BlockFlagValue.Uint, ) @@ -368,21 +368,21 @@ func becdsakfPoolStakeWeightDivisor(c *cli.Context) error { return nil } -func becdsakfGetKeepAtIndex(c *cli.Context) error { +func becdsakfHasMinimumStake(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - index, err := hexutil.DecodeBig(c.Args()[0]) + _operator, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter index, a uint256, from passed value %v", + "couldn't parse parameter _operator, a address, from passed value %v", c.Args()[0], ) } - result, err := contract.GetKeepAtIndexAtBlock( - index, + result, err := contract.HasMinimumStakeAtBlock( + _operator, cmd.BlockFlagValue.Uint, ) @@ -396,21 +396,13 @@ func becdsakfGetKeepAtIndex(c *cli.Context) error { return nil } -func becdsakfGetKeepOpenedTimestamp(c *cli.Context) error { +func becdsakfReseedPool(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _keep, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _keep, a address, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.GetKeepOpenedTimestampAtBlock( - _keep, + result, err := contract.ReseedPoolAtBlock( cmd.BlockFlagValue.Uint, ) @@ -424,13 +416,21 @@ func becdsakfGetKeepOpenedTimestamp(c *cli.Context) error { return nil } -func becdsakfNewGroupSelectionSeedFee(c *cli.Context) error { +func becdsakfBalanceOf(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } + _operator, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _operator, a address, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.NewGroupSelectionSeedFeeAtBlock( + result, err := contract.BalanceOfAtBlock( + _operator, cmd.BlockFlagValue.Uint, ) @@ -444,13 +444,21 @@ func becdsakfNewGroupSelectionSeedFee(c *cli.Context) error { return nil } -func becdsakfOpenKeepFeeEstimate(c *cli.Context) error { +func becdsakfIsOperatorAuthorized(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } + _operator, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _operator, a address, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.OpenKeepFeeEstimateAtBlock( + result, err := contract.IsOperatorAuthorizedAtBlock( + _operator, cmd.BlockFlagValue.Uint, ) @@ -464,13 +472,30 @@ func becdsakfOpenKeepFeeEstimate(c *cli.Context) error { return nil } -func becdsakfCallbackGas(c *cli.Context) error { +func becdsakfIsOperatorRegistered(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } + _operator, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _operator, a address, from passed value %v", + c.Args()[0], + ) + } - result, err := contract.CallbackGasAtBlock( + _application, err := ethutil.AddressFromHex(c.Args()[1]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _application, a address, from passed value %v", + c.Args()[1], + ) + } + + result, err := contract.IsOperatorRegisteredAtBlock( + _operator, + _application, cmd.BlockFlagValue.Uint, ) @@ -484,21 +509,13 @@ func becdsakfCallbackGas(c *cli.Context) error { return nil } -func becdsakfIsOperatorAuthorized(c *cli.Context) error { +func becdsakfMinimumBond(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _operator, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _operator, a address, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.IsOperatorAuthorizedAtBlock( - _operator, + result, err := contract.MinimumBondAtBlock( cmd.BlockFlagValue.Uint, ) @@ -512,21 +529,13 @@ func becdsakfIsOperatorAuthorized(c *cli.Context) error { return nil } -func becdsakfGetSortitionPool(c *cli.Context) error { +func becdsakfNewEntryFeeEstimate(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _application, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _application, a address, from passed value %v", - c.Args()[0], - ) - } - result, err := contract.GetSortitionPoolAtBlock( - _application, + result, err := contract.NewEntryFeeEstimateAtBlock( cmd.BlockFlagValue.Uint, ) @@ -540,30 +549,13 @@ func becdsakfGetSortitionPool(c *cli.Context) error { return nil } -func becdsakfIsOperatorEligible(c *cli.Context) error { +func becdsakfNewGroupSelectionSeedFee(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _operator, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _operator, a address, from passed value %v", - c.Args()[0], - ) - } - - _application, err := ethutil.AddressFromHex(c.Args()[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _application, a address, from passed value %v", - c.Args()[1], - ) - } - result, err := contract.IsOperatorEligibleAtBlock( - _operator, - _application, + result, err := contract.NewGroupSelectionSeedFeeAtBlock( cmd.BlockFlagValue.Uint, ) @@ -577,29 +569,20 @@ func becdsakfIsOperatorEligible(c *cli.Context) error { return nil } -func becdsakfIsOperatorUpToDate(c *cli.Context) error { +func becdsakfGetSortitionPoolWeight(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _operator, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _operator, a address, from passed value %v", - c.Args()[0], - ) - } - - _application, err := ethutil.AddressFromHex(c.Args()[1]) + _application, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( "couldn't parse parameter _application, a address, from passed value %v", - c.Args()[1], + c.Args()[0], ) } - result, err := contract.IsOperatorUpToDateAtBlock( - _operator, + result, err := contract.GetSortitionPoolWeightAtBlock( _application, cmd.BlockFlagValue.Uint, @@ -614,13 +597,30 @@ func becdsakfIsOperatorUpToDate(c *cli.Context) error { return nil } -func becdsakfGroupSelectionSeed(c *cli.Context) error { +func becdsakfIsOperatorEligible(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { - return err + return err + } + _operator, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _operator, a address, from passed value %v", + c.Args()[0], + ) + } + + _application, err := ethutil.AddressFromHex(c.Args()[1]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _application, a address, from passed value %v", + c.Args()[1], + ) } - result, err := contract.GroupSelectionSeedAtBlock( + result, err := contract.IsOperatorEligibleAtBlock( + _operator, + _application, cmd.BlockFlagValue.Uint, ) @@ -634,7 +634,7 @@ func becdsakfGroupSelectionSeed(c *cli.Context) error { return nil } -func becdsakfIsOperatorRegistered(c *cli.Context) error { +func becdsakfIsOperatorUpToDate(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err @@ -655,7 +655,7 @@ func becdsakfIsOperatorRegistered(c *cli.Context) error { ) } - result, err := contract.IsOperatorRegisteredAtBlock( + result, err := contract.IsOperatorUpToDateAtBlock( _operator, _application, @@ -699,41 +699,21 @@ func becdsakfKeeps(c *cli.Context) error { return nil } -func becdsakfMasterKeepAddress(c *cli.Context) error { - contract, err := initializeBondedECDSAKeepFactory(c) - if err != nil { - return err - } - - result, err := contract.MasterKeepAddressAtBlock( - - cmd.BlockFlagValue.Uint, - ) - - if err != nil { - return err - } - - cmd.PrintOutput(result) - - return nil -} - -func becdsakfHasMinimumStake(c *cli.Context) error { +func becdsakfGetKeepOpenedTimestamp(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _operator, err := ethutil.AddressFromHex(c.Args()[0]) + _keep, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _operator, a address, from passed value %v", + "couldn't parse parameter _keep, a address, from passed value %v", c.Args()[0], ) } - result, err := contract.HasMinimumStakeAtBlock( - _operator, + result, err := contract.GetKeepOpenedTimestampAtBlock( + _keep, cmd.BlockFlagValue.Uint, ) @@ -747,13 +727,13 @@ func becdsakfHasMinimumStake(c *cli.Context) error { return nil } -func becdsakfReseedPool(c *cli.Context) error { +func becdsakfCallbackGas(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - result, err := contract.ReseedPoolAtBlock( + result, err := contract.CallbackGasAtBlock( cmd.BlockFlagValue.Uint, ) @@ -767,21 +747,21 @@ func becdsakfReseedPool(c *cli.Context) error { return nil } -func becdsakfBalanceOf(c *cli.Context) error { +func becdsakfGetSortitionPool(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _operator, err := ethutil.AddressFromHex(c.Args()[0]) + _application, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _operator, a address, from passed value %v", + "couldn't parse parameter _application, a address, from passed value %v", c.Args()[0], ) } - result, err := contract.BalanceOfAtBlock( - _operator, + result, err := contract.GetSortitionPoolAtBlock( + _application, cmd.BlockFlagValue.Uint, ) @@ -795,42 +775,28 @@ func becdsakfBalanceOf(c *cli.Context) error { return nil } -/// ------------------- Non-const methods ------------------- - -func becdsakfRequestNewGroupSelectionSeed(c *cli.Context) error { +func becdsakfGetKeepCount(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - var ( - transaction *types.Transaction - ) - - if c.Bool(cmd.SubmitFlag) { - // Do a regular submission. Take payable into account. - transaction, err = contract.RequestNewGroupSelectionSeed( - cmd.ValueFlagValue.Uint) - if err != nil { - return err - } + result, err := contract.GetKeepCountAtBlock( - cmd.PrintOutput(transaction.Hash) - } else { - // Do a call. - err = contract.CallRequestNewGroupSelectionSeed( - cmd.ValueFlagValue.Uint, cmd.BlockFlagValue.Uint, - ) - if err != nil { - return err - } + cmd.BlockFlagValue.Uint, + ) - cmd.PrintOutput(nil) + if err != nil { + return err } + cmd.PrintOutput(result) + return nil } +/// ------------------- Non-const methods ------------------- + func becdsakfOpenKeep(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { @@ -916,16 +882,16 @@ func becdsakfOpenKeep(c *cli.Context) error { return nil } -func becdsakfRegisterMemberCandidate(c *cli.Context) error { +func becdsakfBeaconCallback(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _application, err := ethutil.AddressFromHex(c.Args()[0]) + _relayEntry, err := hexutil.DecodeBig(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _application, a address, from passed value %v", + "couldn't parse parameter _relayEntry, a uint256, from passed value %v", c.Args()[0], ) } @@ -936,8 +902,8 @@ func becdsakfRegisterMemberCandidate(c *cli.Context) error { if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.RegisterMemberCandidate( - _application, + transaction, err = contract.BeaconCallback( + _relayEntry, ) if err != nil { return err @@ -946,8 +912,8 @@ func becdsakfRegisterMemberCandidate(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallRegisterMemberCandidate( - _application, + err = contract.CallBeaconCallback( + _relayEntry, cmd.BlockFlagValue.Uint, ) if err != nil { @@ -960,46 +926,29 @@ func becdsakfRegisterMemberCandidate(c *cli.Context) error { return nil } -func becdsakfSetMinimumBondableValue(c *cli.Context) error { +func becdsakfIsRecognized(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _minimumBondableValue, err := hexutil.DecodeBig(c.Args()[0]) + _delegatedAuthorityRecipient, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _minimumBondableValue, a uint256, from passed value %v", + "couldn't parse parameter _delegatedAuthorityRecipient, a address, from passed value %v", c.Args()[0], ) } - _groupSize, err := hexutil.DecodeBig(c.Args()[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _groupSize, a uint256, from passed value %v", - c.Args()[1], - ) - } - - _honestThreshold, err := hexutil.DecodeBig(c.Args()[2]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _honestThreshold, a uint256, from passed value %v", - c.Args()[2], - ) - } - var ( transaction *types.Transaction + result bool ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.SetMinimumBondableValue( - _minimumBondableValue, - _groupSize, - _honestThreshold, + transaction, err = contract.IsRecognized( + _delegatedAuthorityRecipient, ) if err != nil { return err @@ -1008,46 +957,34 @@ func becdsakfSetMinimumBondableValue(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallSetMinimumBondableValue( - _minimumBondableValue, - _groupSize, - _honestThreshold, + result, err = contract.CallIsRecognized( + _delegatedAuthorityRecipient, cmd.BlockFlagValue.Uint, ) if err != nil { return err } - cmd.PrintOutput(nil) + cmd.PrintOutput(result) } return nil } -func becdsakfIsRecognized(c *cli.Context) error { +func becdsakfRequestNewGroupSelectionSeed(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _delegatedAuthorityRecipient, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter _delegatedAuthorityRecipient, a address, from passed value %v", - c.Args()[0], - ) - } - var ( transaction *types.Transaction - result bool ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.IsRecognized( - _delegatedAuthorityRecipient, - ) + transaction, err = contract.RequestNewGroupSelectionSeed( + cmd.ValueFlagValue.Uint) if err != nil { return err } @@ -1055,42 +992,42 @@ func becdsakfIsRecognized(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - result, err = contract.CallIsRecognized( - _delegatedAuthorityRecipient, - cmd.BlockFlagValue.Uint, + err = contract.CallRequestNewGroupSelectionSeed( + cmd.ValueFlagValue.Uint, cmd.BlockFlagValue.Uint, ) if err != nil { return err } - cmd.PrintOutput(result) + cmd.PrintOutput(nil) } return nil } -func becdsakfBeaconCallback(c *cli.Context) error { +func becdsakfCreateSortitionPool(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err } - _relayEntry, err := hexutil.DecodeBig(c.Args()[0]) + _application, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _relayEntry, a uint256, from passed value %v", + "couldn't parse parameter _application, a address, from passed value %v", c.Args()[0], ) } var ( transaction *types.Transaction + result common.Address ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.BeaconCallback( - _relayEntry, + transaction, err = contract.CreateSortitionPool( + _application, ) if err != nil { return err @@ -1099,15 +1036,15 @@ func becdsakfBeaconCallback(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallBeaconCallback( - _relayEntry, + result, err = contract.CallCreateSortitionPool( + _application, cmd.BlockFlagValue.Uint, ) if err != nil { return err } - cmd.PrintOutput(nil) + cmd.PrintOutput(result) } return nil @@ -1167,7 +1104,7 @@ func becdsakfUpdateOperatorStatus(c *cli.Context) error { return nil } -func becdsakfCreateSortitionPool(c *cli.Context) error { +func becdsakfRegisterMemberCandidate(c *cli.Context) error { contract, err := initializeBondedECDSAKeepFactory(c) if err != nil { return err @@ -1183,12 +1120,11 @@ func becdsakfCreateSortitionPool(c *cli.Context) error { var ( transaction *types.Transaction - result common.Address ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.CreateSortitionPool( + transaction, err = contract.RegisterMemberCandidate( _application, ) if err != nil { @@ -1198,7 +1134,7 @@ func becdsakfCreateSortitionPool(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - result, err = contract.CallCreateSortitionPool( + err = contract.CallRegisterMemberCandidate( _application, cmd.BlockFlagValue.Uint, ) @@ -1206,7 +1142,71 @@ func becdsakfCreateSortitionPool(c *cli.Context) error { return err } - cmd.PrintOutput(result) + cmd.PrintOutput(nil) + } + + return nil +} + +func becdsakfSetMinimumBondableValue(c *cli.Context) error { + contract, err := initializeBondedECDSAKeepFactory(c) + if err != nil { + return err + } + + _minimumBondableValue, err := hexutil.DecodeBig(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _minimumBondableValue, a uint256, from passed value %v", + c.Args()[0], + ) + } + + _groupSize, err := hexutil.DecodeBig(c.Args()[1]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _groupSize, a uint256, from passed value %v", + c.Args()[1], + ) + } + + _honestThreshold, err := hexutil.DecodeBig(c.Args()[2]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _honestThreshold, a uint256, from passed value %v", + c.Args()[2], + ) + } + + var ( + transaction *types.Transaction + ) + + if c.Bool(cmd.SubmitFlag) { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetMinimumBondableValue( + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash) + } else { + // Do a call. + err = contract.CallSetMinimumBondableValue( + _minimumBondableValue, + _groupSize, + _honestThreshold, + cmd.BlockFlagValue.Uint, + ) + if err != nil { + return err + } + + cmd.PrintOutput(nil) } return nil diff --git a/pkg/chain/gen/cmd/BondedECDSAKeepVendor.go b/pkg/chain/gen/cmd/BondedECDSAKeepVendor.go index 197ab00ec..b14af0203 100644 --- a/pkg/chain/gen/cmd/BondedECDSAKeepVendor.go +++ b/pkg/chain/gen/cmd/BondedECDSAKeepVendor.go @@ -51,6 +51,13 @@ func init() { Usage: `Provides access to the BondedECDSAKeepVendor contract.`, Description: bondedECDSAKeepVendorDescription, Subcommands: []cli.Command{{ + Name: "factory-upgrade-time-delay", + Usage: "Calls the constant method factoryUpgradeTimeDelay on the BondedECDSAKeepVendor contract.", + ArgsUsage: "", + Action: becdsakvFactoryUpgradeTimeDelay, + Before: cmd.ArgCountChecker(0), + Flags: cmd.ConstFlags, + }, { Name: "initialized", Usage: "Calls the constant method initialized on the BondedECDSAKeepVendor contract.", ArgsUsage: "", @@ -65,12 +72,12 @@ func init() { Before: cmd.ArgCountChecker(0), Flags: cmd.ConstFlags, }, { - Name: "factory-upgrade-time-delay", - Usage: "Calls the constant method factoryUpgradeTimeDelay on the BondedECDSAKeepVendor contract.", - ArgsUsage: "", - Action: becdsakvFactoryUpgradeTimeDelay, - Before: cmd.ArgCountChecker(0), - Flags: cmd.ConstFlags, + Name: "initialize", + Usage: "Calls the method initialize on the BondedECDSAKeepVendor contract.", + ArgsUsage: "[registryAddress] [factory] ", + Action: becdsakvInitialize, + Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(2))), + Flags: cmd.NonConstFlags, }, { Name: "upgrade-factory", Usage: "Calls the method upgradeFactory on the BondedECDSAKeepVendor contract.", @@ -85,26 +92,19 @@ func init() { Action: becdsakvCompleteFactoryUpgrade, Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(0))), Flags: cmd.NonConstFlags, - }, { - Name: "initialize", - Usage: "Calls the method initialize on the BondedECDSAKeepVendor contract.", - ArgsUsage: "[registryAddress] [factory] ", - Action: becdsakvInitialize, - Before: cli.BeforeFunc(cmd.NonConstArgsChecker.AndThen(cmd.ArgCountChecker(2))), - Flags: cmd.NonConstFlags, }}, }) } /// ------------------- Const methods ------------------- -func becdsakvInitialized(c *cli.Context) error { +func becdsakvFactoryUpgradeTimeDelay(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } - result, err := contract.InitializedAtBlock( + result, err := contract.FactoryUpgradeTimeDelayAtBlock( cmd.BlockFlagValue.Uint, ) @@ -118,13 +118,13 @@ func becdsakvInitialized(c *cli.Context) error { return nil } -func becdsakvSelectFactory(c *cli.Context) error { +func becdsakvInitialized(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } - result, err := contract.SelectFactoryAtBlock( + result, err := contract.InitializedAtBlock( cmd.BlockFlagValue.Uint, ) @@ -138,13 +138,13 @@ func becdsakvSelectFactory(c *cli.Context) error { return nil } -func becdsakvFactoryUpgradeTimeDelay(c *cli.Context) error { +func becdsakvSelectFactory(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } - result, err := contract.FactoryUpgradeTimeDelayAtBlock( + result, err := contract.SelectFactoryAtBlock( cmd.BlockFlagValue.Uint, ) @@ -160,28 +160,37 @@ func becdsakvFactoryUpgradeTimeDelay(c *cli.Context) error { /// ------------------- Non-const methods ------------------- -func becdsakvUpgradeFactory(c *cli.Context) error { +func becdsakvInitialize(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } - _factory, err := ethutil.AddressFromHex(c.Args()[0]) + registryAddress, err := ethutil.AddressFromHex(c.Args()[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter _factory, a address, from passed value %v", + "couldn't parse parameter registryAddress, a address, from passed value %v", c.Args()[0], ) } + factory, err := ethutil.AddressFromHex(c.Args()[1]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter factory, a address, from passed value %v", + c.Args()[1], + ) + } + var ( transaction *types.Transaction ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.UpgradeFactory( - _factory, + transaction, err = contract.Initialize( + registryAddress, + factory, ) if err != nil { return err @@ -190,8 +199,9 @@ func becdsakvUpgradeFactory(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallUpgradeFactory( - _factory, + err = contract.CallInitialize( + registryAddress, + factory, cmd.BlockFlagValue.Uint, ) if err != nil { @@ -204,19 +214,29 @@ func becdsakvUpgradeFactory(c *cli.Context) error { return nil } -func becdsakvCompleteFactoryUpgrade(c *cli.Context) error { +func becdsakvUpgradeFactory(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } + _factory, err := ethutil.AddressFromHex(c.Args()[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter _factory, a address, from passed value %v", + c.Args()[0], + ) + } + var ( transaction *types.Transaction ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.CompleteFactoryUpgrade() + transaction, err = contract.UpgradeFactory( + _factory, + ) if err != nil { return err } @@ -224,7 +244,8 @@ func becdsakvCompleteFactoryUpgrade(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallCompleteFactoryUpgrade( + err = contract.CallUpgradeFactory( + _factory, cmd.BlockFlagValue.Uint, ) if err != nil { @@ -237,38 +258,19 @@ func becdsakvCompleteFactoryUpgrade(c *cli.Context) error { return nil } -func becdsakvInitialize(c *cli.Context) error { +func becdsakvCompleteFactoryUpgrade(c *cli.Context) error { contract, err := initializeBondedECDSAKeepVendor(c) if err != nil { return err } - registryAddress, err := ethutil.AddressFromHex(c.Args()[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter registryAddress, a address, from passed value %v", - c.Args()[0], - ) - } - - factory, err := ethutil.AddressFromHex(c.Args()[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter factory, a address, from passed value %v", - c.Args()[1], - ) - } - var ( transaction *types.Transaction ) if c.Bool(cmd.SubmitFlag) { // Do a regular submission. Take payable into account. - transaction, err = contract.Initialize( - registryAddress, - factory, - ) + transaction, err = contract.CompleteFactoryUpgrade() if err != nil { return err } @@ -276,9 +278,7 @@ func becdsakvInitialize(c *cli.Context) error { cmd.PrintOutput(transaction.Hash) } else { // Do a call. - err = contract.CallInitialize( - registryAddress, - factory, + err = contract.CallCompleteFactoryUpgrade( cmd.BlockFlagValue.Uint, ) if err != nil { diff --git a/pkg/chain/gen/contract/BondedECDSAKeep.go b/pkg/chain/gen/contract/BondedECDSAKeep.go index e25f8db8c..55aaa6df2 100644 --- a/pkg/chain/gen/contract/BondedECDSAKeep.go +++ b/pkg/chain/gen/contract/BondedECDSAKeep.go @@ -221,17 +221,12 @@ func (becdsak *BondedECDSAKeep) DistributeETHRewardGasEstimate() (uint64, error) } // Transaction submission. -func (becdsak *BondedECDSAKeep) Withdraw( - _member common.Address, +func (becdsak *BondedECDSAKeep) SeizeSignerBonds( transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction withdraw", - "params: ", - fmt.Sprint( - _member, - ), + "submitting transaction seizeSignerBonds", ) becdsak.transactionMutex.Lock() @@ -256,22 +251,20 @@ func (becdsak *BondedECDSAKeep) Withdraw( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.Withdraw( + transaction, err := becdsak.contract.SeizeSignerBonds( transactorOptions, - _member, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "withdraw", - _member, + "seizeSignerBonds", ) } becdsakLogger.Infof( - "submitted transaction withdraw with id: [%v] and nonce [%v]", + "submitted transaction seizeSignerBonds with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -282,22 +275,20 @@ func (becdsak *BondedECDSAKeep) Withdraw( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.Withdraw( + transaction, err := becdsak.contract.SeizeSignerBonds( transactorOptions, - _member, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "withdraw", - _member, + "seizeSignerBonds", ) } becdsakLogger.Infof( - "submitted transaction withdraw with id: [%v] and nonce [%v]", + "submitted transaction seizeSignerBonds with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -312,8 +303,7 @@ func (becdsak *BondedECDSAKeep) Withdraw( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallWithdraw( - _member common.Address, +func (becdsak *BondedECDSAKeep) CallSeizeSignerBonds( blockNumber *big.Int, ) error { var result interface{} = nil @@ -325,38 +315,39 @@ func (becdsak *BondedECDSAKeep) CallWithdraw( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "withdraw", + "seizeSignerBonds", &result, - _member, ) return err } -func (becdsak *BondedECDSAKeep) WithdrawGasEstimate( - _member common.Address, -) (uint64, error) { +func (becdsak *BondedECDSAKeep) SeizeSignerBondsGasEstimate() (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "withdraw", + "seizeSignerBonds", becdsak.contractABI, becdsak.transactor, - _member, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) CloseKeep( +func (becdsak *BondedECDSAKeep) Sign( + _digest [32]uint8, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction closeKeep", + "submitting transaction sign", + "params: ", + fmt.Sprint( + _digest, + ), ) becdsak.transactionMutex.Lock() @@ -381,20 +372,22 @@ func (becdsak *BondedECDSAKeep) CloseKeep( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.CloseKeep( + transaction, err := becdsak.contract.Sign( transactorOptions, + _digest, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "closeKeep", + "sign", + _digest, ) } becdsakLogger.Infof( - "submitted transaction closeKeep with id: [%v] and nonce [%v]", + "submitted transaction sign with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -405,20 +398,22 @@ func (becdsak *BondedECDSAKeep) CloseKeep( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.CloseKeep( + transaction, err := becdsak.contract.Sign( transactorOptions, + _digest, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "closeKeep", + "sign", + _digest, ) } becdsakLogger.Infof( - "submitted transaction closeKeep with id: [%v] and nonce [%v]", + "submitted transaction sign with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -433,7 +428,8 @@ func (becdsak *BondedECDSAKeep) CloseKeep( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallCloseKeep( +func (becdsak *BondedECDSAKeep) CallSign( + _digest [32]uint8, blockNumber *big.Int, ) error { var result interface{} = nil @@ -445,40 +441,42 @@ func (becdsak *BondedECDSAKeep) CallCloseKeep( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "closeKeep", + "sign", &result, + _digest, ) return err } -func (becdsak *BondedECDSAKeep) CloseKeepGasEstimate() (uint64, error) { +func (becdsak *BondedECDSAKeep) SignGasEstimate( + _digest [32]uint8, +) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "closeKeep", + "sign", becdsak.contractABI, becdsak.transactor, + _digest, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) DistributeERC20Reward( - _tokenAddress common.Address, - _value *big.Int, +func (becdsak *BondedECDSAKeep) Withdraw( + _member common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction distributeERC20Reward", + "submitting transaction withdraw", "params: ", fmt.Sprint( - _tokenAddress, - _value, + _member, ), ) @@ -504,24 +502,22 @@ func (becdsak *BondedECDSAKeep) DistributeERC20Reward( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.DistributeERC20Reward( + transaction, err := becdsak.contract.Withdraw( transactorOptions, - _tokenAddress, - _value, + _member, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "distributeERC20Reward", - _tokenAddress, - _value, + "withdraw", + _member, ) } becdsakLogger.Infof( - "submitted transaction distributeERC20Reward with id: [%v] and nonce [%v]", + "submitted transaction withdraw with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -532,24 +528,22 @@ func (becdsak *BondedECDSAKeep) DistributeERC20Reward( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.DistributeERC20Reward( + transaction, err := becdsak.contract.Withdraw( transactorOptions, - _tokenAddress, - _value, + _member, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "distributeERC20Reward", - _tokenAddress, - _value, + "withdraw", + _member, ) } becdsakLogger.Infof( - "submitted transaction distributeERC20Reward with id: [%v] and nonce [%v]", + "submitted transaction withdraw with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -564,9 +558,8 @@ func (becdsak *BondedECDSAKeep) DistributeERC20Reward( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallDistributeERC20Reward( - _tokenAddress common.Address, - _value *big.Int, +func (becdsak *BondedECDSAKeep) CallWithdraw( + _member common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -578,59 +571,42 @@ func (becdsak *BondedECDSAKeep) CallDistributeERC20Reward( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "distributeERC20Reward", + "withdraw", &result, - _tokenAddress, - _value, + _member, ) return err } -func (becdsak *BondedECDSAKeep) DistributeERC20RewardGasEstimate( - _tokenAddress common.Address, - _value *big.Int, +func (becdsak *BondedECDSAKeep) WithdrawGasEstimate( + _member common.Address, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "distributeERC20Reward", + "withdraw", becdsak.contractABI, becdsak.transactor, - _tokenAddress, - _value, + _member, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) Initialize( - _owner common.Address, - _members []common.Address, - _honestThreshold *big.Int, - _memberStake *big.Int, - _stakeLockDuration *big.Int, - _tokenStaking common.Address, - _keepBonding common.Address, - _keepFactory common.Address, +func (becdsak *BondedECDSAKeep) SubmitPublicKey( + _publicKey []uint8, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction initialize", + "submitting transaction submitPublicKey", "params: ", fmt.Sprint( - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + _publicKey, ), ) @@ -656,36 +632,22 @@ func (becdsak *BondedECDSAKeep) Initialize( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.Initialize( + transaction, err := becdsak.contract.SubmitPublicKey( transactorOptions, - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + _publicKey, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "initialize", - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + "submitPublicKey", + _publicKey, ) } becdsakLogger.Infof( - "submitted transaction initialize with id: [%v] and nonce [%v]", + "submitted transaction submitPublicKey with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -696,36 +658,22 @@ func (becdsak *BondedECDSAKeep) Initialize( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.Initialize( + transaction, err := becdsak.contract.SubmitPublicKey( transactorOptions, - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + _publicKey, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "initialize", - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + "submitPublicKey", + _publicKey, ) } becdsakLogger.Infof( - "submitted transaction initialize with id: [%v] and nonce [%v]", + "submitted transaction submitPublicKey with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -740,15 +688,8 @@ func (becdsak *BondedECDSAKeep) Initialize( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallInitialize( - _owner common.Address, - _members []common.Address, - _honestThreshold *big.Int, - _memberStake *big.Int, - _stakeLockDuration *big.Int, - _tokenStaking common.Address, - _keepBonding common.Address, - _keepFactory common.Address, +func (becdsak *BondedECDSAKeep) CallSubmitPublicKey( + _publicKey []uint8, blockNumber *big.Int, ) error { var result interface{} = nil @@ -760,71 +701,44 @@ func (becdsak *BondedECDSAKeep) CallInitialize( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "initialize", + "submitPublicKey", &result, - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + _publicKey, ) return err } -func (becdsak *BondedECDSAKeep) InitializeGasEstimate( - _owner common.Address, - _members []common.Address, - _honestThreshold *big.Int, - _memberStake *big.Int, - _stakeLockDuration *big.Int, - _tokenStaking common.Address, - _keepBonding common.Address, - _keepFactory common.Address, +func (becdsak *BondedECDSAKeep) SubmitPublicKeyGasEstimate( + _publicKey []uint8, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "initialize", + "submitPublicKey", becdsak.contractABI, becdsak.transactor, - _owner, - _members, - _honestThreshold, - _memberStake, - _stakeLockDuration, - _tokenStaking, - _keepBonding, - _keepFactory, + _publicKey, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) SubmitSignatureFraud( - _v uint8, - _r [32]uint8, - _s [32]uint8, - _signedDigest [32]uint8, - _preimage []uint8, +func (becdsak *BondedECDSAKeep) DistributeERC20Reward( + _tokenAddress common.Address, + _value *big.Int, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction submitSignatureFraud", + "submitting transaction distributeERC20Reward", "params: ", fmt.Sprint( - _v, - _r, - _s, - _signedDigest, - _preimage, + _tokenAddress, + _value, ), ) @@ -850,30 +764,24 @@ func (becdsak *BondedECDSAKeep) SubmitSignatureFraud( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.SubmitSignatureFraud( + transaction, err := becdsak.contract.DistributeERC20Reward( transactorOptions, - _v, - _r, - _s, - _signedDigest, - _preimage, + _tokenAddress, + _value, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "submitSignatureFraud", - _v, - _r, - _s, - _signedDigest, - _preimage, + "distributeERC20Reward", + _tokenAddress, + _value, ) } becdsakLogger.Infof( - "submitted transaction submitSignatureFraud with id: [%v] and nonce [%v]", + "submitted transaction distributeERC20Reward with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -884,30 +792,24 @@ func (becdsak *BondedECDSAKeep) SubmitSignatureFraud( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.SubmitSignatureFraud( + transaction, err := becdsak.contract.DistributeERC20Reward( transactorOptions, - _v, - _r, - _s, - _signedDigest, - _preimage, + _tokenAddress, + _value, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "submitSignatureFraud", - _v, - _r, - _s, - _signedDigest, - _preimage, + "distributeERC20Reward", + _tokenAddress, + _value, ) } becdsakLogger.Infof( - "submitted transaction submitSignatureFraud with id: [%v] and nonce [%v]", + "submitted transaction distributeERC20Reward with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -922,15 +824,12 @@ func (becdsak *BondedECDSAKeep) SubmitSignatureFraud( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallSubmitSignatureFraud( - _v uint8, - _r [32]uint8, - _s [32]uint8, - _signedDigest [32]uint8, - _preimage []uint8, +func (becdsak *BondedECDSAKeep) CallDistributeERC20Reward( + _tokenAddress common.Address, + _value *big.Int, blockNumber *big.Int, -) (bool, error) { - var result bool +) error { + var result interface{} = nil err := ethutil.CallAtBlock( becdsak.transactorOptions.From, @@ -939,52 +838,60 @@ func (becdsak *BondedECDSAKeep) CallSubmitSignatureFraud( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "submitSignatureFraud", + "distributeERC20Reward", &result, - _v, - _r, - _s, - _signedDigest, - _preimage, + _tokenAddress, + _value, ) - return result, err + return err } -func (becdsak *BondedECDSAKeep) SubmitSignatureFraudGasEstimate( - _v uint8, - _r [32]uint8, - _s [32]uint8, - _signedDigest [32]uint8, - _preimage []uint8, +func (becdsak *BondedECDSAKeep) DistributeERC20RewardGasEstimate( + _tokenAddress common.Address, + _value *big.Int, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "submitSignatureFraud", + "distributeERC20Reward", becdsak.contractABI, becdsak.transactor, - _v, - _r, - _s, - _signedDigest, - _preimage, + _tokenAddress, + _value, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( - value *big.Int, +func (becdsak *BondedECDSAKeep) Initialize( + _owner common.Address, + _members []common.Address, + _honestThreshold *big.Int, + _memberStake *big.Int, + _stakeLockDuration *big.Int, + _tokenStaking common.Address, + _keepBonding common.Address, + _keepFactory common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction returnPartialSignerBonds", - "value: ", value, + "submitting transaction initialize", + "params: ", + fmt.Sprint( + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, + ), ) becdsak.transactionMutex.Lock() @@ -994,8 +901,6 @@ func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( transactorOptions := new(bind.TransactOpts) *transactorOptions = *becdsak.transactorOptions - transactorOptions.Value = value - if len(transactionOptions) > 1 { return nil, fmt.Errorf( "could not process multiple transaction options sets", @@ -1011,20 +916,36 @@ func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.ReturnPartialSignerBonds( + transaction, err := becdsak.contract.Initialize( transactorOptions, + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, - value, - "returnPartialSignerBonds", + nil, + "initialize", + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) } becdsakLogger.Infof( - "submitted transaction returnPartialSignerBonds with id: [%v] and nonce [%v]", + "submitted transaction initialize with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1035,20 +956,36 @@ func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.ReturnPartialSignerBonds( + transaction, err := becdsak.contract.Initialize( transactorOptions, + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, - value, - "returnPartialSignerBonds", + nil, + "initialize", + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) } becdsakLogger.Infof( - "submitted transaction returnPartialSignerBonds with id: [%v] and nonce [%v]", + "submitted transaction initialize with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1063,47 +1000,81 @@ func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallReturnPartialSignerBonds( - value *big.Int, +func (becdsak *BondedECDSAKeep) CallInitialize( + _owner common.Address, + _members []common.Address, + _honestThreshold *big.Int, + _memberStake *big.Int, + _stakeLockDuration *big.Int, + _tokenStaking common.Address, + _keepBonding common.Address, + _keepFactory common.Address, blockNumber *big.Int, ) error { var result interface{} = nil err := ethutil.CallAtBlock( becdsak.transactorOptions.From, - blockNumber, value, + blockNumber, nil, becdsak.contractABI, becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "returnPartialSignerBonds", + "initialize", &result, + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) return err } -func (becdsak *BondedECDSAKeep) ReturnPartialSignerBondsGasEstimate() (uint64, error) { +func (becdsak *BondedECDSAKeep) InitializeGasEstimate( + _owner common.Address, + _members []common.Address, + _honestThreshold *big.Int, + _memberStake *big.Int, + _stakeLockDuration *big.Int, + _tokenStaking common.Address, + _keepBonding common.Address, + _keepFactory common.Address, +) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "returnPartialSignerBonds", + "initialize", becdsak.contractABI, becdsak.transactor, + _owner, + _members, + _honestThreshold, + _memberStake, + _stakeLockDuration, + _tokenStaking, + _keepBonding, + _keepFactory, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) SeizeSignerBonds( +func (becdsak *BondedECDSAKeep) ReturnPartialSignerBonds( + value *big.Int, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction seizeSignerBonds", + "submitting transaction returnPartialSignerBonds", + "value: ", value, ) becdsak.transactionMutex.Lock() @@ -1113,6 +1084,8 @@ func (becdsak *BondedECDSAKeep) SeizeSignerBonds( transactorOptions := new(bind.TransactOpts) *transactorOptions = *becdsak.transactorOptions + transactorOptions.Value = value + if len(transactionOptions) > 1 { return nil, fmt.Errorf( "could not process multiple transaction options sets", @@ -1128,20 +1101,20 @@ func (becdsak *BondedECDSAKeep) SeizeSignerBonds( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.SeizeSignerBonds( + transaction, err := becdsak.contract.ReturnPartialSignerBonds( transactorOptions, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, - nil, - "seizeSignerBonds", + value, + "returnPartialSignerBonds", ) } becdsakLogger.Infof( - "submitted transaction seizeSignerBonds with id: [%v] and nonce [%v]", + "submitted transaction returnPartialSignerBonds with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1152,20 +1125,20 @@ func (becdsak *BondedECDSAKeep) SeizeSignerBonds( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.SeizeSignerBonds( + transaction, err := becdsak.contract.ReturnPartialSignerBonds( transactorOptions, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, - nil, - "seizeSignerBonds", + value, + "returnPartialSignerBonds", ) } becdsakLogger.Infof( - "submitted transaction seizeSignerBonds with id: [%v] and nonce [%v]", + "submitted transaction returnPartialSignerBonds with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1180,32 +1153,33 @@ func (becdsak *BondedECDSAKeep) SeizeSignerBonds( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallSeizeSignerBonds( +func (becdsak *BondedECDSAKeep) CallReturnPartialSignerBonds( + value *big.Int, blockNumber *big.Int, ) error { var result interface{} = nil err := ethutil.CallAtBlock( becdsak.transactorOptions.From, - blockNumber, nil, + blockNumber, value, becdsak.contractABI, becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "seizeSignerBonds", + "returnPartialSignerBonds", &result, ) return err } -func (becdsak *BondedECDSAKeep) SeizeSignerBondsGasEstimate() (uint64, error) { +func (becdsak *BondedECDSAKeep) ReturnPartialSignerBondsGasEstimate() (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "seizeSignerBonds", + "returnPartialSignerBonds", becdsak.contractABI, becdsak.transactor, ) @@ -1214,16 +1188,24 @@ func (becdsak *BondedECDSAKeep) SeizeSignerBondsGasEstimate() (uint64, error) { } // Transaction submission. -func (becdsak *BondedECDSAKeep) SubmitPublicKey( - _publicKey []uint8, +func (becdsak *BondedECDSAKeep) SubmitSignatureFraud( + _v uint8, + _r [32]uint8, + _s [32]uint8, + _signedDigest [32]uint8, + _preimage []uint8, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction submitPublicKey", + "submitting transaction submitSignatureFraud", "params: ", fmt.Sprint( - _publicKey, + _v, + _r, + _s, + _signedDigest, + _preimage, ), ) @@ -1249,22 +1231,30 @@ func (becdsak *BondedECDSAKeep) SubmitPublicKey( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.SubmitPublicKey( + transaction, err := becdsak.contract.SubmitSignatureFraud( transactorOptions, - _publicKey, + _v, + _r, + _s, + _signedDigest, + _preimage, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "submitPublicKey", - _publicKey, + "submitSignatureFraud", + _v, + _r, + _s, + _signedDigest, + _preimage, ) } becdsakLogger.Infof( - "submitted transaction submitPublicKey with id: [%v] and nonce [%v]", + "submitted transaction submitSignatureFraud with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1275,22 +1265,30 @@ func (becdsak *BondedECDSAKeep) SubmitPublicKey( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.SubmitPublicKey( + transaction, err := becdsak.contract.SubmitSignatureFraud( transactorOptions, - _publicKey, + _v, + _r, + _s, + _signedDigest, + _preimage, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "submitPublicKey", - _publicKey, + "submitSignatureFraud", + _v, + _r, + _s, + _signedDigest, + _preimage, ) } becdsakLogger.Infof( - "submitted transaction submitPublicKey with id: [%v] and nonce [%v]", + "submitted transaction submitSignatureFraud with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1305,11 +1303,15 @@ func (becdsak *BondedECDSAKeep) SubmitPublicKey( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallSubmitPublicKey( - _publicKey []uint8, +func (becdsak *BondedECDSAKeep) CallSubmitSignatureFraud( + _v uint8, + _r [32]uint8, + _s [32]uint8, + _signedDigest [32]uint8, + _preimage []uint8, blockNumber *big.Int, -) error { - var result interface{} = nil +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsak.transactorOptions.From, @@ -1318,43 +1320,50 @@ func (becdsak *BondedECDSAKeep) CallSubmitPublicKey( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "submitPublicKey", + "submitSignatureFraud", &result, - _publicKey, + _v, + _r, + _s, + _signedDigest, + _preimage, ) - return err + return result, err } -func (becdsak *BondedECDSAKeep) SubmitPublicKeyGasEstimate( - _publicKey []uint8, +func (becdsak *BondedECDSAKeep) SubmitSignatureFraudGasEstimate( + _v uint8, + _r [32]uint8, + _s [32]uint8, + _signedDigest [32]uint8, + _preimage []uint8, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "submitPublicKey", + "submitSignatureFraud", becdsak.contractABI, becdsak.transactor, - _publicKey, + _v, + _r, + _s, + _signedDigest, + _preimage, ) return result, err } // Transaction submission. -func (becdsak *BondedECDSAKeep) Sign( - _digest [32]uint8, +func (becdsak *BondedECDSAKeep) CloseKeep( transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakLogger.Debug( - "submitting transaction sign", - "params: ", - fmt.Sprint( - _digest, - ), + "submitting transaction closeKeep", ) becdsak.transactionMutex.Lock() @@ -1379,22 +1388,20 @@ func (becdsak *BondedECDSAKeep) Sign( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsak.contract.Sign( + transaction, err := becdsak.contract.CloseKeep( transactorOptions, - _digest, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "sign", - _digest, + "closeKeep", ) } becdsakLogger.Infof( - "submitted transaction sign with id: [%v] and nonce [%v]", + "submitted transaction closeKeep with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1405,22 +1412,20 @@ func (becdsak *BondedECDSAKeep) Sign( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsak.contract.Sign( + transaction, err := becdsak.contract.CloseKeep( transactorOptions, - _digest, ) if err != nil { return transaction, becdsak.errorResolver.ResolveError( err, becdsak.transactorOptions.From, nil, - "sign", - _digest, + "closeKeep", ) } becdsakLogger.Infof( - "submitted transaction sign with id: [%v] and nonce [%v]", + "submitted transaction closeKeep with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1435,8 +1440,7 @@ func (becdsak *BondedECDSAKeep) Sign( } // Non-mutating call, not a transaction submission. -func (becdsak *BondedECDSAKeep) CallSign( - _digest [32]uint8, +func (becdsak *BondedECDSAKeep) CallCloseKeep( blockNumber *big.Int, ) error { var result interface{} = nil @@ -1448,26 +1452,22 @@ func (becdsak *BondedECDSAKeep) CallSign( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "sign", + "closeKeep", &result, - _digest, ) return err } -func (becdsak *BondedECDSAKeep) SignGasEstimate( - _digest [32]uint8, -) (uint64, error) { +func (becdsak *BondedECDSAKeep) CloseKeepGasEstimate() (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsak.callerOptions.From, becdsak.contractAddress, - "sign", + "closeKeep", becdsak.contractABI, becdsak.transactor, - _digest, ) return result, err @@ -1625,6 +1625,44 @@ func (becdsak *BondedECDSAKeep) SubmitSignatureGasEstimate( // ----- Const Methods ------ +func (becdsak *BondedECDSAKeep) Owner() (common.Address, error) { + var result common.Address + result, err := becdsak.contract.Owner( + becdsak.callerOptions, + ) + + if err != nil { + return result, becdsak.errorResolver.ResolveError( + err, + becdsak.callerOptions.From, + nil, + "owner", + ) + } + + return result, err +} + +func (becdsak *BondedECDSAKeep) OwnerAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := ethutil.CallAtBlock( + becdsak.callerOptions.From, + blockNumber, + nil, + becdsak.contractABI, + becdsak.caller, + becdsak.errorResolver, + becdsak.contractAddress, + "owner", + &result, + ) + + return result, err +} + func (becdsak *BondedECDSAKeep) Digest() ([32]uint8, error) { var result [32]uint8 result, err := becdsak.contract.Digest( @@ -1663,9 +1701,9 @@ func (becdsak *BondedECDSAKeep) DigestAtBlock( return result, err } -func (becdsak *BondedECDSAKeep) HonestThreshold() (*big.Int, error) { +func (becdsak *BondedECDSAKeep) GetOpenedTimestamp() (*big.Int, error) { var result *big.Int - result, err := becdsak.contract.HonestThreshold( + result, err := becdsak.contract.GetOpenedTimestamp( becdsak.callerOptions, ) @@ -1674,14 +1712,14 @@ func (becdsak *BondedECDSAKeep) HonestThreshold() (*big.Int, error) { err, becdsak.callerOptions.From, nil, - "honestThreshold", + "getOpenedTimestamp", ) } return result, err } -func (becdsak *BondedECDSAKeep) HonestThresholdAtBlock( +func (becdsak *BondedECDSAKeep) GetOpenedTimestampAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1694,17 +1732,28 @@ func (becdsak *BondedECDSAKeep) HonestThresholdAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "honestThreshold", + "getOpenedTimestamp", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) GetOwner() (common.Address, error) { - var result common.Address - result, err := becdsak.contract.GetOwner( +func (becdsak *BondedECDSAKeep) CheckSignatureFraud( + _v uint8, + _r [32]uint8, + _s [32]uint8, + _signedDigest [32]uint8, + _preimage []uint8, +) (bool, error) { + var result bool + result, err := becdsak.contract.CheckSignatureFraud( becdsak.callerOptions, + _v, + _r, + _s, + _signedDigest, + _preimage, ) if err != nil { @@ -1712,17 +1761,27 @@ func (becdsak *BondedECDSAKeep) GetOwner() (common.Address, error) { err, becdsak.callerOptions.From, nil, - "getOwner", + "checkSignatureFraud", + _v, + _r, + _s, + _signedDigest, + _preimage, ) } return result, err } -func (becdsak *BondedECDSAKeep) GetOwnerAtBlock( +func (becdsak *BondedECDSAKeep) CheckSignatureFraudAtBlock( + _v uint8, + _r [32]uint8, + _s [32]uint8, + _signedDigest [32]uint8, + _preimage []uint8, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -1732,20 +1791,22 @@ func (becdsak *BondedECDSAKeep) GetOwnerAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "getOwner", + "checkSignatureFraud", &result, + _v, + _r, + _s, + _signedDigest, + _preimage, ) return result, err } -func (becdsak *BondedECDSAKeep) IsAwaitingSignature( - _digest [32]uint8, -) (bool, error) { +func (becdsak *BondedECDSAKeep) IsClosed() (bool, error) { var result bool - result, err := becdsak.contract.IsAwaitingSignature( + result, err := becdsak.contract.IsClosed( becdsak.callerOptions, - _digest, ) if err != nil { @@ -1753,16 +1814,14 @@ func (becdsak *BondedECDSAKeep) IsAwaitingSignature( err, becdsak.callerOptions.From, nil, - "isAwaitingSignature", - _digest, + "isClosed", ) } return result, err } -func (becdsak *BondedECDSAKeep) IsAwaitingSignatureAtBlock( - _digest [32]uint8, +func (becdsak *BondedECDSAKeep) IsClosedAtBlock( blockNumber *big.Int, ) (bool, error) { var result bool @@ -1775,21 +1834,20 @@ func (becdsak *BondedECDSAKeep) IsAwaitingSignatureAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "isAwaitingSignature", + "isClosed", &result, - _digest, ) return result, err } -func (becdsak *BondedECDSAKeep) Members( - arg0 *big.Int, -) (common.Address, error) { - var result common.Address - result, err := becdsak.contract.Members( +func (becdsak *BondedECDSAKeep) IsAwaitingSignature( + _digest [32]uint8, +) (bool, error) { + var result bool + result, err := becdsak.contract.IsAwaitingSignature( becdsak.callerOptions, - arg0, + _digest, ) if err != nil { @@ -1797,19 +1855,19 @@ func (becdsak *BondedECDSAKeep) Members( err, becdsak.callerOptions.From, nil, - "members", - arg0, + "isAwaitingSignature", + _digest, ) } return result, err } -func (becdsak *BondedECDSAKeep) MembersAtBlock( - arg0 *big.Int, +func (becdsak *BondedECDSAKeep) IsAwaitingSignatureAtBlock( + _digest [32]uint8, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -1819,21 +1877,21 @@ func (becdsak *BondedECDSAKeep) MembersAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "members", + "isAwaitingSignature", &result, - arg0, + _digest, ) return result, err } -func (becdsak *BondedECDSAKeep) Digests( - arg0 [32]uint8, +func (becdsak *BondedECDSAKeep) GetMemberETHBalance( + _member common.Address, ) (*big.Int, error) { var result *big.Int - result, err := becdsak.contract.Digests( + result, err := becdsak.contract.GetMemberETHBalance( becdsak.callerOptions, - arg0, + _member, ) if err != nil { @@ -1841,16 +1899,16 @@ func (becdsak *BondedECDSAKeep) Digests( err, becdsak.callerOptions.From, nil, - "digests", - arg0, + "getMemberETHBalance", + _member, ) } return result, err } -func (becdsak *BondedECDSAKeep) DigestsAtBlock( - arg0 [32]uint8, +func (becdsak *BondedECDSAKeep) GetMemberETHBalanceAtBlock( + _member common.Address, blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1863,9 +1921,9 @@ func (becdsak *BondedECDSAKeep) DigestsAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "digests", + "getMemberETHBalance", &result, - arg0, + _member, ) return result, err @@ -1909,9 +1967,9 @@ func (becdsak *BondedECDSAKeep) IsActiveAtBlock( return result, err } -func (becdsak *BondedECDSAKeep) PublicKey() ([]uint8, error) { - var result []uint8 - result, err := becdsak.contract.PublicKey( +func (becdsak *BondedECDSAKeep) IsTerminated() (bool, error) { + var result bool + result, err := becdsak.contract.IsTerminated( becdsak.callerOptions, ) @@ -1920,17 +1978,17 @@ func (becdsak *BondedECDSAKeep) PublicKey() ([]uint8, error) { err, becdsak.callerOptions.From, nil, - "publicKey", + "isTerminated", ) } return result, err } -func (becdsak *BondedECDSAKeep) PublicKeyAtBlock( +func (becdsak *BondedECDSAKeep) IsTerminatedAtBlock( blockNumber *big.Int, -) ([]uint8, error) { - var result []uint8 +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -1940,16 +1998,16 @@ func (becdsak *BondedECDSAKeep) PublicKeyAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "publicKey", + "isTerminated", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) GetOpenedTimestamp() (*big.Int, error) { +func (becdsak *BondedECDSAKeep) MemberStake() (*big.Int, error) { var result *big.Int - result, err := becdsak.contract.GetOpenedTimestamp( + result, err := becdsak.contract.MemberStake( becdsak.callerOptions, ) @@ -1958,14 +2016,14 @@ func (becdsak *BondedECDSAKeep) GetOpenedTimestamp() (*big.Int, error) { err, becdsak.callerOptions.From, nil, - "getOpenedTimestamp", + "memberStake", ) } return result, err } -func (becdsak *BondedECDSAKeep) GetOpenedTimestampAtBlock( +func (becdsak *BondedECDSAKeep) MemberStakeAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1978,80 +2036,16 @@ func (becdsak *BondedECDSAKeep) GetOpenedTimestampAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "getOpenedTimestamp", - &result, - ) - - return result, err -} - -func (becdsak *BondedECDSAKeep) CheckSignatureFraud( - _v uint8, - _r [32]uint8, - _s [32]uint8, - _signedDigest [32]uint8, - _preimage []uint8, -) (bool, error) { - var result bool - result, err := becdsak.contract.CheckSignatureFraud( - becdsak.callerOptions, - _v, - _r, - _s, - _signedDigest, - _preimage, - ) - - if err != nil { - return result, becdsak.errorResolver.ResolveError( - err, - becdsak.callerOptions.From, - nil, - "checkSignatureFraud", - _v, - _r, - _s, - _signedDigest, - _preimage, - ) - } - - return result, err -} - -func (becdsak *BondedECDSAKeep) CheckSignatureFraudAtBlock( - _v uint8, - _r [32]uint8, - _s [32]uint8, - _signedDigest [32]uint8, - _preimage []uint8, - blockNumber *big.Int, -) (bool, error) { - var result bool - - err := ethutil.CallAtBlock( - becdsak.callerOptions.From, - blockNumber, - nil, - becdsak.contractABI, - becdsak.caller, - becdsak.errorResolver, - becdsak.contractAddress, - "checkSignatureFraud", + "memberStake", &result, - _v, - _r, - _s, - _signedDigest, - _preimage, ) return result, err } -func (becdsak *BondedECDSAKeep) IsTerminated() (bool, error) { - var result bool - result, err := becdsak.contract.IsTerminated( +func (becdsak *BondedECDSAKeep) GetOwner() (common.Address, error) { + var result common.Address + result, err := becdsak.contract.GetOwner( becdsak.callerOptions, ) @@ -2060,17 +2054,17 @@ func (becdsak *BondedECDSAKeep) IsTerminated() (bool, error) { err, becdsak.callerOptions.From, nil, - "isTerminated", + "getOwner", ) } return result, err } -func (becdsak *BondedECDSAKeep) IsTerminatedAtBlock( +func (becdsak *BondedECDSAKeep) GetOwnerAtBlock( blockNumber *big.Int, -) (bool, error) { - var result bool +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2080,16 +2074,16 @@ func (becdsak *BondedECDSAKeep) IsTerminatedAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "isTerminated", + "getOwner", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) Owner() (common.Address, error) { - var result common.Address - result, err := becdsak.contract.Owner( +func (becdsak *BondedECDSAKeep) HonestThreshold() (*big.Int, error) { + var result *big.Int + result, err := becdsak.contract.HonestThreshold( becdsak.callerOptions, ) @@ -2098,17 +2092,17 @@ func (becdsak *BondedECDSAKeep) Owner() (common.Address, error) { err, becdsak.callerOptions.From, nil, - "owner", + "honestThreshold", ) } return result, err } -func (becdsak *BondedECDSAKeep) OwnerAtBlock( +func (becdsak *BondedECDSAKeep) HonestThresholdAtBlock( blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2118,20 +2112,17 @@ func (becdsak *BondedECDSAKeep) OwnerAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "owner", + "honestThreshold", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) GetMemberETHBalance( - _member common.Address, -) (*big.Int, error) { - var result *big.Int - result, err := becdsak.contract.GetMemberETHBalance( +func (becdsak *BondedECDSAKeep) GetMembers() ([]common.Address, error) { + var result []common.Address + result, err := becdsak.contract.GetMembers( becdsak.callerOptions, - _member, ) if err != nil { @@ -2139,19 +2130,17 @@ func (becdsak *BondedECDSAKeep) GetMemberETHBalance( err, becdsak.callerOptions.From, nil, - "getMemberETHBalance", - _member, + "getMembers", ) } return result, err } -func (becdsak *BondedECDSAKeep) GetMemberETHBalanceAtBlock( - _member common.Address, +func (becdsak *BondedECDSAKeep) GetMembersAtBlock( blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) ([]common.Address, error) { + var result []common.Address err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2161,9 +2150,8 @@ func (becdsak *BondedECDSAKeep) GetMemberETHBalanceAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "getMemberETHBalance", + "getMembers", &result, - _member, ) return result, err @@ -2207,10 +2195,13 @@ func (becdsak *BondedECDSAKeep) GetPublicKeyAtBlock( return result, err } -func (becdsak *BondedECDSAKeep) IsClosed() (bool, error) { - var result bool - result, err := becdsak.contract.IsClosed( +func (becdsak *BondedECDSAKeep) Members( + arg0 *big.Int, +) (common.Address, error) { + var result common.Address + result, err := becdsak.contract.Members( becdsak.callerOptions, + arg0, ) if err != nil { @@ -2218,17 +2209,19 @@ func (becdsak *BondedECDSAKeep) IsClosed() (bool, error) { err, becdsak.callerOptions.From, nil, - "isClosed", + "members", + arg0, ) } return result, err } -func (becdsak *BondedECDSAKeep) IsClosedAtBlock( +func (becdsak *BondedECDSAKeep) MembersAtBlock( + arg0 *big.Int, blockNumber *big.Int, -) (bool, error) { - var result bool +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2238,16 +2231,17 @@ func (becdsak *BondedECDSAKeep) IsClosedAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "isClosed", + "members", &result, + arg0, ) return result, err } -func (becdsak *BondedECDSAKeep) CheckBondAmount() (*big.Int, error) { - var result *big.Int - result, err := becdsak.contract.CheckBondAmount( +func (becdsak *BondedECDSAKeep) PublicKey() ([]uint8, error) { + var result []uint8 + result, err := becdsak.contract.PublicKey( becdsak.callerOptions, ) @@ -2256,17 +2250,17 @@ func (becdsak *BondedECDSAKeep) CheckBondAmount() (*big.Int, error) { err, becdsak.callerOptions.From, nil, - "checkBondAmount", + "publicKey", ) } return result, err } -func (becdsak *BondedECDSAKeep) CheckBondAmountAtBlock( +func (becdsak *BondedECDSAKeep) PublicKeyAtBlock( blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) ([]uint8, error) { + var result []uint8 err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2276,16 +2270,16 @@ func (becdsak *BondedECDSAKeep) CheckBondAmountAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "checkBondAmount", + "publicKey", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) GetMembers() ([]common.Address, error) { - var result []common.Address - result, err := becdsak.contract.GetMembers( +func (becdsak *BondedECDSAKeep) CheckBondAmount() (*big.Int, error) { + var result *big.Int + result, err := becdsak.contract.CheckBondAmount( becdsak.callerOptions, ) @@ -2294,17 +2288,17 @@ func (becdsak *BondedECDSAKeep) GetMembers() ([]common.Address, error) { err, becdsak.callerOptions.From, nil, - "getMembers", + "checkBondAmount", ) } return result, err } -func (becdsak *BondedECDSAKeep) GetMembersAtBlock( +func (becdsak *BondedECDSAKeep) CheckBondAmountAtBlock( blockNumber *big.Int, -) ([]common.Address, error) { - var result []common.Address +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsak.callerOptions.From, @@ -2314,17 +2308,20 @@ func (becdsak *BondedECDSAKeep) GetMembersAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "getMembers", + "checkBondAmount", &result, ) return result, err } -func (becdsak *BondedECDSAKeep) MemberStake() (*big.Int, error) { +func (becdsak *BondedECDSAKeep) Digests( + arg0 [32]uint8, +) (*big.Int, error) { var result *big.Int - result, err := becdsak.contract.MemberStake( + result, err := becdsak.contract.Digests( becdsak.callerOptions, + arg0, ) if err != nil { @@ -2332,14 +2329,16 @@ func (becdsak *BondedECDSAKeep) MemberStake() (*big.Int, error) { err, becdsak.callerOptions.From, nil, - "memberStake", + "digests", + arg0, ) } return result, err } -func (becdsak *BondedECDSAKeep) MemberStakeAtBlock( +func (becdsak *BondedECDSAKeep) DigestsAtBlock( + arg0 [32]uint8, blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -2352,8 +2351,9 @@ func (becdsak *BondedECDSAKeep) MemberStakeAtBlock( becdsak.caller, becdsak.errorResolver, becdsak.contractAddress, - "memberStake", + "digests", &result, + arg0, ) return result, err @@ -2361,9 +2361,10 @@ func (becdsak *BondedECDSAKeep) MemberStakeAtBlock( // ------ Events ------- -func (becdsak *BondedECDSAKeep) KeepClosed( +func (becdsak *BondedECDSAKeep) ConflictingPublicKeySubmitted( opts *ethutil.SubscribeOpts, -) *KeepClosedSubscription { + submittingMemberFilter []common.Address, +) *ConflictingPublicKeySubmittedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -2374,25 +2375,29 @@ func (becdsak *BondedECDSAKeep) KeepClosed( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &KeepClosedSubscription{ + return &ConflictingPublicKeySubmittedSubscription{ becdsak, opts, + submittingMemberFilter, } } -type KeepClosedSubscription struct { - contract *BondedECDSAKeep - opts *ethutil.SubscribeOpts +type ConflictingPublicKeySubmittedSubscription struct { + contract *BondedECDSAKeep + opts *ethutil.SubscribeOpts + submittingMemberFilter []common.Address } -type bondedECDSAKeepKeepClosedFunc func( +type bondedECDSAKeepConflictingPublicKeySubmittedFunc func( + SubmittingMember common.Address, + ConflictingPublicKey []uint8, blockNumber uint64, ) -func (kcs *KeepClosedSubscription) OnEvent( - handler bondedECDSAKeepKeepClosedFunc, +func (cpkss *ConflictingPublicKeySubmittedSubscription) OnEvent( + handler bondedECDSAKeepConflictingPublicKeySubmittedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepKeepClosed) + eventChan := make(chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -2402,48 +2407,51 @@ func (kcs *KeepClosedSubscription) OnEvent( return case event := <-eventChan: handler( + event.SubmittingMember, + event.ConflictingPublicKey, event.Raw.BlockNumber, ) } } }() - sub := kcs.Pipe(eventChan) + sub := cpkss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (kcs *KeepClosedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepKeepClosed, +func (cpkss *ConflictingPublicKeySubmittedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(kcs.opts.Tick) + ticker := time.NewTicker(cpkss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := kcs.contract.blockCounter.CurrentBlock() + lastBlock, err := cpkss.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - kcs.opts.PastBlocks + fromBlock := lastBlock - cpkss.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past KeepClosed events "+ + "subscription monitoring fetching past ConflictingPublicKeySubmitted events "+ "starting from block [%v]", fromBlock, ) - events, err := kcs.contract.PastKeepClosedEvents( + events, err := cpkss.contract.PastConflictingPublicKeySubmittedEvents( fromBlock, nil, + cpkss.submittingMemberFilter, ) if err != nil { becdsakLogger.Errorf( @@ -2453,7 +2461,7 @@ func (kcs *KeepClosedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past KeepClosed events", + "subscription monitoring fetched [%v] past ConflictingPublicKeySubmitted events", len(events), ) @@ -2464,8 +2472,9 @@ func (kcs *KeepClosedSubscription) Pipe( } }() - sub := kcs.contract.watchKeepClosed( + sub := cpkss.contract.watchConflictingPublicKeySubmitted( sink, + cpkss.submittingMemberFilter, ) return subscription.NewEventSubscription(func() { @@ -2474,19 +2483,21 @@ func (kcs *KeepClosedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchKeepClosed( - sink chan *abi.BondedECDSAKeepKeepClosed, +func (becdsak *BondedECDSAKeep) watchConflictingPublicKeySubmitted( + sink chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted, + submittingMemberFilter []common.Address, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchKeepClosed( + return becdsak.contract.WatchConflictingPublicKeySubmitted( &bind.WatchOpts{Context: ctx}, sink, + submittingMemberFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event KeepClosed had to be "+ + "subscription to event ConflictingPublicKeySubmitted had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -2495,7 +2506,7 @@ func (becdsak *BondedECDSAKeep) watchKeepClosed( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event KeepClosed failed "+ + "subscription to event ConflictingPublicKeySubmitted failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -2511,24 +2522,26 @@ func (becdsak *BondedECDSAKeep) watchKeepClosed( ) } -func (becdsak *BondedECDSAKeep) PastKeepClosedEvents( +func (becdsak *BondedECDSAKeep) PastConflictingPublicKeySubmittedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepKeepClosed, error) { - iterator, err := becdsak.contract.FilterKeepClosed( + submittingMemberFilter []common.Address, +) ([]*abi.BondedECDSAKeepConflictingPublicKeySubmitted, error) { + iterator, err := becdsak.contract.FilterConflictingPublicKeySubmitted( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + submittingMemberFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past KeepClosed events: [%v]", + "error retrieving past ConflictingPublicKeySubmitted events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepKeepClosed, 0) + events := make([]*abi.BondedECDSAKeepConflictingPublicKeySubmitted, 0) for iterator.Next() { event := iterator.Event @@ -2538,9 +2551,9 @@ func (becdsak *BondedECDSAKeep) PastKeepClosedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) KeepTerminated( +func (becdsak *BondedECDSAKeep) KeepClosed( opts *ethutil.SubscribeOpts, -) *KeepTerminatedSubscription { +) *KeepClosedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -2551,25 +2564,25 @@ func (becdsak *BondedECDSAKeep) KeepTerminated( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &KeepTerminatedSubscription{ + return &KeepClosedSubscription{ becdsak, opts, } } -type KeepTerminatedSubscription struct { +type KeepClosedSubscription struct { contract *BondedECDSAKeep opts *ethutil.SubscribeOpts } -type bondedECDSAKeepKeepTerminatedFunc func( +type bondedECDSAKeepKeepClosedFunc func( blockNumber uint64, ) -func (kts *KeepTerminatedSubscription) OnEvent( - handler bondedECDSAKeepKeepTerminatedFunc, +func (kcs *KeepClosedSubscription) OnEvent( + handler bondedECDSAKeepKeepClosedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepKeepTerminated) + eventChan := make(chan *abi.BondedECDSAKeepKeepClosed) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -2585,40 +2598,40 @@ func (kts *KeepTerminatedSubscription) OnEvent( } }() - sub := kts.Pipe(eventChan) + sub := kcs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (kts *KeepTerminatedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepKeepTerminated, +func (kcs *KeepClosedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepKeepClosed, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(kts.opts.Tick) + ticker := time.NewTicker(kcs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := kts.contract.blockCounter.CurrentBlock() + lastBlock, err := kcs.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - kts.opts.PastBlocks + fromBlock := lastBlock - kcs.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past KeepTerminated events "+ + "subscription monitoring fetching past KeepClosed events "+ "starting from block [%v]", fromBlock, ) - events, err := kts.contract.PastKeepTerminatedEvents( + events, err := kcs.contract.PastKeepClosedEvents( fromBlock, nil, ) @@ -2630,7 +2643,7 @@ func (kts *KeepTerminatedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past KeepTerminated events", + "subscription monitoring fetched [%v] past KeepClosed events", len(events), ) @@ -2641,7 +2654,7 @@ func (kts *KeepTerminatedSubscription) Pipe( } }() - sub := kts.contract.watchKeepTerminated( + sub := kcs.contract.watchKeepClosed( sink, ) @@ -2651,11 +2664,11 @@ func (kts *KeepTerminatedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchKeepTerminated( - sink chan *abi.BondedECDSAKeepKeepTerminated, +func (becdsak *BondedECDSAKeep) watchKeepClosed( + sink chan *abi.BondedECDSAKeepKeepClosed, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchKeepTerminated( + return becdsak.contract.WatchKeepClosed( &bind.WatchOpts{Context: ctx}, sink, ) @@ -2663,7 +2676,7 @@ func (becdsak *BondedECDSAKeep) watchKeepTerminated( thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event KeepTerminated had to be "+ + "subscription to event KeepClosed had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -2672,7 +2685,7 @@ func (becdsak *BondedECDSAKeep) watchKeepTerminated( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event KeepTerminated failed "+ + "subscription to event KeepClosed failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -2688,11 +2701,11 @@ func (becdsak *BondedECDSAKeep) watchKeepTerminated( ) } -func (becdsak *BondedECDSAKeep) PastKeepTerminatedEvents( +func (becdsak *BondedECDSAKeep) PastKeepClosedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepKeepTerminated, error) { - iterator, err := becdsak.contract.FilterKeepTerminated( +) ([]*abi.BondedECDSAKeepKeepClosed, error) { + iterator, err := becdsak.contract.FilterKeepClosed( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -2700,12 +2713,12 @@ func (becdsak *BondedECDSAKeep) PastKeepTerminatedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past KeepTerminated events: [%v]", + "error retrieving past KeepClosed events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepKeepTerminated, 0) + events := make([]*abi.BondedECDSAKeepKeepClosed, 0) for iterator.Next() { event := iterator.Event @@ -2715,10 +2728,9 @@ func (becdsak *BondedECDSAKeep) PastKeepTerminatedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) SignatureRequested( +func (becdsak *BondedECDSAKeep) KeepTerminated( opts *ethutil.SubscribeOpts, - digestFilter [][32]uint8, -) *SignatureRequestedSubscription { +) *KeepTerminatedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -2729,28 +2741,25 @@ func (becdsak *BondedECDSAKeep) SignatureRequested( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &SignatureRequestedSubscription{ + return &KeepTerminatedSubscription{ becdsak, opts, - digestFilter, } } -type SignatureRequestedSubscription struct { - contract *BondedECDSAKeep - opts *ethutil.SubscribeOpts - digestFilter [][32]uint8 +type KeepTerminatedSubscription struct { + contract *BondedECDSAKeep + opts *ethutil.SubscribeOpts } -type bondedECDSAKeepSignatureRequestedFunc func( - Digest [32]uint8, +type bondedECDSAKeepKeepTerminatedFunc func( blockNumber uint64, ) -func (srs *SignatureRequestedSubscription) OnEvent( - handler bondedECDSAKeepSignatureRequestedFunc, +func (kts *KeepTerminatedSubscription) OnEvent( + handler bondedECDSAKeepKeepTerminatedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepSignatureRequested) + eventChan := make(chan *abi.BondedECDSAKeepKeepTerminated) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -2760,50 +2769,48 @@ func (srs *SignatureRequestedSubscription) OnEvent( return case event := <-eventChan: handler( - event.Digest, event.Raw.BlockNumber, ) } } }() - sub := srs.Pipe(eventChan) + sub := kts.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (srs *SignatureRequestedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepSignatureRequested, +func (kts *KeepTerminatedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepKeepTerminated, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(srs.opts.Tick) + ticker := time.NewTicker(kts.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := srs.contract.blockCounter.CurrentBlock() + lastBlock, err := kts.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - srs.opts.PastBlocks + fromBlock := lastBlock - kts.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past SignatureRequested events "+ + "subscription monitoring fetching past KeepTerminated events "+ "starting from block [%v]", fromBlock, ) - events, err := srs.contract.PastSignatureRequestedEvents( + events, err := kts.contract.PastKeepTerminatedEvents( fromBlock, nil, - srs.digestFilter, ) if err != nil { becdsakLogger.Errorf( @@ -2813,7 +2820,7 @@ func (srs *SignatureRequestedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past SignatureRequested events", + "subscription monitoring fetched [%v] past KeepTerminated events", len(events), ) @@ -2824,9 +2831,8 @@ func (srs *SignatureRequestedSubscription) Pipe( } }() - sub := srs.contract.watchSignatureRequested( + sub := kts.contract.watchKeepTerminated( sink, - srs.digestFilter, ) return subscription.NewEventSubscription(func() { @@ -2835,21 +2841,19 @@ func (srs *SignatureRequestedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchSignatureRequested( - sink chan *abi.BondedECDSAKeepSignatureRequested, - digestFilter [][32]uint8, +func (becdsak *BondedECDSAKeep) watchKeepTerminated( + sink chan *abi.BondedECDSAKeepKeepTerminated, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchSignatureRequested( + return becdsak.contract.WatchKeepTerminated( &bind.WatchOpts{Context: ctx}, sink, - digestFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event SignatureRequested had to be "+ + "subscription to event KeepTerminated had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -2858,7 +2862,7 @@ func (becdsak *BondedECDSAKeep) watchSignatureRequested( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event SignatureRequested failed "+ + "subscription to event KeepTerminated failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -2874,26 +2878,24 @@ func (becdsak *BondedECDSAKeep) watchSignatureRequested( ) } -func (becdsak *BondedECDSAKeep) PastSignatureRequestedEvents( +func (becdsak *BondedECDSAKeep) PastKeepTerminatedEvents( startBlock uint64, endBlock *uint64, - digestFilter [][32]uint8, -) ([]*abi.BondedECDSAKeepSignatureRequested, error) { - iterator, err := becdsak.contract.FilterSignatureRequested( +) ([]*abi.BondedECDSAKeepKeepTerminated, error) { + iterator, err := becdsak.contract.FilterKeepTerminated( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - digestFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past SignatureRequested events: [%v]", + "error retrieving past KeepTerminated events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepSignatureRequested, 0) + events := make([]*abi.BondedECDSAKeepKeepTerminated, 0) for iterator.Next() { event := iterator.Event @@ -2903,10 +2905,9 @@ func (becdsak *BondedECDSAKeep) PastSignatureRequestedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) ConflictingPublicKeySubmitted( +func (becdsak *BondedECDSAKeep) PublicKeyPublished( opts *ethutil.SubscribeOpts, - submittingMemberFilter []common.Address, -) *ConflictingPublicKeySubmittedSubscription { +) *PublicKeyPublishedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -2917,29 +2918,26 @@ func (becdsak *BondedECDSAKeep) ConflictingPublicKeySubmitted( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &ConflictingPublicKeySubmittedSubscription{ + return &PublicKeyPublishedSubscription{ becdsak, opts, - submittingMemberFilter, } } -type ConflictingPublicKeySubmittedSubscription struct { - contract *BondedECDSAKeep - opts *ethutil.SubscribeOpts - submittingMemberFilter []common.Address +type PublicKeyPublishedSubscription struct { + contract *BondedECDSAKeep + opts *ethutil.SubscribeOpts } -type bondedECDSAKeepConflictingPublicKeySubmittedFunc func( - SubmittingMember common.Address, - ConflictingPublicKey []uint8, +type bondedECDSAKeepPublicKeyPublishedFunc func( + PublicKey []uint8, blockNumber uint64, ) -func (cpkss *ConflictingPublicKeySubmittedSubscription) OnEvent( - handler bondedECDSAKeepConflictingPublicKeySubmittedFunc, +func (pkps *PublicKeyPublishedSubscription) OnEvent( + handler bondedECDSAKeepPublicKeyPublishedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted) + eventChan := make(chan *abi.BondedECDSAKeepPublicKeyPublished) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -2949,51 +2947,49 @@ func (cpkss *ConflictingPublicKeySubmittedSubscription) OnEvent( return case event := <-eventChan: handler( - event.SubmittingMember, - event.ConflictingPublicKey, + event.PublicKey, event.Raw.BlockNumber, ) } } }() - sub := cpkss.Pipe(eventChan) + sub := pkps.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (cpkss *ConflictingPublicKeySubmittedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted, +func (pkps *PublicKeyPublishedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepPublicKeyPublished, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(cpkss.opts.Tick) + ticker := time.NewTicker(pkps.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := cpkss.contract.blockCounter.CurrentBlock() + lastBlock, err := pkps.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - cpkss.opts.PastBlocks + fromBlock := lastBlock - pkps.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past ConflictingPublicKeySubmitted events "+ + "subscription monitoring fetching past PublicKeyPublished events "+ "starting from block [%v]", fromBlock, ) - events, err := cpkss.contract.PastConflictingPublicKeySubmittedEvents( + events, err := pkps.contract.PastPublicKeyPublishedEvents( fromBlock, nil, - cpkss.submittingMemberFilter, ) if err != nil { becdsakLogger.Errorf( @@ -3003,7 +2999,7 @@ func (cpkss *ConflictingPublicKeySubmittedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past ConflictingPublicKeySubmitted events", + "subscription monitoring fetched [%v] past PublicKeyPublished events", len(events), ) @@ -3014,9 +3010,8 @@ func (cpkss *ConflictingPublicKeySubmittedSubscription) Pipe( } }() - sub := cpkss.contract.watchConflictingPublicKeySubmitted( + sub := pkps.contract.watchPublicKeyPublished( sink, - cpkss.submittingMemberFilter, ) return subscription.NewEventSubscription(func() { @@ -3025,21 +3020,19 @@ func (cpkss *ConflictingPublicKeySubmittedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchConflictingPublicKeySubmitted( - sink chan *abi.BondedECDSAKeepConflictingPublicKeySubmitted, - submittingMemberFilter []common.Address, +func (becdsak *BondedECDSAKeep) watchPublicKeyPublished( + sink chan *abi.BondedECDSAKeepPublicKeyPublished, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchConflictingPublicKeySubmitted( + return becdsak.contract.WatchPublicKeyPublished( &bind.WatchOpts{Context: ctx}, sink, - submittingMemberFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event ConflictingPublicKeySubmitted had to be "+ + "subscription to event PublicKeyPublished had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -3048,7 +3041,7 @@ func (becdsak *BondedECDSAKeep) watchConflictingPublicKeySubmitted( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event ConflictingPublicKeySubmitted failed "+ + "subscription to event PublicKeyPublished failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -3064,26 +3057,24 @@ func (becdsak *BondedECDSAKeep) watchConflictingPublicKeySubmitted( ) } -func (becdsak *BondedECDSAKeep) PastConflictingPublicKeySubmittedEvents( +func (becdsak *BondedECDSAKeep) PastPublicKeyPublishedEvents( startBlock uint64, endBlock *uint64, - submittingMemberFilter []common.Address, -) ([]*abi.BondedECDSAKeepConflictingPublicKeySubmitted, error) { - iterator, err := becdsak.contract.FilterConflictingPublicKeySubmitted( +) ([]*abi.BondedECDSAKeepPublicKeyPublished, error) { + iterator, err := becdsak.contract.FilterPublicKeyPublished( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - submittingMemberFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past ConflictingPublicKeySubmitted events: [%v]", + "error retrieving past PublicKeyPublished events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepConflictingPublicKeySubmitted, 0) + events := make([]*abi.BondedECDSAKeepPublicKeyPublished, 0) for iterator.Next() { event := iterator.Event @@ -3093,10 +3084,10 @@ func (becdsak *BondedECDSAKeep) PastConflictingPublicKeySubmittedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) ERC20RewardDistributed( +func (becdsak *BondedECDSAKeep) SignatureRequested( opts *ethutil.SubscribeOpts, - tokenFilter []common.Address, -) *ERC20RewardDistributedSubscription { + digestFilter [][32]uint8, +) *SignatureRequestedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -3107,29 +3098,28 @@ func (becdsak *BondedECDSAKeep) ERC20RewardDistributed( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &ERC20RewardDistributedSubscription{ + return &SignatureRequestedSubscription{ becdsak, opts, - tokenFilter, + digestFilter, } } -type ERC20RewardDistributedSubscription struct { - contract *BondedECDSAKeep - opts *ethutil.SubscribeOpts - tokenFilter []common.Address +type SignatureRequestedSubscription struct { + contract *BondedECDSAKeep + opts *ethutil.SubscribeOpts + digestFilter [][32]uint8 } -type bondedECDSAKeepERC20RewardDistributedFunc func( - Token common.Address, - Amount *big.Int, +type bondedECDSAKeepSignatureRequestedFunc func( + Digest [32]uint8, blockNumber uint64, ) -func (ercrds *ERC20RewardDistributedSubscription) OnEvent( - handler bondedECDSAKeepERC20RewardDistributedFunc, +func (srs *SignatureRequestedSubscription) OnEvent( + handler bondedECDSAKeepSignatureRequestedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepERC20RewardDistributed) + eventChan := make(chan *abi.BondedECDSAKeepSignatureRequested) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -3139,51 +3129,50 @@ func (ercrds *ERC20RewardDistributedSubscription) OnEvent( return case event := <-eventChan: handler( - event.Token, - event.Amount, + event.Digest, event.Raw.BlockNumber, ) } } }() - sub := ercrds.Pipe(eventChan) + sub := srs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (ercrds *ERC20RewardDistributedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepERC20RewardDistributed, +func (srs *SignatureRequestedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepSignatureRequested, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(ercrds.opts.Tick) + ticker := time.NewTicker(srs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := ercrds.contract.blockCounter.CurrentBlock() + lastBlock, err := srs.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - ercrds.opts.PastBlocks + fromBlock := lastBlock - srs.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past ERC20RewardDistributed events "+ + "subscription monitoring fetching past SignatureRequested events "+ "starting from block [%v]", fromBlock, ) - events, err := ercrds.contract.PastERC20RewardDistributedEvents( + events, err := srs.contract.PastSignatureRequestedEvents( fromBlock, nil, - ercrds.tokenFilter, + srs.digestFilter, ) if err != nil { becdsakLogger.Errorf( @@ -3193,7 +3182,7 @@ func (ercrds *ERC20RewardDistributedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past ERC20RewardDistributed events", + "subscription monitoring fetched [%v] past SignatureRequested events", len(events), ) @@ -3204,9 +3193,9 @@ func (ercrds *ERC20RewardDistributedSubscription) Pipe( } }() - sub := ercrds.contract.watchERC20RewardDistributed( + sub := srs.contract.watchSignatureRequested( sink, - ercrds.tokenFilter, + srs.digestFilter, ) return subscription.NewEventSubscription(func() { @@ -3215,21 +3204,21 @@ func (ercrds *ERC20RewardDistributedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchERC20RewardDistributed( - sink chan *abi.BondedECDSAKeepERC20RewardDistributed, - tokenFilter []common.Address, +func (becdsak *BondedECDSAKeep) watchSignatureRequested( + sink chan *abi.BondedECDSAKeepSignatureRequested, + digestFilter [][32]uint8, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchERC20RewardDistributed( + return becdsak.contract.WatchSignatureRequested( &bind.WatchOpts{Context: ctx}, sink, - tokenFilter, + digestFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event ERC20RewardDistributed had to be "+ + "subscription to event SignatureRequested had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -3238,7 +3227,7 @@ func (becdsak *BondedECDSAKeep) watchERC20RewardDistributed( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event ERC20RewardDistributed failed "+ + "subscription to event SignatureRequested failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -3254,26 +3243,26 @@ func (becdsak *BondedECDSAKeep) watchERC20RewardDistributed( ) } -func (becdsak *BondedECDSAKeep) PastERC20RewardDistributedEvents( +func (becdsak *BondedECDSAKeep) PastSignatureRequestedEvents( startBlock uint64, endBlock *uint64, - tokenFilter []common.Address, -) ([]*abi.BondedECDSAKeepERC20RewardDistributed, error) { - iterator, err := becdsak.contract.FilterERC20RewardDistributed( + digestFilter [][32]uint8, +) ([]*abi.BondedECDSAKeepSignatureRequested, error) { + iterator, err := becdsak.contract.FilterSignatureRequested( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - tokenFilter, + digestFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past ERC20RewardDistributed events: [%v]", + "error retrieving past SignatureRequested events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepERC20RewardDistributed, 0) + events := make([]*abi.BondedECDSAKeepSignatureRequested, 0) for iterator.Next() { event := iterator.Event @@ -3283,9 +3272,10 @@ func (becdsak *BondedECDSAKeep) PastERC20RewardDistributedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) ETHRewardDistributed( +func (becdsak *BondedECDSAKeep) ERC20RewardDistributed( opts *ethutil.SubscribeOpts, -) *ETHRewardDistributedSubscription { + tokenFilter []common.Address, +) *ERC20RewardDistributedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -3296,26 +3286,29 @@ func (becdsak *BondedECDSAKeep) ETHRewardDistributed( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return ÐRewardDistributedSubscription{ + return &ERC20RewardDistributedSubscription{ becdsak, opts, + tokenFilter, } } -type ETHRewardDistributedSubscription struct { - contract *BondedECDSAKeep - opts *ethutil.SubscribeOpts +type ERC20RewardDistributedSubscription struct { + contract *BondedECDSAKeep + opts *ethutil.SubscribeOpts + tokenFilter []common.Address } -type bondedECDSAKeepETHRewardDistributedFunc func( +type bondedECDSAKeepERC20RewardDistributedFunc func( + Token common.Address, Amount *big.Int, blockNumber uint64, ) -func (ethrds *ETHRewardDistributedSubscription) OnEvent( - handler bondedECDSAKeepETHRewardDistributedFunc, +func (ercrds *ERC20RewardDistributedSubscription) OnEvent( + handler bondedECDSAKeepERC20RewardDistributedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepETHRewardDistributed) + eventChan := make(chan *abi.BondedECDSAKeepERC20RewardDistributed) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -3325,6 +3318,7 @@ func (ethrds *ETHRewardDistributedSubscription) OnEvent( return case event := <-eventChan: handler( + event.Token, event.Amount, event.Raw.BlockNumber, ) @@ -3332,42 +3326,43 @@ func (ethrds *ETHRewardDistributedSubscription) OnEvent( } }() - sub := ethrds.Pipe(eventChan) + sub := ercrds.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (ethrds *ETHRewardDistributedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepETHRewardDistributed, +func (ercrds *ERC20RewardDistributedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepERC20RewardDistributed, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(ethrds.opts.Tick) + ticker := time.NewTicker(ercrds.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := ethrds.contract.blockCounter.CurrentBlock() + lastBlock, err := ercrds.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - ethrds.opts.PastBlocks + fromBlock := lastBlock - ercrds.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past ETHRewardDistributed events "+ + "subscription monitoring fetching past ERC20RewardDistributed events "+ "starting from block [%v]", fromBlock, ) - events, err := ethrds.contract.PastETHRewardDistributedEvents( + events, err := ercrds.contract.PastERC20RewardDistributedEvents( fromBlock, nil, + ercrds.tokenFilter, ) if err != nil { becdsakLogger.Errorf( @@ -3377,7 +3372,7 @@ func (ethrds *ETHRewardDistributedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past ETHRewardDistributed events", + "subscription monitoring fetched [%v] past ERC20RewardDistributed events", len(events), ) @@ -3388,8 +3383,9 @@ func (ethrds *ETHRewardDistributedSubscription) Pipe( } }() - sub := ethrds.contract.watchETHRewardDistributed( + sub := ercrds.contract.watchERC20RewardDistributed( sink, + ercrds.tokenFilter, ) return subscription.NewEventSubscription(func() { @@ -3398,19 +3394,21 @@ func (ethrds *ETHRewardDistributedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchETHRewardDistributed( - sink chan *abi.BondedECDSAKeepETHRewardDistributed, +func (becdsak *BondedECDSAKeep) watchERC20RewardDistributed( + sink chan *abi.BondedECDSAKeepERC20RewardDistributed, + tokenFilter []common.Address, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchETHRewardDistributed( + return becdsak.contract.WatchERC20RewardDistributed( &bind.WatchOpts{Context: ctx}, sink, + tokenFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event ETHRewardDistributed had to be "+ + "subscription to event ERC20RewardDistributed had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -3419,7 +3417,7 @@ func (becdsak *BondedECDSAKeep) watchETHRewardDistributed( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event ETHRewardDistributed failed "+ + "subscription to event ERC20RewardDistributed failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -3435,24 +3433,26 @@ func (becdsak *BondedECDSAKeep) watchETHRewardDistributed( ) } -func (becdsak *BondedECDSAKeep) PastETHRewardDistributedEvents( +func (becdsak *BondedECDSAKeep) PastERC20RewardDistributedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepETHRewardDistributed, error) { - iterator, err := becdsak.contract.FilterETHRewardDistributed( + tokenFilter []common.Address, +) ([]*abi.BondedECDSAKeepERC20RewardDistributed, error) { + iterator, err := becdsak.contract.FilterERC20RewardDistributed( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + tokenFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past ETHRewardDistributed events: [%v]", + "error retrieving past ERC20RewardDistributed events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepETHRewardDistributed, 0) + events := make([]*abi.BondedECDSAKeepERC20RewardDistributed, 0) for iterator.Next() { event := iterator.Event @@ -3462,9 +3462,9 @@ func (becdsak *BondedECDSAKeep) PastETHRewardDistributedEvents( return events, nil } -func (becdsak *BondedECDSAKeep) PublicKeyPublished( +func (becdsak *BondedECDSAKeep) ETHRewardDistributed( opts *ethutil.SubscribeOpts, -) *PublicKeyPublishedSubscription { +) *ETHRewardDistributedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -3475,26 +3475,26 @@ func (becdsak *BondedECDSAKeep) PublicKeyPublished( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &PublicKeyPublishedSubscription{ + return ÐRewardDistributedSubscription{ becdsak, opts, } } -type PublicKeyPublishedSubscription struct { +type ETHRewardDistributedSubscription struct { contract *BondedECDSAKeep opts *ethutil.SubscribeOpts } -type bondedECDSAKeepPublicKeyPublishedFunc func( - PublicKey []uint8, +type bondedECDSAKeepETHRewardDistributedFunc func( + Amount *big.Int, blockNumber uint64, ) -func (pkps *PublicKeyPublishedSubscription) OnEvent( - handler bondedECDSAKeepPublicKeyPublishedFunc, +func (ethrds *ETHRewardDistributedSubscription) OnEvent( + handler bondedECDSAKeepETHRewardDistributedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepPublicKeyPublished) + eventChan := make(chan *abi.BondedECDSAKeepETHRewardDistributed) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -3504,47 +3504,47 @@ func (pkps *PublicKeyPublishedSubscription) OnEvent( return case event := <-eventChan: handler( - event.PublicKey, + event.Amount, event.Raw.BlockNumber, ) } } }() - sub := pkps.Pipe(eventChan) + sub := ethrds.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (pkps *PublicKeyPublishedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepPublicKeyPublished, +func (ethrds *ETHRewardDistributedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepETHRewardDistributed, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(pkps.opts.Tick) + ticker := time.NewTicker(ethrds.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := pkps.contract.blockCounter.CurrentBlock() + lastBlock, err := ethrds.contract.blockCounter.CurrentBlock() if err != nil { becdsakLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - pkps.opts.PastBlocks + fromBlock := lastBlock - ethrds.opts.PastBlocks becdsakLogger.Infof( - "subscription monitoring fetching past PublicKeyPublished events "+ + "subscription monitoring fetching past ETHRewardDistributed events "+ "starting from block [%v]", fromBlock, ) - events, err := pkps.contract.PastPublicKeyPublishedEvents( + events, err := ethrds.contract.PastETHRewardDistributedEvents( fromBlock, nil, ) @@ -3556,7 +3556,7 @@ func (pkps *PublicKeyPublishedSubscription) Pipe( continue } becdsakLogger.Infof( - "subscription monitoring fetched [%v] past PublicKeyPublished events", + "subscription monitoring fetched [%v] past ETHRewardDistributed events", len(events), ) @@ -3567,7 +3567,7 @@ func (pkps *PublicKeyPublishedSubscription) Pipe( } }() - sub := pkps.contract.watchPublicKeyPublished( + sub := ethrds.contract.watchETHRewardDistributed( sink, ) @@ -3577,11 +3577,11 @@ func (pkps *PublicKeyPublishedSubscription) Pipe( }) } -func (becdsak *BondedECDSAKeep) watchPublicKeyPublished( - sink chan *abi.BondedECDSAKeepPublicKeyPublished, +func (becdsak *BondedECDSAKeep) watchETHRewardDistributed( + sink chan *abi.BondedECDSAKeepETHRewardDistributed, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsak.contract.WatchPublicKeyPublished( + return becdsak.contract.WatchETHRewardDistributed( &bind.WatchOpts{Context: ctx}, sink, ) @@ -3589,7 +3589,7 @@ func (becdsak *BondedECDSAKeep) watchPublicKeyPublished( thresholdViolatedFn := func(elapsed time.Duration) { becdsakLogger.Errorf( - "subscription to event PublicKeyPublished had to be "+ + "subscription to event ETHRewardDistributed had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -3598,7 +3598,7 @@ func (becdsak *BondedECDSAKeep) watchPublicKeyPublished( subscriptionFailedFn := func(err error) { becdsakLogger.Errorf( - "subscription to event PublicKeyPublished failed "+ + "subscription to event ETHRewardDistributed failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -3614,11 +3614,11 @@ func (becdsak *BondedECDSAKeep) watchPublicKeyPublished( ) } -func (becdsak *BondedECDSAKeep) PastPublicKeyPublishedEvents( +func (becdsak *BondedECDSAKeep) PastETHRewardDistributedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepPublicKeyPublished, error) { - iterator, err := becdsak.contract.FilterPublicKeyPublished( +) ([]*abi.BondedECDSAKeepETHRewardDistributed, error) { + iterator, err := becdsak.contract.FilterETHRewardDistributed( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -3626,12 +3626,12 @@ func (becdsak *BondedECDSAKeep) PastPublicKeyPublishedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past PublicKeyPublished events: [%v]", + "error retrieving past ETHRewardDistributed events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepPublicKeyPublished, 0) + events := make([]*abi.BondedECDSAKeepETHRewardDistributed, 0) for iterator.Next() { event := iterator.Event diff --git a/pkg/chain/gen/contract/BondedECDSAKeepFactory.go b/pkg/chain/gen/contract/BondedECDSAKeepFactory.go index d4b56c5e5..a9a87c944 100644 --- a/pkg/chain/gen/contract/BondedECDSAKeepFactory.go +++ b/pkg/chain/gen/contract/BondedECDSAKeepFactory.go @@ -99,127 +99,6 @@ func NewBondedECDSAKeepFactory( // ----- Non-const Methods ------ -// Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) RequestNewGroupSelectionSeed( - value *big.Int, - - transactionOptions ...ethutil.TransactionOptions, -) (*types.Transaction, error) { - becdsakfLogger.Debug( - "submitting transaction requestNewGroupSelectionSeed", - "value: ", value, - ) - - becdsakf.transactionMutex.Lock() - defer becdsakf.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *becdsakf.transactorOptions - - transactorOptions.Value = value - - if len(transactionOptions) > 1 { - return nil, fmt.Errorf( - "could not process multiple transaction options sets", - ) - } else if len(transactionOptions) > 0 { - transactionOptions[0].Apply(transactorOptions) - } - - nonce, err := becdsakf.nonceManager.CurrentNonce() - if err != nil { - return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) - } - - transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - - transaction, err := becdsakf.contract.RequestNewGroupSelectionSeed( - transactorOptions, - ) - if err != nil { - return transaction, becdsakf.errorResolver.ResolveError( - err, - becdsakf.transactorOptions.From, - value, - "requestNewGroupSelectionSeed", - ) - } - - becdsakfLogger.Infof( - "submitted transaction requestNewGroupSelectionSeed with id: [%v] and nonce [%v]", - transaction.Hash().Hex(), - transaction.Nonce(), - ) - - go becdsakf.miningWaiter.ForceMining( - transaction, - func(newGasPrice *big.Int) (*types.Transaction, error) { - transactorOptions.GasLimit = transaction.Gas() - transactorOptions.GasPrice = newGasPrice - - transaction, err := becdsakf.contract.RequestNewGroupSelectionSeed( - transactorOptions, - ) - if err != nil { - return transaction, becdsakf.errorResolver.ResolveError( - err, - becdsakf.transactorOptions.From, - value, - "requestNewGroupSelectionSeed", - ) - } - - becdsakfLogger.Infof( - "submitted transaction requestNewGroupSelectionSeed with id: [%v] and nonce [%v]", - transaction.Hash().Hex(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - becdsakf.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallRequestNewGroupSelectionSeed( - value *big.Int, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := ethutil.CallAtBlock( - becdsakf.transactorOptions.From, - blockNumber, value, - becdsakf.contractABI, - becdsakf.caller, - becdsakf.errorResolver, - becdsakf.contractAddress, - "requestNewGroupSelectionSeed", - &result, - ) - - return err -} - -func (becdsakf *BondedECDSAKeepFactory) RequestNewGroupSelectionSeedGasEstimate() (uint64, error) { - var result uint64 - - result, err := ethutil.EstimateGas( - becdsakf.callerOptions.From, - becdsakf.contractAddress, - "requestNewGroupSelectionSeed", - becdsakf.contractABI, - becdsakf.transactor, - ) - - return result, err -} - // Transaction submission. func (becdsakf *BondedECDSAKeepFactory) OpenKeep( _groupSize *big.Int, @@ -396,16 +275,16 @@ func (becdsakf *BondedECDSAKeepFactory) OpenKeepGasEstimate( } // Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidate( - _application common.Address, +func (becdsakf *BondedECDSAKeepFactory) BeaconCallback( + _relayEntry *big.Int, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakfLogger.Debug( - "submitting transaction registerMemberCandidate", + "submitting transaction beaconCallback", "params: ", fmt.Sprint( - _application, + _relayEntry, ), ) @@ -431,22 +310,22 @@ func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidate( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakf.contract.RegisterMemberCandidate( + transaction, err := becdsakf.contract.BeaconCallback( transactorOptions, - _application, + _relayEntry, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "registerMemberCandidate", - _application, + "beaconCallback", + _relayEntry, ) } becdsakfLogger.Infof( - "submitted transaction registerMemberCandidate with id: [%v] and nonce [%v]", + "submitted transaction beaconCallback with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -457,22 +336,22 @@ func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidate( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakf.contract.RegisterMemberCandidate( + transaction, err := becdsakf.contract.BeaconCallback( transactorOptions, - _application, + _relayEntry, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "registerMemberCandidate", - _application, + "beaconCallback", + _relayEntry, ) } becdsakfLogger.Infof( - "submitted transaction registerMemberCandidate with id: [%v] and nonce [%v]", + "submitted transaction beaconCallback with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -487,8 +366,8 @@ func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidate( } // Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallRegisterMemberCandidate( - _application common.Address, +func (becdsakf *BondedECDSAKeepFactory) CallBeaconCallback( + _relayEntry *big.Int, blockNumber *big.Int, ) error { var result interface{} = nil @@ -500,46 +379,42 @@ func (becdsakf *BondedECDSAKeepFactory) CallRegisterMemberCandidate( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "registerMemberCandidate", + "beaconCallback", &result, - _application, + _relayEntry, ) return err } -func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidateGasEstimate( - _application common.Address, +func (becdsakf *BondedECDSAKeepFactory) BeaconCallbackGasEstimate( + _relayEntry *big.Int, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakf.callerOptions.From, becdsakf.contractAddress, - "registerMemberCandidate", + "beaconCallback", becdsakf.contractABI, becdsakf.transactor, - _application, + _relayEntry, ) return result, err } // Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValue( - _minimumBondableValue *big.Int, - _groupSize *big.Int, - _honestThreshold *big.Int, +func (becdsakf *BondedECDSAKeepFactory) IsRecognized( + _delegatedAuthorityRecipient common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakfLogger.Debug( - "submitting transaction setMinimumBondableValue", + "submitting transaction isRecognized", "params: ", fmt.Sprint( - _minimumBondableValue, - _groupSize, - _honestThreshold, + _delegatedAuthorityRecipient, ), ) @@ -565,26 +440,22 @@ func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValue( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakf.contract.SetMinimumBondableValue( + transaction, err := becdsakf.contract.IsRecognized( transactorOptions, - _minimumBondableValue, - _groupSize, - _honestThreshold, + _delegatedAuthorityRecipient, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "setMinimumBondableValue", - _minimumBondableValue, - _groupSize, - _honestThreshold, + "isRecognized", + _delegatedAuthorityRecipient, ) } becdsakfLogger.Infof( - "submitted transaction setMinimumBondableValue with id: [%v] and nonce [%v]", + "submitted transaction isRecognized with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -595,26 +466,22 @@ func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValue( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakf.contract.SetMinimumBondableValue( + transaction, err := becdsakf.contract.IsRecognized( transactorOptions, - _minimumBondableValue, - _groupSize, - _honestThreshold, + _delegatedAuthorityRecipient, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "setMinimumBondableValue", - _minimumBondableValue, - _groupSize, - _honestThreshold, + "isRecognized", + _delegatedAuthorityRecipient, ) } becdsakfLogger.Infof( - "submitted transaction setMinimumBondableValue with id: [%v] and nonce [%v]", + "submitted transaction isRecognized with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -629,13 +496,11 @@ func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValue( } // Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallSetMinimumBondableValue( - _minimumBondableValue *big.Int, - _groupSize *big.Int, - _honestThreshold *big.Int, +func (becdsakf *BondedECDSAKeepFactory) CallIsRecognized( + _delegatedAuthorityRecipient common.Address, blockNumber *big.Int, -) error { - var result interface{} = nil +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsakf.transactorOptions.From, @@ -644,49 +509,40 @@ func (becdsakf *BondedECDSAKeepFactory) CallSetMinimumBondableValue( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "setMinimumBondableValue", + "isRecognized", &result, - _minimumBondableValue, - _groupSize, - _honestThreshold, + _delegatedAuthorityRecipient, ) - return err + return result, err } -func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValueGasEstimate( - _minimumBondableValue *big.Int, - _groupSize *big.Int, - _honestThreshold *big.Int, +func (becdsakf *BondedECDSAKeepFactory) IsRecognizedGasEstimate( + _delegatedAuthorityRecipient common.Address, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakf.callerOptions.From, becdsakf.contractAddress, - "setMinimumBondableValue", + "isRecognized", becdsakf.contractABI, becdsakf.transactor, - _minimumBondableValue, - _groupSize, - _honestThreshold, + _delegatedAuthorityRecipient, ) return result, err } // Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) IsRecognized( - _delegatedAuthorityRecipient common.Address, +func (becdsakf *BondedECDSAKeepFactory) RequestNewGroupSelectionSeed( + value *big.Int, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakfLogger.Debug( - "submitting transaction isRecognized", - "params: ", - fmt.Sprint( - _delegatedAuthorityRecipient, - ), + "submitting transaction requestNewGroupSelectionSeed", + "value: ", value, ) becdsakf.transactionMutex.Lock() @@ -696,6 +552,8 @@ func (becdsakf *BondedECDSAKeepFactory) IsRecognized( transactorOptions := new(bind.TransactOpts) *transactorOptions = *becdsakf.transactorOptions + transactorOptions.Value = value + if len(transactionOptions) > 1 { return nil, fmt.Errorf( "could not process multiple transaction options sets", @@ -711,22 +569,20 @@ func (becdsakf *BondedECDSAKeepFactory) IsRecognized( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakf.contract.IsRecognized( + transaction, err := becdsakf.contract.RequestNewGroupSelectionSeed( transactorOptions, - _delegatedAuthorityRecipient, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, - nil, - "isRecognized", - _delegatedAuthorityRecipient, + value, + "requestNewGroupSelectionSeed", ) } becdsakfLogger.Infof( - "submitted transaction isRecognized with id: [%v] and nonce [%v]", + "submitted transaction requestNewGroupSelectionSeed with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -737,22 +593,20 @@ func (becdsakf *BondedECDSAKeepFactory) IsRecognized( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakf.contract.IsRecognized( + transaction, err := becdsakf.contract.RequestNewGroupSelectionSeed( transactorOptions, - _delegatedAuthorityRecipient, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, - nil, - "isRecognized", - _delegatedAuthorityRecipient, + value, + "requestNewGroupSelectionSeed", ) } becdsakfLogger.Infof( - "submitted transaction isRecognized with id: [%v] and nonce [%v]", + "submitted transaction requestNewGroupSelectionSeed with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -767,55 +621,51 @@ func (becdsakf *BondedECDSAKeepFactory) IsRecognized( } // Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallIsRecognized( - _delegatedAuthorityRecipient common.Address, +func (becdsakf *BondedECDSAKeepFactory) CallRequestNewGroupSelectionSeed( + value *big.Int, blockNumber *big.Int, -) (bool, error) { - var result bool +) error { + var result interface{} = nil err := ethutil.CallAtBlock( becdsakf.transactorOptions.From, - blockNumber, nil, + blockNumber, value, becdsakf.contractABI, becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "isRecognized", + "requestNewGroupSelectionSeed", &result, - _delegatedAuthorityRecipient, ) - return result, err + return err } -func (becdsakf *BondedECDSAKeepFactory) IsRecognizedGasEstimate( - _delegatedAuthorityRecipient common.Address, -) (uint64, error) { +func (becdsakf *BondedECDSAKeepFactory) RequestNewGroupSelectionSeedGasEstimate() (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakf.callerOptions.From, becdsakf.contractAddress, - "isRecognized", + "requestNewGroupSelectionSeed", becdsakf.contractABI, becdsakf.transactor, - _delegatedAuthorityRecipient, ) return result, err } // Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) BeaconCallback( - _relayEntry *big.Int, +func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( + _application common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakfLogger.Debug( - "submitting transaction beaconCallback", + "submitting transaction createSortitionPool", "params: ", fmt.Sprint( - _relayEntry, + _application, ), ) @@ -841,22 +691,22 @@ func (becdsakf *BondedECDSAKeepFactory) BeaconCallback( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakf.contract.BeaconCallback( + transaction, err := becdsakf.contract.CreateSortitionPool( transactorOptions, - _relayEntry, + _application, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "beaconCallback", - _relayEntry, + "createSortitionPool", + _application, ) } becdsakfLogger.Infof( - "submitted transaction beaconCallback with id: [%v] and nonce [%v]", + "submitted transaction createSortitionPool with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -867,22 +717,22 @@ func (becdsakf *BondedECDSAKeepFactory) BeaconCallback( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakf.contract.BeaconCallback( + transaction, err := becdsakf.contract.CreateSortitionPool( transactorOptions, - _relayEntry, + _application, ) if err != nil { return transaction, becdsakf.errorResolver.ResolveError( err, becdsakf.transactorOptions.From, nil, - "beaconCallback", - _relayEntry, + "createSortitionPool", + _application, ) } becdsakfLogger.Infof( - "submitted transaction beaconCallback with id: [%v] and nonce [%v]", + "submitted transaction createSortitionPool with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -897,11 +747,11 @@ func (becdsakf *BondedECDSAKeepFactory) BeaconCallback( } // Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallBeaconCallback( - _relayEntry *big.Int, +func (becdsakf *BondedECDSAKeepFactory) CallCreateSortitionPool( + _application common.Address, blockNumber *big.Int, -) error { - var result interface{} = nil +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsakf.transactorOptions.From, @@ -910,26 +760,26 @@ func (becdsakf *BondedECDSAKeepFactory) CallBeaconCallback( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "beaconCallback", + "createSortitionPool", &result, - _relayEntry, + _application, ) - return err + return result, err } -func (becdsakf *BondedECDSAKeepFactory) BeaconCallbackGasEstimate( - _relayEntry *big.Int, +func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPoolGasEstimate( + _application common.Address, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakf.callerOptions.From, becdsakf.contractAddress, - "beaconCallback", + "createSortitionPool", becdsakf.contractABI, becdsakf.transactor, - _relayEntry, + _application, ) return result, err @@ -1076,13 +926,13 @@ func (becdsakf *BondedECDSAKeepFactory) UpdateOperatorStatusGasEstimate( } // Transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( +func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidate( _application common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakfLogger.Debug( - "submitting transaction createSortitionPool", + "submitting transaction registerMemberCandidate", "params: ", fmt.Sprint( _application, @@ -1111,7 +961,7 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakf.contract.CreateSortitionPool( + transaction, err := becdsakf.contract.RegisterMemberCandidate( transactorOptions, _application, ) @@ -1120,13 +970,13 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( err, becdsakf.transactorOptions.From, nil, - "createSortitionPool", + "registerMemberCandidate", _application, ) } becdsakfLogger.Infof( - "submitted transaction createSortitionPool with id: [%v] and nonce [%v]", + "submitted transaction registerMemberCandidate with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1137,7 +987,7 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakf.contract.CreateSortitionPool( + transaction, err := becdsakf.contract.RegisterMemberCandidate( transactorOptions, _application, ) @@ -1146,13 +996,13 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( err, becdsakf.transactorOptions.From, nil, - "createSortitionPool", + "registerMemberCandidate", _application, ) } becdsakfLogger.Infof( - "submitted transaction createSortitionPool with id: [%v] and nonce [%v]", + "submitted transaction registerMemberCandidate with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -1167,11 +1017,11 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPool( } // Non-mutating call, not a transaction submission. -func (becdsakf *BondedECDSAKeepFactory) CallCreateSortitionPool( +func (becdsakf *BondedECDSAKeepFactory) CallRegisterMemberCandidate( _application common.Address, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) error { + var result interface{} = nil err := ethutil.CallAtBlock( becdsakf.transactorOptions.From, @@ -1180,15 +1030,15 @@ func (becdsakf *BondedECDSAKeepFactory) CallCreateSortitionPool( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "createSortitionPool", + "registerMemberCandidate", &result, _application, ) - return result, err + return err } -func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPoolGasEstimate( +func (becdsakf *BondedECDSAKeepFactory) RegisterMemberCandidateGasEstimate( _application common.Address, ) (uint64, error) { var result uint64 @@ -1196,7 +1046,7 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPoolGasEstimate( result, err := ethutil.EstimateGas( becdsakf.callerOptions.From, becdsakf.contractAddress, - "createSortitionPool", + "registerMemberCandidate", becdsakf.contractABI, becdsakf.transactor, _application, @@ -1205,11 +1055,161 @@ func (becdsakf *BondedECDSAKeepFactory) CreateSortitionPoolGasEstimate( return result, err } +// Transaction submission. +func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValue( + _minimumBondableValue *big.Int, + _groupSize *big.Int, + _honestThreshold *big.Int, + + transactionOptions ...ethutil.TransactionOptions, +) (*types.Transaction, error) { + becdsakfLogger.Debug( + "submitting transaction setMinimumBondableValue", + "params: ", + fmt.Sprint( + _minimumBondableValue, + _groupSize, + _honestThreshold, + ), + ) + + becdsakf.transactionMutex.Lock() + defer becdsakf.transactionMutex.Unlock() + + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *becdsakf.transactorOptions + + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", + ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) + } + + nonce, err := becdsakf.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } + + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) + + transaction, err := becdsakf.contract.SetMinimumBondableValue( + transactorOptions, + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + if err != nil { + return transaction, becdsakf.errorResolver.ResolveError( + err, + becdsakf.transactorOptions.From, + nil, + "setMinimumBondableValue", + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + } + + becdsakfLogger.Infof( + "submitted transaction setMinimumBondableValue with id: [%v] and nonce [%v]", + transaction.Hash().Hex(), + transaction.Nonce(), + ) + + go becdsakf.miningWaiter.ForceMining( + transaction, + func(newGasPrice *big.Int) (*types.Transaction, error) { + transactorOptions.GasLimit = transaction.Gas() + transactorOptions.GasPrice = newGasPrice + + transaction, err := becdsakf.contract.SetMinimumBondableValue( + transactorOptions, + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + if err != nil { + return transaction, becdsakf.errorResolver.ResolveError( + err, + becdsakf.transactorOptions.From, + nil, + "setMinimumBondableValue", + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + } + + becdsakfLogger.Infof( + "submitted transaction setMinimumBondableValue with id: [%v] and nonce [%v]", + transaction.Hash().Hex(), + transaction.Nonce(), + ) + + return transaction, nil + }, + ) + + becdsakf.nonceManager.IncrementNonce() + + return transaction, err +} + +// Non-mutating call, not a transaction submission. +func (becdsakf *BondedECDSAKeepFactory) CallSetMinimumBondableValue( + _minimumBondableValue *big.Int, + _groupSize *big.Int, + _honestThreshold *big.Int, + blockNumber *big.Int, +) error { + var result interface{} = nil + + err := ethutil.CallAtBlock( + becdsakf.transactorOptions.From, + blockNumber, nil, + becdsakf.contractABI, + becdsakf.caller, + becdsakf.errorResolver, + becdsakf.contractAddress, + "setMinimumBondableValue", + &result, + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + + return err +} + +func (becdsakf *BondedECDSAKeepFactory) SetMinimumBondableValueGasEstimate( + _minimumBondableValue *big.Int, + _groupSize *big.Int, + _honestThreshold *big.Int, +) (uint64, error) { + var result uint64 + + result, err := ethutil.EstimateGas( + becdsakf.callerOptions.From, + becdsakf.contractAddress, + "setMinimumBondableValue", + becdsakf.contractABI, + becdsakf.transactor, + _minimumBondableValue, + _groupSize, + _honestThreshold, + ) + + return result, err +} + // ----- Const Methods ------ -func (becdsakf *BondedECDSAKeepFactory) GetKeepCount() (*big.Int, error) { - var result *big.Int - result, err := becdsakf.contract.GetKeepCount( +func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddress() (common.Address, error) { + var result common.Address + result, err := becdsakf.contract.MasterKeepAddress( becdsakf.callerOptions, ) @@ -1218,17 +1218,17 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepCount() (*big.Int, error) { err, becdsakf.callerOptions.From, nil, - "getKeepCount", + "masterKeepAddress", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetKeepCountAtBlock( +func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddressAtBlock( blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1238,20 +1238,17 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepCountAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "getKeepCount", + "masterKeepAddress", &result, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeight( - _application common.Address, -) (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimate() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.GetSortitionPoolWeight( + result, err := becdsakf.contract.OpenKeepFeeEstimate( becdsakf.callerOptions, - _application, ) if err != nil { @@ -1259,16 +1256,14 @@ func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeight( err, becdsakf.callerOptions.From, nil, - "getSortitionPoolWeight", - _application, + "openKeepFeeEstimate", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeightAtBlock( - _application common.Address, +func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimateAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1281,17 +1276,16 @@ func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeightAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "getSortitionPoolWeight", + "openKeepFeeEstimate", &result, - _application, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) MinimumBond() (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisor() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.MinimumBond( + result, err := becdsakf.contract.PoolStakeWeightDivisor( becdsakf.callerOptions, ) @@ -1300,14 +1294,14 @@ func (becdsakf *BondedECDSAKeepFactory) MinimumBond() (*big.Int, error) { err, becdsakf.callerOptions.From, nil, - "minimumBond", + "poolStakeWeightDivisor", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) MinimumBondAtBlock( +func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisorAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1320,17 +1314,20 @@ func (becdsakf *BondedECDSAKeepFactory) MinimumBondAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "minimumBond", + "poolStakeWeightDivisor", &result, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimate() (*big.Int, error) { - var result *big.Int - result, err := becdsakf.contract.NewEntryFeeEstimate( +func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndex( + index *big.Int, +) (common.Address, error) { + var result common.Address + result, err := becdsakf.contract.GetKeepAtIndex( becdsakf.callerOptions, + index, ) if err != nil { @@ -1338,17 +1335,19 @@ func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimate() (*big.Int, error) err, becdsakf.callerOptions.From, nil, - "newEntryFeeEstimate", + "getKeepAtIndex", + index, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimateAtBlock( +func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndexAtBlock( + index *big.Int, blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1358,16 +1357,17 @@ func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimateAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "newEntryFeeEstimate", + "getKeepAtIndex", &result, + index, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisor() (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) GroupSelectionSeed() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.PoolStakeWeightDivisor( + result, err := becdsakf.contract.GroupSelectionSeed( becdsakf.callerOptions, ) @@ -1376,14 +1376,14 @@ func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisor() (*big.Int, erro err, becdsakf.callerOptions.From, nil, - "poolStakeWeightDivisor", + "groupSelectionSeed", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisorAtBlock( +func (becdsakf *BondedECDSAKeepFactory) GroupSelectionSeedAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1396,20 +1396,20 @@ func (becdsakf *BondedECDSAKeepFactory) PoolStakeWeightDivisorAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "poolStakeWeightDivisor", + "groupSelectionSeed", &result, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndex( - index *big.Int, -) (common.Address, error) { - var result common.Address - result, err := becdsakf.contract.GetKeepAtIndex( +func (becdsakf *BondedECDSAKeepFactory) HasMinimumStake( + _operator common.Address, +) (bool, error) { + var result bool + result, err := becdsakf.contract.HasMinimumStake( becdsakf.callerOptions, - index, + _operator, ) if err != nil { @@ -1417,19 +1417,19 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndex( err, becdsakf.callerOptions.From, nil, - "getKeepAtIndex", - index, + "hasMinimumStake", + _operator, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndexAtBlock( - index *big.Int, +func (becdsakf *BondedECDSAKeepFactory) HasMinimumStakeAtBlock( + _operator common.Address, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1439,21 +1439,18 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepAtIndexAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "getKeepAtIndex", + "hasMinimumStake", &result, - index, + _operator, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestamp( - _keep common.Address, -) (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) ReseedPool() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.GetKeepOpenedTimestamp( + result, err := becdsakf.contract.ReseedPool( becdsakf.callerOptions, - _keep, ) if err != nil { @@ -1461,16 +1458,14 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestamp( err, becdsakf.callerOptions.From, nil, - "getKeepOpenedTimestamp", - _keep, + "reseedPool", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestampAtBlock( - _keep common.Address, +func (becdsakf *BondedECDSAKeepFactory) ReseedPoolAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1483,18 +1478,20 @@ func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestampAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "getKeepOpenedTimestamp", + "reseedPool", &result, - _keep, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFee() (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) BalanceOf( + _operator common.Address, +) (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.NewGroupSelectionSeedFee( + result, err := becdsakf.contract.BalanceOf( becdsakf.callerOptions, + _operator, ) if err != nil { @@ -1502,17 +1499,63 @@ func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFee() (*big.Int, er err, becdsakf.callerOptions.From, nil, - "newGroupSelectionSeedFee", + "balanceOf", + _operator, + ) + } + + return result, err +} + +func (becdsakf *BondedECDSAKeepFactory) BalanceOfAtBlock( + _operator common.Address, + blockNumber *big.Int, +) (*big.Int, error) { + var result *big.Int + + err := ethutil.CallAtBlock( + becdsakf.callerOptions.From, + blockNumber, + nil, + becdsakf.contractABI, + becdsakf.caller, + becdsakf.errorResolver, + becdsakf.contractAddress, + "balanceOf", + &result, + _operator, + ) + + return result, err +} + +func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorized( + _operator common.Address, +) (bool, error) { + var result bool + result, err := becdsakf.contract.IsOperatorAuthorized( + becdsakf.callerOptions, + _operator, + ) + + if err != nil { + return result, becdsakf.errorResolver.ResolveError( + err, + becdsakf.callerOptions.From, + nil, + "isOperatorAuthorized", + _operator, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFeeAtBlock( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorizedAtBlock( + _operator common.Address, blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1522,17 +1565,23 @@ func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFeeAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "newGroupSelectionSeedFee", + "isOperatorAuthorized", &result, + _operator, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimate() (*big.Int, error) { - var result *big.Int - result, err := becdsakf.contract.OpenKeepFeeEstimate( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegistered( + _operator common.Address, + _application common.Address, +) (bool, error) { + var result bool + result, err := becdsakf.contract.IsOperatorRegistered( becdsakf.callerOptions, + _operator, + _application, ) if err != nil { @@ -1540,17 +1589,21 @@ func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimate() (*big.Int, error) err, becdsakf.callerOptions.From, nil, - "openKeepFeeEstimate", + "isOperatorRegistered", + _operator, + _application, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimateAtBlock( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegisteredAtBlock( + _operator common.Address, + _application common.Address, blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1560,16 +1613,18 @@ func (becdsakf *BondedECDSAKeepFactory) OpenKeepFeeEstimateAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "openKeepFeeEstimate", + "isOperatorRegistered", &result, + _operator, + _application, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) CallbackGas() (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) MinimumBond() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.CallbackGas( + result, err := becdsakf.contract.MinimumBond( becdsakf.callerOptions, ) @@ -1578,14 +1633,14 @@ func (becdsakf *BondedECDSAKeepFactory) CallbackGas() (*big.Int, error) { err, becdsakf.callerOptions.From, nil, - "callbackGas", + "minimumBond", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) CallbackGasAtBlock( +func (becdsakf *BondedECDSAKeepFactory) MinimumBondAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -1598,20 +1653,17 @@ func (becdsakf *BondedECDSAKeepFactory) CallbackGasAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "callbackGas", + "minimumBond", &result, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorized( - _operator common.Address, -) (bool, error) { - var result bool - result, err := becdsakf.contract.IsOperatorAuthorized( +func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimate() (*big.Int, error) { + var result *big.Int + result, err := becdsakf.contract.NewEntryFeeEstimate( becdsakf.callerOptions, - _operator, ) if err != nil { @@ -1619,19 +1671,17 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorized( err, becdsakf.callerOptions.From, nil, - "isOperatorAuthorized", - _operator, + "newEntryFeeEstimate", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorizedAtBlock( - _operator common.Address, +func (becdsakf *BondedECDSAKeepFactory) NewEntryFeeEstimateAtBlock( blockNumber *big.Int, -) (bool, error) { - var result bool +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1641,21 +1691,17 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorAuthorizedAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "isOperatorAuthorized", + "newEntryFeeEstimate", &result, - _operator, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetSortitionPool( - _application common.Address, -) (common.Address, error) { - var result common.Address - result, err := becdsakf.contract.GetSortitionPool( +func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFee() (*big.Int, error) { + var result *big.Int + result, err := becdsakf.contract.NewGroupSelectionSeedFee( becdsakf.callerOptions, - _application, ) if err != nil { @@ -1663,19 +1709,17 @@ func (becdsakf *BondedECDSAKeepFactory) GetSortitionPool( err, becdsakf.callerOptions.From, nil, - "getSortitionPool", - _application, + "newGroupSelectionSeedFee", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolAtBlock( - _application common.Address, +func (becdsakf *BondedECDSAKeepFactory) NewGroupSelectionSeedFeeAtBlock( blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1685,22 +1729,19 @@ func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "getSortitionPool", + "newGroupSelectionSeedFee", &result, - _application, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligible( - _operator common.Address, +func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeight( _application common.Address, -) (bool, error) { - var result bool - result, err := becdsakf.contract.IsOperatorEligible( +) (*big.Int, error) { + var result *big.Int + result, err := becdsakf.contract.GetSortitionPoolWeight( becdsakf.callerOptions, - _operator, _application, ) @@ -1709,8 +1750,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligible( err, becdsakf.callerOptions.From, nil, - "isOperatorEligible", - _operator, + "getSortitionPoolWeight", _application, ) } @@ -1718,12 +1758,11 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligible( return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligibleAtBlock( - _operator common.Address, +func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolWeightAtBlock( _application common.Address, blockNumber *big.Int, -) (bool, error) { - var result bool +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1733,21 +1772,20 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligibleAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "isOperatorEligible", + "getSortitionPoolWeight", &result, - _operator, _application, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDate( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligible( _operator common.Address, _application common.Address, ) (bool, error) { var result bool - result, err := becdsakf.contract.IsOperatorUpToDate( + result, err := becdsakf.contract.IsOperatorEligible( becdsakf.callerOptions, _operator, _application, @@ -1758,7 +1796,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDate( err, becdsakf.callerOptions.From, nil, - "isOperatorUpToDate", + "isOperatorEligible", _operator, _application, ) @@ -1767,7 +1805,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDate( return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDateAtBlock( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorEligibleAtBlock( _operator common.Address, _application common.Address, blockNumber *big.Int, @@ -1782,7 +1820,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDateAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "isOperatorUpToDate", + "isOperatorEligible", &result, _operator, _application, @@ -1791,50 +1829,12 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDateAtBlock( return result, err } -func (becdsakf *BondedECDSAKeepFactory) GroupSelectionSeed() (*big.Int, error) { - var result *big.Int - result, err := becdsakf.contract.GroupSelectionSeed( - becdsakf.callerOptions, - ) - - if err != nil { - return result, becdsakf.errorResolver.ResolveError( - err, - becdsakf.callerOptions.From, - nil, - "groupSelectionSeed", - ) - } - - return result, err -} - -func (becdsakf *BondedECDSAKeepFactory) GroupSelectionSeedAtBlock( - blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int - - err := ethutil.CallAtBlock( - becdsakf.callerOptions.From, - blockNumber, - nil, - becdsakf.contractABI, - becdsakf.caller, - becdsakf.errorResolver, - becdsakf.contractAddress, - "groupSelectionSeed", - &result, - ) - - return result, err -} - -func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegistered( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDate( _operator common.Address, _application common.Address, ) (bool, error) { var result bool - result, err := becdsakf.contract.IsOperatorRegistered( + result, err := becdsakf.contract.IsOperatorUpToDate( becdsakf.callerOptions, _operator, _application, @@ -1845,7 +1845,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegistered( err, becdsakf.callerOptions.From, nil, - "isOperatorRegistered", + "isOperatorUpToDate", _operator, _application, ) @@ -1854,7 +1854,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegistered( return result, err } -func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegisteredAtBlock( +func (becdsakf *BondedECDSAKeepFactory) IsOperatorUpToDateAtBlock( _operator common.Address, _application common.Address, blockNumber *big.Int, @@ -1869,7 +1869,7 @@ func (becdsakf *BondedECDSAKeepFactory) IsOperatorRegisteredAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "isOperatorRegistered", + "isOperatorUpToDate", &result, _operator, _application, @@ -1922,10 +1922,13 @@ func (becdsakf *BondedECDSAKeepFactory) KeepsAtBlock( return result, err } -func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddress() (common.Address, error) { - var result common.Address - result, err := becdsakf.contract.MasterKeepAddress( +func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestamp( + _keep common.Address, +) (*big.Int, error) { + var result *big.Int + result, err := becdsakf.contract.GetKeepOpenedTimestamp( becdsakf.callerOptions, + _keep, ) if err != nil { @@ -1933,17 +1936,19 @@ func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddress() (common.Address, err err, becdsakf.callerOptions.From, nil, - "masterKeepAddress", + "getKeepOpenedTimestamp", + _keep, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddressAtBlock( +func (becdsakf *BondedECDSAKeepFactory) GetKeepOpenedTimestampAtBlock( + _keep common.Address, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1953,20 +1958,18 @@ func (becdsakf *BondedECDSAKeepFactory) MasterKeepAddressAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "masterKeepAddress", + "getKeepOpenedTimestamp", &result, + _keep, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) HasMinimumStake( - _operator common.Address, -) (bool, error) { - var result bool - result, err := becdsakf.contract.HasMinimumStake( +func (becdsakf *BondedECDSAKeepFactory) CallbackGas() (*big.Int, error) { + var result *big.Int + result, err := becdsakf.contract.CallbackGas( becdsakf.callerOptions, - _operator, ) if err != nil { @@ -1974,19 +1977,17 @@ func (becdsakf *BondedECDSAKeepFactory) HasMinimumStake( err, becdsakf.callerOptions.From, nil, - "hasMinimumStake", - _operator, + "callbackGas", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) HasMinimumStakeAtBlock( - _operator common.Address, +func (becdsakf *BondedECDSAKeepFactory) CallbackGasAtBlock( blockNumber *big.Int, -) (bool, error) { - var result bool +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -1996,18 +1997,20 @@ func (becdsakf *BondedECDSAKeepFactory) HasMinimumStakeAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "hasMinimumStake", + "callbackGas", &result, - _operator, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) ReseedPool() (*big.Int, error) { - var result *big.Int - result, err := becdsakf.contract.ReseedPool( +func (becdsakf *BondedECDSAKeepFactory) GetSortitionPool( + _application common.Address, +) (common.Address, error) { + var result common.Address + result, err := becdsakf.contract.GetSortitionPool( becdsakf.callerOptions, + _application, ) if err != nil { @@ -2015,17 +2018,19 @@ func (becdsakf *BondedECDSAKeepFactory) ReseedPool() (*big.Int, error) { err, becdsakf.callerOptions.From, nil, - "reseedPool", + "getSortitionPool", + _application, ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) ReseedPoolAtBlock( +func (becdsakf *BondedECDSAKeepFactory) GetSortitionPoolAtBlock( + _application common.Address, blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsakf.callerOptions.From, @@ -2035,20 +2040,18 @@ func (becdsakf *BondedECDSAKeepFactory) ReseedPoolAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "reseedPool", + "getSortitionPool", &result, + _application, ) return result, err } -func (becdsakf *BondedECDSAKeepFactory) BalanceOf( - _operator common.Address, -) (*big.Int, error) { +func (becdsakf *BondedECDSAKeepFactory) GetKeepCount() (*big.Int, error) { var result *big.Int - result, err := becdsakf.contract.BalanceOf( + result, err := becdsakf.contract.GetKeepCount( becdsakf.callerOptions, - _operator, ) if err != nil { @@ -2056,16 +2059,14 @@ func (becdsakf *BondedECDSAKeepFactory) BalanceOf( err, becdsakf.callerOptions.From, nil, - "balanceOf", - _operator, + "getKeepCount", ) } return result, err } -func (becdsakf *BondedECDSAKeepFactory) BalanceOfAtBlock( - _operator common.Address, +func (becdsakf *BondedECDSAKeepFactory) GetKeepCountAtBlock( blockNumber *big.Int, ) (*big.Int, error) { var result *big.Int @@ -2078,9 +2079,8 @@ func (becdsakf *BondedECDSAKeepFactory) BalanceOfAtBlock( becdsakf.caller, becdsakf.errorResolver, becdsakf.contractAddress, - "balanceOf", + "getKeepCount", &result, - _operator, ) return result, err diff --git a/pkg/chain/gen/contract/BondedECDSAKeepVendor.go b/pkg/chain/gen/contract/BondedECDSAKeepVendor.go index 7f8510191..2d79e81d0 100644 --- a/pkg/chain/gen/contract/BondedECDSAKeepVendor.go +++ b/pkg/chain/gen/contract/BondedECDSAKeepVendor.go @@ -100,16 +100,18 @@ func NewBondedECDSAKeepVendor( // ----- Non-const Methods ------ // Transaction submission. -func (becdsakv *BondedECDSAKeepVendor) UpgradeFactory( - _factory common.Address, +func (becdsakv *BondedECDSAKeepVendor) Initialize( + registryAddress common.Address, + factory common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakvLogger.Debug( - "submitting transaction upgradeFactory", + "submitting transaction initialize", "params: ", fmt.Sprint( - _factory, + registryAddress, + factory, ), ) @@ -135,22 +137,24 @@ func (becdsakv *BondedECDSAKeepVendor) UpgradeFactory( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakv.contract.UpgradeFactory( + transaction, err := becdsakv.contract.Initialize( transactorOptions, - _factory, + registryAddress, + factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "upgradeFactory", - _factory, + "initialize", + registryAddress, + factory, ) } becdsakvLogger.Infof( - "submitted transaction upgradeFactory with id: [%v] and nonce [%v]", + "submitted transaction initialize with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -161,22 +165,24 @@ func (becdsakv *BondedECDSAKeepVendor) UpgradeFactory( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakv.contract.UpgradeFactory( + transaction, err := becdsakv.contract.Initialize( transactorOptions, - _factory, + registryAddress, + factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "upgradeFactory", - _factory, + "initialize", + registryAddress, + factory, ) } becdsakvLogger.Infof( - "submitted transaction upgradeFactory with id: [%v] and nonce [%v]", + "submitted transaction initialize with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -191,8 +197,9 @@ func (becdsakv *BondedECDSAKeepVendor) UpgradeFactory( } // Non-mutating call, not a transaction submission. -func (becdsakv *BondedECDSAKeepVendor) CallUpgradeFactory( - _factory common.Address, +func (becdsakv *BondedECDSAKeepVendor) CallInitialize( + registryAddress common.Address, + factory common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -204,38 +211,46 @@ func (becdsakv *BondedECDSAKeepVendor) CallUpgradeFactory( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "upgradeFactory", + "initialize", &result, - _factory, + registryAddress, + factory, ) return err } -func (becdsakv *BondedECDSAKeepVendor) UpgradeFactoryGasEstimate( - _factory common.Address, +func (becdsakv *BondedECDSAKeepVendor) InitializeGasEstimate( + registryAddress common.Address, + factory common.Address, ) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakv.callerOptions.From, becdsakv.contractAddress, - "upgradeFactory", + "initialize", becdsakv.contractABI, becdsakv.transactor, - _factory, + registryAddress, + factory, ) return result, err } // Transaction submission. -func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgrade( +func (becdsakv *BondedECDSAKeepVendor) UpgradeFactory( + _factory common.Address, transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakvLogger.Debug( - "submitting transaction completeFactoryUpgrade", + "submitting transaction upgradeFactory", + "params: ", + fmt.Sprint( + _factory, + ), ) becdsakv.transactionMutex.Lock() @@ -260,20 +275,22 @@ func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgrade( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakv.contract.CompleteFactoryUpgrade( + transaction, err := becdsakv.contract.UpgradeFactory( transactorOptions, + _factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "completeFactoryUpgrade", + "upgradeFactory", + _factory, ) } becdsakvLogger.Infof( - "submitted transaction completeFactoryUpgrade with id: [%v] and nonce [%v]", + "submitted transaction upgradeFactory with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -284,20 +301,22 @@ func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgrade( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakv.contract.CompleteFactoryUpgrade( + transaction, err := becdsakv.contract.UpgradeFactory( transactorOptions, + _factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "completeFactoryUpgrade", + "upgradeFactory", + _factory, ) } becdsakvLogger.Infof( - "submitted transaction completeFactoryUpgrade with id: [%v] and nonce [%v]", + "submitted transaction upgradeFactory with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -312,7 +331,8 @@ func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgrade( } // Non-mutating call, not a transaction submission. -func (becdsakv *BondedECDSAKeepVendor) CallCompleteFactoryUpgrade( +func (becdsakv *BondedECDSAKeepVendor) CallUpgradeFactory( + _factory common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -324,41 +344,38 @@ func (becdsakv *BondedECDSAKeepVendor) CallCompleteFactoryUpgrade( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "completeFactoryUpgrade", + "upgradeFactory", &result, + _factory, ) return err } -func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgradeGasEstimate() (uint64, error) { +func (becdsakv *BondedECDSAKeepVendor) UpgradeFactoryGasEstimate( + _factory common.Address, +) (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakv.callerOptions.From, becdsakv.contractAddress, - "completeFactoryUpgrade", + "upgradeFactory", becdsakv.contractABI, becdsakv.transactor, + _factory, ) return result, err } // Transaction submission. -func (becdsakv *BondedECDSAKeepVendor) Initialize( - registryAddress common.Address, - factory common.Address, +func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgrade( transactionOptions ...ethutil.TransactionOptions, ) (*types.Transaction, error) { becdsakvLogger.Debug( - "submitting transaction initialize", - "params: ", - fmt.Sprint( - registryAddress, - factory, - ), + "submitting transaction completeFactoryUpgrade", ) becdsakv.transactionMutex.Lock() @@ -383,24 +400,20 @@ func (becdsakv *BondedECDSAKeepVendor) Initialize( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := becdsakv.contract.Initialize( + transaction, err := becdsakv.contract.CompleteFactoryUpgrade( transactorOptions, - registryAddress, - factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "initialize", - registryAddress, - factory, + "completeFactoryUpgrade", ) } becdsakvLogger.Infof( - "submitted transaction initialize with id: [%v] and nonce [%v]", + "submitted transaction completeFactoryUpgrade with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -411,24 +424,20 @@ func (becdsakv *BondedECDSAKeepVendor) Initialize( transactorOptions.GasLimit = transaction.Gas() transactorOptions.GasPrice = newGasPrice - transaction, err := becdsakv.contract.Initialize( + transaction, err := becdsakv.contract.CompleteFactoryUpgrade( transactorOptions, - registryAddress, - factory, ) if err != nil { return transaction, becdsakv.errorResolver.ResolveError( err, becdsakv.transactorOptions.From, nil, - "initialize", - registryAddress, - factory, + "completeFactoryUpgrade", ) } becdsakvLogger.Infof( - "submitted transaction initialize with id: [%v] and nonce [%v]", + "submitted transaction completeFactoryUpgrade with id: [%v] and nonce [%v]", transaction.Hash().Hex(), transaction.Nonce(), ) @@ -443,9 +452,7 @@ func (becdsakv *BondedECDSAKeepVendor) Initialize( } // Non-mutating call, not a transaction submission. -func (becdsakv *BondedECDSAKeepVendor) CallInitialize( - registryAddress common.Address, - factory common.Address, +func (becdsakv *BondedECDSAKeepVendor) CallCompleteFactoryUpgrade( blockNumber *big.Int, ) error { var result interface{} = nil @@ -457,29 +464,22 @@ func (becdsakv *BondedECDSAKeepVendor) CallInitialize( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "initialize", + "completeFactoryUpgrade", &result, - registryAddress, - factory, ) return err } -func (becdsakv *BondedECDSAKeepVendor) InitializeGasEstimate( - registryAddress common.Address, - factory common.Address, -) (uint64, error) { +func (becdsakv *BondedECDSAKeepVendor) CompleteFactoryUpgradeGasEstimate() (uint64, error) { var result uint64 result, err := ethutil.EstimateGas( becdsakv.callerOptions.From, becdsakv.contractAddress, - "initialize", + "completeFactoryUpgrade", becdsakv.contractABI, becdsakv.transactor, - registryAddress, - factory, ) return result, err @@ -487,9 +487,9 @@ func (becdsakv *BondedECDSAKeepVendor) InitializeGasEstimate( // ----- Const Methods ------ -func (becdsakv *BondedECDSAKeepVendor) Initialized() (bool, error) { - var result bool - result, err := becdsakv.contract.Initialized( +func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelay() (*big.Int, error) { + var result *big.Int + result, err := becdsakv.contract.FactoryUpgradeTimeDelay( becdsakv.callerOptions, ) @@ -498,17 +498,17 @@ func (becdsakv *BondedECDSAKeepVendor) Initialized() (bool, error) { err, becdsakv.callerOptions.From, nil, - "initialized", + "factoryUpgradeTimeDelay", ) } return result, err } -func (becdsakv *BondedECDSAKeepVendor) InitializedAtBlock( +func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelayAtBlock( blockNumber *big.Int, -) (bool, error) { - var result bool +) (*big.Int, error) { + var result *big.Int err := ethutil.CallAtBlock( becdsakv.callerOptions.From, @@ -518,16 +518,16 @@ func (becdsakv *BondedECDSAKeepVendor) InitializedAtBlock( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "initialized", + "factoryUpgradeTimeDelay", &result, ) return result, err } -func (becdsakv *BondedECDSAKeepVendor) SelectFactory() (common.Address, error) { - var result common.Address - result, err := becdsakv.contract.SelectFactory( +func (becdsakv *BondedECDSAKeepVendor) Initialized() (bool, error) { + var result bool + result, err := becdsakv.contract.Initialized( becdsakv.callerOptions, ) @@ -536,17 +536,17 @@ func (becdsakv *BondedECDSAKeepVendor) SelectFactory() (common.Address, error) { err, becdsakv.callerOptions.From, nil, - "selectFactory", + "initialized", ) } return result, err } -func (becdsakv *BondedECDSAKeepVendor) SelectFactoryAtBlock( +func (becdsakv *BondedECDSAKeepVendor) InitializedAtBlock( blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) (bool, error) { + var result bool err := ethutil.CallAtBlock( becdsakv.callerOptions.From, @@ -556,16 +556,16 @@ func (becdsakv *BondedECDSAKeepVendor) SelectFactoryAtBlock( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "selectFactory", + "initialized", &result, ) return result, err } -func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelay() (*big.Int, error) { - var result *big.Int - result, err := becdsakv.contract.FactoryUpgradeTimeDelay( +func (becdsakv *BondedECDSAKeepVendor) SelectFactory() (common.Address, error) { + var result common.Address + result, err := becdsakv.contract.SelectFactory( becdsakv.callerOptions, ) @@ -574,17 +574,17 @@ func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelay() (*big.Int, erro err, becdsakv.callerOptions.From, nil, - "factoryUpgradeTimeDelay", + "selectFactory", ) } return result, err } -func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelayAtBlock( +func (becdsakv *BondedECDSAKeepVendor) SelectFactoryAtBlock( blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +) (common.Address, error) { + var result common.Address err := ethutil.CallAtBlock( becdsakv.callerOptions.From, @@ -594,7 +594,7 @@ func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelayAtBlock( becdsakv.caller, becdsakv.errorResolver, becdsakv.contractAddress, - "factoryUpgradeTimeDelay", + "selectFactory", &result, ) @@ -603,9 +603,9 @@ func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeTimeDelayAtBlock( // ------ Events ------- -func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeCompleted( +func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeStarted( opts *ethutil.SubscribeOpts, -) *FactoryUpgradeCompletedSubscription { +) *FactoryUpgradeStartedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -616,26 +616,27 @@ func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeCompleted( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &FactoryUpgradeCompletedSubscription{ + return &FactoryUpgradeStartedSubscription{ becdsakv, opts, } } -type FactoryUpgradeCompletedSubscription struct { +type FactoryUpgradeStartedSubscription struct { contract *BondedECDSAKeepVendor opts *ethutil.SubscribeOpts } -type bondedECDSAKeepVendorFactoryUpgradeCompletedFunc func( +type bondedECDSAKeepVendorFactoryUpgradeStartedFunc func( Factory common.Address, + Timestamp *big.Int, blockNumber uint64, ) -func (fucs *FactoryUpgradeCompletedSubscription) OnEvent( - handler bondedECDSAKeepVendorFactoryUpgradeCompletedFunc, +func (fuss *FactoryUpgradeStartedSubscription) OnEvent( + handler bondedECDSAKeepVendorFactoryUpgradeStartedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted) + eventChan := make(chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -646,46 +647,47 @@ func (fucs *FactoryUpgradeCompletedSubscription) OnEvent( case event := <-eventChan: handler( event.Factory, + event.Timestamp, event.Raw.BlockNumber, ) } } }() - sub := fucs.Pipe(eventChan) + sub := fuss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fucs *FactoryUpgradeCompletedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, +func (fuss *FactoryUpgradeStartedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fucs.opts.Tick) + ticker := time.NewTicker(fuss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fucs.contract.blockCounter.CurrentBlock() + lastBlock, err := fuss.contract.blockCounter.CurrentBlock() if err != nil { becdsakvLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fucs.opts.PastBlocks + fromBlock := lastBlock - fuss.opts.PastBlocks becdsakvLogger.Infof( - "subscription monitoring fetching past FactoryUpgradeCompleted events "+ + "subscription monitoring fetching past FactoryUpgradeStarted events "+ "starting from block [%v]", fromBlock, ) - events, err := fucs.contract.PastFactoryUpgradeCompletedEvents( + events, err := fuss.contract.PastFactoryUpgradeStartedEvents( fromBlock, nil, ) @@ -697,7 +699,7 @@ func (fucs *FactoryUpgradeCompletedSubscription) Pipe( continue } becdsakvLogger.Infof( - "subscription monitoring fetched [%v] past FactoryUpgradeCompleted events", + "subscription monitoring fetched [%v] past FactoryUpgradeStarted events", len(events), ) @@ -708,7 +710,7 @@ func (fucs *FactoryUpgradeCompletedSubscription) Pipe( } }() - sub := fucs.contract.watchFactoryUpgradeCompleted( + sub := fuss.contract.watchFactoryUpgradeStarted( sink, ) @@ -718,11 +720,11 @@ func (fucs *FactoryUpgradeCompletedSubscription) Pipe( }) } -func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeCompleted( - sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, +func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeStarted( + sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsakv.contract.WatchFactoryUpgradeCompleted( + return becdsakv.contract.WatchFactoryUpgradeStarted( &bind.WatchOpts{Context: ctx}, sink, ) @@ -730,7 +732,7 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeCompleted( thresholdViolatedFn := func(elapsed time.Duration) { becdsakvLogger.Errorf( - "subscription to event FactoryUpgradeCompleted had to be "+ + "subscription to event FactoryUpgradeStarted had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -739,7 +741,7 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeCompleted( subscriptionFailedFn := func(err error) { becdsakvLogger.Errorf( - "subscription to event FactoryUpgradeCompleted failed "+ + "subscription to event FactoryUpgradeStarted failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -755,11 +757,11 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeCompleted( ) } -func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeCompletedEvents( +func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeStartedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, error) { - iterator, err := becdsakv.contract.FilterFactoryUpgradeCompleted( +) ([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, error) { + iterator, err := becdsakv.contract.FilterFactoryUpgradeStarted( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -767,12 +769,12 @@ func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeCompletedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FactoryUpgradeCompleted events: [%v]", + "error retrieving past FactoryUpgradeStarted events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, 0) + events := make([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, 0) for iterator.Next() { event := iterator.Event @@ -782,9 +784,9 @@ func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeCompletedEvents( return events, nil } -func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeStarted( +func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeCompleted( opts *ethutil.SubscribeOpts, -) *FactoryUpgradeStartedSubscription { +) *FactoryUpgradeCompletedSubscription { if opts == nil { opts = new(ethutil.SubscribeOpts) } @@ -795,27 +797,26 @@ func (becdsakv *BondedECDSAKeepVendor) FactoryUpgradeStarted( opts.PastBlocks = ethutil.DefaultSubscribeOptsPastBlocks } - return &FactoryUpgradeStartedSubscription{ + return &FactoryUpgradeCompletedSubscription{ becdsakv, opts, } } -type FactoryUpgradeStartedSubscription struct { +type FactoryUpgradeCompletedSubscription struct { contract *BondedECDSAKeepVendor opts *ethutil.SubscribeOpts } -type bondedECDSAKeepVendorFactoryUpgradeStartedFunc func( +type bondedECDSAKeepVendorFactoryUpgradeCompletedFunc func( Factory common.Address, - Timestamp *big.Int, blockNumber uint64, ) -func (fuss *FactoryUpgradeStartedSubscription) OnEvent( - handler bondedECDSAKeepVendorFactoryUpgradeStartedFunc, +func (fucs *FactoryUpgradeCompletedSubscription) OnEvent( + handler bondedECDSAKeepVendorFactoryUpgradeCompletedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted) + eventChan := make(chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -826,47 +827,46 @@ func (fuss *FactoryUpgradeStartedSubscription) OnEvent( case event := <-eventChan: handler( event.Factory, - event.Timestamp, event.Raw.BlockNumber, ) } } }() - sub := fuss.Pipe(eventChan) + sub := fucs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fuss *FactoryUpgradeStartedSubscription) Pipe( - sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, +func (fucs *FactoryUpgradeCompletedSubscription) Pipe( + sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fuss.opts.Tick) + ticker := time.NewTicker(fucs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fuss.contract.blockCounter.CurrentBlock() + lastBlock, err := fucs.contract.blockCounter.CurrentBlock() if err != nil { becdsakvLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fuss.opts.PastBlocks + fromBlock := lastBlock - fucs.opts.PastBlocks becdsakvLogger.Infof( - "subscription monitoring fetching past FactoryUpgradeStarted events "+ + "subscription monitoring fetching past FactoryUpgradeCompleted events "+ "starting from block [%v]", fromBlock, ) - events, err := fuss.contract.PastFactoryUpgradeStartedEvents( + events, err := fucs.contract.PastFactoryUpgradeCompletedEvents( fromBlock, nil, ) @@ -878,7 +878,7 @@ func (fuss *FactoryUpgradeStartedSubscription) Pipe( continue } becdsakvLogger.Infof( - "subscription monitoring fetched [%v] past FactoryUpgradeStarted events", + "subscription monitoring fetched [%v] past FactoryUpgradeCompleted events", len(events), ) @@ -889,7 +889,7 @@ func (fuss *FactoryUpgradeStartedSubscription) Pipe( } }() - sub := fuss.contract.watchFactoryUpgradeStarted( + sub := fucs.contract.watchFactoryUpgradeCompleted( sink, ) @@ -899,11 +899,11 @@ func (fuss *FactoryUpgradeStartedSubscription) Pipe( }) } -func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeStarted( - sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, +func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeCompleted( + sink chan *abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return becdsakv.contract.WatchFactoryUpgradeStarted( + return becdsakv.contract.WatchFactoryUpgradeCompleted( &bind.WatchOpts{Context: ctx}, sink, ) @@ -911,7 +911,7 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeStarted( thresholdViolatedFn := func(elapsed time.Duration) { becdsakvLogger.Errorf( - "subscription to event FactoryUpgradeStarted had to be "+ + "subscription to event FactoryUpgradeCompleted had to be "+ "retried [%s] since the last attempt; please inspect "+ "Ethereum connectivity", elapsed, @@ -920,7 +920,7 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeStarted( subscriptionFailedFn := func(err error) { becdsakvLogger.Errorf( - "subscription to event FactoryUpgradeStarted failed "+ + "subscription to event FactoryUpgradeCompleted failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -936,11 +936,11 @@ func (becdsakv *BondedECDSAKeepVendor) watchFactoryUpgradeStarted( ) } -func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeStartedEvents( +func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeCompletedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, error) { - iterator, err := becdsakv.contract.FilterFactoryUpgradeStarted( +) ([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, error) { + iterator, err := becdsakv.contract.FilterFactoryUpgradeCompleted( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -948,12 +948,12 @@ func (becdsakv *BondedECDSAKeepVendor) PastFactoryUpgradeStartedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FactoryUpgradeStarted events: [%v]", + "error retrieving past FactoryUpgradeCompleted events: [%v]", err, ) } - events := make([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeStarted, 0) + events := make([]*abi.BondedECDSAKeepVendorImplV1FactoryUpgradeCompleted, 0) for iterator.Next() { event := iterator.Event From a5a289a30a6f127d0d3875236eb167a01c04db9e Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 1 Feb 2021 11:15:28 +0100 Subject: [PATCH 08/11] Describe how timeout works for NotifySigningStarted --- pkg/client/event/deduplicator.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/client/event/deduplicator.go b/pkg/client/event/deduplicator.go index 6c56adb86..313f7d699 100644 --- a/pkg/client/event/deduplicator.go +++ b/pkg/client/event/deduplicator.go @@ -102,6 +102,12 @@ func (d *Deduplicator) NotifyKeyGenCompleted(keepAddress common.Address) { // indicating whether the client should proceed with the execution or ignore the // event as a duplicate. // +// An important part of making the decision about approving the event or not is +// to check on-chain if keep is really awaiting for a signature. This check is +// repeated with a timeout specified as a parameter to address problems with +// minor chain reorgs or chain clients state not being synced yet at the moment +// or receiving an event. +// // In case the client proceeds with signing, it should call // NotifySigningCompleted once the protocol completes, no matter if it failed or // succeeded. From 13b0501d32747bf46e855d1943b5ed5462d5d8bc Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 1 Feb 2021 11:16:46 +0100 Subject: [PATCH 09/11] Fixed missing whitespace in docs --- pkg/utils/wrappers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/wrappers.go b/pkg/utils/wrappers.go index beb975420..335f9d0eb 100644 --- a/pkg/utils/wrappers.go +++ b/pkg/utils/wrappers.go @@ -125,7 +125,7 @@ const ( ) // ConfirmWithTimeoutDefaultBackoff executed the provided confirmFn until it -// returnstrue or until it fails or until timeout is hit. It applies +// returns true or until it fails or until timeout is hit. It applies // backoff wait of DefaultConfirmBackoffTime * 2^n before nth execution of // confirmFn. In case the calculated backoff is longer than // DefaultConfirmMaxBackoffTime, DefaultConfirmMaxBackoffTime is applied. From 6fb4c2996c20195ca373e0b8f86f3fed5593fe95 Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Mon, 1 Feb 2021 11:21:20 +0100 Subject: [PATCH 10/11] Extracted NotifySigningStarted timeout to a constant --- pkg/client/client.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index d8bd0def7..d698fc403 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -30,6 +30,13 @@ var logger = log.Logger("keep-ecdsa") // signings by adversaries in case of a chain fork. const blockConfirmations = 12 +// The timeout for executing repeated on-chain check for a keep awaiting +// a signature. Once the client receives a signature requested event, it needs +// to deduplicate it and execute on-chain check. This action is repeated with +// a timeout to address problems with minor chain re-orgs and chain clients not +// being perfectly in sync yet. +const awaitingSignatureEventCheckTimeout = 60 * time.Second + // Handle represents a handle to the ECDSA client. type Handle struct { tssNode *node.Node @@ -552,7 +559,7 @@ func monitorSigningRequests( // checkAwaitingSignature function. func(ctx context.Context) error { shouldHandle, err := eventDeduplicator.NotifySigningStarted( - 60*time.Second, + awaitingSignatureEventCheckTimeout, keepAddress, event.Digest, ) @@ -667,7 +674,7 @@ func checkAwaitingSignature( clientConfig.GetSigningTimeout(), func(ctx context.Context) error { shouldHandle, err := eventDeduplicator.NotifySigningStarted( - 60*time.Second, + awaitingSignatureEventCheckTimeout, keepAddress, latestDigest, ) From 77c355bdc825efd97f23e31750dc63f285f9bd1f Mon Sep 17 00:00:00 2001 From: Piotr Dyraga Date: Tue, 2 Feb 2021 09:11:03 +0100 Subject: [PATCH 11/11] Changed the order of cache checks in shouldMonitorDeposit The previous approach assumed that if the given deposit address is cached in monitoredDepositsCache, shouldMonitorDeposit returns true withoug executing any further checks. Together with acquireMonitoringLock and releaseMonitoringLock it worked fine for most of the cases but not for all of them. Specifically, for the case when the deposit has already transitioned to the next state, we could run into a situation when monitoring lock has already been released and shouldMonitorDeposit returns true just because the client has a member in that deposit, without executing the initial state check. The order of cache checks has been changed in this commit to address it. Also, renamed monitoredDepositsCache to memberDepositsCache, and notMonitoredDepositsCache to notMemberDepositsCache to state it clearly those caches hold information whether the client has or has not a member in the given deposit. The new approach is: 1. Check if the given deposit is in notMonitoredDepositsCache. If so, we are sure the client is not interested in monitoring this deposit no matter what - it has no member in it. 2. Check initial state of the deposit to do not start monitoring for duplicate events from the past. If initial state is not as expected, the client is not interested in monitoring this deposit as the event triggering the monitoring is something from the past that does not match the current chain state. 3. Check if the given deposit is in memberDepositCache. If so, start the monitoring. This check allows to do not repeate getSignerIndex call. If the deposit is not in memberDepositCache, execute getSignerIndex call, check members, update caches and return true or false depending if the client has a member in the deposit. --- pkg/extensions/tbtc/tbtc.go | 57 +++++++++++++--------------- pkg/extensions/tbtc/tbtc_test.go | 65 +++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 33 deletions(-) diff --git a/pkg/extensions/tbtc/tbtc.go b/pkg/extensions/tbtc/tbtc.go index 1b30cd24b..1a00c1c63 100644 --- a/pkg/extensions/tbtc/tbtc.go +++ b/pkg/extensions/tbtc/tbtc.go @@ -85,8 +85,8 @@ type tbtc struct { chain chain.TBTCHandle monitoringLocks sync.Map blockConfirmations uint64 - monitoredDepositsCache *cache.TimeCache - notMonitoredDepositsCache *cache.TimeCache + memberDepositsCache *cache.TimeCache + notMemberDepositsCache *cache.TimeCache signerActionDelayStep time.Duration } @@ -94,8 +94,8 @@ func newTBTC(chain chain.TBTCHandle) *tbtc { return &tbtc{ chain: chain, blockConfirmations: defaultBlockConfirmations, - monitoredDepositsCache: cache.NewTimeCache(monitoringCachePeriod), - notMonitoredDepositsCache: cache.NewTimeCache(monitoringCachePeriod), + memberDepositsCache: cache.NewTimeCache(monitoringCachePeriod), + notMemberDepositsCache: cache.NewTimeCache(monitoringCachePeriod), signerActionDelayStep: defaultSignerActionDelayStep, } } @@ -794,28 +794,10 @@ func (t *tbtc) shouldMonitorDeposit( depositAddress string, expectedInitialState chain.DepositState, ) bool { - t.monitoredDepositsCache.Sweep() - t.notMonitoredDepositsCache.Sweep() + t.memberDepositsCache.Sweep() + t.notMemberDepositsCache.Sweep() - if t.monitoredDepositsCache.Has(depositAddress) { - return true - } - - if t.notMonitoredDepositsCache.Has(depositAddress) { - return false - } - - signerIndex, err := t.getSignerIndex(depositAddress) - if err != nil { - logger.Errorf( - "could not check if deposit [%v] should be monitored: "+ - "failed to get signer index: [%v]", - depositAddress, - err, - ) - // return false but don't cache the result in case of an error; - // it gives a chance to retry the monitoring later but sooner - // than notMonitoredDepositsCache caching period. + if t.notMemberDepositsCache.Has(depositAddress) { return false } @@ -837,23 +819,36 @@ func (t *tbtc) shouldMonitorDeposit( depositAddress, err, ) - // return false but don't cache the result in case of an error; - // it gives a chance to retry the monitoring later but sooner - // than notMonitoredDepositsCache caching period. + // return false but don't cache the result in case of an error return false } if !hasInitialState { // false start signal, probably an old event - t.notMonitoredDepositsCache.Add(depositAddress) + return false + } + + if t.memberDepositsCache.Has(depositAddress) { + return true + } + + signerIndex, err := t.getSignerIndex(depositAddress) + if err != nil { + logger.Errorf( + "could not check if deposit [%v] should be monitored: "+ + "failed to get signer index: [%v]", + depositAddress, + err, + ) + // return false but don't cache the result in case of an error return false } if signerIndex < 0 { - t.notMonitoredDepositsCache.Add(depositAddress) + t.notMemberDepositsCache.Add(depositAddress) return false } - t.monitoredDepositsCache.Add(depositAddress) + t.memberDepositsCache.Add(depositAddress) return true } diff --git a/pkg/extensions/tbtc/tbtc_test.go b/pkg/extensions/tbtc/tbtc_test.go index 5c89db839..1d8213203 100644 --- a/pkg/extensions/tbtc/tbtc_test.go +++ b/pkg/extensions/tbtc/tbtc_test.go @@ -2025,6 +2025,9 @@ func TestShouldMonitorDeposit_ExpectedInitialState(t *testing.T) { } tbtcChain.RetrieveSignerPubkey(depositAddress) + // Deposit has just retrieved signer public key and is in + // AwaitingSignerSetup state. shouldMonitorDeposit should return false for + // any other state than AwaitingSignerSetup. shouldMonitor := tbtc.shouldMonitorDeposit( 5*time.Second, depositAddress, @@ -2056,6 +2059,9 @@ func TestShouldMonitorDeposit_UnexpectedInitialState(t *testing.T) { } tbtcChain.RetrieveSignerPubkey(depositAddress) + // Deposit has just retrieved signer public key and is in + // AwaitingSignerSetup state. shouldMonitorDeposit should return true + // for this state. shouldMonitor := tbtc.shouldMonitorDeposit( 5*time.Second, depositAddress, @@ -2066,7 +2072,62 @@ func TestShouldMonitorDeposit_UnexpectedInitialState(t *testing.T) { } } -func TestShouldMonitorDeposit_PositiveResultCache(t *testing.T) { +func TestShouldMonitorDeposit_InitialStateChange(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + + tbtcChain := local.NewTBTCLocalChain(ctx) + tbtc := newTestTBTC(tbtcChain) + + // create a signing group which contains the operator + signers := append( + []common.Address{tbtcChain.Address()}, + local.RandomSigningGroup(2)..., + ) + + tbtcChain.CreateDeposit(depositAddress, signers) + _, err := submitKeepPublicKey(depositAddress, tbtcChain) + if err != nil { + t.Fatal(err) + } + + // Deposit has just been created and it is in AwaitingSignerSetup state. + // This first check will setup *some* caching in shouldMonitorDeposit and + // further checks will make sure this caching works as expected when the + // state changed. + shouldMonitor := tbtc.shouldMonitorDeposit( + 5*time.Second, + depositAddress, + chain.AwaitingSignerSetup, + ) + if !shouldMonitor { + t.Errorf("should monitor the deposit for AwaitingSignerSetup state") + } + + tbtcChain.RetrieveSignerPubkey(depositAddress) + + // Deposit state has changed and it is now in AwaitingBtcFundingProof. + // Those checks make sure the caching inside shouldMonitorDeposit does not + // affect the result for changed state. + shouldMonitor = tbtc.shouldMonitorDeposit( + 5*time.Second, + depositAddress, + chain.AwaitingBtcFundingProof, + ) + if !shouldMonitor { + t.Errorf("should monitor the deposit for AwaitingBtcFundingProof state") + } + shouldMonitor = tbtc.shouldMonitorDeposit( + 5*time.Second, + depositAddress, + chain.AwaitingSignerSetup, + ) + if shouldMonitor { + t.Errorf("should not monitor the deposit for AwaitingSignerSetup state") + } +} + +func TestShouldMonitorDeposit_MemberCache(t *testing.T) { ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx() @@ -2116,7 +2177,7 @@ func TestShouldMonitorDeposit_PositiveResultCache(t *testing.T) { } } -func TestShouldMonitorDeposit_NegativeResultCache(t *testing.T) { +func TestShouldMonitorDeposit_NotMemberCache(t *testing.T) { ctx, cancelCtx := context.WithCancel(context.Background()) defer cancelCtx()