-
Notifications
You must be signed in to change notification settings - Fork 1
feat: implement cluster/helpers
#272
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
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
19bfe73
Add `random_eth_address_seed`
emlautarom1 0c3c579
Make `Record::new` accept argument as ref
emlautarom1 76df81a
Prefer to use `&[]` as argument
emlautarom1 d4a1177
Prefer `impl AsRef<str>` when possible
emlautarom1 6dc0d60
Prefer `&mut` over ownership
emlautarom1 52bcd30
Expose function
emlautarom1 129859a
Use inner data directly
emlautarom1 a28dffc
Initial `test_cluster`
emlautarom1 0f556cc
Add missing ref
emlautarom1 04ec923
Apply clippy suggestions
emlautarom1 0cfe82d
Remove +1
emlautarom1 42a6ba8
Make `now` be local without nanos
emlautarom1 25bb2a7
Add `fetch_definition`
emlautarom1 c33ef86
Update lockfile
emlautarom1 09a4b97
Fix formatting
emlautarom1 4e441af
Fix clippy suggestions
emlautarom1 0b26324
Remove import
emlautarom1 8aa7a25
Ignore clippy warning
emlautarom1 bb230ab
Add `create_validator_keys_dir`
emlautarom1 41fde25
Make signature more generic
emlautarom1 0213e47
Merge branch 'main' into emlautarom1/cluster-helpers
emlautarom1 9bbe2eb
Apply timeout to the entire operation
emlautarom1 cc9d2ca
Add more context to the error
emlautarom1 070451c
Truncate to u8
emlautarom1 3a83e36
Update function name and docs
emlautarom1 30c49f4
Revert operation order change
emlautarom1 0bad326
feat(p2p): add upgrade to quic (#259)
varex83 e7c654b
feat(p2p): add force direct connections (#260)
varex83 0ada038
fix: update quinn-proto package (#275)
iamquang95 7594a3c
Merge remote-tracking branch 'origin/main' into emlautarom1/cluster-h…
emlautarom1 27d5241
Fix clippy warnings
emlautarom1 ca177d9
Improve random management
emlautarom1 86cd6c4
Use explicit reqwest features
emlautarom1 3055450
Fix typo
emlautarom1 9d174eb
Use `helpers::to_0x_hex`
emlautarom1 75637ba
Use `Vec::with_capacity`
emlautarom1 e8e11f0
Use `test cluster` as name
emlautarom1 971afcd
Remove qualified use
emlautarom1 d38831a
Fix clippy lints
emlautarom1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ use crate::{ | |
| ssz_hasher::Hasher, | ||
| version::{CURRENT_VERSION, DKG_ALGO, versions::*}, | ||
| }; | ||
| use chrono::{DateTime, Utc}; | ||
| use chrono::{DateTime, Timelike, Utc}; | ||
| use libp2p::PeerId; | ||
| use pluto_eth1wrap::{EthClient, EthClientError}; | ||
| use pluto_eth2util::enr::{Record, RecordError}; | ||
|
|
@@ -394,7 +394,12 @@ impl Definition { | |
| uuid: uuid.to_string(), | ||
| name, | ||
| version: CURRENT_VERSION.to_string(), | ||
| timestamp: Utc::now().to_string(), | ||
| // TODO: This is very error prone and should be replaced with a controlled timestamp in | ||
| // UTC. | ||
| timestamp: chrono::Local::now() | ||
| .with_nanosecond(0) | ||
| .expect("nanoseconds = 0") | ||
| .to_rfc3339(), | ||
|
Comment on lines
+399
to
+402
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to match the Go implementation: requires TZ and explicitly set nanoseconds to 0, otherwise the string gets too long and SSZ serialization fails (exceeds 32 byte limit) |
||
| num_validators, | ||
| threshold, | ||
| dkg_algorithm: DKG_ALGO.to_string(), | ||
|
|
@@ -441,7 +446,9 @@ impl Definition { | |
| return Err(InvalidGasLimitError::GasLimitNotSet.into()); | ||
| } | ||
|
|
||
| def.set_definition_hashes() | ||
| def.set_definition_hashes()?; | ||
|
|
||
| Ok(def) | ||
| } | ||
|
|
||
| /// Returns the timestamp of the definition. | ||
|
|
@@ -479,7 +486,7 @@ impl Definition { | |
| // there are no EIP712 signatures before v1.3.0. For definition versions | ||
| // earlier than v1.3.0, error if either config signature or enr signature for | ||
| // any operator is present. | ||
| if !Self::support_eip712_sigs(self.version.as_str()) { | ||
| if !Self::support_eip712_sigs(&self.version) { | ||
| return if Self::eip712_sigs_present(&self.operators) { | ||
| Err(DefinitionError::OlderVersionSignaturesNotSupported) | ||
| } else { | ||
|
|
@@ -664,18 +671,18 @@ impl Definition { | |
| } | ||
|
|
||
| /// Sets the definition hashes. | ||
| pub fn set_definition_hashes(mut self) -> Result<Self, DefinitionError> { | ||
| pub fn set_definition_hashes(&mut self) -> Result<(), DefinitionError> { | ||
| let config_hash = | ||
| hash_definition(&self, true).map_err(|e| DefinitionError::SSZError(Box::new(e)))?; | ||
| hash_definition(self, true).map_err(|e| DefinitionError::SSZError(Box::new(e)))?; | ||
|
|
||
| self.config_hash = config_hash.to_vec(); | ||
|
|
||
| let definition_hash = | ||
| hash_definition(&self, false).map_err(|e| DefinitionError::SSZError(Box::new(e)))?; | ||
| hash_definition(self, false).map_err(|e| DefinitionError::SSZError(Box::new(e)))?; | ||
|
|
||
| self.definition_hash = definition_hash.to_vec(); | ||
|
|
||
| Ok(self) | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// `verify_hashes` returns an error if hashes populated from json object | ||
|
|
@@ -707,8 +714,8 @@ impl Definition { | |
| /// Returns true if the provided definition version supports EIP712 | ||
| /// signatures. Note that Definition versions prior to v1.3.0 don't | ||
| /// support EIP712 signatures. | ||
| pub(crate) fn support_eip712_sigs(version: &str) -> bool { | ||
| !matches!(version, V1_0 | V1_1 | V1_2) | ||
| pub fn support_eip712_sigs(version: impl AsRef<str>) -> bool { | ||
| !matches!(version.as_ref(), V1_0 | V1_1 | V1_2) | ||
| } | ||
|
|
||
| fn eip712_sigs_present(operators: &[Operator]) -> bool { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.