Skip to content

Commit

Permalink
Merge branch 'main' into namespace-version
Browse files Browse the repository at this point in the history
  • Loading branch information
amityadav0 authored Apr 11, 2023
2 parents 736ef26 + e905143 commit 1b7c0f9
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Version Release
uses: celestiaorg/.github/.github/actions/version-release@main
uses: celestiaorg/.github/.github/actions/version-release@v0.1.1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
version-bump: ${{inputs.version}}
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@main # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.1.1 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
2 changes: 1 addition & 1 deletion .github/workflows/housekeeping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
pr-assignment:
name: PR Auto Assignment
uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@main # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.1.1 # yamllint disable-line rule:line-length
secrets: inherit
# write access for issues and pull requests is needed because the called
# workflow requires write access to issues and pull requests and the
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ jobs:

# hadolint lints the Dockerfile
hadolint:
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@main # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.1.1 # yamllint disable-line rule:line-length

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: celestiaorg/.github/.github/actions/yamllint@main
- uses: celestiaorg/.github/.github/actions/yamllint@v0.1.1

markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: celestiaorg/.github/.github/actions/markdown-lint@main
- uses: celestiaorg/.github/.github/actions/markdown-lint@v0.1.1
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ celestia-appd --help
### Create your own single node devnet

```sh
# WARNING: this deletes config, data, and keyrings from previous local devnets
rm -r ~/.celestia-app
# Start a single node devnet
# Start a single node devnet using the pre-installed celestia app
./scripts/single-node.sh
# Build and start a single node devnet
./scripts/build-run-single-node.sh
# Post data to the local devnet
celestia-appd tx blob PayForBlobs [hexNamespace] [hexBlob] [flags]
```

**Note:** please note that the `./scripts/` commands above, created a random `tmp` directory and keeps all data/configs there.

<!-- markdown-link-check-disable -->
<!-- markdown-link encounters an HTTP 503 on this link even though it works. -->
<!-- See https://github.com/celestiaorg/celestia-app/actions/runs/3296219513/jobs/5439416229#step:4:185 -->
Expand Down
12 changes: 6 additions & 6 deletions app/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() {
val := s.network.Validators[0]
ns1 := appns.MustNewV0(bytes.Repeat([]byte{1}, appns.NamespaceVersionZeroIDSize))

mustNewBlob := func(ns appns.Namespace, data []byte) *blobtypes.Blob {
b, err := blobtypes.NewBlob(ns, data)
mustNewBlob := func(ns appns.Namespace, data []byte, shareVersion uint8) *blobtypes.Blob {
b, err := blobtypes.NewBlob(ns, data, shareVersion)
require.NoError(err)
return b
}
Expand All @@ -241,31 +241,31 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() {
tests := []test{
{
"small random typical",
mustNewBlob(ns1, tmrand.Bytes(3000)),
mustNewBlob(ns1, tmrand.Bytes(3000), appconsts.ShareVersionZero),
[]blobtypes.TxBuilderOption{
blobtypes.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))),
blobtypes.SetGasLimit(1_000_000_000),
},
},
{
"large random typical",
mustNewBlob(ns1, tmrand.Bytes(350000)),
mustNewBlob(ns1, tmrand.Bytes(350000), appconsts.ShareVersionZero),
[]types.TxBuilderOption{
blobtypes.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))),
blobtypes.SetGasLimit(1_000_000_000),
},
},
{
"medium random with memo",
mustNewBlob(ns1, tmrand.Bytes(100000)),
mustNewBlob(ns1, tmrand.Bytes(100000), appconsts.ShareVersionZero),
[]blobtypes.TxBuilderOption{
blobtypes.SetMemo("lol I could stick the rollup block here if I wanted to"),
blobtypes.SetGasLimit(1_000_000_000),
},
},
{
"medium random with timeout height",
mustNewBlob(ns1, tmrand.Bytes(100000)),
mustNewBlob(ns1, tmrand.Bytes(100000), appconsts.ShareVersionZero),
[]blobtypes.TxBuilderOption{
blobtypes.SetTimeoutHeight(1000),
blobtypes.SetGasLimit(1_000_000_000),
Expand Down
4 changes: 0 additions & 4 deletions proto/celestia/blob/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ option go_package = "github.com/celestiaorg/celestia-app/x/blob/types";
message Params {
option (gogoproto.goproto_stringer) = false;

uint32 min_square_size = 1
[ (gogoproto.moretags) = "yaml:\"min_square_size\"" ];
uint32 max_square_size = 2
[ (gogoproto.moretags) = "yaml:\"max_square_size\"" ];
uint32 gas_per_blob_byte = 3
[ (gogoproto.moretags) = "yaml:\"gas_per_blob_byte\"" ];
}
35 changes: 35 additions & 0 deletions scripts/build-run-single-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -o errexit -o nounset

HOME_DIR=$(mktemp -d -t "celestia_app_XXXXXXXXXXXXX")

echo "Home directory: ${HOME_DIR}"

make build || exit 1

BIN_PATH="./build/celestia-appd"

CHAINID="private"

# Build genesis file incl account for passed address
coins="1000000000000000utia"
${BIN_PATH} init $CHAINID --chain-id $CHAINID --home ${HOME_DIR}
${BIN_PATH} keys add validator --keyring-backend="test" --home ${HOME_DIR}
# this won't work because the some proto types are decalared twice and the logs output to stdout (dependency hell involving iavl)
${BIN_PATH} add-genesis-account $(${BIN_PATH} keys show validator -a --keyring-backend="test" --home ${HOME_DIR}) $coins --home ${HOME_DIR}
${BIN_PATH} gentx validator 5000000000utia \
--keyring-backend="test" \
--chain-id $CHAINID \
--home ${HOME_DIR} \
--evm-address 0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488 # private key: da6ed55cb2894ac2c9c10209c09de8e8b9d109b910338d5bf3d747a7e1fc9eb9

${BIN_PATH} collect-gentxs --home ${HOME_DIR}

# Set proper defaults and change ports
# If you encounter: `sed: -I or -i may not be used with stdin` on MacOS you can mitigate by installing gnu-sed
# https://gist.github.com/andre3k1/e3a1a7133fded5de5a9ee99c87c6fa0d?permalink_comment_id=3082272#gistcomment-3082272
sed -i'.bak' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ${HOME_DIR}/config/config.toml

# Start the celestia-app
${BIN_PATH} start --home ${HOME_DIR}
23 changes: 14 additions & 9 deletions scripts/single-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@

set -o errexit -o nounset

HOME_DIR=$(mktemp -d -t "celestia_app_XXXXXXXXXXXXX")

echo "Home directory: ${HOME_DIR}"

CHAINID="private"

# Build genesis file incl account for passed address
coins="1000000000000000utia"
celestia-appd init $CHAINID --chain-id $CHAINID
celestia-appd keys add validator --keyring-backend="test"
celestia-appd init $CHAINID --chain-id $CHAINID --home ${HOME_DIR}
celestia-appd keys add validator --keyring-backend="test" --home ${HOME_DIR}
# this won't work because the some proto types are decalared twice and the logs output to stdout (dependency hell involving iavl)
celestia-appd add-genesis-account $(celestia-appd keys show validator -a --keyring-backend="test") $coins
celestia-appd add-genesis-account $(celestia-appd keys show validator -a --keyring-backend="test" --home ${HOME_DIR}) $coins --home ${HOME_DIR}
celestia-appd gentx validator 5000000000utia \
--keyring-backend="test" \
--chain-id $CHAINID \
--evm-address 0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488 # private key: da6ed55cb2894ac2c9c10209c09de8e8b9d109b910338d5bf3d747a7e1fc9eb9
--keyring-backend="test" \
--chain-id $CHAINID \
--home ${HOME_DIR} \
--evm-address 0x966e6f22781EF6a6A82BBB4DB3df8E225DfD9488 # private key: da6ed55cb2894ac2c9c10209c09de8e8b9d109b910338d5bf3d747a7e1fc9eb9

celestia-appd collect-gentxs
celestia-appd collect-gentxs --home ${HOME_DIR}

# Set proper defaults and change ports
# If you encounter: `sed: -I or -i may not be used with stdin` on MacOS you can mitigate by installing gnu-sed
# https://gist.github.com/andre3k1/e3a1a7133fded5de5a9ee99c87c6fa0d?permalink_comment_id=3082272#gistcomment-3082272
sed -i'.bak' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.celestia-app/config/config.toml
sed -i'.bak' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ${HOME_DIR}/config/config.toml

# Start the celestia-app
celestia-appd start
celestia-appd start --home ${HOME_DIR}
13 changes: 7 additions & 6 deletions testutil/blobfactory/payforblob_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"testing"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-app/pkg/namespace"
appns "github.com/celestiaorg/celestia-app/pkg/namespace"
"github.com/celestiaorg/celestia-app/testutil/testfactory"
Expand All @@ -24,7 +25,7 @@ var defaultSigner = testfactory.RandomAddress().String()
func RandMsgPayForBlobsWithSigner(singer string, size, blobCount int) (*blobtypes.MsgPayForBlobs, []*tmproto.Blob) {
blobs := make([]*tmproto.Blob, blobCount)
for i := 0; i < blobCount; i++ {
blob, err := types.NewBlob(appns.RandomBlobNamespace(), tmrand.Bytes(size))
blob, err := types.NewBlob(appns.RandomBlobNamespace(), tmrand.Bytes(size), appconsts.ShareVersionZero)
if err != nil {
panic(err)
}
Expand All @@ -44,7 +45,7 @@ func RandMsgPayForBlobsWithSigner(singer string, size, blobCount int) (*blobtype
func RandBlobsWithNamespace(namespaces []appns.Namespace, sizes []int) []*tmproto.Blob {
blobs := make([]*tmproto.Blob, len(namespaces))
for i, ns := range namespaces {
blob, err := types.NewBlob(ns, tmrand.Bytes(sizes[i]))
blob, err := types.NewBlob(ns, tmrand.Bytes(sizes[i]), appconsts.ShareVersionZero)
if err != nil {
panic(err)
}
Expand All @@ -54,7 +55,7 @@ func RandBlobsWithNamespace(namespaces []appns.Namespace, sizes []int) []*tmprot
}

func RandMsgPayForBlobsWithNamespaceAndSigner(signer string, ns appns.Namespace, size int) (*blobtypes.MsgPayForBlobs, *tmproto.Blob) {
blob, err := types.NewBlob(ns, tmrand.Bytes(size))
blob, err := types.NewBlob(ns, tmrand.Bytes(size), appconsts.ShareVersionZero)
if err != nil {
panic(err)
}
Expand All @@ -69,7 +70,7 @@ func RandMsgPayForBlobsWithNamespaceAndSigner(signer string, ns appns.Namespace,
}

func RandMsgPayForBlobs(size int) (*blobtypes.MsgPayForBlobs, *tmproto.Blob) {
blob, err := types.NewBlob(namespace.RandomBlobNamespace(), tmrand.Bytes(size))
blob, err := types.NewBlob(namespace.RandomBlobNamespace(), tmrand.Bytes(size), appconsts.ShareVersionZero)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -300,7 +301,7 @@ func Repeat[T any](s T, count int) []T {
func ManyBlobs(t *testing.T, namespaces []appns.Namespace, sizes []int) []*tmproto.Blob {
blobs := make([]*tmproto.Blob, len(namespaces))
for i, ns := range namespaces {
blob, err := blobtypes.NewBlob(ns, tmrand.Bytes(sizes[i]))
blob, err := blobtypes.NewBlob(ns, tmrand.Bytes(sizes[i]), appconsts.ShareVersionZero)
require.NoError(t, err)
blobs[i] = blob
}
Expand All @@ -312,7 +313,7 @@ func NestedBlobs(t *testing.T, namespaces []appns.Namespace, sizes [][]int) [][]
counter := 0
for i, set := range sizes {
for _, size := range set {
blob, err := blobtypes.NewBlob(namespaces[counter], tmrand.Bytes(size))
blob, err := blobtypes.NewBlob(namespaces[counter], tmrand.Bytes(size), appconsts.ShareVersionZero)
require.NoError(t, err)
blobs[i] = append(blobs[i], blob)
counter++
Expand Down
2 changes: 1 addition & 1 deletion testutil/testnode/node_interaction_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *Context) PostData(account, broadcastMode string, ns appns.Namespace, bl
signer.SetAccountNumber(acc)
signer.SetSequence(seq)

blob, err := types.NewBlob(ns, blobData)
blob, err := types.NewBlob(ns, blobData, appconsts.ShareVersionZero)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions x/blob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ The blob module emits the following events:

## Parameters

| Key | Type | Example |
|---------------|--------|---------|
| MinSquareSize | uint32 | 1 |
| MaxSquareSize | uint32 | 128 |
| Key | Type | Default |
|----------------|--------|---------|
| GasPerBlobByte | uint32 | 8 |

### Usage

Expand Down
9 changes: 7 additions & 2 deletions x/blob/client/cli/payforblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
// FlagNamespaceVersion allows the user to override the namespace version when
// submitting a PayForBlob.
const FlagNamespaceVersion = "namespace-version"
// FlagShareVersion allows the user to override the share version when
// submitting a PayForBlob.
const FlagShareVersion = "share-version"

func CmdPayForBlob() *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -43,13 +46,15 @@ func CmdPayForBlob() *cobra.Command {
return err
}

shareVersion, _ := cmd.Flags().GetUint8(FlagShareVersion)

rawblob, err := hex.DecodeString(args[1])
if err != nil {
return fmt.Errorf("failure to decode hex blob: %w", err)
}

// TODO: allow for more than one blob to be sumbmitted via the cli
blob, err := types.NewBlob(namespace, rawblob)
blob, err := types.NewBlob(namespace, rawblob, shareVersion)
if err != nil {
return err
}
Expand All @@ -60,7 +65,7 @@ func CmdPayForBlob() *cobra.Command {

flags.AddTxFlagsToCmd(cmd)
cmd.PersistentFlags().Uint8(FlagNamespaceVersion, 0, "Specify the namespace version")

cmd.PersistentFlags().Uint8(FlagShareVersion, 0, "Specify the share version")
return cmd
}

Expand Down
3 changes: 2 additions & 1 deletion x/blob/client/cli/testrandblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strconv"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
appns "github.com/celestiaorg/celestia-app/pkg/namespace"
"github.com/celestiaorg/celestia-app/testutil/testfactory"
"github.com/celestiaorg/celestia-app/x/blob/types"
Expand Down Expand Up @@ -31,7 +32,7 @@ func CmdTestRandBlob() *cobra.Command {

ns := appns.RandomBlobNamespace()
coreBlob := testfactory.GenerateBlobsWithNamespace(1, size, ns)
blob, err := types.NewBlob(ns, coreBlob[0].Data)
blob, err := types.NewBlob(ns, coreBlob[0].Data, appconsts.ShareVersionZero)
if err != nil {
return fmt.Errorf("failure on generating random blob: %w", err)
}
Expand Down
15 changes: 15 additions & 0 deletions x/blob/client/testutil/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() {
expectedCode: 0,
respType: &sdk.TxResponse{},
},
{
name: "unsupported share version",
args: []string{
hexNamespace,
hexBlob,
fmt.Sprintf("--from=%s", username),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2))).String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=1", cli.FlagShareVersion),
},
expectErr: true,
expectedCode: 0,
respType: &sdk.TxResponse{},
},
{
name: "invalid namespace ID",
args: []string{
Expand Down
14 changes: 0 additions & 14 deletions x/blob/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
// GetParams gets all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.MinSquareSize(ctx),
k.MaxSquareSize(ctx),
k.GasPerBlobByte(ctx),
)
}
Expand All @@ -19,18 +17,6 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
k.paramStore.SetParamSet(ctx, &params)
}

// MinSquareSize returns the MinSquareSize param
func (k Keeper) MinSquareSize(ctx sdk.Context) (res uint32) {
k.paramStore.Get(ctx, types.KeyMinSquareSize, &res)
return
}

// MaxSquareSize returns the MaxSquareSize param
func (k Keeper) MaxSquareSize(ctx sdk.Context) (res uint32) {
k.paramStore.Get(ctx, types.KeyMaxSquareSize, &res)
return
}

// GasPerBlobByte returns the GasPerBlobByte param
func (k Keeper) GasPerBlobByte(ctx sdk.Context) (res uint32) {
k.paramStore.Get(ctx, types.KeyGasPerBlobByte, &res)
Expand Down
2 changes: 0 additions & 2 deletions x/blob/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ func TestGetParams(t *testing.T) {
k.SetParams(ctx, params)

require.EqualValues(t, params, k.GetParams(ctx))
require.EqualValues(t, params.MinSquareSize, k.MinSquareSize(ctx))
require.EqualValues(t, params.MaxSquareSize, k.MaxSquareSize(ctx))
require.EqualValues(t, params.GasPerBlobByte, k.GasPerBlobByte(ctx))
}
Loading

0 comments on commit 1b7c0f9

Please sign in to comment.