Skip to content

Make min_round_exp, forgiveness and observer status configurable in Highway.#140

Merged
afck merged 4 commits intocasper-network:masterfrom
afck:min_round_exp
Aug 6, 2020
Merged

Make min_round_exp, forgiveness and observer status configurable in Highway.#140
afck merged 4 commits intocasper-network:masterfrom
afck:min_round_exp

Conversation

@afck
Copy link
Contributor

@afck afck commented Aug 6, 2020

@afck
Copy link
Contributor Author

afck commented Aug 6, 2020

I'll add it to the chain spec in a separate PR.

@goral09
Copy link
Contributor

goral09 commented Aug 6, 2020

I'll add it to the chain spec in a separate PR.

Why chainspec and not node configuration? It's not required to be the same for all nodes?

@afck
Copy link
Contributor Author

afck commented Aug 6, 2020

min_round_exp and forgiveness_factor is required to be the same in all nodes.
The local round exponent can differ, of course. That's yet another issue to make that adaptive.

/// summit does not exceed half the total weight.
forgiveness_factor: u64,
/// The minimum round exponent. `1 << min_round_exp` milliseconds is the minimum round length.
min_round_exp: u8,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it part of the State and not HighwayParams? Similarly forgiveness_factor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed HighwayParams.
Moving these to Highway would require using Highway instead State in a lot of tests, which will be a major change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Previously State was encapsulating one thing, now it seems like it's a bag for everything single-era-related.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree: State and Highway should just be merged. But that's a task for several days in itself.
(Highway is also single-era-related.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I liked the fact that State was exactly just that – state, and the logic for accessing/modifying it was somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But was that ever really cleanly separated like that? Most of the logic was always in state.rs. 😕

I'd really love to have some discussion about that in general: How should the highway_core logic be separated into modules? I'm pretty sure there's a much better way to do it that what we have now, but I don't know.

/// regular reward.
pub(crate) fn forgiveness_factor(mut self, numerator: u16, denominator: u16) -> Self {
if numerator > denominator {
warn!("forgiveness factor should be at most 100%");
Copy link
Contributor

Choose a reason for hiding this comment

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

If it should be at most 100% why not panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm… I guess so. I'll change it.
Running with more than 100% is perfectly possible, of course. I just can't imagine how it could ever make any economic sense.

/// Creates and returns a new `Highway` instance with an empty protocol state.
pub(crate) fn build(self) -> Highway<C> {
let state = State::new(
self.validators.enumerate().map(|(_, val)| val.weight()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just into_iter() if you're ignoring index anyway?

instance_id,
validators,
seed,
forgiveness_factor: (1, 5),
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't forgiveness_factor and min_round_exp be carried over from the previous State instance rather than using magic numbers as defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But highway_core doesn't know about eras.
Also, I don't think it should be copied over from the previous one. It should rather be read from the chain spec or (probably) the most recent protocol upgrade.

But maybe default numbers don't make sense, that's true. Maybe I should just remove the whole HighwayBuilder again, because in the end, none of those values are really optional.

let idx = self.validators.get_index(&id);
let (av, effects) = ActiveValidator::new(idx, secret, round_exp, start_time, &self.state);
self.active_validator = Some(av);
effects
Copy link
Contributor

Choose a reason for hiding this comment

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

😬 I don't like mutating it like that, I would prefer if it returned new instance of Highway.

Wouldn't it make more sense actually? One cannot become an active validator in the middle of an era, right? you can only become one if you're bonded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it might be useful for syncing up, e.g. if you had an outage for a few minutes: You'd run as an "observer" until you've caught up and downloaded the current protocol state, and only then "activate" it again, so you don't create vertices for old rounds.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense but I would prefer if we didn't have to worry about stuff like that – that our code might produce messages where it shouldn't have and it's not doing that only b/c we have the fuse here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure… in the tests we do activate the validators right away, to the problem would still show up there, wouldn't it? I think at least conceptually it makes sense to have such a mutating activate_validator method, and it even makes the code a bit simpler because nothing has to return a tuple (Highway, Effects).

Copy link
Contributor

@goral09 goral09 left a comment

Choose a reason for hiding this comment

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

Just nitpicks, nothing blocking from me.

@afck
Copy link
Contributor Author

afck commented Aug 6, 2020

But enumerate was just something like a five-line method? We can just recreate it whenever we need it again. It turned out we never used the index, so it's just unused at the moment.

@afck afck merged commit 46606fd into casper-network:master Aug 6, 2020
@afck afck deleted the min_round_exp branch August 6, 2020 15:13
sacherjj pushed a commit that referenced this pull request Feb 8, 2024
140: Add an expiry to requests for block to propose r=fizyk20 a=fizyk20

This adds a `request_expiry` field on `DeployBufferRequest::GetAppendableBlock`, which is the timestamp by which a response must be received to be still relevant.


Co-authored-by: Bartłomiej Kamiński <bart@casperlabs.io>
Co-authored-by: Ed Hastings <ed@casperlabs.io>
Co-authored-by: Bartłomiej Kamiński <fizyk20@gmail.com>
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
The VM memory section for the receipts root was updated only after the
script execution.

It is desirable to have it updated on the fly so the scripts can consume
the generated receipts root.

Closes #125
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.

2 participants