diff --git a/AUTONITY_VERSION b/AUTONITY_VERSION index fbf0603..1b0443f 100644 --- a/AUTONITY_VERSION +++ b/AUTONITY_VERSION @@ -1 +1 @@ -b0e1080d6fce220c9b3daefb57a35835d194695a +v1.1.0-internal diff --git a/Makefile b/Makefile index 1846bec..baf811c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ SRCDIR := $(AUTONITY)/autonity/solidity/contracts OUTDIR := autonity/contracts abigen = hatch run generate:pyabigen \ - --version $(VERSION) \ --src $(word 1,$(1)) \ --devdoc $(word 2,$(1)) \ --userdoc $(word 3,$(1)) \ @@ -36,13 +35,14 @@ $(OUTDIR)/auctioneer.py: $(call gentargets,Auctioneer) $(call abigen,$^) --exclude paidInterest,setOperator,setOracle,setStabilization >$@ $(OUTDIR)/autonity.py: $(call gentargets,Autonity) - $(call abigen,$^) --exclude autobond,computeCommittee,finalize,finalizeInitialization,jail,jailbound,slash,slashAndJail >$@ + $(call abigen,$^) --version $(VERSION) \ + --exclude autobond,computeCommittee,finalize,finalizeInitialization,jail,jailbound,slash,slashAndJail >$@ $(OUTDIR)/inflation_controller.py: $(call gentargets,InflationController) $(call abigen,$^) >$@ $(OUTDIR)/liquid_logic.py: $(call gentargets,LiquidLogic) - $(call abigen,$^) --exclude burn,lock,mint,redistribute,setCommissionRate,unlock >$@ + $(call abigen,$^) --exclude burn,lock,lockFrom,mint,redistribute,setCommissionRate,unlock >$@ $(OUTDIR)/omission_accountability.py: $(call gentargets,OmissionAccountability) $(call abigen,$^) --exclude distributeProposerRewards,finalize,setCommittee,setEpochBlock,setOperator >$@ diff --git a/autonity/contracts/accountability.py b/autonity/contracts/accountability.py index 3e8f34c..48b1ce4 100644 --- a/autonity/contracts/accountability.py +++ b/autonity/contracts/accountability.py @@ -11,8 +11,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - class Rule(enum.IntEnum): """Port of `enum Rule` on the IAccountability contract.""" diff --git a/autonity/contracts/acu.py b/autonity/contracts/acu.py index ee759a4..36fc27b 100644 --- a/autonity/contracts/acu.py +++ b/autonity/contracts/acu.py @@ -8,8 +8,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - class ACU: """ACU contract binding. diff --git a/autonity/contracts/auctioneer.py b/autonity/contracts/auctioneer.py index 8b79ac9..bd476c4 100644 --- a/autonity/contracts/auctioneer.py +++ b/autonity/contracts/auctioneer.py @@ -9,8 +9,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - @dataclass class Config: diff --git a/autonity/contracts/autonity.py b/autonity/contracts/autonity.py index c06393e..3d4ffba 100644 --- a/autonity/contracts/autonity.py +++ b/autonity/contracts/autonity.py @@ -11,7 +11,7 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" +__version__ = "v1.1.0-internal" class ValidatorState(enum.IntEnum): @@ -95,6 +95,7 @@ class Protocol: max_schedule_duration: int gas_limit: int gas_limit_bound_divisor: int + clustering_threshold: int @dataclass @@ -143,6 +144,7 @@ class ClientAwareConfig: epoch_period: int block_period: int gas_limit: int + clustering_threshold: int accountability: Accountability eip1559: Eip1559 @@ -229,6 +231,15 @@ def Approval(self) -> contract.ContractEvent: """Binding for `event Approval` on the Autonity contract.""" return self._contract.events.Approval + @property + def BondingApproval(self) -> contract.ContractEvent: + """Binding for `event BondingApproval` on the Autonity contract. + + Emitted when the bonding-allowance (NTN) of a `_caller` for an `_owner` is set + by a call to `approveBonding`. `_value` is the new `bondingAllowance` (NTN). + """ + return self._contract.events.BondingApproval + @property def BondingRejected(self) -> contract.ContractEvent: """Binding for `event BondingRejected` on the Autonity contract. @@ -479,6 +490,32 @@ def approve( amount, ) + def approve_bonding( + self, + _caller: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `approveBonding` on the Autonity contract. + + Sets `_amount` as the bonding-allowance (NTN) of `_caller` over the caller's + tokens. Returns a boolean value indicating whether the operation succeeded. + Emits an {BondingApproval} event. + + Parameters + ---------- + _caller : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.approveBonding( + _caller, + _amount, + ) + def balance_of( self, _addr: eth_typing.ChecksumAddress, @@ -507,10 +544,7 @@ def bond( ) -> contract.ContractFunction: """Binding for `bond` on the Autonity contract. - Create a bonding(delegation) request with the caller as delegator. In case the - caller is a contract, it needs to send some gas so autonity can notify the - caller about staking operations. In case autonity fails to notify the caller - (contract), the applied request is reverted. + Create a bonding(delegation) request with the caller as delegator. Parameters ---------- @@ -529,6 +563,62 @@ def bond( _amount, ) + def bond_from( + self, + _account: eth_typing.ChecksumAddress, + _validator: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `bondFrom` on the Autonity contract. + + Create a bonding(delegation) request with the `_account` as delegator. The + caller needs to have required bonding-allowance (NTN) from the `_account`. + + Parameters + ---------- + _account : eth_typing.ChecksumAddress + address of the delegator. + _validator : eth_typing.ChecksumAddress + address of the validator to delegate stake to. + _amount : int + total amount of NTN to bond. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.bondFrom( + _account, + _validator, + _amount, + ) + + def bonding_allowance( + self, + _owner: eth_typing.ChecksumAddress, + _caller: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `bondingAllowance` on the Autonity contract. + + Returns the remaining number of NTN that `_caller` will be allowed to bond on + behalf of `_owner` through `bondFrom`. This is zero by default. + + Parameters + ---------- + _owner : eth_typing.ChecksumAddress + _caller : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.bondingAllowance( + _owner, + _caller, + ).call() + return int(return_value) + def burn( self, _addr: eth_typing.ChecksumAddress, @@ -710,16 +800,17 @@ def get_client_config( int(return_value[0]), int(return_value[1]), int(return_value[2]), + int(return_value[3]), Accountability( - int(return_value[3][0]), - int(return_value[3][1]), - int(return_value[3][2]), - ), - Eip1559( int(return_value[4][0]), int(return_value[4][1]), int(return_value[4][2]), - int(return_value[4][3]), + ), + Eip1559( + int(return_value[5][0]), + int(return_value[5][1]), + int(return_value[5][2]), + int(return_value[5][3]), ), ) @@ -804,6 +895,7 @@ def get_config( int(return_value[2][4]), int(return_value[2][5]), int(return_value[2][6]), + int(return_value[2][7]), ), int(return_value[3]), ) @@ -1577,6 +1669,25 @@ def set_auctioneer_contract( _address, ) + def set_clustering_threshold( + self, + _threshold: int, + ) -> contract.ContractFunction: + """Binding for `setClusteringThreshold` on the Autonity contract. + + Parameters + ---------- + _threshold : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.setClusteringThreshold( + _threshold, + ) + def set_committee_size( self, _size: int, @@ -2087,10 +2198,7 @@ def unbond( ) -> contract.ContractFunction: """Binding for `unbond` on the Autonity contract. - Create an unbonding request with the caller as delegator. In case the caller is - a contract, it needs to send some gas so autonity can notify the caller about - staking operations. In case autonity fails to notify the caller (contract), the - applied request is reverted. + Create an unbonding request with the caller as delegator. Parameters ---------- @@ -2109,6 +2217,37 @@ def unbond( _amount, ) + def unbond_from( + self, + _account: eth_typing.ChecksumAddress, + _validator: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `unbondFrom` on the Autonity contract. + + Create an unbonding request with the `_account` as delegator. The caller needs + to have required unbonding-allowance to unbond LNTN from the `_account`. + + Parameters + ---------- + _account : eth_typing.ChecksumAddress + address of the delegator. + _validator : eth_typing.ChecksumAddress + address of the validator to unbond stake to. + _amount : int + total amount of LNTN (or NTN if self delegated) to unbond. + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.unbondFrom( + _account, + _validator, + _amount, + ) + def update_enode( self, _node_address: eth_typing.ChecksumAddress, @@ -2428,6 +2567,11 @@ def upgrade_contract( "name": "gasLimitBoundDivisor", "type": "uint256", }, + { + "internalType": "uint256", + "name": "clusteringThreshold", + "type": "uint256", + }, ], "internalType": "struct IAutonity.Protocol", "name": "protocol", @@ -2497,6 +2641,31 @@ def upgrade_contract( "name": "Approval", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_owner", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "_caller", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_value", + "type": "uint256", + }, + ], + "name": "BondingApproval", + "type": "event", + }, { "anonymous": False, "inputs": [ @@ -2856,6 +3025,12 @@ def upgrade_contract( "name": "delegator", "type": "address", }, + { + "indexed": True, + "internalType": "address", + "name": "caller", + "type": "address", + }, { "indexed": False, "internalType": "bool", @@ -2949,6 +3124,12 @@ def upgrade_contract( "name": "delegator", "type": "address", }, + { + "indexed": True, + "internalType": "address", + "name": "caller", + "type": "address", + }, { "indexed": False, "internalType": "bool", @@ -3139,6 +3320,16 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_caller", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "approveBonding", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_validator", "type": "address"}, @@ -3167,6 +3358,27 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "bondFrom", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "nonpayable", + "type": "function", + }, + { + "inputs": [ + {"internalType": "address", "name": "_owner", "type": "address"}, + {"internalType": "address", "name": "_caller", "type": "address"}, + ], + "name": "bondingAllowance", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_addr", "type": "address"}, @@ -3333,6 +3545,11 @@ def upgrade_contract( "name": "gasLimit", "type": "uint256", }, + { + "internalType": "uint256", + "name": "clusteringThreshold", + "type": "uint256", + }, { "components": [ { @@ -3468,6 +3685,11 @@ def upgrade_contract( "name": "gasLimit", "type": "uint256", }, + { + "internalType": "uint256", + "name": "clusteringThreshold", + "type": "uint256", + }, { "components": [ { @@ -3721,6 +3943,11 @@ def upgrade_contract( "name": "gasLimitBoundDivisor", "type": "uint256", }, + { + "internalType": "uint256", + "name": "clusteringThreshold", + "type": "uint256", + }, ], "internalType": "struct IAutonity.Protocol", "name": "protocol", @@ -4422,6 +4649,15 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "uint256", "name": "_threshold", "type": "uint256"} + ], + "name": "setClusteringThreshold", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [{"internalType": "uint256", "name": "_size", "type": "uint256"}], "name": "setCommitteeSize", @@ -4761,6 +4997,17 @@ def upgrade_contract( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "address", "name": "_validator", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "unbondFrom", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_nodeAddress", "type": "address"}, diff --git a/autonity/contracts/inflation_controller.py b/autonity/contracts/inflation_controller.py index 6414cb6..6de480a 100644 --- a/autonity/contracts/inflation_controller.py +++ b/autonity/contracts/inflation_controller.py @@ -9,8 +9,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - @dataclass class Params: diff --git a/autonity/contracts/liquid_logic.py b/autonity/contracts/liquid_logic.py index f73bdb0..bda10ea 100644 --- a/autonity/contracts/liquid_logic.py +++ b/autonity/contracts/liquid_logic.py @@ -8,8 +8,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - class LiquidLogic: """LiquidLogic contract binding. @@ -43,6 +41,15 @@ def Transfer(self) -> contract.ContractEvent: """Binding for `event Transfer` on the LiquidLogic contract.""" return self._contract.events.Transfer + @property + def UnbondingApproval(self) -> contract.ContractEvent: + """Binding for `event UnbondingApproval` on the LiquidLogic contract. + + Emitted when the unbond-allowance (LNTN) of a `_caller` for an `_owner` is set + by a call to `approveUnbonding`. `_value` is the new unbond-allowance (LNTN). + """ + return self._contract.events.UnbondingApproval + def commission_rate_decimals( self, ) -> int: @@ -137,6 +144,32 @@ def approve( _amount, ) + def approve_unbonding( + self, + _caller: eth_typing.ChecksumAddress, + _amount: int, + ) -> contract.ContractFunction: + """Binding for `approveUnbonding` on the LiquidLogic contract. + + Sets `_amount` as the unbond-allowance (LNTN) of `_caller` over the caller's + tokens. Returns a boolean value indicating whether the operation succeeded. + Emits an {UnbondingApproval} event. + + Parameters + ---------- + _caller : eth_typing.ChecksumAddress + _amount : int + + Returns + ------- + web3.contract.contract.ContractFunction + A contract function instance to be sent in a transaction. + """ + return self._contract.functions.approveUnbonding( + _caller, + _amount, + ) + def balance_of( self, _delegator: eth_typing.ChecksumAddress, @@ -368,6 +401,31 @@ def transfer_from( _amount, ) + def unbonding_allowance( + self, + _owner: eth_typing.ChecksumAddress, + _caller: eth_typing.ChecksumAddress, + ) -> int: + """Binding for `unbondingAllowance` on the LiquidLogic contract. + + Returns the remaining number of LNTN that `_caller` will be allowed to unbond on + behalf of `_owner` through `unbondFrom`. This is zero by default. + + Parameters + ---------- + _owner : eth_typing.ChecksumAddress + _caller : eth_typing.ChecksumAddress + + Returns + ------- + int + """ + return_value = self._contract.functions.unbondingAllowance( + _owner, + _caller, + ).call() + return int(return_value) + def unclaimed_rewards( self, _account: eth_typing.ChecksumAddress, @@ -466,6 +524,31 @@ def unlocked_balance_of( "name": "Transfer", "type": "event", }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "_owner", + "type": "address", + }, + { + "indexed": True, + "internalType": "address", + "name": "_caller", + "type": "address", + }, + { + "indexed": False, + "internalType": "uint256", + "name": "_value", + "type": "uint256", + }, + ], + "name": "UnbondingApproval", + "type": "event", + }, {"stateMutability": "payable", "type": "fallback"}, { "inputs": [], @@ -515,6 +598,16 @@ def unlocked_balance_of( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_caller", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "approveUnbonding", + "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_delegator", "type": "address"} @@ -593,6 +686,17 @@ def unlocked_balance_of( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_account", "type": "address"}, + {"internalType": "address", "name": "_caller", "type": "address"}, + {"internalType": "uint256", "name": "_amount", "type": "uint256"}, + ], + "name": "lockFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_delegator", "type": "address"} @@ -670,6 +774,16 @@ def unlocked_balance_of( "stateMutability": "nonpayable", "type": "function", }, + { + "inputs": [ + {"internalType": "address", "name": "_owner", "type": "address"}, + {"internalType": "address", "name": "_caller", "type": "address"}, + ], + "name": "unbondingAllowance", + "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], + "stateMutability": "view", + "type": "function", + }, { "inputs": [ {"internalType": "address", "name": "_account", "type": "address"} diff --git a/autonity/contracts/omission_accountability.py b/autonity/contracts/omission_accountability.py index 817c6f9..c62c1f4 100644 --- a/autonity/contracts/omission_accountability.py +++ b/autonity/contracts/omission_accountability.py @@ -9,8 +9,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - @dataclass class Config: diff --git a/autonity/contracts/oracle.py b/autonity/contracts/oracle.py index 25b2260..6f4f2b5 100644 --- a/autonity/contracts/oracle.py +++ b/autonity/contracts/oracle.py @@ -9,8 +9,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - @dataclass class Config: diff --git a/autonity/contracts/stabilization.py b/autonity/contracts/stabilization.py index 0cc1e7b..98f6788 100644 --- a/autonity/contracts/stabilization.py +++ b/autonity/contracts/stabilization.py @@ -9,8 +9,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - @dataclass class Config: diff --git a/autonity/contracts/supply_control.py b/autonity/contracts/supply_control.py index e6691f4..266d4ed 100644 --- a/autonity/contracts/supply_control.py +++ b/autonity/contracts/supply_control.py @@ -8,8 +8,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - class SupplyControl: """SupplyControl contract binding. diff --git a/autonity/contracts/upgrade_manager.py b/autonity/contracts/upgrade_manager.py index 93c246f..7b0127d 100644 --- a/autonity/contracts/upgrade_manager.py +++ b/autonity/contracts/upgrade_manager.py @@ -8,8 +8,6 @@ import web3 from web3.contract import contract -__version__ = "b0e1080d6fce220c9b3daefb57a35835d194695a" - class UpgradeManager: """UpgradeManager contract binding. diff --git a/pyproject.toml b/pyproject.toml index 05dbfc0..5397dd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" license = "MIT" keywords = ["autonity", "web3", "rpc", "client", "library"] dynamic = ["version"] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = ["web3==7.6.0", "plum-dispatch==2.5.4", "semver==3.0.2"] classifiers = [ "Development Status :: 4 - Beta",