Skip to content

add autobalancer callback#139

Merged
holyfuchs merged 3 commits intomainfrom
holyfuchs/autobalancer-callback
Mar 3, 2026
Merged

add autobalancer callback#139
holyfuchs merged 3 commits intomainfrom
holyfuchs/autobalancer-callback

Conversation

@holyfuchs
Copy link
Member

@holyfuchs holyfuchs commented Feb 25, 2026

Add an optional callback for the autobalancer, necessary to recover stuck vaults in FlowYieldVaults in an optimized way.
This was intentionally left out of the constructor to maintain backward compatibility.

Copy link
Contributor

@nialexsan nialexsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would need a redeployment with a new name or to a new address

}
}
if let cap = self._executionCallback {
if cap.check() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cap.check() == false, would it be possible for it become true again? if not, does it make sense to set self_executionCallback = nil, so that next time the check can be skipped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test transaction passes:

// 1. Store resource and issue capability
let box <- Counter.createTestBox()
acct.storage.save(<- box, to: Counter.TestBoxStoragePath)
let cap = acct.capabilities.storage.issue<&Counter.TestBox>(Counter.TestBoxStoragePath)
assert(cap.check(), message: "cap.check() should be true when resource is stored")

// 2. Move resource out
let box2 <- acct.storage.load<@Counter.TestBox>(from: Counter.TestBoxStoragePath)!
assert(!cap.check(), message: "cap.check() should be false when resource was moved out")

// 3. Move resource back
acct.storage.save(<- box2, to: Counter.TestBoxStoragePath)
assert(cap.check(), message: "cap.check() should be true when resource is moved back")

so it is possible to become true again.

@zhangchiqing
Copy link
Member

LGTM, some minor suggestions

@holyfuchs holyfuchs force-pushed the holyfuchs/autobalancer-callback branch from bde6921 to 2acbb04 Compare March 3, 2026 11:01
@holyfuchs holyfuchs merged commit 2e12681 into main Mar 3, 2026
3 checks passed
@holyfuchs holyfuchs deleted the holyfuchs/autobalancer-callback branch March 3, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants