Working post bellatrix local testnet

This commit is contained in:
Pawan Dhananjay 2022-12-02 19:50:43 +05:30
parent df3615664e
commit e72d9fb922
No known key found for this signature in database
GPG Key ID: 647E56278D7E9B4C
12 changed files with 932 additions and 41 deletions

View File

@ -163,7 +163,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
};
}
if !el.is_synced_for_notifier().await {
if !el.is_synced().await {
// The EL is not synced.
return MergeReadiness::NotSynced;
}

View File

@ -10,7 +10,7 @@ use std::fmt;
#[derive(Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, Hash, Derivative)]
#[derivative(Debug = "transparent")]
#[serde(transparent)]
pub struct ExecutionBlockHash(Hash256);
pub struct ExecutionBlockHash(pub Hash256);
impl ExecutionBlockHash {
pub fn zero() -> Self {

View File

@ -559,14 +559,41 @@ fn main() {
),
)
.arg(
Arg::with_name("merge-fork-epoch")
.long("merge-fork-epoch")
Arg::with_name("bellatrix-fork-epoch")
.long("bellatrix-fork-epoch")
.value_name("EPOCH")
.takes_value(true)
.help(
"The epoch at which to enable the Merge hard fork",
),
)
.arg(
Arg::with_name("capella-fork-epoch")
.long("capella-fork-epoch")
.value_name("EPOCH")
.takes_value(true)
.help(
"The epoch at which to enable the Capella hard fork",
),
)
.arg(
Arg::with_name("eip4844-fork-epoch")
.long("eip4844-fork-epoch")
.value_name("EPOCH")
.takes_value(true)
.help(
"The epoch at which to enable the eip4844 hard fork",
),
)
.arg(
Arg::with_name("ttd")
.long("ttd")
.value_name("TTD")
.takes_value(true)
.help(
"The terminal total difficulty",
),
)
.arg(
Arg::with_name("eth1-block-hash")
.long("eth1-block-hash")

View File

@ -14,6 +14,7 @@ use std::io::Read;
use std::path::PathBuf;
use std::str::FromStr;
use std::time::{SystemTime, UNIX_EPOCH};
use types::ExecutionBlockHash;
use types::{
test_utils::generate_deterministic_keypairs, Address, BeaconState, ChainSpec, Config, Eth1Data,
EthSpec, ExecutionPayloadHeader, ExecutionPayloadHeaderMerge, Hash256, Keypair, PublicKey,
@ -70,7 +71,7 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
spec.altair_fork_epoch = Some(fork_epoch);
}
if let Some(fork_epoch) = parse_optional(matches, "merge-fork-epoch")? {
if let Some(fork_epoch) = parse_optional(matches, "bellatrix-fork-epoch")? {
spec.bellatrix_fork_epoch = Some(fork_epoch);
}
@ -82,6 +83,10 @@ pub fn run<T: EthSpec>(testnet_dir_path: PathBuf, matches: &ArgMatches) -> Resul
spec.eip4844_fork_epoch = Some(fork_epoch);
}
if let Some(ttd) = parse_optional(matches, "ttd")? {
spec.terminal_total_difficulty = ttd;
}
let genesis_state_bytes = if matches.is_present("interop-genesis-state") {
let execution_payload_header: Option<ExecutionPayloadHeader<T>> =
parse_optional(matches, "execution-payload-header")?
@ -153,6 +158,18 @@ fn initialize_state_with_validators<T: EthSpec>(
execution_payload_header: Option<ExecutionPayloadHeader<T>>,
spec: &ChainSpec,
) -> Result<BeaconState<T>, String> {
let default_header = ExecutionPayloadHeaderMerge {
gas_limit: 10,
base_fee_per_gas: 10.into(),
timestamp: genesis_time,
block_hash: ExecutionBlockHash(eth1_block_hash),
prev_randao: Hash256::random(),
parent_hash: ExecutionBlockHash::zero(),
transactions_root: Hash256::random(),
..ExecutionPayloadHeaderMerge::default()
};
let execution_payload_header =
execution_payload_header.or(Some(ExecutionPayloadHeader::Merge(default_header)));
// Empty eth1 data
let eth1_data = Eth1Data {
block_hash: eth1_block_hash,
@ -215,7 +232,14 @@ fn initialize_state_with_validators<T: EthSpec>(
// Override latest execution payload header.
// See https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/merge/beacon-chain.md#testing
*state.latest_execution_payload_header_mut() = execution_payload_header.unwrap_or_default();
if let Some(ExecutionPayloadHeader::Merge(ref header)) = execution_payload_header {
*state
.latest_execution_payload_header_merge_mut()
.map_err(|_| {
"State must contain bellatrix execution payload header".to_string()
})? = header.clone();
}
}
// Now that we have our validators, initialize the caches (including the committees)

View File

@ -44,7 +44,9 @@ http_port=${@:$OPTIND+2:1}
execution_endpoint=${@:$OPTIND+3:1}
execution_jwt=${@:$OPTIND+4:1}
exec lighthouse \
lighthouse_binary=lighthouse-4844
exec $lighthouse_binary \
--debug-level $DEBUG_LEVEL \
bn \
$SUBSCRIBE_ALL_SUBNETS \

File diff suppressed because one or more lines are too long

View File

@ -44,6 +44,7 @@ echo "Completed init"
exec $geth_binary \
--datadir $data_dir \
--ipcdisable \
--http \
--http.api="engine,eth,web3,net,debug" \
--networkid=$CHAIN_ID \

View File

@ -12,7 +12,7 @@ if [ -f "$1" ]; then
[[ -n "$pid" ]] || continue
echo killing $pid
kill $pid
kill $pid || true
done < $1
fi

View File

@ -13,11 +13,6 @@ set -o nounset -o errexit -o pipefail
source ./vars.env
# lcli \
# deploy-deposit-contract \
# --eth1-http http://localhost:8545 \
# --confirmations 1 \
# --validator-count $VALIDATOR_COUNT
NOW=`date +%s`
GENESIS_TIME=`expr $NOW + $GENESIS_DELAY`
@ -32,10 +27,11 @@ lcli \
--genesis-delay $GENESIS_DELAY \
--genesis-fork-version $GENESIS_FORK_VERSION \
--altair-fork-epoch $ALTAIR_FORK_EPOCH \
--bellatrix-fork-epoch $ALTAIR_FORK_EPOCH \
--capella-fork-epoch $ALTAIR_FORK_EPOCH \
--eip4844-fork-epoch $ALTAIR_FORK_EPOCH \
--eth1-block-hash 0000000000000000000000000000000000000000000000000000000000000000 \
--bellatrix-fork-epoch $BELLATRIX_FORK_EPOCH \
--capella-fork-epoch $CAPELLA_FORK_EPOCH \
--eip4844-fork-epoch $EIP4844_FORK_EPOCH \
--ttd $TTD \
--eth1-block-hash $ETH1_BLOCK_HASH \
--eth1-id $CHAIN_ID \
--eth1-follow-distance 1 \
--seconds-per-slot $SECONDS_PER_SLOT \
@ -44,7 +40,7 @@ lcli \
--interop-genesis-state \
--force
echo Specification generated at $TESTNET_DIR.
echo Specification and genesis.ssz generated at $TESTNET_DIR.
echo "Generating $VALIDATOR_COUNT validators concurrently... (this may take a while)"
lcli \
@ -54,13 +50,3 @@ lcli \
--node-count $BN_COUNT
echo Validators generated with keystore passwords at $DATADIR.
echo "Building genesis state... (this might take a while)"
lcli \
interop-genesis \
--spec $SPEC_PRESET \
--genesis-time $GENESIS_TIME \
--testnet-dir $TESTNET_DIR \
$GENESIS_VALIDATOR_COUNT
echo Created genesis state in $TESTNET_DIR

View File

@ -97,12 +97,6 @@ execute_command_add_PID() {
echo "$!" >> $PID_FILE
}
# Start ganache, setup things up and start the bootnode.
# The delays are necessary, hopefully there is a better way :(
# Delay to let ganache to get started
execute_command_add_PID ganache_test_node.log ./ganache_test_node.sh
sleeping 10
# Setup data
echo "executing: ./setup.sh >> $LOG_DIR/setup.log"
@ -121,7 +115,7 @@ BN_http_port_base=8000
EL_base_network=7000
EL_base_http=6000
EL_base_auth_http=6000
EL_base_auth_http=5000
(( $VC_COUNT < $BN_COUNT )) && SAS=-s || SAS=
@ -129,8 +123,12 @@ for (( el=1; el<=$BN_COUNT; el++ )); do
execute_command_add_PID geth_$el.log ./geth.sh $DATADIR/geth_datadir$el $((EL_base_network + $el)) $((EL_base_http + $el)) $((EL_base_auth_http + $el)) $genesis_file
done
sleeping 20
for (( bn=1; bn<=$BN_COUNT; bn++ )); do
execute_command_add_PID beacon_node_$bn.log ./beacon_node.sh $SAS -d $DEBUG_LEVEL $DATADIR/node_$bn $((BN_udp_tcp_base + $bn)) $((BN_http_port_base + $bn)) http://localhost:$((EL_base_auth_http + $bn)) $DATADIR/geth_datadir$el/geth/jwt.hex
secret=$DATADIR/geth_datadir$bn/geth/jwtsecret
echo $secret
execute_command_add_PID beacon_node_$bn.log ./beacon_node.sh $SAS -d $DEBUG_LEVEL $DATADIR/node_$bn $((BN_udp_tcp_base + $bn)) $((BN_http_port_base + $bn)) http://localhost:$((EL_base_auth_http + $bn)) $secret
done
# Start requested number of validator clients

View File

@ -30,4 +30,5 @@ exec lighthouse \
--testnet-dir $TESTNET_DIR \
--init-slashing-protection \
--beacon-nodes ${@:$OPTIND+1:1} \
--suggested-fee-recipient 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990 \
$VC_ARGS

View File

@ -4,17 +4,16 @@ DATADIR=~/.lighthouse/local-testnet
# Directory for the eth2 config
TESTNET_DIR=$DATADIR/testnet
# Mnemonic for the ganache test network
ETH1_NETWORK_MNEMONIC="vast thought differ pull jewel broom cook wrist tribe word before omit"
EL_BOOTNODE_ENODE="enode://51ea9bb34d31efc3491a842ed13b8cab70e753af108526b57916d716978b380ed713f4336a80cdb85ec2a115d5a8c0ae9f3247bed3c84d3cb025c6bab311062c@127.0.0.1:0?discport=30301"
# Hardcoded deposit contract based on ETH1_NETWORK_MNEMONIC
# DEPOSIT_CONTRACT_ADDRESS=8c594691c0e592ffa21f153a16ae41db5befcaaa
# Hardcoded deposit contract
DEPOSIT_CONTRACT_ADDRESS=4242424242424242424242424242424242424242
GENESIS_FORK_VERSION=0x42424242
# Block hash generated from genesis.json in directory
ETH1_BLOCK_HASH=16ef16304456fdacdeb272bd70207021031db355ed6c5e44ebd34c1ab757e221
VALIDATOR_COUNT=80
GENESIS_VALIDATOR_COUNT=80
@ -41,6 +40,8 @@ BELLATRIX_FORK_EPOCH=0
CAPELLA_FORK_EPOCH=1
EIP4844_FORK_EPOCH=2
TTD=0
# Spec version (mainnet or minimal)
SPEC_PRESET=mainnet