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: support new API utilizing rollup data #43

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/ethereum/go-ethereum
go 1.21

require (
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240209225522-97e3bc68f856.2
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240209225522-97e3bc68f856.1
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240313235745-aa7f84576cf9.2
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240313235745-aa7f84576cf9.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,6 +79,7 @@ require (
)

require (
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240313234236-d24183d0df2f.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
14 changes: 9 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240209225522-97e3bc68f856.2 h1:mK0jVG2+QlJrPKsgL46KKh2ZqHc8lyexQP3TUcOvvNU=
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240209225522-97e3bc68f856.2/go.mod h1:soA8k5qokjmp9DmV6jdcWndlVdSYjfa8KJZgsJrvixc=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.28.1-20240209225522-97e3bc68f856.4/go.mod h1:5wxRDkWimPnuhDUA4pFBaHMtrViNJAHguLU1Wq8T6x8=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240209225522-97e3bc68f856.1 h1:6iyjwuNE2uuRikxiDVr56RvDJ+OE3g32v1V1zk5yIjI=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240209225522-97e3bc68f856.1/go.mod h1:m409hJcO0kExqrFoQS8fQ7yXHuuM8JRTEYB+09WWVy0=
buf.build/gen/go/astria/astria/grpc/go v1.3.0-20240313234236-d24183d0df2f.2/go.mod h1:+CAj7osRLlm0ENWk9OP4Ba1rd0oWdl5iHPZAp5z96/U=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.28.1-20240313234236-d24183d0df2f.4/go.mod h1:2267P73yUQPZlQyW96+03iM2xSEMVcK0DbRqSYbyLJQ=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240313234236-d24183d0df2f.1 h1:ZiIR1AdoaAy5vaEkam+0VPZ961KNIAUscao+03ICutg=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240313234236-d24183d0df2f.1/go.mod h1:Ma4TsfKTQby0r4gCkdb6D2ThBxTNu0mSVNZF1udF2ko=
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240313235745-aa7f84576cf9.2 h1:IET3o9WV21KTPIBgH3+2N18QTD248T8O9UKAf240r8I=
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240313235745-aa7f84576cf9.2/go.mod h1:bN5UvJOv0OzqUdz6sdAAOjoGtm9ogCfXiJoA5DHplII=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.28.1-20240313235745-aa7f84576cf9.4/go.mod h1:85e0cEUbS51UAicRoREF58T2zdbvBx0UHIycSSAEfVc=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240313235745-aa7f84576cf9.1 h1:4RmvAqVLrDDA51RIvYalwuMl2kz7pD7HBcH8Cb7NjEc=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240313235745-aa7f84576cf9.1/go.mod h1:Y1oiW5RZyvDJyJnxf8MSRkbVAFpF5eWPB8yHL2GnaYw=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down
29 changes: 28 additions & 1 deletion grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type ExecutionServiceServerV1Alpha2 struct {

commitementUpdateLock sync.Mutex // Lock for the forkChoiceUpdated method
blockExecutionLock sync.Mutex // Lock for the NewPayload method

genesisInfoCalled bool
getCommitmentStateCalled bool
}

var (
Expand Down Expand Up @@ -90,6 +93,7 @@ func (s *ExecutionServiceServerV1Alpha2) GetGenesisInfo(ctx context.Context, req

log.Info("GetGenesisInfo completed", "response", res)
getGenesisInfoSuccessCount.Inc(1)
s.genesisInfoCalled = true
return res, nil
}

Expand Down Expand Up @@ -148,16 +152,30 @@ func (s *ExecutionServiceServerV1Alpha2) ExecuteBlock(ctx context.Context, req *
executionStart := time.Now()
defer executeBlockTimer.UpdateSince(executionStart)

if !s.syncMethodsCalled() {
return nil, status.Error(codes.PermissionDenied, "Cannot execute block until GetGenesisInfo && GetCommitmentState methods are called")
}

// Validate block being created has valid previous hash
prevHeadHash := common.BytesToHash(req.PrevBlockHash)
softHash := s.bc.CurrentSafeBlock().Hash()
if prevHeadHash != softHash {
return nil, status.Error(codes.FailedPrecondition, "Block can only be created on top of soft block.")
}

// Filter out any Deposit txs since we don't currently support them
txsToProcess := [][]byte{}
for idx, tx := range req.Transactions {
if tx.GetDeposit() != nil {
log.Info("Deposit transactions detected, not implemented for chain, skipping", "index", idx)
} else {
txsToProcess = append(txsToProcess, tx.GetSequencedData())
}
}

// This set of ordered TXs on the TxPool is has been configured to be used by
// the Miner when building a payload.
s.eth.TxPool().SetAstriaOrdered(req.Transactions)
s.eth.TxPool().SetAstriaOrdered(txsToProcess)

// Build a payload to add to the chain
payloadAttributes := &miner.BuildPayloadArgs{
Expand Down Expand Up @@ -226,6 +244,7 @@ func (s *ExecutionServiceServerV1Alpha2) GetCommitmentState(ctx context.Context,

log.Info("GetCommitmentState completed", "request", req, "response", res)
getCommitmentStateSuccessCount.Inc(1)
s.getCommitmentStateCalled = true
return res, nil
}

Expand All @@ -240,6 +259,10 @@ func (s *ExecutionServiceServerV1Alpha2) UpdateCommitmentState(ctx context.Conte
s.commitementUpdateLock.Lock()
defer s.commitementUpdateLock.Unlock()

if !s.syncMethodsCalled() {
return nil, status.Error(codes.PermissionDenied, "Cannot update commitment state until GetGenesisInfo && GetCommitmentState methods are called")
}

softEthHash := common.BytesToHash(req.CommitmentState.Soft.Hash)
firmEthHash := common.BytesToHash(req.CommitmentState.Firm.Hash)

Expand Down Expand Up @@ -336,3 +359,7 @@ func ethHeaderToExecutionBlock(header *types.Header) (*astriaPb.Block, error) {
},
}, nil
}

func (s *ExecutionServiceServerV1Alpha2) syncMethodsCalled() bool {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this related to the rollup data functionality or was it needed for something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed for rollup functionality, but added to stop us from accidentally executing over bad state in case of something like Geth reboots but conductor didn't and txs/blocks lost.

return s.genesisInfoCalled && s.getCommitmentStateCalled
}
Loading