From c69fb5f068f154dc01c6b8c6577d752d58cc4e7b Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 09:47:51 -0400 Subject: [PATCH 01/10] poa e2e test --- .../PoAValidatorManager.go | 1358 +++++++++++++++++ scripts/abi_bindings.sh | 2 +- tests/flows/erc20_token_staking.go | 1 - tests/flows/poa_validator_manager.go | 197 +++ tests/utils/staking.go | 128 ++ 5 files changed, 1684 insertions(+), 2 deletions(-) create mode 100644 abi-bindings/go/staking/PoAValidatorManager/PoAValidatorManager.go create mode 100644 tests/flows/poa_validator_manager.go diff --git a/abi-bindings/go/staking/PoAValidatorManager/PoAValidatorManager.go b/abi-bindings/go/staking/PoAValidatorManager/PoAValidatorManager.go new file mode 100644 index 000000000..2a881915a --- /dev/null +++ b/abi-bindings/go/staking/PoAValidatorManager/PoAValidatorManager.go @@ -0,0 +1,1358 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package poavalidatormanager + +import ( + "errors" + "math/big" + "strings" + + "github.com/ava-labs/subnet-evm/accounts/abi" + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/subnet-evm/core/types" + "github.com/ava-labs/subnet-evm/interfaces" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = interfaces.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ValidatorManagerSettings is an auto generated low-level Go binding around an user-defined struct. +type ValidatorManagerSettings struct { + PChainBlockchainID [32]byte + SubnetID [32]byte + MaximumHourlyChurn uint8 +} + +// PoAValidatorManagerMetaData contains all meta data concerning the PoAValidatorManager contract. +var PoAValidatorManagerMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"init\",\"type\":\"uint8\",\"internalType\":\"enumICMInitializable\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"WARP_MESSENGER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIWarpMessenger\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"completeEndValidation\",\"inputs\":[{\"name\":\"messageIndex\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"setWeightMessageType\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"completeValidatorRegistration\",\"inputs\":[{\"name\":\"messageIndex\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"settings\",\"type\":\"tuple\",\"internalType\":\"structValidatorManagerSettings\",\"components\":[{\"name\":\"pChainBlockchainID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"subnetID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"maximumHourlyChurn\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"initialOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"initializeEndValidation\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"initializeValidatorRegistration\",\"inputs\":[{\"name\":\"weight\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nodeID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"registrationExpiry\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"signature\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"resendEndValidatorMessage\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"resendRegisterValidatorMessage\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"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\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ValidationPeriodCreated\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"nodeID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"registerValidationMessageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"weight\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"registrationExpiry\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ValidationPeriodEnded\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ValidationPeriodRegistered\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"weight\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"timestamp\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ValidatorRemovalInitialized\",\"inputs\":[{\"name\":\"validationID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"setWeightMessageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"weight\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"endTime\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"uptime\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"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\":[]}]", + Bin: "0x608060405234801561000f575f80fd5b50604051612d67380380612d6783398101604081905261002e91610107565b60018160018111156100425761004261012c565b0361004f5761004f610055565b50610140565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100a55760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101045780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b5f60208284031215610117575f80fd5b815160028110610125575f80fd5b9392505050565b634e487b7160e01b5f52602160045260245ffd5b612c1a8061014d5f395ff3fe608060405234801561000f575f80fd5b50600436106100a6575f3560e01c8063a3a65e481161006e578063a3a65e4814610144578063b771b3bc14610157578063bee0a03f14610165578063c151c0b914610178578063f2fde38b1461018b578063fdf94a1a1461019e575f80fd5b80630322ed98146100aa5780633aaa9f25146100bf578063715018a6146100e55780638da5cb5b146100ed57806397fb70d414610131575b5f80fd5b6100bd6100b83660046123bb565b6101b1565b005b6100d26100cd36600461247f565b6103a9565b6040519081526020015b60405180910390f35b6100bd6103c9565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03165b6040516001600160a01b0390911681526020016100dc565b6100bd61013f3660046123bb565b6103dc565b6100bd610152366004612535565b6103e9565b6101196005600160991b0181565b6100bd6101733660046123bb565b610702565b6100bd610186366004612569565b610816565b6100bd6101993660046125a5565b610924565b6100bd6101ac3660046125cd565b61095e565b5f8181527fe92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb0660205260408082208151610120810190925280545f80516020612bee83398151915293929190829060ff166005811115610212576102126125f7565b6005811115610223576102236125f7565b81526001820154602082015260028201546001600160401b038082166040840152600160401b820481166060840152600160801b820481166080840152600160c01b909104811660a08301526003928301546001600160a01b03811660c084015260ff600160a01b820416151560e0840152600160a81b90041661010090910152909150815160058111156102ba576102ba6125f7565b146103245760405162461bcd60e51b815260206004820152602f60248201527f56616c696461746f724d616e616765723a2056616c696461746f72206e6f742060448201526e1c195b991a5b99c81c995b5bdd985b608a1b60648201526084015b60405180910390fd5b5f610335848361010001515f610d92565b60405163ee5b48eb60e01b81529091506005600160991b019063ee5b48eb9061036290849060040161262d565b6020604051808303815f875af115801561037e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103a2919061265f565b5050505050565b5f6103b2610faf565b6103be8486858561100a565b90505b949350505050565b6103d1610faf565b6103da5f61148e565b565b6103e6815f6114fe565b50565b5f5f80516020612bee8339815191526040516306f8253560e41b815263ffffffff841660048201529091505f9081906005600160991b0190636f825350906024015f60405180830381865afa158015610444573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261046b9190810190612681565b915091508061048c5760405162461bcd60e51b815260040161031b90612753565b82548251146104ef5760405162461bcd60e51b815260206004820152602960248201527f56616c696461746f724d616e616765723a20496e76616c696420736f757263656044820152680818da185a5b88125160ba1b606482015260840161031b565b60208201516001600160a01b0316156105625760405162461bcd60e51b815260206004820152602f60248201527f56616c696461746f724d616e616765723a20496e76616c6964206f726967696e60448201526e2073656e646572206164647265737360881b606482015260840161031b565b5f8061057184604001516118b2565b91509150806105d35760405162461bcd60e51b815260206004820152602860248201527f56616c696461746f724d616e616765723a20526567697374726174696f6e206e6044820152671bdd081d985b1a5960c21b606482015260840161031b565b5f828152600586016020526040812080546105ed90612799565b905011801561061f575060015f83815260068701602052604090205460ff16600581111561061d5761061d6125f7565b145b61063b5760405162461bcd60e51b815260040161031b906127d1565b5f828152600586016020526040812061065391612371565b5f8281526006860160208181526040808420805460ff191660029081178255810180546001600160401b0342818116600160401b026fffffffffffffffff000000000000000019909316929092178355600190930154875260078c0185528387208990559588905293835292548151931683529082019290925283917ff8fd1c90fb9cfa2ca2358fdf5806b086ad43315d92b221c929efc7f105ce7568910160405180910390a2505050505050565b5f8181527fe92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb056020526040812080545f80516020612bee83398151915292919061074a90612799565b905011801561077c575060015f83815260068301602052604090205460ff16600581111561077a5761077a6125f7565b145b6107985760405162461bcd60e51b815260040161031b906127d1565b5f82815260058201602052604090819020905163ee5b48eb60e01b81526005600160991b019163ee5b48eb916107d19190600401612818565b6020604051808303815f875af11580156107ed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610811919061265f565b505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f8115801561085a5750825b90505f826001600160401b031660011480156108755750303b155b905081158015610883575080155b156108a15760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156108cb57845460ff60401b1916600160401b1785555b6108d58787611a53565b831561091b57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b61092c610faf565b6001600160a01b03811661095557604051631e4fbdf760e01b81525f600482015260240161031b565b6103e68161148e565b5f5f80516020612bee8339815191526040516306f8253560e41b815263ffffffff851660048201529091505f9081906005600160991b0190636f825350906024015f60405180830381865afa1580156109b9573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526109e09190810190612681565b9150915080610a015760405162461bcd60e51b815260040161031b90612753565b5f8415610a85575f610a168460400151611a71565b919350909150506001600160401b03811615610a7f5760405162461bcd60e51b815260206004820152602260248201527f56616c696461746f724d616e616765723a20576569676874206d757374206265604482015261020360f41b606482015260840161031b565b50610afb565b5f610a9384604001516118b2565b90925090508015610af95760405162461bcd60e51b815260206004820152602a60248201527f56616c696461746f724d616e616765723a20526567697374726174696f6e20736044820152691d1a5b1b081d985b1a5960b21b606482015260840161031b565b505b5f818152600685016020526040808220815161012081019092528054829060ff166005811115610b2d57610b2d6125f7565b6005811115610b3e57610b3e6125f7565b81526001820154602082015260028201546001600160401b038082166040840152600160401b820481166060840152600160801b820481166080840152600160c01b909104811660a08301526003909201546001600160a01b0380821660c080850191909152600160a01b830460ff16151560e0850152600160a81b90920490931661010090920191909152820151919250163314610bef5760405162461bcd60e51b815260040161031b906128a2565b5f600382516005811115610c0557610c056125f7565b1480610c235750600282516005811115610c2157610c216125f7565b145b15610c4657506020808201515f9081526007870190915260408120556004610c4a565b5060055b5f83815260068701602052604090208251815484929190829060ff19166001836005811115610c7b57610c7b6125f7565b0217905550602082015160018201556040808301516002830180546060860151608087015160a08801516001600160401b039586166001600160801b031990941693909317600160401b92861692909202919091176001600160801b0316600160801b918516919091026001600160c01b031617600160c01b9184169190910217905560c08401516003909301805460e0860151610100909601516001600160a01b039095166001600160a81b031990911617600160a01b951515959095029490941767ffffffffffffffff60a81b1916600160a81b9390911692909202919091179091555183907f3532ad18e70a039beb4663d48c15acbef558c96ec9b8fd0cc3c0304f774740b8905f90a25050505050505050565b60408051603680825260608281019093525f91906020820181803683370190505090505f5b6002811015610e0b57610dcb816001612902565b610dd690600861291b565b5081515f90839083908110610ded57610ded612932565b60200101906001600160f81b03191690815f1a905350600101610db7565b505f5b6004811015610e6e57610e22816003612902565b610e2d90600861291b565b6001901c60f81b82610e40836002612946565b81518110610e5057610e50612932565b60200101906001600160f81b03191690815f1a905350600101610e0e565b505f5b6020811015610ed057610e8581601f612902565b610e9090600861291b565b86901c60f81b82610ea2836006612946565b81518110610eb257610eb2612932565b60200101906001600160f81b03191690815f1a905350600101610e71565b505f5b6008811015610f3b57610ee7816007612902565b610ef290600861291b565b6001600160401b038616901c60f81b82610f0d836026612946565b81518110610f1d57610f1d612932565b60200101906001600160f81b03191690815f1a905350600101610ed3565b505f5b6008811015610fa657610f52816007612902565b610f5d90600861291b565b6001600160401b038516901c60f81b82610f7883602e612946565b81518110610f8857610f88612932565b60200101906001600160f81b03191690815f1a905350600101610f3e565b50949350505050565b33610fe17f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146103da5760405163118cdaa760e01b815233600482015260240161031b565b5f611013611cac565b5f80516020612bee833981519152426001600160401b03851611801561104d57506001600160401b03841661104b426202a300612946565b115b6110af5760405162461bcd60e51b815260206004820152602d60248201527f56616c696461746f724d616e616765723a20496e76616c69642072656769737460448201526c726174696f6e2065787069727960981b606482015260840161031b565b856111065760405162461bcd60e51b815260206004820152602160248201527f56616c696461746f724d616e616765723a20496e76616c6964206e6f646520496044820152601160fa1b606482015260840161031b565b5f868152600782016020526040902054156111745760405162461bcd60e51b815260206004820152602860248201527f56616c696461746f724d616e616765723a204e6f646520494420616c72656164604482015267792061637469766560c01b606482015260840161031b565b82516030146111db5760405162461bcd60e51b815260206004820152602d60248201527f56616c696461746f724d616e616765723a20496e76616c696420626c7350756260448201526c0d8d2c696caf240d8cadccee8d609b1b606482015260840161031b565b6111e485611cf6565b5f8061122b6040518060a00160405280856001015481526020018a8152602001896001600160401b03168152602001886001600160401b0316815260200187815250611e97565b5f82815260058601602052604090209193509150611249828261299d565b5060405163ee5b48eb60e01b81525f906005600160991b019063ee5b48eb9061127690859060040161262d565b6020604051808303815f875af1158015611292573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112b6919061265f565b6040805161012081019091529091508060018152602081018b90526001600160401b038a1660408201525f606082018190526080820181905260a082015260c001336001600160a01b031681525f602080830182905260409283018290528682526006880190522081518154829060ff1916600183600581111561133c5761133c6125f7565b021790555060208281015160018301556040808401516002840180546060870151608088015160a08901516001600160401b03908116600160c01b026001600160c01b03928216600160801b02929092166001600160801b03938216600160401b026001600160801b03199095169682169690961793909317919091169390931792909217905560c08501516003909401805460e0870151610100909701518316600160a81b0267ffffffffffffffff60a81b19971515600160a01b026001600160a81b03199092166001600160a01b039097169690961717959095169390931790935582518b83168152918a169082015282918b9186917f79b81620b81daf2c08cd5bb3dbb79e75d2d7a87f52171fde5aadc8c47823026e910160405180910390a45090925050506103c160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f8281527fe92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb0660205260408082208151610120810190925280545f80516020612bee83398151915293929190829060ff16600581111561155f5761155f6125f7565b6005811115611570576115706125f7565b8152600182015460208201526002808301546001600160401b038082166040850152600160401b820481166060850152600160801b820481166080850152600160c01b909104811660a08401526003909301546001600160a01b03811660c084015260ff600160a01b820416151560e0840152600160a81b9004909216610100909101529091508151600581111561160a5761160a6125f7565b146116665760405162461bcd60e51b815260206004820152602660248201527f56616c696461746f724d616e616765723a2056616c696461746f72206e6f742060448201526561637469766560d01b606482015260840161031b565b60c08101516001600160a01b0316336001600160a01b03161461169b5760405162461bcd60e51b815260040161031b906128a2565b6116a88160400151611cf6565b600381526001600160401b034281166080830152831660a08201525f84815260068301602052604090208151815483929190829060ff191660018360058111156116f4576116f46125f7565b02179055506020820151600182015560408201516002820180546060850151608086015160a08701516001600160401b039586166001600160801b031990941693909317600160401b92861692909202919091176001600160801b0316600160801b918516919091026001600160c01b031617600160c01b9184169190910217905560c08301516003909201805460e0850151610100958601516001600160a01b039095166001600160a81b031990921691909117600160a01b911515919091021767ffffffffffffffff60a81b1916600160a81b93909216929092021790558101515f906117e590869083610d92565b60405163ee5b48eb60e01b81529091505f906005600160991b019063ee5b48eb9061181490859060040161262d565b6020604051808303815f875af1158015611830573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611854919061265f565b60408481015181516001600160401b039182168152426020820152908816818301529051919250829188917f530b908725650fb1052974f9df59e834fefac78c9ec2f00c6d2464d60cc6add5919081900360600190a3505050505050565b5f8082516027146118d55760405162461bcd60e51b815260040161031b90612a5c565b5f805b6002811015611924576118ec816001612902565b6118f790600861291b565b61ffff1685828151811061190d5761190d612932565b016020015160f81c901b91909117906001016118d8565b5061ffff8116156119475760405162461bcd60e51b815260040161031b90612aa5565b5f805b60048110156119a25761195e816003612902565b61196990600861291b565b63ffffffff168661197b836002612946565b8151811061198b5761198b612932565b016020015160f81c901b919091179060010161194a565b5063ffffffff81166002146119c95760405162461bcd60e51b815260040161031b90612ae8565b5f805b6020811015611a1e576119e081601f612902565b6119eb90600861291b565b876119f7836006612946565b81518110611a0757611a07612932565b016020015160f81c901b91909117906001016119cc565b505f86602681518110611a3357611a33612932565b016020015191976001600160f81b03199092161515965090945050505050565b611a5b612262565b611a64826122ab565b611a6d816122cc565b5050565b5f805f8351603614611a955760405162461bcd60e51b815260040161031b90612a5c565b5f805b6002811015611ae457611aac816001612902565b611ab790600861291b565b61ffff16868281518110611acd57611acd612932565b016020015160f81c901b9190911790600101611a98565b5061ffff811615611b075760405162461bcd60e51b815260040161031b90612aa5565b5f805b6004811015611b6257611b1e816003612902565b611b2990600861291b565b63ffffffff1687611b3b836002612946565b81518110611b4b57611b4b612932565b016020015160f81c901b9190911790600101611b0a565b5063ffffffff8116600114611b895760405162461bcd60e51b815260040161031b90612ae8565b5f805b6020811015611bde57611ba081601f612902565b611bab90600861291b565b88611bb7836006612946565b81518110611bc757611bc7612932565b016020015160f81c901b9190911790600101611b8c565b505f805b6008811015611c3d57611bf6816007612902565b611c0190600861291b565b6001600160401b031689611c16836026612946565b81518110611c2657611c26612932565b016020015160f81c901b9190911790600101611be2565b505f805b6008811015611c9c57611c55816007612902565b611c6090600861291b565b6001600160401b03168a611c7583602e612946565b81518110611c8557611c85612932565b016020015160f81c901b9190911790600101611c41565b5091989097509095509350505050565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00805460011901611cf057604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b7fe92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb02545f80516020612bee8339815191529060ff165f03611d34575050565b60408051606081018252600383015480825260048401546001600160401b038082166020850152600160401b9091041692820192909252904290610e1090611d7c9083612902565b10611d98576001600160401b0384166040830152808252611db7565b8382604001818151611daa9190612b2f565b6001600160401b03169052505b5f826020015183604001516064611dce9190612b56565b611dd89190612b81565b600285015490915060ff9081169082161115611e535760405162461bcd60e51b815260206004820152603460248201527f56616c696461746f724d616e616765723a204d6178696d756d20686f75726c796044820152730818da1d5c9b881c985d1948195e18d95959195960621b606482015260840161031b565b5050805160038301556020810151600490920180546040909201516001600160401b03908116600160401b026001600160801b031990931693169290921717905550565b5f6060826080015151603014611f015760405162461bcd60e51b815260206004820152602960248201527f5374616b696e674d657373616765733a20496e76616c6964207369676e6174756044820152680e4ca40d8cadccee8d60bb1b606482015260840161031b565b60408051608680825260c082019092525f916020820181803683370190505090505f5b6002811015611f7857611f38816001612902565b611f4390600861291b565b5081515f90839083908110611f5a57611f5a612932565b60200101906001600160f81b03191690815f1a905350600101611f24565b505f5b6004811015611fd657611f8f816003612902565b611f9a90600861291b565b505f82611fa8836002612946565b81518110611fb857611fb8612932565b60200101906001600160f81b03191690815f1a905350600101611f7b565b505f5b60208110156120335784518160208110611ff557611ff5612932565b1a60f81b82612005836006612946565b8151811061201557612015612932565b60200101906001600160f81b03191690815f1a905350600101611fd9565b505f5b6020811015612093578460200151816020811061205557612055612932565b1a60f81b82612065836026612946565b8151811061207557612075612932565b60200101906001600160f81b03191690815f1a905350600101612036565b505f5b6008811015612107576120aa816007612902565b6120b590600861291b565b60ff1685604001516001600160401b0316901c60f81b828260466120d99190612946565b815181106120e9576120e9612932565b60200101906001600160f81b03191690815f1a905350600101612096565b505f5b6030811015612172578460800151818151811061212957612129612932565b01602001516001600160f81b0319168261214483604e612946565b8151811061215457612154612932565b60200101906001600160f81b03191690815f1a90535060010161210a565b505f5b60088110156121e457612189816007612902565b61219490600861291b565b60608601516001600160401b0390811691161c60f81b826121b683607e612946565b815181106121c6576121c6612932565b60200101906001600160f81b03191690815f1a905350600101612175565b506002816040516121f59190612bb2565b602060405180830381855afa158015612210573d5f803e3d5ffd5b5050506040513d601f19601f82011682018060405250810190612233919061265f565b94909350915050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166103da57604051631afcd79f60e31b815260040160405180910390fd5b6122b3612262565b6122bb6122dd565b6122c36122ed565b6103e6816122f5565b6122d4612262565b6103e681612361565b6122e5612262565b6103da612369565b6103da612262565b6122fd612262565b80355f80516020612bee83398151915290815560208201357fe92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb01556123476060830160408401612bcd565b600291909101805460ff191660ff90921691909117905550565b61092c612262565b61223c612262565b50805461237d90612799565b5f825580601f1061238c575050565b601f0160209004905f5260205f20908101906103e691905b808211156123b7575f81556001016123a4565b5090565b5f602082840312156123cb575f80fd5b5035919050565b80356001600160401b03811681146123e8575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b604051606081016001600160401b0381118282101715612423576124236123ed565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612451576124516123ed565b604052919050565b5f6001600160401b03821115612471576124716123ed565b50601f01601f191660200190565b5f805f8060808587031215612492575f80fd5b61249b856123d2565b9350602085013592506124b0604086016123d2565b915060608501356001600160401b038111156124ca575f80fd5b8501601f810187136124da575f80fd5b80356124ed6124e882612459565b612429565b818152886020838501011115612501575f80fd5b816020840160208301375f6020838301015280935050505092959194509250565b803563ffffffff811681146123e8575f80fd5b5f60208284031215612545575f80fd5b61254e82612522565b9392505050565b6001600160a01b03811681146103e6575f80fd5b5f80828403608081121561257b575f80fd5b6060811215612588575f80fd5b50829150606083013561259a81612555565b809150509250929050565b5f602082840312156125b5575f80fd5b813561254e81612555565b80151581146103e6575f80fd5b5f80604083850312156125de575f80fd5b6125e783612522565b9150602083013561259a816125c0565b634e487b7160e01b5f52602160045260245ffd5b5f5b8381101561262557818101518382015260200161260d565b50505f910152565b602081525f825180602084015261264b81604085016020870161260b565b601f01601f19169190910160400192915050565b5f6020828403121561266f575f80fd5b5051919050565b80516123e8816125c0565b5f8060408385031215612692575f80fd5b82516001600160401b03808211156126a8575f80fd5b90840190606082870312156126bb575f80fd5b6126c3612401565b825181526020808401516126d681612555565b828201526040840151838111156126eb575f80fd5b80850194505087601f8501126126ff575f80fd5b8351925061270f6124e884612459565b8381528882858701011115612722575f80fd5b6127318483830184880161260b565b80604084015250819550612746818801612676565b9450505050509250929050565b60208082526026908201527f56616c696461746f724d616e616765723a20496e76616c69642077617270206d60408201526565737361676560d01b606082015260800190565b600181811c908216806127ad57607f821691505b6020821081036127cb57634e487b7160e01b5f52602260045260245ffd5b50919050565b60208082526027908201527f56616c696461746f724d616e616765723a20496e76616c69642076616c6964616040820152661d1a5bdb88125160ca1b606082015260800190565b5f60208083525f845461282a81612799565b806020870152604060018084165f811461284b576001811461286757612894565b60ff19851660408a0152604084151560051b8a01019550612894565b895f5260205f205f5b8581101561288b5781548b8201860152908301908801612870565b8a016040019650505b509398975050505050505050565b6020808252602c908201527f56616c696461746f724d616e616765723a2053656e646572206e6f742076616c60408201526b34b230ba37b91037bbb732b960a11b606082015260800190565b634e487b7160e01b5f52601160045260245ffd5b81810381811115612915576129156128ee565b92915050565b8082028115828204841417612915576129156128ee565b634e487b7160e01b5f52603260045260245ffd5b80820180821115612915576129156128ee565b601f82111561081157805f5260205f20601f840160051c8101602085101561297e5750805b601f840160051c820191505b818110156103a2575f815560010161298a565b81516001600160401b038111156129b6576129b66123ed565b6129ca816129c48454612799565b84612959565b602080601f8311600181146129fd575f84156129e65750858301515b5f19600386901b1c1916600185901b178555612a54565b5f85815260208120601f198616915b82811015612a2b57888601518255948401946001909101908401612a0c565b5085821015612a4857878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b60208082526029908201527f56616c696461746f724d657373616765733a20496e76616c6964206d657373616040820152680ceca40d8cadccee8d60bb1b606082015260800190565b60208082526023908201527f56616c696461746f724d657373616765733a20496e76616c696420636f64656360408201526208125160ea1b606082015260800190565b60208082526027908201527f56616c696461746f724d657373616765733a20496e76616c6964206d657373616040820152666765207479706560c81b606082015260800190565b6001600160401b03818116838216019080821115612b4f57612b4f6128ee565b5092915050565b6001600160401b03818116838216028082169190828114612b7957612b796128ee565b505092915050565b5f6001600160401b0380841680612ba657634e487b7160e01b5f52601260045260245ffd5b92169190910492915050565b5f8251612bc381846020870161260b565b9190910192915050565b5f60208284031215612bdd575f80fd5b813560ff8116811461254e575f80fdfee92546d698950ddd38910d2e15ed1d923cd0a7b3dde9e2a6a3f380565559cb00a164736f6c6343000819000a", +} + +// PoAValidatorManagerABI is the input ABI used to generate the binding from. +// Deprecated: Use PoAValidatorManagerMetaData.ABI instead. +var PoAValidatorManagerABI = PoAValidatorManagerMetaData.ABI + +// PoAValidatorManagerBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use PoAValidatorManagerMetaData.Bin instead. +var PoAValidatorManagerBin = PoAValidatorManagerMetaData.Bin + +// DeployPoAValidatorManager deploys a new Ethereum contract, binding an instance of PoAValidatorManager to it. +func DeployPoAValidatorManager(auth *bind.TransactOpts, backend bind.ContractBackend, init uint8) (common.Address, *types.Transaction, *PoAValidatorManager, error) { + parsed, err := PoAValidatorManagerMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(PoAValidatorManagerBin), backend, init) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &PoAValidatorManager{PoAValidatorManagerCaller: PoAValidatorManagerCaller{contract: contract}, PoAValidatorManagerTransactor: PoAValidatorManagerTransactor{contract: contract}, PoAValidatorManagerFilterer: PoAValidatorManagerFilterer{contract: contract}}, nil +} + +// PoAValidatorManager is an auto generated Go binding around an Ethereum contract. +type PoAValidatorManager struct { + PoAValidatorManagerCaller // Read-only binding to the contract + PoAValidatorManagerTransactor // Write-only binding to the contract + PoAValidatorManagerFilterer // Log filterer for contract events +} + +// PoAValidatorManagerCaller is an auto generated read-only Go binding around an Ethereum contract. +type PoAValidatorManagerCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoAValidatorManagerTransactor is an auto generated write-only Go binding around an Ethereum contract. +type PoAValidatorManagerTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoAValidatorManagerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type PoAValidatorManagerFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// PoAValidatorManagerSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type PoAValidatorManagerSession struct { + Contract *PoAValidatorManager // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoAValidatorManagerCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type PoAValidatorManagerCallerSession struct { + Contract *PoAValidatorManagerCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// PoAValidatorManagerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type PoAValidatorManagerTransactorSession struct { + Contract *PoAValidatorManagerTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// PoAValidatorManagerRaw is an auto generated low-level Go binding around an Ethereum contract. +type PoAValidatorManagerRaw struct { + Contract *PoAValidatorManager // Generic contract binding to access the raw methods on +} + +// PoAValidatorManagerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type PoAValidatorManagerCallerRaw struct { + Contract *PoAValidatorManagerCaller // Generic read-only contract binding to access the raw methods on +} + +// PoAValidatorManagerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type PoAValidatorManagerTransactorRaw struct { + Contract *PoAValidatorManagerTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewPoAValidatorManager creates a new instance of PoAValidatorManager, bound to a specific deployed contract. +func NewPoAValidatorManager(address common.Address, backend bind.ContractBackend) (*PoAValidatorManager, error) { + contract, err := bindPoAValidatorManager(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &PoAValidatorManager{PoAValidatorManagerCaller: PoAValidatorManagerCaller{contract: contract}, PoAValidatorManagerTransactor: PoAValidatorManagerTransactor{contract: contract}, PoAValidatorManagerFilterer: PoAValidatorManagerFilterer{contract: contract}}, nil +} + +// NewPoAValidatorManagerCaller creates a new read-only instance of PoAValidatorManager, bound to a specific deployed contract. +func NewPoAValidatorManagerCaller(address common.Address, caller bind.ContractCaller) (*PoAValidatorManagerCaller, error) { + contract, err := bindPoAValidatorManager(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &PoAValidatorManagerCaller{contract: contract}, nil +} + +// NewPoAValidatorManagerTransactor creates a new write-only instance of PoAValidatorManager, bound to a specific deployed contract. +func NewPoAValidatorManagerTransactor(address common.Address, transactor bind.ContractTransactor) (*PoAValidatorManagerTransactor, error) { + contract, err := bindPoAValidatorManager(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &PoAValidatorManagerTransactor{contract: contract}, nil +} + +// NewPoAValidatorManagerFilterer creates a new log filterer instance of PoAValidatorManager, bound to a specific deployed contract. +func NewPoAValidatorManagerFilterer(address common.Address, filterer bind.ContractFilterer) (*PoAValidatorManagerFilterer, error) { + contract, err := bindPoAValidatorManager(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &PoAValidatorManagerFilterer{contract: contract}, nil +} + +// bindPoAValidatorManager binds a generic wrapper to an already deployed contract. +func bindPoAValidatorManager(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := PoAValidatorManagerMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoAValidatorManager *PoAValidatorManagerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoAValidatorManager.Contract.PoAValidatorManagerCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoAValidatorManager *PoAValidatorManagerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.PoAValidatorManagerTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoAValidatorManager *PoAValidatorManagerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.PoAValidatorManagerTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_PoAValidatorManager *PoAValidatorManagerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _PoAValidatorManager.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_PoAValidatorManager *PoAValidatorManagerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_PoAValidatorManager *PoAValidatorManagerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.contract.Transact(opts, method, params...) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerCaller) WARPMESSENGER(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoAValidatorManager.contract.Call(opts, &out, "WARP_MESSENGER") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerSession) WARPMESSENGER() (common.Address, error) { + return _PoAValidatorManager.Contract.WARPMESSENGER(&_PoAValidatorManager.CallOpts) +} + +// WARPMESSENGER is a free data retrieval call binding the contract method 0xb771b3bc. +// +// Solidity: function WARP_MESSENGER() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerCallerSession) WARPMESSENGER() (common.Address, error) { + return _PoAValidatorManager.Contract.WARPMESSENGER(&_PoAValidatorManager.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _PoAValidatorManager.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerSession) Owner() (common.Address, error) { + return _PoAValidatorManager.Contract.Owner(&_PoAValidatorManager.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_PoAValidatorManager *PoAValidatorManagerCallerSession) Owner() (common.Address, error) { + return _PoAValidatorManager.Contract.Owner(&_PoAValidatorManager.CallOpts) +} + +// CompleteEndValidation is a paid mutator transaction binding the contract method 0xfdf94a1a. +// +// Solidity: function completeEndValidation(uint32 messageIndex, bool setWeightMessageType) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) CompleteEndValidation(opts *bind.TransactOpts, messageIndex uint32, setWeightMessageType bool) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "completeEndValidation", messageIndex, setWeightMessageType) +} + +// CompleteEndValidation is a paid mutator transaction binding the contract method 0xfdf94a1a. +// +// Solidity: function completeEndValidation(uint32 messageIndex, bool setWeightMessageType) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) CompleteEndValidation(messageIndex uint32, setWeightMessageType bool) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.CompleteEndValidation(&_PoAValidatorManager.TransactOpts, messageIndex, setWeightMessageType) +} + +// CompleteEndValidation is a paid mutator transaction binding the contract method 0xfdf94a1a. +// +// Solidity: function completeEndValidation(uint32 messageIndex, bool setWeightMessageType) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) CompleteEndValidation(messageIndex uint32, setWeightMessageType bool) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.CompleteEndValidation(&_PoAValidatorManager.TransactOpts, messageIndex, setWeightMessageType) +} + +// CompleteValidatorRegistration is a paid mutator transaction binding the contract method 0xa3a65e48. +// +// Solidity: function completeValidatorRegistration(uint32 messageIndex) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) CompleteValidatorRegistration(opts *bind.TransactOpts, messageIndex uint32) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "completeValidatorRegistration", messageIndex) +} + +// CompleteValidatorRegistration is a paid mutator transaction binding the contract method 0xa3a65e48. +// +// Solidity: function completeValidatorRegistration(uint32 messageIndex) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) CompleteValidatorRegistration(messageIndex uint32) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.CompleteValidatorRegistration(&_PoAValidatorManager.TransactOpts, messageIndex) +} + +// CompleteValidatorRegistration is a paid mutator transaction binding the contract method 0xa3a65e48. +// +// Solidity: function completeValidatorRegistration(uint32 messageIndex) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) CompleteValidatorRegistration(messageIndex uint32) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.CompleteValidatorRegistration(&_PoAValidatorManager.TransactOpts, messageIndex) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc151c0b9. +// +// Solidity: function initialize((bytes32,bytes32,uint8) settings, address initialOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) Initialize(opts *bind.TransactOpts, settings ValidatorManagerSettings, initialOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "initialize", settings, initialOwner) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc151c0b9. +// +// Solidity: function initialize((bytes32,bytes32,uint8) settings, address initialOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) Initialize(settings ValidatorManagerSettings, initialOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.Initialize(&_PoAValidatorManager.TransactOpts, settings, initialOwner) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc151c0b9. +// +// Solidity: function initialize((bytes32,bytes32,uint8) settings, address initialOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) Initialize(settings ValidatorManagerSettings, initialOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.Initialize(&_PoAValidatorManager.TransactOpts, settings, initialOwner) +} + +// InitializeEndValidation is a paid mutator transaction binding the contract method 0x97fb70d4. +// +// Solidity: function initializeEndValidation(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) InitializeEndValidation(opts *bind.TransactOpts, validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "initializeEndValidation", validationID) +} + +// InitializeEndValidation is a paid mutator transaction binding the contract method 0x97fb70d4. +// +// Solidity: function initializeEndValidation(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) InitializeEndValidation(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.InitializeEndValidation(&_PoAValidatorManager.TransactOpts, validationID) +} + +// InitializeEndValidation is a paid mutator transaction binding the contract method 0x97fb70d4. +// +// Solidity: function initializeEndValidation(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) InitializeEndValidation(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.InitializeEndValidation(&_PoAValidatorManager.TransactOpts, validationID) +} + +// InitializeValidatorRegistration is a paid mutator transaction binding the contract method 0x3aaa9f25. +// +// Solidity: function initializeValidatorRegistration(uint64 weight, bytes32 nodeID, uint64 registrationExpiry, bytes signature) returns(bytes32 validationID) +func (_PoAValidatorManager *PoAValidatorManagerTransactor) InitializeValidatorRegistration(opts *bind.TransactOpts, weight uint64, nodeID [32]byte, registrationExpiry uint64, signature []byte) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "initializeValidatorRegistration", weight, nodeID, registrationExpiry, signature) +} + +// InitializeValidatorRegistration is a paid mutator transaction binding the contract method 0x3aaa9f25. +// +// Solidity: function initializeValidatorRegistration(uint64 weight, bytes32 nodeID, uint64 registrationExpiry, bytes signature) returns(bytes32 validationID) +func (_PoAValidatorManager *PoAValidatorManagerSession) InitializeValidatorRegistration(weight uint64, nodeID [32]byte, registrationExpiry uint64, signature []byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.InitializeValidatorRegistration(&_PoAValidatorManager.TransactOpts, weight, nodeID, registrationExpiry, signature) +} + +// InitializeValidatorRegistration is a paid mutator transaction binding the contract method 0x3aaa9f25. +// +// Solidity: function initializeValidatorRegistration(uint64 weight, bytes32 nodeID, uint64 registrationExpiry, bytes signature) returns(bytes32 validationID) +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) InitializeValidatorRegistration(weight uint64, nodeID [32]byte, registrationExpiry uint64, signature []byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.InitializeValidatorRegistration(&_PoAValidatorManager.TransactOpts, weight, nodeID, registrationExpiry, signature) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) RenounceOwnership() (*types.Transaction, error) { + return _PoAValidatorManager.Contract.RenounceOwnership(&_PoAValidatorManager.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _PoAValidatorManager.Contract.RenounceOwnership(&_PoAValidatorManager.TransactOpts) +} + +// ResendEndValidatorMessage is a paid mutator transaction binding the contract method 0x0322ed98. +// +// Solidity: function resendEndValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) ResendEndValidatorMessage(opts *bind.TransactOpts, validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "resendEndValidatorMessage", validationID) +} + +// ResendEndValidatorMessage is a paid mutator transaction binding the contract method 0x0322ed98. +// +// Solidity: function resendEndValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) ResendEndValidatorMessage(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.ResendEndValidatorMessage(&_PoAValidatorManager.TransactOpts, validationID) +} + +// ResendEndValidatorMessage is a paid mutator transaction binding the contract method 0x0322ed98. +// +// Solidity: function resendEndValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) ResendEndValidatorMessage(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.ResendEndValidatorMessage(&_PoAValidatorManager.TransactOpts, validationID) +} + +// ResendRegisterValidatorMessage is a paid mutator transaction binding the contract method 0xbee0a03f. +// +// Solidity: function resendRegisterValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) ResendRegisterValidatorMessage(opts *bind.TransactOpts, validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "resendRegisterValidatorMessage", validationID) +} + +// ResendRegisterValidatorMessage is a paid mutator transaction binding the contract method 0xbee0a03f. +// +// Solidity: function resendRegisterValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) ResendRegisterValidatorMessage(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.ResendRegisterValidatorMessage(&_PoAValidatorManager.TransactOpts, validationID) +} + +// ResendRegisterValidatorMessage is a paid mutator transaction binding the contract method 0xbee0a03f. +// +// Solidity: function resendRegisterValidatorMessage(bytes32 validationID) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) ResendRegisterValidatorMessage(validationID [32]byte) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.ResendRegisterValidatorMessage(&_PoAValidatorManager.TransactOpts, validationID) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.TransferOwnership(&_PoAValidatorManager.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_PoAValidatorManager *PoAValidatorManagerTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _PoAValidatorManager.Contract.TransferOwnership(&_PoAValidatorManager.TransactOpts, newOwner) +} + +// PoAValidatorManagerInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the PoAValidatorManager contract. +type PoAValidatorManagerInitializedIterator struct { + Event *PoAValidatorManagerInitialized // 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 interfaces.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 *PoAValidatorManagerInitializedIterator) 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(PoAValidatorManagerInitialized) + 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(PoAValidatorManagerInitialized) + 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 *PoAValidatorManagerInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerInitialized represents a Initialized event raised by the PoAValidatorManager contract. +type PoAValidatorManagerInitialized struct { + Version uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterInitialized(opts *bind.FilterOpts) (*PoAValidatorManagerInitializedIterator, error) { + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &PoAValidatorManagerInitializedIterator{contract: _PoAValidatorManager.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerInitialized) (event.Subscription, error) { + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "Initialized") + 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(PoAValidatorManagerInitialized) + if err := _PoAValidatorManager.contract.UnpackLog(event, "Initialized", 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 +} + +// ParseInitialized is a log parse operation binding the contract event 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2. +// +// Solidity: event Initialized(uint64 version) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseInitialized(log types.Log) (*PoAValidatorManagerInitialized, error) { + event := new(PoAValidatorManagerInitialized) + if err := _PoAValidatorManager.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoAValidatorManagerOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the PoAValidatorManager contract. +type PoAValidatorManagerOwnershipTransferredIterator struct { + Event *PoAValidatorManagerOwnershipTransferred // 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 interfaces.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 *PoAValidatorManagerOwnershipTransferredIterator) 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(PoAValidatorManagerOwnershipTransferred) + 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(PoAValidatorManagerOwnershipTransferred) + 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 *PoAValidatorManagerOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerOwnershipTransferred represents a OwnershipTransferred event raised by the PoAValidatorManager contract. +type PoAValidatorManagerOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*PoAValidatorManagerOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &PoAValidatorManagerOwnershipTransferredIterator{contract: _PoAValidatorManager.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + 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(PoAValidatorManagerOwnershipTransferred) + if err := _PoAValidatorManager.contract.UnpackLog(event, "OwnershipTransferred", 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 +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseOwnershipTransferred(log types.Log) (*PoAValidatorManagerOwnershipTransferred, error) { + event := new(PoAValidatorManagerOwnershipTransferred) + if err := _PoAValidatorManager.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoAValidatorManagerValidationPeriodCreatedIterator is returned from FilterValidationPeriodCreated and is used to iterate over the raw logs and unpacked data for ValidationPeriodCreated events raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodCreatedIterator struct { + Event *PoAValidatorManagerValidationPeriodCreated // 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 interfaces.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 *PoAValidatorManagerValidationPeriodCreatedIterator) 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(PoAValidatorManagerValidationPeriodCreated) + 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(PoAValidatorManagerValidationPeriodCreated) + 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 *PoAValidatorManagerValidationPeriodCreatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerValidationPeriodCreatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerValidationPeriodCreated represents a ValidationPeriodCreated event raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodCreated struct { + ValidationID [32]byte + NodeID [32]byte + RegisterValidationMessageID [32]byte + Weight *big.Int + RegistrationExpiry uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterValidationPeriodCreated is a free log retrieval operation binding the contract event 0x79b81620b81daf2c08cd5bb3dbb79e75d2d7a87f52171fde5aadc8c47823026e. +// +// Solidity: event ValidationPeriodCreated(bytes32 indexed validationID, bytes32 indexed nodeID, bytes32 indexed registerValidationMessageID, uint256 weight, uint64 registrationExpiry) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterValidationPeriodCreated(opts *bind.FilterOpts, validationID [][32]byte, nodeID [][32]byte, registerValidationMessageID [][32]byte) (*PoAValidatorManagerValidationPeriodCreatedIterator, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + var nodeIDRule []interface{} + for _, nodeIDItem := range nodeID { + nodeIDRule = append(nodeIDRule, nodeIDItem) + } + var registerValidationMessageIDRule []interface{} + for _, registerValidationMessageIDItem := range registerValidationMessageID { + registerValidationMessageIDRule = append(registerValidationMessageIDRule, registerValidationMessageIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "ValidationPeriodCreated", validationIDRule, nodeIDRule, registerValidationMessageIDRule) + if err != nil { + return nil, err + } + return &PoAValidatorManagerValidationPeriodCreatedIterator{contract: _PoAValidatorManager.contract, event: "ValidationPeriodCreated", logs: logs, sub: sub}, nil +} + +// WatchValidationPeriodCreated is a free log subscription operation binding the contract event 0x79b81620b81daf2c08cd5bb3dbb79e75d2d7a87f52171fde5aadc8c47823026e. +// +// Solidity: event ValidationPeriodCreated(bytes32 indexed validationID, bytes32 indexed nodeID, bytes32 indexed registerValidationMessageID, uint256 weight, uint64 registrationExpiry) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchValidationPeriodCreated(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerValidationPeriodCreated, validationID [][32]byte, nodeID [][32]byte, registerValidationMessageID [][32]byte) (event.Subscription, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + var nodeIDRule []interface{} + for _, nodeIDItem := range nodeID { + nodeIDRule = append(nodeIDRule, nodeIDItem) + } + var registerValidationMessageIDRule []interface{} + for _, registerValidationMessageIDItem := range registerValidationMessageID { + registerValidationMessageIDRule = append(registerValidationMessageIDRule, registerValidationMessageIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "ValidationPeriodCreated", validationIDRule, nodeIDRule, registerValidationMessageIDRule) + 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(PoAValidatorManagerValidationPeriodCreated) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodCreated", 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 +} + +// ParseValidationPeriodCreated is a log parse operation binding the contract event 0x79b81620b81daf2c08cd5bb3dbb79e75d2d7a87f52171fde5aadc8c47823026e. +// +// Solidity: event ValidationPeriodCreated(bytes32 indexed validationID, bytes32 indexed nodeID, bytes32 indexed registerValidationMessageID, uint256 weight, uint64 registrationExpiry) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseValidationPeriodCreated(log types.Log) (*PoAValidatorManagerValidationPeriodCreated, error) { + event := new(PoAValidatorManagerValidationPeriodCreated) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodCreated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoAValidatorManagerValidationPeriodEndedIterator is returned from FilterValidationPeriodEnded and is used to iterate over the raw logs and unpacked data for ValidationPeriodEnded events raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodEndedIterator struct { + Event *PoAValidatorManagerValidationPeriodEnded // 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 interfaces.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 *PoAValidatorManagerValidationPeriodEndedIterator) 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(PoAValidatorManagerValidationPeriodEnded) + 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(PoAValidatorManagerValidationPeriodEnded) + 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 *PoAValidatorManagerValidationPeriodEndedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerValidationPeriodEndedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerValidationPeriodEnded represents a ValidationPeriodEnded event raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodEnded struct { + ValidationID [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterValidationPeriodEnded is a free log retrieval operation binding the contract event 0x3532ad18e70a039beb4663d48c15acbef558c96ec9b8fd0cc3c0304f774740b8. +// +// Solidity: event ValidationPeriodEnded(bytes32 indexed validationID) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterValidationPeriodEnded(opts *bind.FilterOpts, validationID [][32]byte) (*PoAValidatorManagerValidationPeriodEndedIterator, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "ValidationPeriodEnded", validationIDRule) + if err != nil { + return nil, err + } + return &PoAValidatorManagerValidationPeriodEndedIterator{contract: _PoAValidatorManager.contract, event: "ValidationPeriodEnded", logs: logs, sub: sub}, nil +} + +// WatchValidationPeriodEnded is a free log subscription operation binding the contract event 0x3532ad18e70a039beb4663d48c15acbef558c96ec9b8fd0cc3c0304f774740b8. +// +// Solidity: event ValidationPeriodEnded(bytes32 indexed validationID) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchValidationPeriodEnded(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerValidationPeriodEnded, validationID [][32]byte) (event.Subscription, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "ValidationPeriodEnded", validationIDRule) + 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(PoAValidatorManagerValidationPeriodEnded) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodEnded", 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 +} + +// ParseValidationPeriodEnded is a log parse operation binding the contract event 0x3532ad18e70a039beb4663d48c15acbef558c96ec9b8fd0cc3c0304f774740b8. +// +// Solidity: event ValidationPeriodEnded(bytes32 indexed validationID) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseValidationPeriodEnded(log types.Log) (*PoAValidatorManagerValidationPeriodEnded, error) { + event := new(PoAValidatorManagerValidationPeriodEnded) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodEnded", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoAValidatorManagerValidationPeriodRegisteredIterator is returned from FilterValidationPeriodRegistered and is used to iterate over the raw logs and unpacked data for ValidationPeriodRegistered events raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodRegisteredIterator struct { + Event *PoAValidatorManagerValidationPeriodRegistered // 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 interfaces.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 *PoAValidatorManagerValidationPeriodRegisteredIterator) 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(PoAValidatorManagerValidationPeriodRegistered) + 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(PoAValidatorManagerValidationPeriodRegistered) + 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 *PoAValidatorManagerValidationPeriodRegisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerValidationPeriodRegisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerValidationPeriodRegistered represents a ValidationPeriodRegistered event raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidationPeriodRegistered struct { + ValidationID [32]byte + Weight *big.Int + Timestamp *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterValidationPeriodRegistered is a free log retrieval operation binding the contract event 0xf8fd1c90fb9cfa2ca2358fdf5806b086ad43315d92b221c929efc7f105ce7568. +// +// Solidity: event ValidationPeriodRegistered(bytes32 indexed validationID, uint256 weight, uint256 timestamp) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterValidationPeriodRegistered(opts *bind.FilterOpts, validationID [][32]byte) (*PoAValidatorManagerValidationPeriodRegisteredIterator, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "ValidationPeriodRegistered", validationIDRule) + if err != nil { + return nil, err + } + return &PoAValidatorManagerValidationPeriodRegisteredIterator{contract: _PoAValidatorManager.contract, event: "ValidationPeriodRegistered", logs: logs, sub: sub}, nil +} + +// WatchValidationPeriodRegistered is a free log subscription operation binding the contract event 0xf8fd1c90fb9cfa2ca2358fdf5806b086ad43315d92b221c929efc7f105ce7568. +// +// Solidity: event ValidationPeriodRegistered(bytes32 indexed validationID, uint256 weight, uint256 timestamp) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchValidationPeriodRegistered(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerValidationPeriodRegistered, validationID [][32]byte) (event.Subscription, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "ValidationPeriodRegistered", validationIDRule) + 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(PoAValidatorManagerValidationPeriodRegistered) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodRegistered", 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 +} + +// ParseValidationPeriodRegistered is a log parse operation binding the contract event 0xf8fd1c90fb9cfa2ca2358fdf5806b086ad43315d92b221c929efc7f105ce7568. +// +// Solidity: event ValidationPeriodRegistered(bytes32 indexed validationID, uint256 weight, uint256 timestamp) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseValidationPeriodRegistered(log types.Log) (*PoAValidatorManagerValidationPeriodRegistered, error) { + event := new(PoAValidatorManagerValidationPeriodRegistered) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidationPeriodRegistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// PoAValidatorManagerValidatorRemovalInitializedIterator is returned from FilterValidatorRemovalInitialized and is used to iterate over the raw logs and unpacked data for ValidatorRemovalInitialized events raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidatorRemovalInitializedIterator struct { + Event *PoAValidatorManagerValidatorRemovalInitialized // 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 interfaces.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 *PoAValidatorManagerValidatorRemovalInitializedIterator) 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(PoAValidatorManagerValidatorRemovalInitialized) + 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(PoAValidatorManagerValidatorRemovalInitialized) + 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 *PoAValidatorManagerValidatorRemovalInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *PoAValidatorManagerValidatorRemovalInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// PoAValidatorManagerValidatorRemovalInitialized represents a ValidatorRemovalInitialized event raised by the PoAValidatorManager contract. +type PoAValidatorManagerValidatorRemovalInitialized struct { + ValidationID [32]byte + SetWeightMessageID [32]byte + Weight *big.Int + EndTime *big.Int + Uptime uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterValidatorRemovalInitialized is a free log retrieval operation binding the contract event 0x530b908725650fb1052974f9df59e834fefac78c9ec2f00c6d2464d60cc6add5. +// +// Solidity: event ValidatorRemovalInitialized(bytes32 indexed validationID, bytes32 indexed setWeightMessageID, uint256 weight, uint256 endTime, uint64 uptime) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) FilterValidatorRemovalInitialized(opts *bind.FilterOpts, validationID [][32]byte, setWeightMessageID [][32]byte) (*PoAValidatorManagerValidatorRemovalInitializedIterator, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + var setWeightMessageIDRule []interface{} + for _, setWeightMessageIDItem := range setWeightMessageID { + setWeightMessageIDRule = append(setWeightMessageIDRule, setWeightMessageIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.FilterLogs(opts, "ValidatorRemovalInitialized", validationIDRule, setWeightMessageIDRule) + if err != nil { + return nil, err + } + return &PoAValidatorManagerValidatorRemovalInitializedIterator{contract: _PoAValidatorManager.contract, event: "ValidatorRemovalInitialized", logs: logs, sub: sub}, nil +} + +// WatchValidatorRemovalInitialized is a free log subscription operation binding the contract event 0x530b908725650fb1052974f9df59e834fefac78c9ec2f00c6d2464d60cc6add5. +// +// Solidity: event ValidatorRemovalInitialized(bytes32 indexed validationID, bytes32 indexed setWeightMessageID, uint256 weight, uint256 endTime, uint64 uptime) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) WatchValidatorRemovalInitialized(opts *bind.WatchOpts, sink chan<- *PoAValidatorManagerValidatorRemovalInitialized, validationID [][32]byte, setWeightMessageID [][32]byte) (event.Subscription, error) { + + var validationIDRule []interface{} + for _, validationIDItem := range validationID { + validationIDRule = append(validationIDRule, validationIDItem) + } + var setWeightMessageIDRule []interface{} + for _, setWeightMessageIDItem := range setWeightMessageID { + setWeightMessageIDRule = append(setWeightMessageIDRule, setWeightMessageIDItem) + } + + logs, sub, err := _PoAValidatorManager.contract.WatchLogs(opts, "ValidatorRemovalInitialized", validationIDRule, setWeightMessageIDRule) + 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(PoAValidatorManagerValidatorRemovalInitialized) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidatorRemovalInitialized", 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 +} + +// ParseValidatorRemovalInitialized is a log parse operation binding the contract event 0x530b908725650fb1052974f9df59e834fefac78c9ec2f00c6d2464d60cc6add5. +// +// Solidity: event ValidatorRemovalInitialized(bytes32 indexed validationID, bytes32 indexed setWeightMessageID, uint256 weight, uint256 endTime, uint64 uptime) +func (_PoAValidatorManager *PoAValidatorManagerFilterer) ParseValidatorRemovalInitialized(log types.Log) (*PoAValidatorManagerValidatorRemovalInitialized, error) { + event := new(PoAValidatorManagerValidatorRemovalInitialized) + if err := _PoAValidatorManager.contract.UnpackLog(event, "ValidatorRemovalInitialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/scripts/abi_bindings.sh b/scripts/abi_bindings.sh index 4b2f09dce..a9380d05c 100755 --- a/scripts/abi_bindings.sh +++ b/scripts/abi_bindings.sh @@ -16,7 +16,7 @@ export ARCH=$(uname -m) [ $ARCH = x86_64 ] && ARCH=amd64 echo "ARCH set to $ARCH" -DEFAULT_CONTRACT_LIST="TeleporterMessenger TeleporterRegistry ExampleERC20 TestMessenger ValidatorSetSig NativeTokenStakingManager ERC20TokenStakingManager" +DEFAULT_CONTRACT_LIST="TeleporterMessenger TeleporterRegistry ExampleERC20 TestMessenger ValidatorSetSig NativeTokenStakingManager ERC20TokenStakingManager PoAValidatorManager" CONTRACT_LIST= HELP= diff --git a/tests/flows/erc20_token_staking.go b/tests/flows/erc20_token_staking.go index a9bb4f8cb..ba40a8073 100644 --- a/tests/flows/erc20_token_staking.go +++ b/tests/flows/erc20_token_staking.go @@ -82,7 +82,6 @@ func ERC20TokenStakingManager(network interfaces.LocalNetwork) { // (Sending to the P-Chain will be skipped for now) signedWarpMessage := network.ConstructSignedWarpMessage(context.Background(), receipt, subnetAInfo, pChainInfo) - // Validate the Warp message, (this will be done on the P-Chain in the future) // Validate the Warp message, (this will be done on the P-Chain in the future) utils.ValidateRegisterSubnetValidatorMessage( signedWarpMessage, diff --git a/tests/flows/poa_validator_manager.go b/tests/flows/poa_validator_manager.go new file mode 100644 index 000000000..c693d0f2a --- /dev/null +++ b/tests/flows/poa_validator_manager.go @@ -0,0 +1,197 @@ +package flows + +import ( + "context" + "math/big" + "time" + + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/utils/crypto/bls" + "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/subnet-evm/core/types" + "github.com/ava-labs/teleporter/tests/interfaces" + "github.com/ava-labs/teleporter/tests/utils" + "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/gomega" +) + +/* +* Register a PoA validator manager on a L1. The steps are as follows: +* - Generate random address to be the owner address +* - Fund native assets to the owner address +* - Deploy the PoAValidatorManager contract +* - Attempt to initiate with non owner and check that it fails +* - Initiate validator registration +* - Deliver the Warp message to the P-Chain (not implemented) +* - Aggregate P-Chain signatures on the response Warp message +* - Deliver the Warp message to the L1 +* - Verify that the validator is registered in the validator manager contract + +* Delists the validator from the L1. The steps are as follows: +* - Attempt to initiate with non owner and check that it fails +* - Initiate validator delisting +* - Deliver the Warp message to the P-Chain (not implemented) +* - Aggregate P-Chain signatures on the response Warp message +* - Deliver the Warp message to the L1 +* - Verify that the validator is delisted from the validator manager contract + */ +func PoAValidatorManager(network interfaces.LocalNetwork) { + cChainInfo := network.GetPrimaryNetworkInfo() + subnetAInfo, _ := utils.GetTwoSubnets(network) + _, fundedKey := network.GetFundedAccountInfo() + pChainInfo := utils.GetPChainInfo(cChainInfo) + + signatureAggregator := utils.NewSignatureAggregator( + cChainInfo.NodeURIs[0], + []ids.ID{ + subnetAInfo.SubnetID, + ids.Empty, // Primary network subnet ID + }, + ) + + // Generate random address to be the owner address + ownerKey, err := crypto.GenerateKey() + Expect(err).Should(BeNil()) + ownerAddress := crypto.PubkeyToAddress(ownerKey.PublicKey) + + // Transfer native assets to the non owner account + ctx := context.Background() + fundAmount := big.NewInt(1e18) // 1avax + utils.SendNativeTransfer( + ctx, + subnetAInfo, + fundedKey, + ownerAddress, + fundAmount, + ) + + validatorManagerAddress, validatorManager := utils.DeployAndInitializePoAValidatorManager( + ctx, + fundedKey, + subnetAInfo, + pChainInfo, + ownerAddress, + ) + + var validationID ids.ID // To be used in the delisting step + nodeID := ids.GenerateTestID() + blsPublicKey := [bls.PublicKeyLen]byte{} + weight := uint64(1) + + { + // Try to call with invalid owner + opts, err := bind.NewKeyedTransactorWithChainID(fundedKey, subnetAInfo.EVMChainID) + Expect(err).Should(BeNil()) + + _, err = validatorManager.InitializeValidatorRegistration( + opts, + weight, + nodeID, + uint64(time.Now().Add(24*time.Hour).Unix()), + blsPublicKey[:], + ) + Expect(err).ShouldNot(BeNil()) + + // Initiate validator registration + var receipt *types.Receipt + receipt, validationID = utils.InitializePoAValidatorRegistration( + ownerKey, + subnetAInfo, + weight, + nodeID, + blsPublicKey, + validatorManager, + ) + + // Gather subnet-evm Warp signatures for the RegisterSubnetValidatorMessage & relay to the P-Chain + // (Sending to the P-Chain will be skipped for now) + signedWarpMessage := network.ConstructSignedWarpMessage(context.Background(), receipt, subnetAInfo, pChainInfo) + + // Validate the Warp message, (this will be done on the P-Chain in the future) + utils.ValidateRegisterSubnetValidatorMessage( + signedWarpMessage, + nodeID, + weight, + subnetAInfo.SubnetID, + blsPublicKey, + ) + + // Construct a SubnetValidatorRegistrationMessage Warp message from the P-Chain + registrationSignedMessage := utils.ConstructSubnetValidatorRegistrationMessage( + validationID, + true, + subnetAInfo, + pChainInfo, + network, + signatureAggregator, + ) + + // Deliver the Warp message to the subnet + receipt = utils.CompletePoAValidatorRegistration( + fundedKey, + subnetAInfo, + validatorManagerAddress, + registrationSignedMessage, + ) + // Check that the validator is registered in the staking contract + registrationEvent, err := utils.GetEventFromLogs( + receipt.Logs, + validatorManager.ParseValidationPeriodRegistered, + ) + Expect(err).Should(BeNil()) + Expect(registrationEvent.ValidationID[:]).Should(Equal(validationID[:])) + } + + // + // Delist the validator + // + { + receipt := utils.InitializeEndPoAValidation( + fundedKey, + subnetAInfo, + validatorManager, + validationID, + ) + validatorRemovalEvent, err := utils.GetEventFromLogs( + receipt.Logs, + validatorManager.ParseValidatorRemovalInitialized, + ) + Expect(err).Should(BeNil()) + Expect(validatorRemovalEvent.ValidationID[:]).Should(Equal(validationID[:])) + Expect(validatorRemovalEvent.Weight.Uint64()).Should(Equal(weight)) + + // Gather subnet-evm Warp signatures for the SetSubnetValidatorWeightMessage & relay to the P-Chain + // (Sending to the P-Chain will be skipped for now) + signedWarpMessage := network.ConstructSignedWarpMessage(context.Background(), receipt, subnetAInfo, pChainInfo) + Expect(err).Should(BeNil()) + + // Validate the Warp message, (this will be done on the P-Chain in the future) + utils.ValidateSetSubnetValidatorWeightMessage(signedWarpMessage, validationID, 0, 0) + + // Construct a SubnetValidatorRegistrationMessage Warp message from the P-Chain + registrationSignedMessage := utils.ConstructSubnetValidatorRegistrationMessage( + validationID, + false, + subnetAInfo, + pChainInfo, + network, + signatureAggregator, + ) + + // Deliver the Warp message to the subnet + receipt = utils.CompleteEndPoAValidation( + fundedKey, + subnetAInfo, + validatorManagerAddress, + registrationSignedMessage, + ) + + // Check that the validator is has been delisted from the staking contract + registrationEvent, err := utils.GetEventFromLogs( + receipt.Logs, + validatorManager.ParseValidationPeriodEnded, + ) + Expect(err).Should(BeNil()) + Expect(registrationEvent.ValidationID[:]).Should(Equal(validationID[:])) + } +} diff --git a/tests/utils/staking.go b/tests/utils/staking.go index 453464e8f..5c998e18f 100644 --- a/tests/utils/staking.go +++ b/tests/utils/staking.go @@ -20,6 +20,7 @@ import ( exampleerc20 "github.com/ava-labs/teleporter/abi-bindings/go/mocks/ExampleERC20" erc20tokenstakingmanager "github.com/ava-labs/teleporter/abi-bindings/go/staking/ERC20TokenStakingManager" nativetokenstakingmanager "github.com/ava-labs/teleporter/abi-bindings/go/staking/NativeTokenStakingManager" + poavalidatormanager "github.com/ava-labs/teleporter/abi-bindings/go/staking/PoAValidatorManager" "github.com/ava-labs/teleporter/tests/interfaces" "github.com/ethereum/go-ethereum/common" @@ -144,6 +145,55 @@ func DeployAndInitializeERC20TokenStakingManager( return stakingManagerContractAddress, stakingManager, erc20Address, erc20 } +func DeployPoAValidatorManager( + ctx context.Context, + senderKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, +) (common.Address, *poavalidatormanager.PoAValidatorManager) { + opts, err := bind.NewKeyedTransactorWithChainID(senderKey, subnet.EVMChainID) + Expect(err).Should(BeNil()) + address, tx, validatorManager, err := poavalidatormanager.DeployPoAValidatorManager( + opts, + subnet.RPCClient, + 0, // ICMInitializable.Allowed + ) + Expect(err).Should(BeNil()) + + // Wait for the transaction to be mined + WaitForTransactionSuccess(ctx, subnet, tx.Hash()) + + return address, validatorManager +} + +func DeployAndInitializePoAValidatorManager( + ctx context.Context, + senderKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, + pChainInfo interfaces.SubnetTestInfo, + ownerAddress common.Address, +) (common.Address, *poavalidatormanager.PoAValidatorManager) { + validatorManagerAddress, validatorManager := DeployPoAValidatorManager( + ctx, + senderKey, + subnet, + ) + opts, err := bind.NewKeyedTransactorWithChainID(senderKey, subnet.EVMChainID) + Expect(err).Should(BeNil()) + tx, err := validatorManager.Initialize( + opts, + poavalidatormanager.ValidatorManagerSettings{ + PChainBlockchainID: pChainInfo.BlockchainID, + SubnetID: subnet.SubnetID, + MaximumHourlyChurn: 0, + }, + ownerAddress, + ) + Expect(err).Should(BeNil()) + WaitForTransactionSuccess(context.Background(), subnet, tx.Hash()) + + return validatorManagerAddress, validatorManager +} + // // Function call utils // @@ -215,6 +265,34 @@ func InitializeERC20ValidatorRegistration( return receipt, ids.ID(registrationInitiatedEvent.ValidationID) } +func InitializePoAValidatorRegistration( + senderKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, + weight uint64, + nodeID ids.ID, + blsPublicKey [bls.PublicKeyLen]byte, + validatorManager *poavalidatormanager.PoAValidatorManager, +) (*types.Receipt, ids.ID) { + opts, err := bind.NewKeyedTransactorWithChainID(senderKey, subnet.EVMChainID) + Expect(err).Should(BeNil()) + + tx, err := validatorManager.InitializeValidatorRegistration( + opts, + weight, + nodeID, + uint64(time.Now().Add(24*time.Hour).Unix()), + blsPublicKey[:], + ) + Expect(err).Should(BeNil()) + receipt := WaitForTransactionSuccess(context.Background(), subnet, tx.Hash()) + registrationInitiatedEvent, err := GetEventFromLogs( + receipt.Logs, + validatorManager.ParseValidationPeriodCreated, + ) + Expect(err).Should(BeNil()) + return receipt, ids.ID(registrationInitiatedEvent.ValidationID) +} + func CompleteNativeValidatorRegistration( sendingKey *ecdsa.PrivateKey, subnet interfaces.SubnetTestInfo, @@ -249,6 +327,23 @@ func CompleteERC20ValidatorRegistration( ) } +func CompletePoAValidatorRegistration( + sendingKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, + validatorManagerAddress common.Address, + registrationSignedMessage *avalancheWarp.Message, +) *types.Receipt { + abi, err := poavalidatormanager.PoAValidatorManagerMetaData.GetAbi() + Expect(err).Should(BeNil()) + return completeValidatorRegistration( + abi, + sendingKey, + subnet, + validatorManagerAddress, + registrationSignedMessage, + ) +} + func completeValidatorRegistration( abi *abi.ABI, sendingKey *ecdsa.PrivateKey, @@ -312,6 +407,22 @@ func InitializeEndERC20Validation( return WaitForTransactionSuccess(context.Background(), subnet, tx.Hash()) } +func InitializeEndPoAValidation( + sendingKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, + validatorManager *poavalidatormanager.PoAValidatorManager, + validationID ids.ID, +) *types.Receipt { + opts, err := bind.NewKeyedTransactorWithChainID(sendingKey, subnet.EVMChainID) + Expect(err).Should(BeNil()) + tx, err := validatorManager.InitializeEndValidation( + opts, + validationID, + ) + Expect(err).Should(BeNil()) + return WaitForTransactionSuccess(context.Background(), subnet, tx.Hash()) +} + func CompleteEndNativeValidation( sendingKey *ecdsa.PrivateKey, subnet interfaces.SubnetTestInfo, @@ -346,6 +457,23 @@ func CompleteEndERC20Validation( ) } +func CompleteEndPoAValidation( + sendingKey *ecdsa.PrivateKey, + subnet interfaces.SubnetTestInfo, + validatorManagerAddress common.Address, + registrationSignedMessage *avalancheWarp.Message, +) *types.Receipt { + abi, err := poavalidatormanager.PoAValidatorManagerMetaData.GetAbi() + Expect(err).Should(BeNil()) + return callCompleteEndValidation( + abi, + sendingKey, + subnet, + validatorManagerAddress, + registrationSignedMessage, + ) +} + func callCompleteEndValidation( abi *abi.ABI, sendingKey *ecdsa.PrivateKey, From 1196be39f1ffa5ecc19564ced3b9c9e427e3cb52 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 10:18:53 -0400 Subject: [PATCH 02/10] restructure e2e test flows --- tests/flows/errors.go | 2 +- .../{ => governance}/validator_set_sig.go | 2 +- .../{ => staking}/erc20_token_staking.go | 2 +- .../{ => staking}/native_token_staking.go | 2 +- .../{ => staking}/poa_validator_manager.go | 2 +- .../flows/{ => teleporter}/add_fee_amount.go | 2 +- .../{ => teleporter}/basic_send_receive.go | 2 +- .../deliver_to_nonexistent_contract.go | 2 +- .../deliver_to_wrong_chain.go | 2 +- .../{ => teleporter}/insufficient_gas.go | 2 +- .../registry}/check_upgrade_access.go | 8 +- .../registry}/pause_teleporter.go | 2 +- .../registry}/teleporter_registry.go | 2 +- .../{ => teleporter}/relay_message_twice.go | 2 +- .../relayer_modifies_message.go | 2 +- .../resubmit_altered_message.go | 2 +- .../retry_successful_execution.go | 2 +- .../send_specific_receipts.go | 2 +- .../teleporter_message_ids.go | 2 +- .../{ => teleporter}/unallowed_relayer.go | 2 +- .../flows/{ => teleporter}/validator_churn.go | 2 +- tests/local/e2e_test.go | 85 ++++++++++--------- tests/testnet/main/run_testnet_flows.go | 26 +++--- 23 files changed, 86 insertions(+), 73 deletions(-) rename tests/flows/{ => governance}/validator_set_sig.go (99%) rename tests/flows/{ => staking}/erc20_token_staking.go (99%) rename tests/flows/{ => staking}/native_token_staking.go (99%) rename tests/flows/{ => staking}/poa_validator_manager.go (99%) rename tests/flows/{ => teleporter}/add_fee_amount.go (99%) rename tests/flows/{ => teleporter}/basic_send_receive.go (99%) rename tests/flows/{ => teleporter}/deliver_to_nonexistent_contract.go (99%) rename tests/flows/{ => teleporter}/deliver_to_wrong_chain.go (99%) rename tests/flows/{ => teleporter}/insufficient_gas.go (99%) rename tests/flows/{ => teleporter/registry}/check_upgrade_access.go (95%) rename tests/flows/{ => teleporter/registry}/pause_teleporter.go (99%) rename tests/flows/{ => teleporter/registry}/teleporter_registry.go (99%) rename tests/flows/{ => teleporter}/relay_message_twice.go (99%) rename tests/flows/{ => teleporter}/relayer_modifies_message.go (99%) rename tests/flows/{ => teleporter}/resubmit_altered_message.go (99%) rename tests/flows/{ => teleporter}/retry_successful_execution.go (99%) rename tests/flows/{ => teleporter}/send_specific_receipts.go (99%) rename tests/flows/{ => teleporter}/teleporter_message_ids.go (98%) rename tests/flows/{ => teleporter}/unallowed_relayer.go (99%) rename tests/flows/{ => teleporter}/validator_churn.go (99%) diff --git a/tests/flows/errors.go b/tests/flows/errors.go index c3efc7ec4..9ba39996c 100644 --- a/tests/flows/errors.go +++ b/tests/flows/errors.go @@ -1,5 +1,5 @@ package flows const ( - errTxReverted = "execution reverted" + ErrTxReverted = "execution reverted" ) diff --git a/tests/flows/validator_set_sig.go b/tests/flows/governance/validator_set_sig.go similarity index 99% rename from tests/flows/validator_set_sig.go rename to tests/flows/governance/validator_set_sig.go index 1789b9bf1..a9685a966 100644 --- a/tests/flows/validator_set_sig.go +++ b/tests/flows/governance/validator_set_sig.go @@ -1,4 +1,4 @@ -package flows +package governance import ( "context" diff --git a/tests/flows/erc20_token_staking.go b/tests/flows/staking/erc20_token_staking.go similarity index 99% rename from tests/flows/erc20_token_staking.go rename to tests/flows/staking/erc20_token_staking.go index ba40a8073..22880ed47 100644 --- a/tests/flows/erc20_token_staking.go +++ b/tests/flows/staking/erc20_token_staking.go @@ -1,4 +1,4 @@ -package flows +package staking import ( "context" diff --git a/tests/flows/native_token_staking.go b/tests/flows/staking/native_token_staking.go similarity index 99% rename from tests/flows/native_token_staking.go rename to tests/flows/staking/native_token_staking.go index 74aa0fe34..aa3f40879 100644 --- a/tests/flows/native_token_staking.go +++ b/tests/flows/staking/native_token_staking.go @@ -1,4 +1,4 @@ -package flows +package staking import ( "context" diff --git a/tests/flows/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go similarity index 99% rename from tests/flows/poa_validator_manager.go rename to tests/flows/staking/poa_validator_manager.go index c693d0f2a..1f48e9f43 100644 --- a/tests/flows/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -1,4 +1,4 @@ -package flows +package staking import ( "context" diff --git a/tests/flows/add_fee_amount.go b/tests/flows/teleporter/add_fee_amount.go similarity index 99% rename from tests/flows/add_fee_amount.go rename to tests/flows/teleporter/add_fee_amount.go index 0771d450d..1a05e6e81 100644 --- a/tests/flows/add_fee_amount.go +++ b/tests/flows/teleporter/add_fee_amount.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/basic_send_receive.go b/tests/flows/teleporter/basic_send_receive.go similarity index 99% rename from tests/flows/basic_send_receive.go rename to tests/flows/teleporter/basic_send_receive.go index 8e4f8e036..fe31746c5 100644 --- a/tests/flows/basic_send_receive.go +++ b/tests/flows/teleporter/basic_send_receive.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/deliver_to_nonexistent_contract.go b/tests/flows/teleporter/deliver_to_nonexistent_contract.go similarity index 99% rename from tests/flows/deliver_to_nonexistent_contract.go rename to tests/flows/teleporter/deliver_to_nonexistent_contract.go index d5502b26e..ce54899bb 100644 --- a/tests/flows/deliver_to_nonexistent_contract.go +++ b/tests/flows/teleporter/deliver_to_nonexistent_contract.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/deliver_to_wrong_chain.go b/tests/flows/teleporter/deliver_to_wrong_chain.go similarity index 99% rename from tests/flows/deliver_to_wrong_chain.go rename to tests/flows/teleporter/deliver_to_wrong_chain.go index c0c406584..cbd83754c 100644 --- a/tests/flows/deliver_to_wrong_chain.go +++ b/tests/flows/teleporter/deliver_to_wrong_chain.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/insufficient_gas.go b/tests/flows/teleporter/insufficient_gas.go similarity index 99% rename from tests/flows/insufficient_gas.go rename to tests/flows/teleporter/insufficient_gas.go index bd5761f08..0ce3b1ca6 100644 --- a/tests/flows/insufficient_gas.go +++ b/tests/flows/teleporter/insufficient_gas.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/check_upgrade_access.go b/tests/flows/teleporter/registry/check_upgrade_access.go similarity index 95% rename from tests/flows/check_upgrade_access.go rename to tests/flows/teleporter/registry/check_upgrade_access.go index 023c47dd7..61f9b1683 100644 --- a/tests/flows/check_upgrade_access.go +++ b/tests/flows/teleporter/registry/check_upgrade_access.go @@ -1,13 +1,15 @@ -package flows +package registry import ( "context" "math/big" "github.com/ava-labs/subnet-evm/accounts/abi/bind" + "github.com/ava-labs/teleporter/tests/flows" "github.com/ava-labs/teleporter/tests/interfaces" "github.com/ava-labs/teleporter/tests/utils" "github.com/ethereum/go-ethereum/crypto" + . "github.com/onsi/gomega" ) @@ -53,7 +55,7 @@ func CheckUpgradeAccess(network interfaces.Network) { Expect(err).Should(BeNil()) _, err = testMessenger.PauseTeleporterAddress(nonOwnerOpts, teleporterAddress) Expect(err).ShouldNot(BeNil()) - Expect(err.Error()).Should(ContainSubstring(errTxReverted)) + Expect(err.Error()).Should(ContainSubstring(flows.ErrTxReverted)) // Check that the teleporter address is not paused, because previous call should have failed isPaused, err := testMessenger.IsTeleporterAddressPaused(&bind.CallOpts{}, teleporterAddress) @@ -84,7 +86,7 @@ func CheckUpgradeAccess(network interfaces.Network) { // Try to call unpauseTeleporterAddress from the previous owner account _, err = testMessenger.UnpauseTeleporterAddress(ownerOpts, teleporterAddress) Expect(err).ShouldNot(BeNil()) - Expect(err.Error()).Should(ContainSubstring(errTxReverted)) + Expect(err.Error()).Should(ContainSubstring(flows.ErrTxReverted)) // Make sure the teleporter address is still paused isPaused, err = testMessenger.IsTeleporterAddressPaused(&bind.CallOpts{}, teleporterAddress) diff --git a/tests/flows/pause_teleporter.go b/tests/flows/teleporter/registry/pause_teleporter.go similarity index 99% rename from tests/flows/pause_teleporter.go rename to tests/flows/teleporter/registry/pause_teleporter.go index 8cde4a3ad..41b44849d 100644 --- a/tests/flows/pause_teleporter.go +++ b/tests/flows/teleporter/registry/pause_teleporter.go @@ -1,4 +1,4 @@ -package flows +package registry import ( "context" diff --git a/tests/flows/teleporter_registry.go b/tests/flows/teleporter/registry/teleporter_registry.go similarity index 99% rename from tests/flows/teleporter_registry.go rename to tests/flows/teleporter/registry/teleporter_registry.go index da7bf91a9..d1d00d5d6 100644 --- a/tests/flows/teleporter_registry.go +++ b/tests/flows/teleporter/registry/teleporter_registry.go @@ -1,4 +1,4 @@ -package flows +package registry import ( "context" diff --git a/tests/flows/relay_message_twice.go b/tests/flows/teleporter/relay_message_twice.go similarity index 99% rename from tests/flows/relay_message_twice.go rename to tests/flows/teleporter/relay_message_twice.go index 3c91b7cd9..fec7100c4 100644 --- a/tests/flows/relay_message_twice.go +++ b/tests/flows/teleporter/relay_message_twice.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/relayer_modifies_message.go b/tests/flows/teleporter/relayer_modifies_message.go similarity index 99% rename from tests/flows/relayer_modifies_message.go rename to tests/flows/teleporter/relayer_modifies_message.go index a0999f6b1..4011ebc6f 100644 --- a/tests/flows/relayer_modifies_message.go +++ b/tests/flows/teleporter/relayer_modifies_message.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/resubmit_altered_message.go b/tests/flows/teleporter/resubmit_altered_message.go similarity index 99% rename from tests/flows/resubmit_altered_message.go rename to tests/flows/teleporter/resubmit_altered_message.go index 18435a9df..268c8b6cf 100644 --- a/tests/flows/resubmit_altered_message.go +++ b/tests/flows/teleporter/resubmit_altered_message.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/retry_successful_execution.go b/tests/flows/teleporter/retry_successful_execution.go similarity index 99% rename from tests/flows/retry_successful_execution.go rename to tests/flows/teleporter/retry_successful_execution.go index f9834bbc5..d75439e0f 100644 --- a/tests/flows/retry_successful_execution.go +++ b/tests/flows/teleporter/retry_successful_execution.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/send_specific_receipts.go b/tests/flows/teleporter/send_specific_receipts.go similarity index 99% rename from tests/flows/send_specific_receipts.go rename to tests/flows/teleporter/send_specific_receipts.go index 3e165a311..603074fe5 100644 --- a/tests/flows/send_specific_receipts.go +++ b/tests/flows/teleporter/send_specific_receipts.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "bytes" diff --git a/tests/flows/teleporter_message_ids.go b/tests/flows/teleporter/teleporter_message_ids.go similarity index 98% rename from tests/flows/teleporter_message_ids.go rename to tests/flows/teleporter/teleporter_message_ids.go index 1ae8285b3..f0005c8a1 100644 --- a/tests/flows/teleporter_message_ids.go +++ b/tests/flows/teleporter/teleporter_message_ids.go @@ -1,7 +1,7 @@ // (c) 2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package flows +package teleporter import ( "math/big" diff --git a/tests/flows/unallowed_relayer.go b/tests/flows/teleporter/unallowed_relayer.go similarity index 99% rename from tests/flows/unallowed_relayer.go rename to tests/flows/teleporter/unallowed_relayer.go index 155f55079..fe9ba6c1e 100644 --- a/tests/flows/unallowed_relayer.go +++ b/tests/flows/teleporter/unallowed_relayer.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/flows/validator_churn.go b/tests/flows/teleporter/validator_churn.go similarity index 99% rename from tests/flows/validator_churn.go rename to tests/flows/teleporter/validator_churn.go index 316c4c8b9..8de4a8c3a 100644 --- a/tests/flows/validator_churn.go +++ b/tests/flows/teleporter/validator_churn.go @@ -1,4 +1,4 @@ -package flows +package teleporter import ( "context" diff --git a/tests/local/e2e_test.go b/tests/local/e2e_test.go index 8b84c6955..673438546 100644 --- a/tests/local/e2e_test.go +++ b/tests/local/e2e_test.go @@ -7,7 +7,10 @@ import ( "os" "testing" - "github.com/ava-labs/teleporter/tests/flows" + "github.com/ava-labs/teleporter/tests/flows/governance" + "github.com/ava-labs/teleporter/tests/flows/staking" + "github.com/ava-labs/teleporter/tests/flows/teleporter" + "github.com/ava-labs/teleporter/tests/flows/teleporter/registry" deploymentUtils "github.com/ava-labs/teleporter/utils/deployment-utils" "github.com/ethereum/go-ethereum/log" "github.com/onsi/ginkgo/v2" @@ -22,7 +25,7 @@ const ( upgradabilityLabel = "upgradability" utilsLabel = "utils" validatorSetSigLabel = "ValidatorSetSig" - stakingManagerLabel = "StakingManager" + stakingManagerLabel = "ValidatorManager" ) var ( @@ -106,101 +109,107 @@ var _ = ginkgo.Describe("[Teleporter integration tests]", func() { ginkgo.It("Send a message from Subnet A to Subnet B, and one from B to A", ginkgo.Label(teleporterMessengerLabel), func() { - flows.BasicSendReceive(LocalNetworkInstance) + teleporter.BasicSendReceive(LocalNetworkInstance) }) ginkgo.It("Deliver to the wrong chain", ginkgo.Label(teleporterMessengerLabel), func() { - flows.DeliverToWrongChain(LocalNetworkInstance) + teleporter.DeliverToWrongChain(LocalNetworkInstance) }) ginkgo.It("Deliver to non-existent contract", ginkgo.Label(teleporterMessengerLabel), func() { - flows.DeliverToNonExistentContract(LocalNetworkInstance) + teleporter.DeliverToNonExistentContract(LocalNetworkInstance) }) ginkgo.It("Retry successful execution", ginkgo.Label(teleporterMessengerLabel), func() { - flows.RetrySuccessfulExecution(LocalNetworkInstance) + teleporter.RetrySuccessfulExecution(LocalNetworkInstance) }) ginkgo.It("Unallowed relayer", ginkgo.Label(teleporterMessengerLabel), func() { - flows.UnallowedRelayer(LocalNetworkInstance) + teleporter.UnallowedRelayer(LocalNetworkInstance) }) ginkgo.It("Relay message twice", ginkgo.Label(teleporterMessengerLabel), func() { - flows.RelayMessageTwice(LocalNetworkInstance) + teleporter.RelayMessageTwice(LocalNetworkInstance) }) ginkgo.It("Add additional fee amount", ginkgo.Label(teleporterMessengerLabel), func() { - flows.AddFeeAmount(LocalNetworkInstance) + teleporter.AddFeeAmount(LocalNetworkInstance) }) ginkgo.It("Send specific receipts", ginkgo.Label(teleporterMessengerLabel), func() { - flows.SendSpecificReceipts(LocalNetworkInstance) + teleporter.SendSpecificReceipts(LocalNetworkInstance) }) ginkgo.It("Insufficient gas", ginkgo.Label(teleporterMessengerLabel), func() { - flows.InsufficientGas(LocalNetworkInstance) + teleporter.InsufficientGas(LocalNetworkInstance) }) ginkgo.It("Resubmit altered message", ginkgo.Label(teleporterMessengerLabel), func() { - flows.ResubmitAlteredMessage(LocalNetworkInstance) - }) - ginkgo.It("Check upgrade access", - ginkgo.Label(upgradabilityLabel), - func() { - flows.CheckUpgradeAccess(LocalNetworkInstance) - }) - ginkgo.It("Pause and Unpause Teleporter", - ginkgo.Label(upgradabilityLabel), - func() { - flows.PauseTeleporter(LocalNetworkInstance) + teleporter.ResubmitAlteredMessage(LocalNetworkInstance) }) ginkgo.It("Calculate Teleporter message IDs", ginkgo.Label(utilsLabel), func() { - flows.CalculateMessageID(LocalNetworkInstance) + teleporter.CalculateMessageID(LocalNetworkInstance) }) - - // The following tests require special behavior by the relayer, so we only run them on a local network ginkgo.It("Relayer modifies message", ginkgo.Label(teleporterMessengerLabel), func() { - flows.RelayerModifiesMessage(LocalNetworkInstance) + teleporter.RelayerModifiesMessage(LocalNetworkInstance) + }) + ginkgo.It("Validator churn", + ginkgo.Label(teleporterMessengerLabel), + func() { + teleporter.ValidatorChurn(LocalNetworkInstance) }) + + // Teleporter Registry tests ginkgo.It("Teleporter registry", ginkgo.Label(upgradabilityLabel), func() { - flows.TeleporterRegistry(LocalNetworkInstance) + registry.TeleporterRegistry(LocalNetworkInstance) }) - ginkgo.It("Deliver ValidatorSetSig signed message", - ginkgo.Label(validatorSetSigLabel), + ginkgo.It("Check upgrade access", + ginkgo.Label(upgradabilityLabel), func() { - flows.ValidatorSetSig(LocalNetworkInstance) + registry.CheckUpgradeAccess(LocalNetworkInstance) }) - ginkgo.It("Validator churn", - ginkgo.Label(teleporterMessengerLabel), + ginkgo.It("Pause and Unpause Teleporter", + ginkgo.Label(upgradabilityLabel), func() { - flows.ValidatorChurn(LocalNetworkInstance) + registry.PauseTeleporter(LocalNetworkInstance) }) + + // Governance tests + ginkgo.It("Deliver ValidatorSetSig signed message", + ginkgo.Label(validatorSetSigLabel), + func() { + governance.ValidatorSetSig(LocalNetworkInstance) + }) + + // Staking tests ginkgo.It("Native token staking manager", ginkgo.Label(stakingManagerLabel), func() { - flows.NativeTokenStakingManager(LocalNetworkInstance) + staking.NativeTokenStakingManager(LocalNetworkInstance) }) ginkgo.It("ERC20 token staking manager", ginkgo.Label(stakingManagerLabel), func() { - flows.ERC20TokenStakingManager(LocalNetworkInstance) + staking.ERC20TokenStakingManager(LocalNetworkInstance) + }) + ginkgo.It("PoA validator manager", + ginkgo.Label(stakingManagerLabel), + func() { + staking.PoAValidatorManager(LocalNetworkInstance) }) - // Since the validator churn test modifies the network topology, we put it last for now. - // It should not affect the other tests, but we get some errors if we run it before the other tests. - // TODO: we should fix this so that the order of the tests does not matter. }) diff --git a/tests/testnet/main/run_testnet_flows.go b/tests/testnet/main/run_testnet_flows.go index 440a02711..5721537e1 100644 --- a/tests/testnet/main/run_testnet_flows.go +++ b/tests/testnet/main/run_testnet_flows.go @@ -3,7 +3,9 @@ package main import ( "github.com/ethereum/go-ethereum/log" - "github.com/ava-labs/teleporter/tests/flows" + "github.com/ava-labs/teleporter/tests/flows/teleporter" + "github.com/ava-labs/teleporter/tests/flows/teleporter/registry" + "github.com/ava-labs/teleporter/tests/interfaces" "github.com/ava-labs/teleporter/tests/testnet" "github.com/onsi/gomega" @@ -34,19 +36,19 @@ func main() { // - UnallowedRelayer // - ValidatorSetChrun // - TeleporterRegistry - runFlow("AddFeeAmount", flows.AddFeeAmount, network) - runFlow("BasicSendRecevie", flows.BasicSendReceive, network) - runFlow("DeliverToNonExistentContract", flows.DeliverToNonExistentContract, network) - runFlow("DeliverToWrongChain", flows.DeliverToWrongChain, network) - runFlow("InsufficientGas", flows.InsufficientGas, network) - runFlow("RelayMessageTwice", flows.RelayMessageTwice, network) - runFlow("ResubmitAlteredMessage", flows.ResubmitAlteredMessage, network) - runFlow("RetrySuccessfulExecution", flows.RetrySuccessfulExecution, network) - runFlow("SendSpecificReceipts", flows.SendSpecificReceipts, network) + runFlow("AddFeeAmount", teleporter.AddFeeAmount, network) + runFlow("BasicSendRecevie", teleporter.BasicSendReceive, network) + runFlow("DeliverToNonExistentContract", teleporter.DeliverToNonExistentContract, network) + runFlow("DeliverToWrongChain", teleporter.DeliverToWrongChain, network) + runFlow("InsufficientGas", teleporter.InsufficientGas, network) + runFlow("RelayMessageTwice", teleporter.RelayMessageTwice, network) + runFlow("ResubmitAlteredMessage", teleporter.ResubmitAlteredMessage, network) + runFlow("RetrySuccessfulExecution", teleporter.RetrySuccessfulExecution, network) + runFlow("SendSpecificReceipts", teleporter.SendSpecificReceipts, network) log.Info("Finished Teleporter test flows") // Run the upgradability test flows - runFlow("CheckUpgradeAccess", flows.CheckUpgradeAccess, network) - runFlow("PauseTeleporter", flows.PauseTeleporter, network) + runFlow("CheckUpgradeAccess", registry.CheckUpgradeAccess, network) + runFlow("PauseTeleporter", registry.PauseTeleporter, network) log.Info("Finished upgradability test flows") } From 7587e3a2bba55bea960cbc313ae0328bdefb2ed3 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 10:44:20 -0400 Subject: [PATCH 03/10] fix poa e2e --- tests/flows/staking/poa_validator_manager.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 1f48e9f43..701a22711 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -146,8 +146,17 @@ func PoAValidatorManager(network interfaces.LocalNetwork) { // Delist the validator // { + // Try with invalid validator owner + opts, err := bind.NewKeyedTransactorWithChainID(fundedKey, subnetAInfo.EVMChainID) + Expect(err).Should(BeNil()) + _, err = validatorManager.InitializeEndValidation( + opts, + validationID, + ) + + Expect(err).ShouldNot(BeNil()) receipt := utils.InitializeEndPoAValidation( - fundedKey, + ownerKey, subnetAInfo, validatorManager, validationID, From c4d89612f9468a851db067307190a4f4a2a4e9ca Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 11:02:36 -0400 Subject: [PATCH 04/10] fix owner key --- tests/flows/staking/poa_validator_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 701a22711..09e52fe80 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -189,7 +189,7 @@ func PoAValidatorManager(network interfaces.LocalNetwork) { // Deliver the Warp message to the subnet receipt = utils.CompleteEndPoAValidation( - fundedKey, + ownerKey, subnetAInfo, validatorManagerAddress, registrationSignedMessage, From f5e04482fcb8cff29491a9afcac9e7096b90dfcb Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Wed, 21 Aug 2024 14:33:10 -0400 Subject: [PATCH 05/10] Update tests/flows/staking/poa_validator_manager.go Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- tests/flows/staking/poa_validator_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 09e52fe80..62c5183cc 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -153,8 +153,8 @@ func PoAValidatorManager(network interfaces.LocalNetwork) { opts, validationID, ) - Expect(err).ShouldNot(BeNil()) + receipt := utils.InitializeEndPoAValidation( ownerKey, subnetAInfo, From b3884583170b79437552d85ada2ad59d4c61dff4 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Wed, 21 Aug 2024 14:33:17 -0400 Subject: [PATCH 06/10] Update tests/flows/staking/poa_validator_manager.go Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- tests/flows/staking/poa_validator_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 62c5183cc..4ebf95861 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -54,7 +54,7 @@ func PoAValidatorManager(network interfaces.LocalNetwork) { Expect(err).Should(BeNil()) ownerAddress := crypto.PubkeyToAddress(ownerKey.PublicKey) - // Transfer native assets to the non owner account + // Transfer native assets to the owner account ctx := context.Background() fundAmount := big.NewInt(1e18) // 1avax utils.SendNativeTransfer( From 3dff40e23217e55055af67fdaa8e3e5aee6df313 Mon Sep 17 00:00:00 2001 From: minghinmatthewlam Date: Wed, 21 Aug 2024 14:33:27 -0400 Subject: [PATCH 07/10] Update tests/flows/staking/poa_validator_manager.go Co-authored-by: cam-schultz <78878559+cam-schultz@users.noreply.github.com> Signed-off-by: minghinmatthewlam --- tests/flows/staking/poa_validator_manager.go | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 4ebf95861..524d5b270 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -16,24 +16,24 @@ import ( ) /* -* Register a PoA validator manager on a L1. The steps are as follows: -* - Generate random address to be the owner address -* - Fund native assets to the owner address -* - Deploy the PoAValidatorManager contract -* - Attempt to initiate with non owner and check that it fails -* - Initiate validator registration -* - Deliver the Warp message to the P-Chain (not implemented) -* - Aggregate P-Chain signatures on the response Warp message -* - Deliver the Warp message to the L1 -* - Verify that the validator is registered in the validator manager contract - -* Delists the validator from the L1. The steps are as follows: -* - Attempt to initiate with non owner and check that it fails -* - Initiate validator delisting -* - Deliver the Warp message to the P-Chain (not implemented) -* - Aggregate P-Chain signatures on the response Warp message -* - Deliver the Warp message to the L1 -* - Verify that the validator is delisted from the validator manager contract + * Register a PoA validator manager on a L1. The steps are as follows: + * - Generate random address to be the owner address + * - Fund native assets to the owner address + * - Deploy the PoAValidatorManager contract + * - Attempt to initiate with non owner and check that it fails + * - Initiate validator registration + * - Deliver the Warp message to the P-Chain (not implemented) + * - Aggregate P-Chain signatures on the response Warp message + * - Deliver the Warp message to the L1 + * - Verify that the validator is registered in the validator manager contract + + * Delists the validator from the L1. The steps are as follows: + * - Attempt to initiate with non owner and check that it fails + * - Initiate validator delisting + * - Deliver the Warp message to the P-Chain (not implemented) + * - Aggregate P-Chain signatures on the response Warp message + * - Deliver the Warp message to the L1 + * - Verify that the validator is delisted from the validator manager contract */ func PoAValidatorManager(network interfaces.LocalNetwork) { cChainInfo := network.GetPrimaryNetworkInfo() From 24ebdbeb58c86315f66694e641d3eac181a7f551 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 14:34:18 -0400 Subject: [PATCH 08/10] rename label --- tests/local/e2e_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/local/e2e_test.go b/tests/local/e2e_test.go index 673438546..2d5a8c90e 100644 --- a/tests/local/e2e_test.go +++ b/tests/local/e2e_test.go @@ -25,7 +25,7 @@ const ( upgradabilityLabel = "upgradability" utilsLabel = "utils" validatorSetSigLabel = "ValidatorSetSig" - stakingManagerLabel = "ValidatorManager" + validatorManagerLabel = "ValidatorManager" ) var ( @@ -198,17 +198,17 @@ var _ = ginkgo.Describe("[Teleporter integration tests]", func() { // Staking tests ginkgo.It("Native token staking manager", - ginkgo.Label(stakingManagerLabel), + ginkgo.Label(validatorManagerLabel), func() { staking.NativeTokenStakingManager(LocalNetworkInstance) }) ginkgo.It("ERC20 token staking manager", - ginkgo.Label(stakingManagerLabel), + ginkgo.Label(validatorManagerLabel), func() { staking.ERC20TokenStakingManager(LocalNetworkInstance) }) ginkgo.It("PoA validator manager", - ginkgo.Label(stakingManagerLabel), + ginkgo.Label(validatorManagerLabel), func() { staking.PoAValidatorManager(LocalNetworkInstance) }) From 0e22e7994bedf99a241484200409a222f9eee011 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 14:42:06 -0400 Subject: [PATCH 09/10] fix lint comments --- tests/flows/staking/poa_validator_manager.go | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 524d5b270..3f9006e3f 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -16,24 +16,24 @@ import ( ) /* - * Register a PoA validator manager on a L1. The steps are as follows: - * - Generate random address to be the owner address - * - Fund native assets to the owner address - * - Deploy the PoAValidatorManager contract - * - Attempt to initiate with non owner and check that it fails - * - Initiate validator registration - * - Deliver the Warp message to the P-Chain (not implemented) - * - Aggregate P-Chain signatures on the response Warp message - * - Deliver the Warp message to the L1 - * - Verify that the validator is registered in the validator manager contract - - * Delists the validator from the L1. The steps are as follows: - * - Attempt to initiate with non owner and check that it fails - * - Initiate validator delisting - * - Deliver the Warp message to the P-Chain (not implemented) - * - Aggregate P-Chain signatures on the response Warp message - * - Deliver the Warp message to the L1 - * - Verify that the validator is delisted from the validator manager contract +* Register a PoA validator manager on a L1. The steps are as follows: +* - Generate random address to be the owner address +* - Fund native assets to the owner address +* - Deploy the PoAValidatorManager contract +* - Attempt to initiate with non owner and check that it fails +* - Initiate validator registration +* - Deliver the Warp message to the P-Chain (not implemented) +* - Aggregate P-Chain signatures on the response Warp message +* - Deliver the Warp message to the L1 +* - Verify that the validator is registered in the validator manager contract + +* Delists the validator from the L1. The steps are as follows: +* - Attempt to initiate with non owner and check that it fails +* - Initiate validator delisting +* - Deliver the Warp message to the P-Chain (not implemented) +* - Aggregate P-Chain signatures on the response Warp message +* - Deliver the Warp message to the L1 +* - Verify that the validator is delisted from the validator manager contract */ func PoAValidatorManager(network interfaces.LocalNetwork) { cChainInfo := network.GetPrimaryNetworkInfo() @@ -154,7 +154,7 @@ func PoAValidatorManager(network interfaces.LocalNetwork) { validationID, ) Expect(err).ShouldNot(BeNil()) - + receipt := utils.InitializeEndPoAValidation( ownerKey, subnetAInfo, From 598cef4266f97fabe510be6ae5e299e52501e140 Mon Sep 17 00:00:00 2001 From: Matthew Lam Date: Wed, 21 Aug 2024 14:43:24 -0400 Subject: [PATCH 10/10] fix lint again --- tests/flows/staking/poa_validator_manager.go | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/flows/staking/poa_validator_manager.go b/tests/flows/staking/poa_validator_manager.go index 3f9006e3f..ec9b5fe93 100644 --- a/tests/flows/staking/poa_validator_manager.go +++ b/tests/flows/staking/poa_validator_manager.go @@ -16,24 +16,24 @@ import ( ) /* -* Register a PoA validator manager on a L1. The steps are as follows: -* - Generate random address to be the owner address -* - Fund native assets to the owner address -* - Deploy the PoAValidatorManager contract -* - Attempt to initiate with non owner and check that it fails -* - Initiate validator registration -* - Deliver the Warp message to the P-Chain (not implemented) -* - Aggregate P-Chain signatures on the response Warp message -* - Deliver the Warp message to the L1 -* - Verify that the validator is registered in the validator manager contract - -* Delists the validator from the L1. The steps are as follows: -* - Attempt to initiate with non owner and check that it fails -* - Initiate validator delisting -* - Deliver the Warp message to the P-Chain (not implemented) -* - Aggregate P-Chain signatures on the response Warp message -* - Deliver the Warp message to the L1 -* - Verify that the validator is delisted from the validator manager contract + * Register a PoA validator manager on a L1. The steps are as follows: + * - Generate random address to be the owner address + * - Fund native assets to the owner address + * - Deploy the PoAValidatorManager contract + * - Attempt to initiate with non owner and check that it fails + * - Initiate validator registration + * - Deliver the Warp message to the P-Chain (not implemented) + * - Aggregate P-Chain signatures on the response Warp message + * - Deliver the Warp message to the L1 + * - Verify that the validator is registered in the validator manager contract + * + * Delists the validator from the L1. The steps are as follows: + * - Attempt to initiate with non owner and check that it fails + * - Initiate validator delisting + * - Deliver the Warp message to the P-Chain (not implemented) + * - Aggregate P-Chain signatures on the response Warp message + * - Deliver the Warp message to the L1 + * - Verify that the validator is delisted from the validator manager contract */ func PoAValidatorManager(network interfaces.LocalNetwork) { cChainInfo := network.GetPrimaryNetworkInfo()