Skip to content

Commit fd29039

Browse files
thlorenzDodecahedr0x
authored andcommitted
fix: don't unbork for same delegation slot as remote slot (#702)
1 parent 88cb32b commit fd29039

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) fn account_still_undelegating_on_chain(
5555
.as_ref()
5656
.map(|d| d.delegation_slot)
5757
.unwrap_or_default();
58-
if delegation_slot < remote_slot_in_bank {
58+
if delegation_slot <= remote_slot_in_bank {
5959
// The last update of the account was after the last delegation
6060
// Therefore the account was not redelegated which indicates
6161
// that the undelegation is still not completed. Case (D))
@@ -132,14 +132,17 @@ mod tests {
132132
// Case B: The account was undelegated and was re-delegated to us.
133133
// Conditions:
134134
// - is_delegated: true (account is delegated to us on chain)
135-
// - delegation_slot >= remote_slot (delegation happend after we last updated the account)
135+
// - delegation_slot > remote_slot (delegation happend after we last updated the account)
136136
// Expected: true (should override/update)
137137

138138
let pubkey = Pubkey::default();
139139
let is_delegated = true;
140140
let remote_slot = 100;
141141

142+
// NOTE: this case led to incorrect unborking if delegation + undelegation + redelegation
143+
// happend all in the same slot
142144
// Subcase B1: delegation_slot == remote_slot
145+
/*
143146
let delegation_slot = 100;
144147
let deleg_record = Some(create_delegation_record(delegation_slot));
145148
assert!(!account_still_undelegating_on_chain(
@@ -149,6 +152,7 @@ mod tests {
149152
deleg_record,
150153
&Pubkey::default(),
151154
));
155+
*/
152156

153157
// Subcase B2: delegation_slot > remote_slot
154158
let delegation_slot = 101;

0 commit comments

Comments
 (0)