-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update initializing from eth1 for merge genesis * read execution payload header from file lcli * add `create-payload-header` command to `lcli` * fix base fee parsing * Apply suggestions from code review * default `execution_payload_header` bool to false when deserializing `meta.yml` in EF tests Co-authored-by: Paul Hauner <[email protected]>
- Loading branch information
1 parent
93363bf
commit dc72800
Showing
17 changed files
with
187 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,39 @@ | ||
use bls::Hash256; | ||
use clap::ArgMatches; | ||
use clap_utils::{parse_optional, parse_required}; | ||
use int_to_bytes::int_to_bytes32; | ||
use ssz::Encode; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
use types::{EthSpec, ExecutionPayloadHeader}; | ||
|
||
pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> { | ||
let eth1_block_hash = parse_required(matches, "execution-block-hash")?; | ||
let genesis_time = parse_optional(matches, "genesis-time")?.unwrap_or( | ||
SystemTime::now() | ||
.duration_since(UNIX_EPOCH) | ||
.map_err(|e| format!("Unable to get time: {:?}", e))? | ||
.as_secs(), | ||
); | ||
let base_fee_per_gas = Hash256::from_slice(&int_to_bytes32(parse_required( | ||
matches, | ||
"base-fee-per-gas", | ||
)?)); | ||
let gas_limit = parse_required(matches, "gas-limit")?; | ||
let file_name = matches.value_of("file").ok_or("No file supplied")?; | ||
|
||
let execution_payload_header: ExecutionPayloadHeader<T> = ExecutionPayloadHeader { | ||
gas_limit, | ||
base_fee_per_gas, | ||
timestamp: genesis_time, | ||
block_hash: eth1_block_hash, | ||
random: eth1_block_hash, | ||
..ExecutionPayloadHeader::default() | ||
}; | ||
let mut file = File::create(file_name).map_err(|_| "Unable to create file".to_string())?; | ||
let bytes = execution_payload_header.as_ssz_bytes(); | ||
file.write_all(bytes.as_slice()) | ||
.map_err(|_| "Unable to write to file".to_string())?; | ||
Ok(()) | ||
} |
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
Oops, something went wrong.