NDRS-215: Unify bids persistence by auction contract#165
NDRS-215: Unify bids persistence by auction contract#165mpapierski merged 3 commits intocasper-network:masterfrom
Conversation
3209c32 to
4b91dbb
Compare
4b91dbb to
528756e
Compare
|
|
||
| builder.exec(transfer_request_1).commit().expect_success(); | ||
|
|
||
| // |
| let mut entry_points = EntryPoints::new(); | ||
|
|
||
| let entry_point = EntryPoint::new( | ||
| METHOD_RELEASE_FOUNDER, |
There was a problem hiding this comment.
Should this really be an entry point of the auction contract? Who is going to call that?
I was thinking they would automatically released in the run_auction call with the corresponding era number?
There was a problem hiding this comment.
Doable - I actually have ticket this sprint to refine this https://casperlabs.atlassian.net/browse/NDRS-231
There was a problem hiding this comment.
OK. I guess we'll never actually use this entry point then. Would probably be more work to call it from BlockExecutor than to implement NDRS-231.
There was a problem hiding this comment.
Yes - I plan to remove this entry point since I'll be introducing a field to indicate which era it will unlock, there's no need for a special entry point
types/src/auction/args.rs
Outdated
| pub const FOUNDING_VALIDATORS_KEY: &str = "founding_validators"; | ||
| /// Storage for `ActiveBids`. | ||
| pub const ACTIVE_BIDS_KEY: &str = "active_bids"; | ||
| pub const VALIDATORS_KEY: &str = "validators"; |
There was a problem hiding this comment.
Isn't "active bids" (or just "bids") a better term? Because they are not all validators, only the winner are?
There was a problem hiding this comment.
Yep fair I changed the data structure to Bid and collection of bids to Bids and the relevant keys.
| /// For a founding validator, the same logic is carried out with founding_validators, instead | ||
| /// of `active_bids`. | ||
| /// For a founding validator, the same logic is carried out with validators, instead | ||
| /// of `founders`. |
There was a problem hiding this comment.
Is that comment still accurate? Now both cases seem to access the validators map.
| // Return early if target validator is not in `active_bids` | ||
| let _active_bid = active_bids | ||
| // Return early if target validator is not in `validators` | ||
| let _founding_validator = validators |
There was a problem hiding this comment.
Same as above: This is not a founding validator, is it?
| // .iter() | ||
| // .map(|(validator_account_hash, active_bid)| { | ||
| // (*validator_account_hash, active_bid.bid_amount) | ||
| // }); |
There was a problem hiding this comment.
Is that comment left by mistake?
| staked_amount, | ||
| delegation_rate: 0, | ||
| funds_locked: true, | ||
| is_founding_validator: true, |
There was a problem hiding this comment.
I guess that should be:
| is_founding_validator: true, | |
| is_founding_validator: false, |
| } | ||
| } | ||
|
|
||
| /// Creates a new instance of `FoundingValidator` for non-founding entry. |
There was a problem hiding this comment.
| /// Creates a new instance of `FoundingValidator` for non-founding entry. | |
| /// Creates a new instance of `Validator` for non-founding entry. |
…or ActiveBid or Bid?
| !self.funds_locked | ||
| } else { | ||
| // Non founding validator can always withdraw funds | ||
| true |
There was a problem hiding this comment.
pub fn can_withdraw_funds(&self) -> bool {
!self.is_founding_validator || !self.funds_locked
}But actually: Why do we need to distinguish founding validators at all? Is there any other reason why your funds could be locked?
There was a problem hiding this comment.
So founding validator's should have funds unlocked at certain era, right? Non-founding entries aren't locked
There was a problem hiding this comment.
Exactly… why does the is_founding_validator boolean exist at all?
Should this method maybe just return !self.funds_locked and that's it?
There was a problem hiding this comment.
As discussed on slack I removed the bool flag
Unifies storage of bids and founding validators into one collection where founding/non-founding validators are determined upon an attribute
is_founding_validator