Skip to content

Commit

Permalink
feat(engine): Refactor engine client (berachain#89)
Browse files Browse the repository at this point in the history
* engine client refactor

* address pos comment

* basic tests for sanity

* test build headers

* proper check for the key thing

* gib fix

* deadline

* address

* add comment

* feat(types): removing more prysm types (berachain#90)

* bet

* keep going

* bing bong

* cleanup

* fix nil ptr issue

* remove third_party

* refactor engine

* remove payload attributer

* bet

* comments

* henlo

* get payload refactor

* dctx

* bet

* bet

* bet

* remove ded function

* add service_registry tests

* merge main

* Update execution.go

Signed-off-by: Devon Bear <[email protected]>

---------

Signed-off-by: Devon Bear <[email protected]>

* merge main

* fix mockery

---------

Signed-off-by: Devon Bear <[email protected]>
  • Loading branch information
itsdevbear authored Feb 12, 2024
1 parent 9f69e3f commit c968d4f
Show file tree
Hide file tree
Showing 62 changed files with 1,535 additions and 884 deletions.
5 changes: 5 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ packages:
recursive: True
with-expecter: true
all: True
github.com/itsdevbear/bolaris/execution/engine/ethclient:
config:
recursive: True
with-expecter: true
include-regex: GethRPCClient
github.com/itsdevbear/bolaris/runtime/service:
config:
recursive: True
Expand Down
2 changes: 1 addition & 1 deletion beacon/blockchain/finalize_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package blockchain
import (
"context"

"github.com/itsdevbear/bolaris/third_party/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
)

Expand Down
4 changes: 2 additions & 2 deletions beacon/blockchain/payload_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import (
"time"

"github.com/itsdevbear/bolaris/beacon/core"
payloadattribute "github.com/prysmaticlabs/prysm/v4/consensus-types/payload-attribute"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
)

// getPayloadAttribute returns the payload attributes for the given state and slot.
// The attribute is required to initiate a payload build process in the
// context of an `engine_forkchoiceUpdated` call.
func (s *Service) getPayloadAttribute(
ctx context.Context,
) payloadattribute.Attributer {
) interfaces.PayloadAttributer {
var (
// NOTE: We have to use time.Now() and not the time on the block header coming from
// Comet or else we attempt to build a block at an equivalent timestamp to the last.
Expand Down
4 changes: 2 additions & 2 deletions beacon/blockchain/process_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"context"

"github.com/cosmos/cosmos-sdk/telemetry"
"github.com/ethereum/go-ethereum/common"
"github.com/itsdevbear/bolaris/beacon/execution"
"github.com/itsdevbear/bolaris/third_party/go-ethereum/common"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
payloadattribute "github.com/prysmaticlabs/prysm/v4/consensus-types/payload-attribute"
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func (s *Service) postBlockProcess(
// TODO: we should probably just have a validator job in the background that is
// constantly building new payloads and then not worry about anything here triggering
// payload builds.
var attrs payloadattribute.Attributer
var attrs interfaces.PayloadAttributer
if s.BeaconCfg().Validator.PrepareAllPayloads {
attrs = s.getPayloadAttribute(ctx)
} else {
Expand Down
6 changes: 3 additions & 3 deletions beacon/blockchain/receive_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"errors"
"fmt"

"github.com/itsdevbear/bolaris/beacon/execution"
eth "github.com/itsdevbear/bolaris/execution/engine/ethclient"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
"golang.org/x/sync/errgroup"
)
Expand Down Expand Up @@ -122,11 +122,11 @@ func (s *Service) validateExecutionOnBlock(
}

isValidPayload, err := s.en.NotifyNewPayload(ctx, 0, header)
if err != nil && errors.Is(err, execution.ErrAcceptedSyncingPayloadStatus) {
if err != nil && errors.Is(err, eth.ErrAcceptedSyncingPayloadStatus) {
s.Logger().Error("Failed to validate execution on block", "error", err)
return isValidPayload, err
} else if err != nil || !isValidPayload {
return isValidPayload, execution.ErrInvalidPayloadStatus
return isValidPayload, eth.ErrInvalidPayloadStatus
}
return isValidPayload, nil
}
4 changes: 2 additions & 2 deletions beacon/blockchain/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ package blockchain
import (
"context"

"github.com/ethereum/go-ethereum/common"
"github.com/itsdevbear/bolaris/beacon/execution"
"github.com/itsdevbear/bolaris/third_party/go-ethereum/common"
enginev1 "github.com/itsdevbear/bolaris/third_party/prysm/proto/engine/v1"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
"github.com/itsdevbear/bolaris/types/consensus/primitives"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
)

type ExecutionService interface {
Expand Down
7 changes: 4 additions & 3 deletions beacon/core/payload_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import (

"github.com/itsdevbear/bolaris/beacon/state"
"github.com/itsdevbear/bolaris/config"
enginev1 "github.com/itsdevbear/bolaris/third_party/prysm/proto/engine/v1"
"github.com/itsdevbear/bolaris/types/consensus/interfaces"
"github.com/itsdevbear/bolaris/types/consensus/version"
payloadattribute "github.com/prysmaticlabs/prysm/v4/consensus-types/payload-attribute"
enginev1 "github.com/prysmaticlabs/prysm/v4/proto/engine/v1"
)

// BuildPayloadAttributes builds payload attributes for a given state.
Expand All @@ -43,9 +44,9 @@ func BuildPayloadAttributes(
prevRando []byte,
headRoot []byte,
t uint64,
) payloadattribute.Attributer {
) interfaces.PayloadAttributer {
emptyAttri := payloadattribute.EmptyWithVersion(st.Version())
var attr payloadattribute.Attributer
var attr interfaces.PayloadAttributer
switch st.Version() {
case version.Deneb:
withdrawals, err := st.ExpectedWithdrawals()
Expand Down
200 changes: 0 additions & 200 deletions beacon/execution/engine/engine.go

This file was deleted.

Loading

0 comments on commit c968d4f

Please sign in to comment.