Skip to content

Commit

Permalink
Merge pull request #1361 from EspressoSystems/feat/builder-fee
Browse files Browse the repository at this point in the history
Use fee from builder
  • Loading branch information
jbearer authored Apr 25, 2024
2 parents cc45606 + 390db12 commit 71f8ee7
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 332 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ ESPRESSO_SEQUENCER2_API_PORT=44002
ESPRESSO_SEQUENCER3_API_PORT=44003
ESPRESSO_SEQUENCER4_API_PORT=44004
ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE=10kb
ESPRESSO_SEQUENCER_BASE_FEE=0
ESPRESSO_SEQUENCER_BASE_FEE=1
ESPRESSO_SEQUENCER_URL=http://sequencer0:${ESPRESSO_SEQUENCER_API_PORT}
ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer
ESPRESSO_SEQUENCER_L1_PORT=8545
ESPRESSO_SEQUENCER_L1_WS_PORT=8546
ESPRESSO_SEQUENCER_L1_PROVIDER=http://demo-l1-network:${ESPRESSO_SEQUENCER_L1_PORT}
ESPRESSO_SEQUENCER_ETH_MNEMONIC="test test test test test test test test test test test junk"
# The first account is the permission less builder, the last are sequencer0 to 4
ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f,0xBcd4042DE499D14e55001CcbB24a551F3b954096,0x71bE63f3384f5fb98995898A86B02Fb2426c5788,0xFABB0ac9d68B0B445fB7357272Ff202C5651694a,0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec,0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097
ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS=0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f
ESPRESSO_COMMITMENT_TASK_PORT=60000
ESPRESSO_SEQUENCER_DB_PORT=5432
ESPRESSO_STATE_RELAY_SERVER_PORT=40004
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions builder/src/bin/permissioned-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ async fn main() -> anyhow::Result<()> {
let builder_key_pair = EthKeyPair::from_mnemonic(&opt.eth_mnemonic, opt.eth_account_index)?;

let builder_params = BuilderParams {
mnemonic: opt.eth_mnemonic,
prefunded_accounts: vec![],
eth_account_index: opt.eth_account_index,
};

// Parse supplied Libp2p addresses to their socket form
Expand Down
18 changes: 3 additions & 15 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use es_version::SEQUENCER_VERSION;
use hotshot_types::data::ViewNumber;
use hotshot_types::traits::node_implementation::ConsensusTime;
use sequencer::eth_signature_key::EthKeyPair;
use sequencer::{BuilderParams, L1Params};
use sequencer::L1Params;
use snafu::Snafu;
use std::num::NonZeroUsize;
use std::{str::FromStr, time::Duration};
Expand Down Expand Up @@ -101,24 +101,12 @@ async fn main() -> anyhow::Result<()> {
};

let builder_key_pair = EthKeyPair::from_mnemonic(&opt.eth_mnemonic, opt.eth_account_index)?;

let builder_params = BuilderParams {
mnemonic: opt.eth_mnemonic,
prefunded_accounts: vec![],
eth_account_index: opt.eth_account_index,
};

let bootstrapped_view = ViewNumber::new(opt.view_number);

let builder_server_url: Url = format!("http://0.0.0.0:{}", opt.port).parse().unwrap();

let instance_state = build_instance_state(
l1_params,
builder_params,
opt.state_peers,
sequencer_version,
)
.unwrap();
let instance_state =
build_instance_state(l1_params, opt.state_peers, sequencer_version).unwrap();

let api_response_timeout_duration = opt.max_api_timeout_duration;

Expand Down
25 changes: 0 additions & 25 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,9 @@ pub mod testing {
_pd: Default::default(),
};

let key = Self::builder_key(i);
tracing::info!("node {i} is builder {:x}", key.address());
let node_state = NodeState::new(
ChainConfig::default(),
L1Client::new(self.anvil.endpoint().parse().unwrap(), Address::default()),
key,
MockStateCatchup::default(),
)
.with_genesis(ValidatedState::default());
Expand All @@ -419,14 +416,6 @@ pub mod testing {
handle
}

pub fn builder_key(i: usize) -> EthKeyPair {
EthKeyPair::from_mnemonic(
"test test test test test test test test test test test junk",
i as u32,
)
.unwrap()
}

// url for the hotshot event streaming api
pub fn hotshot_event_streaming_api_url() -> Url {
// spawn the event streaming api
Expand Down Expand Up @@ -538,19 +527,12 @@ pub mod testing {
hotshot_builder_api_url: Url,
) -> Self {
// setup the instance state
let key = HotShotTestConfig::builder_key(Self::SUBSCRIBED_DA_NODE_ID);
tracing::info!(
"node {} is builder {:x}",
Self::SUBSCRIBED_DA_NODE_ID,
key.address()
);
let node_state = NodeState::new(
ChainConfig::default(),
L1Client::new(
hotshot_test_config.get_anvil().endpoint().parse().unwrap(),
Address::default(),
),
key,
MockStateCatchup::default(),
)
.with_genesis(ValidatedState::default());
Expand Down Expand Up @@ -604,19 +586,12 @@ pub mod testing {
hotshot_builder_api_url: Url,
) -> Self {
// setup the instance state
let key = HotShotTestConfig::builder_key(HotShotTestConfig::NUM_STAKED_NODES);
tracing::info!(
"node {} is builder {:x}",
HotShotTestConfig::NUM_STAKED_NODES,
key.address()
);
let node_state = NodeState::new(
ChainConfig::default(),
L1Client::new(
hotshot_test_config.get_anvil().endpoint().parse().unwrap(),
Address::default(),
),
key,
MockStateCatchup::default(),
)
.with_genesis(ValidatedState::default());
Expand Down
9 changes: 0 additions & 9 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,13 @@ pub struct BuilderConfig {

pub fn build_instance_state<Ver: StaticVersionType + 'static>(
l1_params: L1Params,
builder_params: BuilderParams,
state_peers: Vec<Url>,
_: Ver,
) -> anyhow::Result<NodeState> {
// creating the instance state without any builder mnemonic
let builder_key =
EthKeyPair::from_mnemonic(&builder_params.mnemonic, builder_params.eth_account_index)?;

tracing::info!("Builder account address {:?}", builder_key.address());

let l1_client = L1Client::new(l1_params.url, Address::default());

let instance_state = NodeState::new(
ChainConfig::default(),
l1_client,
builder_key,
Arc::new(StatePeers::<Ver>::from_urls(state_peers)),
);
Ok(instance_state)
Expand Down
6 changes: 0 additions & 6 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
// crash horribly just because we're not using the P2P network yet.
let _ = NetworkingMetricsValue::new(metrics);

// creating the instance state without any builder mnemonic
let builder_key =
EthKeyPair::from_mnemonic(&builder_params.mnemonic, builder_params.eth_account_index)?;
tracing::info!("Builder account address {:?}", builder_key.address());

let mut genesis_state = ValidatedState::default();
for address in builder_params.prefunded_accounts {
tracing::warn!("Prefunding account {:?} for demo", address);
Expand All @@ -256,7 +251,6 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
let instance_state = NodeState::new(
ChainConfig::default(),
l1_client,
builder_key,
Arc::new(StatePeers::<Ver>::from_urls(network_params.state_peers)),
);

Expand Down
10 changes: 0 additions & 10 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ services:
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_0
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_0
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=sequencer0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_0
- ESPRESSO_SEQUENCER_ETH_MNEMONIC
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=10
- ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS
- ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_SEQUENCER_BASE_FEE
Expand Down Expand Up @@ -238,8 +236,6 @@ services:
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_1
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_1
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=sequencer1:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_1
- ESPRESSO_SEQUENCER_ETH_MNEMONIC
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=11
- ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS
- ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_SEQUENCER_BASE_FEE
Expand Down Expand Up @@ -277,8 +273,6 @@ services:
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_2
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_2
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=sequencer2:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_2
- ESPRESSO_SEQUENCER_ETH_MNEMONIC
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=12
- ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS
- ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_SEQUENCER_BASE_FEE
Expand Down Expand Up @@ -315,8 +309,6 @@ services:
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_3
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_3
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=sequencer3:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_3
- ESPRESSO_SEQUENCER_ETH_MNEMONIC
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=13
- ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS
- ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_SEQUENCER_BASE_FEE
Expand Down Expand Up @@ -353,8 +345,6 @@ services:
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_4
- ESPRESSO_SEQUENCER_LIBP2P_BIND_ADDRESS=0.0.0.0:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_4
- ESPRESSO_SEQUENCER_LIBP2P_ADVERTISE_ADDRESS=sequencer4:$ESPRESSO_DEMO_SEQUENCER_LIBP2P_PORT_4
- ESPRESSO_SEQUENCER_ETH_MNEMONIC
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=14
- ESPRESSO_SEQUENCER_PREFUNDED_BUILDER_ACCOUNTS
- ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_SEQUENCER_BASE_FEE
Expand Down
5 changes: 0 additions & 5 deletions process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ processes:
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq0
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_0
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_0
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=10
- ESPRESSO_SEQUENCER_STAKE_TABLE_CAPACITY=10
depends_on:
orchestrator:
Expand Down Expand Up @@ -128,7 +127,6 @@ processes:
- ESPRESSO_SEQUENCER_POSTGRES_PASSWORD=password
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_1
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_1
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=11
- ESPRESSO_SEQUENCER_STAKE_TABLE_CAPACITY=10
depends_on:
orchestrator:
Expand Down Expand Up @@ -165,7 +163,6 @@ processes:
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq2
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_2
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_2
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=12
- ESPRESSO_SEQUENCER_STAKE_TABLE_CAPACITY=10
depends_on:
orchestrator:
Expand Down Expand Up @@ -200,7 +197,6 @@ processes:
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq3
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_3
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_3
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=13
- ESPRESSO_SEQUENCER_STAKE_TABLE_CAPACITY=10
depends_on:
orchestrator:
Expand Down Expand Up @@ -233,7 +229,6 @@ processes:
- ESPRESSO_SEQUENCER_STORAGE_PATH=$ESPRESSO_BASE_STORAGE_PATH/seq4
- ESPRESSO_SEQUENCER_PRIVATE_STAKING_KEY=$ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_4
- ESPRESSO_SEQUENCER_PRIVATE_STATE_KEY=$ESPRESSO_DEMO_SEQUENCER_STATE_PRIVATE_KEY_4
- ESPRESSO_SEQUENCER_ETH_ACCOUNT_INDEX=14
- ESPRESSO_SEQUENCER_STAKE_TABLE_CAPACITY=10
depends_on:
orchestrator:
Expand Down
Loading

0 comments on commit 71f8ee7

Please sign in to comment.