Skip to content

Commit

Permalink
Merge pull request #43 from astriaorg/joroshiba/upgrade-to-support-ro…
Browse files Browse the repository at this point in the history
…llup-data

feat: support new API utilizing rollup data
  • Loading branch information
joroshiba committed Mar 19, 2024
2 parents af9f7e4 + 882c887 commit 5ee4ef2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
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-20240314225003-19f6b40c3e7b.2
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240314225003-19f6b40c3e7b.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-20240314225002-310b29d1ef86.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-20240314225002-310b29d1ef86.2/go.mod h1:FFX7uXjELBVDDB3WOW6lO6Sn36kC9QqkHu5xU9xY4ac=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.28.1-20240314225002-310b29d1ef86.4/go.mod h1:2267P73yUQPZlQyW96+03iM2xSEMVcK0DbRqSYbyLJQ=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240314225002-310b29d1ef86.1 h1:tqubh9diC2bk6BzxO9Obs9KgxvsfTEa0hWKqG9kA45E=
buf.build/gen/go/astria/astria/protocolbuffers/go v1.32.0-20240314225002-310b29d1ef86.1/go.mod h1:Ma4TsfKTQby0r4gCkdb6D2ThBxTNu0mSVNZF1udF2ko=
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240314225003-19f6b40c3e7b.2 h1:9vSSs8hVVcYrQMt7CTO5r1I4eUhPiXUEBrVBZ9SaCnc=
buf.build/gen/go/astria/execution-apis/grpc/go v1.3.0-20240314225003-19f6b40c3e7b.2/go.mod h1:wSSvcWt7/78D8RQKhBjTaTvl0j7paszROJHHnJCfZ40=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.28.1-20240314225003-19f6b40c3e7b.4/go.mod h1:Ow5heKoG4UcB64gsltdmZNOZQsL8khlJzysd5lLwOfI=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240314225003-19f6b40c3e7b.1 h1:7dX4IwODvMlzcC0j0wkuLPf4JBzT9EW2O2Vb6tCEHHs=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.32.0-20240314225003-19f6b40c3e7b.1/go.mod h1:1PoFKhLruAgpqRKBz6cY/Z5bfXXYj3pHTvtf2uBoRJs=
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 {
return s.genesisInfoCalled && s.getCommitmentStateCalled
}

0 comments on commit 5ee4ef2

Please sign in to comment.