Skip to content

Commit

Permalink
fix: add a separate exit round for the checkpoint call
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Nov 15, 2023
1 parent 5345671 commit ed8da35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/valory/skills/staking_abci/rounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
return res


class CheckpointCallPreparedRound(DegenerateRound, ABC):
"""A round that represents staking has finished with a checkpoint call safe tx prepared."""


class FinishedStakingRound(DegenerateRound, ABC):
"""A round that represents staking has finished."""

Expand All @@ -137,26 +141,30 @@ class StakingAbciApp(AbciApp[Event]): # pylint: disable=too-few-public-methods
initial_round_cls: Type[AbstractRound] = CallCheckpointRound
transition_function: AbciAppTransitionFunction = {
CallCheckpointRound: {
Event.DONE: FinishedStakingRound,
Event.DONE: CheckpointCallPreparedRound,
Event.SERVICE_NOT_STAKED: FinishedStakingRound,
Event.NEXT_CHECKPOINT_NOT_REACHED_YET: FinishedStakingRound,
Event.ROUND_TIMEOUT: CallCheckpointRound,
Event.NO_MAJORITY: CallCheckpointRound,
},
CheckpointCallPreparedRound: {},
FinishedStakingRound: {},
}
cross_period_persisted_keys = frozenset(
{get_name(SynchronizedData.is_service_staked)}
)
final_states: Set[AppState] = {FinishedStakingRound}
final_states: Set[AppState] = {CheckpointCallPreparedRound, FinishedStakingRound}
event_to_timeout: Dict[Event, float] = {
Event.ROUND_TIMEOUT: 30.0,
}
db_pre_conditions: Dict[AppState, Set[str]] = {CallCheckpointRound: set()}
db_post_conditions: Dict[AppState, Set[str]] = {
FinishedStakingRound: {
CheckpointCallPreparedRound: {
get_name(SynchronizedData.tx_submitter),
get_name(SynchronizedData.most_voted_tx_hash),
get_name(SynchronizedData.is_service_staked),
},
FinishedStakingRound: {
get_name(SynchronizedData.is_service_staked),
},
}
4 changes: 3 additions & 1 deletion packages/valory/skills/trader_abci/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
)
from packages.valory.skills.staking_abci.rounds import (
CallCheckpointRound,
CheckpointCallPreparedRound,
FinishedStakingRound,
StakingAbciApp,
)
Expand Down Expand Up @@ -97,7 +98,8 @@
FinishedRedeemingTxRound: CallCheckpointRound,
FinishedWithoutDecisionRound: RedeemRound,
FinishedWithoutRedeemingRound: CallCheckpointRound,
FinishedStakingRound: RandomnessTransactionSubmissionRound,
FinishedStakingRound: ResetAndPauseRound,
CheckpointCallPreparedRound: RandomnessTransactionSubmissionRound,
FinishedStakingTxRound: ResetAndPauseRound,
FinishedResetAndPauseRound: UpdateBetsRound,
FinishedResetAndPauseErrorRound: RegistrationRound,
Expand Down

0 comments on commit ed8da35

Please sign in to comment.