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

refactor: override the upgrade height for chain-id test to 3 #4065

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ PACKAGE_NAME := github.com/celestiaorg/celestia-app/v3
GOLANG_CROSS_VERSION ?= v1.23.1
# Set this to override the max square size of the binary
OVERRIDE_MAX_SQUARE_SIZE ?=
# Set this to override the upgrade height delay of the binary
OVERRIDE_UPGRADE_HEIGHT_DELAY ?=

# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
-X github.com/cosmos/cosmos-sdk/version.AppName=celestia-appd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/celestiaorg/celestia-app/v3/pkg/appconsts.OverrideSquareSizeUpperBoundStr=$(OVERRIDE_MAX_SQUARE_SIZE) \
-X github.com/celestiaorg/celestia-app/v3/pkg/appconsts.OverrideUpgradeHeightDelayStr=$(OVERRIDE_UPGRADE_HEIGHT_DELAY)
-X github.com/celestiaorg/celestia-app/v3/pkg/appconsts.OverrideSquareSizeUpperBoundStr=$(OVERRIDE_MAX_SQUARE_SIZE)

BUILD_FLAGS := -tags "ledger" -ldflags '$(ldflags)'

Expand Down
5 changes: 1 addition & 4 deletions app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ func TestAppUpgradeV3(t *testing.T) {
t.Skip("skipping TestAppUpgradeV3 in short mode")
}

appconsts.OverrideUpgradeHeightDelayStr = "1"
defer func() { appconsts.OverrideUpgradeHeightDelayStr = "" }()

testApp, genesis := SetupTestAppWithUpgradeHeight(t, 3)
upgradeFromV1ToV2(t, testApp)

Expand Down Expand Up @@ -104,7 +101,6 @@ func TestAppUpgradeV3(t *testing.T) {
require.NoError(t, err)
require.Equal(t, v3.Version, getUpgradeResp.Upgrade.AppVersion)

// brace yourselfs, this part may take a while
initialHeight := int64(4)
for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version); height++ {
appVersion := v2.Version
Expand Down Expand Up @@ -259,6 +255,7 @@ func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App,
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeight, util.EmptyAppOptions{})
genesis := genesis.NewDefaultGenesis().
WithChainID("test").
WithValidators(genesis.NewDefaultValidator(testnode.DefaultValidatorAccountName)).
WithConsensusParams(app.DefaultInitialConsensusParams())
genDoc, err := genesis.Export()
Expand Down
3 changes: 1 addition & 2 deletions docs/architecture/adr-015-namespace-id-size.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Users will specify a version (1 byte) and a ID (28 bytes) in their PFB. Addition

### Criteria 1

The namespace ID must provide at least 72 bits of randomness [^2] to satisfy criteria 1. Since an 8 byte namespace ID can only provide 64 bits of randomness, it fail to meet this criteria.
The namespace ID must provide at least 72 bits of randomness to satisfy criteria 1. Since an 8 byte namespace ID can only provide 64 bits of randomness, it fail to meet this criteria.

| Namespace ID size (bytes) | Criteria 1 |
|---------------------------|------------|
Expand Down Expand Up @@ -229,7 +229,6 @@ Note: to verify the number of SHA256 compression invocations, we analyzed the nu
- <https://github.com/celestiaorg/celestia-app/issues/1308>

[^1]: This assumes a user uses sufficient entropy to generate the namespace ID and isn't front-run by an adversary prior to actually using the namespace.
[^2]: <https://eager.io/blog/how-long-does-an-id-need-to-be/>
[^3]: <https://kevingal.com/apps/collision.html>
[^4]: <https://www.johndcook.com/blog/2017/01/10/probability-of-secure-hash-collisions/>
<!-- markdown-link-check-disable -->
Expand Down
1 change: 0 additions & 1 deletion pkg/appconsts/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ package appconsts
// Look at the Makefile to see how these are set.
var (
OverrideSquareSizeUpperBoundStr string
OverrideUpgradeHeightDelayStr string
)
9 changes: 2 additions & 7 deletions pkg/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ func GetTimeoutCommit(v uint64) time.Duration {

// UpgradeHeightDelay returns the delay in blocks after a quorum has been reached that the chain should upgrade to the new version.
func UpgradeHeightDelay(chainID string, v uint64) int64 {
if OverrideUpgradeHeightDelayStr != "" {
parsedValue, err := strconv.ParseInt(OverrideUpgradeHeightDelayStr, 10, 64)
if err != nil {
panic("Invalid OverrideUpgradeHeightDelayStr value")
}
return parsedValue
if chainID == "test" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit can we use a constant name (that can also be used in tests)

return 3
}
switch v {
case v1.Version:
Expand All @@ -100,6 +96,5 @@ func UpgradeHeightDelay(chainID string, v uint64) int64 {
return v2.UpgradeHeightDelay
default:
return v3.UpgradeHeightDelay

}
}
12 changes: 12 additions & 0 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ func TestUpgradeHeightDelay(t *testing.T) {
version: 3,
expectedUpgradeHeightDelay: v3.UpgradeHeightDelay,
},
{
name: "the upgrade delay for chainID 'test' should be 3 regardless of the version",
chainID: "test",
version: 3,
expectedUpgradeHeightDelay: 3,
},
{
name: "the upgrade delay for chainID 'test' should be 3 regardless of the version",
chainID: "test",
version: 4,
expectedUpgradeHeightDelay: 3,
},
}

for _, tc := range tests {
Expand Down
Loading