Skip to content

Commit

Permalink
chore: upgrade to v1 server api
Browse files Browse the repository at this point in the history
  • Loading branch information
joroshiba committed Oct 16, 2024
1 parent b43daa1 commit f84a877
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1,981 deletions.
4 changes: 2 additions & 2 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {

// Configure gRPC if requested.
if ctx.IsSet(utils.GRPCEnabledFlag.Name) {
serviceV1a2, err := execution.NewExecutionServiceServerV1Alpha2(eth)
serviceV1, err := execution.NewExecutionServiceServerV1(eth)
if err != nil {
utils.Fatalf("failed to create execution service: %v", err)
}
utils.RegisterGRPCExecutionService(stack, serviceV1a2, &cfg.Node)
utils.RegisterGRPCExecutionService(stack, serviceV1, &cfg.Node)
}

// Add the Ethereum Stats daemon if requested.
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"strings"
"time"

astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1alpha2/executionv1alpha2grpc"
astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1/executionv1grpc"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
bparams "github.com/ethereum/go-ethereum/beacon/params"
Expand Down
15 changes: 6 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ethereum/go-ethereum
go 1.21

require (
buf.build/gen/go/astria/execution-apis/grpc/go v1.4.0-20240725205400-4746841755df.1
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.34.1-20240725205400-4746841755df.1
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.34.2-20240911152449-eeebd3decdce.2
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.34.2-20240911152449-b41cca615e35.2
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-21f1b77897ba.1
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-00000000000000-21f1b77897ba.1
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-00000000000000-68c4cd4acb9f.1
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-00000000000000-3a358734821d.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
github.com/Microsoft/go-winio v0.6.1
github.com/VictoriaMetrics/fastcache v1.12.1
Expand Down Expand Up @@ -79,16 +79,12 @@ require (
golang.org/x/time v0.5.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
google.golang.org/protobuf v1.35.1
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v3 v3.0.1
)

require (
buf.build/gen/go/astria/primitives/grpc/go v1.5.1-20240911152449-eeebd3decdce.1 // indirect
buf.build/gen/go/astria/protocol-apis/grpc/go v1.3.0-20240829200558-cd9207200425.3 // indirect
buf.build/gen/go/astria/protocol-apis/protocolbuffers/go v1.34.1-20240829200558-cd9207200425.1 // indirect
buf.build/gen/go/astria/sequencerblock-apis/grpc/go v1.5.1-20240911152449-b41cca615e35.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
Expand Down Expand Up @@ -154,6 +150,7 @@ require (
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
1,950 changes: 10 additions & 1,940 deletions go.sum

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"sync"
"time"

astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1alpha2/executionv1alpha2grpc"
astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1alpha2"
astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1/executionv1grpc"
astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1"
primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -30,9 +30,9 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)

// ExecutionServiceServerV1Alpha2 is the implementation of the
// ExecutionServiceServerV1 is the implementation of the
// ExecutionServiceServer interface.
type ExecutionServiceServerV1Alpha2 struct {
type ExecutionServiceServerV1 struct {
// NOTE - from the generated code: All implementations must embed
// UnimplementedExecutionServiceServer for forward compatibility
astriaGrpc.UnimplementedExecutionServiceServer
Expand Down Expand Up @@ -74,7 +74,7 @@ var (
commitmentStateUpdateTimer = metrics.GetOrRegisterTimer("astria/execution/commitment", nil)
)

func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServerV1Alpha2, error) {
func NewExecutionServiceServerV1(eth *eth.Ethereum) (*ExecutionServiceServerV1, error) {
bc := eth.BlockChain()

if bc.Config().AstriaRollupName == "" {
Expand Down Expand Up @@ -143,7 +143,7 @@ func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServ
}
}

return &ExecutionServiceServerV1Alpha2{
return &ExecutionServiceServerV1{
eth: eth,
bc: bc,
bridgeAddresses: bridgeAddresses,
Expand All @@ -152,7 +152,7 @@ func NewExecutionServiceServerV1Alpha2(eth *eth.Ethereum) (*ExecutionServiceServ
}, nil
}

func (s *ExecutionServiceServerV1Alpha2) GetGenesisInfo(ctx context.Context, req *astriaPb.GetGenesisInfoRequest) (*astriaPb.GenesisInfo, error) {
func (s *ExecutionServiceServerV1) GetGenesisInfo(ctx context.Context, req *astriaPb.GetGenesisInfoRequest) (*astriaPb.GenesisInfo, error) {
log.Debug("GetGenesisInfo called")
getGenesisInfoRequestCount.Inc(1)

Expand All @@ -172,7 +172,7 @@ func (s *ExecutionServiceServerV1Alpha2) GetGenesisInfo(ctx context.Context, req
}

// GetBlock will return a block given an identifier.
func (s *ExecutionServiceServerV1Alpha2) GetBlock(ctx context.Context, req *astriaPb.GetBlockRequest) (*astriaPb.Block, error) {
func (s *ExecutionServiceServerV1) GetBlock(ctx context.Context, req *astriaPb.GetBlockRequest) (*astriaPb.Block, error) {
if req.GetIdentifier() == nil {
return nil, status.Error(codes.InvalidArgument, "identifier cannot be empty")
}
Expand All @@ -193,7 +193,7 @@ func (s *ExecutionServiceServerV1Alpha2) GetBlock(ctx context.Context, req *astr

// BatchGetBlocks will return an array of Blocks given an array of block
// identifiers.
func (s *ExecutionServiceServerV1Alpha2) BatchGetBlocks(ctx context.Context, req *astriaPb.BatchGetBlocksRequest) (*astriaPb.BatchGetBlocksResponse, error) {
func (s *ExecutionServiceServerV1) BatchGetBlocks(ctx context.Context, req *astriaPb.BatchGetBlocksRequest) (*astriaPb.BatchGetBlocksResponse, error) {
if req.Identifiers == nil || len(req.Identifiers) == 0 {
return nil, status.Error(codes.InvalidArgument, "identifiers cannot be empty")
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func protoU128ToBigInt(u128 *primitivev1.Uint128) *big.Int {

// ExecuteBlock drives deterministic derivation of a rollup block from sequencer
// block data
func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req *astriaPb.ExecuteBlockRequest) (*astriaPb.Block, error) {
func (s *ExecutionServiceServerV1) ExecuteBlock(ctx context.Context, req *astriaPb.ExecuteBlockRequest) (*astriaPb.Block, error) {
if err := validateStaticExecuteBlockRequest(req); err != nil {
log.Error("ExecuteBlock called with invalid ExecuteBlockRequest", "err", err)
return nil, status.Error(codes.InvalidArgument, "ExecuteBlockRequest is invalid")
Expand Down Expand Up @@ -323,7 +323,7 @@ func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req *
}

// GetCommitmentState fetches the current CommitmentState of the chain.
func (s *ExecutionServiceServerV1Alpha2) GetCommitmentState(ctx context.Context, req *astriaPb.GetCommitmentStateRequest) (*astriaPb.CommitmentState, error) {
func (s *ExecutionServiceServerV1) GetCommitmentState(ctx context.Context, req *astriaPb.GetCommitmentStateRequest) (*astriaPb.CommitmentState, error) {
log.Info("GetCommitmentState called")
getCommitmentStateRequestCount.Inc(1)

Expand Down Expand Up @@ -354,7 +354,7 @@ func (s *ExecutionServiceServerV1Alpha2) GetCommitmentState(ctx context.Context,

// UpdateCommitmentState replaces the whole CommitmentState with a new
// CommitmentState.
func (s *ExecutionServiceServerV1Alpha2) UpdateCommitmentState(ctx context.Context, req *astriaPb.UpdateCommitmentStateRequest) (*astriaPb.CommitmentState, error) {
func (s *ExecutionServiceServerV1) UpdateCommitmentState(ctx context.Context, req *astriaPb.UpdateCommitmentStateRequest) (*astriaPb.CommitmentState, error) {
if err := validateStaticCommitmentState(req.CommitmentState); err != nil {
log.Error("UpdateCommitmentState called with invalid CommitmentState", "err", err)
return nil, status.Error(codes.InvalidArgument, "CommitmentState is invalid")
Expand Down Expand Up @@ -434,7 +434,7 @@ func (s *ExecutionServiceServerV1Alpha2) UpdateCommitmentState(ctx context.Conte
return req.CommitmentState, nil
}

func (s *ExecutionServiceServerV1Alpha2) getBlockFromIdentifier(identifier *astriaPb.BlockIdentifier) (*astriaPb.Block, error) {
func (s *ExecutionServiceServerV1) getBlockFromIdentifier(identifier *astriaPb.BlockIdentifier) (*astriaPb.Block, error) {
var header *types.Header

// Grab the header based on the identifier provided
Expand Down Expand Up @@ -475,6 +475,6 @@ func ethHeaderToExecutionBlock(header *types.Header) (*astriaPb.Block, error) {
}, nil
}

func (s *ExecutionServiceServerV1Alpha2) syncMethodsCalled() bool {
func (s *ExecutionServiceServerV1) syncMethodsCalled() bool {
return s.genesisInfoCalled && s.getCommitmentStateCalled
}
4 changes: 2 additions & 2 deletions grpc/execution/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ func startEthService(t *testing.T, genesis *core.Genesis) *eth.Ethereum {
return ethservice
}

func setupExecutionService(t *testing.T, noOfBlocksToGenerate int) (*eth.Ethereum, *ExecutionServiceServerV1Alpha2) {
func setupExecutionService(t *testing.T, noOfBlocksToGenerate int) (*eth.Ethereum, *ExecutionServiceServerV1) {
t.Helper()
genesis, blocks, bridgeAddress, feeCollectorKey := generateMergeChain(noOfBlocksToGenerate, true)
ethservice := startEthService(t, genesis)

serviceV1Alpha1, err := NewExecutionServiceServerV1Alpha2(ethservice)
serviceV1Alpha1, err := NewExecutionServiceServerV1(ethservice)
require.Nil(t, err, "can't create execution service")

feeCollector := crypto.PubkeyToAddress(feeCollectorKey.PublicKey)
Expand Down
24 changes: 12 additions & 12 deletions grpc/execution/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"math/big"

astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1alpha2"
sequencerblockv1alpha1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1alpha1"
astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1"
sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -20,7 +20,7 @@ import (
// tx is not a blob tx or a deposit tx.
func validateAndUnmarshalSequencerTx(
height uint64,
tx *sequencerblockv1alpha1.RollupData,
tx *sequencerblockv1.RollupData,
bridgeAddresses map[string]*params.AstriaBridgeAddressConfig,
bridgeAllowedAssets map[string]struct{},
) (*types.Transaction, error) {
Expand Down Expand Up @@ -68,10 +68,10 @@ func validateAndUnmarshalSequencerTx(
//
// the fees are spent from the "bridge account" which is not actually a real account, but is instead some
// address defined by consensus, so the gas cost is not actually deducted from any account.
Gas: 64000,
To: &bac.Erc20Asset.ContractAddress,
Data: calldata,
SourceTransactionId: *deposit.SourceTransactionId,
Gas: 64000,
To: &bac.Erc20Asset.ContractAddress,
Data: calldata,
SourceTransactionId: *deposit.SourceTransactionId,
SourceTransactionIndex: deposit.SourceActionIndex,
}

Expand All @@ -80,11 +80,11 @@ func validateAndUnmarshalSequencerTx(
}

txdata := types.DepositTx{
From: bac.SenderAddress,
To: &recipient,
Value: amount,
Gas: 0,
SourceTransactionId: *deposit.SourceTransactionId,
From: bac.SenderAddress,
To: &recipient,
Value: amount,
Gas: 0,
SourceTransactionId: *deposit.SourceTransactionId,
SourceTransactionIndex: deposit.SourceActionIndex,
}
return types.NewTx(&txdata), nil
Expand Down
2 changes: 1 addition & 1 deletion node/grpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net"
"sync"

astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1alpha2/executionv1alpha2grpc"
astriaGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/execution/v1/executionv1grpc"
"github.com/ethereum/go-ethereum/log"
"google.golang.org/grpc"
)
Expand Down

0 comments on commit f84a877

Please sign in to comment.