Skip to content

Commit

Permalink
Merge pull request #28 from astriaorg/joroshiba/API-update
Browse files Browse the repository at this point in the history
Migrate to the v1alpha1 API
  • Loading branch information
joroshiba committed Sep 8, 2023
2 parents b99af21 + 5fa3e94 commit d2ce656
Show file tree
Hide file tree
Showing 8 changed files with 1,671 additions and 526 deletions.
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb/remotedb"
"github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/graphql"
executionv1 "github.com/ethereum/go-ethereum/grpc/gen/astria/execution/v1"
executionv1a1 "github.com/ethereum/go-ethereum/grpc/gen/astria/execution/v1alpha1"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/les"
Expand Down Expand Up @@ -2087,7 +2087,7 @@ func RegisterGraphQLService(stack *node.Node, backend ethapi.Backend, filterSyst

// RegisterGRPCService adds the gRPC API to the node.
// It was done this way so that our grpc execution server can access the ethapi.Backend
func RegisterGRPCService(stack *node.Node, execServer executionv1.ExecutionServiceServer, cfg *node.Config) {
func RegisterGRPCService(stack *node.Node, execServer executionv1a1.ExecutionServiceServer, cfg *node.Config) {
if err := node.NewGRPCServerHandler(stack, execServer, cfg); err != nil {
Fatalf("Failed to register the gRPC service: %v", err)
}
Expand Down
16 changes: 8 additions & 8 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/catalyst"
executionv1 "github.com/ethereum/go-ethereum/grpc/gen/astria/execution/v1"
executionv1a1 "github.com/ethereum/go-ethereum/grpc/gen/astria/execution/v1alpha1"
"github.com/ethereum/go-ethereum/log"
)

Expand All @@ -23,7 +23,7 @@ type ExecutionServiceServer struct {
// NOTE - from the generated code:
// All implementations must embed UnimplementedExecutionServiceServer
// for forward compatibility
executionv1.UnimplementedExecutionServiceServer
executionv1a1.UnimplementedExecutionServiceServer

consensus *catalyst.ConsensusAPI
eth *eth.Ethereum
Expand All @@ -43,7 +43,7 @@ func NewExecutionServiceServer(eth *eth.Ethereum) *ExecutionServiceServer {
}
}

func (s *ExecutionServiceServer) DoBlock(ctx context.Context, req *executionv1.DoBlockRequest) (*executionv1.DoBlockResponse, error) {
func (s *ExecutionServiceServer) DoBlock(ctx context.Context, req *executionv1a1.DoBlockRequest) (*executionv1a1.DoBlockResponse, error) {
log.Info("DoBlock called request", "request", req)
prevHeadHash := common.BytesToHash(req.PrevBlockHash)

Expand Down Expand Up @@ -107,25 +107,25 @@ func (s *ExecutionServiceServer) DoBlock(ctx context.Context, req *executionv1.D
return nil, err
}

res := &executionv1.DoBlockResponse{
res := &executionv1a1.DoBlockResponse{
BlockHash: fcEndResp.PayloadStatus.LatestValidHash.Bytes(),
}
return res, nil
}

func (s *ExecutionServiceServer) FinalizeBlock(ctx context.Context, req *executionv1.FinalizeBlockRequest) (*executionv1.FinalizeBlockResponse, error) {
func (s *ExecutionServiceServer) FinalizeBlock(ctx context.Context, req *executionv1a1.FinalizeBlockRequest) (*executionv1a1.FinalizeBlockResponse, error) {
header := s.bc.GetHeaderByHash(common.BytesToHash(req.BlockHash))
if header == nil {
return nil, fmt.Errorf("failed to get header for block hash 0x%x", req.BlockHash)
}

s.bc.SetFinalized(header)
return &executionv1.FinalizeBlockResponse{}, nil
return &executionv1a1.FinalizeBlockResponse{}, nil
}

func (s *ExecutionServiceServer) InitState(ctx context.Context, req *executionv1.InitStateRequest) (*executionv1.InitStateResponse, error) {
func (s *ExecutionServiceServer) InitState(ctx context.Context, req *executionv1a1.InitStateRequest) (*executionv1a1.InitStateResponse, error) {
currHead := s.eth.BlockChain().CurrentHeader()
res := &executionv1.InitStateResponse{
res := &executionv1a1.InitStateResponse{
BlockHash: currHead.Hash().Bytes(),
}

Expand Down
Loading

0 comments on commit d2ce656

Please sign in to comment.