Skip to content

Commit

Permalink
Merge pull request #46 from astriaorg/noot/startup-checks
Browse files Browse the repository at this point in the history
exit node if genesis astria fields are unset
  • Loading branch information
noot committed Apr 2, 2024
2 parents a04a97d + 21e9946 commit d05e3b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {

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

Expand Down
21 changes: 19 additions & 2 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package execution
import (
"context"
"crypto/sha256"
"errors"
"fmt"
"math/big"
"sync"
Expand Down Expand Up @@ -67,17 +68,33 @@ var (
commitmentStateUpdateTimer = metrics.GetOrRegisterTimer("astria/execution/commitment", nil)
)

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

if bc.Config().AstriaRollupName == "" {
return nil, errors.New("rollup name not set")
}

if bc.Config().AstriaSequencerInitialHeight == 0 {
return nil, errors.New("sequencer initial height not set")
}

if bc.Config().AstriaCelestiaInitialHeight == 0 {
return nil, errors.New("celestia initial height not set")
}

if bc.Config().AstriaCelestiaHeightVariance == 0 {
return nil, errors.New("celestia height variance not set")
}

if merger := eth.Merger(); !merger.PoSFinalized() {
merger.FinalizePoS()
}

return &ExecutionServiceServerV1Alpha2{
eth: eth,
bc: bc,
}
}, nil
}

func (s *ExecutionServiceServerV1Alpha2) GetGenesisInfo(ctx context.Context, req *astriaPb.GetGenesisInfoRequest) (*astriaPb.GenesisInfo, error) {
Expand Down

0 comments on commit d05e3b2

Please sign in to comment.