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!: refactor blob, namespace and shares into single package #2778

Closed
wants to merge 2 commits into from

Conversation

cmwaters
Copy link
Contributor

Overview

This is an incredibly broad change in terms of files changed but it chiefly consists of merging pkg/blob, pkg/namespace and pkg/shares into a shares package and updating all the import paths accordingly.

This is part of the move to create a separate go module for the shares package that can be used by downstream dependents like rollkit without needing to import tendermint or the cosmos-sdk.

Logically, Share, Namespace and Blob are all part of the same encoding protocol that marshals/unmarshals blobs into fixed length shares.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@rootulp
Copy link
Collaborator

rootulp commented Oct 27, 2023

@github-actions
Copy link

PR Preview Action v1.4.4
🚀 Deployed preview to https://celestiaorg.github.io/celestia-app/pr-preview/pr-2778/
on branch gh-pages at 2023-10-27 15:52 UTC

@rootulp
Copy link
Collaborator

rootulp commented Oct 27, 2023

Overall LGTM. Not actually approving b/c looks like merge conflicts.

One remaining question: should this be marked as API breaking? I assume consumers who imported the previous packages will have to change their import path.

@cmwaters
Copy link
Contributor Author

Yeah this is definitely API breaking. I'll add the exclamation mark in the commit just to be clear

@rootulp rootulp changed the title feat: refactor blob, namespace and shares into single package feat!: refactor blob, namespace and shares into single package Oct 29, 2023
@cmwaters
Copy link
Contributor Author

So there's talk about just having this as a separate repo. I don't mind doing that but if that is the case we probably don't need to merge this PR.

@@ -41,7 +41,7 @@ func TestInsufficientMinGasPriceIntegration(t *testing.T) {
require.NoError(t, err)

fee := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(feeAmount)))
b, err := blob.NewBlob(namespace.RandomNamespace(), []byte("hello world"), 0)
b, err := blob.NewBlob(shares.RandomNamespace(), []byte("hello world"), 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

[Question] Is there any plan on isolating test related functionalities to their own package as well?

{1, 385, []int{128, 128, 128}, []uint32{2, 130, 258}},
{1024, 32, []int{32}, []uint32{1024}},
}
for i, tt := range tests {
res, indexes := BlobSharesUsedNonInteractiveDefaults(tt.cursor, appconsts.DefaultSubtreeRootThreshold, tt.blobLens...)
res, indexes := BlobSharesUsedNonInteractiveDefaults(tt.cursor, 64, tt.blobLens...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind elaborating why this const is replaced with a hardcoded value?

@@ -26,12 +25,12 @@ func TestBlobSharesUsedNonInteractiveDefaults(t *testing.T) {
{0, 10, []int{10}, []uint32{0}},
{1, 20, []int{10, 10}, []uint32{1, 11}},
{0, 1000, []int{1000}, []uint32{0}},
{0, appconsts.DefaultSquareSizeUpperBound + 1, []int{appconsts.DefaultSquareSizeUpperBound + 1}, []uint32{0}},
{0, 129, []int{129}, []uint32{0}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind elaborating why these are replaced with a hardcoded value?

@@ -0,0 +1,59 @@
package shares
Copy link
Contributor

Choose a reason for hiding this comment

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

This file seems to contain only test utilities, would be good to consider updating the file's name with some 'test' suffix.

// NamespaceVersionMaxValue is the maximum value a namespace version can be.
// This const must be updated if NamespaceVersionSize is changed.
NamespaceVersionMaxValue = math.MaxUint8

// NamespaceIDSize is the size of a namespace ID in bytes.
NamespaceIDSize = ns.NamespaceIDSize
NamespaceIDSize = shares.NamespaceIDSize
Copy link
Contributor

@staheri14 staheri14 Nov 10, 2023

Choose a reason for hiding this comment

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

[suggestion] Now that the share package will have its own go.mod, it might be more logical to define these constants e.g., NamespaceIDSize at the app level (where the share package is used and where the core logic of app resides). We can then pass them as parameters to the relevant structs and methods within the share package. If we decide to that, it may not fall within the scope of this PR though, could be part of another PR.

@rootulp
Copy link
Collaborator

rootulp commented Nov 14, 2023

Converting to draft b/c we may not merge this based on

So there's talk about just having this as a separate repo. I don't mind doing that but if that is the case we probably don't need to merge this PR.

@rootulp rootulp marked this pull request as draft November 14, 2023 16:30
@rootulp
Copy link
Collaborator

rootulp commented Dec 19, 2023

Assuming this is safe to close b/c we're moving most of this code to https://github.com/celestiaorg/go-square

@rootulp rootulp closed this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants