diff --git a/docs/resources/client-start-help b/docs/resources/client-start-help index 09bc3386aa..bf6cf5769e 100644 --- a/docs/resources/client-start-help +++ b/docs/resources/client-start-help @@ -31,7 +31,7 @@ Flags: --tbtc.preParamsGenerationTimeout duration tECDSA pre-parameters generation timeout. (default 2m0s) --tbtc.preParamsGenerationDelay duration tECDSA pre-parameters generation delay. (default 10s) --tbtc.preParamsGenerationConcurrency int tECDSA pre-parameters generation concurrency. (default 1) - --tbtc.keyGenerationConcurrency int tECDSA key generation concurrency. (default number of cores) + --tbtc.keyGenerationConcurrency int tECDSA key generation concurrency. (default 10) --developer.bridgeAddress string Address of the Bridge smart contract --developer.maintainerProxyAddress string Address of the MaintainerProxy smart contract --developer.lightRelayAddress string Address of the LightRelay smart contract diff --git a/pkg/beacon/registry/gen/pb/message.pb.go b/pkg/beacon/registry/gen/pb/message.pb.go index 9d61871f9d..c1d74e8947 100644 --- a/pkg/beacon/registry/gen/pb/message.pb.go +++ b/pkg/beacon/registry/gen/pb/message.pb.go @@ -1,16 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/beacon/registry/gen/pb/message.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/pkg/chain/ethereum/beacon/gen/_address/RandomBeacon b/pkg/chain/ethereum/beacon/gen/_address/RandomBeacon index e69de29bb2..c0bcc4f49f 100644 --- a/pkg/chain/ethereum/beacon/gen/_address/RandomBeacon +++ b/pkg/chain/ethereum/beacon/gen/_address/RandomBeacon @@ -0,0 +1 @@ +0x02CBA6D77CF9fB019e322c55b34c9d42f2eF4D74 \ No newline at end of file diff --git a/pkg/chain/ethereum/ecdsa/gen/_address/WalletRegistry b/pkg/chain/ethereum/ecdsa/gen/_address/WalletRegistry index e69de29bb2..3977c205dd 100644 --- a/pkg/chain/ethereum/ecdsa/gen/_address/WalletRegistry +++ b/pkg/chain/ethereum/ecdsa/gen/_address/WalletRegistry @@ -0,0 +1 @@ +0x2DfC89675AB5Fb5Be7c2A86d373Daac3E795fc25 \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index f4a27b4ffd..ede2fac1ae 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -49,6 +49,7 @@ type TbtcChain struct { walletRegistry *ecdsacontract.WalletRegistry sortitionPool *ecdsacontract.EcdsaSortitionPool walletCoordinator *tbtccontract.WalletCoordinator + lightRelay *tbtccontract.LightRelay } // NewTbtcChain construct a new instance of the TBTC-specific Ethereum @@ -194,6 +195,34 @@ func newTbtcChain( ) } + lightRelayAddress, err := config.ContractAddress( + LightRelayContractName, + ) + if err != nil { + return nil, fmt.Errorf( + "failed to attach to LightRelay contract: [%w]", + err, + ) + } + + lightRelay, err := + tbtccontract.NewLightRelay( + lightRelayAddress, + baseChain.chainID, + baseChain.key, + baseChain.client, + baseChain.nonceManager, + baseChain.miningWaiter, + baseChain.blockCounter, + baseChain.transactionMutex, + ) + if err != nil { + return nil, fmt.Errorf( + "failed to attach to LightRelay contract: [%w]", + err, + ) + } + return &TbtcChain{ baseChain: baseChain, bridge: bridge, @@ -201,6 +230,7 @@ func newTbtcChain( walletRegistry: walletRegistry, sortitionPool: sortitionPool, walletCoordinator: walletCoordinator, + lightRelay: lightRelay, }, nil } @@ -1449,6 +1479,11 @@ func (tc *TbtcChain) SubmitRedemptionProofWithReimbursement( TxOutputValue: uint64(mainUTXO.Value), } + _, err := tc.lightRelay.SetDifficultyFromHeaders(sweepProof.BitcoinHeaders) + if err != nil { + return err + } + gasEstimate, err := tc.maintainerProxy.SubmitRedemptionProofGasEstimate( bitcoinTxInfo, sweepProof, @@ -1525,6 +1560,11 @@ func (tc *TbtcChain) SubmitDepositSweepProofWithReimbursement( TxOutputValue: uint64(mainUTXO.Value), } + _, err := tc.lightRelay.SetDifficultyFromHeaders(sweepProof.BitcoinHeaders) + if err != nil { + return err + } + gasEstimate, err := tc.maintainerProxy.SubmitDepositSweepProofGasEstimate( bitcoinTxInfo, sweepProof, diff --git a/pkg/chain/ethereum/tbtc/gen/_address/Bridge b/pkg/chain/ethereum/tbtc/gen/_address/Bridge index e69de29bb2..a5eabcabde 100644 --- a/pkg/chain/ethereum/tbtc/gen/_address/Bridge +++ b/pkg/chain/ethereum/tbtc/gen/_address/Bridge @@ -0,0 +1 @@ +0x9b1a7fE5a16A15F2f9475C5B231750598b113403 \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc/gen/_address/LightRelay b/pkg/chain/ethereum/tbtc/gen/_address/LightRelay index e69de29bb2..bba7e153e6 100644 --- a/pkg/chain/ethereum/tbtc/gen/_address/LightRelay +++ b/pkg/chain/ethereum/tbtc/gen/_address/LightRelay @@ -0,0 +1 @@ +0x998D17122dA4ed98e558198665984E08D1cEAA8d \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc/gen/_address/LightRelayMaintainerProxy b/pkg/chain/ethereum/tbtc/gen/_address/LightRelayMaintainerProxy index e69de29bb2..627c40153d 100644 --- a/pkg/chain/ethereum/tbtc/gen/_address/LightRelayMaintainerProxy +++ b/pkg/chain/ethereum/tbtc/gen/_address/LightRelayMaintainerProxy @@ -0,0 +1 @@ +0xA669AC294BCf04CEeB5EBC26d9E1bF4fc4574e06 \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc/gen/_address/MaintainerProxy b/pkg/chain/ethereum/tbtc/gen/_address/MaintainerProxy index e69de29bb2..4fc51b87b8 100644 --- a/pkg/chain/ethereum/tbtc/gen/_address/MaintainerProxy +++ b/pkg/chain/ethereum/tbtc/gen/_address/MaintainerProxy @@ -0,0 +1 @@ +0xCE85405123Ed0DC2596B4FCB9a2Fe15Bc59ff886 \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator b/pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator index 8b13789179..eaea281ffb 100644 --- a/pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator +++ b/pkg/chain/ethereum/tbtc/gen/_address/WalletCoordinator @@ -1 +1 @@ - +0x4ABE632d4fb69b895A242616b09C5596D6D8de7F \ No newline at end of file diff --git a/pkg/chain/ethereum/tbtc/gen/abi/LightRelay.go b/pkg/chain/ethereum/tbtc/gen/abi/LightRelay.go index 971aae98b0..4b303b8a03 100644 --- a/pkg/chain/ethereum/tbtc/gen/abi/LightRelay.go +++ b/pkg/chain/ethereum/tbtc/gen/abi/LightRelay.go @@ -30,7 +30,7 @@ var ( // LightRelayMetaData contains all meta data concerning the LightRelay contract. var LightRelayMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newStatus\",\"type\":\"bool\"}],\"name\":\"AuthorizationRequirementChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"}],\"name\":\"Genesis\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newLength\",\"type\":\"uint256\"}],\"name\":\"ProofLengthChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDifficulty\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDifficulty\",\"type\":\"uint256\"}],\"name\":\"Retarget\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterAuthorized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterDeauthorized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"authorizationRequired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"authorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"deauthorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"genesisHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"genesisHeight\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"genesisProofLength\",\"type\":\"uint64\"}],\"name\":\"genesis\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentAndPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"current\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previous\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRelayRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"relayGenesis\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentEpochEnd\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isAuthorized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofLength\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ready\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"retarget\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setAuthorizationStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newLength\",\"type\":\"uint64\"}],\"name\":\"setProofLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"validateChain\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"startingHeaderTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"headerCount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"newStatus\",\"type\":\"bool\"}],\"name\":\"AuthorizationRequirementChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"blockHeight\",\"type\":\"uint256\"}],\"name\":\"Genesis\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newLength\",\"type\":\"uint256\"}],\"name\":\"ProofLengthChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldDifficulty\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newDifficulty\",\"type\":\"uint256\"}],\"name\":\"Retarget\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterAuthorized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"SubmitterDeauthorized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"authorizationRequired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"authorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"currentEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"deauthorize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"genesisHeader\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"genesisHeight\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"genesisProofLength\",\"type\":\"uint64\"}],\"name\":\"genesis\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisEpoch\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getBlockDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentAndPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"current\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previous\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"epochNumber\",\"type\":\"uint256\"}],\"name\":\"getEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getPrevEpochDifficulty\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRelayRange\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"relayGenesis\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentEpochEnd\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isAuthorized\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"proofLength\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ready\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"retarget\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"status\",\"type\":\"bool\"}],\"name\":\"setAuthorizationStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"}],\"name\":\"setDifficultyFromHeaders\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newLength\",\"type\":\"uint64\"}],\"name\":\"setProofLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"headers\",\"type\":\"bytes\"}],\"name\":\"validateChain\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"startingHeaderTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"headerCount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // LightRelayABI is the input ABI used to generate the binding from. @@ -781,6 +781,27 @@ func (_LightRelay *LightRelayTransactorSession) SetAuthorizationStatus(status bo return _LightRelay.Contract.SetAuthorizationStatus(&_LightRelay.TransactOpts, status) } +// SetDifficultyFromHeaders is a paid mutator transaction binding the contract method 0xd38c29a1. +// +// Solidity: function setDifficultyFromHeaders(bytes bitcoinHeaders) returns() +func (_LightRelay *LightRelayTransactor) SetDifficultyFromHeaders(opts *bind.TransactOpts, bitcoinHeaders []byte) (*types.Transaction, error) { + return _LightRelay.contract.Transact(opts, "setDifficultyFromHeaders", bitcoinHeaders) +} + +// SetDifficultyFromHeaders is a paid mutator transaction binding the contract method 0xd38c29a1. +// +// Solidity: function setDifficultyFromHeaders(bytes bitcoinHeaders) returns() +func (_LightRelay *LightRelaySession) SetDifficultyFromHeaders(bitcoinHeaders []byte) (*types.Transaction, error) { + return _LightRelay.Contract.SetDifficultyFromHeaders(&_LightRelay.TransactOpts, bitcoinHeaders) +} + +// SetDifficultyFromHeaders is a paid mutator transaction binding the contract method 0xd38c29a1. +// +// Solidity: function setDifficultyFromHeaders(bytes bitcoinHeaders) returns() +func (_LightRelay *LightRelayTransactorSession) SetDifficultyFromHeaders(bitcoinHeaders []byte) (*types.Transaction, error) { + return _LightRelay.Contract.SetDifficultyFromHeaders(&_LightRelay.TransactOpts, bitcoinHeaders) +} + // SetProofLength is a paid mutator transaction binding the contract method 0x19c9aa32. // // Solidity: function setProofLength(uint64 newLength) returns() diff --git a/pkg/chain/ethereum/tbtc/gen/cmd/LightRelay.go b/pkg/chain/ethereum/tbtc/gen/cmd/LightRelay.go index 721e19da72..aa4906c93b 100644 --- a/pkg/chain/ethereum/tbtc/gen/cmd/LightRelay.go +++ b/pkg/chain/ethereum/tbtc/gen/cmd/LightRelay.go @@ -70,6 +70,7 @@ func init() { lrRenounceOwnershipCommand(), lrRetargetCommand(), lrSetAuthorizationStatusCommand(), + lrSetDifficultyFromHeadersCommand(), lrSetProofLengthCommand(), lrTransferOwnershipCommand(), ) @@ -990,6 +991,71 @@ func lrSetAuthorizationStatus(c *cobra.Command, args []string) error { return nil } +func lrSetDifficultyFromHeadersCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-difficulty-from-headers [arg_bitcoinHeaders]", + Short: "Calls the nonpayable method setDifficultyFromHeaders on the LightRelay contract.", + Args: cmd.ArgCountChecker(1), + RunE: lrSetDifficultyFromHeaders, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func lrSetDifficultyFromHeaders(c *cobra.Command, args []string) error { + contract, err := initializeLightRelay(c) + if err != nil { + return err + } + + arg_bitcoinHeaders, err := hexutil.Decode(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_bitcoinHeaders, a bytes, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetDifficultyFromHeaders( + arg_bitcoinHeaders, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetDifficultyFromHeaders( + arg_bitcoinHeaders, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + func lrSetProofLengthCommand() *cobra.Command { c := &cobra.Command{ Use: "set-proof-length [arg_newLength]", diff --git a/pkg/chain/ethereum/tbtc/gen/contract/LightRelay.go b/pkg/chain/ethereum/tbtc/gen/contract/LightRelay.go index 8337363521..8e654dfb11 100644 --- a/pkg/chain/ethereum/tbtc/gen/contract/LightRelay.go +++ b/pkg/chain/ethereum/tbtc/gen/contract/LightRelay.go @@ -938,6 +938,144 @@ func (lr *LightRelay) SetAuthorizationStatusGasEstimate( return result, err } +// Transaction submission. +func (lr *LightRelay) SetDifficultyFromHeaders( + arg_bitcoinHeaders []byte, + + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + lrLogger.Debug( + "submitting transaction setDifficultyFromHeaders", + " params: ", + fmt.Sprint( + arg_bitcoinHeaders, + ), + ) + + lr.transactionMutex.Lock() + defer lr.transactionMutex.Unlock() + + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *lr.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 := lr.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 := lr.contract.SetDifficultyFromHeaders( + transactorOptions, + arg_bitcoinHeaders, + ) + if err != nil { + return transaction, lr.errorResolver.ResolveError( + err, + lr.transactorOptions.From, + nil, + "setDifficultyFromHeaders", + arg_bitcoinHeaders, + ) + } + + lrLogger.Infof( + "submitted transaction setDifficultyFromHeaders with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + go lr.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } + + transaction, err := lr.contract.SetDifficultyFromHeaders( + newTransactorOptions, + arg_bitcoinHeaders, + ) + if err != nil { + return nil, lr.errorResolver.ResolveError( + err, + lr.transactorOptions.From, + nil, + "setDifficultyFromHeaders", + arg_bitcoinHeaders, + ) + } + + lrLogger.Infof( + "submitted transaction setDifficultyFromHeaders with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + return transaction, nil + }, + ) + + lr.nonceManager.IncrementNonce() + + return transaction, err +} + +// Non-mutating call, not a transaction submission. +func (lr *LightRelay) CallSetDifficultyFromHeaders( + arg_bitcoinHeaders []byte, + blockNumber *big.Int, +) error { + var result interface{} = nil + + err := chainutil.CallAtBlock( + lr.transactorOptions.From, + blockNumber, nil, + lr.contractABI, + lr.caller, + lr.errorResolver, + lr.contractAddress, + "setDifficultyFromHeaders", + &result, + arg_bitcoinHeaders, + ) + + return err +} + +func (lr *LightRelay) SetDifficultyFromHeadersGasEstimate( + arg_bitcoinHeaders []byte, +) (uint64, error) { + var result uint64 + + result, err := chainutil.EstimateGas( + lr.callerOptions.From, + lr.contractAddress, + "setDifficultyFromHeaders", + lr.contractABI, + lr.transactor, + arg_bitcoinHeaders, + ) + + return result, err +} + // Transaction submission. func (lr *LightRelay) SetProofLength( arg_newLength uint64, diff --git a/pkg/chain/ethereum/threshold/gen/_address/TokenStaking b/pkg/chain/ethereum/threshold/gen/_address/TokenStaking index e69de29bb2..0fefc6317f 100644 --- a/pkg/chain/ethereum/threshold/gen/_address/TokenStaking +++ b/pkg/chain/ethereum/threshold/gen/_address/TokenStaking @@ -0,0 +1 @@ +0x3d4cb85c0e3c5bd1667B7E30f3E86B3FAB878Ff8 \ No newline at end of file diff --git a/pkg/chain/ethereum/threshold/gen/abi/TokenStaking.go b/pkg/chain/ethereum/threshold/gen/abi/TokenStaking.go index 5ded783bbb..c26bc59b38 100644 --- a/pkg/chain/ethereum/threshold/gen/abi/TokenStaking.go +++ b/pkg/chain/ethereum/threshold/gen/abi/TokenStaking.go @@ -36,7 +36,7 @@ type CheckpointsCheckpoint struct { // TokenStakingMetaData contains all meta data concerning the TokenStaking contract. var TokenStakingMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractT\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"contractIKeepTokenStaking\",\"name\":\"_keepStakingContract\",\"type\":\"address\"},{\"internalType\":\"contractINuCypherStakingEscrow\",\"name\":\"_nucypherStakingContract\",\"type\":\"address\"},{\"internalType\":\"contractVendingMachine\",\"name\":\"_keepVendingMachine\",\"type\":\"address\"},{\"internalType\":\"contractVendingMachine\",\"name\":\"_nucypherVendingMachine\",\"type\":\"address\"},{\"internalType\":\"contractKeepStake\",\"name\":\"_keepStake\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enumTokenStaking.ApplicationStatus\",\"name\":\"newStatus\",\"type\":\"uint8\"}],\"name\":\"ApplicationStatusChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"ceiling\",\"type\":\"uint256\"}],\"name\":\"AuthorizationCeilingSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationDecreaseApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationDecreaseRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationIncreased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"},{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"successfulCall\",\"type\":\"bool\"}],\"name\":\"AuthorizationInvoluntaryDecreased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGovernance\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"GovernanceTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"MinimumStakeAmountSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardPushed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"notifier\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"NotifierRewarded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnerRefreshed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"name\":\"PanicButtonSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"}],\"name\":\"SlashingProcessed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"penalty\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"}],\"name\":\"StakeDiscrepancyPenaltySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enumIStaking.StakeType\",\"name\":\"stakeType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"discrepancy\",\"type\":\"bool\"}],\"name\":\"TokensSeized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"ToppedUp\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"applicationInfo\",\"outputs\":[{\"internalType\":\"enumTokenStaking.ApplicationStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"applications\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"approveApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"approveAuthorizationDecrease\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"authorizationCeiling\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"authorizedStake\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"pos\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"structCheckpoints.Checkpoint\",\"name\":\"checkpoint\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegateVoting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"disableApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"forceDecreaseAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getApplicationsLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"getAvailableToAuthorize\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"availableTValue\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"enumIStaking.StakeType\",\"name\":\"stakeTypes\",\"type\":\"uint8\"}],\"name\":\"getMinStaked\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastTotalSupply\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSlashingQueueLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"getStartStakingTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"increaseAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTStakeAmount\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notificationReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notifiersTreasury\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"notifyKeepStakeDiscrepancy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"notifyNuStakeDiscrepancy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"pauseApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"processSlashing\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"pushNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"refreshKeepStakeOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"requestAuthorizationDecrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestAuthorizationDecrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"rolesOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"notifier\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_stakingProviders\",\"type\":\"address[]\"}],\"name\":\"seize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"ceiling\",\"type\":\"uint256\"}],\"name\":\"setAuthorizationCeiling\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"setMinimumStakeAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"setNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"name\":\"setPanicButton\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"penalty\",\"type\":\"uint96\"},{\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"}],\"name\":\"setStakeDiscrepancyPenalty\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"internalType\":\"address[]\",\"name\":\"_stakingProviders\",\"type\":\"address[]\"}],\"name\":\"slash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"slashingQueue\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"slashingQueueIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDiscrepancyPenalty\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDiscrepancyRewardMultiplier\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakeKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"}],\"name\":\"stakeNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakedNu\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nuAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"tStake\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"keepInTStake\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"nuInTStake\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"topUp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"topUpKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"topUpNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGuvnor\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"unstakeAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"unstakeKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"unstakeNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"unstakeT\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"withdrawNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"contractT\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"contractIKeepTokenStaking\",\"name\":\"_keepStakingContract\",\"type\":\"address\"},{\"internalType\":\"contractINuCypherStakingEscrow\",\"name\":\"_nucypherStakingContract\",\"type\":\"address\"},{\"internalType\":\"contractVendingMachine\",\"name\":\"_keepVendingMachine\",\"type\":\"address\"},{\"internalType\":\"contractVendingMachine\",\"name\":\"_nucypherVendingMachine\",\"type\":\"address\"},{\"internalType\":\"contractKeepStake\",\"name\":\"_keepStake\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"enumTokenStaking.ApplicationStatus\",\"name\":\"newStatus\",\"type\":\"uint8\"}],\"name\":\"ApplicationStatusChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"ceiling\",\"type\":\"uint256\"}],\"name\":\"AuthorizationCeilingSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationDecreaseApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationDecreaseRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"}],\"name\":\"AuthorizationIncreased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fromAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"toAmount\",\"type\":\"uint96\"},{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"successfulCall\",\"type\":\"bool\"}],\"name\":\"AuthorizationInvoluntaryDecreased\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGovernance\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"GovernanceTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"MinimumStakeAmountSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardPushed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"NotificationRewardWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"notifier\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"NotifierRewarded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnerRefreshed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"name\":\"PanicButtonSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tAmount\",\"type\":\"uint256\"}],\"name\":\"SlashingProcessed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"penalty\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"}],\"name\":\"StakeDiscrepancyPenaltySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enumIStaking.StakeType\",\"name\":\"stakeType\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"indexed\":true,\"internalType\":\"bool\",\"name\":\"discrepancy\",\"type\":\"bool\"}],\"name\":\"TokensSeized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"ToppedUp\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"applicationInfo\",\"outputs\":[{\"internalType\":\"enumTokenStaking.ApplicationStatus\",\"name\":\"status\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"applications\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"approveApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"approveAuthorizationDecrease\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"authorizationCeiling\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"authorizedStake\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"pos\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"structCheckpoints.Checkpoint\",\"name\":\"checkpoint\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegateVoting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"disableApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"forceDecreaseAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getApplicationsLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"getAvailableToAuthorize\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"availableTValue\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"enumIStaking.StakeType\",\"name\":\"stakeTypes\",\"type\":\"uint8\"}],\"name\":\"getMinStaked\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastTotalSupply\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSlashingQueueLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"getStartStakingTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"increaseAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minTStakeAmount\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notificationReward\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notifiersTreasury\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"notifyKeepStakeDiscrepancy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"notifyNuStakeDiscrepancy\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"}],\"name\":\"pauseApplication\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"processSlashing\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"pushNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"requestAuthorizationDecrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"requestAuthorizationDecrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"rolesOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"notifier\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_stakingProviders\",\"type\":\"address[]\"}],\"name\":\"seize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"ceiling\",\"type\":\"uint256\"}],\"name\":\"setAuthorizationCeiling\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"setMinimumStakeAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"reward\",\"type\":\"uint96\"}],\"name\":\"setNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"application\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"panicButton\",\"type\":\"address\"}],\"name\":\"setPanicButton\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"penalty\",\"type\":\"uint96\"},{\"internalType\":\"uint256\",\"name\":\"rewardMultiplier\",\"type\":\"uint256\"}],\"name\":\"setStakeDiscrepancyPenalty\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"},{\"internalType\":\"address[]\",\"name\":\"_stakingProviders\",\"type\":\"address[]\"}],\"name\":\"slash\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"slashingQueue\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"slashingQueueIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDiscrepancyPenalty\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDiscrepancyRewardMultiplier\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakeKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"}],\"name\":\"stakeNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakedNu\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"nuAmount\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"stakes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"tStake\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"keepInTStake\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"nuInTStake\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"topUp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"topUpKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"topUpNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGuvnor\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"unstakeAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"}],\"name\":\"unstakeKeep\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"unstakeNu\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"stakingProvider\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"unstakeT\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"amount\",\"type\":\"uint96\"}],\"name\":\"withdrawNotificationReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // TokenStakingABI is the input ABI used to generate the binding from. @@ -1309,27 +1309,6 @@ func (_TokenStaking *TokenStakingTransactorSession) PushNotificationReward(rewar return _TokenStaking.Contract.PushNotificationReward(&_TokenStaking.TransactOpts, reward) } -// RefreshKeepStakeOwner is a paid mutator transaction binding the contract method 0xaf5f24ad. -// -// Solidity: function refreshKeepStakeOwner(address stakingProvider) returns() -func (_TokenStaking *TokenStakingTransactor) RefreshKeepStakeOwner(opts *bind.TransactOpts, stakingProvider common.Address) (*types.Transaction, error) { - return _TokenStaking.contract.Transact(opts, "refreshKeepStakeOwner", stakingProvider) -} - -// RefreshKeepStakeOwner is a paid mutator transaction binding the contract method 0xaf5f24ad. -// -// Solidity: function refreshKeepStakeOwner(address stakingProvider) returns() -func (_TokenStaking *TokenStakingSession) RefreshKeepStakeOwner(stakingProvider common.Address) (*types.Transaction, error) { - return _TokenStaking.Contract.RefreshKeepStakeOwner(&_TokenStaking.TransactOpts, stakingProvider) -} - -// RefreshKeepStakeOwner is a paid mutator transaction binding the contract method 0xaf5f24ad. -// -// Solidity: function refreshKeepStakeOwner(address stakingProvider) returns() -func (_TokenStaking *TokenStakingTransactorSession) RefreshKeepStakeOwner(stakingProvider common.Address) (*types.Transaction, error) { - return _TokenStaking.Contract.RefreshKeepStakeOwner(&_TokenStaking.TransactOpts, stakingProvider) -} - // RequestAuthorizationDecrease is a paid mutator transaction binding the contract method 0x5f2d5030. // // Solidity: function requestAuthorizationDecrease(address stakingProvider, address application, uint96 amount) returns() diff --git a/pkg/chain/ethereum/threshold/gen/cmd/TokenStaking.go b/pkg/chain/ethereum/threshold/gen/cmd/TokenStaking.go index 43f3eda9e0..95af3c9c0b 100644 --- a/pkg/chain/ethereum/threshold/gen/cmd/TokenStaking.go +++ b/pkg/chain/ethereum/threshold/gen/cmd/TokenStaking.go @@ -88,7 +88,6 @@ func init() { tsPauseApplicationCommand(), tsProcessSlashingCommand(), tsPushNotificationRewardCommand(), - tsRefreshKeepStakeOwnerCommand(), tsRequestAuthorizationDecreaseCommand(), tsRequestAuthorizationDecrease0Command(), tsSetAuthorizationCeilingCommand(), @@ -1991,71 +1990,6 @@ func tsPushNotificationReward(c *cobra.Command, args []string) error { return nil } -func tsRefreshKeepStakeOwnerCommand() *cobra.Command { - c := &cobra.Command{ - Use: "refresh-keep-stake-owner [arg_stakingProvider]", - Short: "Calls the nonpayable method refreshKeepStakeOwner on the TokenStaking contract.", - Args: cmd.ArgCountChecker(1), - RunE: tsRefreshKeepStakeOwner, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func tsRefreshKeepStakeOwner(c *cobra.Command, args []string) error { - contract, err := initializeTokenStaking(c) - if err != nil { - return err - } - - arg_stakingProvider, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_stakingProvider, a address, from passed value %v", - args[0], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.RefreshKeepStakeOwner( - arg_stakingProvider, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallRefreshKeepStakeOwner( - arg_stakingProvider, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - func tsRequestAuthorizationDecreaseCommand() *cobra.Command { c := &cobra.Command{ Use: "request-authorization-decrease [arg_stakingProvider] [arg_application] [arg_amount]", diff --git a/pkg/chain/ethereum/threshold/gen/contract/TokenStaking.go b/pkg/chain/ethereum/threshold/gen/contract/TokenStaking.go index 633094047c..040c4ca3ca 100644 --- a/pkg/chain/ethereum/threshold/gen/contract/TokenStaking.go +++ b/pkg/chain/ethereum/threshold/gen/contract/TokenStaking.go @@ -1786,144 +1786,6 @@ func (ts *TokenStaking) PushNotificationRewardGasEstimate( return result, err } -// Transaction submission. -func (ts *TokenStaking) RefreshKeepStakeOwner( - arg_stakingProvider common.Address, - - transactionOptions ...chainutil.TransactionOptions, -) (*types.Transaction, error) { - tsLogger.Debug( - "submitting transaction refreshKeepStakeOwner", - " params: ", - fmt.Sprint( - arg_stakingProvider, - ), - ) - - ts.transactionMutex.Lock() - defer ts.transactionMutex.Unlock() - - // create a copy - transactorOptions := new(bind.TransactOpts) - *transactorOptions = *ts.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 := ts.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 := ts.contract.RefreshKeepStakeOwner( - transactorOptions, - arg_stakingProvider, - ) - if err != nil { - return transaction, ts.errorResolver.ResolveError( - err, - ts.transactorOptions.From, - nil, - "refreshKeepStakeOwner", - arg_stakingProvider, - ) - } - - tsLogger.Infof( - "submitted transaction refreshKeepStakeOwner with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - go ts.miningWaiter.ForceMining( - transaction, - transactorOptions, - func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { - // If original transactor options has a non-zero gas limit, that - // means the client code set it on their own. In that case, we - // should rewrite the gas limit from the original transaction - // for each resubmission. If the gas limit is not set by the client - // code, let the the submitter re-estimate the gas limit on each - // resubmission. - if transactorOptions.GasLimit != 0 { - newTransactorOptions.GasLimit = transactorOptions.GasLimit - } - - transaction, err := ts.contract.RefreshKeepStakeOwner( - newTransactorOptions, - arg_stakingProvider, - ) - if err != nil { - return nil, ts.errorResolver.ResolveError( - err, - ts.transactorOptions.From, - nil, - "refreshKeepStakeOwner", - arg_stakingProvider, - ) - } - - tsLogger.Infof( - "submitted transaction refreshKeepStakeOwner with id: [%s] and nonce [%v]", - transaction.Hash(), - transaction.Nonce(), - ) - - return transaction, nil - }, - ) - - ts.nonceManager.IncrementNonce() - - return transaction, err -} - -// Non-mutating call, not a transaction submission. -func (ts *TokenStaking) CallRefreshKeepStakeOwner( - arg_stakingProvider common.Address, - blockNumber *big.Int, -) error { - var result interface{} = nil - - err := chainutil.CallAtBlock( - ts.transactorOptions.From, - blockNumber, nil, - ts.contractABI, - ts.caller, - ts.errorResolver, - ts.contractAddress, - "refreshKeepStakeOwner", - &result, - arg_stakingProvider, - ) - - return err -} - -func (ts *TokenStaking) RefreshKeepStakeOwnerGasEstimate( - arg_stakingProvider common.Address, -) (uint64, error) { - var result uint64 - - result, err := chainutil.EstimateGas( - ts.callerOptions.From, - ts.contractAddress, - "refreshKeepStakeOwner", - ts.contractABI, - ts.transactor, - arg_stakingProvider, - ) - - return result, err -} - // Transaction submission. func (ts *TokenStaking) RequestAuthorizationDecrease( arg_stakingProvider common.Address, diff --git a/pkg/maintainer/spv/spv.go b/pkg/maintainer/spv/spv.go index 50de02189a..b9892caa39 100644 --- a/pkg/maintainer/spv/spv.go +++ b/pkg/maintainer/spv/spv.go @@ -5,7 +5,6 @@ import ( "context" "encoding/hex" "fmt" - "math/big" "time" "github.com/keep-network/keep-core/pkg/tbtc" @@ -166,7 +165,7 @@ func (sm *spvMaintainer) proveTransactions( transactionHashStr, ) - isProofWithinRelayRange, accumulatedConfirmations, requiredConfirmations, err := getProofInfo( + _, accumulatedConfirmations, requiredConfirmations, err := getProofInfo( transaction.Hash(), sm.btcChain, sm.spvChain, @@ -176,19 +175,6 @@ func (sm *spvMaintainer) proveTransactions( return fmt.Errorf("failed to get proof info: [%v]", err) } - if !isProofWithinRelayRange { - // The required proof goes outside the previous and current - // difficulty epochs as seen by the relay. Skip the transaction. It - // will most likely be proven later. - logger.Warnf( - "skipped proving transaction [%s]; the range "+ - "of the required proof goes outside the previous and "+ - "current difficulty epochs as seen by the relay", - transactionHashStr, - ) - continue - } - if accumulatedConfirmations < requiredConfirmations { // Skip the transaction as it has not accumulated enough // confirmations. It will be proven later. @@ -267,14 +253,6 @@ func getProofInfo( ) ( bool, uint, uint, error, ) { - latestBlockHeight, err := btcChain.GetLatestBlockHeight() - if err != nil { - return false, 0, 0, fmt.Errorf( - "failed to get latest block height: [%v]", - err, - ) - } - accumulatedConfirmations, err := btcChain.GetTransactionConfirmations( transactionHash, ) @@ -293,135 +271,11 @@ func getProofInfo( ) } - // Calculate the starting block of the proof and the difficulty epoch number - // it belongs to. - proofStartBlock := uint64(latestBlockHeight - accumulatedConfirmations + 1) - proofStartEpoch := proofStartBlock / difficultyEpochLength - - // Calculate the ending block of the proof and the difficulty epoch number - // it belongs to. - proofEndBlock := proofStartBlock + txProofDifficultyFactor.Uint64() - 1 - proofEndEpoch := proofEndBlock / difficultyEpochLength - - // Get the current difficulty epoch number as seen by the relay. Subtract - // one to get the previous epoch number. - currentEpoch, err := btcDiffChain.CurrentEpoch() - if err != nil { - return false, 0, 0, fmt.Errorf("failed to get current epoch: [%v]", err) - } - previousEpoch := currentEpoch - 1 - - // There are only three possible valid combinations of the proof's block - // headers range: the proof must either be entirely in the previous epoch, - // must be entirely in the current epoch or must span the previous and - // current epochs. - - // If the proof is entirely within the current epoch, required confirmations - // does not need to be adjusted. - if proofStartEpoch == currentEpoch && - proofEndEpoch == currentEpoch { - return true, accumulatedConfirmations, uint(txProofDifficultyFactor.Uint64()), nil - } - - // If the proof is entirely within the previous epoch, required confirmations - // does not need to be adjusted. - if proofStartEpoch == previousEpoch && - proofEndEpoch == previousEpoch { - return true, accumulatedConfirmations, uint(txProofDifficultyFactor.Uint64()), nil - } - - // If the proof spans the previous and current difficulty epochs, the - // required confirmations may have to be adjusted. The reason for this is - // that there may be a drop in the value of difficulty between the current - // and the previous epochs. Example: - // Let's assume the transaction was done near the end of an epoch, so that - // part of the proof (let's say two block headers) is in the previous epoch - // and part of it is in the current epoch. - // If the previous epoch difficulty is 50 and the current epoch difficulty - // is 30, the total required difficulty of the proof will be transaction - // difficulty factor times previous difficulty: 6 * 50 = 300. - // However, if we simply use transaction difficulty factor to get the number - // of blocks we will end up with the difficulty sum that is too low: - // 50 + 50 + 30 + 30 + 30 + 30 = 220. To calculate the correct number of - // block headers needed we need to find how much difficulty needs to come - // from from the current epoch block headers: 300 - 2*50 = 200 and divide - // it by the current difficulty: 200 / 30 = 6 and add 1, because there - // was a remainder. So the number of block headers from the current epoch - // would be 7. The total number of block headers would be 9 and the sum - // of their difficulties would be: 50 + 50 + 30 + 30 + 30 + 30 + 30 + 30 + - // 30 = 310 which is enough to prove the transaction. - if proofStartEpoch == previousEpoch && - proofEndEpoch == currentEpoch { - currentEpochDifficulty, previousEpochDifficulty, err := - btcDiffChain.GetCurrentAndPrevEpochDifficulty() - if err != nil { - return false, 0, 0, fmt.Errorf( - "failed to get Bitcoin epoch difficulties: [%v]", - err, - ) - } - - // Calculate the total difficulty that is required for the proof. The - // proof begins in the previous difficulty epoch, therefore the total - // required difficulty will be the previous epoch difficulty times - // transaction proof difficulty factor. - totalDifficultyRequired := new(big.Int).Mul( - previousEpochDifficulty, - txProofDifficultyFactor, - ) - - // Calculate the number of block headers in the proof that will come - // from the previous difficulty epoch. - numberOfBlocksPreviousEpoch := - uint64(difficultyEpochLength - proofStartBlock%difficultyEpochLength) - - // Calculate how much difficulty the blocks from the previous epoch part - // of the proof have in total. - totalDifficultyPreviousEpoch := new(big.Int).Mul( - big.NewInt(int64(numberOfBlocksPreviousEpoch)), - previousEpochDifficulty, - ) - - // Calculate how much difficulty must come from the current epoch. - totalDifficultyCurrentEpoch := new(big.Int).Sub( - totalDifficultyRequired, - totalDifficultyPreviousEpoch, - ) - - // Calculate how many blocks from the current epoch we need. - remainder := new(big.Int) - numberOfBlocksCurrentEpoch, remainder := new(big.Int).DivMod( - totalDifficultyCurrentEpoch, - currentEpochDifficulty, - remainder, - ) - // If there is a remainder, it means there is still some amount of - // difficulty missing that is less than one block difficulty. We need to - // account for that by adding one additional block. - if remainder.Cmp(big.NewInt(0)) > 0 { - numberOfBlocksCurrentEpoch.Add( - numberOfBlocksCurrentEpoch, - big.NewInt(1), - ) - } - - // The total required number of confirmations is the sum of blocks from - // the previous and current epochs. - requiredConfirmations := numberOfBlocksPreviousEpoch + - numberOfBlocksCurrentEpoch.Uint64() - - return true, accumulatedConfirmations, uint(requiredConfirmations), nil - } + // Testnet proofs often require longer header chains due to the frequent + // difficulty changes on Bitcoin testnet. + requiredConfirmations := uint(txProofDifficultyFactor.Uint64()) + 3 - // If we entered here, it means that the proof's block headers range goes - // outside the previous or current difficulty epochs as seen by the relay. - // The reason for this is most likely that transaction entered the Bitcoin - // blockchain within the very new difficulty epoch that is not yet proven in - // the relay. In that case the transaction will be proven in the future. - // The other case could be that the transaction is older than the last two - // Bitcoin difficulty epochs. In that case the transaction will soon leave - // the sliding window of recent transactions. - return false, 0, 0, nil + return false, accumulatedConfirmations, requiredConfirmations, nil } // walletEvent is a type constraint representing wallet-related chain events. diff --git a/pkg/net/gen/pb/handshake.pb.go b/pkg/net/gen/pb/handshake.pb.go index 1a6f33e8fa..67ebd6cab5 100644 --- a/pkg/net/gen/pb/handshake.pb.go +++ b/pkg/net/gen/pb/handshake.pb.go @@ -1,16 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/net/gen/pb/handshake.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/pkg/net/gen/pb/message.pb.go b/pkg/net/gen/pb/message.pb.go index 78da03c065..f433911f3e 100644 --- a/pkg/net/gen/pb/message.pb.go +++ b/pkg/net/gen/pb/message.pb.go @@ -1,16 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/net/gen/pb/message.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/pkg/tbtc/gen/pb/wallet.pb.go b/pkg/tbtc/gen/pb/wallet.pb.go index 176b7b0e8d..e20e870717 100644 --- a/pkg/tbtc/gen/pb/wallet.pb.go +++ b/pkg/tbtc/gen/pb/wallet.pb.go @@ -1,16 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/tbtc/gen/pb/wallet.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/pkg/tecdsa/dkg/gen/pb/preparams.pb.go b/pkg/tecdsa/dkg/gen/pb/preparams.pb.go index d88410684d..e0ab1cfafe 100644 --- a/pkg/tecdsa/dkg/gen/pb/preparams.pb.go +++ b/pkg/tecdsa/dkg/gen/pb/preparams.pb.go @@ -1,17 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/tecdsa/dkg/gen/pb/preparams.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" + + timestamp "github.com/golang/protobuf/ptypes/timestamp" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -27,7 +28,7 @@ type PreParams struct { unknownFields protoimpl.UnknownFields Data *PreParams_LocalPreParams `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - CreationTimestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=creationTimestamp,proto3" json:"creationTimestamp,omitempty"` + CreationTimestamp *timestamp.Timestamp `protobuf:"bytes,2,opt,name=creationTimestamp,proto3" json:"creationTimestamp,omitempty"` } func (x *PreParams) Reset() { @@ -69,7 +70,7 @@ func (x *PreParams) GetData() *PreParams_LocalPreParams { return nil } -func (x *PreParams) GetCreationTimestamp() *timestamppb.Timestamp { +func (x *PreParams) GetCreationTimestamp() *timestamp.Timestamp { if x != nil { return x.CreationTimestamp } @@ -349,7 +350,7 @@ var file_pkg_tecdsa_dkg_gen_pb_preparams_proto_goTypes = []interface{}{ (*PreParams_PublicKey)(nil), // 1: dkg.PreParams.PublicKey (*PreParams_PrivateKey)(nil), // 2: dkg.PreParams.PrivateKey (*PreParams_LocalPreParams)(nil), // 3: dkg.PreParams.LocalPreParams - (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp } var file_pkg_tecdsa_dkg_gen_pb_preparams_proto_depIdxs = []int32{ 3, // 0: dkg.PreParams.data:type_name -> dkg.PreParams.LocalPreParams diff --git a/pkg/tecdsa/gen/pb/key.pb.go b/pkg/tecdsa/gen/pb/key.pb.go index 977b3f06a5..9a31d0a6b3 100644 --- a/pkg/tecdsa/gen/pb/key.pb.go +++ b/pkg/tecdsa/gen/pb/key.pb.go @@ -1,16 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.5 +// protoc v3.7.1 // source: pkg/tecdsa/gen/pb/key.proto package pb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const (