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

feat(rpc): Custom RPC types #1893

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0eec5fd
bet
itsdevbear Aug 14, 2024
d3907f4
bet
itsdevbear Aug 14, 2024
d828672
bet
itsdevbear Aug 14, 2024
17a7b79
bet
itsdevbear Aug 14, 2024
a2547f1
bet
itsdevbear Aug 14, 2024
4ca0c57
bet
itsdevbear Aug 14, 2024
39c3e7d
bet
itsdevbear Aug 14, 2024
441a038
bet
itsdevbear Aug 14, 2024
fe9fd58
bet
itsdevbear Aug 14, 2024
5f56fe7
bet
itsdevbear Aug 14, 2024
57a3bf3
bet
itsdevbear Aug 14, 2024
fbcf372
bet
itsdevbear Aug 14, 2024
85e1837
bet
itsdevbear Aug 14, 2024
cd8e51d
bet
itsdevbear Aug 14, 2024
799feb1
bet
itsdevbear Aug 14, 2024
569a674
bet
itsdevbear Aug 14, 2024
f1a2945
bet
itsdevbear Aug 14, 2024
92b3b45
bet
itsdevbear Aug 14, 2024
079fcdc
bet
itsdevbear Aug 14, 2024
31cf017
bet
itsdevbear Aug 15, 2024
cbfac1e
bet
itsdevbear Aug 15, 2024
18237a1
bet
itsdevbear Aug 15, 2024
9c7f44d
bet
itsdevbear Aug 15, 2024
fd90876
bet
itsdevbear Aug 15, 2024
59a20d0
bet
itsdevbear Aug 15, 2024
50b4f0e
Merge branch 'main' into custom-rpc-types
itsdevbear Aug 15, 2024
e919d88
bet
itsdevbear Aug 15, 2024
a767000
Merge branch 'main' into custom-rpc-types
itsdevbear Aug 15, 2024
3fc5350
bet
itsdevbear Aug 15, 2024
939f14b
bet
itsdevbear Aug 15, 2024
53a7ef1
bet
itsdevbear Aug 15, 2024
9f22f3d
bet
itsdevbear Aug 15, 2024
5d9ff65
bet
itsdevbear Aug 15, 2024
347c1d2
Merge branch 'main' into custom-rpc-types
itsdevbear Aug 15, 2024
72ae104
bet
itsdevbear Aug 15, 2024
d7ffc21
merge
itsdevbear Aug 15, 2024
248286c
bet
itsdevbear Aug 15, 2024
19306ce
bet
itsdevbear Aug 15, 2024
a264441
bet
itsdevbear Aug 15, 2024
3dc62f0
bet
itsdevbear Aug 15, 2024
fd0a805
bet
itsdevbear Aug 15, 2024
43799a4
bet
itsdevbear Aug 15, 2024
9b08e28
bet
itsdevbear Aug 15, 2024
af0c586
bet
itsdevbear Aug 15, 2024
9a8fdb4
bet
itsdevbear Aug 15, 2024
88b6899
bet
itsdevbear Aug 15, 2024
70a74c8
Merge branch 'main' into custom-rpc-types
itsdevbear Aug 15, 2024
d198db5
bet
itsdevbear Aug 15, 2024
257e8ba
Merge branch 'main' into custom-rpc-types
itsdevbear Aug 16, 2024
20f7634
Merge branch 'main' of github.com:berachain/beacon-kit into custom-rp…
calbera Oct 1, 2024
ab27640
log generic
calbera Oct 1, 2024
be73fd8
bet
calbera Oct 1, 2024
ce4ad41
Merge branch 'main' into custom-rpc-types
calbera Oct 1, 2024
8e30442
bet
calbera Oct 2, 2024
c528d7e
nits
calbera Oct 2, 2024
0a30dcc
gen
calbera Oct 2, 2024
0486a82
tests
calbera Oct 2, 2024
62d6d23
bet
calbera Oct 2, 2024
a795152
Wipg
calbera Oct 2, 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
20 changes: 11 additions & 9 deletions beacond/cmd/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func DefaultComponents() []any {
*BeaconBlockHeader, *BlobSidecars, *Logger,
],
components.ProvideBeaconDepositContract[
*Deposit, *ExecutionPayload, *ExecutionPayloadHeader,
*Deposit, *ExecutionPayload, *ExecutionPayloadHeader, Log,
*Withdrawal, Withdrawals, WithdrawalCredentials,
calbera marked this conversation as resolved.
Show resolved Hide resolved
],
components.ProvideBlockStore[
*BeaconBlock, *BeaconBlockBody, *BeaconBlockHeader, *Logger,
Expand All @@ -64,7 +65,7 @@ func DefaultComponents() []any {
*AvailabilityStore, *BeaconBlock, *BeaconBlockBody,
*BeaconBlockHeader, *BeaconState, *BeaconStateMarshallable,
*BlobSidecars, *BlockStore, *Deposit, *DepositStore,
*ExecutionPayload, *ExecutionPayloadHeader, *Genesis,
*ExecutionPayload, *ExecutionPayloadHeader, *Log, *Genesis,
*KVStore, *Logger, *StorageBackend,
],
components.ProvideNode,
Expand All @@ -82,27 +83,28 @@ func DefaultComponents() []any {
components.ProvideDBManager[*AvailabilityStore, *DepositStore, *Logger],
components.ProvideDepositPruner[
*BeaconBlock, *BeaconBlockBody, *BeaconBlockHeader,
*Deposit, *DepositStore, *Logger,
*Deposit, *DepositStore, Log, *Logger,
calbera marked this conversation as resolved.
Show resolved Hide resolved
],
components.ProvideDepositService[
*BeaconBlock, *BeaconBlockBody, *BeaconBlockHeader, *Deposit,
*DepositContract, *DepositStore, *ExecutionPayload,
*ExecutionPayloadHeader, *Logger,
*ExecutionPayloadHeader, Log, *Logger,
*Withdrawal, Withdrawals, WithdrawalCredentials,
],
components.ProvideDepositStore[*Deposit],
components.ProvideDispatcher[
*BeaconBlock, *BlobSidecars, *Genesis, *Logger,
],
components.ProvideEngineClient[
*ExecutionPayload, *ExecutionPayloadHeader, *Logger,
*ExecutionPayload, *ExecutionPayloadHeader, *Log, *Logger,
],
components.ProvideExecutionEngine[
*ExecutionPayload, *ExecutionPayloadHeader, *Logger,
*ExecutionPayload, *ExecutionPayloadHeader, *Log, *Logger,
],
components.ProvideJWTSecret,
components.ProvideLocalBuilder[
*BeaconBlockHeader, *BeaconState, *BeaconStateMarshallable,
*ExecutionPayload, *ExecutionPayloadHeader, *KVStore, *Logger,
*ExecutionPayload, *ExecutionPayloadHeader, *Log, *KVStore, *Logger,
],
components.ProvideReportingService[*Logger],
components.ProvideCometBFTService[*Logger],
Expand All @@ -111,7 +113,7 @@ func DefaultComponents() []any {
*BeaconBlockHeader, *BlockStore, *BeaconState,
*BeaconStateMarshallable, *BlobSidecar, *BlobSidecars,
*Deposit, *DepositStore, *ExecutionPayload, *ExecutionPayloadHeader,
*Genesis, *KVStore, *Logger,
Log, *Genesis, *KVStore, *Logger,
NodeAPIContext,
],
components.ProvideSidecarFactory[
Expand All @@ -120,7 +122,7 @@ func DefaultComponents() []any {
components.ProvideStateProcessor[
*BeaconBlock, *BeaconBlockBody, *BeaconBlockHeader,
*BeaconState, *BeaconStateMarshallable, *Deposit, *ExecutionPayload,
*ExecutionPayloadHeader, *KVStore,
*ExecutionPayloadHeader, Log, *KVStore,
],
components.ProvideKVStore[*BeaconBlockHeader, *ExecutionPayloadHeader],
components.ProvideStorageBackend[
Expand Down
11 changes: 9 additions & 2 deletions beacond/cmd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,21 @@ type (
*BeaconBlockBody,
*Deposit,
*ExecutionPayload,
Log,
WithdrawalCredentials,
]

// EngineClient is a type alias for the engine client.
EngineClient = engineclient.EngineClient[
*ExecutionPayload,
Log,
*PayloadAttributes,
]

// EngineClient is a type alias for the engine client.
ExecutionEngine = execution.Engine[
*ExecutionPayload,
*Log,
*PayloadAttributes,
PayloadID,
engineprimitives.Withdrawals,
Expand Down Expand Up @@ -246,7 +249,7 @@ type (

// BeaconBlock type aliases.
BeaconBlock = types.BeaconBlock
BeaconBlockBody = types.BeaconBlockBody
BeaconBlockBody = types.BeaconBlockBody[Log]
BeaconBlockHeader = types.BeaconBlockHeader

// BeaconState is a type alias for the BeaconState.
Expand Down Expand Up @@ -290,11 +293,12 @@ type (
Context = transition.Context

// Deposit is a type alias for the deposit.
Deposit = types.Deposit
Deposit = types.Deposit[Log]

// DepositContract is a type alias for the deposit contract.
DepositContract = deposit.WrappedBeaconDepositContract[
*Deposit,
Log,
WithdrawalCredentials,
]

Expand All @@ -320,6 +324,9 @@ type (
*ExecutionPayloadHeader,
]

// Log is a type alias for the log.
Log = engineprimitives.Log

// Logger is a type alias for the logger.
Logger = phuslu.Logger

Expand Down
11 changes: 6 additions & 5 deletions mod/cli/pkg/commands/genesis/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/berachain/beacon-kit/mod/cli/pkg/context"
"github.com/berachain/beacon-kit/mod/consensus-types/pkg/types"
engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives"
"github.com/berachain/beacon-kit/mod/errors"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/json"
"github.com/cosmos/cosmos-sdk/x/genutil"
Expand Down Expand Up @@ -59,7 +60,7 @@ func CollectGenesisDepositsCmd() *cobra.Command {
return err
}

var deposits []*types.Deposit
var deposits []*types.Deposit[engineprimitives.Log]
if deposits, err = CollectValidatorJSONFiles(
filepath.Join(config.RootDir, "config", "premined-deposits"),
appGenesis,
Expand All @@ -71,7 +72,7 @@ func CollectGenesisDepositsCmd() *cobra.Command {
}

genesisInfo := &types.Genesis[
*types.Deposit,
*types.Deposit[engineprimitives.Log],
*types.ExecutionPayloadHeader,
]{}

Expand Down Expand Up @@ -110,7 +111,7 @@ func CollectGenesisDepositsCmd() *cobra.Command {
func CollectValidatorJSONFiles(
genTxsDir string,
genesis *genutiltypes.AppGenesis,
) ([]*types.Deposit, error) {
) ([]*types.Deposit[engineprimitives.Log], error) {
// prepare a map of all balances in genesis state to then validate
// against the validators addresses
var appState map[string]json.RawMessage
Expand All @@ -125,7 +126,7 @@ func CollectValidatorJSONFiles(
}

// prepare the list of validators
deposits := make([]*types.Deposit, 0)
deposits := make([]*types.Deposit[engineprimitives.Log], 0)
for _, fo := range fos {
if fo.IsDir() {
continue
Expand All @@ -143,7 +144,7 @@ func CollectValidatorJSONFiles(
return nil, err
}

val := &types.Deposit{}
val := &types.Deposit[engineprimitives.Log]{}
if err = json.Unmarshal(bz, val); err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions mod/cli/pkg/commands/genesis/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/berachain/beacon-kit/mod/cli/pkg/context"
"github.com/berachain/beacon-kit/mod/cli/pkg/utils/parser"
"github.com/berachain/beacon-kit/mod/consensus-types/pkg/types"
engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives"
"github.com/berachain/beacon-kit/mod/errors"
"github.com/berachain/beacon-kit/mod/node-core/pkg/components"
"github.com/berachain/beacon-kit/mod/node-core/pkg/components/signer"
Expand Down Expand Up @@ -116,7 +117,7 @@ func AddGenesisDepositCmd(cs common.ChainSpec) *cobra.Command {
return err
}

deposit := types.Deposit{
deposit := types.Deposit[engineprimitives.Log]{
Pubkey: depositMsg.Pubkey,
Amount: depositMsg.Amount,
Signature: signature,
Expand Down Expand Up @@ -165,7 +166,7 @@ func makeOutputFilepath(rootDir, pubkey string) (string, error) {

func writeDepositToFile(
outputDocument string,
depositMessage *types.Deposit,
depositMessage *types.Deposit[engineprimitives.Log],
) error {
//#nosec:G302,G304 // Ignore errors on this line.
outputFile, err := afero.NewOsFs().OpenFile(
Expand Down
3 changes: 2 additions & 1 deletion mod/cli/pkg/commands/genesis/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func AddExecutionPayloadCmd(chainSpec common.ChainSpec) *cobra.Command {
}

genesisInfo := &types.Genesis[
*types.Deposit, *types.ExecutionPayloadHeader,
*types.Deposit[engineprimitives.Log],
*types.ExecutionPayloadHeader,
calbera marked this conversation as resolved.
Show resolved Hide resolved
]{}

if err = json.Unmarshal(
Expand Down
7 changes: 4 additions & 3 deletions mod/consensus-types/pkg/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package types

import (
engineprimitives "github.com/berachain/beacon-kit/mod/engine-primitives/pkg/engine-primitives"
"github.com/berachain/beacon-kit/mod/primitives/pkg/common"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math"
"github.com/berachain/beacon-kit/mod/primitives/pkg/version"
Expand All @@ -41,7 +42,7 @@ type BeaconBlock struct {
StateRoot common.Root `json:"state_root"`
// Body is the body of the BeaconBlock, containing the block's
// operations.
Body *BeaconBlockBody `json:"body"`
Body *BeaconBlockBody[engineprimitives.Log] `json:"body"`
}

// Empty creates an empty beacon block.
Expand All @@ -67,7 +68,7 @@ func (b *BeaconBlock) NewWithVersion(
ProposerIndex: proposerIndex,
ParentRoot: parentBlockRoot,
StateRoot: common.Root{},
Body: &BeaconBlockBody{},
Body: &BeaconBlockBody[engineprimitives.Log]{},
}
default:
return &BeaconBlock{}, ErrForkVersionNotSupported
Expand Down Expand Up @@ -219,7 +220,7 @@ func (b *BeaconBlock) SetStateRoot(root common.Root) {
}

// GetBody retrieves the body of the BeaconBlock.
func (b *BeaconBlock) GetBody() *BeaconBlockBody {
func (b *BeaconBlock) GetBody() *BeaconBlockBody[engineprimitives.Log] {
return b.Body
}

Expand Down
4 changes: 2 additions & 2 deletions mod/consensus-types/pkg/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func generateValidBeaconBlock() *types.BeaconBlock {
ProposerIndex: 5,
ParentRoot: common.Root{1, 2, 3, 4, 5},
StateRoot: common.Root{5, 4, 3, 2, 1},
Body: &types.BeaconBlockBody{
Body: &types.BeaconBlockBody[engineprimitives.Log]{
calbera marked this conversation as resolved.
Show resolved Hide resolved
ExecutionPayload: &types.ExecutionPayload{
Number: 10,
ExtraData: []byte("dummy extra data for testing"),
Expand All @@ -56,7 +56,7 @@ func generateValidBeaconBlock() *types.BeaconBlock {
BaseFeePerGas: math.NewU256(0),
},
Eth1Data: &types.Eth1Data{},
Deposits: []*types.Deposit{
Deposits: []*types.Deposit[engineprimitives.Log]{
{
Index: 1,
},
Expand Down
Loading
Loading