diff --git a/contracts-abi/abi/BidderRegistry.abi b/contracts-abi/abi/BidderRegistry.abi index e4108881e..141994a13 100644 --- a/contracts-abi/abi/BidderRegistry.abi +++ b/contracts-abi/abi/BidderRegistry.abi @@ -114,6 +114,24 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "depositForNWindows", + "inputs": [ + { + "name": "window", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "n", + "type": "uint16", + "internalType": "uint16" + } + ], + "outputs": [], + "stateMutability": "payable" + }, { "type": "function", "name": "depositForSpecificWindow", @@ -321,6 +339,24 @@ ], "stateMutability": "view" }, + { + "type": "function", + "name": "moveDepositToWindow", + "inputs": [ + { + "name": "fromWindow", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "toWindow", + "type": "uint256", + "internalType": "uint256" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, { "type": "function", "name": "owner", @@ -559,6 +595,37 @@ "outputs": [], "stateMutability": "nonpayable" }, + { + "type": "event", + "name": "BidderMovedFunds", + "inputs": [ + { + "name": "bidder", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "fromWindow", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "toWindow", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, { "type": "event", "name": "BidderRegistered", diff --git a/contracts-abi/abi/BlockTracker.abi b/contracts-abi/abi/BlockTracker.abi index 46cad7fac..c0e3b0359 100644 --- a/contracts-abi/abi/BlockTracker.abi +++ b/contracts-abi/abi/BlockTracker.abi @@ -240,19 +240,6 @@ ], "anonymous": false }, - { - "type": "event", - "name": "NewBlocksPerWindow", - "inputs": [ - { - "name": "blocksPerWindow", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, { "type": "event", "name": "NewL1Block", diff --git a/contracts-abi/abi/Oracle.abi b/contracts-abi/abi/Oracle.abi index 2c80c3041..a704831a0 100644 --- a/contracts-abi/abi/Oracle.abi +++ b/contracts-abi/abi/Oracle.abi @@ -125,9 +125,9 @@ "name": "CommitmentProcessed", "inputs": [ { - "name": "commitmentHash", + "name": "commitmentIndex", "type": "bytes32", - "indexed": false, + "indexed": true, "internalType": "bytes32" }, { diff --git a/contracts-abi/clients/BidderRegistry/BidderRegistry.go b/contracts-abi/clients/BidderRegistry/BidderRegistry.go index 9c527b742..1f2579982 100644 --- a/contracts-abi/clients/BidderRegistry/BidderRegistry.go +++ b/contracts-abi/clients/BidderRegistry/BidderRegistry.go @@ -31,7 +31,7 @@ var ( // BidderregistryMetaData contains all meta data concerning the Bidderregistry contract. var BidderregistryMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"BidPayment\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"bidAmt\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"state\",\"type\":\"uint8\",\"internalType\":\"enumIBidderRegistry.State\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"OpenBid\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"bid\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"blockNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"bidderRegistered\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blockTrackerContract\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIBlockTracker\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositForSpecificWindow\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"feePercent\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"feeRecipient\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"feeRecipientAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getDeposit\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getFeeRecipientAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getProviderAmount\",\"inputs\":[{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_minDeposit\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_feeRecipient\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_feePercent\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blockTracker\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blocksPerWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"lockedFunds\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"maxBidPerBlock\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"minDeposit\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"preConfirmationsContract\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"protocolFeeAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"providerAmount\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"retrieveFunds\",\"inputs\":[{\"name\":\"windowToSettle\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"addresspayable\"},{\"name\":\"residualBidPercentAfterDecay\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setNewFeePercent\",\"inputs\":[{\"name\":\"newFeePercent\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setNewFeeRecipient\",\"inputs\":[{\"name\":\"newFeeRecipient\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setPreconfirmationsContract\",\"inputs\":[{\"name\":\"contractAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unlockFunds\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"bidID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"usedFunds\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"withdrawBidderAmountFromWindow\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"addresspayable\"},{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawFeeRecipientAmount\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawProtocolFee\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawProviderAmount\",\"inputs\":[{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"BidderRegistered\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"depositedAmount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"windowNumber\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BidderWithdrawal\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"FundsRetrieved\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"FundsRewarded\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"provider\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"ReentrancyGuardReentrantCall\",\"inputs\":[]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"BidPayment\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"bidAmt\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"state\",\"type\":\"uint8\",\"internalType\":\"enumIBidderRegistry.State\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"OpenBid\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"bid\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"blockNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"bidderRegistered\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blockTrackerContract\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIBlockTracker\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"depositForNWindows\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"n\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositForSpecificWindow\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"feePercent\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"feeRecipient\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"feeRecipientAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getDeposit\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getFeeRecipientAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getProviderAmount\",\"inputs\":[{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_minDeposit\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_feeRecipient\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_feePercent\",\"type\":\"uint16\",\"internalType\":\"uint16\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blockTracker\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blocksPerWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"lockedFunds\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"maxBidPerBlock\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"minDeposit\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"moveDepositToWindow\",\"inputs\":[{\"name\":\"fromWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"toWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"preConfirmationsContract\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"protocolFeeAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"providerAmount\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"retrieveFunds\",\"inputs\":[{\"name\":\"windowToSettle\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"addresspayable\"},{\"name\":\"residualBidPercentAfterDecay\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setNewFeePercent\",\"inputs\":[{\"name\":\"newFeePercent\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setNewFeeRecipient\",\"inputs\":[{\"name\":\"newFeeRecipient\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setPreconfirmationsContract\",\"inputs\":[{\"name\":\"contractAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unlockFunds\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"bidID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"usedFunds\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"withdrawBidderAmountFromWindow\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"addresspayable\"},{\"name\":\"window\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawFeeRecipientAmount\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawProtocolFee\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"withdrawProviderAmount\",\"inputs\":[{\"name\":\"provider\",\"type\":\"address\",\"internalType\":\"addresspayable\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"BidderMovedFunds\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"fromWindow\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"toWindow\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BidderRegistered\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"depositedAmount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"windowNumber\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"BidderWithdrawal\",\"inputs\":[{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"FundsRetrieved\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"FundsRewarded\",\"inputs\":[{\"name\":\"commitmentDigest\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"bidder\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"provider\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"ReentrancyGuardReentrantCall\",\"inputs\":[]}]", } // BidderregistryABI is the input ABI used to generate the binding from. @@ -778,6 +778,27 @@ func (_Bidderregistry *BidderregistryTransactorSession) OpenBid(commitmentDigest return _Bidderregistry.Contract.OpenBid(&_Bidderregistry.TransactOpts, commitmentDigest, bid, bidder, blockNumber) } +// DepositForNWindows is a paid mutator transaction binding the contract method 0xaac7617f. +// +// Solidity: function depositForNWindows(uint256 window, uint16 n) payable returns() +func (_Bidderregistry *BidderregistryTransactor) DepositForNWindows(opts *bind.TransactOpts, window *big.Int, n uint16) (*types.Transaction, error) { + return _Bidderregistry.contract.Transact(opts, "depositForNWindows", window, n) +} + +// DepositForNWindows is a paid mutator transaction binding the contract method 0xaac7617f. +// +// Solidity: function depositForNWindows(uint256 window, uint16 n) payable returns() +func (_Bidderregistry *BidderregistrySession) DepositForNWindows(window *big.Int, n uint16) (*types.Transaction, error) { + return _Bidderregistry.Contract.DepositForNWindows(&_Bidderregistry.TransactOpts, window, n) +} + +// DepositForNWindows is a paid mutator transaction binding the contract method 0xaac7617f. +// +// Solidity: function depositForNWindows(uint256 window, uint16 n) payable returns() +func (_Bidderregistry *BidderregistryTransactorSession) DepositForNWindows(window *big.Int, n uint16) (*types.Transaction, error) { + return _Bidderregistry.Contract.DepositForNWindows(&_Bidderregistry.TransactOpts, window, n) +} + // DepositForSpecificWindow is a paid mutator transaction binding the contract method 0xe5e4bf4c. // // Solidity: function depositForSpecificWindow(uint256 window) payable returns() @@ -820,6 +841,27 @@ func (_Bidderregistry *BidderregistryTransactorSession) Initialize(_minDeposit * return _Bidderregistry.Contract.Initialize(&_Bidderregistry.TransactOpts, _minDeposit, _feeRecipient, _feePercent, _owner, _blockTracker, _blocksPerWindow) } +// MoveDepositToWindow is a paid mutator transaction binding the contract method 0x73dac150. +// +// Solidity: function moveDepositToWindow(uint256 fromWindow, uint256 toWindow) returns() +func (_Bidderregistry *BidderregistryTransactor) MoveDepositToWindow(opts *bind.TransactOpts, fromWindow *big.Int, toWindow *big.Int) (*types.Transaction, error) { + return _Bidderregistry.contract.Transact(opts, "moveDepositToWindow", fromWindow, toWindow) +} + +// MoveDepositToWindow is a paid mutator transaction binding the contract method 0x73dac150. +// +// Solidity: function moveDepositToWindow(uint256 fromWindow, uint256 toWindow) returns() +func (_Bidderregistry *BidderregistrySession) MoveDepositToWindow(fromWindow *big.Int, toWindow *big.Int) (*types.Transaction, error) { + return _Bidderregistry.Contract.MoveDepositToWindow(&_Bidderregistry.TransactOpts, fromWindow, toWindow) +} + +// MoveDepositToWindow is a paid mutator transaction binding the contract method 0x73dac150. +// +// Solidity: function moveDepositToWindow(uint256 fromWindow, uint256 toWindow) returns() +func (_Bidderregistry *BidderregistryTransactorSession) MoveDepositToWindow(fromWindow *big.Int, toWindow *big.Int) (*types.Transaction, error) { + return _Bidderregistry.Contract.MoveDepositToWindow(&_Bidderregistry.TransactOpts, fromWindow, toWindow) +} + // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. // // Solidity: function renounceOwnership() returns() @@ -1093,6 +1135,153 @@ func (_Bidderregistry *BidderregistryTransactorSession) Receive() (*types.Transa return _Bidderregistry.Contract.Receive(&_Bidderregistry.TransactOpts) } +// BidderregistryBidderMovedFundsIterator is returned from FilterBidderMovedFunds and is used to iterate over the raw logs and unpacked data for BidderMovedFunds events raised by the Bidderregistry contract. +type BidderregistryBidderMovedFundsIterator struct { + Event *BidderregistryBidderMovedFunds // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BidderregistryBidderMovedFundsIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BidderregistryBidderMovedFunds) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BidderregistryBidderMovedFunds) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BidderregistryBidderMovedFundsIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BidderregistryBidderMovedFundsIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BidderregistryBidderMovedFunds represents a BidderMovedFunds event raised by the Bidderregistry contract. +type BidderregistryBidderMovedFunds struct { + Bidder common.Address + FromWindow *big.Int + ToWindow *big.Int + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBidderMovedFunds is a free log retrieval operation binding the contract event 0xc6f0b69dd53688553b5b6f9f791e83055ccbd1875750b877276fe0a31dbf1812. +// +// Solidity: event BidderMovedFunds(address indexed bidder, uint256 fromWindow, uint256 toWindow, uint256 amount) +func (_Bidderregistry *BidderregistryFilterer) FilterBidderMovedFunds(opts *bind.FilterOpts, bidder []common.Address) (*BidderregistryBidderMovedFundsIterator, error) { + + var bidderRule []interface{} + for _, bidderItem := range bidder { + bidderRule = append(bidderRule, bidderItem) + } + + logs, sub, err := _Bidderregistry.contract.FilterLogs(opts, "BidderMovedFunds", bidderRule) + if err != nil { + return nil, err + } + return &BidderregistryBidderMovedFundsIterator{contract: _Bidderregistry.contract, event: "BidderMovedFunds", logs: logs, sub: sub}, nil +} + +// WatchBidderMovedFunds is a free log subscription operation binding the contract event 0xc6f0b69dd53688553b5b6f9f791e83055ccbd1875750b877276fe0a31dbf1812. +// +// Solidity: event BidderMovedFunds(address indexed bidder, uint256 fromWindow, uint256 toWindow, uint256 amount) +func (_Bidderregistry *BidderregistryFilterer) WatchBidderMovedFunds(opts *bind.WatchOpts, sink chan<- *BidderregistryBidderMovedFunds, bidder []common.Address) (event.Subscription, error) { + + var bidderRule []interface{} + for _, bidderItem := range bidder { + bidderRule = append(bidderRule, bidderItem) + } + + logs, sub, err := _Bidderregistry.contract.WatchLogs(opts, "BidderMovedFunds", bidderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BidderregistryBidderMovedFunds) + if err := _Bidderregistry.contract.UnpackLog(event, "BidderMovedFunds", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBidderMovedFunds is a log parse operation binding the contract event 0xc6f0b69dd53688553b5b6f9f791e83055ccbd1875750b877276fe0a31dbf1812. +// +// Solidity: event BidderMovedFunds(address indexed bidder, uint256 fromWindow, uint256 toWindow, uint256 amount) +func (_Bidderregistry *BidderregistryFilterer) ParseBidderMovedFunds(log types.Log) (*BidderregistryBidderMovedFunds, error) { + event := new(BidderregistryBidderMovedFunds) + if err := _Bidderregistry.contract.UnpackLog(event, "BidderMovedFunds", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BidderregistryBidderRegisteredIterator is returned from FilterBidderRegistered and is used to iterate over the raw logs and unpacked data for BidderRegistered events raised by the Bidderregistry contract. type BidderregistryBidderRegisteredIterator struct { Event *BidderregistryBidderRegistered // Event containing the contract specifics and raw log diff --git a/contracts-abi/clients/BlockTracker/BlockTracker.go b/contracts-abi/clients/BlockTracker/BlockTracker.go index 52e66653d..895ecd28b 100644 --- a/contracts-abi/clients/BlockTracker/BlockTracker.go +++ b/contracts-abi/clients/BlockTracker/BlockTracker.go @@ -31,7 +31,7 @@ var ( // BlocktrackerMetaData contains all meta data concerning the Blocktracker contract. var BlocktrackerMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"addBuilderAddress\",\"inputs\":[{\"name\":\"builderName\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"builderAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"blockBuilderNameToAddress\",\"inputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blockWinners\",\"inputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"currentWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockWinner\",\"inputs\":[{\"name\":\"blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBuilder\",\"inputs\":[{\"name\":\"builderNameGrafiti\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blocksPerWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"recordL1Block\",\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_winnerGraffiti\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"NewBlocksPerWindow\",\"inputs\":[{\"name\":\"blocksPerWindow\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"NewL1Block\",\"inputs\":[{\"name\":\"blockNumber\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"winner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"NewWindow\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"addBuilderAddress\",\"inputs\":[{\"name\":\"builderName\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"builderAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"blockBuilderNameToAddress\",\"inputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blockWinners\",\"inputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"blocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"currentWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockWinner\",\"inputs\":[{\"name\":\"blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlocksPerWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBuilder\",\"inputs\":[{\"name\":\"builderNameGrafiti\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentWindow\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blocksPerWindow\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"recordL1Block\",\"inputs\":[{\"name\":\"_blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_winnerGraffiti\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"NewL1Block\",\"inputs\":[{\"name\":\"blockNumber\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"},{\"name\":\"winner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"NewWindow\",\"inputs\":[{\"name\":\"window\",\"type\":\"uint256\",\"indexed\":true,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]}]", } // BlocktrackerABI is the input ABI used to generate the binding from. @@ -740,140 +740,6 @@ func (_Blocktracker *BlocktrackerFilterer) ParseInitialized(log types.Log) (*Blo return event, nil } -// BlocktrackerNewBlocksPerWindowIterator is returned from FilterNewBlocksPerWindow and is used to iterate over the raw logs and unpacked data for NewBlocksPerWindow events raised by the Blocktracker contract. -type BlocktrackerNewBlocksPerWindowIterator struct { - Event *BlocktrackerNewBlocksPerWindow // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *BlocktrackerNewBlocksPerWindowIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(BlocktrackerNewBlocksPerWindow) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(BlocktrackerNewBlocksPerWindow) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *BlocktrackerNewBlocksPerWindowIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *BlocktrackerNewBlocksPerWindowIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// BlocktrackerNewBlocksPerWindow represents a NewBlocksPerWindow event raised by the Blocktracker contract. -type BlocktrackerNewBlocksPerWindow struct { - BlocksPerWindow *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterNewBlocksPerWindow is a free log retrieval operation binding the contract event 0xd2abfe7e41e182f2121a97e57d5133f2ccef005fb15e25ef2f09d4a6657e20e0. -// -// Solidity: event NewBlocksPerWindow(uint256 blocksPerWindow) -func (_Blocktracker *BlocktrackerFilterer) FilterNewBlocksPerWindow(opts *bind.FilterOpts) (*BlocktrackerNewBlocksPerWindowIterator, error) { - - logs, sub, err := _Blocktracker.contract.FilterLogs(opts, "NewBlocksPerWindow") - if err != nil { - return nil, err - } - return &BlocktrackerNewBlocksPerWindowIterator{contract: _Blocktracker.contract, event: "NewBlocksPerWindow", logs: logs, sub: sub}, nil -} - -// WatchNewBlocksPerWindow is a free log subscription operation binding the contract event 0xd2abfe7e41e182f2121a97e57d5133f2ccef005fb15e25ef2f09d4a6657e20e0. -// -// Solidity: event NewBlocksPerWindow(uint256 blocksPerWindow) -func (_Blocktracker *BlocktrackerFilterer) WatchNewBlocksPerWindow(opts *bind.WatchOpts, sink chan<- *BlocktrackerNewBlocksPerWindow) (event.Subscription, error) { - - logs, sub, err := _Blocktracker.contract.WatchLogs(opts, "NewBlocksPerWindow") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(BlocktrackerNewBlocksPerWindow) - if err := _Blocktracker.contract.UnpackLog(event, "NewBlocksPerWindow", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseNewBlocksPerWindow is a log parse operation binding the contract event 0xd2abfe7e41e182f2121a97e57d5133f2ccef005fb15e25ef2f09d4a6657e20e0. -// -// Solidity: event NewBlocksPerWindow(uint256 blocksPerWindow) -func (_Blocktracker *BlocktrackerFilterer) ParseNewBlocksPerWindow(log types.Log) (*BlocktrackerNewBlocksPerWindow, error) { - event := new(BlocktrackerNewBlocksPerWindow) - if err := _Blocktracker.contract.UnpackLog(event, "NewBlocksPerWindow", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // BlocktrackerNewL1BlockIterator is returned from FilterNewL1Block and is used to iterate over the raw logs and unpacked data for NewL1Block events raised by the Blocktracker contract. type BlocktrackerNewL1BlockIterator struct { Event *BlocktrackerNewL1Block // Event containing the contract specifics and raw log diff --git a/contracts-abi/clients/Oracle/Oracle.go b/contracts-abi/clients/Oracle/Oracle.go index 46efdb217..2c8238f81 100644 --- a/contracts-abi/clients/Oracle/Oracle.go +++ b/contracts-abi/clients/Oracle/Oracle.go @@ -31,7 +31,7 @@ var ( // OracleMetaData contains all meta data concerning the Oracle contract. var OracleMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"blockBuilderNameToAddress\",\"inputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_preConfContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blockTrackerContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"processBuilderCommitmentForBlockNumber\",\"inputs\":[{\"name\":\"commitmentIndex\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"builder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"isSlash\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"residualBidPercentAfterDecay\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"CommitmentProcessed\",\"inputs\":[{\"name\":\"commitmentHash\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"isSlash\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"blockBuilderNameToAddress\",\"inputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_preConfContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_blockTrackerContract\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"processBuilderCommitmentForBlockNumber\",\"inputs\":[{\"name\":\"commitmentIndex\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"blockNumber\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"builder\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"isSlash\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"residualBidPercentAfterDecay\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"CommitmentProcessed\",\"inputs\":[{\"name\":\"commitmentIndex\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"isSlash\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]}]", } // OracleABI is the input ABI used to generate the binding from. @@ -437,17 +437,22 @@ func (it *OracleCommitmentProcessedIterator) Close() error { // OracleCommitmentProcessed represents a CommitmentProcessed event raised by the Oracle contract. type OracleCommitmentProcessed struct { - CommitmentHash [32]byte - IsSlash bool - Raw types.Log // Blockchain specific contextual infos + CommitmentIndex [32]byte + IsSlash bool + Raw types.Log // Blockchain specific contextual infos } // FilterCommitmentProcessed is a free log retrieval operation binding the contract event 0xddc1768a3a762a04e5fd3abea8ae3b60e23bcf290f4a032280e6a726611d41f5. // -// Solidity: event CommitmentProcessed(bytes32 commitmentHash, bool isSlash) -func (_Oracle *OracleFilterer) FilterCommitmentProcessed(opts *bind.FilterOpts) (*OracleCommitmentProcessedIterator, error) { +// Solidity: event CommitmentProcessed(bytes32 indexed commitmentIndex, bool isSlash) +func (_Oracle *OracleFilterer) FilterCommitmentProcessed(opts *bind.FilterOpts, commitmentIndex [][32]byte) (*OracleCommitmentProcessedIterator, error) { - logs, sub, err := _Oracle.contract.FilterLogs(opts, "CommitmentProcessed") + var commitmentIndexRule []interface{} + for _, commitmentIndexItem := range commitmentIndex { + commitmentIndexRule = append(commitmentIndexRule, commitmentIndexItem) + } + + logs, sub, err := _Oracle.contract.FilterLogs(opts, "CommitmentProcessed", commitmentIndexRule) if err != nil { return nil, err } @@ -456,10 +461,15 @@ func (_Oracle *OracleFilterer) FilterCommitmentProcessed(opts *bind.FilterOpts) // WatchCommitmentProcessed is a free log subscription operation binding the contract event 0xddc1768a3a762a04e5fd3abea8ae3b60e23bcf290f4a032280e6a726611d41f5. // -// Solidity: event CommitmentProcessed(bytes32 commitmentHash, bool isSlash) -func (_Oracle *OracleFilterer) WatchCommitmentProcessed(opts *bind.WatchOpts, sink chan<- *OracleCommitmentProcessed) (event.Subscription, error) { +// Solidity: event CommitmentProcessed(bytes32 indexed commitmentIndex, bool isSlash) +func (_Oracle *OracleFilterer) WatchCommitmentProcessed(opts *bind.WatchOpts, sink chan<- *OracleCommitmentProcessed, commitmentIndex [][32]byte) (event.Subscription, error) { + + var commitmentIndexRule []interface{} + for _, commitmentIndexItem := range commitmentIndex { + commitmentIndexRule = append(commitmentIndexRule, commitmentIndexItem) + } - logs, sub, err := _Oracle.contract.WatchLogs(opts, "CommitmentProcessed") + logs, sub, err := _Oracle.contract.WatchLogs(opts, "CommitmentProcessed", commitmentIndexRule) if err != nil { return nil, err } @@ -493,7 +503,7 @@ func (_Oracle *OracleFilterer) WatchCommitmentProcessed(opts *bind.WatchOpts, si // ParseCommitmentProcessed is a log parse operation binding the contract event 0xddc1768a3a762a04e5fd3abea8ae3b60e23bcf290f4a032280e6a726611d41f5. // -// Solidity: event CommitmentProcessed(bytes32 commitmentHash, bool isSlash) +// Solidity: event CommitmentProcessed(bytes32 indexed commitmentIndex, bool isSlash) func (_Oracle *OracleFilterer) ParseCommitmentProcessed(log types.Log) (*OracleCommitmentProcessed, error) { event := new(OracleCommitmentProcessed) if err := _Oracle.contract.UnpackLog(event, "CommitmentProcessed", log); err != nil { diff --git a/contracts/contracts/BidderRegistry.sol b/contracts/contracts/BidderRegistry.sol index 745b48368..91e1cf5a1 100644 --- a/contracts/contracts/BidderRegistry.sol +++ b/contracts/contracts/BidderRegistry.sol @@ -93,6 +93,14 @@ contract BidderRegistry is uint256 amount ); + /// @dev Event emitted when a bidder moves their deposit from one window to another + event BidderMovedFunds( + address indexed bidder, + uint256 fromWindow, + uint256 toWindow, + uint256 amount + ); + /** * @dev Fallback function to revert all calls, ensuring no unintended interactions. */ @@ -198,9 +206,70 @@ contract BidderRegistry is emit BidderRegistered(msg.sender, newLockedFunds, window); } + /** + * @dev Move deposit from one window to another. + * @param fromWindow The window from which the deposit is being moved. + * @param toWindow The window to which the deposit is being moved. + */ + function moveDepositToWindow( + uint256 fromWindow, + uint256 toWindow + ) external nonReentrant { + require( + fromWindow < toWindow, + "fromWindow should be less than toWindow" + ); + uint256 currentWindow = blockTrackerContract.getCurrentWindow(); + require( + fromWindow < currentWindow, + "funds can only be moved after the window is settled" + ); + uint256 deposit = lockedFunds[msg.sender][fromWindow]; + require(deposit > 0, "deposit amount is zero"); + + lockedFunds[msg.sender][fromWindow] = 0; + lockedFunds[msg.sender][toWindow] += deposit; + + emit BidderMovedFunds(msg.sender, fromWindow, toWindow, deposit); + } + + /** + * @dev Deposit for n windows. + * @param window The window for which the deposit is being made. + * @param n The number of windows for which the deposit is being made. + */ + function depositForNWindows( + uint256 window, + uint16 n + ) external payable { + require(msg.value >= minDeposit * n, "Insufficient deposit"); + + if (!bidderRegistered[msg.sender]) { + bidderRegistered[msg.sender] = true; + } + + uint256 amountToDeposit = msg.value / n; + uint256 remainingAmount = msg.value % n; // to handle rounding issues + + for (uint16 i = 0; i < n; i++) { + uint256 windowIndex = window + i; + uint256 currentLockedFunds = lockedFunds[msg.sender][windowIndex]; + + uint256 newLockedFunds = currentLockedFunds + amountToDeposit; + if (i == n - 1) { + newLockedFunds += remainingAmount; // Add the remainder to the last window + } + + lockedFunds[msg.sender][windowIndex] = newLockedFunds; + maxBidPerBlock[msg.sender][windowIndex] = newLockedFunds / blocksPerWindow; + + emit BidderRegistered(msg.sender, newLockedFunds, windowIndex); + } + } /** * @dev Check the deposit of a bidder. * @param bidder The address of the bidder. + * @param window The window for which the deposit is being checked. * @return The deposited amount for the bidder. */ function getDeposit( @@ -213,8 +282,10 @@ contract BidderRegistry is /** * @dev Retrieve funds from a bidder's deposit (only callable by the pre-confirmations contract). * @dev reenterancy not necessary but still putting here for precaution + * @param windowToSettle The window for which the funds are being retrieved. * @param commitmentDigest is the Bid ID that allows us to identify the bid, and deposit * @param provider The address to transfer the retrieved funds to. + * @param residualBidPercentAfterDecay The residual bid percent after decay. */ function retrieveFunds( uint256 windowToSettle, @@ -263,6 +334,7 @@ contract BidderRegistry is /** * @dev Return funds to a bidder's deposit (only callable by the pre-confirmations contract). * @dev reenterancy not necessary but still putting here for precaution + * @param window The window for which the funds are being retrieved. * @param bidID is the Bid ID that allows us to identify the bid, and deposit */ function unlockFunds( diff --git a/contracts/contracts/BlockTracker.sol b/contracts/contracts/BlockTracker.sol index 81d51d336..56b4cd8c3 100644 --- a/contracts/contracts/BlockTracker.sol +++ b/contracts/contracts/BlockTracker.sol @@ -18,9 +18,6 @@ contract BlockTracker is OwnableUpgradeable { /// @dev Event emitted when a new window is created. event NewWindow(uint256 indexed window); - /// @dev Event emitted when the number of blocks per window is updated. - event NewBlocksPerWindow(uint256 blocksPerWindow); - uint256 public currentWindow; uint256 public blocksPerWindow; diff --git a/contracts/contracts/Oracle.sol b/contracts/contracts/Oracle.sol index e8747c4a5..e7a5750d8 100644 --- a/contracts/contracts/Oracle.sol +++ b/contracts/contracts/Oracle.sol @@ -61,7 +61,7 @@ contract Oracle is OwnableUpgradeable { } /// @dev Event emitted when a commitment is processed. - event CommitmentProcessed(bytes32 commitmentHash, bool isSlash); + event CommitmentProcessed(bytes32 indexed commitmentIndex, bool isSlash); // Function to receive and process the block data (this would be automated in a real-world scenario) /** diff --git a/contracts/test/BidderRegistryTest.sol b/contracts/test/BidderRegistryTest.sol index 73d192567..3713be633 100644 --- a/contracts/test/BidderRegistryTest.sol +++ b/contracts/test/BidderRegistryTest.sol @@ -337,4 +337,73 @@ contract BidderRegistryTest is Test { bidderRegistry.depositForSpecificWindow{value: 5 ether}(nextWindow); bidderRegistry.withdrawProtocolFee(payable(address(bidder))); } -} + + function test_MoveDepositToWindow() public { + uint256 currentWindow = blockTracker.getCurrentWindow(); + uint256 nextWindow = currentWindow + 1; + vm.prank(bidder); + bidderRegistry.depositForSpecificWindow{value: 1 ether}(currentWindow); + uint64 blockNumber = uint64(blocksPerWindow + 2); + blockTracker.recordL1Block(blockNumber, "test"); + + vm.prank(bidder); + bidderRegistry.moveDepositToWindow(currentWindow, nextWindow); + uint256 oldWindowDeposit = bidderRegistry.getDeposit(bidder, currentWindow); + uint256 newWindowDeposit = bidderRegistry.getDeposit(bidder, nextWindow); + assertEq(oldWindowDeposit, 0); + assertEq(newWindowDeposit, 1 ether); + } + + function testFail_MoveDepositToWindowUnregisteredBidder() public { + address unregisteredBidder = vm.addr(2); + vm.startPrank(unregisteredBidder); + bidderRegistry.moveDepositToWindow(1, 2); + } + + function testFail_MoveDepositToWindowNoDeposit() public { + uint256 currentWindow = blockTracker.getCurrentWindow(); + uint256 nextWindow = currentWindow + 1; + vm.startPrank(bidder); + bidderRegistry.moveDepositToWindow(currentWindow, nextWindow); + } + + function testFail_MoveDepositToWindowInvalidToWindow() public { + uint256 currentWindow = blockTracker.getCurrentWindow(); + uint256 previousWindow = currentWindow - 1; + vm.startPrank(bidder); + bidderRegistry.depositForSpecificWindow{value: 1 ether}(currentWindow); + bidderRegistry.moveDepositToWindow(currentWindow, previousWindow); + } + + function test_DepositForNWindows() public { + uint256 currentWindow = blockTracker.getCurrentWindow(); + uint16 n = 3; + uint256 depositAmount = minStake * n; + + vm.startPrank(bidder); + vm.expectEmit(true, false, false, true); + for (uint16 i = 0; i < n; i++) { + emit BidderRegistered(bidder, depositAmount / n, currentWindow + i); + } + + bidderRegistry.depositForNWindows{value: depositAmount}(currentWindow, n); + + for (uint16 i = 0; i < n; i++) { + uint256 lockedFunds = bidderRegistry.lockedFunds(bidder, currentWindow + i); + assertEq(lockedFunds, depositAmount / n); + + uint256 maxBid = bidderRegistry.maxBidPerBlock(bidder, currentWindow + i); + assertEq(maxBid, (depositAmount / n) / blocksPerWindow); + } + + bool isBidderRegistered = bidderRegistry.bidderRegistered(bidder); + assertEq(isBidderRegistered, true); + } + + function testFail_DepositForNWindows_InsufficientDeposit() public { + uint256 currentWindow = blockTracker.getCurrentWindow(); + uint16 n = 3; + + vm.startPrank(bidder); + bidderRegistry.depositForNWindows{value: (minStake * n) - 1}(currentWindow, n); +}} diff --git a/oracle/pkg/apiserver/dashboard.go b/oracle/pkg/apiserver/dashboard.go index 5af82af4f..cf5fd72a5 100644 --- a/oracle/pkg/apiserver/dashboard.go +++ b/oracle/pkg/apiserver/dashboard.go @@ -88,7 +88,7 @@ func (s *Service) configureDashboard() error { events.NewEventHandler( "CommitmentProcessed", func(upd *oracle.OracleCommitmentProcessed) { - cmt, err := s.store.Settlement(context.Background(), upd.CommitmentHash[:]) + cmt, err := s.store.Settlement(context.Background(), upd.CommitmentIndex[:]) if err != nil { s.logger.Error("failed to get settlement", "error", err) return diff --git a/p2p/gen/go/bidderapi/v1/bidderapi.pb.go b/p2p/gen/go/bidderapi/v1/bidderapi.pb.go index 796b344da..4c7bc3c3c 100644 --- a/p2p/gen/go/bidderapi/v1/bidderapi.pb.go +++ b/p2p/gen/go/bidderapi/v1/bidderapi.pb.go @@ -142,6 +142,108 @@ func (x *DepositResponse) GetWindowNumber() *wrapperspb.UInt64Value { return nil } +type AutoDepositResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AmountsAndWindowNumbers []*AutoDeposit `protobuf:"bytes,1,rep,name=amounts_and_window_numbers,json=amountsAndWindowNumbers,proto3" json:"amounts_and_window_numbers,omitempty"` +} + +func (x *AutoDepositResponse) Reset() { + *x = AutoDepositResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AutoDepositResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AutoDepositResponse) ProtoMessage() {} + +func (x *AutoDepositResponse) ProtoReflect() protoreflect.Message { + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AutoDepositResponse.ProtoReflect.Descriptor instead. +func (*AutoDepositResponse) Descriptor() ([]byte, []int) { + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{2} +} + +func (x *AutoDepositResponse) GetAmountsAndWindowNumbers() []*AutoDeposit { + if x != nil { + return x.AmountsAndWindowNumbers + } + return nil +} + +type AutoDeposit struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"` + WindowNumber *wrapperspb.UInt64Value `protobuf:"bytes,2,opt,name=window_number,json=windowNumber,proto3" json:"window_number,omitempty"` +} + +func (x *AutoDeposit) Reset() { + *x = AutoDeposit{} + if protoimpl.UnsafeEnabled { + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AutoDeposit) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AutoDeposit) ProtoMessage() {} + +func (x *AutoDeposit) ProtoReflect() protoreflect.Message { + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AutoDeposit.ProtoReflect.Descriptor instead. +func (*AutoDeposit) Descriptor() ([]byte, []int) { + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{3} +} + +func (x *AutoDeposit) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +func (x *AutoDeposit) GetWindowNumber() *wrapperspb.UInt64Value { + if x != nil { + return x.WindowNumber + } + return nil +} + type EmptyMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -151,7 +253,7 @@ type EmptyMessage struct { func (x *EmptyMessage) Reset() { *x = EmptyMessage{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[2] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -164,7 +266,7 @@ func (x *EmptyMessage) String() string { func (*EmptyMessage) ProtoMessage() {} func (x *EmptyMessage) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[2] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -177,7 +279,7 @@ func (x *EmptyMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use EmptyMessage.ProtoReflect.Descriptor instead. func (*EmptyMessage) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{2} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{4} } type GetDepositRequest struct { @@ -191,7 +293,7 @@ type GetDepositRequest struct { func (x *GetDepositRequest) Reset() { *x = GetDepositRequest{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[3] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -204,7 +306,7 @@ func (x *GetDepositRequest) String() string { func (*GetDepositRequest) ProtoMessage() {} func (x *GetDepositRequest) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[3] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -217,7 +319,7 @@ func (x *GetDepositRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDepositRequest.ProtoReflect.Descriptor instead. func (*GetDepositRequest) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{3} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{5} } func (x *GetDepositRequest) GetWindowNumber() *wrapperspb.UInt64Value { @@ -238,7 +340,7 @@ type WithdrawRequest struct { func (x *WithdrawRequest) Reset() { *x = WithdrawRequest{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[4] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -251,7 +353,7 @@ func (x *WithdrawRequest) String() string { func (*WithdrawRequest) ProtoMessage() {} func (x *WithdrawRequest) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[4] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -264,7 +366,7 @@ func (x *WithdrawRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WithdrawRequest.ProtoReflect.Descriptor instead. func (*WithdrawRequest) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{4} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{6} } func (x *WithdrawRequest) GetWindowNumber() *wrapperspb.UInt64Value { @@ -286,7 +388,7 @@ type WithdrawResponse struct { func (x *WithdrawResponse) Reset() { *x = WithdrawResponse{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[5] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +401,7 @@ func (x *WithdrawResponse) String() string { func (*WithdrawResponse) ProtoMessage() {} func (x *WithdrawResponse) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[5] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -312,7 +414,7 @@ func (x *WithdrawResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use WithdrawResponse.ProtoReflect.Descriptor instead. func (*WithdrawResponse) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{5} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{7} } func (x *WithdrawResponse) GetAmount() string { @@ -344,7 +446,7 @@ type Bid struct { func (x *Bid) Reset() { *x = Bid{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[6] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -357,7 +459,7 @@ func (x *Bid) String() string { func (*Bid) ProtoMessage() {} func (x *Bid) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[6] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -370,7 +472,7 @@ func (x *Bid) ProtoReflect() protoreflect.Message { // Deprecated: Use Bid.ProtoReflect.Descriptor instead. func (*Bid) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{6} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{8} } func (x *Bid) GetTxHashes() []string { @@ -429,7 +531,7 @@ type Commitment struct { func (x *Commitment) Reset() { *x = Commitment{} if protoimpl.UnsafeEnabled { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[7] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -442,7 +544,7 @@ func (x *Commitment) String() string { func (*Commitment) ProtoMessage() {} func (x *Commitment) ProtoReflect() protoreflect.Message { - mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[7] + mi := &file_bidderapi_v1_bidderapi_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -455,7 +557,7 @@ func (x *Commitment) ProtoReflect() protoreflect.Message { // Deprecated: Use Commitment.ProtoReflect.Descriptor instead. func (*Commitment) Descriptor() ([]byte, []int) { - return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{7} + return file_bidderapi_v1_bidderapi_proto_rawDescGZIP(), []int{9} } func (x *Commitment) GetTxHashes() []string { @@ -619,7 +721,36 @@ var file_bidderapi_v1_bidderapi_proto_rawDesc = []byte{ 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x20, 0x22, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x20, - 0x31, 0x20, 0x7d, 0x22, 0x0e, 0x0a, 0x0c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, + 0x31, 0x20, 0x7d, 0x22, 0xe3, 0x02, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x6f, 0x44, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x56, 0x0a, 0x1a, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, + 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x41, + 0x75, 0x74, 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x17, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x73, 0x41, 0x6e, 0x64, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x73, 0x3a, 0xf3, 0x01, 0x92, 0x41, 0xef, 0x01, 0x0a, 0x45, 0x2a, 0x14, 0x41, 0x75, + 0x74, 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x32, 0x2d, 0x41, 0x75, 0x74, 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x20, + 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, + 0x20, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x20, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x2e, 0x32, 0xa5, 0x01, 0x5b, 0x7b, 0x22, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3a, 0x20, + 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x20, 0x22, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x20, 0x31, 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2c, 0x20, 0x22, 0x77, + 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x3a, 0x20, 0x32, + 0x7d, 0x2c, 0x20, 0x7b, 0x22, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x31, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x22, 0x2c, 0x20, 0x22, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x22, 0x3a, 0x20, 0x33, 0x7d, 0x5d, 0x22, 0x68, 0x0a, 0x0b, 0x41, 0x75, 0x74, + 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x41, 0x0a, 0x0d, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x4e, 0x75, 0x6d, + 0x62, 0x65, 0x72, 0x22, 0x0e, 0x0a, 0x0c, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa9, 0x02, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x93, 0x02, 0x0a, 0x0d, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, @@ -854,7 +985,7 @@ var file_bidderapi_v1_bidderapi_proto_rawDesc = []byte{ 0x61, 0x6d, 0x70, 0x20, 0x61, 0x74, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x69, 0x73, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x2e, 0x52, 0x11, 0x64, 0x69, 0x73, 0x70, 0x61, - 0x74, 0x63, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x32, 0x90, 0x04, 0x0a, + 0x74, 0x63, 0x68, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x32, 0xff, 0x05, 0x0a, 0x06, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x12, 0x53, 0x0a, 0x07, 0x53, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x64, 0x12, 0x11, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x64, 0x1a, 0x18, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, @@ -867,47 +998,62 @@ var file_bidderapi_v1_bidderapi_proto_rawDesc = []byte{ 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x22, 0x1b, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x2f, 0x7b, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x7d, 0x12, 0x6c, 0x0a, 0x0a, 0x47, 0x65, 0x74, - 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1f, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, + 0x2f, 0x7b, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x7d, 0x12, 0x78, 0x0a, 0x0b, 0x41, 0x75, 0x74, + 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1c, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, - 0x16, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x74, 0x5f, - 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x6e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4d, 0x69, - 0x6e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, + 0x22, 0x22, 0x20, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x61, 0x75, + 0x74, 0x6f, 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x2f, 0x7b, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x7d, 0x12, 0x73, 0x0a, 0x11, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x41, 0x75, 0x74, + 0x6f, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x76, 0x31, - 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x6d, 0x69, 0x6e, 0x5f, - 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x66, 0x0a, 0x08, 0x57, 0x69, 0x74, 0x68, 0x64, - 0x72, 0x61, 0x77, 0x12, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x76, 0x31, 0x2f, - 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x42, - 0xaa, 0x02, 0x92, 0x41, 0x72, 0x12, 0x70, 0x0a, 0x0a, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x20, - 0x41, 0x50, 0x49, 0x2a, 0x55, 0x0a, 0x1b, 0x42, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x20, - 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x31, - 0x2e, 0x31, 0x12, 0x36, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, + 0x73, 0x61, 0x67, 0x65, 0x1a, 0x1a, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, + 0x64, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x5f, 0x61, 0x75, 0x74, 0x6f, + 0x5f, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x6c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x44, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1f, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, + 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x64, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x6e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4d, 0x69, 0x6e, + 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x1a, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x1a, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x76, 0x31, 0x2f, + 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x6d, 0x69, 0x6e, 0x5f, 0x64, + 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x66, 0x0a, 0x08, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, + 0x61, 0x77, 0x12, 0x1d, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x76, 0x31, 0x2f, 0x62, + 0x69, 0x64, 0x64, 0x65, 0x72, 0x2f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x42, 0xaa, + 0x02, 0x92, 0x41, 0x72, 0x12, 0x70, 0x0a, 0x0a, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x20, 0x41, + 0x50, 0x49, 0x2a, 0x55, 0x0a, 0x1b, 0x42, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x20, 0x53, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x31, 0x2e, + 0x31, 0x12, 0x36, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x76, 0x2f, 0x6d, 0x65, 0x76, + 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x69, + 0x6e, 0x2f, 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x0b, 0x31, 0x2e, 0x30, 0x2e, 0x30, + 0x2d, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x69, 0x64, 0x64, + 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, + 0x61, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x76, 0x2f, 0x6d, 0x65, - 0x76, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, - 0x69, 0x6e, 0x2f, 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x0b, 0x31, 0x2e, 0x30, 0x2e, - 0x30, 0x2d, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x69, 0x64, - 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x42, 0x69, 0x64, 0x64, 0x65, - 0x72, 0x61, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x76, 0x2f, 0x6d, - 0x65, 0x76, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2f, 0x70, 0x32, 0x70, 0x2f, 0x67, 0x65, - 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2f, 0x76, - 0x31, 0x3b, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, - 0x42, 0x58, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, - 0x56, 0x31, 0xca, 0x02, 0x0c, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x18, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x5c, 0x56, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, - 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2f, 0x70, 0x32, 0x70, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, + 0x3b, 0x62, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x42, + 0x58, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x0c, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x18, 0x42, 0x69, 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x69, + 0x64, 0x64, 0x65, 0x72, 0x61, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -922,40 +1068,48 @@ func file_bidderapi_v1_bidderapi_proto_rawDescGZIP() []byte { return file_bidderapi_v1_bidderapi_proto_rawDescData } -var file_bidderapi_v1_bidderapi_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_bidderapi_v1_bidderapi_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_bidderapi_v1_bidderapi_proto_goTypes = []interface{}{ (*DepositRequest)(nil), // 0: bidderapi.v1.DepositRequest (*DepositResponse)(nil), // 1: bidderapi.v1.DepositResponse - (*EmptyMessage)(nil), // 2: bidderapi.v1.EmptyMessage - (*GetDepositRequest)(nil), // 3: bidderapi.v1.GetDepositRequest - (*WithdrawRequest)(nil), // 4: bidderapi.v1.WithdrawRequest - (*WithdrawResponse)(nil), // 5: bidderapi.v1.WithdrawResponse - (*Bid)(nil), // 6: bidderapi.v1.Bid - (*Commitment)(nil), // 7: bidderapi.v1.Commitment - (*wrapperspb.UInt64Value)(nil), // 8: google.protobuf.UInt64Value + (*AutoDepositResponse)(nil), // 2: bidderapi.v1.AutoDepositResponse + (*AutoDeposit)(nil), // 3: bidderapi.v1.AutoDeposit + (*EmptyMessage)(nil), // 4: bidderapi.v1.EmptyMessage + (*GetDepositRequest)(nil), // 5: bidderapi.v1.GetDepositRequest + (*WithdrawRequest)(nil), // 6: bidderapi.v1.WithdrawRequest + (*WithdrawResponse)(nil), // 7: bidderapi.v1.WithdrawResponse + (*Bid)(nil), // 8: bidderapi.v1.Bid + (*Commitment)(nil), // 9: bidderapi.v1.Commitment + (*wrapperspb.UInt64Value)(nil), // 10: google.protobuf.UInt64Value } var file_bidderapi_v1_bidderapi_proto_depIdxs = []int32{ - 8, // 0: bidderapi.v1.DepositRequest.window_number:type_name -> google.protobuf.UInt64Value - 8, // 1: bidderapi.v1.DepositRequest.block_number:type_name -> google.protobuf.UInt64Value - 8, // 2: bidderapi.v1.DepositResponse.window_number:type_name -> google.protobuf.UInt64Value - 8, // 3: bidderapi.v1.GetDepositRequest.window_number:type_name -> google.protobuf.UInt64Value - 8, // 4: bidderapi.v1.WithdrawRequest.window_number:type_name -> google.protobuf.UInt64Value - 8, // 5: bidderapi.v1.WithdrawResponse.window_number:type_name -> google.protobuf.UInt64Value - 6, // 6: bidderapi.v1.Bidder.SendBid:input_type -> bidderapi.v1.Bid - 0, // 7: bidderapi.v1.Bidder.Deposit:input_type -> bidderapi.v1.DepositRequest - 3, // 8: bidderapi.v1.Bidder.GetDeposit:input_type -> bidderapi.v1.GetDepositRequest - 2, // 9: bidderapi.v1.Bidder.GetMinDeposit:input_type -> bidderapi.v1.EmptyMessage - 4, // 10: bidderapi.v1.Bidder.Withdraw:input_type -> bidderapi.v1.WithdrawRequest - 7, // 11: bidderapi.v1.Bidder.SendBid:output_type -> bidderapi.v1.Commitment - 1, // 12: bidderapi.v1.Bidder.Deposit:output_type -> bidderapi.v1.DepositResponse - 1, // 13: bidderapi.v1.Bidder.GetDeposit:output_type -> bidderapi.v1.DepositResponse - 1, // 14: bidderapi.v1.Bidder.GetMinDeposit:output_type -> bidderapi.v1.DepositResponse - 5, // 15: bidderapi.v1.Bidder.Withdraw:output_type -> bidderapi.v1.WithdrawResponse - 11, // [11:16] is the sub-list for method output_type - 6, // [6:11] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 10, // 0: bidderapi.v1.DepositRequest.window_number:type_name -> google.protobuf.UInt64Value + 10, // 1: bidderapi.v1.DepositRequest.block_number:type_name -> google.protobuf.UInt64Value + 10, // 2: bidderapi.v1.DepositResponse.window_number:type_name -> google.protobuf.UInt64Value + 3, // 3: bidderapi.v1.AutoDepositResponse.amounts_and_window_numbers:type_name -> bidderapi.v1.AutoDeposit + 10, // 4: bidderapi.v1.AutoDeposit.window_number:type_name -> google.protobuf.UInt64Value + 10, // 5: bidderapi.v1.GetDepositRequest.window_number:type_name -> google.protobuf.UInt64Value + 10, // 6: bidderapi.v1.WithdrawRequest.window_number:type_name -> google.protobuf.UInt64Value + 10, // 7: bidderapi.v1.WithdrawResponse.window_number:type_name -> google.protobuf.UInt64Value + 8, // 8: bidderapi.v1.Bidder.SendBid:input_type -> bidderapi.v1.Bid + 0, // 9: bidderapi.v1.Bidder.Deposit:input_type -> bidderapi.v1.DepositRequest + 0, // 10: bidderapi.v1.Bidder.AutoDeposit:input_type -> bidderapi.v1.DepositRequest + 4, // 11: bidderapi.v1.Bidder.CancelAutoDeposit:input_type -> bidderapi.v1.EmptyMessage + 5, // 12: bidderapi.v1.Bidder.GetDeposit:input_type -> bidderapi.v1.GetDepositRequest + 4, // 13: bidderapi.v1.Bidder.GetMinDeposit:input_type -> bidderapi.v1.EmptyMessage + 6, // 14: bidderapi.v1.Bidder.Withdraw:input_type -> bidderapi.v1.WithdrawRequest + 9, // 15: bidderapi.v1.Bidder.SendBid:output_type -> bidderapi.v1.Commitment + 1, // 16: bidderapi.v1.Bidder.Deposit:output_type -> bidderapi.v1.DepositResponse + 2, // 17: bidderapi.v1.Bidder.AutoDeposit:output_type -> bidderapi.v1.AutoDepositResponse + 4, // 18: bidderapi.v1.Bidder.CancelAutoDeposit:output_type -> bidderapi.v1.EmptyMessage + 1, // 19: bidderapi.v1.Bidder.GetDeposit:output_type -> bidderapi.v1.DepositResponse + 1, // 20: bidderapi.v1.Bidder.GetMinDeposit:output_type -> bidderapi.v1.DepositResponse + 7, // 21: bidderapi.v1.Bidder.Withdraw:output_type -> bidderapi.v1.WithdrawResponse + 15, // [15:22] is the sub-list for method output_type + 8, // [8:15] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_bidderapi_v1_bidderapi_proto_init() } @@ -989,7 +1143,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EmptyMessage); i { + switch v := v.(*AutoDepositResponse); i { case 0: return &v.state case 1: @@ -1001,7 +1155,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetDepositRequest); i { + switch v := v.(*AutoDeposit); i { case 0: return &v.state case 1: @@ -1013,7 +1167,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WithdrawRequest); i { + switch v := v.(*EmptyMessage); i { case 0: return &v.state case 1: @@ -1025,7 +1179,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WithdrawResponse); i { + switch v := v.(*GetDepositRequest); i { case 0: return &v.state case 1: @@ -1037,7 +1191,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Bid); i { + switch v := v.(*WithdrawRequest); i { case 0: return &v.state case 1: @@ -1049,6 +1203,30 @@ func file_bidderapi_v1_bidderapi_proto_init() { } } file_bidderapi_v1_bidderapi_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WithdrawResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_bidderapi_v1_bidderapi_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bid); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_bidderapi_v1_bidderapi_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Commitment); i { case 0: return &v.state @@ -1067,7 +1245,7 @@ func file_bidderapi_v1_bidderapi_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_bidderapi_v1_bidderapi_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/p2p/gen/go/bidderapi/v1/bidderapi.pb.gw.go b/p2p/gen/go/bidderapi/v1/bidderapi.pb.gw.go index 32da4ca38..dd5d996d9 100644 --- a/p2p/gen/go/bidderapi/v1/bidderapi.pb.gw.go +++ b/p2p/gen/go/bidderapi/v1/bidderapi.pb.gw.go @@ -122,6 +122,94 @@ func local_request_Bidder_Deposit_0(ctx context.Context, marshaler runtime.Marsh } +var ( + filter_Bidder_AutoDeposit_0 = &utilities.DoubleArray{Encoding: map[string]int{"amount": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Bidder_AutoDeposit_0(ctx context.Context, marshaler runtime.Marshaler, client BidderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DepositRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["amount"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amount") + } + + protoReq.Amount, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amount", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bidder_AutoDeposit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AutoDeposit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bidder_AutoDeposit_0(ctx context.Context, marshaler runtime.Marshaler, server BidderServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DepositRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["amount"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "amount") + } + + protoReq.Amount, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "amount", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Bidder_AutoDeposit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AutoDeposit(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Bidder_CancelAutoDeposit_0(ctx context.Context, marshaler runtime.Marshaler, client BidderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EmptyMessage + var metadata runtime.ServerMetadata + + msg, err := client.CancelAutoDeposit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Bidder_CancelAutoDeposit_0(ctx context.Context, marshaler runtime.Marshaler, server BidderServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq EmptyMessage + var metadata runtime.ServerMetadata + + msg, err := server.CancelAutoDeposit(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Bidder_GetDeposit_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -250,6 +338,56 @@ func RegisterBidderHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser }) + mux.Handle("POST", pattern_Bidder_AutoDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bidderapi.v1.Bidder/AutoDeposit", runtime.WithHTTPPathPattern("/v1/bidder/auto_deposit/{amount}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bidder_AutoDeposit_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bidder_AutoDeposit_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Bidder_CancelAutoDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bidderapi.v1.Bidder/CancelAutoDeposit", runtime.WithHTTPPathPattern("/v1/bidder/cancel_auto_deposit")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Bidder_CancelAutoDeposit_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bidder_CancelAutoDeposit_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Bidder_GetDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -410,6 +548,50 @@ func RegisterBidderHandlerClient(ctx context.Context, mux *runtime.ServeMux, cli }) + mux.Handle("POST", pattern_Bidder_AutoDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bidderapi.v1.Bidder/AutoDeposit", runtime.WithHTTPPathPattern("/v1/bidder/auto_deposit/{amount}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bidder_AutoDeposit_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bidder_AutoDeposit_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Bidder_CancelAutoDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bidderapi.v1.Bidder/CancelAutoDeposit", runtime.WithHTTPPathPattern("/v1/bidder/cancel_auto_deposit")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Bidder_CancelAutoDeposit_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Bidder_CancelAutoDeposit_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Bidder_GetDeposit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -484,6 +666,10 @@ var ( pattern_Bidder_Deposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "bidder", "deposit", "amount"}, "")) + pattern_Bidder_AutoDeposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "bidder", "auto_deposit", "amount"}, "")) + + pattern_Bidder_CancelAutoDeposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "bidder", "cancel_auto_deposit"}, "")) + pattern_Bidder_GetDeposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "bidder", "get_deposit"}, "")) pattern_Bidder_GetMinDeposit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "bidder", "get_min_deposit"}, "")) @@ -496,6 +682,10 @@ var ( forward_Bidder_Deposit_0 = runtime.ForwardResponseMessage + forward_Bidder_AutoDeposit_0 = runtime.ForwardResponseMessage + + forward_Bidder_CancelAutoDeposit_0 = runtime.ForwardResponseMessage + forward_Bidder_GetDeposit_0 = runtime.ForwardResponseMessage forward_Bidder_GetMinDeposit_0 = runtime.ForwardResponseMessage diff --git a/p2p/gen/go/bidderapi/v1/bidderapi_grpc.pb.go b/p2p/gen/go/bidderapi/v1/bidderapi_grpc.pb.go index 6af2bd228..ef5e02b38 100644 --- a/p2p/gen/go/bidderapi/v1/bidderapi_grpc.pb.go +++ b/p2p/gen/go/bidderapi/v1/bidderapi_grpc.pb.go @@ -19,11 +19,13 @@ import ( const _ = grpc.SupportPackageIsVersion8 const ( - Bidder_SendBid_FullMethodName = "/bidderapi.v1.Bidder/SendBid" - Bidder_Deposit_FullMethodName = "/bidderapi.v1.Bidder/Deposit" - Bidder_GetDeposit_FullMethodName = "/bidderapi.v1.Bidder/GetDeposit" - Bidder_GetMinDeposit_FullMethodName = "/bidderapi.v1.Bidder/GetMinDeposit" - Bidder_Withdraw_FullMethodName = "/bidderapi.v1.Bidder/Withdraw" + Bidder_SendBid_FullMethodName = "/bidderapi.v1.Bidder/SendBid" + Bidder_Deposit_FullMethodName = "/bidderapi.v1.Bidder/Deposit" + Bidder_AutoDeposit_FullMethodName = "/bidderapi.v1.Bidder/AutoDeposit" + Bidder_CancelAutoDeposit_FullMethodName = "/bidderapi.v1.Bidder/CancelAutoDeposit" + Bidder_GetDeposit_FullMethodName = "/bidderapi.v1.Bidder/GetDeposit" + Bidder_GetMinDeposit_FullMethodName = "/bidderapi.v1.Bidder/GetMinDeposit" + Bidder_Withdraw_FullMethodName = "/bidderapi.v1.Bidder/Withdraw" ) // BidderClient is the client API for Bidder service. @@ -38,6 +40,14 @@ type BidderClient interface { // // Deposit is called by the bidder node to add deposit in the bidder registry. Deposit(ctx context.Context, in *DepositRequest, opts ...grpc.CallOption) (*DepositResponse, error) + // AutoDeposit + // + // AutoDeposit is called by the bidder node to add deposit in the bidder registry and move funds automatily from one window to another. + AutoDeposit(ctx context.Context, in *DepositRequest, opts ...grpc.CallOption) (*AutoDepositResponse, error) + // CancelAutoDeposit + // + // CancelAutoDeposit is called by the bidder node to cancel the auto deposit. + CancelAutoDeposit(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (*EmptyMessage, error) // GetDeposit // // GetDeposit is called by the bidder to get its deposit in the bidder registry. @@ -103,6 +113,26 @@ func (c *bidderClient) Deposit(ctx context.Context, in *DepositRequest, opts ... return out, nil } +func (c *bidderClient) AutoDeposit(ctx context.Context, in *DepositRequest, opts ...grpc.CallOption) (*AutoDepositResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AutoDepositResponse) + err := c.cc.Invoke(ctx, Bidder_AutoDeposit_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *bidderClient) CancelAutoDeposit(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (*EmptyMessage, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(EmptyMessage) + err := c.cc.Invoke(ctx, Bidder_CancelAutoDeposit_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *bidderClient) GetDeposit(ctx context.Context, in *GetDepositRequest, opts ...grpc.CallOption) (*DepositResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(DepositResponse) @@ -145,6 +175,14 @@ type BidderServer interface { // // Deposit is called by the bidder node to add deposit in the bidder registry. Deposit(context.Context, *DepositRequest) (*DepositResponse, error) + // AutoDeposit + // + // AutoDeposit is called by the bidder node to add deposit in the bidder registry and move funds automatily from one window to another. + AutoDeposit(context.Context, *DepositRequest) (*AutoDepositResponse, error) + // CancelAutoDeposit + // + // CancelAutoDeposit is called by the bidder node to cancel the auto deposit. + CancelAutoDeposit(context.Context, *EmptyMessage) (*EmptyMessage, error) // GetDeposit // // GetDeposit is called by the bidder to get its deposit in the bidder registry. @@ -170,6 +208,12 @@ func (UnimplementedBidderServer) SendBid(*Bid, Bidder_SendBidServer) error { func (UnimplementedBidderServer) Deposit(context.Context, *DepositRequest) (*DepositResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Deposit not implemented") } +func (UnimplementedBidderServer) AutoDeposit(context.Context, *DepositRequest) (*AutoDepositResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AutoDeposit not implemented") +} +func (UnimplementedBidderServer) CancelAutoDeposit(context.Context, *EmptyMessage) (*EmptyMessage, error) { + return nil, status.Errorf(codes.Unimplemented, "method CancelAutoDeposit not implemented") +} func (UnimplementedBidderServer) GetDeposit(context.Context, *GetDepositRequest) (*DepositResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetDeposit not implemented") } @@ -231,6 +275,42 @@ func _Bidder_Deposit_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Bidder_AutoDeposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DepositRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BidderServer).AutoDeposit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bidder_AutoDeposit_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BidderServer).AutoDeposit(ctx, req.(*DepositRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Bidder_CancelAutoDeposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EmptyMessage) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BidderServer).CancelAutoDeposit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Bidder_CancelAutoDeposit_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BidderServer).CancelAutoDeposit(ctx, req.(*EmptyMessage)) + } + return interceptor(ctx, in, info, handler) +} + func _Bidder_GetDeposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetDepositRequest) if err := dec(in); err != nil { @@ -296,6 +376,14 @@ var Bidder_ServiceDesc = grpc.ServiceDesc{ MethodName: "Deposit", Handler: _Bidder_Deposit_Handler, }, + { + MethodName: "AutoDeposit", + Handler: _Bidder_AutoDeposit_Handler, + }, + { + MethodName: "CancelAutoDeposit", + Handler: _Bidder_CancelAutoDeposit_Handler, + }, { MethodName: "GetDeposit", Handler: _Bidder_GetDeposit_Handler, diff --git a/p2p/gen/openapi/bidderapi/v1/bidderapi.swagger.yaml b/p2p/gen/openapi/bidderapi/v1/bidderapi.swagger.yaml index 0fbdabdbd..b21327382 100644 --- a/p2p/gen/openapi/bidderapi/v1/bidderapi.swagger.yaml +++ b/p2p/gen/openapi/bidderapi/v1/bidderapi.swagger.yaml @@ -10,6 +10,38 @@ consumes: produces: - application/json paths: + /v1/bidder/auto_deposit/{amount}: + post: + summary: AutoDeposit + description: AutoDeposit is called by the bidder node to add deposit in the bidder registry and move funds automatily from one window to another. + operationId: Bidder_AutoDeposit + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v1AutoDepositResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: amount + description: Amount of ETH to be deposited in wei. + in: path + required: true + type: string + - name: windowNumber + description: Optional window number for querying deposit. If not specified, the current block number is used. + in: query + required: false + type: string + format: uint64 + - name: blockNumber + description: Optional block number for querying deposit. If specified, calculate window based on this block number. + in: query + required: false + type: string + format: uint64 /v1/bidder/bid: post: summary: SendBid @@ -37,6 +69,20 @@ paths: required: true schema: $ref: '#/definitions/bidderapiv1Bid' + /v1/bidder/cancel_auto_deposit: + post: + summary: CancelAutoDeposit + description: CancelAutoDeposit is called by the bidder node to cancel the auto deposit. + operationId: Bidder_CancelAutoDeposit + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/bidderapiv1EmptyMessage' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' /v1/bidder/deposit/{amount}: post: summary: Deposit @@ -126,6 +172,14 @@ paths: type: string format: uint64 definitions: + bidderapiv1AutoDeposit: + type: object + properties: + amount: + type: string + windowNumber: + type: string + format: uint64 bidderapiv1Bid: type: object example: @@ -163,6 +217,8 @@ definitions: - txHashes - amount - blockNumber + bidderapiv1EmptyMessage: + type: object googlerpcStatus: type: object properties: @@ -182,6 +238,23 @@ definitions: '@type': type: string additionalProperties: {} + v1AutoDepositResponse: + type: object + example: + - amount: "1000000000000000000" + window_number: 1 + - amount: "1000000000000000000" + window_number: 2 + - amount: "1000000000000000000" + window_number: 3 + properties: + amountsAndWindowNumbers: + type: array + items: + type: object + $ref: '#/definitions/bidderapiv1AutoDeposit' + description: AutoDeposit deposit from the bidder registry. + title: AutoDeposit response v1Commitment: type: object properties: diff --git a/p2p/integrationtest/real-bidder/main.go b/p2p/integrationtest/real-bidder/main.go index 7d00a1709..458e8fd17 100644 --- a/p2p/integrationtest/real-bidder/main.go +++ b/p2p/integrationtest/real-bidder/main.go @@ -148,34 +148,60 @@ func main() { wg := sync.WaitGroup{} - wg.Add(1) - go func() { - ticker := time.NewTicker(10 * time.Minute) - defer ticker.Stop() + // wg.Add(1) + // go func() { + // ticker := time.NewTicker(10 * time.Minute) + // defer ticker.Stop() + + // minDepositResp, err := bidderClient.GetMinDeposit(context.Background(), &pb.EmptyMessage{}) + // if err != nil { + // logger.Error("failed to get min deposit", "err", err) + // return + // } + + // minDeposit, set := big.NewInt(0).SetString(minDepositResp.Amount, 10) + // if !set { + // logger.Error("failed to parse min deposit amount") + // return + // } + + // minDepositAmt := new(big.Int).Mul(minDeposit, big.NewInt(10)) + + // for { + // err = checkOrDeposit(bidderClient, logger, minDepositAmt) + // if err != nil { + // logger.Error("failed to check or stake", "err", err) + // } + // <-ticker.C + // } + // }() + + minDepositResp, err := bidderClient.GetMinDeposit(context.Background(), &pb.EmptyMessage{}) + if err != nil { + logger.Error("failed to get min deposit", "err", err) + return + } - minDepositResp, err := bidderClient.GetMinDeposit(context.Background(), &pb.EmptyMessage{}) - if err != nil { - logger.Error("failed to get min deposit", "err", err) - return - } + minDeposit, set := big.NewInt(0).SetString(minDepositResp.Amount, 10) + if !set { + logger.Error("failed to parse min deposit amount") + return + } - minDeposit, set := big.NewInt(0).SetString(minDepositResp.Amount, 10) - if !set { - logger.Error("failed to parse min deposit amount") - return - } + minDepositAmt := new(big.Int).Mul(minDeposit, big.NewInt(10)) - minDepositAmt := new(big.Int).Mul(minDeposit, big.NewInt(10)) - - for { - err = checkOrDeposit(bidderClient, logger, minDepositAmt) - if err != nil { - logger.Error("failed to check or stake", "err", err) - } - <-ticker.C - } - }() + minDepositAmt = new(big.Int).Mul(minDepositAmt, big.NewInt(3)) + resp, err := bidderClient.AutoDeposit(context.Background(), &pb.DepositRequest{ + Amount: minDepositAmt.String(), + }) + if err != nil { + logger.Error("failed to auto deposit", "err", err) + return + } + for _, v := range resp.AmountsAndWindowNumbers { + logger.Info("auto deposit", "amount", v.Amount, "window", v.WindowNumber) + } type blockWithTxns struct { blockNum int64 txns []string diff --git a/p2p/pkg/depositmanager/autodeposit.go b/p2p/pkg/depositmanager/autodeposit.go new file mode 100644 index 000000000..6dcbb4e7a --- /dev/null +++ b/p2p/pkg/depositmanager/autodeposit.go @@ -0,0 +1,142 @@ +package depositmanager + +import ( + "context" + "fmt" + "log/slog" + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/core/types" + blocktracker "github.com/primev/mev-commit/contracts-abi/clients/BlockTracker" + bidderapiv1 "github.com/primev/mev-commit/p2p/gen/go/bidderapi/v1" + "github.com/primev/mev-commit/x/contracts/events" + "golang.org/x/sync/errgroup" +) + +type OptsGetter func(context.Context) (*bind.TransactOpts, error) + +type BidderRegistryContract interface { + MoveDepositToWindow(opts *bind.TransactOpts, fromWindow *big.Int, toWindow *big.Int) (*types.Transaction, error) +} + +type AutoDepositTracker struct { + deposits map[uint64]bool + windowChan chan *blocktracker.BlocktrackerNewWindow + eventMgr events.EventManager + isWorking bool + brContract BidderRegistryContract + optsGetter OptsGetter + logger *slog.Logger + cancelFunc context.CancelFunc +} + +func NewAutoDepositTracker( + evtMgr events.EventManager, + brContract BidderRegistryContract, + optsGetter OptsGetter, + logger *slog.Logger, +) *AutoDepositTracker { + return &AutoDepositTracker{ + deposits: make(map[uint64]bool), + eventMgr: evtMgr, + brContract: brContract, + optsGetter: optsGetter, + windowChan: make(chan *blocktracker.BlocktrackerNewWindow, 1), + logger: logger, + } +} + +func (adt *AutoDepositTracker) DoAutoMoveToAnotherWindow(ads []*bidderapiv1.AutoDeposit) <-chan struct{} { + if adt.isWorking { + return nil + } + adt.isWorking = true + + for _, ad := range ads { + adt.deposits[ad.WindowNumber.Value] = true + } + + doneChan := make(chan struct{}) + + eg, egCtx := errgroup.WithContext(context.Background()) + egCtx, cancel := context.WithCancel(egCtx) + adt.cancelFunc = cancel + + evt := events.NewEventHandler( + "NewWindow", + func(update *blocktracker.BlocktrackerNewWindow) { + adt.logger.Info( + "new window event", + "window", update.Window, + ) + select { + case <-egCtx.Done(): + case adt.windowChan <- update: + } + }, + ) + + sub, err := adt.eventMgr.Subscribe(evt) + if err != nil { + close(doneChan) + return doneChan + } + + eg.Go(func() error { + defer sub.Unsubscribe() + + select { + case <-egCtx.Done(): + adt.logger.Info("event subscription context done") + return nil + case err := <-sub.Err(): + return fmt.Errorf("error in event subscription: %w", err) + } + }) + + eg.Go(func() error { + for { + select { + case <-egCtx.Done(): + adt.logger.Info("context done") + return nil + case window := <-adt.windowChan: + // logic for 3 windows for deposit + fromWindow := new(big.Int).Sub(window.Window, big.NewInt(1)) + if _, ok := adt.deposits[fromWindow.Uint64()]; !ok { + continue + } + toWindow := new(big.Int).Add(window.Window, big.NewInt(1)) + + opts, err := adt.optsGetter(egCtx) + if err != nil { + return err + } + txn, err := adt.brContract.MoveDepositToWindow(opts, fromWindow, toWindow) + if err != nil { + return err + } + adt.logger.Info("move deposit to window", "hash", txn.Hash(), "from", fromWindow, "to", toWindow) + delete(adt.deposits, fromWindow.Uint64()) + adt.deposits[toWindow.Uint64()] = true + } + } + }) + + go func() { + defer close(doneChan) + if err := eg.Wait(); err != nil { + adt.logger.Error("error in errgroup", "err", err) + } + adt.isWorking = false + }() + + return doneChan +} + +func (adt *AutoDepositTracker) Stop() { + if adt.cancelFunc != nil { + adt.cancelFunc() + } +} diff --git a/p2p/pkg/node/node.go b/p2p/pkg/node/node.go index 7500c5727..b791ca2c6 100644 --- a/p2p/pkg/node/node.go +++ b/p2p/pkg/node/node.go @@ -435,6 +435,13 @@ func NewNode(opts *Options) (*Node, error) { srv.RegisterMetricsCollectors(preconfProto.Metrics()...) + autoDeposit := depositmanager.NewAutoDepositTracker( + evtMgr, + bidderRegistry, + optsGetter, + opts.Logger.With("component", "auto_deposit_tracker"), + ) + bidderAPI := bidderapi.NewService( opts.KeySigner.GetAddress(), blocksPerWindow, @@ -444,6 +451,7 @@ func NewNode(opts *Options) (*Node, error) { validator, monitor, optsGetter, + autoDeposit, opts.Logger.With("component", "bidderapi"), ) bidderapiv1.RegisterBidderServer(grpcServer, bidderAPI) diff --git a/p2p/pkg/rpc/bidder/service.go b/p2p/pkg/rpc/bidder/service.go index 6c5d99185..40931dbb4 100644 --- a/p2p/pkg/rpc/bidder/service.go +++ b/p2p/pkg/rpc/bidder/service.go @@ -29,6 +29,7 @@ type Service struct { blockTrackerContract BlockTrackerContract watcher TxWatcher optsGetter OptsGetter + autoDepositTracker AutoDepositTracker logger *slog.Logger metrics *metrics validator *protovalidate.Validator @@ -43,6 +44,7 @@ func NewService( validator *protovalidate.Validator, watcher TxWatcher, optsGetter OptsGetter, + autoDepositTracker AutoDepositTracker, logger *slog.Logger, ) *Service { return &Service{ @@ -55,16 +57,23 @@ func NewService( optsGetter: optsGetter, logger: logger, metrics: newMetrics(), + autoDepositTracker: autoDepositTracker, validator: validator, } } +type AutoDepositTracker interface { + DoAutoMoveToAnotherWindow([]*bidderapiv1.AutoDeposit) <-chan struct{} + Stop() +} + type PreconfSender interface { SendBid(context.Context, string, string, int64, int64, int64) (chan *preconfirmationv1.PreConfirmation, error) } type BidderRegistryContract interface { DepositForSpecificWindow(*bind.TransactOpts, *big.Int) (*types.Transaction, error) + DepositForNWindows(*bind.TransactOpts, *big.Int, uint16) (*types.Transaction, error) WithdrawBidderAmountFromWindow(*bind.TransactOpts, common.Address, *big.Int) (*types.Transaction, error) GetDeposit(*bind.CallOpts, common.Address, *big.Int) (*big.Int, error) MinDeposit(*bind.CallOpts) (*big.Int, error) @@ -316,3 +325,83 @@ func (s *Service) Withdraw( return nil, status.Errorf(codes.Internal, "missing log for withdrawal") } + +func (s *Service) AutoDeposit( + ctx context.Context, + r *bidderapiv1.DepositRequest, +) (*bidderapiv1.AutoDepositResponse, error) { + err := s.validator.Validate(r) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "validating auto deposit request: %v", err) + } + + currentWindow, err := s.blockTrackerContract.GetCurrentWindow() + if err != nil { + return nil, status.Errorf(codes.Internal, "getting current window: %v", err) + } + + windowToDeposit, err := s.calculateWindowToDeposit(ctx, r, currentWindow.Uint64()) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "calculating window to deposit: %v", err) + } + + amount, success := big.NewInt(0).SetString(r.Amount, 10) + if !success { + return nil, status.Errorf(codes.InvalidArgument, "parsing amount: %v", r.Amount) + } + + opts, err := s.optsGetter(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "getting transact opts: %v", err) + } + opts.Value = amount + + // Deposit for 3 windows + tx, err := s.registryContract.DepositForNWindows(opts, windowToDeposit, 3) + if err != nil { + return nil, status.Errorf(codes.Internal, "deposit: %v", err) + } + + receipt, err := s.watcher.WaitForReceipt(ctx, tx) + if err != nil { + return nil, status.Errorf(codes.Internal, "waiting for receipt: %v", err) + } + + if receipt.Status != types.ReceiptStatusSuccessful { + return nil, status.Errorf(codes.Internal, "receipt status: %v", receipt.Status) + } + + var ads []*bidderapiv1.AutoDeposit + + for _, log := range receipt.Logs { + if registration, err := s.registryContract.ParseBidderRegistered(*log); err == nil { + s.logger.Info("deposit successful", "amount", registration.DepositedAmount, "window", registration.WindowNumber) + ads = append(ads, &bidderapiv1.AutoDeposit{ + Amount: registration.DepositedAmount.String(), + WindowNumber: wrapperspb.UInt64(registration.WindowNumber.Uint64()), + }) + } + } + + if len(ads) > 0 { + s.autoDepositTracker.DoAutoMoveToAnotherWindow(ads) + return &bidderapiv1.AutoDepositResponse{AmountsAndWindowNumbers: ads}, nil + } + + s.logger.Error( + "deposit successful but missing log", + "txHash", receipt.TxHash.Hex(), + "window", windowToDeposit, + "logs", receipt.Logs, + ) + + return nil, status.Errorf(codes.Internal, "missing log for deposit") +} + +func (s *Service) CancelDeposit( + ctx context.Context, + _ *bidderapiv1.EmptyMessage, +) (*bidderapiv1.EmptyMessage, error) { + s.autoDepositTracker.Stop() + return &bidderapiv1.EmptyMessage{}, nil +} diff --git a/p2p/pkg/rpc/bidder/service_test.go b/p2p/pkg/rpc/bidder/service_test.go index 710c2e4cc..9094dde2a 100644 --- a/p2p/pkg/rpc/bidder/service_test.go +++ b/p2p/pkg/rpc/bidder/service_test.go @@ -88,6 +88,11 @@ func (t *testRegistryContract) DepositForSpecificWindow(opts *bind.TransactOpts, return types.NewTransaction(1, common.Address{}, nil, 0, nil, nil), nil } +func (t *testRegistryContract) DepositForNWindows(opts *bind.TransactOpts, _ *big.Int, _ uint16) (*types.Transaction, error) { + t.deposit = opts.Value + return types.NewTransaction(1, common.Address{}, nil, 0, nil, nil), nil +} + func (t *testRegistryContract) WithdrawBidderAmountFromWindow( opts *bind.TransactOpts, address common.Address, @@ -118,6 +123,24 @@ func (t *testRegistryContract) ParseBidderWithdrawal(_ types.Log) (*bidderregist }, nil } +type testAutoDepositTracker struct { + deposits map[uint64]bool +} + +func (t *testAutoDepositTracker) DoAutoMoveToAnotherWindow(ads []*bidderapiv1.AutoDeposit) <-chan struct{} { + for _, ad := range ads { + t.deposits[ad.WindowNumber.Value] = true + } + + doneChan := make(chan struct{}) + close(doneChan) + + return doneChan +} + +func (t *testAutoDepositTracker) Stop() { +} + type testTxWatcher struct { nonce int } @@ -162,6 +185,7 @@ func startServer(t *testing.T) bidderapiv1.BidderClient { registryContract := &testRegistryContract{minDeposit: big.NewInt(100000000000000000)} sender := &testSender{noOfPreconfs: 2} blockTrackerContract := &testBlockTrackerContract{blocksPerWindow: 64, blockNumberToWinner: make(map[uint64]common.Address)} + testAutoDepositTracker := &testAutoDepositTracker{deposits: make(map[uint64]bool)} srvImpl := bidderapi.NewService( owner, blockTrackerContract.blocksPerWindow, @@ -176,6 +200,7 @@ func startServer(t *testing.T) bidderapiv1.BidderClient { Context: ctx, }, nil }, + testAutoDepositTracker, logger, ) diff --git a/p2p/rpc/bidderapi/v1/bidderapi.proto b/p2p/rpc/bidderapi/v1/bidderapi.proto index 77391c04c..17675e5bf 100644 --- a/p2p/rpc/bidderapi/v1/bidderapi.proto +++ b/p2p/rpc/bidderapi/v1/bidderapi.proto @@ -34,6 +34,21 @@ service Bidder { rpc Deposit(DepositRequest) returns (DepositResponse) { option (google.api.http) = {post: "/v1/bidder/deposit/{amount}"}; } + + // AutoDeposit + // + // AutoDeposit is called by the bidder node to add deposit in the bidder registry and move funds automatily from one window to another. + rpc AutoDeposit(DepositRequest) returns (AutoDepositResponse) { + option (google.api.http) = {post: "/v1/bidder/auto_deposit/{amount}"}; + } + + // CancelAutoDeposit + // + // CancelAutoDeposit is called by the bidder node to cancel the auto deposit. + rpc CancelAutoDeposit(EmptyMessage) returns (EmptyMessage) { + option (google.api.http) = {post: "/v1/bidder/cancel_auto_deposit"}; + } + // GetDeposit // // GetDeposit is called by the bidder to get its deposit in the bidder registry. @@ -103,6 +118,21 @@ message DepositResponse { google.protobuf.UInt64Value window_number = 2; }; +message AutoDepositResponse { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + json_schema: { + title: "AutoDeposit response" + description: "AutoDeposit deposit from the bidder registry." + } + example: "[{\"amount\": \"1000000000000000000\", \"window_number\": 1}, {\"amount\": \"1000000000000000000\", \"window_number\": 2}, {\"amount\": \"1000000000000000000\", \"window_number\": 3}]" + }; + repeated AutoDeposit amounts_and_window_numbers = 1; +}; + +message AutoDeposit { + string amount = 1; + google.protobuf.UInt64Value window_number = 2; +} message EmptyMessage {}; message GetDepositRequest {