Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
cb7c8e8
refactor(db)!: own GoLevelDB and memory database adapters (#1551)
lklimek Oct 21, 2026
c516ed6
docs: specify full consensus parameter commitments for v2.0
lklimek Nov 4, 2026
2f9852c
Merge origin/v1.8-dev into docs/v2-consensus-params-commitment
lklimek Nov 4, 2026
b6dce43
Merge remote-tracking branch 'origin/dev' into docs/v2-consensus-para…
lklimek Nov 6, 2026
dccffb8
docs(book): list the v2.0 consensus parameter commitment chapter
lklimek Nov 6, 2026
8b942c3
Merge branch 'dev' into docs/v2-consensus-params-commitment
lklimek Nov 6, 2026
7643045
docs(spec)!: remove app version from consensus params and drop releas…
lklimek Nov 6, 2026
1428c0f
docs(spec)!: select full parameter commitment by consensus version
lklimek Nov 6, 2026
686f8be
feat(types)!: remove app version from consensus parameters
lklimek Nov 6, 2026
de6f24b
docs(spec): require monotonic consensus version without block protoco…
lklimek Nov 6, 2026
e68e80d
docs(spec): describe the impact of forged consensus parameters
lklimek Nov 6, 2026
b88ec6a
docs(spec): note minority polkas under a low voting-power threshold
lklimek Nov 6, 2026
cb3b4b7
Merge remote-tracking branch 'origin/dev' into docs/v2-consensus-para…
lklimek Nov 6, 2026
c832d43
docs(spec): frame low voting-power threshold as a configuration risk
lklimek Nov 6, 2026
eecb88d
Merge remote-tracking branch 'origin/dev' into docs/v2-consensus-para…
lklimek Nov 6, 2026
b0c4b8a
test: cover app version at InitChain and legacy params decoding
lklimek Nov 6, 2026
f3a81c2
docs(spec): require applications to choose their initial protocol ver…
lklimek Nov 6, 2026
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: 1 addition & 5 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ func (app *Application) InitChain(_ context.Context, req *abci.RequestInitChain)
}
consensusParams, ok := app.consensusParamsUpdates[app.initialHeight]
if !ok {
consensusParams = types1.ConsensusParams{
Version: &types1.VersionParams{
AppVersion: uint64(app.LastCommittedState.GetHeight()) + 1,
},
}
consensusParams = types1.ConsensusParams{}
}
vsu := app.getValidatorSetUpdate(app.initialHeight, 0)
if vsu == nil {
Expand Down
2 changes: 1 addition & 1 deletion abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestConsensusParamsUpdate(t *testing.T) {
genesisHeight + 4: {
ConsParamUpdates: &tmproto.ConsensusParams{
Version: &tmproto.VersionParams{
AppVersion: 123,
ConsensusVersion: tmproto.VersionParams_CONSENSUS_VERSION_1,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion abci/types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
- [Commit handling](spec/consensus/consensus-commit.md)
- [Recovery and synchronisation](spec/consensus/consensus-recovery.md)
- [Known issues and discrepancies](spec/consensus/consensus-known-issues.md)
- [Full consensus parameter commitment (draft)](spec/consensus/consensus-params-commitment.md)

# ABCI

Expand Down
53 changes: 53 additions & 0 deletions internal/consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,52 @@ func TestHandshakeInitialCoreLockHeight(t *testing.T) {
assert.Equal(t, InitialCoreHeight, state.LastCoreChainLockedBlockHeight)
}

// The application version recorded at height 0 comes from ResponseInfo. InitChain
// carries none, so processing its response must not reset it, even when the
// application returns a version parameter group.
func TestHandshakeInitChainKeepsInfoAppVersion(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

const infoAppVersion uint64 = 7
logger := log.NewNopLogger()
conf, err := ResetConfig(t, "handshake_test_init_chain_app_version")
require.NoError(t, err)

privVal, err := privval.LoadFilePV(conf.PrivValidator.KeyFile(), conf.PrivValidator.StateFile())
require.NoError(t, err)

eventBus := eventbus.NewDefault(logger)
require.NoError(t, eventBus.Start(ctx))

app := &initChainApp{
infoAppVersion: infoAppVersion,
consensusParams: &tmproto.ConsensusParams{
Version: &tmproto.VersionParams{ConsensusVersion: tmproto.VersionParams_CONSENSUS_VERSION_1},
},
}
client := abciclient.NewLocalClient(logger, app)

proTxHash, err := privVal.GetProTxHash(ctx)
require.NoError(t, err)
stateDB, state, store := stateAndStore(t, conf, 0x0)
stateStore := sm.NewStore(stateDB)
proxyApp := proxy.New(client, logger, proxy.NopMetrics())
require.NoError(t, proxyApp.Start(ctx), "Error starting proxy app connections")

genDoc, _ := sm.MakeGenesisDocFromFile(conf.GenesisFile())
replayer := newBlockReplayer(stateStore, store, genDoc, eventBus, proxyApp, proTxHash)
handshaker := NewHandshaker(replayer, logger, state)

_, err = handshaker.Handshake(ctx, proxyApp)
require.NoError(t, err, "error on abci handshake")

state, err = stateStore.Load()
require.NoError(t, err)
assert.Equal(t, infoAppVersion, state.Version.Consensus.App)
assert.EqualValues(t, tmproto.VersionParams_CONSENSUS_VERSION_1, state.ConsensusParams.Version.ConsensusVersion)
}

// walRoundsSkipperProposeTimeout replaces the test genesis' 30ms propose
// timeout on the node that generates the WAL for testWALRoundsSkipper. That
// node is the only validator, so it proposes every round and its propose
Expand Down Expand Up @@ -1546,11 +1592,18 @@ type initChainApp struct {
abci.BaseApplication
vals *abci.ValidatorSetUpdate
initialCoreHeight uint32
infoAppVersion uint64
consensusParams *tmproto.ConsensusParams
}

func (ica *initChainApp) Info(_ context.Context, _req *abci.RequestInfo) (*abci.ResponseInfo, error) {
return &abci.ResponseInfo{AppVersion: ica.infoAppVersion}, nil
}

func (ica *initChainApp) InitChain(_ context.Context, _req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
resp := abci.ResponseInitChain{
InitialCoreHeight: ica.initialCoreHeight,
ConsensusParams: ica.consensusParams,
}
if ica.vals != nil {
resp.ValidatorSetUpdate = *ica.vals
Expand Down
4 changes: 2 additions & 2 deletions internal/rpc/core/blocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestBlockResults(t *testing.T) {
},
ConsensusParamUpdates: &types.ConsensusParams{
Version: &types.VersionParams{
AppVersion: 1,
ConsensusVersion: types.VersionParams_CONSENSUS_VERSION_1,
},
},
},
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestBlockResults(t *testing.T) {
FinalizeBlockEvents: results.ProcessProposal.Events,
ValidatorSetUpdate: results.ProcessProposal.ValidatorSetUpdate,
ConsensusParamUpdates: &tmtypes.ConsensusParams{
Version: tmtypes.VersionParams{AppVersion: 1},
Version: tmtypes.VersionParams{ConsensusVersion: 1},
},
}},
}
Expand Down
1 change: 0 additions & 1 deletion internal/state/current_round_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func (candidate *CurrentRoundState) UpdateState(target *State) error {
target.LastResultsHash = candidate.ResultsHash
target.ConsensusParams = candidate.NextConsensusParams
target.LastHeightConsensusParamsChanged = candidate.LastHeightConsensusParamsChanged
target.Version.Consensus.App = candidate.NextConsensusParams.Version.AppVersion
target.Validators = candidate.NextValidators
target.LastHeightValidatorsChanged = candidate.LastHeightValidatorsChanged
if candidate.CoreChainLock != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,8 @@ func (state State) Update(
) (State, error) {

nextVersion := state.Version
// The proposer's PrepareProposal response sets the committed header's app version.
nextVersion.Consensus.App = header.Version.App

// NOTE: LastBlockRound, LastStateIDHash, AppHash and VoteExtension has not been populated.
// It will be filled on state.Save.
Expand Down
8 changes: 2 additions & 6 deletions internal/state/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ func (app *testApp) PrepareProposal(_ context.Context, req *abci.RequestPrepareP
AppHash: make([]byte, crypto.DefaultAppHashSize),
ValidatorSetUpdate: app.ValidatorSetUpdate,
ConsensusParamUpdates: &tmproto.ConsensusParams{
Version: &tmproto.VersionParams{
AppVersion: 1,
},
Version: &tmproto.VersionParams{},
},
AppVersion: 1,
TxResults: resTxs,
Expand All @@ -291,9 +289,7 @@ func (app *testApp) ProcessProposal(_ context.Context, req *abci.RequestProcessP
AppHash: make([]byte, crypto.DefaultAppHashSize),
ValidatorSetUpdate: app.ValidatorSetUpdate,
ConsensusParamUpdates: &tmproto.ConsensusParams{
Version: &tmproto.VersionParams{
AppVersion: 1,
},
Version: &tmproto.VersionParams{},
},
TxResults: resTxs,
Status: abci.ResponseProcessProposal_ACCEPT,
Expand Down
2 changes: 1 addition & 1 deletion internal/state/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func Rollback(bs BlockStore, ss Store) (int64, []byte, error) {
Version: Version{
Consensus: version.Consensus{
Block: version.BlockProtocol,
App: previousParams.Version.AppVersion,
App: rollbackBlock.Header.Version.App,
},
Software: version.TMCoreSemVer,
},
Expand Down
5 changes: 3 additions & 2 deletions internal/state/rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestRollback(t *testing.T) {

// perform the rollback over a version bump
newParams := types.DefaultConsensusParams()
newParams.Version.AppVersion = 11
newParams.Block.MaxBytes = 1000
nextState := initialState.Copy()
nextState.LastBlockHeight = nextHeight
Expand All @@ -45,6 +44,8 @@ func TestRollback(t *testing.T) {
block := &types.BlockMeta{
BlockID: initialState.LastBlockID,
Header: types.Header{
// The rolled-back state's app version comes from this header.
Version: version.Consensus{Block: version.BlockProtocol, App: initialState.Version.Consensus.App},
Height: initialState.LastBlockHeight,
AppHash: factory.RandomHash(),
LastBlockID: factory.MakeBlockID(),
Expand All @@ -57,6 +58,7 @@ func TestRollback(t *testing.T) {
nextBlock := &types.BlockMeta{
BlockID: initialState.LastBlockID,
Header: types.Header{
Version: version.Consensus{Block: version.BlockProtocol, App: 11},
Height: nextState.LastBlockHeight,
AppHash: initialState.LastAppHash,
LastBlockID: block.BlockID,
Expand Down Expand Up @@ -123,7 +125,6 @@ func setupStateStore(t *testing.T, height int64) state.Store {
valSet, _ := types.RandValidatorSet(5)

params := types.DefaultConsensusParams()
params.Version.AppVersion = 10

initialState := state.State{
Version: state.Version{
Expand Down
22 changes: 22 additions & 0 deletions internal/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
statefactory "github.com/dashpay/tenderdash/internal/state/test/factory"
tmstate "github.com/dashpay/tenderdash/proto/tendermint/state"
"github.com/dashpay/tenderdash/types"
"github.com/dashpay/tenderdash/version"
)

// setupTestCase does setup common to all test cases.
Expand Down Expand Up @@ -769,3 +770,24 @@ func assertLLMQDataWithValidatorSet(t *testing.T, ld *llmq.Data, valSet *types.V
}
require.Equal(t, ld.ThresholdPubKey, valSet.ThresholdPublicKey)
}

// The application version recorded in state follows the committed block header,
// which the proposer's PrepareProposal response sets; consensus parameters carry
// no application version.
func TestStateUpdateTakesAppVersionFromCommittedHeader(t *testing.T) {
tearDown, _, state := setupTestCase(t)
defer tearDown(t)

state.Version.Consensus.App = 1
ctx := dash.ContextWithProTxHash(context.Background(), state.Validators.GetByIndex(0).ProTxHash)
changes, err := state.NewStateChangeset(ctx, sm.RoundParams{})
require.NoError(t, err)

header := types.Header{
Version: version.Consensus{Block: version.BlockProtocol, App: 7},
Height: state.LastBlockHeight + 1,
}
newState, err := state.Update(types.BlockID{}, &header, &changes)
require.NoError(t, err)
assert.EqualValues(t, 7, newState.Version.Consensus.App)
}
3 changes: 2 additions & 1 deletion proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ message ResponsePrepareProposal {
tendermint.types.CoreChainLock core_chain_lock_update = 5;
// Changes to validator set that will be applied at next height.
ValidatorSetUpdate validator_set_update = 6 [(gogoproto.nullable) = true];
// Application version that was used to create the current proposal.
// Application protocol version used to create this proposal; MUST be non-zero.
// It becomes Header.Version.App. Validators' applications verify it in ProcessProposal.
uint64 app_version = 7;
}

Expand Down
3 changes: 2 additions & 1 deletion proto/tendermint/types/canonical.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion proto/tendermint/types/canonical.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ message CanonicalVote {
SignedMsgType type = 1; // type alias for byte
sfixed64 height = 2; // canonicalization requires fixed size encoding here
sfixed64 round = 3; // canonicalization requires fixed size encoding here
// block_id is a checksum (sha256) of CanonicalBlockID for the block being voted on
// block_id is a checksum (sha256) of CanonicalBlockID for the block being voted on.
// Its header hash binds current and next consensus parameter commitments.
bytes block_id = 4 [(gogoproto.customname) = "BlockID"];
// state_id is a checksum (sha256) of StateID message for the block being voted on
bytes state_id = 5 [(gogoproto.customname) = "StateID"];
Expand Down
Loading
Loading