Skip to content

Commit

Permalink
Updated to use new Init, and fill out starting attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
joroshiba committed Mar 30, 2023
1 parent 2060a4e commit dda2605
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 49 deletions.
9 changes: 8 additions & 1 deletion grpc/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
This package provides a gRPC server as an entrypoint to the EVM.

## Build and run from source:


Helpful commands (MacOS):
```bash
# install necessary dependencies
brew install leveldb

# build geth
make geth

# generating protobuf files
buf generate buf.build/astria/execution-apis

# TODO - run beacon?

# run geth
./build/bin/geth --goerli --grpc --grpc.addr "0.0.0.0" --grpc.port 50051
```
Expand Down
26 changes: 21 additions & 5 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"

"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/catalyst"
executionv1 "github.com/ethereum/go-ethereum/grpc/gen/proto/execution/v1"
Expand All @@ -34,18 +35,24 @@ func NewExecutionServiceServer(eth *eth.Ethereum) *ExecutionServiceServer {
}
}

// FIXME - how do we know which hash to start with? will probably need another api function like
// GetHeadHash() to get the head hash of the forkchoice

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

// The Engine API has been modified to use transactions from this mempool and abide by it's ordering.
s.eth.TxPool().SetAstriaOrdered(req.Transactions)

// Do the whole Engine API in a single loop
startForkChoice := &engine.ForkchoiceStateV1{}
payloadAttributes := &engine.PayloadAttributes{}
startForkChoice := &engine.ForkchoiceStateV1{
HeadBlockHash: prevHeadHash,
SafeBlockHash: prevHeadHash,
FinalizedBlockHash: prevHeadHash,
}
payloadAttributes := &engine.PayloadAttributes{
Timestamp: uint64(req.GetTimestamp().GetSeconds()),
Random: common.Hash{},
SuggestedFeeRecipient: common.Address{},
}
fcStartResp, err := s.consensus.ForkchoiceUpdatedV1(*startForkChoice, payloadAttributes)
if err != nil {
return nil, err
Expand Down Expand Up @@ -73,3 +80,12 @@ func (s *ExecutionServiceServer) DoBlock(ctx context.Context, req *executionv1.D
}
return res, nil
}

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

return res, nil
}
224 changes: 182 additions & 42 deletions grpc/gen/proto/execution/v1/execution.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dda2605

Please sign in to comment.