-
Notifications
You must be signed in to change notification settings - Fork 8
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
External stacking locks #57
Conversation
efce10a
to
de4fdfb
Compare
de4fdfb
to
cef8ba0
Compare
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.
Looks like a good start. Add some detailed comments, but it is really minor stuff.
Updating the external-staking (and mock-external-staking) contracts is an important step for tests. The real one should just send back a message in the same tx to commit_tx. When there is IBC, we can change it, but at least you upgrade the vault <-> external staking communication to be "IBC safe"
)?; | ||
|
||
// Rollback user's max_lien | ||
let mut user = self.users.load(ctx.deps.storage, &tx.user)?; |
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.
Yeah, this is kind of why I wouldn't apply it in the beginning, just lock and only apply on the success case.
Calculating maximum is harder when reducing (are there others higher?) vs raising (compare my new value with the max). This is an argument in favor of approach 2 above
8c5f3f3
to
4a251b6
Compare
3cefb74
to
1b59f93
Compare
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.
General design looks good.
Added a number of smaller style comments for cleanup.
It would be good to see integration into external-staking, but even more, we need to start IBC and figure out how to test well.
@@ -71,4 +81,24 @@ impl VaultApiHelper { | |||
}; | |||
Ok(wasm) | |||
} | |||
|
|||
pub fn commit_tx(&self, tx_id: u64) -> Result<WasmMsg, StdError> { |
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.
Good to add here, but question - isn't such a helper class now auto-generated?
Maybe a worthwhile PR to remove these and replace with mt autogen types (please do independent from this PR)
} | ||
} | ||
|
||
pub fn next_tx_id(&self, store: &mut dyn Storage) -> StdResult<u64> { | ||
let id: u64 = self.tx_count.may_load(store)?.unwrap_or_default() + 1; |
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.
Note: this may be the best use of update. You can use it as a return result directly.
(But it may require initializing the count to 0 in instantiate)
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.
Copied this from somewhere else. Will refactor if possible.
Using pending txs list
Using Lockable liens
Locked range fails with ParseError
Use enum instead of struct for generality / extensibility
73c8eea
to
8fd2445
Compare
Alternative to #54, but using
Lockable
for synchronisation.Proves that
Lockable
is a useful abstraction around this.TODO:
commit_tx
.rollback_tx
.