Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] working diff of latest changes against boonet #2335

Draft
wants to merge 42 commits into
base: boonet
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
60b1c2a
1/n: Remove ForkDataT generic type (#2256)
fridrik01 Dec 15, 2024
c49eafd
2/n: Remove ForkT generic type (#2257)
fridrik01 Dec 15, 2024
8e1de3b
3/n: Remove AttestationDataT generic type (#2259)
fridrik01 Dec 15, 2024
9e5aff0
4/n: Remove DepositT generic type (#2260)
fridrik01 Dec 15, 2024
5b36b2e
5/n: Remove ValidatorT generic type (#2263)
fridrik01 Dec 15, 2024
f47c119
6/n: Remove WithdrawalT generic type (#2264)
fridrik01 Dec 15, 2024
138d6e0
chore(deps): bump github.com/phuslu/log from 1.0.110 to 1.0.113 (#2212)
dependabot[bot] Dec 15, 2024
f6fc5d8
chore(deps): bump github.com/protolambda/zrnt from 0.32.2 to 0.32.3 (…
dependabot[bot] Dec 15, 2024
7013be3
chore(deps): bump github.com/go-playground/validator/v10 from 10.22.0…
dependabot[bot] Dec 15, 2024
0a14e1d
nits (#2016)
abi87 Dec 15, 2024
8e9e4a1
chore(deps): bump github.com/quic-go/quic-go from 0.48.1 to 0.48.2 in…
dependabot[bot] Dec 15, 2024
cc31590
chore(blockchain) : non optimistic client should not request build op…
nidhi-singh02 Dec 16, 2024
98d1225
fix(blockchain): sequential blob `Persist()` DB writes (#2258)
shotes Dec 17, 2024
5246cf5
Support for signed beacon block header and signature verification (#2…
sbudella-gco Dec 17, 2024
3f9fd9d
chore(da): fix broken UT (#2278)
abi87 Dec 17, 2024
2f6789b
1/n Remove ExecutionAddressT generic type (#2266)
fridrik01 Dec 17, 2024
f3b35ee
2/n Remove ExecutionPayloadT generic type (#2272)
fridrik01 Dec 17, 2024
9b90c55
3/n Remove ExecutionPayloadHeaderT generic type. (#2273)
fridrik01 Dec 17, 2024
40cb7a0
Remove BeaconBlockBodyT generic type
fridrik01 Dec 17, 2024
60a96e4
Moved common types back to common package
fridrik01 Dec 17, 2024
502deb9
6/n Remove slashinginfo and slotdata (#2284)
fridrik01 Dec 17, 2024
d3228bc
chore(blobs): Cleanup configurable constants for BlobSidecars (#2262)
shotes Dec 18, 2024
0b784a5
chore(blobs): parallelize blobSidecar header checks (#2286)
shotes Dec 18, 2024
f40a241
Remove PayloadAttributesT generic type
fridrik01 Dec 17, 2024
1dcbf4d
fix: remove err check for nil to address nilaway false positive
fridrik01 Dec 17, 2024
c08698e
appease nilaway
abi87 Dec 18, 2024
bd74b71
feat(state-transition): add deposits root to beacon state (#2296)
abi87 Dec 20, 2024
f30b1db
chore(state): cleanup deposits special casing (#2304)
calbera Dec 20, 2024
e5e526b
chore(all): update cosmos-sdk deps (#2221)
abi87 Dec 20, 2024
b04368c
Updated go.mod and go.sum to pull latest version of cometbft.
alesforz Dec 20, 2024
582b803
8/n Remove BlobSidecarT and BlobSidecarsT generic type (#2307)
fridrik01 Dec 20, 2024
497c9b4
9/n Remove PayloadIDT generic type (#2293)
fridrik01 Dec 20, 2024
b0cc796
Merge pull request #2309 from informalsystems/alesforz/bls-type-is-ptr
fridrik01 Dec 20, 2024
f9e2640
Enable nilaway on CI and remove build tags from linters (#2310)
fridrik01 Dec 20, 2024
7e5f02d
10/n Remove BeaconBlockT and BeaconStateT generic types (#2297)
fridrik01 Dec 20, 2024
0a2b137
chore(blobs): Validate `Index` field in `BlobSidecar` during processi…
shotes Dec 20, 2024
763d7d8
fix(blobs): Validate sidecar `KzgCommitments` and disallow sidecar om…
shotes Dec 20, 2024
8ec48e5
chore(state): use passed in context from comet during process proposa…
calbera Dec 20, 2024
f2c6e5c
chore(blobs): remove `Len`, `GetSidecars`, and `Get` from `BlobSideca…
shotes Dec 20, 2024
c988366
Add make lint-ci which runs all CI linters (#2314)
fridrik01 Dec 20, 2024
4c7ff6d
fix: timeout_commit defaults to 0 in init (#2312)
fridrik01 Dec 20, 2024
1e1a869
chore(test): readme for e2e-test (#2316)
nidhi-singh02 Dec 20, 2024
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
36 changes: 17 additions & 19 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@
cancel-in-progress: ${{ !(github.base_ref == 'refs/heads/main' && github.event_name == 'merge_group') || github.ref != 'refs/heads/main' }}

env:
GCP_ID_PROVIDER: 'projects/341806074811/locations/global/workloadIdentityPools/oidc-apps-automation-st-01-pool/providers/gh-apps-oidc-provider'
GCP_SERVICE_ACCOUNT: 'sa-apps-deployment@prj-berachain-automation-st-01.iam.gserviceaccount.com'
GCP_ID_PROVIDER: "projects/341806074811/locations/global/workloadIdentityPools/oidc-apps-automation-st-01-pool/providers/gh-apps-oidc-provider"
GCP_SERVICE_ACCOUNT: "sa-apps-deployment@prj-berachain-automation-st-01.iam.gserviceaccount.com"
GCP_REGISTRY: northamerica-northeast1-docker.pkg.dev
GHCR_REGISTRY: ghcr.io
PUSH_DOCKER_IMAGE: ${{ (github.base_ref == github.head_ref && github.event_name == 'push') || github.ref == 'refs/tags/v*'}}
VERSION: ${{ github.ref_name }}

jobs:

# -------------------------------------------------------------------------- #
# Main Pipeline #
# -------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# Main Pipeline #
# -------------------------------------------------------------------------- #

ci:
strategy:
Expand Down Expand Up @@ -90,7 +89,7 @@
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: "1.23.0"
go-version: "1.23.4"
check-latest: true
cache-dependency-path: "**/*.sum"
if: ${{ !(matrix.args == 'test-forge-cover' || matrix.args == 'test-forge-fuzz') }}
Expand All @@ -106,10 +105,9 @@
files: ./${{ matrix.args }}.txt
if: ${{ matrix.args == 'test-unit-cover' || matrix.args == 'test-forge-cover'}}


# -------------------------------------------------------------------------- #
# E2E Testing #
# -------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# E2E Testing #
# -------------------------------------------------------------------------- #

ci-e2e:
strategy:
Expand Down Expand Up @@ -155,9 +153,9 @@
env:
GOPATH: /home/runner/go

# -------------------------------------------------------------------------- #
# Docker Container Build and Push #
# -------------------------------------------------------------------------- #
# -------------------------------------------------------------------------- #
# Docker Container Build and Push #
# -------------------------------------------------------------------------- #

build-and-push-container:
runs-on:
Expand Down Expand Up @@ -203,15 +201,15 @@

- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Authenticate to Google Cloud
id: 'auth'
uses: 'google-github-actions/auth@v2'
id: "auth"
uses: "google-github-actions/auth@v2"

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'pipeline' step
Uses Step: auth
uses 'google-github-actions/auth' with ref 'v2', not a pinned commit hash
with:
workload_identity_provider: ${{ env.GCP_ID_PROVIDER }}
service_account: ${{ env.GCP_SERVICE_ACCOUNT }}

- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'pipeline' step
Uses Step
uses 'google-github-actions/setup-gcloud' with ref 'v2', not a pinned commit hash

- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Setup Docker to use Google Cloud OIDC
Expand All @@ -221,4 +219,4 @@
- if: ${{ env.PUSH_DOCKER_IMAGE == 'true' }}
name: Push Docker image
run: |
make push-docker-gcp push-docker-github
make push-docker-gcp push-docker-github
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ site/
contracts/cache
contracts/out
tmp/
cscope.files

##########
# Golang #
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
### Stage 0 - Build Arguments ###
#######################################################

ARG GO_VERSION=1.23.0
ARG GO_VERSION=1.23.4
ARG RUNNER_IMAGE=alpine:3.20
ARG BUILD_TAGS="netgo,muslc,blst,bls12381,pebbledb"
ARG NAME=beacond
Expand Down
10 changes: 5 additions & 5 deletions beacon/blockchain/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (
const defaultRetryInterval = 20 * time.Second

func (s *Service[
_, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) depositFetcher(
ctx context.Context,
blockNum math.U64,
) {
if blockNum < s.eth1FollowDistance {
if blockNum <= s.eth1FollowDistance {
s.logger.Info(
"depositFetcher, nothing to fetch",
"block num", blockNum,
Expand All @@ -52,7 +52,7 @@ func (s *Service[
}

func (s *Service[
_, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) fetchAndStoreDeposits(
ctx context.Context,
blockNum math.U64,
Expand All @@ -78,7 +78,7 @@ func (s *Service[
)
}

if err = s.depositStore.EnqueueDeposits(deposits); err != nil {
if err = s.storageBackend.DepositStore().EnqueueDeposits(deposits); err != nil {
s.logger.Error("Failed to store deposits", "error", err)
s.failedBlocksMu.Lock()
s.failedBlocks[blockNum] = struct{}{}
Expand All @@ -92,7 +92,7 @@ func (s *Service[
}

func (s *Service[
_, _, ConsensusBlockT, _, _, _, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) depositCatchupFetcher(ctx context.Context) {
ticker := time.NewTicker(defaultRetryInterval)
defer ticker.Stop()
Expand Down
2 changes: 2 additions & 0 deletions beacon/blockchain/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import "github.com/berachain/beacon-kit/errors"
var (
// ErrNilBlk is an error for when the beacon block is nil.
ErrNilBlk = errors.New("nil beacon block")
// ErrNilBlob is an error for when the BlobSidecars is nil.
ErrNilBlob = errors.New("nil blob")
// ErrDataNotAvailable indicates that the required data is not available.
ErrDataNotAvailable = errors.New("data not available")
)
113 changes: 21 additions & 92 deletions beacon/blockchain/execution_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ package blockchain

import (
"context"
"time"

payloadtime "github.com/berachain/beacon-kit/beacon/payload-time"
"github.com/berachain/beacon-kit/config/spec"
ctypes "github.com/berachain/beacon-kit/consensus-types/types"
engineprimitives "github.com/berachain/beacon-kit/engine-primitives/engine-primitives"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
)

// sendPostBlockFCU sends a forkchoice update to the execution client.
// sendPostBlockFCU sends a forkchoice update to the execution client after a
// block is finalized.This function should only be used to notify
// the EL client of the new head and should not request optimistic builds, as:
// Optimistic clients already request builds in handleOptimisticPayloadBuild()
// Non-optimistic clients should never request optimistic builds.
func (s *Service[
_, _, ConsensusBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) sendPostBlockFCU(
ctx context.Context,
st BeaconStateT,
st *statedb.StateDB,
blk ConsensusBlockT,
) {
lph, err := st.GetLatestExecutionPayloadHeader()
Expand All @@ -46,95 +49,21 @@ func (s *Service[
return
}

if !s.shouldBuildOptimisticPayloads() && s.localBuilder.Enabled() {
s.sendNextFCUWithAttributes(ctx, st, blk, lph)
} else {
s.sendNextFCUWithoutAttributes(ctx, blk, lph)
}
}

// sendNextFCUWithAttributes sends a forkchoice update to the execution
// client with attributes.
func (s *Service[
_, _, ConsensusBlockT, _, _, BeaconStateT, _,
_, _, ExecutionPayloadHeaderT, _, _, _, _,
]) sendNextFCUWithAttributes(
ctx context.Context,
st BeaconStateT,
blk ConsensusBlockT,
lph ExecutionPayloadHeaderT,
) {
beaconBlk := blk.GetBeaconBlock()

stCopy := st.Copy()
if _, err := s.stateProcessor.ProcessSlots(
stCopy, beaconBlk.GetSlot()+1,
); err != nil {
s.logger.Error(
"failed to process slots in non-optimistic payload",
"error", err,
)
return
}

nextPayloadTime := payloadtime.Next(
blk.GetConsensusTime(),
lph.GetTimestamp(),
true, // buildOptimistically
).Unwrap()

// We set timestamp check on Bartio for backward compatibility reasons
// TODO: drop this we drop other Bartio special cases.
if s.chainSpec.DepositEth1ChainID() == spec.BartioChainID {
nextPayloadTime = max(
//#nosec:G701
uint64(time.Now().Unix()+1),
uint64((lph.GetTimestamp() + 1)),
)
}

prevBlockRoot := beaconBlk.HashTreeRoot()
if _, err := s.localBuilder.RequestPayloadAsync(
ctx,
stCopy,
beaconBlk.GetSlot()+1,
nextPayloadTime,
prevBlockRoot,
lph.GetBlockHash(),
lph.GetParentHash(),
); err != nil {
s.logger.Error(
"failed to send forkchoice update with attributes in non-optimistic payload",
"error",
err,
)
}
}

// sendNextFCUWithoutAttributes sends a forkchoice update to the
// execution client without attributes.
func (s *Service[
_, _, ConsensusBlockT, _, _, _, _, _, _,
ExecutionPayloadHeaderT, _, _, _, PayloadAttributesT,
]) sendNextFCUWithoutAttributes(
ctx context.Context,
blk ConsensusBlockT,
lph ExecutionPayloadHeaderT,
) {
// Send a forkchoice update without payload attributes to notify
// EL of the new head.
beaconBlk := blk.GetBeaconBlock()

if _, _, err := s.executionEngine.NotifyForkchoiceUpdate(
if _, _, err = s.executionEngine.NotifyForkchoiceUpdate(
ctx,
// TODO: Switch to New().
engineprimitives.
BuildForkchoiceUpdateRequestNoAttrs[PayloadAttributesT](
&engineprimitives.ForkchoiceStateV1{
HeadBlockHash: lph.GetBlockHash(),
SafeBlockHash: lph.GetParentHash(),
FinalizedBlockHash: lph.GetParentHash(),
},
s.chainSpec.ActiveForkVersionForSlot(beaconBlk.GetSlot()),
),
ctypes.
BuildForkchoiceUpdateRequestNoAttrs(
&engineprimitives.ForkchoiceStateV1{
HeadBlockHash: lph.GetBlockHash(),
SafeBlockHash: lph.GetParentHash(),
FinalizedBlockHash: lph.GetParentHash(),
},
s.chainSpec.ActiveForkVersionForSlot(beaconBlk.GetSlot()),
),
); err != nil {
s.logger.Error(
"failed to send forkchoice update without attributes",
Expand Down
31 changes: 16 additions & 15 deletions beacon/blockchain/finalize_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import (
"github.com/berachain/beacon-kit/consensus/types"
"github.com/berachain/beacon-kit/primitives/math"
"github.com/berachain/beacon-kit/primitives/transition"
statedb "github.com/berachain/beacon-kit/state-transition/core/state"
cmtabci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (s *Service[
_, _, ConsensusBlockT, BeaconBlockT, _, _, _,
_, _, _, GenesisT, ConsensusSidecarsT, BlobSidecarsT, _,
_, _, ConsensusBlockT, _,
GenesisT, ConsensusSidecarsT,
]) FinalizeBlock(
ctx sdk.Context,
req *cmtabci.FinalizeBlockRequest,
Expand All @@ -46,13 +47,13 @@ func (s *Service[

// STEP 1: Decode blok and blobs
blk, blobs, err := encoding.
ExtractBlobsAndBlockFromRequest[BeaconBlockT, BlobSidecarsT](
req,
BeaconBlockTxIndex,
BlobSidecarsTxIndex,
s.chainSpec.ActiveForkVersionForSlot(
math.Slot(req.Height),
))
ExtractBlobsAndBlockFromRequest(
req,
BeaconBlockTxIndex,
BlobSidecarsTxIndex,
s.chainSpec.ActiveForkVersionForSlot(
math.Slot(req.Height),
))
if err != nil {
//nolint:nilerr // If we don't have a block, we can't do anything.
return nil, nil
Expand All @@ -69,7 +70,7 @@ func (s *Service[
}

// STEP 3: finalize the block
var consensusBlk *types.ConsensusBlock[BeaconBlockT]
var consensusBlk *types.ConsensusBlock
consensusBlk = consensusBlk.New(
blk,
req.GetProposerAddress(),
Expand Down Expand Up @@ -97,7 +98,7 @@ func (s *Service[

// store the finalized block in the KVStore.
slot := blk.GetSlot()
if err = s.blockStore.Set(blk); err != nil {
if err = s.storageBackend.BlockStore().Set(blk); err != nil {
s.logger.Error(
"failed to store block", "slot", slot, "error", err,
)
Expand All @@ -117,10 +118,10 @@ func (s *Service[
// finalizeBeaconBlock receives an incoming beacon block, it first validates
// and then processes the block.
func (s *Service[
_, _, ConsensusBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) finalizeBeaconBlock(
ctx context.Context,
st BeaconStateT,
st *statedb.StateDB,
blk ConsensusBlockT,
) (transition.ValidatorUpdates, error) {
beaconBlk := blk.GetBeaconBlock()
Expand Down Expand Up @@ -148,10 +149,10 @@ func (s *Service[

// executeStateTransition runs the stf.
func (s *Service[
_, _, ConsensusBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _,
_, _, ConsensusBlockT, _, _, _,
]) executeStateTransition(
ctx context.Context,
st BeaconStateT,
st *statedb.StateDB,
blk ConsensusBlockT,
) (transition.ValidatorUpdates, error) {
startTime := time.Now()
Expand Down
Loading
Loading