Skip to content

NDRS-215: Unify bids persistence by auction contract#165

Merged
mpapierski merged 3 commits intocasper-network:masterfrom
mpapierski:ndrs-215-unify-storage
Aug 28, 2020
Merged

NDRS-215: Unify bids persistence by auction contract#165
mpapierski merged 3 commits intocasper-network:masterfrom
mpapierski:ndrs-215-unify-storage

Conversation

@mpapierski
Copy link
Collaborator

@mpapierski mpapierski commented Aug 24, 2020

Unifies storage of bids and founding validators into one collection where founding/non-founding validators are determined upon an attribute is_founding_validator

@mpapierski mpapierski force-pushed the ndrs-215-unify-storage branch from 4b91dbb to 528756e Compare August 27, 2020 10:57
@mpapierski mpapierski marked this pull request as ready for review August 27, 2020 10:59
@EdHastingsCasperAssociation EdHastingsCasperAssociation changed the title NDRS-215: Unify storage NDRS-215: Unify bids persistence by auction contract Aug 27, 2020

builder.exec(transfer_request_1).commit().expect_success();

//
Copy link
Contributor

Choose a reason for hiding this comment

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

No comment. 😄

let mut entry_points = EntryPoints::new();

let entry_point = EntryPoint::new(
METHOD_RELEASE_FOUNDER,
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doable - I actually have ticket this sprint to refine this https://casperlabs.atlassian.net/browse/NDRS-231

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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

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";
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't "active bids" (or just "bids") a better term? Because they are not all validators, only the winner are?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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`.
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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)
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that comment left by mistake?

staked_amount,
delegation_rate: 0,
funds_locked: true,
is_founding_validator: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that should be:

Suggested change
is_founding_validator: true,
is_founding_validator: false,

}
}

/// Creates a new instance of `FoundingValidator` for non-founding entry.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// 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
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So founding validator's should have funds unlocked at certain era, right? Non-founding entries aren't locked

Copy link
Contributor

@afck afck Aug 28, 2020

Choose a reason for hiding this comment

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

Exactly… why does the is_founding_validator boolean exist at all?
Should this method maybe just return !self.funds_locked and that's it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed on slack I removed the bool flag

@mpapierski mpapierski merged commit b9bb305 into casper-network:master Aug 28, 2020
sacherjj pushed a commit that referenced this pull request Aug 13, 2024
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
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