Skip to content

Commit

Permalink
Added lighthouse validator for geth node
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaven committed Oct 31, 2023
1 parent dfb12f0 commit 8c3b7de
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
18 changes: 13 additions & 5 deletions GethNode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ RUN apt-get update -y && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:ethereum/ethereum

# Version configurations
ARG ETH_VER=1.13.4+build29068+jammy
ARG PRYSM_VER=v4.1.1
ARG LIGHTHOUSE_VER=v4.5.0

# Geth
ARG ETH_VER=1.13.4+build29068+jammy
RUN apt-get update -y && \
apt-get install -y \
ethereum=${ETH_VER} \
Expand All @@ -35,17 +31,29 @@ RUN apt-get update -y && \
curl

# Prysm
ARG PRYSM_VER=v4.1.1
RUN mkdir /opt/prysm
RUN curl -L https://github.com/prysmaticlabs/prysm/raw/${PRYSM_VER}/prysm.sh \
--output /opt/prysm/prysm.sh
RUN chmod 755 /opt/prysm/prysm.sh

# Lighthouse
ARG LIGHTHOUSE_VER=v4.5.0
RUN mkdir /opt/lighthouse
RUN curl -L https://github.com/sigp/lighthouse/releases/download/${LIGHTHOUSE_VER}/lighthouse-${LIGHTHOUSE_VER}-$(uname -m)-unknown-linux-gnu.tar.gz \
--output /opt/lighthouse/lighthouse-linux-gnu.tar.gz
RUN tar -xvf /opt/lighthouse/lighthouse-linux-gnu.tar.gz -C /opt/lighthouse
RUN chmod 755 /opt/lighthouse/lighthouse

# staking-deposit-cli
ARG STAKE_CLI_VER=v2.7.0
ARG STAKE_CLI_HASH=fdab65d
RUN mkdir /opt/staking-deposit-cli
RUN export ARCH=`uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/` && \
curl -L https://github.com/ethereum/staking-deposit-cli/releases/download/${STAKE_CLI_VER}/staking_deposit-cli-${STAKE_CLI_HASH}-linux-${ARCH}.tar.gz \
--output /opt/staking-deposit-cli/staking-deposit-cli.tar.gz && \
export ARCH=""
RUN tar -xvf /opt/staking-deposit-cli/staking-deposit-cli.tar.gz --strip-components=2 -C /opt/staking-deposit-cli
################################################################################

ENV DEBIAN_FRONTEND=
Expand Down
37 changes: 37 additions & 0 deletions GethNode/init-geth
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ def RunConsCltLighthouse() -> subprocess.Popen:
return lighthouseProc


def RunValiCltLighthouse() -> subprocess.Popen:
lighthouseAddArgs = []
envVal = os.getenv('V_LIGHTHOUSE_OPTS', None)
if envVal is not None:
lighthouseAddArgs = shlex.split(envVal)

lighthouseCmd = [
'/opt/lighthouse/lighthouse',
'validator_client',
'--beacon-nodes', 'http://localhost:5052',
] + lighthouseAddArgs

lighthouseEnv = {
'PATH': os.environ.get('PATH', ''),
}

lighthouseProc = subprocess.Popen(
lighthouseCmd,
env=lighthouseEnv,
stdout=sys.stdout,
stderr=sys.stderr
)
return lighthouseProc


def TerminateProc(proc: subprocess.Popen) -> None:
while proc.poll() is None:
proc.terminate()
Expand Down Expand Up @@ -137,6 +162,16 @@ def main():
'Unknown consensus client selection: {}'.format(consCltSelect)
)

valiCltSelect = os.getenv('ETH_VALI_CLT', None)
if valiCltSelect == 'lighthouse':
valiCltProc = RunValiCltLighthouse()
elif valiCltSelect is not None:
raise RuntimeError(
'Unknown validator client selection: {}'.format(valiCltSelect)
)
else:
print('Validator client disabled.')

# register signal handler
signal.signal(signal.SIGTERM, OnTerminate)
signal.signal(signal.SIGINT, OnTerminate)
Expand All @@ -147,6 +182,8 @@ def main():
# terminate processes
TerminateProc(consCltProc)
TerminateProc(execCltProc)
if valiCltProc is not None:
TerminateProc(valiCltProc)


if __name__ == '__main__':
Expand Down

0 comments on commit 8c3b7de

Please sign in to comment.