-
Notifications
You must be signed in to change notification settings - Fork 47
fix(cardano): Handle pool re-registrations #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ use crate::{ | |
| reset::{AccountTransition, EpochTransition, PoolTransition}, | ||
| }, | ||
| ewrap::{ | ||
| drops::{DRepDelegatorDrop, DRepExpiration}, | ||
| drops::{DRepDelegatorDrop, DRepExpiration, PoolDelegatorRetire}, | ||
| enactment::{PParamsUpdate, TreasuryWithdrawal}, | ||
| refunds::{PoolDepositRefund, ProposalDepositRefund}, | ||
| rewards::AssignRewards, | ||
|
|
@@ -533,6 +533,10 @@ pub struct AccountState { | |
|
|
||
| #[n(6)] | ||
| pub credential: StakeCredential, | ||
|
|
||
| #[n(7)] | ||
| #[cbor(default)] | ||
| pub retired_pool: Option<PoolHash>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's put a cbor default attribute here so that previous snapshots still work regardless of the existence of the new value.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved at d9b758c |
||
| } | ||
|
|
||
| entity_boilerplate!(AccountState, "accounts"); | ||
|
|
@@ -547,6 +551,7 @@ impl AccountState { | |
| drep: EpochValue::new(epoch), | ||
| vote_delegated_at: None, | ||
| deregistered_at: None, | ||
| retired_pool: None, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1816,6 +1821,7 @@ pub enum CardanoDelta { | |
| EpochTransition(EpochTransition), | ||
| EpochWrapUp(EpochWrapUp), | ||
| DRepDelegatorDrop(DRepDelegatorDrop), | ||
| PoolDelegatorRetire(PoolDelegatorRetire), | ||
| PoolWrapUp(PoolWrapUp), | ||
| ProposalDepositRefund(ProposalDepositRefund), | ||
| TreasuryWithdrawal(TreasuryWithdrawal), | ||
|
|
@@ -1883,6 +1889,7 @@ delta_from!(PoolDepositRefund); | |
| delta_from!(EpochTransition); | ||
| delta_from!(EpochWrapUp); | ||
| delta_from!(DRepDelegatorDrop); | ||
| delta_from!(PoolDelegatorRetire); | ||
| delta_from!(PoolWrapUp); | ||
| delta_from!(ProposalDepositRefund); | ||
| delta_from!(TreasuryWithdrawal); | ||
|
|
@@ -1919,6 +1926,7 @@ impl dolos_core::EntityDelta for CardanoDelta { | |
| Self::PoolDepositRefund(x) => x.key(), | ||
| Self::EpochTransition(x) => x.key(), | ||
| Self::EpochWrapUp(x) => x.key(), | ||
| Self::PoolDelegatorRetire(x) => x.key(), | ||
| Self::DRepDelegatorDrop(x) => x.key(), | ||
| Self::PoolWrapUp(x) => x.key(), | ||
| Self::ProposalDepositRefund(x) => x.key(), | ||
|
|
@@ -1956,6 +1964,7 @@ impl dolos_core::EntityDelta for CardanoDelta { | |
| Self::EpochTransition(x) => Self::downcast_apply(x, entity), | ||
| Self::EpochWrapUp(x) => Self::downcast_apply(x, entity), | ||
| Self::DRepDelegatorDrop(x) => Self::downcast_apply(x, entity), | ||
| Self::PoolDelegatorRetire(x) => Self::downcast_apply(x, entity), | ||
| Self::PoolWrapUp(x) => Self::downcast_apply(x, entity), | ||
| Self::ProposalDepositRefund(x) => Self::downcast_apply(x, entity), | ||
| Self::TreasuryWithdrawal(x) => Self::downcast_apply(x, entity), | ||
|
|
@@ -1992,6 +2001,7 @@ impl dolos_core::EntityDelta for CardanoDelta { | |
| Self::EpochTransition(x) => Self::downcast_undo(x, entity), | ||
| Self::EpochWrapUp(x) => Self::downcast_undo(x, entity), | ||
| Self::DRepDelegatorDrop(x) => Self::downcast_undo(x, entity), | ||
| Self::PoolDelegatorRetire(x) => Self::downcast_undo(x, entity), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, find where PoolDelegatorRetire is defined
fd -t f -n "*.rs" | head -20
echo "---"
# Search for PoolDelegatorRetire definition
rg "struct PoolDelegatorRetire" --type rust -A 5
echo "---"
# Search for EntityDelta implementation for PoolDelegatorRetire
rg "impl.*EntityDelta.*PoolDelegatorRetire" --type rust -A 10Repository: txpipe/dolos Length of output: 1407 🏁 Script executed: #!/bin/bash
# Check the context around line 2004 in model.rs
cat -n crates/cardano/src/model.rs | sed -n '1995,2015p'Repository: txpipe/dolos Length of output: 1204 🏁 Script executed: #!/bin/bash
# Find the exact file structure for drops.rs
fd "drops.rs" --type fRepository: txpipe/dolos Length of output: 89 🏁 Script executed: #!/bin/bash
# Get the full PoolDelegatorRetire implementation in drops.rs
rg "impl.*EntityDelta.*PoolDelegatorRetire" -A 50 --type rustRepository: txpipe/dolos Length of output: 3080 Implement the missing The |
||
| Self::PoolWrapUp(x) => Self::downcast_undo(x, entity), | ||
| Self::ProposalDepositRefund(x) => Self::downcast_undo(x, entity), | ||
| Self::TreasuryWithdrawal(x) => Self::downcast_undo(x, entity), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder undo logic may cause issues during chain rollbacks.
The
undomethod is not implemented, which could lead to incorrect state after rollbacks. Unlike some other deltas where undo is less critical,PoolDelegatorRetire::applymodifies bothentity.pool(viaschedule) andentity.retired_pool. If a rollback occurs, these changes won't be reversed.🔎 Proposed undo implementation
fn undo(&self, _entity: &mut Option<AccountState>) { - // todo!() - // Placeholder undo logic. Ensure this does not panic. + let Some(entity) = _entity.as_mut() else { + warn!(delegator=%self.delegator, "missing account during undo"); + return; + }; + + // Restore previous pool delegation + entity.pool.reset(self.prev_pool.clone()); + // Clear the retired_pool since we're undoing the retirement + entity.retired_pool = None; }🤖 Prompt for AI Agents