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

go/upgrade: Adjust MaxTxSize and MaxBlockSize in consensus240 handler #5588

Merged
merged 2 commits into from
Mar 8, 2024
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
4 changes: 4 additions & 0 deletions .changelog/5588.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/upgrade: Adjust MaxTxSize and MaxBlockSize in consensus240 handler

This is needed as DCAP quotes are larger and nodes running multiple
confidential runtimes may otherwise exceed the max transaction size.
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d
google.golang.org/grpc v1.59.0
google.golang.org/grpc/security/advancedtls v0.0.0-20221004221323-12db695f1648
google.golang.org/protobuf v1.31.0
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
18 changes: 18 additions & 0 deletions go/oasis-test-runner/scenario/e2e/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ func (c *upgrade240Checker) PreUpgradeFn(ctx context.Context, ctrl *oasis.Contro
}

func (c *upgrade240Checker) PostUpgradeFn(ctx context.Context, ctrl *oasis.Controller) error {
// Check updated consensus parameters.
consParams, err := ctrl.Consensus.GetParameters(ctx, consensus.HeightLatest)
if err != nil {
return fmt.Errorf("can't get consensus parameters: %w", err)
}
if expectedMaxTxSize := 128 * 1024; consParams.Parameters.MaxTxSize != uint64(expectedMaxTxSize) {
return fmt.Errorf("consensus parameter MaxTxSize not updated correctly (expected: %d actual: %d)",
expectedMaxTxSize,
consParams.Parameters.MaxTxSize,
)
}
if expectedMaxBlockSize := 4 * 1024 * 1024; consParams.Parameters.MaxBlockSize != uint64(expectedMaxBlockSize) {
return fmt.Errorf("consensus parameter MaxBlockSize not updated correctly (expected: %d actual: %d)",
expectedMaxBlockSize,
consParams.Parameters.MaxBlockSize,
)
}

// Check updated registry parameters.
registryParams, err := ctrl.Registry.ConsensusParameters(ctx, consensus.HeightLatest)
if err != nil {
Expand Down
23 changes: 19 additions & 4 deletions go/upgrade/migrations/consensus_240.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package migrations
import (
"fmt"

consensusState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/abci/state"
abciAPI "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api"
churpState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/keymanager/churp/state"
registryState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/registry/state"
"github.com/oasisprotocol/oasis-core/go/keymanager/churp"
)

const (
// Consensus240 is the name of the upgrade that transitions Oasis Core
// from version 23.0.x to 24.0.0.
// Consensus240 is the name of the upgrade that enables features introduced in Oasis Core 24.0.
//
// This upgrade enables the key manager CHURP extension.
// This upgrade enables the key manager CHURP extension and updates the MaxTxSize/MaxBlockSize
// in order to accommodate larger node registrations.
Consensus240 = "consensus240"
)

Expand All @@ -35,6 +36,20 @@ func (h *Handler240) ConsensusUpgrade(privateCtx interface{}) error {
case abciAPI.ContextBeginBlock:
// Nothing to do.
case abciAPI.ContextEndBlock:
// Consensus parameters.
consState := consensusState.NewMutableState(abciCtx.State())

consParams, err := consState.ConsensusParameters(abciCtx)
if err != nil {
return fmt.Errorf("failed to load consensus parameters: %w", err)
}
consParams.MaxTxSize = 131072 // 32 KiB -> 128 KiB
consParams.MaxBlockSize = 4194304 // 1 MiB -> 4 MiB

if err = consState.SetConsensusParameters(abciCtx, consParams); err != nil {
return fmt.Errorf("failed to set consensus parameters: %w", err)
}

// Registry.
regState := registryState.NewMutableState(abciCtx.State())

Expand All @@ -51,7 +66,7 @@ func (h *Handler240) ConsensusUpgrade(privateCtx interface{}) error {
// CHURP.
state := churpState.NewMutableState(abciCtx.State())

if err := state.SetConsensusParameters(abciCtx, &churp.DefaultConsensusParameters); err != nil {
if err = state.SetConsensusParameters(abciCtx, &churp.DefaultConsensusParameters); err != nil {
return fmt.Errorf("failed to set CHURP consensus parameters: %w", err)
}
default:
Expand Down
Loading