diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml index fff08019ec..8f628ea3b8 100644 --- a/.github/workflows/docker-build-publish.yml +++ b/.github/workflows/docker-build-publish.yml @@ -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 }} @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c41d9dd8d6..28edf737be 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -29,7 +29,7 @@ jobs: # hadolint lints the Dockerfile hadolint: - uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.4.6 + uses: celestiaorg/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.5.0 with: dockerfile: "docker/Dockerfile" @@ -37,4 +37,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: celestiaorg/.github/.github/actions/yamllint@v0.4.6 + - uses: celestiaorg/.github/.github/actions/yamllint@v0.5.0 diff --git a/.github/workflows/pr-review-requester.yml b/.github/workflows/pr-review-requester.yml index 0e62d00940..487f52bc95 100644 --- a/.github/workflows/pr-review-requester.yml +++ b/.github/workflows/pr-review-requester.yml @@ -11,7 +11,7 @@ on: jobs: auto-request-review: name: Auto request reviews - uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.4.6 + uses: celestiaorg/.github/.github/workflows/reusable_housekeeping.yml@v0.5.0 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 diff --git a/Makefile b/Makefile index e095b08bb5..d946b5af93 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -264,6 +264,7 @@ enable-bbr: @if [ "$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')" != "bbr" ]; then \ echo "BBR is not enabled. Configuring BBR..."; \ sudo modprobe tcp_bbr; \ + echo tcp_bbr | sudo tee -a /etc/modules; \ echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.conf; \ echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.conf; \ sudo sysctl -p; \ @@ -273,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 = .*/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 = .*/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 + diff --git a/README.md b/README.md index 7854890901..44906140b4 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ system's kernel. The result should contain `bbr`: sysctl net.ipv4.tcp_congestion_control ``` -If not, enable it on Linux by calling the `make use-bbr` or by running: +If not, enable it on Linux by calling the `make enable-bbr` or by running: ```sh sudo modprobe tcp_bbr diff --git a/app/default_overrides.go b/app/default_overrides.go index 9e0b5dd382..39a5189188 100644 --- a/app/default_overrides.go +++ b/app/default_overrides.go @@ -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 } diff --git a/app/test/check_tx_test.go b/app/test/check_tx_test.go index 45ac426d88..aba7720547 100644 --- a/app/test/check_tx_test.go +++ b/app/test/check_tx_test.go @@ -189,11 +189,18 @@ func TestCheckTx(t *testing.T) { checkType: abci.CheckTxType_New, getTx: func() []byte { signer := createSigner(t, kr, accs[10], encCfg.TxConfig, 11) - blob, err := share.NewV1Blob(share.RandomBlobNamespace(), []byte("data"), testnode.RandomAddress().(sdk.AccAddress)) + blob, err := share.NewV1Blob(share.RandomBlobNamespace(), []byte("data"), signer.Account(accs[10]).Address()) require.NoError(t, err) blobTx, _, err := signer.CreatePayForBlobs(accs[10], []*share.Blob{blob}, opts...) require.NoError(t, err) - return blobTx + blob, err = share.NewV1Blob(share.RandomBlobNamespace(), []byte("data"), testnode.RandomAddress().(sdk.AccAddress)) + require.NoError(t, err) + bTx, _, err := tx.UnmarshalBlobTx(blobTx) + require.NoError(t, err) + bTx.Blobs[0] = blob + blobTxBytes, err := tx.MarshalBlobTx(bTx.Tx, bTx.Blobs[0]) + require.NoError(t, err) + return blobTxBytes }, expectedABCICode: blobtypes.ErrInvalidBlobSigner.ABCICode(), }, diff --git a/app/test/process_proposal_test.go b/app/test/process_proposal_test.go index 69f18b8bd4..33b1d406c5 100644 --- a/app/test/process_proposal_test.go +++ b/app/test/process_proposal_test.go @@ -321,8 +321,9 @@ func TestProcessProposal(t *testing.T) { falseAddr := testnode.RandomAddress().(sdk.AccAddress) blob, err := share.NewV1Blob(ns1, data, falseAddr) require.NoError(t, err) - msg, err := blobtypes.NewMsgPayForBlobs(addr.String(), appconsts.LatestVersion, blob) + msg, err := blobtypes.NewMsgPayForBlobs(falseAddr.String(), appconsts.LatestVersion, blob) require.NoError(t, err) + msg.Signer = addr.String() rawTx, err := signer.CreateTx([]sdk.Msg{msg}, user.SetGasLimit(100000), user.SetFee(100000)) require.NoError(t, err) diff --git a/app/test/square_size_test.go b/app/test/square_size_test.go index d030b89093..b7d147fe0d 100644 --- a/app/test/square_size_test.go +++ b/app/test/square_size_test.go @@ -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) diff --git a/app/test/upgrade_test.go b/app/test/upgrade_test.go index f200dc261e..ea79ad3a76 100644 --- a/app/test/upgrade_test.go +++ b/app/test/upgrade_test.go @@ -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{ @@ -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) @@ -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}, }, }) @@ -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) } diff --git a/docs/release-notes/release-notes.md b/docs/release-notes/release-notes.md index 1ca2be4f41..48e72f45ee 100644 --- a/docs/release-notes/release-notes.md +++ b/docs/release-notes/release-notes.md @@ -6,12 +6,64 @@ 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). -- 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. + +The following command can be used, if you are a validator in the active set, to signal to upgrade to v3 + +```bash +celestia-appd tx signal signal 3 +``` + +You can track the tally of signalling by validators using the following query + +```bash +celestia-appd query signal tally 3 +``` + +Once 5/6+ of the voting power have signalled, the upgrade will be ready. There is a hard coded delay between confirmation of the upgrade and execution to the new state machine. + +To view the upcoming upgrade height use the following query: + +```bash +celestia-appd query signal upgrade +> An upgrade is pending to app version 3 at height 2348907. +``` + +For more information refer to the module [docs](../../x/signal/README.md) ### Library Consumers (v3.0.0) diff --git a/go.mod b/go.mod index 01c4bf1be0..ab67f2cc19 100644 --- a/go.mod +++ b/go.mod @@ -34,10 +34,10 @@ require ( github.com/tendermint/tm-db v0.6.7 golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 - google.golang.org/grpc v1.67.1 + google.golang.org/grpc v1.68.0 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v2 v2.4.0 - k8s.io/apimachinery v0.31.1 + k8s.io/apimachinery v0.31.2 ) require ( @@ -230,7 +230,7 @@ require ( go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.27.0 // indirect golang.org/x/net v0.29.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/term v0.24.0 // indirect diff --git a/go.sum b/go.sum index 90e87978de..a81046b06a 100644 --- a/go.sum +++ b/go.sum @@ -1544,8 +1544,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1995,8 +1995,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2066,8 +2066,8 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI= -k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= -k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/apimachinery v0.31.2 h1:i4vUt2hPK56W6mlT7Ry+AO8eEsyxMD1U44NR22CLTYw= +k8s.io/apimachinery v0.31.2/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50= k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= diff --git a/pkg/appconsts/chain_ids.go b/pkg/appconsts/chain_ids.go new file mode 100644 index 0000000000..50c26932f9 --- /dev/null +++ b/pkg/appconsts/chain_ids.go @@ -0,0 +1,5 @@ +package appconsts + +const ( + ArabicaChainID = "arabica-11" +) diff --git a/pkg/appconsts/versioned_consts.go b/pkg/appconsts/versioned_consts.go index 2455e87791..6034453598 100644 --- a/pkg/appconsts/versioned_consts.go +++ b/pkg/appconsts/versioned_consts.go @@ -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 { @@ -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 diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index f621c0199e..249dd99805 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -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) + }) + } +} diff --git a/pkg/user/signer.go b/pkg/user/signer.go index 4b39c9bd31..0340e3ad57 100644 --- a/pkg/user/signer.go +++ b/pkg/user/signer.go @@ -92,10 +92,6 @@ func (s *Signer) CreatePayForBlobs(accountName string, blobs []*share.Blob, opts return nil, 0, fmt.Errorf("account %s not found", accountName) } - if err := blobtypes.ValidateBlobs(blobs...); err != nil { - return nil, 0, err - } - msg, err := blobtypes.NewMsgPayForBlobs(acc.address.String(), s.appVersion, blobs...) if err != nil { return nil, 0, err diff --git a/specs/src/parameters_v2.md b/specs/src/parameters_v2.md index 9bd3e63f25..ec93c9acda 100644 --- a/specs/src/parameters_v2.md +++ b/specs/src/parameters_v2.md @@ -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 diff --git a/specs/src/parameters_v3.md b/specs/src/parameters_v3.md index 860cdb286f..6f8d84fccb 100644 --- a/specs/src/parameters_v3.md +++ b/specs/src/parameters_v3.md @@ -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 diff --git a/test/e2e/testnet/defaults.go b/test/e2e/testnet/defaults.go index 6c6da2cbf9..a02ff9a70a 100644 --- a/test/e2e/testnet/defaults.go +++ b/test/e2e/testnet/defaults.go @@ -10,7 +10,7 @@ var DefaultResources = Resources{ } const ( - TxsimVersion = "pr-3541" + TxsimVersion = "8e573bb" MB = 1000 * 1000 GB = 1000 * MB MiB = 1024 * 1024 diff --git a/test/util/testnode/config.go b/test/util/testnode/config.go index 0ec6e7920e..76508f91d4 100644 --- a/test/util/testnode/config.go +++ b/test/util/testnode/config.go @@ -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. @@ -132,7 +132,7 @@ func DefaultConfig() *Config { WithTendermintConfig(DefaultTendermintConfig()). WithAppConfig(DefaultAppConfig()). WithAppOptions(DefaultAppOptions()). - WithAppCreator(DefaultAppCreator()). + WithTimeoutCommit(time.Millisecond * 30). WithSuppressLogs(true) } @@ -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( @@ -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 } } diff --git a/x/blob/types/payforblob.go b/x/blob/types/payforblob.go index b49eb05394..b282925323 100644 --- a/x/blob/types/payforblob.go +++ b/x/blob/types/payforblob.go @@ -1,6 +1,7 @@ package types import ( + "bytes" fmt "fmt" "cosmossdk.io/errors" @@ -42,12 +43,23 @@ const ( // See: https://github.com/cosmos/cosmos-sdk/blob/v0.46.15/docs/building-modules/messages-and-queries.md#legacy-amino-legacymsgs var _ legacytx.LegacyMsg = &MsgPayForBlobs{} -func NewMsgPayForBlobs(signer string, version uint64, blobs ...*share.Blob) (*MsgPayForBlobs, error) { +func NewMsgPayForBlobs(signer string, appVersion uint64, blobs ...*share.Blob) (*MsgPayForBlobs, error) { err := ValidateBlobs(blobs...) if err != nil { return nil, err } - commitments, err := inclusion.CreateCommitments(blobs, merkle.HashFromByteSlices, appconsts.SubtreeRootThreshold(version)) + + signerBytes, err := sdk.AccAddressFromBech32(signer) + if err != nil { + return nil, err + } + + err = ValidateBlobShareVersion(signerBytes, blobs...) + if err != nil { + return nil, err + } + + commitments, err := inclusion.CreateCommitments(blobs, merkle.HashFromByteSlices, appconsts.SubtreeRootThreshold(appVersion)) if err != nil { return nil, fmt.Errorf("creating commitments: %w", err) } @@ -217,6 +229,16 @@ func ValidateBlobs(blobs ...*share.Blob) error { return nil } +// ValidateBlobShareVersion validates any share version specific rules +func ValidateBlobShareVersion(signer sdk.AccAddress, blobs ...*share.Blob) error { + for _, blob := range blobs { + if blob.ShareVersion() == share.ShareVersionOne && !bytes.Equal(blob.Signer(), []byte(signer)) { + return ErrInvalidBlobSigner.Wrapf("blob signer %X does not match msgPFB signer %X", blob.Signer(), signer) + } + } + return nil +} + // ExtractBlobComponents separates and returns the components of a slice of // blobs. func ExtractBlobComponents(pblobs []*share.Blob) (namespaces []share.Namespace, sizes []uint32, shareVersions []uint32) { diff --git a/x/signal/integration_test.go b/x/signal/integration_test.go index c3dd2419dd..829a2d0be9 100644 --- a/x/signal/integration_test.go +++ b/x/signal/integration_test.go @@ -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) @@ -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) diff --git a/x/signal/keeper.go b/x/signal/keeper.go index 3ee13a9708..7e85e604d5 100644 --- a/x/signal/keeper.go +++ b/x/signal/keeper.go @@ -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) } diff --git a/x/signal/keeper_test.go b/x/signal/keeper_test.go index f79d1c3884..6c688a3328 100644 --- a/x/signal/keeper_test.go +++ b/x/signal/keeper_test.go @@ -183,7 +183,7 @@ func TestTallyingLogic(t *testing.T) { require.False(t, shouldUpgrade) // should be false because upgrade height hasn't been reached. require.Equal(t, uint64(0), version) - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(version)) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay("test", version)) shouldUpgrade, version = upgradeKeeper.ShouldUpgrade(ctx) require.True(t, shouldUpgrade) // should be true because upgrade height has been reached. @@ -426,7 +426,7 @@ func TestGetUpgrade(t *testing.T) { got, err := upgradeKeeper.GetUpgrade(ctx, &types.QueryGetUpgradeRequest{}) require.NoError(t, err) assert.Equal(t, v2.Version, got.Upgrade.AppVersion) - assert.Equal(t, appconsts.UpgradeHeightDelay(v2.Version), got.Upgrade.UpgradeHeight) + assert.Equal(t, appconsts.UpgradeHeightDelay("test", v2.Version), got.Upgrade.UpgradeHeight) }) } @@ -441,6 +441,7 @@ func setup(t *testing.T) (signal.Keeper, sdk.Context, *mockStakingKeeper) { Block: 1, App: 1, }, + ChainID: "test", }, false, log.NewNopLogger()) mockStakingKeeper := newMockStakingKeeper( map[string]int64{