Skip to content

Commit

Permalink
Merge branch 'celestiaorg:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bombermine3 authored Nov 7, 2024
2 parents ef94ce6 + 5d6c695 commit 8b6bdc2
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.6
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.5.0
with:
dockerfile: docker/Dockerfile
checkout_ref: ${{ github.event.inputs.ref }}
Expand All @@ -31,7 +31,7 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.6
uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.5.0
with:
dockerfile: docker/txsim/Dockerfile
packageName: txsim
Expand Down
52 changes: 49 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ prebuilt-binary:
## check-bbr: Check if your system uses BBR congestion control algorithm. Only works on Linux.
check-bbr:
@echo "Checking if BBR is enabled..."
@if [ "$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')" != "bbr" ]; then \
echo "WARNING: BBR is not enabled. Please enable BBR for optimal performance. Call make enable-bbr or see Usage section in the README."; \
@if [ "$$(sysctl net.ipv4.tcp_congestion_control | awk '{print $$3}')" != "bbr" ]; then \
echo "WARNING: BBR is not enabled. Please enable BBR for optimal performance. Call make enable-bbr or see Usage section in the README."; \
else \
echo "BBR is enabled."; \
echo "BBR is enabled."; \
fi
.PHONY: check-bbr

Expand All @@ -274,8 +274,54 @@ enable-bbr:
fi
.PHONY: enable-bbr

## enable-mptcp: Enable mptcp over multiple ports (not interfaces). Only works on Linux Kernel 5.6 and above.
enable-mptcp:
@echo "Configuring system to use mptcp..."
@sudo sysctl -w net.mptcp.enabled=1
@sudo sysctl -w net.mptcp.mptcp_path_manager=ndiffports
@sudo sysctl -w net.mptcp.mptcp_ndiffports=16
@echo "Making MPTCP settings persistent across reboots..."
@echo "net.mptcp.enabled=1" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_path_manager=ndiffports" | sudo tee -a /etc/sysctl.conf
@echo "net.mptcp.mptcp_ndiffports=16" | sudo tee -a /etc/sysctl.conf
@echo "MPTCP configuration complete and persistent!"

.PHONY: enable-mptcp

## disable-mptcp: Disables mptcp over multiple ports. Only works on Linux Kernel 5.6 and above.
disable-mptcp:
@echo "Disabling MPTCP..."
@sudo sysctl -w net.mptcp.enabled=0
@sudo sysctl -w net.mptcp.mptcp_path_manager=default
@echo "Removing MPTCP settings from /etc/sysctl.conf..."
@sudo sed -i '/net.mptcp.enabled=1/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_path_manager=ndiffports/d' /etc/sysctl.conf
@sudo sed -i '/net.mptcp.mptcp_ndiffports=16/d' /etc/sysctl.conf
@echo "MPTCP configuration reverted!"

.PHONY: disable-mptcp

CONFIG_FILE ?= ${HOME}/.celestia-app/config/config.toml
SEND_RECV_RATE ?= 10485760 # 10 MiB

configure-v3:
@echo "Using config file at: $(CONFIG_FILE)"; \
if [[ "$$(uname)" == "Darwin" ]]; then \
sed -i '' "s/^recv_rate = .*/recv_rate = $(SEND_RECV_RATE)/" $(CONFIG_FILE); \
sed -i '' "s/^send_rate = .*/send_rate = $(SEND_RECV_RATE)/" $(CONFIG_FILE); \
sed -i '' "s/ttl-num-blocks = 5/ttl-num-blocks = 12/" $(CONFIG_FILE); \
else \
sed -i "s/^recv_rate = .*/recv_rate = $(SEND_RECV_RATE)/" $(CONFIG_FILE); \
sed -i "s/^send_rate = .*/send_rate = $(SEND_RECV_RATE)/" $(CONFIG_FILE); \
sed -i "s/ttl-num-blocks = 5/ttl-num-blocks = 12/" $(CONFIG_FILE); \
fi

.PHONY: configure-v3


## debug-version: Print the git tag and version.
debug-version:
@echo "GIT_TAG: $(GIT_TAG)"
@echo "VERSION: $(VERSION)"
.PHONY: debug-version

4 changes: 4 additions & 0 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ func DefaultConsensusConfig() *tmcfg.Config {
cfg.TxIndex.Indexer = "null"
cfg.Storage.DiscardABCIResponses = true

const mebibyte = 1048576
cfg.P2P.SendRate = 10 * mebibyte
cfg.P2P.RecvRate = 10 * mebibyte

return cfg
}

Expand Down
4 changes: 3 additions & 1 deletion app/test/square_size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func (s *SquareSizeIntegrationTest) SetupSuite() {
t := s.T()
t.Log("setting up square size integration test")
s.ecfg = encoding.MakeConfig(app.ModuleEncodingRegisters...)

cfg := testnode.DefaultConfig().
WithModifiers(genesis.ImmediateProposals(s.ecfg.Codec))
WithModifiers(genesis.ImmediateProposals(s.ecfg.Codec)).
WithTimeoutCommit(time.Second)

cctx, rpcAddr, grpcAddr := testnode.NewNetwork(t, cfg)

Expand Down
8 changes: 4 additions & 4 deletions app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestAppUpgradeV3(t *testing.T) {

// brace yourselfs, this part may take a while
initialHeight := int64(4)
for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(v2.Version); height++ {
for height := initialHeight; height < initialHeight+appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version); height++ {
appVersion := v2.Version
_ = testApp.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
Expand All @@ -116,7 +116,7 @@ func TestAppUpgradeV3(t *testing.T) {
})

endBlockResp = testApp.EndBlock(abci.RequestEndBlock{
Height: 3 + appconsts.UpgradeHeightDelay(v2.Version),
Height: 3 + appconsts.UpgradeHeightDelay(testApp.GetChainID(), v2.Version),
})

require.Equal(t, appconsts.GetTimeoutCommit(appVersion), endBlockResp.Timeouts.TimeoutCommit)
Expand All @@ -141,7 +141,7 @@ func TestAppUpgradeV3(t *testing.T) {
_ = testApp.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
ChainID: genesis.ChainID,
Height: initialHeight + appconsts.UpgradeHeightDelay(v3.Version),
Height: initialHeight + appconsts.UpgradeHeightDelay(testApp.GetChainID(), v3.Version),
Version: tmversion.Consensus{App: 3},
},
})
Expand All @@ -152,7 +152,7 @@ func TestAppUpgradeV3(t *testing.T) {
require.Equal(t, abci.CodeTypeOK, deliverTxResp.Code, deliverTxResp.Log)

respEndBlock := testApp.EndBlock(abci.
RequestEndBlock{Height: initialHeight + appconsts.UpgradeHeightDelay(v3.Version)})
RequestEndBlock{Height: initialHeight + appconsts.UpgradeHeightDelay(testApp.GetChainID(), v3.Version)})
require.Equal(t, appconsts.GetTimeoutCommit(v3.Version), respEndBlock.Timeouts.TimeoutCommit)
require.Equal(t, appconsts.GetTimeoutPropose(v3.Version), respEndBlock.Timeouts.TimeoutPropose)
}
Expand Down
38 changes: 32 additions & 6 deletions docs/release-notes/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,39 @@ This guide provides notes for major version releases. These notes may be helpful

### Node Operators (v3.0.0)

- Consensus node operators must enable the BBR (Bottleneck Bandwidth and Round-trip propagation time) congestion control algorithm. See [#3774](https://github.com/celestiaorg/celestia-app/pull/3774).
- if using linux in docker, kubernetes, a vm or baremetal, this can be done by calling the `make enable-bbr` command on the host machine.
- Consensus node operators should manually configure their node's mempool `ttl-num-blocks = 12` in config.toml. An example command to do this:
#### Enabling BBR and MCTCP

```bash
sed -i 's/ttl-num-blocks = 5/ttl-num-blocks = 12/' ~/.celestia-app/config/config.toml
```
Consensus node operators must enable the BBR (Bottleneck Bandwidth and Round-trip propagation time) congestion control algorithm. See [#3774](https://github.com/celestiaorg/celestia-app/pull/3774).
if using linux in docker, kubernetes, a vm or baremetal, this can be done by calling

```sh
make enable-bbr
```

command on the host machine.

#### Configure Node for V3

Consensus node operators should update several configurations for v3. This can be done by calling:

```sh
make configure-v3
```

If the config file is not in the default spot, it can be provided using:

```sh
make configure-v3 CONFIG_FILE=path/to/other/config.toml
```

**Alternatively**, the configurations can be changed manually. This involves updating the mempool TTLs and the send and the receive rates.

- Configuring Bandwidth Settings
- update `recv_rate` and `send_rate` in your TOML config file to 10MiB (10485760).
- Extend TTLs
- update `ttl-num-blocks` in your TOML config file to 12.

#### Signaling Upgrades

- Upgrades now use the `x/signal` module to coordinate the network to an upgrade height.

Expand Down
5 changes: 5 additions & 0 deletions pkg/appconsts/chain_ids.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package appconsts

const (
ArabicaChainID = "arabica-11"
)
8 changes: 7 additions & 1 deletion pkg/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ 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(v uint64) int64 {
func UpgradeHeightDelay(chainID string, v uint64) int64 {
if OverrideUpgradeHeightDelayStr != "" {
parsedValue, err := strconv.ParseInt(OverrideUpgradeHeightDelayStr, 10, 64)
if err != nil {
Expand All @@ -91,6 +91,12 @@ func UpgradeHeightDelay(v uint64) int64 {
case v1.Version:
return v1.UpgradeHeightDelay
case v2.Version:
// ONLY ON ARABICA: don't return the v2 value even when the app version is
// v2 on arabica. This is due to a bug that was shipped on arabica, where
// the next version was used.
if chainID == ArabicaChainID {
return v3.UpgradeHeightDelay
}
return v2.UpgradeHeightDelay
default:
return v3.UpgradeHeightDelay
Expand Down
47 changes: 47 additions & 0 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,50 @@ func TestVersionedConsts(t *testing.T) {
})
}
}

func TestUpgradeHeightDelay(t *testing.T) {
tests := []struct {
name string
chainID string
version uint64
expectedUpgradeHeightDelay int64
}{
{
name: "v1 upgrade delay",
chainID: "test-chain",
version: v1.Version,
expectedUpgradeHeightDelay: v1.UpgradeHeightDelay,
},
{
name: "v1 arabica upgrade delay",
chainID: "arabica-11",
version: v1.Version,
expectedUpgradeHeightDelay: v1.UpgradeHeightDelay,
},
{
name: "v2 upgrade delay on non-arabica chain",
chainID: "celestia",
version: v2.Version,
expectedUpgradeHeightDelay: v2.UpgradeHeightDelay,
},
{
name: "v2 upgrade delay on arabica",
chainID: "arabica-11",
version: v2.Version,
expectedUpgradeHeightDelay: v3.UpgradeHeightDelay, // falls back to v3 because of arabica bug
},
{
name: "v3 upgrade delay",
chainID: "mocha-4",
version: 3,
expectedUpgradeHeightDelay: v3.UpgradeHeightDelay,
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := appconsts.UpgradeHeightDelay(tc.chainID, tc.version)
require.Equal(t, tc.expectedUpgradeHeightDelay, actual)
})
}
}
9 changes: 5 additions & 4 deletions specs/src/parameters_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ hardcoded in the application or they are blocked by the `x/paramfilter` module.

## Global parameters

| Parameter | Default | Summary | Changeable via Governance |
|-------------------|---------|------------------------------------------------------------------------------------------------------------------------|---------------------------|
| MaxBlockSizeBytes | 100MiB | Hardcoded value in CometBFT for the protobuf encoded block. | False |
| MaxSquareSize | 128 | Hardcoded maximum square size determined per shares per row or column for the original data square (not yet extended). | False |
| Parameter | Default | Summary | Changeable via Governance |
|--------------------|---------|------------------------------------------------------------------------------------------------------------------------|---------------------------|
| MaxBlockSizeBytes | 100MiB | Hardcoded value in CometBFT for the protobuf encoded block. | False |
| MaxSquareSize | 128 | Hardcoded maximum square size determined per shares per row or column for the original data square (not yet extended). | False |
| UpgradeHeightDelay | 50400 | Height based delay after a successful `MsgTryUpgrade` has been submitted. | False |

## Module parameters

Expand Down
9 changes: 5 additions & 4 deletions specs/src/parameters_v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ hardcoded in the application or they are blocked by the `x/paramfilter` module.

## Global parameters

| Parameter | Default | Summary | Changeable via Governance |
|-------------------|---------|------------------------------------------------------------------------------------------------------------------------|---------------------------|
| MaxBlockSizeBytes | 100MiB | Hardcoded value in CometBFT for the protobuf encoded block. | False |
| MaxSquareSize | 128 | Hardcoded maximum square size determined per shares per row or column for the original data square (not yet extended). | False |
| Parameter | Default | Summary | Changeable via Governance |
|--------------------|---------|------------------------------------------------------------------------------------------------------------------------|---------------------------|
| MaxBlockSizeBytes | 100MiB | Hardcoded value in CometBFT for the protobuf encoded block. | False |
| MaxSquareSize | 128 | Hardcoded maximum square size determined per shares per row or column for the original data square (not yet extended). | False |
| UpgradeHeightDelay | 100800 | Height based delay after a successful `MsgTryUpgrade` has been submitted. | False |

## Module parameters

Expand Down
24 changes: 18 additions & 6 deletions test/util/testnode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func (c *Config) WithSuppressLogs(sl bool) *Config {
return c
}

// WithTimeoutCommit sets the TimeoutCommit and returns the Config.
// WithTimeoutCommit sets the timeout commit in the cometBFT config and returns
// the Config.
func (c *Config) WithTimeoutCommit(d time.Duration) *Config {
c.TmConfig.Consensus.TimeoutCommit = d
return c
return c.WithAppCreator(DefaultAppCreator(WithTimeoutCommit(d)))
}

// WithFundedAccounts sets the genesis accounts and returns the Config.
Expand Down Expand Up @@ -132,7 +132,7 @@ func DefaultConfig() *Config {
WithTendermintConfig(DefaultTendermintConfig()).
WithAppConfig(DefaultAppConfig()).
WithAppOptions(DefaultAppOptions()).
WithAppCreator(DefaultAppCreator()).
WithTimeoutCommit(time.Millisecond * 30).
WithSuppressLogs(true)
}

Expand Down Expand Up @@ -171,7 +171,15 @@ func DefaultTendermintConfig() *tmconfig.Config {
return tmCfg
}

func DefaultAppCreator() srvtypes.AppCreator {
type AppCreationOptions func(app *app.App)

func WithTimeoutCommit(d time.Duration) AppCreationOptions {
return func(app *app.App) {
app.SetEndBlocker(wrapEndBlocker(app, d))
}
}

func DefaultAppCreator(opts ...AppCreationOptions) srvtypes.AppCreator {
return func(_ log.Logger, _ tmdb.DB, _ io.Writer, _ srvtypes.AppOptions) srvtypes.Application {
encodingConfig := encoding.MakeConfig(app.ModuleEncodingRegisters...)
app := app.New(
Expand All @@ -184,7 +192,11 @@ func DefaultAppCreator() srvtypes.AppCreator {
simapp.EmptyAppOptions{},
baseapp.SetMinGasPrices(fmt.Sprintf("%v%v", appconsts.DefaultMinGasPrice, app.BondDenom)),
)
app.SetEndBlocker(wrapEndBlocker(app, time.Millisecond*30))

for _, opt := range opts {
opt(app)
}

return app
}
}
Expand Down
4 changes: 3 additions & 1 deletion x/signal/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ func TestUpgradeIntegration(t *testing.T) {
cp := app.DefaultConsensusParams()
cp.Version.AppVersion = v2.Version
app, _ := testutil.SetupTestAppWithGenesisValSet(cp)
chainID := "test"
ctx := sdk.NewContext(app.CommitMultiStore(), tmtypes.Header{
Version: tmversion.Consensus{
App: v2.Version,
},
ChainID: chainID,
}, false, tmlog.NewNopLogger())
goCtx := sdk.WrapSDKContext(ctx)
ctx = sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -77,7 +79,7 @@ func TestUpgradeIntegration(t *testing.T) {
require.False(t, shouldUpgrade)
require.EqualValues(t, 0, version)

ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(version))
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(chainID, version))

shouldUpgrade, version = app.SignalKeeper.ShouldUpgrade(ctx)
require.True(t, shouldUpgrade)
Expand Down
3 changes: 2 additions & 1 deletion x/signal/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ func (k *Keeper) TryUpgrade(ctx context.Context, _ *types.MsgTryUpgrade) (*types
if version <= sdkCtx.BlockHeader().Version.App {
return &types.MsgTryUpgradeResponse{}, types.ErrInvalidUpgradeVersion.Wrapf("can not upgrade to version %v because it is less than or equal to current version %v", version, sdkCtx.BlockHeader().Version.App)
}
header := sdkCtx.BlockHeader()
upgrade := types.Upgrade{
AppVersion: version,
UpgradeHeight: sdkCtx.BlockHeader().Height + appconsts.UpgradeHeightDelay(version),
UpgradeHeight: header.Height + appconsts.UpgradeHeightDelay(header.ChainID, header.Version.App),
}
k.setUpgrade(sdkCtx, upgrade)
}
Expand Down
Loading

0 comments on commit 8b6bdc2

Please sign in to comment.