Skip to content

Commit

Permalink
time measure and 5 nodes setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lucca30 committed Feb 17, 2025
1 parent 583885e commit af792eb
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# ignore build
build
engine-api-poc/build
logs
*.log

Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,25 @@ release:
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate

###############################################################################
### Engine API POC ###
###############################################################################

engine-api-poc-init-heimdall:
ARCH=$(ARCH) docker compose -f ./engine-api-poc/docker-compose.yaml up --build heimdalld-init
.PHONY: engine-api-poc-init

engine-api-poc-init-erigon:
ARCH=$(ARCH) docker compose -f ./engine-api-poc/docker-compose.yaml up erigon-init
.PHONY: engine-api-poc-init

engine-api-poc-run-erigon: ## run erigon nodes using docker
ARCH=$(ARCH) docker compose -f ./engine-api-poc/docker-compose.yaml up -d erigon-0 erigon-1 erigon-2 erigon-3 erigon-4
.PHONY: engine-api-poc-run-erigon

engine-api-poc-run-heimdall: ## run erigon nodes using docker
ARCH=$(ARCH) docker compose -f ./engine-api-poc/docker-compose.yaml up -d node0 node1 node2 node3 node4
.PHONY: engine-api-poc-run-heimdall

.PHONY: help
help:
Expand Down
21 changes: 20 additions & 1 deletion app/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type HeimdallMetadata struct {
func (app *HeimdallApp) NewPrepareProposalHandler() sdk.PrepareProposalHandler {
return func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) {
logger := app.Logger()
start := time.Now()

if err := ValidateVoteExtensions(ctx, req.Height, req.ProposerAddress, req.LocalLastCommit.Votes, req.LocalLastCommit.Round, app.StakeKeeper); err != nil {
logger.Error("Error occurred while validating VEs in PrepareProposal", err)
Expand Down Expand Up @@ -151,6 +152,9 @@ func (app *HeimdallApp) NewPrepareProposalHandler() sdk.PrepareProposalHandler {
txs = append(txs, proposedTx)
}

duration := time.Since(start)
formatted := fmt.Sprintf("%.6fms", float64(duration)/float64(time.Millisecond))
logger.Info("🕒 PrepareProposal:" + formatted)
return &abci.ResponsePrepareProposal{Txs: txs}, nil
}
}
Expand All @@ -160,6 +164,7 @@ func (app *HeimdallApp) NewPrepareProposalHandler() sdk.PrepareProposalHandler {
func (app *HeimdallApp) NewProcessProposalHandler() sdk.ProcessProposalHandler {
return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
logger := app.Logger()
start := time.Now()

// check if there are any txs in the request
if len(req.Txs) < 1 {
Expand Down Expand Up @@ -243,6 +248,9 @@ func (app *HeimdallApp) NewProcessProposalHandler() sdk.ProcessProposalHandler {
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil
}

duration := time.Since(start)
formatted := fmt.Sprintf("%.6fms", float64(duration)/float64(time.Millisecond))
logger.Info("🕒 ProcessProposal:" + formatted)
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil
}
}
Expand All @@ -252,6 +260,7 @@ func (app *HeimdallApp) ExtendVoteHandler() sdk.ExtendVoteHandler {
return func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) {
logger := app.Logger()
logger.Debug("Extending Vote!", "height", ctx.BlockHeight())
start := time.Now()

// check if VEs are enabled
if err := checkIfVoteExtensionsDisabled(ctx, req.Height); err != nil {
Expand Down Expand Up @@ -355,6 +364,9 @@ func (app *HeimdallApp) ExtendVoteHandler() sdk.ExtendVoteHandler {
return nil, err
}

duration := time.Since(start)
formatted := fmt.Sprintf("%.6fms", float64(duration)/float64(time.Millisecond))
logger.Info("🕒 ExtendVote:" + formatted)
return &abci.ResponseExtendVote{VoteExtension: bz, NonRpExtension: nonRpVoteExt}, nil
}
}
Expand All @@ -364,6 +376,7 @@ func (app *HeimdallApp) VerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHand
return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) {
logger := app.Logger()
logger.Debug("Verifying vote extension", "height", ctx.BlockHeight())
start := time.Now()

// check if VEs are enabled
if err := checkIfVoteExtensionsDisabled(ctx, req.Height); err != nil {
Expand Down Expand Up @@ -407,13 +420,17 @@ func (app *HeimdallApp) VerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHand
}
}

duration := time.Since(start)
formatted := fmt.Sprintf("%.6fms", float64(duration)/float64(time.Millisecond))
logger.Info("🕒 VerifyVote:" + formatted)
return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil
}
}

// PreBlocker application updates every pre block
func (app *HeimdallApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) {
logger := app.Logger()
start := time.Now()

if err := checkIfVoteExtensionsDisabled(ctx, req.Height+1); err != nil {
return nil, err
Expand Down Expand Up @@ -584,7 +601,9 @@ func (app *HeimdallApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlo

}
}

duration := time.Since(start)
formatted := fmt.Sprintf("%.6fms", float64(duration)/float64(time.Millisecond))
logger.Info("🕒 PreBlocker:" + formatted)
return app.ModuleManager.PreBlock(ctx)
}

Expand Down
15 changes: 15 additions & 0 deletions engine-api-poc/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ERIGON_NODE_PK_0=7d05b4bdbd6122d69a78b55067a7c2cf0a00f379d7ab464d7451e779a9156232
ERIGON_NODE_P2P_KEY_0=bc86aef702b4a051ef433a558cdf2fed61dcc8115737b9b268b4656ba46d453a55f3b14d65393f9c9dd6e777a406d3d4603ad8f530638f93c79e878b7755ff85

ERIGON_NODE_PK_1=1404ac0beb320ad28843b7b1b3864fea433249d017e53aa42739d3a9d4e07104
ERIGON_NODE_P2P_KEY_1=53598b5fa00971bd89c71386a0b55fd9ef143a23b004524731572fdc3d179e563e45bdbddef6efa10a1bc0cfd259c6bbbfa09ebd5e045fcc1fa5b437fed79ae3

ERIGON_NODE_PK_2=9cae6d35022694bbad93c943eb01e1d1add02bf8e5c4f284d8f6eaa83fed95f5
ERIGON_NODE_P2P_KEY_2=1553bfad397d2eb79c679e2840286fd9d7f4289d0bca10f8eeb897579e4cde1dbbfe5ff7d4e0a72ec29e7c0bdd8093b96b1a4b924a2cb9f7e461015f5623b898

ERIGON_NODE_PK_3=264e2d10c13c7ae6262fec1ec2714eb7f3da0854a89f5a4c08bdccc8fd0e8acd
ERIGON_NODE_P2P_KEY_3=260c5c1b6c09b59aa58516ffdeabd98d14efd9ac9cdf518669aede3b31dac996d5f7352a7455653efba0306211d2472f71e289fc6f573b5f2a406209aa4f82b8

ERIGON_NODE_PK_4=0c2ff7a6abeb66c4a4f23539f478dd6b73619682f0ba28e4a900a24f5c5d1677
ERIGON_NODE_P2P_KEY_4=0efcc3fc9a9618bb339655f18164912bcceec2c194570df91a9b258dc22b4402a0f0280c20749503c1079c41771c03ad08dc16c83258c1921c67a1aaefc65990

10 changes: 10 additions & 0 deletions engine-api-poc/Dockerfile.erigon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Use root to ensure permission changes work
FROM public.ecr.aws/alluvial/thorax/erigon:v2.52.5

USER root
COPY ./engine-api-poc/init-erigon-script.sh .
COPY ./engine-api-poc/genesis.json .

# Ensure correct ownership and permissions
RUN chown root:root ./init-erigon-script.sh && chmod +x ./init-erigon-script.sh

20 changes: 20 additions & 0 deletions engine-api-poc/Dockerfile.heimdalld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# TODO-HV2: check this file once we have a proper build
FROM golang:latest

ARG HEIMDALL_DIR=/var/lib/heimdall
ENV HEIMDALL_DIR=$HEIMDALL_DIR

RUN apt-get update -y && apt-get upgrade -y \
&& apt install build-essential git -y \
&& mkdir -p $HEIMDALL_DIR

WORKDIR ${HEIMDALL_DIR}
COPY . .

RUN make heimdalld && cp build/heimdalld /usr/local/bin/
RUN chmod +x ./engine-api-poc/init-heimdalld-script.sh


ENV SHELL /bin/bash
EXPOSE 1317 26656 26657

Loading

0 comments on commit af792eb

Please sign in to comment.