Repository navigation
refactor: migrate to blob api and remove da interface. #2893
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6d4b404
approach 2
randygrok b4bd549
Refactor DA debug tool to improve blob fetching and error handling
randygrok a25a529
linter
randygrok 24e4cec
fix: add missing datypes import in integration test
randygrok 955a170
fix: remove obsolete +build tags from test files
randygrok 3c0a15c
fix: persist DA included height in syncer for full nodes
randygrok 4ad19ee
fix: add ErrHeightFromFuture check to local-da GetAll
randygrok 55a9f7d
Revert "fix: persist DA included height in syncer for full nodes"
randygrok 6a3b2dd
fix tests
randygrok 7b3d095
Merge branch 'main' into blob-rpc-migration
randygrok 3eb1c92
fix: correct relative paths in grpc app README
randygrok 0fc90f1
Improve marshalItems cancellation handling
randygrok 54d90c2
Validate submit inputs and guard size overflow
randygrok 498d901
Validate blob sizes in jsonrpc client
randygrok 7ab2555
Merge remote-tracking branch 'origin/main' into blob-rpc-migration
randygrok d1e2288
Merge remote-tracking branch 'origin/main' into blob-rpc-migration
randygrok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
approach 2
- Loading branch information
commit 6d4b4041c3420014a82e6f10d57c99e1ca653a59
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package da | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "sync" | ||
|
|
||
| "github.com/celestiaorg/go-square/v3/share" | ||
|
|
||
| "github.com/evstack/ev-node/pkg/blob" | ||
| ) | ||
|
|
||
| // LocalBlobAPI is a simple in-memory BlobAPI implementation for tests. | ||
| type LocalBlobAPI struct { | ||
| mu sync.Mutex | ||
| height uint64 | ||
| maxSize uint64 | ||
| byHeight map[uint64][]*blob.Blob | ||
| } | ||
|
|
||
| // NewLocalBlobAPI creates an in-memory BlobAPI with a max blob size. | ||
| func NewLocalBlobAPI(maxSize uint64) *LocalBlobAPI { | ||
| return &LocalBlobAPI{ | ||
| maxSize: maxSize, | ||
| byHeight: make(map[uint64][]*blob.Blob), | ||
| } | ||
| } | ||
|
|
||
| func (l *LocalBlobAPI) Submit(ctx context.Context, blobs []*blob.Blob, _ *blob.SubmitOptions) (uint64, error) { | ||
| l.mu.Lock() | ||
| defer l.mu.Unlock() | ||
|
|
||
| for i, b := range blobs { | ||
| if uint64(len(b.Data())) > l.maxSize { | ||
| return 0, fmt.Errorf("blob %d too big", i) | ||
| } | ||
| } | ||
|
|
||
| l.height++ | ||
| // store clones to avoid external mutation | ||
| stored := make([]*blob.Blob, len(blobs)) | ||
| for i, b := range blobs { | ||
| stored[i] = b | ||
| } | ||
| l.byHeight[l.height] = append(l.byHeight[l.height], stored...) | ||
| return l.height, nil | ||
| } | ||
|
|
||
| func (l *LocalBlobAPI) GetAll(ctx context.Context, height uint64, namespaces []share.Namespace) ([]*blob.Blob, error) { | ||
| l.mu.Lock() | ||
| defer l.mu.Unlock() | ||
|
|
||
| nsMap := make(map[string]struct{}, len(namespaces)) | ||
| for _, ns := range namespaces { | ||
| nsMap[string(ns.Bytes())] = struct{}{} | ||
| } | ||
|
|
||
| blobs, ok := l.byHeight[height] | ||
| if !ok { | ||
| return []*blob.Blob{}, nil | ||
| } | ||
| var out []*blob.Blob | ||
| for _, b := range blobs { | ||
| if _, ok := nsMap[string(b.Namespace().Bytes())]; ok { | ||
| out = append(out, b) | ||
| } | ||
| } | ||
| return out, nil | ||
| } | ||
|
|
||
| func (l *LocalBlobAPI) GetProof(ctx context.Context, height uint64, namespace share.Namespace, commitment blob.Commitment) (*blob.Proof, error) { | ||
| return &blob.Proof{}, nil | ||
| } | ||
|
|
||
| func (l *LocalBlobAPI) Included(ctx context.Context, height uint64, namespace share.Namespace, proof *blob.Proof, commitment blob.Commitment) (bool, error) { | ||
| return true, nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,9 +13,10 @@ import ( | |
| "github.com/evstack/ev-node/block/internal/cache" | ||
| "github.com/evstack/ev-node/block/internal/common" | ||
| "github.com/evstack/ev-node/block/internal/da" | ||
| coreda "github.com/evstack/ev-node/core/da" | ||
| "github.com/evstack/ev-node/pkg/blob" | ||
| "github.com/evstack/ev-node/pkg/config" | ||
| pkgda "github.com/evstack/ev-node/pkg/da" | ||
| datypes "github.com/evstack/ev-node/pkg/da/types" | ||
| "github.com/evstack/ev-node/pkg/genesis" | ||
| "github.com/evstack/ev-node/pkg/rpc/server" | ||
| "github.com/evstack/ev-node/pkg/signer" | ||
|
|
@@ -119,7 +120,21 @@ func NewDASubmitter( | |
|
|
||
| if config.RPC.EnableDAVisualization { | ||
| visualizerLogger := logger.With().Str("component", "da_visualization").Logger() | ||
| server.SetDAVisualizationServer(server.NewDAVisualizationServer(client.GetDA(), visualizerLogger, config.Node.Aggregator)) | ||
| server.SetDAVisualizationServer( | ||
| server.NewDAVisualizationServer( | ||
| func(ctx context.Context, id []byte, ns []byte) ([]datypes.Blob, error) { | ||
| // minimal fetch: derive height from ID and use namespace provided | ||
| height, _ := blob.SplitID(id) | ||
| res := client.Retrieve(ctx, height, ns) | ||
| if res.Code != datypes.StatusSuccess || len(res.Data) == 0 { | ||
| return nil, fmt.Errorf("blob not found") | ||
| } | ||
| return res.Data, nil | ||
| }, | ||
| visualizerLogger, | ||
| config.Node.Aggregator, | ||
| ), | ||
| ) | ||
|
Comment on lines
+121
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we modify the server to not need the function wrapper? |
||
| } | ||
|
|
||
| // Use NoOp metrics if nil to avoid nil checks throughout the code | ||
|
|
@@ -184,7 +199,7 @@ func (s *DASubmitter) SubmitHeaders(ctx context.Context, cache cache.Manager) er | |
| } | ||
| return proto.Marshal(headerPb) | ||
| }, | ||
| func(submitted []*types.SignedHeader, res *coreda.ResultSubmit) { | ||
| func(submitted []*types.SignedHeader, res *datypes.ResultSubmit) { | ||
| for _, header := range submitted { | ||
| cache.SetHeaderDAIncluded(header.Hash().String(), res.Height, header.Height()) | ||
| } | ||
|
|
@@ -227,7 +242,7 @@ func (s *DASubmitter) SubmitData(ctx context.Context, cache cache.Manager, signe | |
| func(signedData *types.SignedData) ([]byte, error) { | ||
| return signedData.MarshalBinary() | ||
| }, | ||
| func(submitted []*types.SignedData, res *coreda.ResultSubmit) { | ||
| func(submitted []*types.SignedData, res *datypes.ResultSubmit) { | ||
| for _, sd := range submitted { | ||
| cache.SetDataDAIncluded(sd.Data.DACommitment().String(), res.Height, sd.Height()) | ||
| } | ||
|
|
@@ -343,7 +358,7 @@ func submitToDA[T any]( | |
| ctx context.Context, | ||
| items []T, | ||
| marshalFn func(T) ([]byte, error), | ||
| postSubmit func([]T, *coreda.ResultSubmit), | ||
| postSubmit func([]T, *datypes.ResultSubmit), | ||
| itemType string, | ||
| namespace []byte, | ||
| options []byte, | ||
|
|
@@ -406,7 +421,7 @@ func submitToDA[T any]( | |
|
|
||
| // Perform submission | ||
| start := time.Now() | ||
| res := s.client.Submit(submitCtx, marshaled, -1, namespace, mergedOptions) | ||
| res := s.client.Submit(submitCtx, marshaled, namespace, mergedOptions) | ||
| s.logger.Debug().Int("attempts", rs.Attempt).Dur("elapsed", time.Since(start)).Uint64("code", uint64(res.Code)).Msg("got SubmitWithHelpers response from celestia") | ||
|
|
||
| // Record submission result for observability | ||
|
|
@@ -415,7 +430,7 @@ func submitToDA[T any]( | |
| } | ||
|
|
||
| switch res.Code { | ||
| case coreda.StatusSuccess: | ||
| case datypes.StatusSuccess: | ||
| submitted := items[:res.SubmittedCount] | ||
| postSubmit(submitted, &res) | ||
| s.logger.Info().Str("itemType", itemType).Uint64("count", res.SubmittedCount).Msg("successfully submitted items to DA layer") | ||
|
|
@@ -436,7 +451,7 @@ func submitToDA[T any]( | |
| s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn())) | ||
| } | ||
|
|
||
| case coreda.StatusTooBig: | ||
| case datypes.StatusTooBig: | ||
| // Record failure metric | ||
| s.recordFailure(common.DASubmitterFailureReasonTooBig) | ||
| // Iteratively halve until it fits or single-item too big | ||
|
|
@@ -460,19 +475,19 @@ func submitToDA[T any]( | |
| s.metrics.DASubmitterPendingBlobs.Set(float64(getTotalPendingFn())) | ||
| } | ||
|
|
||
| case coreda.StatusNotIncludedInBlock: | ||
| case datypes.StatusNotIncludedInBlock: | ||
| // Record failure metric | ||
| s.recordFailure(common.DASubmitterFailureReasonNotIncludedInBlock) | ||
| s.logger.Info().Dur("backoff", pol.MaxBackoff).Msg("retrying due to mempool state") | ||
| rs.Next(reasonMempool, pol) | ||
|
|
||
| case coreda.StatusAlreadyInMempool: | ||
| case datypes.StatusAlreadyInMempool: | ||
| // Record failure metric | ||
| s.recordFailure(common.DASubmitterFailureReasonAlreadyInMempool) | ||
| s.logger.Info().Dur("backoff", pol.MaxBackoff).Msg("retrying due to mempool state") | ||
| rs.Next(reasonMempool, pol) | ||
|
|
||
| case coreda.StatusContextCanceled: | ||
| case datypes.StatusContextCanceled: | ||
| // Record failure metric | ||
| s.recordFailure(common.DASubmitterFailureReasonContextCanceled) | ||
| s.logger.Info().Msg("DA layer submission canceled due to context cancellation") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can this file be marked as _tests? or a comment at the top saying its for tests