From 5fe28437b504883d32db5a9e18ad8f176d44624b Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:59:11 -0700 Subject: [PATCH] feat: consolidate slashAmount and minStake for vanillaRegistry (#406) --- contracts-abi/abi/VanillaRegistry.abi | 42 +--- .../VanillaRegistry/VanillaRegistry.go | 192 ++---------------- .../contracts/interfaces/IVanillaRegistry.sol | 8 +- .../validator-registry/VanillaRegistry.sol | 32 +-- .../DeployVanillaRegistry.s.sol | 13 +- .../VanillaRegistryTest.sol | 75 +++---- 6 files changed, 60 insertions(+), 302 deletions(-) diff --git a/contracts-abi/abi/VanillaRegistry.abi b/contracts-abi/abi/VanillaRegistry.abi index e34bdc911..b44164fd0 100644 --- a/contracts-abi/abi/VanillaRegistry.abi +++ b/contracts-abi/abi/VanillaRegistry.abi @@ -163,11 +163,6 @@ "type": "uint256", "internalType": "uint256" }, - { - "name": "_slashAmount", - "type": "uint256", - "internalType": "uint256" - }, { "name": "_slashOracle", "type": "address", @@ -322,19 +317,6 @@ "outputs": [], "stateMutability": "nonpayable" }, - { - "type": "function", - "name": "setSlashAmount", - "inputs": [ - { - "name": "newSlashAmount", - "type": "uint256", - "internalType": "uint256" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, { "type": "function", "name": "setSlashOracle", @@ -645,25 +627,6 @@ ], "anonymous": false }, - { - "type": "event", - "name": "SlashAmountSet", - "inputs": [ - { - "name": "msgSender", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newSlashAmount", - "type": "uint256", - "indexed": false, - "internalType": "uint256" - } - ], - "anonymous": false - }, { "type": "event", "name": "SlashOracleSet", @@ -1012,6 +975,11 @@ "name": "NotInitializing", "inputs": [] }, + { + "type": "error", + "name": "NothingToWithdraw", + "inputs": [] + }, { "type": "error", "name": "OwnableInvalidOwner", diff --git a/contracts-abi/clients/VanillaRegistry/VanillaRegistry.go b/contracts-abi/clients/VanillaRegistry/VanillaRegistry.go index 3dda2c897..a01b79a8b 100644 --- a/contracts-abi/clients/VanillaRegistry/VanillaRegistry.go +++ b/contracts-abi/clients/VanillaRegistry/VanillaRegistry.go @@ -45,7 +45,7 @@ type IVanillaRegistryStakedValidator struct { // Validatorregistryv1MetaData contains all meta data concerning the Validatorregistryv1 contract. var Validatorregistryv1MetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"UPGRADE_INTERFACE_VERSION\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addStake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"delegateStake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"getBlocksTillWithdrawAllowed\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getStakedAmount\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getStakedValidator\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIVanillaRegistry.StakedValidator\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"balance\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unstakeOccurrence\",\"type\":\"tuple\",\"internalType\":\"structBlockHeightOccurrence.Occurrence\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"blockHeight\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_minStake\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_slashAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_slashOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_slashReceiver\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_unstakePeriodBlocks\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isUnstaking\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isValidatorOptedIn\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"minStake\",\"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\":\"pause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pendingOwner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setMinStake\",\"inputs\":[{\"name\":\"newMinStake\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setSlashAmount\",\"inputs\":[{\"name\":\"newSlashAmount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setSlashOracle\",\"inputs\":[{\"name\":\"newSlashOracle\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setSlashReceiver\",\"inputs\":[{\"name\":\"newSlashReceiver\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setUnstakePeriodBlocks\",\"inputs\":[{\"name\":\"newUnstakePeriodBlocks\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"slash\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"slashAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"slashOracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"slashReceiver\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"stake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"stakedValidators\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"balance\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unstakeOccurrence\",\"type\":\"tuple\",\"internalType\":\"structBlockHeightOccurrence.Occurrence\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"blockHeight\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unpause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unstake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unstakePeriodBlocks\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"upgradeToAndCall\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"withdraw\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"MinStakeSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newMinStake\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferStarted\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"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\":\"event\",\"name\":\"Paused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"SlashAmountSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newSlashAmount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"SlashOracleSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newSlashOracle\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"SlashReceiverSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newSlashReceiver\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Slashed\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"slashReceiver\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"StakeAdded\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"newBalance\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"StakeWithdrawn\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Staked\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unpaused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"UnstakePeriodBlocksSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newUnstakePeriodBlocks\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unstaked\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Upgraded\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AddressEmptyCode\",\"inputs\":[{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"AtLeastOneRecipientRequired\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ERC1967InvalidImplementation\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"ERC1967NonPayable\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"EnforcedPause\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ExpectedPause\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FailedInnerCall\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidBLSPubKeyLength\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"InvalidFallback\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidReceive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"MinStakeMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"MustUnstakeToWithdraw\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotEnoughBalanceToSlash\",\"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\":\"SenderIsNotSlashOracle\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"slashOracle\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"SenderIsNotWithdrawalAddress\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"SlashAmountMustBeLessThanMinStake\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashAmountMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashOracleMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashReceiverMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashingTransferFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"StakeTooLowForNumberOfKeys\",\"inputs\":[{\"name\":\"msgValue\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"numberOfKeys\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UUPSUnauthorizedCallContext\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UUPSUnsupportedProxiableUUID\",\"inputs\":[{\"name\":\"slot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"UnstakePeriodMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ValidatorCannotBeUnstaking\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ValidatorRecordMustExist\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ValidatorRecordMustNotExist\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"WithdrawalAddressMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"WithdrawalFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"WithdrawingTooSoon\",\"inputs\":[]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"fallback\",\"stateMutability\":\"payable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"UPGRADE_INTERFACE_VERSION\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"acceptOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"addStake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"delegateStake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"getBlocksTillWithdrawAllowed\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getStakedAmount\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getStakedValidator\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIVanillaRegistry.StakedValidator\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"balance\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unstakeOccurrence\",\"type\":\"tuple\",\"internalType\":\"structBlockHeightOccurrence.Occurrence\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"blockHeight\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_minStake\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_slashOracle\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_slashReceiver\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_unstakePeriodBlocks\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_owner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isUnstaking\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isValidatorOptedIn\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"minStake\",\"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\":\"pause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pendingOwner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proxiableUUID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setMinStake\",\"inputs\":[{\"name\":\"newMinStake\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setSlashOracle\",\"inputs\":[{\"name\":\"newSlashOracle\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setSlashReceiver\",\"inputs\":[{\"name\":\"newSlashReceiver\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"setUnstakePeriodBlocks\",\"inputs\":[{\"name\":\"newUnstakePeriodBlocks\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"slash\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"slashAmount\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"slashOracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"slashReceiver\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"stake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"stakedValidators\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"balance\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unstakeOccurrence\",\"type\":\"tuple\",\"internalType\":\"structBlockHeightOccurrence.Occurrence\",\"components\":[{\"name\":\"exists\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"blockHeight\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unpause\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unstake\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"unstakePeriodBlocks\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"upgradeToAndCall\",\"inputs\":[{\"name\":\"newImplementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"withdraw\",\"inputs\":[{\"name\":\"blsPubKeys\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"MinStakeSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newMinStake\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferStarted\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"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\":\"event\",\"name\":\"Paused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"SlashOracleSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newSlashOracle\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"SlashReceiverSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newSlashReceiver\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Slashed\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"slashReceiver\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"StakeAdded\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"newBalance\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"StakeWithdrawn\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Staked\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unpaused\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"UnstakePeriodBlocksSet\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newUnstakePeriodBlocks\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Unstaked\",\"inputs\":[{\"name\":\"msgSender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Upgraded\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AddressEmptyCode\",\"inputs\":[{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"AtLeastOneRecipientRequired\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ERC1967InvalidImplementation\",\"inputs\":[{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"ERC1967NonPayable\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"EnforcedPause\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ExpectedPause\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FailedInnerCall\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidBLSPubKeyLength\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"InvalidFallback\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidInitialization\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidReceive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"MinStakeMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"MustUnstakeToWithdraw\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotEnoughBalanceToSlash\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NotInitializing\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"NothingToWithdraw\",\"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\":\"SenderIsNotSlashOracle\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"slashOracle\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"SenderIsNotWithdrawalAddress\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"withdrawalAddress\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"SlashAmountMustBeLessThanMinStake\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashAmountMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashOracleMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashReceiverMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"SlashingTransferFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"StakeTooLowForNumberOfKeys\",\"inputs\":[{\"name\":\"msgValue\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"numberOfKeys\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UUPSUnauthorizedCallContext\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"UUPSUnsupportedProxiableUUID\",\"inputs\":[{\"name\":\"slot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"UnstakePeriodMustBePositive\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ValidatorCannotBeUnstaking\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ValidatorRecordMustExist\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ValidatorRecordMustNotExist\",\"inputs\":[{\"name\":\"valBLSPubKey\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"WithdrawalAddressMustBeSet\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"WithdrawalFailed\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"WithdrawingTooSoon\",\"inputs\":[]}]", } // Validatorregistryv1ABI is the input ABI used to generate the binding from. @@ -777,25 +777,25 @@ func (_Validatorregistryv1 *Validatorregistryv1TransactorSession) DelegateStake( return _Validatorregistryv1.Contract.DelegateStake(&_Validatorregistryv1.TransactOpts, blsPubKeys, withdrawalAddress) } -// Initialize is a paid mutator transaction binding the contract method 0x00267735. +// Initialize is a paid mutator transaction binding the contract method 0x2b7c9fd6. // -// Solidity: function initialize(uint256 _minStake, uint256 _slashAmount, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() -func (_Validatorregistryv1 *Validatorregistryv1Transactor) Initialize(opts *bind.TransactOpts, _minStake *big.Int, _slashAmount *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { - return _Validatorregistryv1.contract.Transact(opts, "initialize", _minStake, _slashAmount, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) +// Solidity: function initialize(uint256 _minStake, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() +func (_Validatorregistryv1 *Validatorregistryv1Transactor) Initialize(opts *bind.TransactOpts, _minStake *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { + return _Validatorregistryv1.contract.Transact(opts, "initialize", _minStake, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) } -// Initialize is a paid mutator transaction binding the contract method 0x00267735. +// Initialize is a paid mutator transaction binding the contract method 0x2b7c9fd6. // -// Solidity: function initialize(uint256 _minStake, uint256 _slashAmount, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() -func (_Validatorregistryv1 *Validatorregistryv1Session) Initialize(_minStake *big.Int, _slashAmount *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { - return _Validatorregistryv1.Contract.Initialize(&_Validatorregistryv1.TransactOpts, _minStake, _slashAmount, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) +// Solidity: function initialize(uint256 _minStake, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() +func (_Validatorregistryv1 *Validatorregistryv1Session) Initialize(_minStake *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { + return _Validatorregistryv1.Contract.Initialize(&_Validatorregistryv1.TransactOpts, _minStake, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) } -// Initialize is a paid mutator transaction binding the contract method 0x00267735. +// Initialize is a paid mutator transaction binding the contract method 0x2b7c9fd6. // -// Solidity: function initialize(uint256 _minStake, uint256 _slashAmount, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() -func (_Validatorregistryv1 *Validatorregistryv1TransactorSession) Initialize(_minStake *big.Int, _slashAmount *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { - return _Validatorregistryv1.Contract.Initialize(&_Validatorregistryv1.TransactOpts, _minStake, _slashAmount, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) +// Solidity: function initialize(uint256 _minStake, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner) returns() +func (_Validatorregistryv1 *Validatorregistryv1TransactorSession) Initialize(_minStake *big.Int, _slashOracle common.Address, _slashReceiver common.Address, _unstakePeriodBlocks *big.Int, _owner common.Address) (*types.Transaction, error) { + return _Validatorregistryv1.Contract.Initialize(&_Validatorregistryv1.TransactOpts, _minStake, _slashOracle, _slashReceiver, _unstakePeriodBlocks, _owner) } // Pause is a paid mutator transaction binding the contract method 0x8456cb59. @@ -861,27 +861,6 @@ func (_Validatorregistryv1 *Validatorregistryv1TransactorSession) SetMinStake(ne return _Validatorregistryv1.Contract.SetMinStake(&_Validatorregistryv1.TransactOpts, newMinStake) } -// SetSlashAmount is a paid mutator transaction binding the contract method 0xcce94c38. -// -// Solidity: function setSlashAmount(uint256 newSlashAmount) returns() -func (_Validatorregistryv1 *Validatorregistryv1Transactor) SetSlashAmount(opts *bind.TransactOpts, newSlashAmount *big.Int) (*types.Transaction, error) { - return _Validatorregistryv1.contract.Transact(opts, "setSlashAmount", newSlashAmount) -} - -// SetSlashAmount is a paid mutator transaction binding the contract method 0xcce94c38. -// -// Solidity: function setSlashAmount(uint256 newSlashAmount) returns() -func (_Validatorregistryv1 *Validatorregistryv1Session) SetSlashAmount(newSlashAmount *big.Int) (*types.Transaction, error) { - return _Validatorregistryv1.Contract.SetSlashAmount(&_Validatorregistryv1.TransactOpts, newSlashAmount) -} - -// SetSlashAmount is a paid mutator transaction binding the contract method 0xcce94c38. -// -// Solidity: function setSlashAmount(uint256 newSlashAmount) returns() -func (_Validatorregistryv1 *Validatorregistryv1TransactorSession) SetSlashAmount(newSlashAmount *big.Int) (*types.Transaction, error) { - return _Validatorregistryv1.Contract.SetSlashAmount(&_Validatorregistryv1.TransactOpts, newSlashAmount) -} - // SetSlashOracle is a paid mutator transaction binding the contract method 0x370baff6. // // Solidity: function setSlashOracle(address newSlashOracle) returns() @@ -1853,151 +1832,6 @@ func (_Validatorregistryv1 *Validatorregistryv1Filterer) ParsePaused(log types.L return event, nil } -// Validatorregistryv1SlashAmountSetIterator is returned from FilterSlashAmountSet and is used to iterate over the raw logs and unpacked data for SlashAmountSet events raised by the Validatorregistryv1 contract. -type Validatorregistryv1SlashAmountSetIterator struct { - Event *Validatorregistryv1SlashAmountSet // 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 *Validatorregistryv1SlashAmountSetIterator) 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(Validatorregistryv1SlashAmountSet) - 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(Validatorregistryv1SlashAmountSet) - 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 *Validatorregistryv1SlashAmountSetIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *Validatorregistryv1SlashAmountSetIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// Validatorregistryv1SlashAmountSet represents a SlashAmountSet event raised by the Validatorregistryv1 contract. -type Validatorregistryv1SlashAmountSet struct { - MsgSender common.Address - NewSlashAmount *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSlashAmountSet is a free log retrieval operation binding the contract event 0x52c748036b0bd81834109c732a532071b78a03bfa822284e701b233ec1d549b1. -// -// Solidity: event SlashAmountSet(address indexed msgSender, uint256 newSlashAmount) -func (_Validatorregistryv1 *Validatorregistryv1Filterer) FilterSlashAmountSet(opts *bind.FilterOpts, msgSender []common.Address) (*Validatorregistryv1SlashAmountSetIterator, error) { - - var msgSenderRule []interface{} - for _, msgSenderItem := range msgSender { - msgSenderRule = append(msgSenderRule, msgSenderItem) - } - - logs, sub, err := _Validatorregistryv1.contract.FilterLogs(opts, "SlashAmountSet", msgSenderRule) - if err != nil { - return nil, err - } - return &Validatorregistryv1SlashAmountSetIterator{contract: _Validatorregistryv1.contract, event: "SlashAmountSet", logs: logs, sub: sub}, nil -} - -// WatchSlashAmountSet is a free log subscription operation binding the contract event 0x52c748036b0bd81834109c732a532071b78a03bfa822284e701b233ec1d549b1. -// -// Solidity: event SlashAmountSet(address indexed msgSender, uint256 newSlashAmount) -func (_Validatorregistryv1 *Validatorregistryv1Filterer) WatchSlashAmountSet(opts *bind.WatchOpts, sink chan<- *Validatorregistryv1SlashAmountSet, msgSender []common.Address) (event.Subscription, error) { - - var msgSenderRule []interface{} - for _, msgSenderItem := range msgSender { - msgSenderRule = append(msgSenderRule, msgSenderItem) - } - - logs, sub, err := _Validatorregistryv1.contract.WatchLogs(opts, "SlashAmountSet", msgSenderRule) - 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(Validatorregistryv1SlashAmountSet) - if err := _Validatorregistryv1.contract.UnpackLog(event, "SlashAmountSet", 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 -} - -// ParseSlashAmountSet is a log parse operation binding the contract event 0x52c748036b0bd81834109c732a532071b78a03bfa822284e701b233ec1d549b1. -// -// Solidity: event SlashAmountSet(address indexed msgSender, uint256 newSlashAmount) -func (_Validatorregistryv1 *Validatorregistryv1Filterer) ParseSlashAmountSet(log types.Log) (*Validatorregistryv1SlashAmountSet, error) { - event := new(Validatorregistryv1SlashAmountSet) - if err := _Validatorregistryv1.contract.UnpackLog(event, "SlashAmountSet", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // Validatorregistryv1SlashOracleSetIterator is returned from FilterSlashOracleSet and is used to iterate over the raw logs and unpacked data for SlashOracleSet events raised by the Validatorregistryv1 contract. type Validatorregistryv1SlashOracleSetIterator struct { Event *Validatorregistryv1SlashOracleSet // Event containing the contract specifics and raw log diff --git a/contracts/contracts/interfaces/IVanillaRegistry.sol b/contracts/contracts/interfaces/IVanillaRegistry.sol index 669f2d063..33607c9bc 100644 --- a/contracts/contracts/interfaces/IVanillaRegistry.sol +++ b/contracts/contracts/interfaces/IVanillaRegistry.sol @@ -33,9 +33,6 @@ interface IVanillaRegistry { /// @dev Event emitted when the min stake parameter is set. event MinStakeSet(address indexed msgSender, uint256 newMinStake); - /// @dev Event emitted when the slash amount parameter is set. - event SlashAmountSet(address indexed msgSender, uint256 newSlashAmount); - /// @dev Event emitted when the slash oracle parameter is set. event SlashOracleSet(address indexed msgSender, address newSlashOracle); @@ -53,6 +50,7 @@ interface IVanillaRegistry { error SenderIsNotSlashOracle(address sender, address slashOracle); error WithdrawalAddressMustBeSet(); error MustUnstakeToWithdraw(); + error NothingToWithdraw(); error AtLeastOneRecipientRequired(); error StakeTooLowForNumberOfKeys(uint256 msgValue, uint256 numberOfKeys); error WithdrawingTooSoon(); @@ -69,7 +67,6 @@ interface IVanillaRegistry { /// @dev Initializes the contract with the provided parameters. function initialize( uint256 _minStake, - uint256 _slashAmount, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, @@ -124,9 +121,6 @@ interface IVanillaRegistry { /// @dev Enables the owner to set the minimum stake parameter. function setMinStake(uint256 newMinStake) external; - /// @dev Enables the owner to set the slash amount parameter. - function setSlashAmount(uint256 newSlashAmount) external; - /// @dev Enables the owner to set the slash oracle parameter. function setSlashOracle(address newSlashOracle) external; diff --git a/contracts/contracts/validator-registry/VanillaRegistry.sol b/contracts/contracts/validator-registry/VanillaRegistry.sol index e5f8b01f7..a446eae69 100644 --- a/contracts/contracts/validator-registry/VanillaRegistry.sol +++ b/contracts/contracts/validator-registry/VanillaRegistry.sol @@ -82,14 +82,12 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage, /// @dev Initializes the contract with the provided parameters. function initialize( uint256 _minStake, - uint256 _slashAmount, address _slashOracle, address _slashReceiver, uint256 _unstakePeriodBlocks, address _owner ) external initializer { _setMinStake(_minStake); - _setSlashAmount(_slashAmount); _setSlashOracle(_slashOracle); _setSlashReceiver(_slashReceiver); _setUnstakePeriodBlocks(_unstakePeriodBlocks); @@ -180,11 +178,6 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage, _setMinStake(newMinStake); } - /// @dev Enables the owner to set the slash amount parameter. - function setSlashAmount(uint256 newSlashAmount) external onlyOwner { - _setSlashAmount(newSlashAmount); - } - /// @dev Enables the owner to set the slash oracle parameter. function setSlashOracle(address newSlashOracle) external onlyOwner { _setSlashOracle(newSlashOracle); @@ -321,6 +314,7 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage, require(block.number > stakedValidators[pubKey].unstakeOccurrence.blockHeight + unstakePeriodBlocks, IVanillaRegistry.WithdrawingTooSoon()); uint256 balance = stakedValidators[pubKey].balance; + require(balance != 0, IVanillaRegistry.NothingToWithdraw()); address withdrawalAddress = stakedValidators[pubKey].withdrawalAddress; delete stakedValidators[pubKey]; (bool success, ) = withdrawalAddress.call{value: balance}(""); @@ -330,23 +324,21 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage, } /* - * @dev Internal function to slash ETH on behalf of one or multiple validators via their BLS pubkey. + * @dev Internal function to slash minStake worth of ETH on behalf of one or multiple validators via their BLS pubkey. * @param blsPubKeys The BLS public keys to slash. */ function _slash(bytes[] calldata blsPubKeys) internal { uint256 len = blsPubKeys.length; for (uint256 i = 0; i < len; ++i) { bytes calldata pubKey = blsPubKeys[i]; - require(stakedValidators[pubKey].balance > slashAmount, - IVanillaRegistry.NotEnoughBalanceToSlash()); - stakedValidators[pubKey].balance -= slashAmount; - if (!_isUnstaking(pubKey)) { - _unstakeSingle(pubKey); + require(stakedValidators[pubKey].balance >= minStake, IVanillaRegistry.NotEnoughBalanceToSlash()); + stakedValidators[pubKey].balance -= minStake; + if (!_isUnstaking(pubKey)) { + _unstakeSingle(pubKey); } - (bool success, ) = slashReceiver.call{value: slashAmount}(""); + (bool success, ) = slashReceiver.call{value: minStake}(""); require(success, IVanillaRegistry.SlashingTransferFailed()); - emit Slashed(msg.sender, slashReceiver, - stakedValidators[pubKey].withdrawalAddress, pubKey, slashAmount); + emit Slashed(msg.sender, slashReceiver, stakedValidators[pubKey].withdrawalAddress, pubKey, minStake); } } @@ -357,14 +349,6 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage, emit MinStakeSet(msg.sender, newMinStake); } - /// @dev Internal function to set the slash amount parameter. - function _setSlashAmount(uint256 newSlashAmount) internal { - require(newSlashAmount != 0, IVanillaRegistry.SlashAmountMustBePositive()); - require(newSlashAmount < minStake, IVanillaRegistry.SlashAmountMustBeLessThanMinStake()); - slashAmount = newSlashAmount; - emit SlashAmountSet(msg.sender, newSlashAmount); - } - /// @dev Internal function to set the slash oracle parameter. function _setSlashOracle(address newSlashOracle) internal { require(newSlashOracle != address(0), IVanillaRegistry.SlashOracleMustBeSet()); diff --git a/contracts/scripts/validator-registry/DeployVanillaRegistry.s.sol b/contracts/scripts/validator-registry/DeployVanillaRegistry.s.sol index 296911959..8050f6bcc 100644 --- a/contracts/scripts/validator-registry/DeployVanillaRegistry.s.sol +++ b/contracts/scripts/validator-registry/DeployVanillaRegistry.s.sol @@ -13,7 +13,6 @@ import {console} from "forge-std/console.sol"; contract BaseDeploy is Script { function deployVanillaRegistry( uint256 minStake, - uint256 slashAmount, address slashOracle, address slashReceiver, uint256 unstakePeriodBlocks, @@ -24,7 +23,7 @@ contract BaseDeploy is Script { "VanillaRegistry.sol", abi.encodeCall( VanillaRegistry.initialize, - (minStake, slashAmount, slashOracle, slashReceiver, unstakePeriodBlocks, owner) + (minStake, slashOracle, slashReceiver, unstakePeriodBlocks, owner) ) ); console.log("VanillaRegistry UUPS proxy deployed to:", address(proxy)); @@ -36,7 +35,6 @@ contract BaseDeploy is Script { contract DeployHolesky is BaseDeploy { uint256 constant public MIN_STAKE = 0.0001 ether; // 10k vals = 1 ETH cost - uint256 constant public SLASH_AMOUNT = 0.00003 ether; address constant public SLASH_ORACLE = 0x4535bd6fF24860b5fd2889857651a85fb3d3C6b1; address constant public SLASH_RECEIVER = 0x4535bd6fF24860b5fd2889857651a85fb3d3C6b1; uint256 constant public UNSTAKE_PERIOD_BLOCKS = 32 * 3; // 2 epoch finalization time + settlement buffer @@ -47,15 +45,13 @@ contract DeployHolesky is BaseDeploy { function run() external { require(block.chainid == 17000, "must deploy on Holesky"); vm.startBroadcast(); - deployVanillaRegistry(MIN_STAKE, SLASH_AMOUNT, - SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD_BLOCKS, OWNER); + deployVanillaRegistry(MIN_STAKE, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD_BLOCKS, OWNER); vm.stopBroadcast(); } } contract DeployAnvil is BaseDeploy { - uint256 constant public MIN_STAKE = 3 ether; - uint256 constant public SLASH_AMOUNT = 1 ether; + uint256 constant public MIN_STAKE = 1 ether; address constant public SLASH_ORACLE = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; address constant public SLASH_RECEIVER = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC; uint256 constant public UNSTAKE_PERIOD_BLOCKS = 100; @@ -63,8 +59,7 @@ contract DeployAnvil is BaseDeploy { function run() external { require(block.chainid == 31337, "must deploy on anvil"); vm.startBroadcast(); - deployVanillaRegistry(MIN_STAKE, SLASH_AMOUNT, - SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD_BLOCKS, msg.sender); + deployVanillaRegistry(MIN_STAKE, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD_BLOCKS, msg.sender); vm.stopBroadcast(); } } diff --git a/contracts/test/validator-registry/VanillaRegistryTest.sol b/contracts/test/validator-registry/VanillaRegistryTest.sol index b0b6059fc..1bb6d121a 100644 --- a/contracts/test/validator-registry/VanillaRegistryTest.sol +++ b/contracts/test/validator-registry/VanillaRegistryTest.sol @@ -13,7 +13,6 @@ contract VanillaRegistryTest is Test { address public user2; uint256 public constant MIN_STAKE = 1 ether; - uint256 public constant SLASH_AMOUNT = 0.1 ether; uint256 public constant UNSTAKE_PERIOD = 10; address public constant SLASH_ORACLE = address(0x78888); address public constant SLASH_RECEIVER = address(0x78886); @@ -28,7 +27,6 @@ contract VanillaRegistryTest is Test { event Slashed(address indexed msgSender, address indexed slashReceiver, address indexed withdrawalAddress, bytes valBLSPubKey, uint256 amount); event MinStakeSet(address indexed owner, uint256 minStake); - event SlashAmountSet(address indexed owner, uint256 slashAmount); event SlashOracleSet(address indexed owner, address slashOracle); event SlashReceiverSet(address indexed owner, address slashReceiver); event UnstakePeriodBlocksSet(address indexed owner, uint256 unstakePeriodBlocks); @@ -43,7 +41,7 @@ contract VanillaRegistryTest is Test { address proxy = Upgrades.deployUUPSProxy( "VanillaRegistry.sol", - abi.encodeCall(VanillaRegistry.initialize, (MIN_STAKE, SLASH_AMOUNT, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD, owner)) + abi.encodeCall(VanillaRegistry.initialize, (MIN_STAKE, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD, owner)) ); validatorRegistry = VanillaRegistry(payable(proxy)); } @@ -51,7 +49,7 @@ contract VanillaRegistryTest is Test { function testSecondInitialize() public { vm.prank(owner); vm.expectRevert(); - validatorRegistry.initialize(MIN_STAKE, SLASH_AMOUNT, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD, owner); + validatorRegistry.initialize(MIN_STAKE, SLASH_ORACLE, SLASH_RECEIVER, UNSTAKE_PERIOD, owner); vm.stopPrank(); } @@ -81,21 +79,21 @@ contract VanillaRegistryTest is Test { validators[0] = user1BLSKey; validators[1] = user2BLSKey; - uint256 totalAmount = 2 ether; - vm.deal(user1, 3 ether); - assertEq(user1.balance, 3 ether); + uint256 totalAmount = 6 ether; + vm.deal(user1, 7 ether); + assertEq(user1.balance, 7 ether); vm.startPrank(user1); vm.expectEmit(true, true, true, true); - emit Staked(user1, user1, user1BLSKey, 1 ether); + emit Staked(user1, user1, user1BLSKey, 3 ether); vm.expectEmit(true, true, true, true); - emit Staked(user1, user1, user2BLSKey, 1 ether); + emit Staked(user1, user1, user2BLSKey, 3 ether); validatorRegistry.stake{value: totalAmount}(validators); vm.stopPrank(); assertEq(user1.balance, 1 ether); - assertEq(validatorRegistry.getStakedAmount(user1BLSKey), 1 ether); - assertEq(validatorRegistry.getStakedAmount(user2BLSKey), 1 ether); + assertEq(validatorRegistry.getStakedAmount(user1BLSKey), 3 ether); + assertEq(validatorRegistry.getStakedAmount(user2BLSKey), 3 ether); assertTrue(validatorRegistry.isValidatorOptedIn(user1BLSKey)); assertTrue(validatorRegistry.isValidatorOptedIn(user1BLSKey)); } @@ -306,18 +304,15 @@ contract VanillaRegistryTest is Test { vm.prank(SLASH_ORACLE); validatorRegistry.slash(validators); - vm.deal(user1, 1 ether); + vm.deal(user1, 2 ether); vm.startPrank(user1); - uint256 stakeAmount = MIN_STAKE/2+1; + uint256 stakeAmount = MIN_STAKE+1; validatorRegistry.stake{value: stakeAmount}(validators); vm.stopPrank(); - vm.prank(owner); - validatorRegistry.setSlashAmount(MIN_STAKE/2); - vm.prank(SLASH_ORACLE); vm.expectEmit(true, true, true, true); - emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, MIN_STAKE/2); + emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, MIN_STAKE); validatorRegistry.slash(validators); vm.expectRevert(IVanillaRegistry.NotEnoughBalanceToSlash.selector); @@ -352,14 +347,14 @@ contract VanillaRegistryTest is Test { vm.prank(SLASH_ORACLE); vm.expectEmit(true, true, true, true); - emit Unstaked(SLASH_ORACLE, user1, user1BLSKey, 0.9 ether); + emit Unstaked(SLASH_ORACLE, user1, user1BLSKey, 0 ether); vm.expectEmit(true, true, true, true); - emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 0.1 ether); + emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 1 ether); validatorRegistry.slash(validators); assertEq(address(user1).balance, 8.0 ether); - assertEq(address(SLASH_RECEIVER).balance, 0.1 ether); - assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 0.9 ether); + assertEq(address(SLASH_RECEIVER).balance, 1 ether); + assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 0 ether); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).withdrawalAddress, user1); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).unstakeOccurrence.blockHeight, 11); assertFalse(validatorRegistry.isValidatorOptedIn(user1BLSKey)); @@ -388,7 +383,7 @@ contract VanillaRegistryTest is Test { vm.prank(SLASH_ORACLE); vm.expectEmit(true, true, true, true); - emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 0.1 ether); + emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 1 ether); validatorRegistry.slash(validators); finalAssertions(); // See directly below @@ -397,8 +392,8 @@ contract VanillaRegistryTest is Test { // Split final assertions into own func to avoid stack overflow function finalAssertions() public view { assertEq(address(user1).balance, 8 ether); - assertEq(address(SLASH_RECEIVER).balance, 0.1 ether); - assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 0.9 ether); + assertEq(address(SLASH_RECEIVER).balance, 1 ether); + assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 0 ether); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).withdrawalAddress, user1); // Unstake occurrence should not be updated for already unstaked validators assertEq(validatorRegistry.getStakedValidator(user1BLSKey).unstakeOccurrence.blockHeight, 11); @@ -407,8 +402,8 @@ contract VanillaRegistryTest is Test { function testBatchedSlashing() public { testMultiStake(); - assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 1 ether); - assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 1 ether); + assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 3 ether); + assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 3 ether); vm.roll(14); @@ -416,16 +411,16 @@ contract VanillaRegistryTest is Test { vals[0] = user1BLSKey; vm.startPrank(user1); vm.expectEmit(true, true, true, true); - emit Unstaked(user1, user1, user1BLSKey, 1 ether); + emit Unstaked(user1, user1, user1BLSKey, 3 ether); validatorRegistry.unstake(vals); vm.stopPrank(); - assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 1 ether); + assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 3 ether); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).withdrawalAddress, user1); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).unstakeOccurrence.blockHeight, 14); assertFalse(validatorRegistry.isValidatorOptedIn(user1BLSKey)); - assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 1 ether); + assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 3 ether); assertEq(validatorRegistry.getStakedValidator(user2BLSKey).withdrawalAddress, user1); assertEq(validatorRegistry.getStakedValidator(user2BLSKey).unstakeOccurrence.blockHeight, 0); assertTrue(validatorRegistry.isValidatorOptedIn(user2BLSKey)); @@ -437,20 +432,20 @@ contract VanillaRegistryTest is Test { toSlash[1] = user2BLSKey; vm.prank(SLASH_ORACLE); vm.expectEmit(true, true, true, true); - emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 0.1 ether); + emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user1BLSKey, 1 ether); vm.expectEmit(true, true, true, true); - emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user2BLSKey, 0.1 ether); + emit Slashed(SLASH_ORACLE, SLASH_RECEIVER, user1, user2BLSKey, 1 ether); validatorRegistry.slash(toSlash); - assertEq(address(SLASH_RECEIVER).balance, 0.2 ether); + assertEq(address(SLASH_RECEIVER).balance, 2 ether); - assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 0.9 ether); + assertEq(validatorRegistry.getStakedValidator(user1BLSKey).balance, 2 ether); assertEq(validatorRegistry.getStakedValidator(user1BLSKey).withdrawalAddress, user1); // Unstake occurrence should not be updated for already unstaked validators assertEq(validatorRegistry.getStakedValidator(user1BLSKey).unstakeOccurrence.blockHeight, 14); assertFalse(validatorRegistry.isValidatorOptedIn(user1BLSKey)); - assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 0.9 ether); + assertEq(validatorRegistry.getStakedValidator(user2BLSKey).balance, 2 ether); assertEq(validatorRegistry.getStakedValidator(user2BLSKey).withdrawalAddress, user1); assertEq(validatorRegistry.getStakedValidator(user2BLSKey).unstakeOccurrence.blockHeight, 78); assertFalse(validatorRegistry.isValidatorOptedIn(user2BLSKey)); @@ -588,18 +583,6 @@ contract VanillaRegistryTest is Test { vm.stopPrank(); assertEq(validatorRegistry.minStake(), 17 ether); - vm.startPrank(user1); - vm.expectRevert(); - validatorRegistry.setSlashAmount(0.2 ether); - vm.stopPrank(); - - vm.startPrank(owner); - vm.expectEmit(true, true, true, true); - emit SlashAmountSet(owner, 0.2 ether); - validatorRegistry.setSlashAmount(0.2 ether); - vm.stopPrank(); - assertEq(validatorRegistry.slashAmount(), 0.2 ether); - vm.startPrank(user1); vm.expectRevert(); validatorRegistry.setSlashOracle(user2);