-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eth2Near-relay: split relay on a few crates, many improvements (#825)
* Separate `logger`, `eth_rpc_client`, and `Eth2OnNearClient` contract initialization into separate crates * Check configuration setup for Mainnet: add a verification on init args that it can't be executed in the trustless mode without `bls` verification on Mainnet (#767). * Improve config file usage on contract initialization: `validate_updates`, `verify_bls_signatures`, `hashes_gc_threshold`, `max_submitted_blocks_by_account`, `trusted_signer_account_id` fields are set through the config file instead of hardcoded values (#769). * Improve configuration of some args: `network`, `contract_type`, and `near_network_id` now use `enum`s instead of `String`s (#811). * Add messages for unhandled `unwraps()` on relay start-up (#816). Co-authored-by: Kirill <[email protected]> Co-authored-by: Karim <[email protected]>
- Loading branch information
1 parent
bc16598
commit 2230d63
Showing
57 changed files
with
10,913 additions
and
479 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::error::Error; | ||
use std::fmt; | ||
use std::fmt::{Display, Formatter}; | ||
use std::str::FromStr; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub enum EthNetwork { | ||
Mainnet, | ||
Kiln, | ||
Ropsten, | ||
Goerli, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct IncorrectEthNetwork; | ||
|
||
impl Display for IncorrectEthNetwork { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!( | ||
f, | ||
"Unknown Ethereum network. Possible networks: 'Mainnet', 'Kiln', 'Goerli', 'Ropsten'" | ||
) | ||
} | ||
} | ||
|
||
impl Error for IncorrectEthNetwork {} | ||
|
||
impl Display for EthNetwork { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", self.as_str()) | ||
} | ||
} | ||
|
||
impl EthNetwork { | ||
pub fn as_str(&self) -> &str { | ||
match self { | ||
EthNetwork::Mainnet => "mainnet", | ||
EthNetwork::Kiln => "kiln", | ||
EthNetwork::Goerli => "goerli", | ||
EthNetwork::Ropsten => "ropsten" | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for EthNetwork { | ||
type Err = IncorrectEthNetwork; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s.to_lowercase().as_str() { | ||
"mainnet" => Ok(EthNetwork::Mainnet), | ||
"kiln" => Ok(EthNetwork::Kiln), | ||
"goerli" => Ok(EthNetwork::Goerli), | ||
"ropsten" => Ok(EthNetwork::Ropsten), | ||
_ => Err(IncorrectEthNetwork), | ||
} | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::error::Error; | ||
use std::fmt; | ||
use std::fmt::{Display, Formatter}; | ||
use std::str::FromStr; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub enum NearNetwork { | ||
Mainnet, | ||
Testnet, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct IncorrectNearNetwork; | ||
|
||
impl Display for IncorrectNearNetwork { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!( | ||
f, | ||
"Unknown NEAR network id. Possible networks: 'Mainnet', 'Testnet'" | ||
) | ||
} | ||
} | ||
|
||
impl Error for IncorrectNearNetwork {} | ||
|
||
impl Display for NearNetwork { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
write!(f, "{}", self.as_str()) | ||
} | ||
} | ||
|
||
impl NearNetwork { | ||
pub fn as_str(&self) -> &str { | ||
match self { | ||
NearNetwork::Mainnet => "mainnet", | ||
NearNetwork::Testnet => "testnet", | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for NearNetwork { | ||
type Err = IncorrectNearNetwork; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s.to_lowercase().as_str() { | ||
"mainnet" => Ok(NearNetwork::Mainnet), | ||
"testnet" => Ok(NearNetwork::Testnet), | ||
_ => Err(IncorrectNearNetwork), | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.