Skip to content

Commit

Permalink
fix: the checks for the rounds' attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Dec 13, 2024
1 parent 7914223 commit 8d3eafd
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/valory/skills/check_stop_trading_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CheckStopTradingRound(VotingRound):
none_event = Event.NONE
no_majority_event = Event.NO_MAJORITY
collection_key = get_name(SynchronizedData.participant_to_votes)
required_class_attributes = ()

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""Process the end of the block."""
Expand Down
1 change: 0 additions & 1 deletion packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ class TxPreparationRound(CollectSameUntilThresholdRound):
get_name(SynchronizedData.mocking_mode),
)
collection_key = get_name(SynchronizedData.participant_to_tx_prep)
required_class_attributes = ()

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""Process the end of the block."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ class CheckBenchmarkingModeRound(HandleFailedTxRound):
done_event = Event.BENCHMARKING_ENABLED
negative_event = Event.BENCHMARKING_DISABLED
none_event = Event.NONE
required_class_attributes = ()
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ class ClaimRound(VotingRound):
negative_event = Event.SUBSCRIPTION_ERROR
no_majority_event = Event.NO_MAJORITY
collection_key = get_name(SynchronizedData.participant_to_votes)
required_class_attributes = ()
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class DecisionReceiveRound(CollectSameUntilThresholdRound):
get_name(SynchronizedData.next_mock_data_row),
)
collection_key = get_name(SynchronizedData.participant_to_decision)
required_class_attributes = ()

def end_block(self) -> Optional[Tuple[SynchronizedData, Enum]]:
"""Process the end of the block."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class DecisionRequestRound(CollectSameUntilThresholdRound):
get_name(SynchronizedData.mocking_mode),
)
none_event = Event.SLOTS_UNSUPPORTED_ERROR
required_class_attributes = ()

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""Process the end of the block."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ class HandleFailedTxRound(VotingRound):
negative_event = Event.NO_OP
no_majority_event = Event.NO_MAJORITY
collection_key = get_name(SynchronizedData.participant_to_votes)
required_class_attributes = ()
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class RandomnessRound(RandomnessTransactionSubmissionRound):

done_event: Any = Event.DONE
no_majority_event: Any = Event.NO_MAJORITY
required_class_attributes = ()


class BenchmarkingRandomnessRound(RandomnessRound):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ class ToolSelectionRound(CollectSameUntilThresholdRound):
get_name(SynchronizedData.mech_tool),
)
collection_key = get_name(SynchronizedData.participant_to_selection)
required_class_attributes = ()
1 change: 0 additions & 1 deletion packages/valory/skills/market_manager_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class UpdateBetsRound(CollectSameUntilThresholdRound, MarketManagerAbstractRound
selection_key = get_name(SynchronizedData.bets_hash)
collection_key = get_name(SynchronizedData.participant_to_bets_hash)
synchronized_data_class = SynchronizedData
required_class_attributes = ()


class FinishedMarketManagerRound(DegenerateRound, ABC):
Expand Down
8 changes: 7 additions & 1 deletion packages/valory/skills/staking_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CollectionRound,
DegenerateRound,
DeserializedCollection,
NONE_EVENT_ATTRIBUTE,
get_name,
)
from packages.valory.skills.staking_abci.payloads import CallCheckpointPayload
Expand Down Expand Up @@ -100,7 +101,12 @@ class CallCheckpointRound(CollectSameUntilThresholdRound):
)
collection_key = get_name(SynchronizedData.participant_to_checkpoint)
synchronized_data_class = SynchronizedData
required_class_attributes = ()
# the none event is not required because the `CallCheckpointPayload` payload does not allow for `None` values
required_class_attributes = tuple(
attribute
for attribute in CollectSameUntilThresholdRound.required_class_attributes
if attribute != NONE_EVENT_ATTRIBUTE
)

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""Process the end of the block."""
Expand Down
4 changes: 0 additions & 4 deletions packages/valory/skills/trader_abci/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,3 @@
),
abci_app_transition_mapping,
).add_background_app(termination_config)

# patch to avoid breaking changes introduced on open-autonomy v0.18.3
for state in TraderAbciApp.get_all_rounds():
state.required_class_attributes = ()
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,20 @@ class PreTxSettlementRound(VotingRound):
payload_class = VotingPayload
synchronized_data_class = SynchronizedData
done_event = Event.CHECKS_PASSED
none_event = Event.REFILL_REQUIRED
negative_event = Event.REFILL_REQUIRED
no_majority_event = Event.NO_MAJORITY
collection_key = get_name(SynchronizedData.participant_to_votes)
required_class_attributes = ()


class PostTxSettlementRound(CollectSameUntilThresholdRound):
"""A round that will be called after tx settlement is done."""

payload_class: Any = object()
synchronized_data_class = SynchronizedData
# no class attributes are required because this round is overriding the `end_block` method
required_class_attributes = ()

def _check_required_attributes(self) -> None:
"""Check that required attributes are set."""
# skip the checks for this round
...

def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
"""
The end block.
Expand Down

0 comments on commit 8d3eafd

Please sign in to comment.