namada_apps_lib/config/ethereum_bridge/ledger.rs
1//! Runtime configuration for a validator node.
2#[allow(unused_imports)]
3use namada_sdk::ethereum_events::EthereumEvent;
4use serde::{Deserialize, Serialize};
5
6/// Default [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) endpoint used by the oracle
7pub const DEFAULT_ORACLE_RPC_ENDPOINT: &str = "http://127.0.0.1:8545";
8
9/// The default maximum number of Ethereum events the channel between
10/// the oracle and the shell can hold.
11pub const ORACLE_CHANNEL_BUFFER_SIZE: usize = 1000;
12
13/// The mode in which to run the Ethereum bridge.
14#[derive(Clone, Debug, Serialize, Deserialize)]
15pub enum Mode {
16 /// The oracle will listen to the Ethereum JSON-RPC endpoint as
17 /// specified in the `oracle_rpc_endpoint` setting.
18 RemoteEndpoint,
19 /// Instead of the oracle listening for events using an Ethereum
20 /// JSON-RPC endpoint, an endpoint will be exposed by the ledger
21 /// itself for submission of Borsh-serialized [`EthereumEvent`]
22 /// instances. Mostly useful for testing purposes.
23 SelfHostedEndpoint,
24 /// Do not run any components of the Ethereum bridge.
25 Off,
26}
27
28#[derive(Clone, Debug, Serialize, Deserialize)]
29pub struct Config {
30 /// The mode in which to run the Ethereum node and oracle setup of this
31 /// validator.
32 pub mode: Mode,
33 /// The Ethereum JSON-RPC endpoint that the Ethereum event oracle will use
34 /// to listen for events from the Ethereum bridge smart contracts
35 pub oracle_rpc_endpoint: String,
36 /// The size of bounded channel between the Ethereum oracle and main
37 /// ledger subprocesses. This is the number of Ethereum events that
38 /// can be held in the channel. The default is 1000.
39 pub channel_buffer_size: usize,
40}
41
42impl Default for Config {
43 fn default() -> Self {
44 Self {
45 mode: Mode::RemoteEndpoint,
46 oracle_rpc_endpoint: DEFAULT_ORACLE_RPC_ENDPOINT.to_owned(),
47 channel_buffer_size: ORACLE_CHANNEL_BUFFER_SIZE,
48 }
49 }
50}