Skip to content

Commit f8e7ca8

Browse files
committed
Remove exclusions from Makefile because they will come from NatSpec docs
The functions to be excluded with be tagged with the @Custom:exclude natspec tag, which are handled by pyabigen.
1 parent 76579d8 commit f8e7ca8

File tree

8 files changed

+470
-38
lines changed

8 files changed

+470
-38
lines changed

Makefile

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,40 @@ VERSION := $(shell cat AUTONITY_VERSION)
22
AUTONITY := build/autonity
33
ABIDIR := $(AUTONITY)/params/generated
44
OUTDIR := autonity/contracts
5-
ABIGEN = hatch run generate:pyabigen \
6-
--srcdir $(AUTONITY)/autonity/solidity/contracts \
7-
--version $(VERSION) \
8-
--userdoc $(word 2,$(1)) \
9-
--devdoc $(word 3,$(1)) \
10-
$(word 1,$(1))
115

12-
all: $(OUTDIR)/accountability.py \
13-
$(OUTDIR)/acu.py \
14-
$(OUTDIR)/autonity.py \
15-
$(OUTDIR)/ierc20.py \
16-
$(OUTDIR)/inflation_controller.py \
17-
$(OUTDIR)/liquid.py \
18-
$(OUTDIR)/non_stakable_vesting.py \
19-
$(OUTDIR)/oracle.py \
20-
$(OUTDIR)/stabilization.py \
21-
$(OUTDIR)/supply_control.py \
22-
$(OUTDIR)/upgrade_manager.py
6+
BINDINGS := $(OUTDIR)/accountability.py \
7+
$(OUTDIR)/acu.py \
8+
$(OUTDIR)/autonity.py \
9+
$(OUTDIR)/ierc20.py \
10+
$(OUTDIR)/inflation_controller.py \
11+
$(OUTDIR)/liquid.py \
12+
$(OUTDIR)/non_stakable_vesting.py \
13+
$(OUTDIR)/oracle.py \
14+
$(OUTDIR)/stabilization.py \
15+
$(OUTDIR)/supply_control.py \
16+
$(OUTDIR)/upgrade_manager.py
2317

24-
$(OUTDIR)/accountability.py: $(addprefix $(ABIDIR)/Accountability,.abi .docuser .docdev)
25-
$(call ABIGEN,$^) --exclude distributeRewards,finalize,setEpochPeriod >$@
18+
all: $(BINDINGS)
2619

20+
$(OUTDIR)/accountability.py: $(addprefix $(ABIDIR)/Accountability,.abi .docuser .docdev)
2721
$(OUTDIR)/acu.py: $(addprefix $(ABIDIR)/ACU,.abi .docuser .docdev)
28-
$(call ABIGEN,$^) --exclude setOperator,setOracle,update >$@
29-
3022
$(OUTDIR)/autonity.py: $(addprefix $(ABIDIR)/Autonity,.abi .docuser .docdev)
31-
$(call ABIGEN,$^) --exclude computeCommittee,finalize,finalizeInitialization >$@
32-
3323
$(OUTDIR)/ierc20.py: $(addprefix $(ABIDIR)/IERC20,.abi .docuser .docdev)
34-
$(call ABIGEN,$^) >$@
35-
3624
$(OUTDIR)/inflation_controller.py: $(addprefix $(ABIDIR)/InflationController,.abi .docuser .docdev)
37-
$(call ABIGEN,$^) >$@
38-
3925
$(OUTDIR)/liquid.py: $(addprefix $(ABIDIR)/Liquid,.abi .docuser .docdev)
40-
$(call ABIGEN,$^) --exclude burn,lock,mint,redistribute,setCommissionRate,unlock >$@
41-
4226
$(OUTDIR)/non_stakable_vesting.py: $(addprefix $(ABIDIR)/NonStakableVesting,.abi .docuser .docdev)
43-
$(call ABIGEN,$^) --exclude unlockTokens >$@
44-
4527
$(OUTDIR)/oracle.py: $(addprefix $(ABIDIR)/Oracle,.abi .docuser .docdev)
46-
$(call ABIGEN,$^) --exclude finalize,setOperator,setVoters >$@
47-
4828
$(OUTDIR)/stabilization.py: $(addprefix $(ABIDIR)/Stabilization,.abi .docuser .docdev)
49-
$(call ABIGEN,$^) --exclude setOperator,setOracle >$@
50-
5129
$(OUTDIR)/supply_control.py: $(addprefix $(ABIDIR)/SupplyControl,.abi .docuser .docdev)
52-
$(call ABIGEN,$^) --exclude setOperator >$@
53-
5430
$(OUTDIR)/upgrade_manager.py: $(addprefix $(ABIDIR)/UpgradeManager,.abi .docuser .docdev)
55-
$(call ABIGEN,$^) --exclude setOperator >$@
31+
32+
$(BINDINGS):
33+
hatch run generate:pyabigen \
34+
--srcdir $(AUTONITY)/autonity/solidity/contracts \
35+
--version $(VERSION) \
36+
--userdoc $(word 2,$^) \
37+
--devdoc $(word 3,$^) \
38+
$(word 1,$^) >$@
5639

5740
$(ABIDIR)/%.abi: $(AUTONITY) AUTONITY_VERSION
5841
cd $< && \

autonity/contracts/accountability.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,32 @@ def config(
218218
int(return_value[6]),
219219
)
220220

221+
def distribute_rewards(
222+
self,
223+
_validator: eth_typing.ChecksumAddress,
224+
_ntn_reward: int,
225+
) -> contract.ContractFunction:
226+
"""Binding for `distributeRewards` on the Accountability contract.
227+
228+
called by the Autonity Contract at block finalization, to reward the reporter of
229+
a valid proof.
230+
231+
Parameters
232+
----------
233+
_validator : eth_typing.ChecksumAddress
234+
validator account which got slashed.
235+
_ntn_reward : int
236+
237+
Returns
238+
-------
239+
web3.contract.contract.ContractFunction
240+
A contract function instance to be sent in a transaction.
241+
"""
242+
return self._contract.functions.distributeRewards(
243+
_validator,
244+
_ntn_reward,
245+
)
246+
221247
def epoch_period(
222248
self,
223249
) -> int:
@@ -262,6 +288,28 @@ def events(
262288
int(return_value[11]),
263289
)
264290

291+
def finalize(
292+
self,
293+
_epoch_end: bool,
294+
) -> contract.ContractFunction:
295+
"""Binding for `finalize` on the Accountability contract.
296+
297+
called by the Autonity Contract at block finalization, before processing reward
298+
redistribution.
299+
300+
Parameters
301+
----------
302+
_epoch_end : bool
303+
304+
Returns
305+
-------
306+
web3.contract.contract.ContractFunction
307+
A contract function instance to be sent in a transaction.
308+
"""
309+
return self._contract.functions.finalize(
310+
_epoch_end,
311+
)
312+
265313
def get_validator_accusation(
266314
self,
267315
_val: eth_typing.ChecksumAddress,
@@ -361,6 +409,27 @@ def handle_event(
361409
),
362410
)
363411

412+
def set_epoch_period(
413+
self,
414+
_new_period: int,
415+
) -> contract.ContractFunction:
416+
"""Binding for `setEpochPeriod` on the Accountability contract.
417+
418+
called by the Autonity Contract when the epoch period is updated.
419+
420+
Parameters
421+
----------
422+
_new_period : int
423+
424+
Returns
425+
-------
426+
web3.contract.contract.ContractFunction
427+
A contract function instance to be sent in a transaction.
428+
"""
429+
return self._contract.functions.setEpochPeriod(
430+
_new_period,
431+
)
432+
364433
def slashing_history(
365434
self,
366435
key0: eth_typing.ChecksumAddress,

autonity/contracts/acu.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,52 @@ def scale_factor(
141141
return_value = self._contract.functions.scaleFactor().call()
142142
return int(return_value)
143143

144+
def set_operator(
145+
self,
146+
operator: eth_typing.ChecksumAddress,
147+
) -> contract.ContractFunction:
148+
"""Binding for `setOperator` on the ACU contract.
149+
150+
Set the Governance Operator account address. Only the Autonity Contract is
151+
authorized to set the Governance Operator account address.
152+
153+
Parameters
154+
----------
155+
operator : eth_typing.ChecksumAddress
156+
Address of the new Governance Operator
157+
158+
Returns
159+
-------
160+
web3.contract.contract.ContractFunction
161+
A contract function instance to be sent in a transaction.
162+
"""
163+
return self._contract.functions.setOperator(
164+
operator,
165+
)
166+
167+
def set_oracle(
168+
self,
169+
oracle: eth_typing.ChecksumAddress,
170+
) -> contract.ContractFunction:
171+
"""Binding for `setOracle` on the ACU contract.
172+
173+
Set the Oracle Contract address that is used to retrieve prices. Only the
174+
Autonity Contract is authorized to set the Oracle Contract address.
175+
176+
Parameters
177+
----------
178+
oracle : eth_typing.ChecksumAddress
179+
Address of the new Oracle Contract
180+
181+
Returns
182+
-------
183+
web3.contract.contract.ContractFunction
184+
A contract function instance to be sent in a transaction.
185+
"""
186+
return self._contract.functions.setOracle(
187+
oracle,
188+
)
189+
144190
def symbols(
145191
self,
146192
) -> typing.List[str]:
@@ -156,6 +202,25 @@ def symbols(
156202
return_value = self._contract.functions.symbols().call()
157203
return [str(elem) for elem in return_value]
158204

205+
def update(
206+
self,
207+
) -> contract.ContractFunction:
208+
"""Binding for `update` on the ACU contract.
209+
210+
Compute the ACU value and store it. It retrieves the latest prices from the
211+
Oracle Contract. If one or more prices are unavailable from the Oracle, it will
212+
not compute the value for that round. This function is intended to be called by
213+
the protocol during block finalization, after the Oracle Contract finalization
214+
has completed. Only the Autonity Contract is authorized to trigger the
215+
computation of the ACU.
216+
217+
Returns
218+
-------
219+
web3.contract.contract.ContractFunction
220+
A contract function instance to be sent in a transaction.
221+
"""
222+
return self._contract.functions.update()
223+
159224
def value(
160225
self,
161226
) -> int:

autonity/contracts/autonity.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,21 @@ def complete_contract_upgrade(
474474
"""
475475
return self._contract.functions.completeContractUpgrade()
476476

477+
def compute_committee(
478+
self,
479+
) -> contract.ContractFunction:
480+
"""Binding for `computeCommittee` on the Autonity contract.
481+
482+
update the current committee by selecting top staking validators. Restricted to
483+
the protocol.
484+
485+
Returns
486+
-------
487+
web3.contract.contract.ContractFunction
488+
A contract function instance to be sent in a transaction.
489+
"""
490+
return self._contract.functions.computeCommittee()
491+
477492
def config(
478493
self,
479494
) -> Config:
@@ -575,6 +590,34 @@ def epoch_total_bonded_stake(
575590
return_value = self._contract.functions.epochTotalBondedStake().call()
576591
return int(return_value)
577592

593+
def finalize(
594+
self,
595+
) -> contract.ContractFunction:
596+
"""Binding for `finalize` on the Autonity contract.
597+
598+
finalize is the block state finalisation function. It is called each block after
599+
processing every transactions within it. It must be restricted to the protocol
600+
only.
601+
602+
Returns
603+
-------
604+
web3.contract.contract.ContractFunction
605+
A contract function instance to be sent in a transaction.
606+
"""
607+
return self._contract.functions.finalize()
608+
609+
def finalize_initialization(
610+
self,
611+
) -> contract.ContractFunction:
612+
"""Binding for `finalizeInitialization` on the Autonity contract.
613+
614+
Returns
615+
-------
616+
web3.contract.contract.ContractFunction
617+
A contract function instance to be sent in a transaction.
618+
"""
619+
return self._contract.functions.finalizeInitialization()
620+
578621
def get_block_period(
579622
self,
580623
) -> int:

0 commit comments

Comments
 (0)