Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clients/lighthouse-bn/lighthouse_bn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,22 @@ esac
echo "bootnodes: ${HIVE_ETH2_BOOTNODE_ENRS}"

CONTAINER_IP=`hostname -i | awk '{print $1;}'`
eth1_option=$([[ "$HIVE_ETH2_ETH1_RPC_ADDRS" == "" ]] && echo "--dummy-eth1" || echo "--eth1-endpoints=$HIVE_ETH2_ETH1_RPC_ADDRS")
metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--metrics --metrics-address=0.0.0.0 --metrics-port=$HIVE_ETH2_METRICS_PORT --metrics-allow-origin=*")
if [ "$HIVE_ETH2_MERGE_ENABLED" != "" ]; then
echo -n "0x7365637265747365637265747365637265747365637265747365637265747365" > /jwtsecret
merge_option="--execution-endpoints=$HIVE_ETH2_ETH1_ENGINE_RPC_ADDRS --jwt-secrets=/jwtsecret"
fi
opt_sync_option=$([[ "$HIVE_ETH2_SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY" == "" ]] && echo "" || echo "--safe-slots-to-import-optimistically=$HIVE_ETH2_SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY")
builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--builder=$HIVE_ETH2_BUILDER_ENDPOINT")
echo BUILDER=$builder_option

lighthouse \
--debug-level="$LOG" \
--datadir=/data/beacon \
--testnet-dir=/data/testnet_setup \
bn \
--network-dir=/data/network \
$metrics_option $eth1_option $merge_option $opt_sync_option \
$metrics_option $builder_option $merge_option $opt_sync_option \
--enr-tcp-port="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \
--enr-udp-port="${HIVE_ETH2_P2P_UDP_PORT:-9000}" \
--enr-address="${CONTAINER_IP}" \
Expand Down
5 changes: 4 additions & 1 deletion clients/lighthouse-vc/lighthouse_vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ case "$HIVE_LOGLEVEL" in
5) LOG=trace ;;
esac

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--builder-proposals")

lighthouse \
--debug-level="$LOG" \
--datadir=/data/vc \
Expand All @@ -39,4 +41,5 @@ lighthouse \
--secrets-dir="/data/secrets" \
--init-slashing-protection \
--beacon-nodes="http://$HIVE_ETH2_BN_API_IP:$HIVE_ETH2_BN_API_PORT" \
--suggested-fee-recipient="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
--suggested-fee-recipient="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" \
$builder_option
3 changes: 3 additions & 0 deletions clients/lodestar-bn/lodestar_bn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ CONTAINER_IP=`hostname -i | awk '{print $1;}'`
echo Container IP: $CONTAINER_IP
bootnodes_option=$([[ "$HIVE_ETH2_BOOTNODE_ENRS" == "" ]] && echo "" || echo "--bootnodes ${HIVE_ETH2_BOOTNODE_ENRS//,/ }")
metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--metrics --metrics.address=$CONTAINER_IP --metrics.port=$HIVE_ETH2_METRICS_PORT")
builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--builder --builder.urls $HIVE_ETH2_BUILDER_ENDPOINT")
echo BUILDER=$builder_option

echo "bootnodes option : ${bootnodes_option}"

Expand All @@ -61,6 +63,7 @@ node /usr/app/node_modules/.bin/lodestar \
--jwt-secret=/jwtsecret \
$metrics_option \
$bootnodes_option \
$builder_option \
--enr.ip="${CONTAINER_IP}" \
--enr.tcp="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \
--enr.udp="${HIVE_ETH2_P2P_UDP_PORT:-9000}" \
Expand Down
5 changes: 4 additions & 1 deletion clients/lodestar-vc/lodestar_vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ case "$HIVE_LOGLEVEL" in
5) LOG=trace ;;
esac

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--builder --suggestedFeeRecipient 0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B")
echo BUILDER=$builder_option

echo Starting Lodestar Validator Client

node /usr/app/node_modules/.bin/lodestar \
Expand All @@ -41,6 +44,6 @@ node /usr/app/node_modules/.bin/lodestar \
--paramsFile=/hive/input/config.yaml \
--keystoresDir="/data/validators" \
--secretsDir="/data/secrets" \
$metrics_option \
$metrics_option $builder_option \
--beaconNodes="http://$HIVE_ETH2_BN_API_IP:$HIVE_ETH2_BN_API_PORT"

5 changes: 4 additions & 1 deletion clients/nimbus-bn/nimbus_bn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ else
fi
metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--metrics --metrics-address=0.0.0.0 --metrics-port=$HIVE_ETH2_METRICS_PORT")

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--payload-builder=true --payload-builder-url=$HIVE_ETH2_BUILDER_ENDPOINT")
echo BUILDER=$builder_option

echo -n "0x7365637265747365637265747365637265747365637265747365637265747365" > /jwtsecret

echo Starting Nimbus Beacon Node
Expand All @@ -68,7 +71,7 @@ echo Starting Nimbus Beacon Node
--web3-url="$HIVE_ETH2_ETH1_ENGINE_RPC_ADDRS" \
--jwt-secret=/jwtsecret \
--num-threads=4 \
$bootnodes_option $metrics_option \
$bootnodes_option $metrics_option $builder_option \
--nat="extip:${CONTAINER_IP}" \
--listen-address=0.0.0.0 \
--tcp-port="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \
Expand Down
4 changes: 4 additions & 0 deletions clients/nimbus-vc/nimbus_vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ case "$HIVE_LOGLEVEL" in
5) LOG=TRACE ;;
esac

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--payload-builder=true")
echo BUILDER=$builder_option

echo Starting Nimbus Validator Client

/usr/bin/nimbus_validator_client \
Expand All @@ -26,3 +29,4 @@ echo Starting Nimbus Validator Client
--beacon-node="http://$HIVE_ETH2_BN_API_IP:$HIVE_ETH2_BN_API_PORT" \
--validators-dir="/hive/input/keystores" \
--secrets-dir="/hive/input/secrets" \
$builder_option
4 changes: 4 additions & 0 deletions clients/prysm-bn/prysm_bn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ else
bootnode_option="$bootnode_option --bootstrap-node=$trimmed_bn"
done
fi
builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--http-mev-relay=$HIVE_ETH2_BUILDER_ENDPOINT")
echo BUILDER=$builder_option

echo Starting Prysm Beacon Node

/beacon-chain \
Expand All @@ -75,6 +78,7 @@ echo Starting Prysm Beacon Node
--subscribe-all-subnets=true \
--enable-debug-rpc-endpoints=true \
$metrics_option \
$builder_option \
--deposit-contract="${HIVE_ETH2_CONFIG_DEPOSIT_CONTRACT_ADDRESS:-0x1111111111111111111111111111111111111111}" \
--contract-deployment-block="${HIVE_ETH2_DEPOSIT_DEPLOY_BLOCK_NUMBER:-0}" \
--rpc-host=0.0.0.0 --rpc-port="${HIVE_ETH2_BN_GRPC_PORT:-3500}" \
Expand Down
6 changes: 5 additions & 1 deletion clients/prysm-vc/prysm_vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ case "$HIVE_LOGLEVEL" in
5) LOG=trace ;;
esac

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--enable-builder --suggested-fee-recipient=0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b")
echo BUILDER=$builder_option

echo Starting Prysm Validator Client

/validator \
Expand All @@ -52,5 +55,6 @@ echo Starting Prysm Validator Client
--datadir="/data/vc" \
--wallet-dir="/data/validators" \
--wallet-password-file="/wallet.pass" \
--chain-config-file="/hive/input/config.yaml"
--chain-config-file="/hive/input/config.yaml" \
$builder_option
# NOTE: gRPC/RPC ports are inverted to allow the simulator to access the REST API
4 changes: 3 additions & 1 deletion clients/teku-bn/teku_bn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ metrics_option=$([[ "$HIVE_ETH2_METRICS_PORT" == "" ]] && echo "" || echo "--met
enr_option=$([[ "$HIVE_ETH2_BOOTNODE_ENRS" == "" ]] && echo "" || echo --p2p-discovery-bootnodes="$HIVE_ETH2_BOOTNODE_ENRS")
static_option=$([[ "$HIVE_ETH2_STATIC_PEERS" == "" ]] && echo "" || echo --p2p-static-peers="$HIVE_ETH2_STATIC_PEERS")
opt_sync_option=$([[ "$HIVE_ETH2_SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY" == "" ]] && echo "" || echo "--Xnetwork-safe-slots-to-import-optimistically=$HIVE_ETH2_SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY")
builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--validators-builder-registration-default-enabled=true --validators-proposer-blinded-blocks-enabled=true --builder-endpoint=$HIVE_ETH2_BUILDER_ENDPOINT")
echo $builder_option

if [ "$HIVE_ETH2_MERGE_ENABLED" != "" ]; then
echo -n "0x7365637265747365637265747365637265747365637265747365637265747365" > /jwtsecret
Expand All @@ -61,7 +63,7 @@ echo Starting Teku Beacon Node
--eth1-deposit-contract-address="${HIVE_ETH2_CONFIG_DEPOSIT_CONTRACT_ADDRESS:-0x1111111111111111111111111111111111111111}" \
--log-destination console \
--logging="$LOG" \
$metrics_option $eth1_option $merge_option $enr_option $static_option $opt_sync_option \
$metrics_option $eth1_option $merge_option $enr_option $static_option $opt_sync_option $builder_option \
--validators-proposer-default-fee-recipient="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" \
--p2p-port="${HIVE_ETH2_P2P_TCP_PORT:-9000}" \
--p2p-udp-port="${HIVE_ETH2_P2P_UDP_PORT:-9000}" \
Expand Down
6 changes: 5 additions & 1 deletion clients/teku-vc/teku_vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ case "$HIVE_LOGLEVEL" in
5) LOG=TRACE ;;
esac

builder_option=$([[ "$HIVE_ETH2_BUILDER_ENDPOINT" == "" ]] && echo "" || echo "--validators-proposer-blinded-blocks-enabled=true --validators-builder-registration-default-enabled=true")
echo $builder_option

echo Starting Teku Validator Client

/opt/teku/bin/teku vc \
Expand All @@ -34,4 +37,5 @@ echo Starting Teku Validator Client
--logging="$LOG" \
--validator-keys=/data/validators/keys:/data/validators/passwords \
--validators-proposer-default-fee-recipient="0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" \
--validators-external-signer-slashing-protection-enabled=true
--validators-external-signer-slashing-protection-enabled=true \
$builder_option
15 changes: 15 additions & 0 deletions simulators/eth2/common/builder/builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package builder

import (
api "github.com/ethereum/go-ethereum/core/beacon"
beacon "github.com/protolambda/zrnt/eth2/beacon/common"
)

type Builder interface {
Address() string
Cancel() error
GetBuiltPayloadsCount() int
GetSignedBeaconBlockCount() int
GetModifiedPayloads() map[beacon.Slot]*api.ExecutableData
GetBuiltPayloads() map[beacon.Slot]*api.ExecutableData
}
30 changes: 30 additions & 0 deletions simulators/eth2/common/builder/mock/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Hive Configurable Builder API Mock Server

Instantiates a server that listens for Builder API (https://github.com/ethereum/builder-specs/) directives and responds with payloads built using an execution client.

The builder can inject modifications into the built payloads at predefined slots by using configurable callbacks:
- Before sending the ForkchoiceUpdated directive to the execution client, by modifying the payload attributes, using `WithPayloadAttributesModifier` option
- Before responding with the build payload to the consensus client by modifying the any field in the payload, using `WithPayloadModifier` option

Both callbacks are supplied with either the `PayloadAttributesV1`/`PayloadAttributesV2` or the `ExecutionPayloadV1`/`ExecutionPayloadV2` object, and the beacon slot number of the payload request.

The callbacks must respond with a boolean indicating whether any modification was performed, and an error, if any.

The builder can also be configured to insert an error on:
- `/eth/v1/builder/header/{slot}/{parent_hash}/{pubkey}` using `WithErrorOnHeaderRequest` option
- `/eth/v1/builder/blinded_blocks` using `WithErrorOnPayloadReveal` option

Both callbacks are supplied with the beacon slot number of the payload/blinded block request.

The callback can then use the slot number to determine whether to throw an error or not.

Currently, the builder will produce payloads with the following correct fields:
- PrevRandao
- Timestamp
- SuggestedFeeRecipient
- Withdrawals

For the builder to function properly, the following parameters are necessary:
- Execution client: Required to build the payloads
- Beacon client: Required to fetch the state of the previous slot, and calculate, e.g., the prevrandao value
- Beacon Spec: Required so the builder is aware of fork specific changes in the built payloads, as well as the beacon blocks
Loading