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!: disable x/blobstream in v2 #3310

Merged
merged 37 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d3d0434
feat!: disable blobstream in v2
rootulp Apr 12, 2024
753d5f6
feat: run migrations when module is removed
rootulp Apr 12, 2024
b575823
docs: state blobstream is disabled for v2
rootulp Apr 12, 2024
9bfc942
docs: remove blobstream from specs
rootulp Apr 12, 2024
31ad30e
feat: register migration boilerplate
rootulp Apr 12, 2024
a2c28f4
refactor: README and names
rootulp Apr 12, 2024
07bcfd9
Merge branch 'main' into rp/remove-blobstream
rootulp Apr 18, 2024
c3f8391
chore: disable blobstream
rootulp Apr 18, 2024
715cad5
feat: runModuleMigration
rootulp Apr 18, 2024
0e9914c
feat: alphabetize and remove blobstream v2 store key
rootulp Apr 18, 2024
119e93c
fix: typo
rootulp Apr 18, 2024
75bb0b5
feat: add commented out qgb register command
rootulp Apr 18, 2024
f1b2528
Merge branch 'main' into rp/remove-blobstream
rootulp Apr 23, 2024
ccf3b5d
feat: set hooks per version
rootulp Apr 23, 2024
d8945f7
add a test
rootulp Apr 23, 2024
ae6be09
refactor app.go
rootulp Apr 23, 2024
66ca18b
clarify test name
rootulp Apr 23, 2024
1892c99
make hooks no-op in version > 1
rootulp Apr 23, 2024
7b9dcef
revert: refactors
rootulp Apr 24, 2024
3e99bd2
revert: unnecessary changes
rootulp Apr 24, 2024
8a393ef
test: TestAfterValidatorBeginUnbonding
rootulp Apr 24, 2024
416e7fc
refactor: test
rootulp Apr 24, 2024
86ef546
test: TestAfterValidatorCreated
rootulp Apr 24, 2024
95d2e17
refactor: tests
rootulp Apr 24, 2024
4d37342
feat!: disable tx and query CLI commands
rootulp Apr 24, 2024
1e02a42
fix: lint
rootulp Apr 24, 2024
45e42e6
test: configurator
rootulp Apr 24, 2024
17daa1b
Revert "test: configurator"
rootulp Apr 24, 2024
8f84390
fix: integration test
rootulp Apr 24, 2024
fbe7354
fix: TestQueryAttestationByNonce
rootulp Apr 24, 2024
1061c24
fix: blobstream tests by using v1
rootulp Apr 24, 2024
618d592
test: manually test qgb tx commands
rootulp Apr 24, 2024
042c2e6
feat!(blobstream): disable CLI commands
rootulp Apr 24, 2024
e7be31b
revert: single-node.sh
rootulp Apr 24, 2024
f67293e
Update x/blobstream/keeper/hooks.go
rootulp Apr 25, 2024
b406002
refactor: use testEnv
rootulp Apr 25, 2024
46e9690
Merge branch 'main' into rp/remove-blobstream
rootulp Apr 25, 2024
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
6 changes: 2 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (app *App) setupModuleManager(skipGenesisInvariants bool) error {
},
{
Module: blobstream.NewAppModule(app.appCodec, app.BlobstreamKeeper),
FromVersion: v1, ToVersion: v2,
FromVersion: v1, ToVersion: v1,
},
{
Module: signal.NewAppModule(app.SignalKeeper),
Expand Down Expand Up @@ -299,8 +299,7 @@ func allStoreKeys() []string {
}
}

// versionedStoreKeys returns the store keys for each app version
// ... I wish there was an easier way than this (like using the modules which are already versioned)
// versionedStoreKeys returns the store keys for each app version.
func versionedStoreKeys() map[uint64][]string {
return map[uint64][]string{
1: {
Expand All @@ -325,7 +324,6 @@ func versionedStoreKeys() map[uint64][]string {
authtypes.StoreKey,
authzkeeper.StoreKey,
banktypes.StoreKey,
blobstreamtypes.StoreKey,
capabilitytypes.StoreKey,
distrtypes.StoreKey,
evidencetypes.StoreKey,
Expand Down
4 changes: 3 additions & 1 deletion app/test/qgb_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func TestBlobstreamRPCQueries(t *testing.T) {
t.Skip("skipping blobstream integration test in short mode.")
}
ecfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
cfg := testnode.DefaultConfig().WithModifiers(genesis.SetDataCommitmentWindow(ecfg.Codec, 100))
cfg := testnode.DefaultConfig().
WithModifiers(genesis.SetDataCommitmentWindow(ecfg.Codec, 100)).
WithConsensusParams(app.DefaultInitialConsensusParams())
rach-id marked this conversation as resolved.
Show resolved Hide resolved

cctx, _, _ := testnode.NewNetwork(t, cfg)

Expand Down
1 change: 0 additions & 1 deletion specs/src/specs/state_machine_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Celestia app is built using the cosmos-sdk, and follows standard cosmos-sdk modu
## `celestia-app` Specific Modules

- [blob](https://github.com/celestiaorg/celestia-app/blob/main/x/blob/README.md)
- [blobstream](https://github.com/celestiaorg/celestia-app/blob/main/x/blobstream/README.md)
- [minfee](https://github.com/celestiaorg/celestia-app/blob/main/x/minfee/README.md)
- [mint](https://github.com/celestiaorg/celestia-app/blob/main/x/mint/README.md)
- [paramfilter](https://github.com/celestiaorg/celestia-app/blob/main/x/paramfilter/README.md)
Expand Down
6 changes: 6 additions & 0 deletions x/blobstream/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# `x/blobstream`

> [!NOTE]
> The `x/blobstream` module was enabled for app version 1 and disabled in app version >= 2.

## Concepts

This module contains the [Blobstream](https://blog.celestia.org/celestiums/) state machine implementation.
Expand Down Expand Up @@ -226,6 +229,9 @@ If all the attestations in store are expired, which is an edge case that should

### Hooks

> [!NOTE]
> Hooks are no-ops for app versions >= 2.

#### Validator unbonding hook

When a validator starts unbonding, a [hook](https://github.com/celestiaorg/celestia-app/blob/0629c757ef35a24187a8d7a4c706c7cdc894c8b6/x/qgb/keeper/hooks.go#L23-L34) is executed that [sets](https://github.com/celestiaorg/celestia-app/blob/0629c757ef35a24187a8d7a4c706c7cdc894c8b6/x/qgb/keeper/hooks.go#LL33C2-L33C2) the `LatestUnBondingBlockHeight` to the current block height. This allows creating a new valset that removes that validator from the valset members so that he doesn't need to sign attestations afterwards.
Expand Down
3 changes: 2 additions & 1 deletion x/blobstream/client/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client_test
import (
"testing"

"github.com/celestiaorg/celestia-app/v2/app"
"github.com/celestiaorg/celestia-app/v2/test/util/testnode"
"github.com/stretchr/testify/suite"
tmrand "github.com/tendermint/tendermint/libs/rand"
Expand All @@ -19,7 +20,7 @@ func (s *CLITestSuite) SetupSuite() {
s.T().Skip("skipping Blobstream CLI tests in short mode.")
}

cfg := testnode.DefaultConfig()
cfg := testnode.DefaultConfig().WithConsensusParams(app.DefaultInitialConsensusParams())

numAccounts := 120
accounts := make([]string, numAccounts)
Expand Down
4 changes: 3 additions & 1 deletion x/blobstream/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func (s *BlobstreamIntegrationSuite) SetupSuite() {

s.accounts = []string{"jimmy"}

cfg := testnode.DefaultConfig().WithFundedAccounts(s.accounts...)
cfg := testnode.DefaultConfig().
WithFundedAccounts(s.accounts...).
WithConsensusParams(app.DefaultInitialConsensusParams())
cctx, _, _ := testnode.NewNetwork(t, cfg)
s.ecfg = encoding.MakeConfig(app.ModuleEncodingRegisters...)
s.cctx = cctx
Expand Down
19 changes: 13 additions & 6 deletions x/blobstream/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ func (k Keeper) Hooks() Hooks {
}

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error {
// When Validator starts Unbonding, Persist the block height in the store
// Later in endblocker, check if there is at least one validator who started
if ctx.BlockHeader().Version.App > 1 {
// no-op if the app version is greater than 1 because blobstream was disabled in v2.
return nil
}
// When Validator starts Unbonding, Persist the block height in the store.
// Later in EndBlocker, check if there is at least one validator who started
// unbonding and create a valset request. The reason for creating valset
// requests in endblock is to create only one valset request per block, if
// multiple validators starts unbonding at same block.
// requests in EndBlock is to create only one valset request per block if
// multiple validators start unbonding in the same block.

// this hook IS called for jailing or unbonding triggered by users but it IS
// This hook is called for jailing or unbonding triggered by users but it is
// NOT called for jailing triggered in the endblocker therefore we call the
// keeper function ourselves there.

h.k.SetLatestUnBondingBlockHeight(ctx, uint64(ctx.BlockHeight()))
return nil
}
Expand All @@ -41,6 +44,10 @@ func (h Hooks) BeforeDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.Va
}

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) error {
if ctx.BlockHeader().Version.App > 1 {
// no-op if the app version is greater than 1 because blobstream was disabled in v2.
return nil
}
defaultEvmAddr := types.DefaultEVMAddress(addr)
// This should practically never happen that we have a collision. It may be
// bad UX to reject the attempt to create a validator and require the user to
Expand Down
58 changes: 58 additions & 0 deletions x/blobstream/keeper/hooks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package keeper_test

import (
"testing"

"github.com/celestiaorg/celestia-app/v2/test/util"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
version "github.com/tendermint/tendermint/proto/tendermint/version"
)

func TestAfterValidatorBeginUnbonding(t *testing.T) {
testEnv := util.CreateTestEnv(t)
height := int64(1)

t.Run("should be a no-op if app version is 2", func(t *testing.T) {
ctx := testEnv.Context.WithBlockHeader(tmproto.Header{Version: version.Consensus{App: 2}, Height: height})
err := testEnv.BlobstreamKeeper.Hooks().AfterValidatorBeginUnbonding(ctx, sdk.ConsAddress{}, sdk.ValAddress{})
assert.NoError(t, err)

got := testEnv.BlobstreamKeeper.GetLatestUnBondingBlockHeight(ctx)
assert.Equal(t, uint64(0), got)
})
t.Run("should set latest unboding height if app version is 1", func(t *testing.T) {
ctx := testEnv.Context.WithBlockHeader(tmproto.Header{Version: version.Consensus{App: 1}, Height: height})
err := testEnv.BlobstreamKeeper.Hooks().AfterValidatorBeginUnbonding(ctx, sdk.ConsAddress{}, sdk.ValAddress{})
assert.NoError(t, err)

got := testEnv.BlobstreamKeeper.GetLatestUnBondingBlockHeight(ctx)
assert.Equal(t, uint64(height), got)
})
}

func TestAfterValidatorCreated(t *testing.T) {
testEnv := util.CreateTestEnv(t)
height := int64(1)
valAddress := sdk.ValAddress([]byte("valAddress"))
t.Run("should be a no-op if app version is 2", func(t *testing.T) {
ctx := testEnv.Context.WithBlockHeader(tmproto.Header{Version: version.Consensus{App: 2}, Height: height})
err := testEnv.BlobstreamKeeper.Hooks().AfterValidatorCreated(ctx, valAddress)
assert.NoError(t, err)

address, ok := testEnv.BlobstreamKeeper.GetEVMAddress(ctx, valAddress)
assert.False(t, ok)
assert.Empty(t, address)
})
t.Run("should set EVM address if app version is 1", func(t *testing.T) {
ctx := testEnv.Context.WithBlockHeader(tmproto.Header{Version: version.Consensus{App: 1}, Height: height})
err := testEnv.BlobstreamKeeper.Hooks().AfterValidatorCreated(ctx, valAddress)
assert.NoError(t, err)

address, ok := testEnv.BlobstreamKeeper.GetEVMAddress(ctx, valAddress)
assert.True(t, ok)
assert.Equal(t, common.HexToAddress("0x0000000000000000000076616C41646472657373"), address)
})
}
12 changes: 6 additions & 6 deletions x/blobstream/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"encoding/json"
"fmt"

bscmd "github.com/celestiaorg/celestia-app/v2/x/blobstream/client"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -79,14 +77,16 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
}
}

// GetTxCmd returns the capability module's root tx command.
// GetTxCmd returns no command because the blobstream module was disabled in app
// version 2.
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return bscmd.GetTxCmd()
return nil
rach-id marked this conversation as resolved.
Show resolved Hide resolved
}

// GetQueryCmd returns the capability module's root query command.
// GetQueryCmd returns no command because the blobstream module was disabled in
// app version 2.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return bscmd.GetQueryCmd()
return nil
rach-id marked this conversation as resolved.
Show resolved Hide resolved
}

// ----------------------------------------------------------------------------
Expand Down
Loading