Skip to content
This repository was archived by the owner on Jun 25, 2024. It is now read-only.

feat(): Pinned validators#15

Open
ijerkovic wants to merge 1 commit intomasterfrom
pinned-validators
Open

feat(): Pinned validators#15
ijerkovic wants to merge 1 commit intomasterfrom
pinned-validators

Conversation

@ijerkovic
Copy link
Copy Markdown

Any workspace that cares for security should run at least num_shards validators (potentially even factor_of_redundancy * num_shards). The proposed solution is to assign at least one validator from a workspace to each shard (depending on factor_of_redundancy, this can obviously be at least factor_of_redundancy).

For workspaces that do not care about security, their validators will be assigned falling back to the nearprotocol

Test plan:
Described here
https://docs.google.com/document/d/1Wc9b5eM3oQ57Ibe4RkzK3lUEZh3AAhQcx68_bcKH8yc/edit

Any workspace that cares for security should run at least num_shards validators (potentially even factor_of_redundancy * num_shards).
The proposed solution is to assign at least one validator from a workspace to each shard (depending on factor_of_redundancy, this can obviously be at least factor_of_redundancy).

For workspaces that do not care about security, their validators will be assigned falling back to the nearprotocol

Test plan:
Described here
https://docs.google.com/document/d/1Wc9b5eM3oQ57Ibe4RkzK3lUEZh3AAhQcx68_bcKH8yc/edit
Copy link
Copy Markdown

@mercepluka mercepluka left a comment

Choose a reason for hiding this comment

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

I left a few style comments, I think that the rest of the code is good.

min_validators_per_shard: usize,
validator_account_id_to_workspace_id: HashMap<AccountId, usize>,
workspace_to_validator_ids: HashMap<usize, Vec<ValidatorId>>,
workspace_id_validators: HashMap<usize, Vec<AccountId>>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any difference between those 2 arguments? workspace_to_validator_ids and workspace_to_validator_ids

let workspace_id: usize = if workspace_to_id.contains_key(&workspace_name) {
*workspace_to_id.get(&workspace_name).unwrap()
} else {
workspace_to_id.insert(workspace_name,num_workspaces);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are you converting workspace references to numbers?


let mut result: Vec<Vec<T>> = (0..num_shards).map(|_| Vec::new()).collect();

let mut index_to_insert: usize = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think this function would be more readable if an initial assignment is also done in a separate function (like 2 original functions are).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants