From fdb40c82946253c9ee23c87c0d5a8f5035c8e93b Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 01:35:55 +0700 Subject: [PATCH 01/25] feat(abci)!: add the ApplyBlockRandomness method and commit beacon fields Add a new ABCI method, ApplyBlockRandomness, for same-block randomness. Tenderdash will call it at consensus version 2 with the random beacon of a block and round (the BLS threshold signature recovered from its prevotes), and the application returns the app hash the precommits sign. - proto: RequestApplyBlockRandomness {hash, height, round, beacon} and ResponseApplyBlockRandomness {app_hash} in the Request/Response oneofs and the ABCI service; CommitInfo.beacon and CommitInfo.app_hash; Commit.beacon and Commit.app_hash. - Go: Application interface, socket, gRPC, routed and local clients, socket server, proxy client with timing metrics, regenerated mocks. - BaseApplication returns ErrApplyBlockRandomnessNotImplemented: an empty app hash must never pass as an answer. - kvstore example: returns the app hash of the processed block unchanged. - types.Commit carries Beacon and AppHash through protobuf and CommitInfo. MaxCommitOverheadBytes grows by 132 bytes (96+2 for the beacon, 32+2 for the app hash). Nothing calls the method yet, and the new fields stay empty, so behaviour is unchanged apart from the larger commit overhead reserved by the mempool size pre-check. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- abci/client/grpc_client.go | 4 + abci/client/mocks/client.go | 68 ++ abci/client/routed_client.go | 5 + abci/client/socket_client.go | 10 + abci/example/kvstore/kvstore.go | 35 + abci/example/kvstore/kvstore_test.go | 42 + abci/server/socket_server.go | 6 + abci/types/application.go | 12 + abci/types/messages.go | 12 + abci/types/mocks/application.go | 68 ++ abci/types/types.pb.go | 1495 ++++++++++++++++++++------ abci/types/types_test.go | 9 + internal/proxy/client.go | 5 + internal/state/tx_filter_test.go | 2 +- node/node_test.go | 4 +- proto/tendermint/abci/types.proto | 111 +- proto/tendermint/types/types.pb.go | 311 ++++-- proto/tendermint/types/types.proto | 6 + spec/abci++/abci++_methods.md | 56 +- spec/abci++/api.md | 66 ++ types/block.go | 17 +- types/block_test.go | 31 +- 22 files changed, 1899 insertions(+), 476 deletions(-) diff --git a/abci/client/grpc_client.go b/abci/client/grpc_client.go index 0ffed9b399..b66dea9390 100644 --- a/abci/client/grpc_client.go +++ b/abci/client/grpc_client.go @@ -274,3 +274,7 @@ func (cli *grpcClient) VerifyVoteExtension(ctx context.Context, params *types.Re func (cli *grpcClient) FinalizeBlock(ctx context.Context, params *types.RequestFinalizeBlock) (*types.ResponseFinalizeBlock, error) { return cli.client.FinalizeBlock(ctx, types.ToRequestFinalizeBlock(params).GetFinalizeBlock(), grpc.WaitForReady(true)) } + +func (cli *grpcClient) ApplyBlockRandomness(ctx context.Context, params *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error) { + return cli.client.ApplyBlockRandomness(ctx, types.ToRequestApplyBlockRandomness(params).GetApplyBlockRandomness(), grpc.WaitForReady(true)) +} diff --git a/abci/client/mocks/client.go b/abci/client/mocks/client.go index b39444b38f..e75bf4676b 100644 --- a/abci/client/mocks/client.go +++ b/abci/client/mocks/client.go @@ -47,6 +47,74 @@ func (_m *Client) EXPECT() *Client_Expecter { return &Client_Expecter{mock: &_m.Mock} } +// ApplyBlockRandomness provides a mock function for the type Client +func (_mock *Client) ApplyBlockRandomness(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error) { + ret := _mock.Called(context1, requestApplyBlockRandomness) + + if len(ret) == 0 { + panic("no return value specified for ApplyBlockRandomness") + } + + var r0 *types.ResponseApplyBlockRandomness + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error)); ok { + return returnFunc(context1, requestApplyBlockRandomness) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.RequestApplyBlockRandomness) *types.ResponseApplyBlockRandomness); ok { + r0 = returnFunc(context1, requestApplyBlockRandomness) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ResponseApplyBlockRandomness) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, *types.RequestApplyBlockRandomness) error); ok { + r1 = returnFunc(context1, requestApplyBlockRandomness) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// Client_ApplyBlockRandomness_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyBlockRandomness' +type Client_ApplyBlockRandomness_Call struct { + *mock.Call +} + +// ApplyBlockRandomness is a helper method to define mock.On call +// - context1 context.Context +// - requestApplyBlockRandomness *types.RequestApplyBlockRandomness +func (_e *Client_Expecter) ApplyBlockRandomness(context1 any, requestApplyBlockRandomness any) *Client_ApplyBlockRandomness_Call { + return &Client_ApplyBlockRandomness_Call{Call: _e.mock.On("ApplyBlockRandomness", context1, requestApplyBlockRandomness)} +} + +func (_c *Client_ApplyBlockRandomness_Call) Run(run func(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness)) *Client_ApplyBlockRandomness_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *types.RequestApplyBlockRandomness + if args[1] != nil { + arg1 = args[1].(*types.RequestApplyBlockRandomness) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *Client_ApplyBlockRandomness_Call) Return(responseApplyBlockRandomness *types.ResponseApplyBlockRandomness, err error) *Client_ApplyBlockRandomness_Call { + _c.Call.Return(responseApplyBlockRandomness, err) + return _c +} + +func (_c *Client_ApplyBlockRandomness_Call) RunAndReturn(run func(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error)) *Client_ApplyBlockRandomness_Call { + _c.Call.Return(run) + return _c +} + // ApplySnapshotChunk provides a mock function for the type Client func (_mock *Client) ApplySnapshotChunk(context1 context.Context, requestApplySnapshotChunk *types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) { ret := _mock.Called(context1, requestApplySnapshotChunk) diff --git a/abci/client/routed_client.go b/abci/client/routed_client.go index fa1afc1bc3..9878f20537 100644 --- a/abci/client/routed_client.go +++ b/abci/client/routed_client.go @@ -375,3 +375,8 @@ func (cli *routedClient) FinalizeBlock(ctx context.Context, req *types.RequestFi result, err := cli.delegate(ctx, req) return result.(*types.ResponseFinalizeBlock), err } + +func (cli *routedClient) ApplyBlockRandomness(ctx context.Context, req *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error) { + result, err := cli.delegate(ctx, req) + return result.(*types.ResponseApplyBlockRandomness), err +} diff --git a/abci/client/socket_client.go b/abci/client/socket_client.go index fb046187d8..5c3b2a8270 100644 --- a/abci/client/socket_client.go +++ b/abci/client/socket_client.go @@ -397,6 +397,14 @@ func (cli *socketClient) FinalizeBlock(ctx context.Context, req *types.RequestFi return res.GetFinalizeBlock(), nil } +func (cli *socketClient) ApplyBlockRandomness(ctx context.Context, req *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error) { + res, err := cli.doRequest(ctx, types.ToRequestApplyBlockRandomness(req)) + if err != nil { + return nil, err + } + return res.GetApplyBlockRandomness(), nil +} + //---------------------------------------- func resMatchesReq(req *types.Request, res *types.Response) (ok bool) { @@ -431,6 +439,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) { _, ok = res.Value.(*types.Response_OfferSnapshot) case *types.Request_FinalizeBlock: _, ok = res.Value.(*types.Response_FinalizeBlock) + case *types.Request_ApplyBlockRandomness: + _, ok = res.Value.(*types.Response_ApplyBlockRandomness) } return ok } diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index 02e287e7a0..82016f0eda 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -490,6 +490,41 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali return resp, nil } +// ApplyBlockRandomness implements ABCI. The example application uses no randomness, so it returns +// the app hash of the state that PrepareProposal or ProcessProposal left for the block and round. +func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { + app.mu.Lock() + defer app.mu.Unlock() + + roundState, err := app.processedRoundState(req.Height, req.Round) + if err != nil { + return nil, fmt.Errorf("apply block randomness (hash: %X): %w", req.Hash, err) + } + + resp := &abci.ResponseApplyBlockRandomness{AppHash: roundState.GetAppHash()} + app.logger.Debug("ApplyBlockRandomness", "req", req, "resp", resp) + return resp, nil +} + +// processedRoundState returns the state of the proposal executed at the given height and round. +// Caller should lock the Application. +func (app *Application) processedRoundState(height int64, round int32) (State, error) { + var found State + for _, state := range app.roundStates { + if state.GetHeight() != height || state.GetRound() != round { + continue + } + if found != nil { + return nil, fmt.Errorf("more than one proposal executed at height %d round %d", height, round) + } + found = state + } + if found == nil { + return nil, fmt.Errorf("no proposal executed at height %d round %d", height, round) + } + return found, nil +} + // eventValUpdate generates an event that contains info about current validator set func (app *Application) eventValUpdate(height int64) abci.Event { size := 0 diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index e109c851d2..d541b83b5f 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -441,6 +441,13 @@ func testClient(ctx context.Context, t *testing.T, app abciclient.Client, height require.False(t, rpp.TxResults[0].IsErr()) require.Len(t, rpp.Events, 1) + rabr, err := app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{ + Height: height, + Beacon: tmcrypto.CRandBytes(tmtypes.SignatureSize), + }) + require.NoError(t, err) + require.Equal(t, rpp.AppHash, rabr.AppHash, "no randomness is applied, so the app hash is unchanged") + rfb := &types.RequestFinalizeBlock{Height: height} rfb.Block, rfb.BlockID = makeBlock(t, height, [][]byte{tx}, rpp.AppHash) ar, err := app.FinalizeBlock(ctx, rfb) @@ -644,3 +651,38 @@ func TestProcessProposalRoundReprocessing(t *testing.T) { _, err = app.FinalizeBlock(ctx, reqFin) require.NoError(t, err) } + +// TestApplyBlockRandomness checks that ApplyBlockRandomness answers for the round that was processed, +// gives the same answer when called again, and fails for a round that was not processed. +func TestApplyBlockRandomness(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + app := newKvApp(ctx, t, 1) + const height = 1 + resp, err := app.ProcessProposal(ctx, &types.RequestProcessProposal{ + Txs: [][]byte{[]byte(testKey)}, + Hash: []byte("block-hash"), + Height: height, + Round: 1, + Version: &pbversion.Consensus{App: uint64(height)}, + }) + require.NoError(t, err) + + req := &types.RequestApplyBlockRandomness{ + Hash: []byte("block-hash"), + Height: height, + Round: 1, + Beacon: tmcrypto.CRandBytes(tmtypes.SignatureSize), + } + first, err := app.ApplyBlockRandomness(ctx, req) + require.NoError(t, err) + require.Equal(t, resp.AppHash, first.AppHash) + + again, err := app.ApplyBlockRandomness(ctx, req) + require.NoError(t, err) + require.Equal(t, first.AppHash, again.AppHash) + + _, err = app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{Height: height, Round: 0}) + require.ErrorContains(t, err, "no proposal executed") +} diff --git a/abci/server/socket_server.go b/abci/server/socket_server.go index 650d9828f2..c1ef4e627c 100644 --- a/abci/server/socket_server.go +++ b/abci/server/socket_server.go @@ -280,6 +280,12 @@ func (s *SocketServer) processRequest(ctx context.Context, req *types.Request) ( return nil, err } return types.ToResponseFinalizeBlock(res), nil + case *types.Request_ApplyBlockRandomness: + res, err := s.app.ApplyBlockRandomness(ctx, r.ApplyBlockRandomness) + if err != nil { + return nil, err + } + return types.ToResponseApplyBlockRandomness(res), nil default: return types.ToResponseException("Unknown request"), errors.New("unknown request type") } diff --git a/abci/types/application.go b/abci/types/application.go index fe7b60bca4..a77149b554 100644 --- a/abci/types/application.go +++ b/abci/types/application.go @@ -2,10 +2,14 @@ package types import ( "context" + "errors" "github.com/dashpay/tenderdash/crypto" ) +// ErrApplyBlockRandomnessNotImplemented is returned by BaseApplication.ApplyBlockRandomness. +var ErrApplyBlockRandomnessNotImplemented = errors.New("ApplyBlockRandomness is not implemented by the application") + // StateSyncer is an interface that handles the state sync protocol type StateSyncer interface { // ListSnapshots returns list available snapshots @@ -42,6 +46,8 @@ type Application interface { VerifyVoteExtension(context.Context, *RequestVerifyVoteExtension) (*ResponseVerifyVoteExtension, error) // Deliver the decided block with its txs to the Application FinalizeBlock(context.Context, *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) + // Apply the block's random beacon and return the app hash the precommit signs (consensus version 2) + ApplyBlockRandomness(context.Context, *RequestApplyBlockRandomness) (*ResponseApplyBlockRandomness, error) } //------------------------------------------------------- @@ -137,3 +143,9 @@ func (BaseApplication) FinalizeBlock(_ context.Context, _req *RequestFinalizeBlo return &ResponseFinalizeBlock{}, nil } + +// ApplyBlockRandomness returns an error: an empty app hash must never pass as an answer, so applications +// that run at consensus version 2 must implement it. +func (BaseApplication) ApplyBlockRandomness(_ context.Context, _req *RequestApplyBlockRandomness) (*ResponseApplyBlockRandomness, error) { + return nil, ErrApplyBlockRandomnessNotImplemented +} diff --git a/abci/types/messages.go b/abci/types/messages.go index fed82db198..1e762f5243 100644 --- a/abci/types/messages.go +++ b/abci/types/messages.go @@ -117,6 +117,12 @@ func ToRequestFinalizeBlock(req *RequestFinalizeBlock) *Request { } } +func ToRequestApplyBlockRandomness(req *RequestApplyBlockRandomness) *Request { + return &Request{ + Value: &Request_ApplyBlockRandomness{req}, + } +} + //---------------------------------------- func ToResponseException(errStr string) *Response { @@ -214,3 +220,9 @@ func ToResponseFinalizeBlock(res *ResponseFinalizeBlock) *Response { Value: &Response_FinalizeBlock{res}, } } + +func ToResponseApplyBlockRandomness(res *ResponseApplyBlockRandomness) *Response { + return &Response{ + Value: &Response_ApplyBlockRandomness{res}, + } +} diff --git a/abci/types/mocks/application.go b/abci/types/mocks/application.go index c63b765649..e47bde6873 100644 --- a/abci/types/mocks/application.go +++ b/abci/types/mocks/application.go @@ -47,6 +47,74 @@ func (_m *Application) EXPECT() *Application_Expecter { return &Application_Expecter{mock: &_m.Mock} } +// ApplyBlockRandomness provides a mock function for the type Application +func (_mock *Application) ApplyBlockRandomness(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error) { + ret := _mock.Called(context1, requestApplyBlockRandomness) + + if len(ret) == 0 { + panic("no return value specified for ApplyBlockRandomness") + } + + var r0 *types.ResponseApplyBlockRandomness + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error)); ok { + return returnFunc(context1, requestApplyBlockRandomness) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.RequestApplyBlockRandomness) *types.ResponseApplyBlockRandomness); ok { + r0 = returnFunc(context1, requestApplyBlockRandomness) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.ResponseApplyBlockRandomness) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, *types.RequestApplyBlockRandomness) error); ok { + r1 = returnFunc(context1, requestApplyBlockRandomness) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// Application_ApplyBlockRandomness_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyBlockRandomness' +type Application_ApplyBlockRandomness_Call struct { + *mock.Call +} + +// ApplyBlockRandomness is a helper method to define mock.On call +// - context1 context.Context +// - requestApplyBlockRandomness *types.RequestApplyBlockRandomness +func (_e *Application_Expecter) ApplyBlockRandomness(context1 any, requestApplyBlockRandomness any) *Application_ApplyBlockRandomness_Call { + return &Application_ApplyBlockRandomness_Call{Call: _e.mock.On("ApplyBlockRandomness", context1, requestApplyBlockRandomness)} +} + +func (_c *Application_ApplyBlockRandomness_Call) Run(run func(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness)) *Application_ApplyBlockRandomness_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *types.RequestApplyBlockRandomness + if args[1] != nil { + arg1 = args[1].(*types.RequestApplyBlockRandomness) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *Application_ApplyBlockRandomness_Call) Return(responseApplyBlockRandomness *types.ResponseApplyBlockRandomness, err error) *Application_ApplyBlockRandomness_Call { + _c.Call.Return(responseApplyBlockRandomness, err) + return _c +} + +func (_c *Application_ApplyBlockRandomness_Call) RunAndReturn(run func(context1 context.Context, requestApplyBlockRandomness *types.RequestApplyBlockRandomness) (*types.ResponseApplyBlockRandomness, error)) *Application_ApplyBlockRandomness_Call { + _c.Call.Return(run) + return _c +} + // ApplySnapshotChunk provides a mock function for the type Application func (_mock *Application) ApplySnapshotChunk(context1 context.Context, requestApplySnapshotChunk *types.RequestApplySnapshotChunk) (*types.ResponseApplySnapshotChunk, error) { ret := _mock.Called(context1, requestApplySnapshotChunk) diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 87837539b6..972df8ed8f 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -125,7 +125,7 @@ func (x ResponseOfferSnapshot_Result) String() string { } func (ResponseOfferSnapshot_Result) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{25, 0} + return fileDescriptor_252557cfdd89a31a, []int{26, 0} } type ResponseApplySnapshotChunk_Result int32 @@ -165,7 +165,7 @@ func (x ResponseApplySnapshotChunk_Result) String() string { } func (ResponseApplySnapshotChunk_Result) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{27, 0} + return fileDescriptor_252557cfdd89a31a, []int{28, 0} } type ResponseProcessProposal_ProposalStatus int32 @@ -193,7 +193,7 @@ func (x ResponseProcessProposal_ProposalStatus) String() string { } func (ResponseProcessProposal_ProposalStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{29, 0} + return fileDescriptor_252557cfdd89a31a, []int{30, 0} } type ResponseVerifyVoteExtension_VerifyStatus int32 @@ -221,7 +221,7 @@ func (x ResponseVerifyVoteExtension_VerifyStatus) String() string { } func (ResponseVerifyVoteExtension_VerifyStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{32, 0} + return fileDescriptor_252557cfdd89a31a, []int{33, 0} } // TxAction contains App-provided information on what to do with a transaction that is part of a raw proposal @@ -256,7 +256,7 @@ func (x TxRecord_TxAction) String() string { } func (TxRecord_TxAction) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{39, 0} + return fileDescriptor_252557cfdd89a31a, []int{41, 0} } // Request types @@ -277,6 +277,7 @@ type Request struct { // *Request_ExtendVote // *Request_VerifyVoteExtension // *Request_FinalizeBlock + // *Request_ApplyBlockRandomness Value isRequest_Value `protobuf_oneof:"value"` } @@ -364,22 +365,26 @@ type Request_VerifyVoteExtension struct { type Request_FinalizeBlock struct { FinalizeBlock *RequestFinalizeBlock `protobuf:"bytes,19,opt,name=finalize_block,json=finalizeBlock,proto3,oneof" json:"finalize_block,omitempty"` } - -func (*Request_Echo) isRequest_Value() {} -func (*Request_Flush) isRequest_Value() {} -func (*Request_Info) isRequest_Value() {} -func (*Request_InitChain) isRequest_Value() {} -func (*Request_Query) isRequest_Value() {} -func (*Request_CheckTx) isRequest_Value() {} -func (*Request_ListSnapshots) isRequest_Value() {} -func (*Request_OfferSnapshot) isRequest_Value() {} -func (*Request_LoadSnapshotChunk) isRequest_Value() {} -func (*Request_ApplySnapshotChunk) isRequest_Value() {} -func (*Request_PrepareProposal) isRequest_Value() {} -func (*Request_ProcessProposal) isRequest_Value() {} -func (*Request_ExtendVote) isRequest_Value() {} -func (*Request_VerifyVoteExtension) isRequest_Value() {} -func (*Request_FinalizeBlock) isRequest_Value() {} +type Request_ApplyBlockRandomness struct { + ApplyBlockRandomness *RequestApplyBlockRandomness `protobuf:"bytes,20,opt,name=apply_block_randomness,json=applyBlockRandomness,proto3,oneof" json:"apply_block_randomness,omitempty"` +} + +func (*Request_Echo) isRequest_Value() {} +func (*Request_Flush) isRequest_Value() {} +func (*Request_Info) isRequest_Value() {} +func (*Request_InitChain) isRequest_Value() {} +func (*Request_Query) isRequest_Value() {} +func (*Request_CheckTx) isRequest_Value() {} +func (*Request_ListSnapshots) isRequest_Value() {} +func (*Request_OfferSnapshot) isRequest_Value() {} +func (*Request_LoadSnapshotChunk) isRequest_Value() {} +func (*Request_ApplySnapshotChunk) isRequest_Value() {} +func (*Request_PrepareProposal) isRequest_Value() {} +func (*Request_ProcessProposal) isRequest_Value() {} +func (*Request_ExtendVote) isRequest_Value() {} +func (*Request_VerifyVoteExtension) isRequest_Value() {} +func (*Request_FinalizeBlock) isRequest_Value() {} +func (*Request_ApplyBlockRandomness) isRequest_Value() {} func (m *Request) GetValue() isRequest_Value { if m != nil { @@ -493,6 +498,13 @@ func (m *Request) GetFinalizeBlock() *RequestFinalizeBlock { return nil } +func (m *Request) GetApplyBlockRandomness() *RequestApplyBlockRandomness { + if x, ok := m.GetValue().(*Request_ApplyBlockRandomness); ok { + return x.ApplyBlockRandomness + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*Request) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -511,6 +523,7 @@ func (*Request) XXX_OneofWrappers() []interface{} { (*Request_ExtendVote)(nil), (*Request_VerifyVoteExtension)(nil), (*Request_FinalizeBlock)(nil), + (*Request_ApplyBlockRandomness)(nil), } } @@ -1998,6 +2011,101 @@ func (m *RequestFinalizeBlock) GetBlockID() *types1.BlockID { return nil } +// Applies the block's randomness and returns the app hash the Precommit signs. +// +// #### Usage +// +// - Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. +// - `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold +// signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against +// the quorum's threshold public key before the call. +// - The Application applies the randomness to the state that `ProcessProposal` (or `PrepareProposal`) left for +// that block and round, and returns the resulting Merkle root hash in `ResponseApplyBlockRandomness.app_hash`. +// When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. +// - The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign +// `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +// - The implementation MUST be deterministic: every process that applies the same beacon to the same block +// and round MUST return the same `app_hash`. +// - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return +// the same `app_hash` each time. +// - An ABCI error is fatal, as for `ExtendVote`. +// +// #### When does Tenderdash call it? +// +// - On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is +// recovered, before `ExtendVote` and before signing its Precommit for _v_. +// - On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a +// node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the +// commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with +// `Commit.app_hash` and stops on a mismatch. +type RequestApplyBlockRandomness struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,3,opt,name=round,proto3" json:"round,omitempty"` + Beacon []byte `protobuf:"bytes,4,opt,name=beacon,proto3" json:"beacon,omitempty"` +} + +func (m *RequestApplyBlockRandomness) Reset() { *m = RequestApplyBlockRandomness{} } +func (m *RequestApplyBlockRandomness) String() string { return proto.CompactTextString(m) } +func (*RequestApplyBlockRandomness) ProtoMessage() {} +func (*RequestApplyBlockRandomness) Descriptor() ([]byte, []int) { + return fileDescriptor_252557cfdd89a31a, []int{16} +} +func (m *RequestApplyBlockRandomness) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RequestApplyBlockRandomness) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RequestApplyBlockRandomness.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RequestApplyBlockRandomness) XXX_Merge(src proto.Message) { + xxx_messageInfo_RequestApplyBlockRandomness.Merge(m, src) +} +func (m *RequestApplyBlockRandomness) XXX_Size() int { + return m.Size() +} +func (m *RequestApplyBlockRandomness) XXX_DiscardUnknown() { + xxx_messageInfo_RequestApplyBlockRandomness.DiscardUnknown(m) +} + +var xxx_messageInfo_RequestApplyBlockRandomness proto.InternalMessageInfo + +func (m *RequestApplyBlockRandomness) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *RequestApplyBlockRandomness) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *RequestApplyBlockRandomness) GetRound() int32 { + if m != nil { + return m.Round + } + return 0 +} + +func (m *RequestApplyBlockRandomness) GetBeacon() []byte { + if m != nil { + return m.Beacon + } + return nil +} + type Response struct { // Types that are valid to be assigned to Value: // *Response_Exception @@ -2016,6 +2124,7 @@ type Response struct { // *Response_ExtendVote // *Response_VerifyVoteExtension // *Response_FinalizeBlock + // *Response_ApplyBlockRandomness Value isResponse_Value `protobuf_oneof:"value"` } @@ -2023,7 +2132,7 @@ func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{16} + return fileDescriptor_252557cfdd89a31a, []int{17} } func (m *Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2106,23 +2215,27 @@ type Response_VerifyVoteExtension struct { type Response_FinalizeBlock struct { FinalizeBlock *ResponseFinalizeBlock `protobuf:"bytes,16,opt,name=finalize_block,json=finalizeBlock,proto3,oneof" json:"finalize_block,omitempty"` } - -func (*Response_Exception) isResponse_Value() {} -func (*Response_Echo) isResponse_Value() {} -func (*Response_Flush) isResponse_Value() {} -func (*Response_Info) isResponse_Value() {} -func (*Response_InitChain) isResponse_Value() {} -func (*Response_Query) isResponse_Value() {} -func (*Response_CheckTx) isResponse_Value() {} -func (*Response_ListSnapshots) isResponse_Value() {} -func (*Response_OfferSnapshot) isResponse_Value() {} -func (*Response_LoadSnapshotChunk) isResponse_Value() {} -func (*Response_ApplySnapshotChunk) isResponse_Value() {} -func (*Response_PrepareProposal) isResponse_Value() {} -func (*Response_ProcessProposal) isResponse_Value() {} -func (*Response_ExtendVote) isResponse_Value() {} -func (*Response_VerifyVoteExtension) isResponse_Value() {} -func (*Response_FinalizeBlock) isResponse_Value() {} +type Response_ApplyBlockRandomness struct { + ApplyBlockRandomness *ResponseApplyBlockRandomness `protobuf:"bytes,17,opt,name=apply_block_randomness,json=applyBlockRandomness,proto3,oneof" json:"apply_block_randomness,omitempty"` +} + +func (*Response_Exception) isResponse_Value() {} +func (*Response_Echo) isResponse_Value() {} +func (*Response_Flush) isResponse_Value() {} +func (*Response_Info) isResponse_Value() {} +func (*Response_InitChain) isResponse_Value() {} +func (*Response_Query) isResponse_Value() {} +func (*Response_CheckTx) isResponse_Value() {} +func (*Response_ListSnapshots) isResponse_Value() {} +func (*Response_OfferSnapshot) isResponse_Value() {} +func (*Response_LoadSnapshotChunk) isResponse_Value() {} +func (*Response_ApplySnapshotChunk) isResponse_Value() {} +func (*Response_PrepareProposal) isResponse_Value() {} +func (*Response_ProcessProposal) isResponse_Value() {} +func (*Response_ExtendVote) isResponse_Value() {} +func (*Response_VerifyVoteExtension) isResponse_Value() {} +func (*Response_FinalizeBlock) isResponse_Value() {} +func (*Response_ApplyBlockRandomness) isResponse_Value() {} func (m *Response) GetValue() isResponse_Value { if m != nil { @@ -2243,6 +2356,13 @@ func (m *Response) GetFinalizeBlock() *ResponseFinalizeBlock { return nil } +func (m *Response) GetApplyBlockRandomness() *ResponseApplyBlockRandomness { + if x, ok := m.GetValue().(*Response_ApplyBlockRandomness); ok { + return x.ApplyBlockRandomness + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*Response) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -2262,6 +2382,7 @@ func (*Response) XXX_OneofWrappers() []interface{} { (*Response_ExtendVote)(nil), (*Response_VerifyVoteExtension)(nil), (*Response_FinalizeBlock)(nil), + (*Response_ApplyBlockRandomness)(nil), } } @@ -2274,7 +2395,7 @@ func (m *ResponseException) Reset() { *m = ResponseException{} } func (m *ResponseException) String() string { return proto.CompactTextString(m) } func (*ResponseException) ProtoMessage() {} func (*ResponseException) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{17} + return fileDescriptor_252557cfdd89a31a, []int{18} } func (m *ResponseException) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2318,7 +2439,7 @@ func (m *ResponseEcho) Reset() { *m = ResponseEcho{} } func (m *ResponseEcho) String() string { return proto.CompactTextString(m) } func (*ResponseEcho) ProtoMessage() {} func (*ResponseEcho) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{18} + return fileDescriptor_252557cfdd89a31a, []int{19} } func (m *ResponseEcho) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2361,7 +2482,7 @@ func (m *ResponseFlush) Reset() { *m = ResponseFlush{} } func (m *ResponseFlush) String() string { return proto.CompactTextString(m) } func (*ResponseFlush) ProtoMessage() {} func (*ResponseFlush) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{19} + return fileDescriptor_252557cfdd89a31a, []int{20} } func (m *ResponseFlush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2402,7 +2523,7 @@ func (m *ResponseInfo) Reset() { *m = ResponseInfo{} } func (m *ResponseInfo) String() string { return proto.CompactTextString(m) } func (*ResponseInfo) ProtoMessage() {} func (*ResponseInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{20} + return fileDescriptor_252557cfdd89a31a, []int{21} } func (m *ResponseInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2486,7 +2607,7 @@ func (m *ResponseInitChain) Reset() { *m = ResponseInitChain{} } func (m *ResponseInitChain) String() string { return proto.CompactTextString(m) } func (*ResponseInitChain) ProtoMessage() {} func (*ResponseInitChain) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{21} + return fileDescriptor_252557cfdd89a31a, []int{22} } func (m *ResponseInitChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2603,7 +2724,7 @@ func (m *ResponseQuery) Reset() { *m = ResponseQuery{} } func (m *ResponseQuery) String() string { return proto.CompactTextString(m) } func (*ResponseQuery) ProtoMessage() {} func (*ResponseQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{22} + return fileDescriptor_252557cfdd89a31a, []int{23} } func (m *ResponseQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2709,7 +2830,7 @@ func (m *ResponseCheckTx) Reset() { *m = ResponseCheckTx{} } func (m *ResponseCheckTx) String() string { return proto.CompactTextString(m) } func (*ResponseCheckTx) ProtoMessage() {} func (*ResponseCheckTx) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{23} + return fileDescriptor_252557cfdd89a31a, []int{24} } func (m *ResponseCheckTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2795,7 +2916,7 @@ func (m *ResponseListSnapshots) Reset() { *m = ResponseListSnapshots{} } func (m *ResponseListSnapshots) String() string { return proto.CompactTextString(m) } func (*ResponseListSnapshots) ProtoMessage() {} func (*ResponseListSnapshots) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{24} + return fileDescriptor_252557cfdd89a31a, []int{25} } func (m *ResponseListSnapshots) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2839,7 +2960,7 @@ func (m *ResponseOfferSnapshot) Reset() { *m = ResponseOfferSnapshot{} } func (m *ResponseOfferSnapshot) String() string { return proto.CompactTextString(m) } func (*ResponseOfferSnapshot) ProtoMessage() {} func (*ResponseOfferSnapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{25} + return fileDescriptor_252557cfdd89a31a, []int{26} } func (m *ResponseOfferSnapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2885,7 +3006,7 @@ func (m *ResponseLoadSnapshotChunk) Reset() { *m = ResponseLoadSnapshotC func (m *ResponseLoadSnapshotChunk) String() string { return proto.CompactTextString(m) } func (*ResponseLoadSnapshotChunk) ProtoMessage() {} func (*ResponseLoadSnapshotChunk) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{26} + return fileDescriptor_252557cfdd89a31a, []int{27} } func (m *ResponseLoadSnapshotChunk) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2938,7 +3059,7 @@ func (m *ResponseApplySnapshotChunk) Reset() { *m = ResponseApplySnapsho func (m *ResponseApplySnapshotChunk) String() string { return proto.CompactTextString(m) } func (*ResponseApplySnapshotChunk) ProtoMessage() {} func (*ResponseApplySnapshotChunk) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{27} + return fileDescriptor_252557cfdd89a31a, []int{28} } func (m *ResponseApplySnapshotChunk) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3016,7 +3137,7 @@ func (m *ResponsePrepareProposal) Reset() { *m = ResponsePrepareProposal func (m *ResponsePrepareProposal) String() string { return proto.CompactTextString(m) } func (*ResponsePrepareProposal) ProtoMessage() {} func (*ResponsePrepareProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{28} + return fileDescriptor_252557cfdd89a31a, []int{29} } func (m *ResponsePrepareProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3113,7 +3234,7 @@ func (m *ResponseProcessProposal) Reset() { *m = ResponseProcessProposal func (m *ResponseProcessProposal) String() string { return proto.CompactTextString(m) } func (*ResponseProcessProposal) ProtoMessage() {} func (*ResponseProcessProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{29} + return fileDescriptor_252557cfdd89a31a, []int{30} } func (m *ResponseProcessProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3202,7 +3323,7 @@ func (m *ExtendVoteExtension) Reset() { *m = ExtendVoteExtension{} } func (m *ExtendVoteExtension) String() string { return proto.CompactTextString(m) } func (*ExtendVoteExtension) ProtoMessage() {} func (*ExtendVoteExtension) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{30} + return fileDescriptor_252557cfdd89a31a, []int{31} } func (m *ExtendVoteExtension) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3286,7 +3407,7 @@ func (m *ResponseExtendVote) Reset() { *m = ResponseExtendVote{} } func (m *ResponseExtendVote) String() string { return proto.CompactTextString(m) } func (*ResponseExtendVote) ProtoMessage() {} func (*ResponseExtendVote) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{31} + return fileDescriptor_252557cfdd89a31a, []int{32} } func (m *ResponseExtendVote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3330,7 +3451,7 @@ func (m *ResponseVerifyVoteExtension) Reset() { *m = ResponseVerifyVoteE func (m *ResponseVerifyVoteExtension) String() string { return proto.CompactTextString(m) } func (*ResponseVerifyVoteExtension) ProtoMessage() {} func (*ResponseVerifyVoteExtension) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{32} + return fileDescriptor_252557cfdd89a31a, []int{33} } func (m *ResponseVerifyVoteExtension) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3381,7 +3502,7 @@ func (m *ResponseFinalizeBlock) Reset() { *m = ResponseFinalizeBlock{} } func (m *ResponseFinalizeBlock) String() string { return proto.CompactTextString(m) } func (*ResponseFinalizeBlock) ProtoMessage() {} func (*ResponseFinalizeBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{33} + return fileDescriptor_252557cfdd89a31a, []int{34} } func (m *ResponseFinalizeBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3424,18 +3545,70 @@ func (m *ResponseFinalizeBlock) GetProposeNextBlockImmediately() bool { return false } +type ResponseApplyBlockRandomness struct { + // The Merkle root hash of the application state after the randomness is applied. 32 bytes. + // Equals the header app hash when nothing in the block uses randomness. + AppHash []byte `protobuf:"bytes,1,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` +} + +func (m *ResponseApplyBlockRandomness) Reset() { *m = ResponseApplyBlockRandomness{} } +func (m *ResponseApplyBlockRandomness) String() string { return proto.CompactTextString(m) } +func (*ResponseApplyBlockRandomness) ProtoMessage() {} +func (*ResponseApplyBlockRandomness) Descriptor() ([]byte, []int) { + return fileDescriptor_252557cfdd89a31a, []int{35} +} +func (m *ResponseApplyBlockRandomness) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResponseApplyBlockRandomness) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResponseApplyBlockRandomness.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResponseApplyBlockRandomness) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResponseApplyBlockRandomness.Merge(m, src) +} +func (m *ResponseApplyBlockRandomness) XXX_Size() int { + return m.Size() +} +func (m *ResponseApplyBlockRandomness) XXX_DiscardUnknown() { + xxx_messageInfo_ResponseApplyBlockRandomness.DiscardUnknown(m) +} + +var xxx_messageInfo_ResponseApplyBlockRandomness proto.InternalMessageInfo + +func (m *ResponseApplyBlockRandomness) GetAppHash() []byte { + if m != nil { + return m.AppHash + } + return nil +} + type CommitInfo struct { Round int32 `protobuf:"varint,1,opt,name=round,proto3" json:"round,omitempty"` QuorumHash []byte `protobuf:"bytes,2,opt,name=quorum_hash,json=quorumHash,proto3" json:"quorum_hash,omitempty"` BlockSignature []byte `protobuf:"bytes,3,opt,name=block_signature,json=blockSignature,proto3" json:"block_signature,omitempty"` ThresholdVoteExtensions []*types1.VoteExtension `protobuf:"bytes,4,rep,name=threshold_vote_extensions,json=thresholdVoteExtensions,proto3" json:"threshold_vote_extensions,omitempty"` + // Random beacon of the committed block: the threshold signature recovered from the prevotes of + // the commit round. Set from consensus version 2; empty before. + Beacon []byte `protobuf:"bytes,5,opt,name=beacon,proto3" json:"beacon,omitempty"` + // App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and + // round. Set from consensus version 2; empty before. + AppHash []byte `protobuf:"bytes,6,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } func (m *CommitInfo) Reset() { *m = CommitInfo{} } func (m *CommitInfo) String() string { return proto.CompactTextString(m) } func (*CommitInfo) ProtoMessage() {} func (*CommitInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{34} + return fileDescriptor_252557cfdd89a31a, []int{36} } func (m *CommitInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3492,6 +3665,20 @@ func (m *CommitInfo) GetThresholdVoteExtensions() []*types1.VoteExtension { return nil } +func (m *CommitInfo) GetBeacon() []byte { + if m != nil { + return m.Beacon + } + return nil +} + +func (m *CommitInfo) GetAppHash() []byte { + if m != nil { + return m.AppHash + } + return nil +} + // Event allows application developers to attach additional information to // ResponseCheckTx, ResponsePrepareProposal, ResponseProcessProposal // and ResponseFinalizeBlock. @@ -3506,7 +3693,7 @@ func (m *Event) Reset() { *m = Event{} } func (m *Event) String() string { return proto.CompactTextString(m) } func (*Event) ProtoMessage() {} func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{35} + return fileDescriptor_252557cfdd89a31a, []int{37} } func (m *Event) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3560,7 +3747,7 @@ func (m *EventAttribute) Reset() { *m = EventAttribute{} } func (m *EventAttribute) String() string { return proto.CompactTextString(m) } func (*EventAttribute) ProtoMessage() {} func (*EventAttribute) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{36} + return fileDescriptor_252557cfdd89a31a, []int{38} } func (m *EventAttribute) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3626,7 +3813,7 @@ func (m *ExecTxResult) Reset() { *m = ExecTxResult{} } func (m *ExecTxResult) String() string { return proto.CompactTextString(m) } func (*ExecTxResult) ProtoMessage() {} func (*ExecTxResult) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{37} + return fileDescriptor_252557cfdd89a31a, []int{39} } func (m *ExecTxResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3718,7 +3905,7 @@ func (m *TxResult) Reset() { *m = TxResult{} } func (m *TxResult) String() string { return proto.CompactTextString(m) } func (*TxResult) ProtoMessage() {} func (*TxResult) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{38} + return fileDescriptor_252557cfdd89a31a, []int{40} } func (m *TxResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3784,7 +3971,7 @@ func (m *TxRecord) Reset() { *m = TxRecord{} } func (m *TxRecord) String() string { return proto.CompactTextString(m) } func (*TxRecord) ProtoMessage() {} func (*TxRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{39} + return fileDescriptor_252557cfdd89a31a, []int{41} } func (m *TxRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3837,7 +4024,7 @@ func (m *Validator) Reset() { *m = Validator{} } func (m *Validator) String() string { return proto.CompactTextString(m) } func (*Validator) ProtoMessage() {} func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{40} + return fileDescriptor_252557cfdd89a31a, []int{42} } func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3894,7 +4081,7 @@ func (m *ValidatorUpdate) Reset() { *m = ValidatorUpdate{} } func (m *ValidatorUpdate) String() string { return proto.CompactTextString(m) } func (*ValidatorUpdate) ProtoMessage() {} func (*ValidatorUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{41} + return fileDescriptor_252557cfdd89a31a, []int{43} } func (m *ValidatorUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3976,7 +4163,7 @@ func (m *ValidatorSetUpdate) Reset() { *m = ValidatorSetUpdate{} } func (m *ValidatorSetUpdate) String() string { return proto.CompactTextString(m) } func (*ValidatorSetUpdate) ProtoMessage() {} func (*ValidatorSetUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{42} + return fileDescriptor_252557cfdd89a31a, []int{44} } func (m *ValidatorSetUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4034,7 +4221,7 @@ func (m *ThresholdPublicKeyUpdate) Reset() { *m = ThresholdPublicKeyUpda func (m *ThresholdPublicKeyUpdate) String() string { return proto.CompactTextString(m) } func (*ThresholdPublicKeyUpdate) ProtoMessage() {} func (*ThresholdPublicKeyUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{43} + return fileDescriptor_252557cfdd89a31a, []int{45} } func (m *ThresholdPublicKeyUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4078,7 +4265,7 @@ func (m *QuorumHashUpdate) Reset() { *m = QuorumHashUpdate{} } func (m *QuorumHashUpdate) String() string { return proto.CompactTextString(m) } func (*QuorumHashUpdate) ProtoMessage() {} func (*QuorumHashUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{44} + return fileDescriptor_252557cfdd89a31a, []int{46} } func (m *QuorumHashUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4124,7 +4311,7 @@ func (m *VoteInfo) Reset() { *m = VoteInfo{} } func (m *VoteInfo) String() string { return proto.CompactTextString(m) } func (*VoteInfo) ProtoMessage() {} func (*VoteInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{45} + return fileDescriptor_252557cfdd89a31a, []int{47} } func (m *VoteInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4181,7 +4368,7 @@ func (m *ExtendedVoteInfo) Reset() { *m = ExtendedVoteInfo{} } func (m *ExtendedVoteInfo) String() string { return proto.CompactTextString(m) } func (*ExtendedVoteInfo) ProtoMessage() {} func (*ExtendedVoteInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{46} + return fileDescriptor_252557cfdd89a31a, []int{48} } func (m *ExtendedVoteInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4249,7 +4436,7 @@ func (m *Misbehavior) Reset() { *m = Misbehavior{} } func (m *Misbehavior) String() string { return proto.CompactTextString(m) } func (*Misbehavior) ProtoMessage() {} func (*Misbehavior) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{47} + return fileDescriptor_252557cfdd89a31a, []int{49} } func (m *Misbehavior) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4324,7 +4511,7 @@ func (m *Snapshot) Reset() { *m = Snapshot{} } func (m *Snapshot) String() string { return proto.CompactTextString(m) } func (*Snapshot) ProtoMessage() {} func (*Snapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_252557cfdd89a31a, []int{48} + return fileDescriptor_252557cfdd89a31a, []int{50} } func (m *Snapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4405,6 +4592,7 @@ func init() { proto.RegisterType((*RequestExtendVote)(nil), "tendermint.abci.RequestExtendVote") proto.RegisterType((*RequestVerifyVoteExtension)(nil), "tendermint.abci.RequestVerifyVoteExtension") proto.RegisterType((*RequestFinalizeBlock)(nil), "tendermint.abci.RequestFinalizeBlock") + proto.RegisterType((*RequestApplyBlockRandomness)(nil), "tendermint.abci.RequestApplyBlockRandomness") proto.RegisterType((*Response)(nil), "tendermint.abci.Response") proto.RegisterType((*ResponseException)(nil), "tendermint.abci.ResponseException") proto.RegisterType((*ResponseEcho)(nil), "tendermint.abci.ResponseEcho") @@ -4423,6 +4611,7 @@ func init() { proto.RegisterType((*ResponseExtendVote)(nil), "tendermint.abci.ResponseExtendVote") proto.RegisterType((*ResponseVerifyVoteExtension)(nil), "tendermint.abci.ResponseVerifyVoteExtension") proto.RegisterType((*ResponseFinalizeBlock)(nil), "tendermint.abci.ResponseFinalizeBlock") + proto.RegisterType((*ResponseApplyBlockRandomness)(nil), "tendermint.abci.ResponseApplyBlockRandomness") proto.RegisterType((*CommitInfo)(nil), "tendermint.abci.CommitInfo") proto.RegisterType((*Event)(nil), "tendermint.abci.Event") proto.RegisterType((*EventAttribute)(nil), "tendermint.abci.EventAttribute") @@ -4443,241 +4632,248 @@ func init() { func init() { proto.RegisterFile("tendermint/abci/types.proto", fileDescriptor_252557cfdd89a31a) } var fileDescriptor_252557cfdd89a31a = []byte{ - // 3737 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5b, 0xcb, 0x73, 0xdb, 0x56, - 0x77, 0x27, 0xf8, 0xe6, 0xe1, 0x0b, 0xba, 0x92, 0x6d, 0x9a, 0xb6, 0x25, 0x05, 0x6e, 0x62, 0xc7, - 0x49, 0xa4, 0xc4, 0x6e, 0xe2, 0xa4, 0x49, 0x3b, 0x43, 0x51, 0x74, 0x29, 0x59, 0x96, 0x14, 0x88, - 0x52, 0x26, 0x4d, 0x13, 0x0c, 0x44, 0x5e, 0x89, 0x88, 0x49, 0x02, 0x01, 0x40, 0x99, 0xca, 0xb6, - 0xcd, 0x4c, 0x27, 0x9b, 0xe6, 0x1f, 0xc8, 0xae, 0x5d, 0x76, 0xdf, 0x55, 0x3b, 0x5d, 0x35, 0x9d, - 0x6e, 0xb2, 0xec, 0x4c, 0xa7, 0x6e, 0xc6, 0xd9, 0x75, 0x97, 0x55, 0x37, 0xdf, 0xe2, 0x9b, 0xfb, - 0x00, 0x08, 0x10, 0x00, 0x1f, 0x71, 0x66, 0xbe, 0xf9, 0x76, 0xb8, 0xe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4d, 0x66, 0xb3, 0x62, 0x6e, 0x37, - 0x99, 0xcd, 0x89, 0xb0, 0x9b, 0xcc, 0x82, 0x98, 0x97, 0xee, 0x40, 0xde, 0xe3, 0x5e, 0x50, 0x05, - 0x32, 0x7d, 0x6c, 0x59, 0xea, 0x39, 0xa6, 0xde, 0x28, 0x27, 0x3b, 0x4d, 0xa9, 0x04, 0x05, 0xaf, - 0x4b, 0x91, 0xbe, 0x13, 0x20, 0xef, 0xf1, 0x16, 0x44, 0x92, 0xbb, 0x47, 0x47, 0x92, 0x37, 0xd1, - 0x6d, 0x28, 0xd2, 0xa9, 0x28, 0x4e, 0x3f, 0x71, 0x59, 0x49, 0xb9, 0x40, 0x89, 0x27, 0x9c, 0x69, - 0x0d, 0xf2, 0xc6, 0x7d, 0xc3, 0x65, 0x49, 0x50, 0x16, 0x30, 0xee, 0x1b, 0x0e, 0xc3, 0x2b, 0x50, - 0x20, 0xf3, 0x76, 0x39, 0x92, 0xf4, 0x47, 0xf2, 0x84, 0xc6, 0x59, 0xa4, 0xbf, 0x4d, 0x80, 0x38, - 0xe9, 0x86, 0xd0, 0xfb, 0x90, 0x24, 0x1e, 0x99, 0x3b, 0xd7, 0xea, 0x06, 0x73, 0xd7, 0x1b, 0x8e, - 0xbb, 0xde, 0x68, 0x39, 0xee, 0x7a, 0x2b, 0xfb, 0xc3, 0xf3, 0xb5, 0xd8, 0x77, 0xff, 0xbb, 0x26, - 0xc8, 0x54, 0x02, 0x5d, 0x27, 0xce, 0x47, 0xd5, 0x06, 0x8a, 0xd6, 0xa1, 0x43, 0xce, 0x11, 0xcf, - 0xa2, 0x6a, 0x83, 0x9d, 0x0e, 0xda, 0x03, 0xb1, 0xad, 0x0f, 0x2c, 0x3c, 0xb0, 0x86, 0x96, 0xc2, - 0xc2, 0x45, 0x25, 0x11, 0x74, 0x8c, 0x2c, 0x4e, 0xd4, 0x1d, 0xce, 0x43, 0xca, 0x28, 0x97, 0xdb, - 0x7e, 0x02, 0xda, 0x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a, 0xe0, 0x88, 0xbe, 0xf0, 0xa2, 0xcf, 0x60, 0xc5, 0x87, - 0x7d, 0x38, 0xc9, 0x5f, 0x62, 0x31, 0x08, 0x24, 0xe6, 0xc9, 0x45, 0xdc, 0x1e, 0xf4, 0x39, 0xdc, - 0xa0, 0x69, 0x6c, 0x44, 0x82, 0x99, 0x9c, 0x2f, 0xc1, 0xbc, 0x46, 0x74, 0xd4, 0x43, 0x92, 0xcc, - 0x08, 0x60, 0x24, 0x15, 0x01, 0x8c, 0xa0, 0x3d, 0x28, 0x9c, 0xe3, 0x01, 0xb6, 0x34, 0x4b, 0x59, - 0xe0, 0x66, 0x28, 0x90, 0xbc, 0xbc, 0x19, 0x93, 0xf3, 0x5c, 0x96, 0xf4, 0xfe, 0x9d, 0x20, 0x6c, - 0x95, 0xa1, 0xa8, 0x78, 0xd5, 0x49, 0xff, 0x2f, 0x40, 0xd1, 0x17, 0x59, 0x88, 0x15, 0xb6, 0xf5, - 0x0e, 0x33, 0xdf, 0xa2, 0x4c, 0xbf, 0xc9, 0x1d, 0xa8, 0xa7, 0x9f, 0x73, 0x0b, 0x24, 0x9f, 0x84, - 0xcb, 0xad, 0x09, 0xe4, 0x78, 0x1c, 0x5c, 0x81, 0x94, 0x36, 0xe8, 0xe0, 0x11, 0x37, 0x32, 0xd6, - 0x20, 0xb2, 0x4f, 0xf1, 0x25, 0x37, 0x25, 0xf2, 0x89, 0x56, 0xf8, 0x39, 0xa3, 0x73, 0x29, 0xc8, - 0xac, 0x81, 0xde, 0x87, 0x1c, 0x2d, 0xec, 0x28, 0xba, 0x61, 0x55, 0x32, 0xc1, 0x84, 0x8b, 0x15, - 0x61, 0x36, 0x0e, 0x09, 0xcf, 0x81, 0x61, 0xc9, 0x59, 0x83, 0x7f, 0x79, 0x52, 0xa2, 0xac, 0x2f, - 0x25, 0xba, 0x09, 0x39, 0x32, 0x7a, 0xcb, 0x50, 0xdb, 0x98, 0x46, 0xa1, 0x9c, 0x3c, 0x26, 0x48, - 0xff, 0x22, 0x40, 0x79, 0x22, 0x30, 0x86, 0xce, 0xdd, 0x39, 0x95, 0x71, 0x3f, 0x12, 0x15, 0x98, - 0xfd, 0x2d, 0x80, 0x73, 0xd5, 0x52, 0x9e, 0xa9, 0x03, 0x1b, 0x77, 0xf8, 0x12, 0xe4, 0xce, 0x55, - 0xeb, 0x13, 0x4a, 0xf0, 0x0f, 0x26, 0x35, 0x31, 0x18, 0x0f, 0x16, 0x92, 0xf6, 0x62, 0x21, 0xa8, - 0x0a, 0x59, 0xc3, 0xd4, 0x74, 0x53, 0xb3, 0x2f, 0xe9, 0x9a, 0x24, 0x64, 0xb7, 0x2d, 0x1d, 0xc2, - 0x95, 0xd0, 0x98, 0x8c, 0x1e, 0x42, 0x6e, 0x1c, 0xce, 0x85, 0xf5, 0xc4, 0x64, 0x1a, 0xe7, 0x87, - 0x98, 0xc6, 0xbc, 0x64, 0x49, 0xae, 0x84, 0x46, 0x65, 0xd4, 0x80, 0xb4, 0x89, 0xad, 0x61, 0x8f, - 0xa5, 0xc2, 0xa5, 0xfb, 0x6f, 0xcd, 0x17, 0xcd, 0x09, 0x75, 0xd8, 0xb3, 0x65, 0x2e, 0x2c, 0x7d, - 0x01, 0x69, 0x46, 0x41, 0x79, 0xc8, 0x1c, 0xef, 0x3f, 0xde, 0x3f, 0xf8, 0x64, 0x5f, 0x8c, 0x21, - 0x80, 0x74, 0xad, 0x5e, 0x6f, 0x1c, 0xb6, 0x44, 0x01, 0xe5, 0x20, 0x55, 0xdb, 0x3a, 0x90, 0x5b, - 0x62, 0x9c, 0x90, 0xe5, 0xc6, 0x6e, 0xa3, 0xde, 0x12, 0x13, 0x68, 0x09, 0x8a, 0xec, 0x5b, 0x79, - 0x74, 0x20, 0x3f, 0xa9, 0xb5, 0xc4, 0xa4, 0x87, 0x74, 0xd4, 0xd8, 0xdf, 0x6e, 0xc8, 0x62, 0x4a, - 0x7a, 0x07, 0xae, 0x3b, 0xe3, 0x08, 0x42, 0x61, 0x2e, 0x0a, 0x25, 0x78, 0x50, 0x28, 0xe9, 0xc7, - 0x38, 0x54, 0x1d, 0x99, 0x10, 0x54, 0x6b, 0x77, 0x62, 0xe2, 0xf7, 0x17, 0xc8, 0x08, 0x26, 0x66, - 0x4f, 0xa0, 0x53, 0x13, 0x9f, 0x61, 0xbb, 0xdd, 0x65, 0x49, 0x86, 0x03, 0x53, 0x15, 0x39, 0x95, - 0x0a, 0x59, 0x8c, 0xed, 0x4b, 0xdc, 0xb6, 0x15, 0x66, 0x04, 0x16, 0x05, 0x03, 0x72, 0x72, 0x91, - 0x51, 0x8f, 0x18, 0x91, 0xf8, 0x7f, 0xe6, 0xa7, 0x98, 0xaa, 0x24, 0x55, 0x05, 0xd4, 0xed, 0x50, - 0x8a, 0xf4, 0x6c, 0xa1, 0xc5, 0xce, 0x41, 0x4a, 0x6e, 0xb4, 0xe4, 0x4f, 0xc5, 0x04, 0x42, 0x50, - 0xa2, 0x9f, 0xca, 0xd1, 0x7e, 0xed, 0xf0, 0xa8, 0x79, 0x40, 0x16, 0x7b, 0x19, 0xca, 0xce, 0x62, - 0x3b, 0xc4, 0x14, 0xba, 0x02, 0x4b, 0xf5, 0x83, 0x27, 0x87, 0x7b, 0x8d, 0x56, 0x63, 0x4c, 0x4e, - 0x4b, 0xff, 0x9d, 0x80, 0x6b, 0x11, 0xa9, 0x0c, 0x7a, 0x1f, 0xc0, 0x1e, 0x29, 0x26, 0x6e, 0xeb, - 0x66, 0x27, 0xda, 0x38, 0x5b, 0x23, 0x99, 0x72, 0xc8, 0x39, 0x9b, 0x7f, 0x4d, 0x8d, 0x07, 0x1f, - 0x71, 0xa5, 0x64, 0xb2, 0x16, 0x87, 0x4e, 0x6e, 0x85, 0xdc, 0x05, 0x71, 0x9b, 0x28, 0xa6, 0x7b, - 0x92, 0xb3, 0xf9, 0x97, 0x85, 0x3e, 0x85, 0x6b, 0x13, 0x61, 0x8b, 0xfb, 0x7a, 0x2b, 0xac, 0x6e, - 0x19,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, 0x2b, 0x61, 0x10, 0x92, 0xf0, 0x12, 0x10, 0xd2, 0x3f, 0x0a, - 0x70, 0x63, 0xca, 0x0d, 0x06, 0x7d, 0x3c, 0x71, 0x2e, 0x3e, 0x58, 0xe4, 0xfe, 0xb3, 0xc1, 0x68, - 0xfe, 0x93, 0x21, 0x3d, 0x80, 0x82, 0x97, 0x3e, 0xdf, 0xe6, 0xfd, 0xbd, 0x27, 0xc0, 0xfb, 0xb1, - 0xae, 0xdb, 0x50, 0x34, 0xb1, 0x4d, 0xbc, 0x94, 0x0f, 0x1c, 0x2c, 0x30, 0x22, 0xcf, 0x45, 0xeb, - 0xb0, 0xca, 0x31, 0x4d, 0x85, 0x86, 0x1e, 0x8e, 0x15, 0xf5, 0xfb, 0xb8, 0xa3, 0xa9, 0x36, 0xee, - 0x5d, 0xd2, 0xbd, 0xc9, 0xca, 0x37, 0x38, 0xd7, 0x3e, 0x1e, 0xb1, 0x7b, 0xc3, 0xce, 0x98, 0x65, - 0x37, 0x99, 0x15, 0xc4, 0xb8, 0x6b, 0x85, 0xff, 0x21, 0x00, 0x8c, 0x51, 0xb4, 0x31, 0x8a, 0x25, - 0x78, 0x51, 0xac, 0x09, 0xf0, 0x33, 0x3e, 0x09, 0x7e, 0xa2, 0x3b, 0x50, 0x66, 0x63, 0x21, 0xbb, - 0xaf, 0xda, 0x43, 0x13, 0x73, 0xcc, 0xac, 0x44, 0xc9, 0x47, 0x0e, 0x15, 0x7d, 0x06, 0xd7, 0xed, - 0xae, 0x89, 0xad, 0xae, 0xde, 0xeb, 0x28, 0x93, 0x16, 0xc0, 0x6a, 0x39, 0x6b, 0x33, 0x4c, 0x57, - 0xbe, 0xe6, 0x6a, 0x38, 0xf1, 0x5b, 0xc1, 0xd7, 0x90, 0xa2, 0x87, 0x8f, 0xa4, 0x87, 0xee, 0x59, - 0xc8, 0x71, 0x33, 0xff, 0x1c, 0x40, 0xb5, 0x6d, 0x53, 0x3b, 0x1d, 0xda, 0x98, 0x05, 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b, 0x9b, 0x5c, 0x9d, 0xb3, 0xa4, 0x87, 0xbe, 0x84, 0xa5, 0x20, - 0x1a, 0x37, 0xff, 0x53, 0xe5, 0xea, 0x02, 0x45, 0x3e, 0xd4, 0x07, 0x14, 0x82, 0xe2, 0x2d, 0xf0, - 0x72, 0xb9, 0xba, 0x48, 0xcd, 0x0f, 0x75, 0xa0, 0x3c, 0x89, 0x70, 0xcd, 0xfb, 0x92, 0xb9, 0x3a, - 0x77, 0xfd, 0x8f, 0xfd, 0x8a, 0x1f, 0x69, 0x99, 0xf7, 0x65, 0x73, 0x75, 0xee, 0x72, 0x20, 0x3a, - 0x06, 0xf0, 0xdc, 0x90, 0xe7, 0x78, 0xe9, 0x5c, 0x9d, 0xa7, 0x30, 0x88, 0x0c, 0x58, 0x0e, 0xbb, - 0x12, 0x2f, 0xf2, 0xf0, 0xb9, 0xba, 0x50, 0xbd, 0x90, 0xd8, 0xb3, 0xff, 0x72, 0x3b, 0xdf, 0x43, - 0xe8, 0xea, 0x9c, 0x85, 0xc3, 0xad, 0xad, 0x1f, 0x5e, 0xac, 0x0a, 0x3f, 0xbe, 0x58, 0x15, 0x7e, - 0x7a, 0xb1, 0x2a, 0x7c, 0xf7, 0xf3, 0x6a, 0xec, 0xc7, 0x9f, 0x57, 0x63, 0xff, 0xf5, 0xf3, 0x6a, - 0xec, 0xaf, 0xee, 0x9e, 0x6b, 0x76, 0x77, 0x78, 0xba, 0xd1, 0xd6, 0xfb, 0xf4, 0x7f, 0x28, 0x86, - 0x7a, 0xb9, 0xc9, 0x74, 0x92, 0x96, 0xe7, 0xdf, 0x2e, 0xa7, 0x69, 0x1a, 0xeb, 0x1e, 0xfc, 0x7e, - 0x00, 0xb8, 0x8f, 0x2b, 0xda, 0x0d, 0x33, 0x00, 0x00, + // 3845 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5b, 0xcd, 0x73, 0x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x16, 0xdf, 0xbe, 0xd9, 0xcc, 0xf1, 0x86, 0x9c, 0xa3, 0x72, 0xfb, + 0x9a, 0xf4, 0x1a, 0xee, 0xcc, 0xb9, 0x73, 0xbc, 0xbb, 0x45, 0x12, 0xee, 0x73, 0xac, 0xf6, 0x78, + 0x36, 0x5f, 0x92, 0x79, 0x4b, 0xfa, 0x7b, 0x80, 0xbc, 0x8c, 0x6d, 0x93, 0x9c, 0x1d, 0xb4, 0x0b, + 0x05, 0x3c, 0xe9, 0x61, 0xd3, 0x71, 0xaf, 0x16, 0xd1, 0x17, 0x44, 0xc6, 0xdd, 0x76, 0x39, 0x09, + 0xc8, 0xe1, 0x89, 0xa1, 0xc7, 0x1c, 0xc7, 0x89, 0x87, 0x64, 0xb8, 0xb8, 0x1f, 0xc8, 0xf9, 0x89, + 0x0b, 0xe4, 0xb0, 0x0c, 0x63, 0x23, 0x56, 0x6a, 0x06, 0xc9, 0x79, 0xcc, 0x91, 0x9c, 0xf4, 0x82, + 0x1f, 0x0b, 0x40, 0x39, 0xad, 0x00, 0x94, 0x93, 0x59, 0x30, 0xcd, 0x18, 0x2c, 0xe7, 0x27, 0x2e, + 0x96, 0x93, 0x5d, 0x30, 0xe2, 0x19, 0x30, 0xe7, 0x8f, 0x43, 0x60, 0xce, 0x56, 0xac, 0x68, 0x04, + 0x9a, 0x73, 0x1c, 0x42, 0x73, 0xf2, 0x54, 0xc9, 0x0f, 0x62, 0x95, 0x2c, 0x80, 0x73, 0x8e, 0x43, + 0x70, 0x4e, 0x61, 0x81, 0xc2, 0x05, 0x78, 0xce, 0x9f, 0x47, 0xe3, 0x39, 0x10, 0x8b, 0xb8, 0xf0, + 0x61, 0x2e, 0x07, 0xe8, 0x28, 0x31, 0x80, 0x4e, 0x31, 0x16, 0x7c, 0x60, 0xea, 0x97, 0x46, 0x74, + 0xce, 0x22, 0x10, 0x1d, 0x96, 0x35, 0x3d, 0x88, 0x55, 0xbe, 0x04, 0xa4, 0x73, 0x16, 0x01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+ 0x61, 0x36, 0x35, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -4708,6 +4904,7 @@ type ABCIApplicationClient interface { ExtendVote(ctx context.Context, in *RequestExtendVote, opts ...grpc.CallOption) (*ResponseExtendVote, error) VerifyVoteExtension(ctx context.Context, in *RequestVerifyVoteExtension, opts ...grpc.CallOption) (*ResponseVerifyVoteExtension, error) FinalizeBlock(ctx context.Context, in *RequestFinalizeBlock, opts ...grpc.CallOption) (*ResponseFinalizeBlock, error) + ApplyBlockRandomness(ctx context.Context, in *RequestApplyBlockRandomness, opts ...grpc.CallOption) (*ResponseApplyBlockRandomness, error) } type aBCIApplicationClient struct { @@ -4853,6 +5050,15 @@ func (c *aBCIApplicationClient) FinalizeBlock(ctx context.Context, in *RequestFi return out, nil } +func (c *aBCIApplicationClient) ApplyBlockRandomness(ctx context.Context, in *RequestApplyBlockRandomness, opts ...grpc.CallOption) (*ResponseApplyBlockRandomness, error) { + out := new(ResponseApplyBlockRandomness) + err := c.cc.Invoke(ctx, "/tendermint.abci.ABCIApplication/ApplyBlockRandomness", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ABCIApplicationServer is the server API for ABCIApplication service. type ABCIApplicationServer interface { // Echo a string to test an abci client/server implementation @@ -4871,6 +5077,7 @@ type ABCIApplicationServer interface { ExtendVote(context.Context, *RequestExtendVote) (*ResponseExtendVote, error) VerifyVoteExtension(context.Context, *RequestVerifyVoteExtension) (*ResponseVerifyVoteExtension, error) FinalizeBlock(context.Context, *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) + ApplyBlockRandomness(context.Context, *RequestApplyBlockRandomness) (*ResponseApplyBlockRandomness, error) } // UnimplementedABCIApplicationServer can be embedded to have forward compatible implementations. @@ -4922,6 +5129,9 @@ func (*UnimplementedABCIApplicationServer) VerifyVoteExtension(ctx context.Conte func (*UnimplementedABCIApplicationServer) FinalizeBlock(ctx context.Context, req *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) { return nil, status.Errorf(codes.Unimplemented, "method FinalizeBlock not implemented") } +func (*UnimplementedABCIApplicationServer) ApplyBlockRandomness(ctx context.Context, req *RequestApplyBlockRandomness) (*ResponseApplyBlockRandomness, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApplyBlockRandomness not implemented") +} func RegisterABCIApplicationServer(s grpc1.Server, srv ABCIApplicationServer) { s.RegisterService(&_ABCIApplication_serviceDesc, srv) @@ -5197,6 +5407,24 @@ func _ABCIApplication_FinalizeBlock_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _ABCIApplication_ApplyBlockRandomness_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestApplyBlockRandomness) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ABCIApplicationServer).ApplyBlockRandomness(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/tendermint.abci.ABCIApplication/ApplyBlockRandomness", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ABCIApplicationServer).ApplyBlockRandomness(ctx, req.(*RequestApplyBlockRandomness)) + } + return interceptor(ctx, in, info, handler) +} + var ABCIApplication_serviceDesc = _ABCIApplication_serviceDesc var _ABCIApplication_serviceDesc = grpc.ServiceDesc{ ServiceName: "tendermint.abci.ABCIApplication", @@ -5262,6 +5490,10 @@ var _ABCIApplication_serviceDesc = grpc.ServiceDesc{ MethodName: "FinalizeBlock", Handler: _ABCIApplication_FinalizeBlock_Handler, }, + { + MethodName: "ApplyBlockRandomness", + Handler: _ABCIApplication_ApplyBlockRandomness_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "tendermint/abci/types.proto", @@ -5670,6 +5902,32 @@ func (m *Request_FinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } +func (m *Request_ApplyBlockRandomness) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Request_ApplyBlockRandomness) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + if m.ApplyBlockRandomness != nil { + { + size, err := m.ApplyBlockRandomness.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa2 + } + return len(dAtA) - i, nil +} func (m *RequestEcho) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -5850,12 +6108,12 @@ func (m *RequestInitChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - n18, err18 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err18 != nil { - return 0, err18 + n19, err19 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err19 != nil { + return 0, err19 } - i -= n18 - i = encodeVarintTypes(dAtA, i, uint64(n18)) + i -= n19 + i = encodeVarintTypes(dAtA, i, uint64(n19)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -6186,12 +6444,12 @@ func (m *RequestPrepareProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x3a } - n21, err21 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err21 != nil { - return 0, err21 + n22, err22 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err22 != nil { + return 0, err22 } - i -= n21 - i = encodeVarintTypes(dAtA, i, uint64(n21)) + i -= n22 + i = encodeVarintTypes(dAtA, i, uint64(n22)) i-- dAtA[i] = 0x32 if m.Height != 0 { @@ -6318,12 +6576,12 @@ func (m *RequestProcessProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x42 } - n25, err25 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err25 != nil { - return 0, err25 + n26, err26 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err26 != nil { + return 0, err26 } - i -= n25 - i = encodeVarintTypes(dAtA, i, uint64(n25)) + i -= n26 + i = encodeVarintTypes(dAtA, i, uint64(n26)) i-- dAtA[i] = 0x3a if m.Round != 0 { @@ -6577,6 +6835,56 @@ func (m *RequestFinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *RequestApplyBlockRandomness) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RequestApplyBlockRandomness) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RequestApplyBlockRandomness) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Beacon) > 0 { + i -= len(m.Beacon) + copy(dAtA[i:], m.Beacon) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Beacon))) + i-- + dAtA[i] = 0x22 + } + if m.Round != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Round)) + i-- + dAtA[i] = 0x18 + } + if m.Height != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Response) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -6998,10 +7306,36 @@ func (m *Response_FinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) } return len(dAtA) - i, nil } -func (m *ResponseException) Marshal() (dAtA []byte, err error) { +func (m *Response_ApplyBlockRandomness) MarshalTo(dAtA []byte) (int, error) { size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Response_ApplyBlockRandomness) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + if m.ApplyBlockRandomness != nil { + { + size, err := m.ApplyBlockRandomness.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + return len(dAtA) - i, nil +} +func (m *ResponseException) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -7239,12 +7573,12 @@ func (m *ResponseInitChain_GenesisTime) MarshalToSizedBuffer(dAtA []byte) (int, } i := len(dAtA) if m.GenesisTime != nil { - n49, err49 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime):]) - if err49 != nil { - return 0, err49 + n51, err51 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime):]) + if err51 != nil { + return 0, err51 } - i -= n49 - i = encodeVarintTypes(dAtA, i, uint64(n49)) + i -= n51 + i = encodeVarintTypes(dAtA, i, uint64(n51)) i-- dAtA[i] = 0x32 } @@ -7939,6 +8273,39 @@ func (m *ResponseFinalizeBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ResponseApplyBlockRandomness) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResponseApplyBlockRandomness) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResponseApplyBlockRandomness) MarshalToSizedBuffer(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AppHash) > 0 { + i -= len(m.AppHash) + copy(dAtA[i:], m.AppHash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.AppHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *CommitInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -7962,6 +8329,20 @@ func (m *CommitInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AppHash) > 0 { + i -= len(m.AppHash) + copy(dAtA[i:], m.AppHash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.AppHash))) + i-- + dAtA[i] = 0x32 + } + if len(m.Beacon) > 0 { + i -= len(m.Beacon) + copy(dAtA[i:], m.Beacon) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Beacon))) + i-- + dAtA[i] = 0x2a + } if len(m.ThresholdVoteExtensions) > 0 { for iNdEx := len(m.ThresholdVoteExtensions) - 1; iNdEx >= 0; iNdEx-- { { @@ -8612,12 +8993,12 @@ func (m *Misbehavior) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - n62, err62 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err62 != nil { - return 0, err62 + n64, err64 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err64 != nil { + return 0, err64 } - i -= n62 - i = encodeVarintTypes(dAtA, i, uint64(n62)) + i -= n64 + i = encodeVarintTypes(dAtA, i, uint64(n64)) i-- dAtA[i] = 0x22 if m.Height != 0 { @@ -8896,6 +9277,18 @@ func (m *Request_FinalizeBlock) Size() (n int) { } return n } +func (m *Request_ApplyBlockRandomness) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ApplyBlockRandomness != nil { + l = m.ApplyBlockRandomness.Size() + n += 2 + l + sovTypes(uint64(l)) + } + return n +} func (m *RequestEcho) Size() (n int) { if m == nil { return 0 @@ -9279,6 +9672,29 @@ func (m *RequestFinalizeBlock) Size() (n int) { return n } +func (m *RequestApplyBlockRandomness) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovTypes(uint64(m.Height)) + } + if m.Round != 0 { + n += 1 + sovTypes(uint64(m.Round)) + } + l = len(m.Beacon) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func (m *Response) Size() (n int) { if m == nil { return 0 @@ -9483,6 +9899,18 @@ func (m *Response_FinalizeBlock) Size() (n int) { } return n } +func (m *Response_ApplyBlockRandomness) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ApplyBlockRandomness != nil { + l = m.ApplyBlockRandomness.Size() + n += 2 + l + sovTypes(uint64(l)) + } + return n +} func (m *ResponseException) Size() (n int) { if m == nil { return 0 @@ -9881,6 +10309,19 @@ func (m *ResponseFinalizeBlock) Size() (n int) { return n } +func (m *ResponseApplyBlockRandomness) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AppHash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func (m *CommitInfo) Size() (n int) { if m == nil { return 0 @@ -9904,6 +10345,14 @@ func (m *CommitInfo) Size() (n int) { n += 1 + l + sovTypes(uint64(l)) } } + l = len(m.Beacon) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.AppHash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -10742,6 +11191,41 @@ func (m *Request) Unmarshal(dAtA []byte) error { } m.Value = &Request_FinalizeBlock{v} iNdEx = postIndex + case 20: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApplyBlockRandomness", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &RequestApplyBlockRandomness{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &Request_ApplyBlockRandomness{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -13460,6 +13944,162 @@ func (m *RequestFinalizeBlock) Unmarshal(dAtA []byte) error { } return nil } +func (m *RequestApplyBlockRandomness) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RequestApplyBlockRandomness: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RequestApplyBlockRandomness: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) + } + m.Round = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Round |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beacon", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beacon = append(m.Beacon[:0], dAtA[iNdEx:postIndex]...) + if m.Beacon == nil { + m.Beacon = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Response) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -14049,6 +14689,41 @@ func (m *Response) Unmarshal(dAtA []byte) error { } m.Value = &Response_FinalizeBlock{v} iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApplyBlockRandomness", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ResponseApplyBlockRandomness{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &Response_ApplyBlockRandomness{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -16559,6 +17234,90 @@ func (m *ResponseFinalizeBlock) Unmarshal(dAtA []byte) error { } return nil } +func (m *ResponseApplyBlockRandomness) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResponseApplyBlockRandomness: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResponseApplyBlockRandomness: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppHash = append(m.AppHash[:0], dAtA[iNdEx:postIndex]...) + if m.AppHash == nil { + m.AppHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *CommitInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -16709,6 +17468,74 @@ func (m *CommitInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beacon", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beacon = append(m.Beacon[:0], dAtA[iNdEx:postIndex]...) + if m.Beacon == nil { + m.Beacon = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppHash = append(m.AppHash[:0], dAtA[iNdEx:postIndex]...) + if m.AppHash == nil { + m.AppHash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/abci/types/types_test.go b/abci/types/types_test.go index ca178c8e23..8d3e846f00 100644 --- a/abci/types/types_test.go +++ b/abci/types/types_test.go @@ -1,6 +1,7 @@ package types_test import ( + "context" "encoding/json" "testing" @@ -130,3 +131,11 @@ func TestVoteExtensionDoesNotSharetheApplicationsBytes(t *testing.T) { require.Equal(t, []byte("returned by the application"), converted.Extension) require.Equal(t, []byte("also returned by the application"), converted.GetSignRequestId()) } + +// TestBaseApplicationApplyBlockRandomness checks that the base application refuses ApplyBlockRandomness: +// an empty app hash must never pass as an answer. +func TestBaseApplicationApplyBlockRandomness(t *testing.T) { + resp, err := abci.NewBaseApplication().ApplyBlockRandomness(context.Background(), &abci.RequestApplyBlockRandomness{}) + require.ErrorIs(t, err, abci.ErrApplyBlockRandomnessNotImplemented) + require.Nil(t, resp) +} diff --git a/internal/proxy/client.go b/internal/proxy/client.go index 9421d6b8ea..cb83c412dc 100644 --- a/internal/proxy/client.go +++ b/internal/proxy/client.go @@ -167,6 +167,11 @@ func (app *proxyClient) FinalizeBlock(ctx context.Context, req *types.RequestFin return app.client.FinalizeBlock(ctx, req) } +func (app *proxyClient) ApplyBlockRandomness(ctx context.Context, req *types.RequestApplyBlockRandomness) (r *types.ResponseApplyBlockRandomness, err error) { + defer addTimeSample(app.metrics.MethodTiming.With("method", "apply_block_randomness", "type", "sync"))(&err) + return app.client.ApplyBlockRandomness(ctx, req) +} + func (app *proxyClient) Flush(ctx context.Context) (err error) { defer addTimeSample(app.metrics.MethodTiming.With("method", "flush", "type", "sync"))(&err) return app.client.Flush(ctx) diff --git a/internal/state/tx_filter_test.go b/internal/state/tx_filter_test.go index 3456fed3b1..ef1e833f09 100644 --- a/internal/state/tx_filter_test.go +++ b/internal/state/tx_filter_test.go @@ -15,7 +15,7 @@ import ( func TestTxFilter(t *testing.T) { const maxBlockBytes = 3241 - maxTxSize := maxBlockBytes - 1132 + maxTxSize := maxBlockBytes - 1264 genDoc := factory.MinimalGenesisDoc() genDoc.ConsensusParams.Block.MaxBytes = maxBlockBytes genDoc.ConsensusParams.Evidence.MaxBytes = 1500 diff --git a/node/node_test.go b/node/node_test.go index 849bc6ee84..ce33a25126 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -850,6 +850,8 @@ func TestMaxProposalBlockSize(t *testing.T) { BlockID: blockID, QuorumHash: crypto.RandQuorumHash(), ThresholdBlockSignature: crypto.CRandBytes(bls12381.SignatureSize), + Beacon: crypto.CRandBytes(bls12381.SignatureSize), + AppHash: crypto.Checksum([]byte("final_app_hash")), } block, _, err := blockExec.CreateProposalBlock( @@ -875,7 +877,7 @@ func TestMaxProposalBlockSize(t *testing.T) { require.Equal(t, types.MaxHeaderBytes, int64(pb.Header.Size())) require.Equal(t, types.MaxCommitOverheadBytes, int64(pb.LastCommit.Size())) // make sure that the block is less than the max possible size - assert.Equal(t, int64(1116+cfg.Mempool.MaxTxBytes), int64(pb.Size())) + assert.Equal(t, int64(1248+cfg.Mempool.MaxTxBytes), int64(pb.Size())) // because of the proto overhead we expect the part set bytes to be equal or // less than the pb block size assert.LessOrEqual(t, partSet.ByteSize(), int64(pb.Size())) diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index 155086841a..780dfabb47 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -22,21 +22,22 @@ import "gogoproto/gogo.proto"; // Request types message Request { oneof value { - RequestEcho echo = 1; - RequestFlush flush = 2; - RequestInfo info = 3; - RequestInitChain init_chain = 4; - RequestQuery query = 5; - RequestCheckTx check_tx = 7; - RequestListSnapshots list_snapshots = 11; - RequestOfferSnapshot offer_snapshot = 12; - RequestLoadSnapshotChunk load_snapshot_chunk = 13; - RequestApplySnapshotChunk apply_snapshot_chunk = 14; - RequestPrepareProposal prepare_proposal = 15; - RequestProcessProposal process_proposal = 16; - RequestExtendVote extend_vote = 17; - RequestVerifyVoteExtension verify_vote_extension = 18; - RequestFinalizeBlock finalize_block = 19; + RequestEcho echo = 1; + RequestFlush flush = 2; + RequestInfo info = 3; + RequestInitChain init_chain = 4; + RequestQuery query = 5; + RequestCheckTx check_tx = 7; + RequestListSnapshots list_snapshots = 11; + RequestOfferSnapshot offer_snapshot = 12; + RequestLoadSnapshotChunk load_snapshot_chunk = 13; + RequestApplySnapshotChunk apply_snapshot_chunk = 14; + RequestPrepareProposal prepare_proposal = 15; + RequestProcessProposal process_proposal = 16; + RequestExtendVote extend_vote = 17; + RequestVerifyVoteExtension verify_vote_extension = 18; + RequestFinalizeBlock finalize_block = 19; + RequestApplyBlockRandomness apply_block_randomness = 20; } reserved 6, 8, 9, 10; // RequestBeginBlock, RequestDeliverTx, RequestEndBlock, RequestCommit } @@ -559,27 +560,62 @@ message RequestFinalizeBlock { tendermint.types.BlockID block_id = 7 [(gogoproto.customname) = "BlockID"]; } +// Applies the block's randomness and returns the app hash the Precommit signs. +// +// #### Usage +// +// - Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. +// - `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold +// signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against +// the quorum's threshold public key before the call. +// - The Application applies the randomness to the state that `ProcessProposal` (or `PrepareProposal`) left for +// that block and round, and returns the resulting Merkle root hash in `ResponseApplyBlockRandomness.app_hash`. +// When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. +// - The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign +// `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +// - The implementation MUST be deterministic: every process that applies the same beacon to the same block +// and round MUST return the same `app_hash`. +// - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return +// the same `app_hash` each time. +// - An ABCI error is fatal, as for `ExtendVote`. +// +// #### When does Tenderdash call it? +// +// - On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is +// recovered, before `ExtendVote` and before signing its Precommit for _v_. +// - On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a +// node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the +// commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with +// `Commit.app_hash` and stops on a mismatch. +message RequestApplyBlockRandomness { + bytes hash = 1; // The header hash of the block the Prevotes are for. + int64 height = 2; // Height of the block. + int32 round = 3; // Round whose Prevotes produced the beacon. + bytes beacon = 4; // 96-byte BLS threshold signature recovered from those Prevotes. +} + //---------------------------------------- // Response types message Response { oneof value { - ResponseException exception = 1; - ResponseEcho echo = 2; - ResponseFlush flush = 3; - ResponseInfo info = 4; - ResponseInitChain init_chain = 5; - ResponseQuery query = 6; - ResponseCheckTx check_tx = 7; - ResponseListSnapshots list_snapshots = 8; - ResponseOfferSnapshot offer_snapshot = 9; - ResponseLoadSnapshotChunk load_snapshot_chunk = 10; - ResponseApplySnapshotChunk apply_snapshot_chunk = 11; - ResponsePrepareProposal prepare_proposal = 12; - ResponseProcessProposal process_proposal = 13; - ResponseExtendVote extend_vote = 14; - ResponseVerifyVoteExtension verify_vote_extension = 15; - ResponseFinalizeBlock finalize_block = 16; + ResponseException exception = 1; + ResponseEcho echo = 2; + ResponseFlush flush = 3; + ResponseInfo info = 4; + ResponseInitChain init_chain = 5; + ResponseQuery query = 6; + ResponseCheckTx check_tx = 7; + ResponseListSnapshots list_snapshots = 8; + ResponseOfferSnapshot offer_snapshot = 9; + ResponseLoadSnapshotChunk load_snapshot_chunk = 10; + ResponseApplySnapshotChunk apply_snapshot_chunk = 11; + ResponsePrepareProposal prepare_proposal = 12; + ResponseProcessProposal process_proposal = 13; + ResponseExtendVote extend_vote = 14; + ResponseVerifyVoteExtension verify_vote_extension = 15; + ResponseFinalizeBlock finalize_block = 16; + ResponseApplyBlockRandomness apply_block_randomness = 17; } } @@ -783,6 +819,12 @@ message ResponseFinalizeBlock { bool propose_next_block_immediately = 3; } +message ResponseApplyBlockRandomness { + // The Merkle root hash of the application state after the randomness is applied. 32 bytes. + // Equals the header app hash when nothing in the block uses randomness. + bytes app_hash = 1; +} + //---------------------------------------- // Misc. @@ -791,6 +833,12 @@ message CommitInfo { bytes quorum_hash = 2; bytes block_signature = 3; repeated tendermint.types.VoteExtension threshold_vote_extensions = 4; + // Random beacon of the committed block: the threshold signature recovered from the prevotes of + // the commit round. Set from consensus version 2; empty before. + bytes beacon = 5; + // App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and + // round. Set from consensus version 2; empty before. + bytes app_hash = 6; } // Event allows application developers to attach additional information to @@ -963,4 +1011,5 @@ service ABCIApplication { rpc ExtendVote(RequestExtendVote) returns (ResponseExtendVote); rpc VerifyVoteExtension(RequestVerifyVoteExtension) returns (ResponseVerifyVoteExtension); rpc FinalizeBlock(RequestFinalizeBlock) returns (ResponseFinalizeBlock); + rpc ApplyBlockRandomness(RequestApplyBlockRandomness) returns (ResponseApplyBlockRandomness); } diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index 6c695234d0..cbe25466a6 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -692,6 +692,12 @@ type Commit struct { QuorumHash []byte `protobuf:"bytes,4,opt,name=quorum_hash,json=quorumHash,proto3" json:"quorum_hash,omitempty"` ThresholdBlockSignature []byte `protobuf:"bytes,5,opt,name=threshold_block_signature,json=thresholdBlockSignature,proto3" json:"threshold_block_signature,omitempty"` ThresholdVoteExtensions []*VoteExtension `protobuf:"bytes,6,rep,name=threshold_vote_extensions,json=thresholdVoteExtensions,proto3" json:"threshold_vote_extensions,omitempty"` + // Random beacon: the threshold signature recovered from the prevotes of the commit round. + // Set from consensus version 2; empty before. + Beacon []byte `protobuf:"bytes,7,opt,name=beacon,proto3" json:"beacon,omitempty"` + // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. + // Set from consensus version 2; empty before. + AppHash []byte `protobuf:"bytes,8,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } func (m *Commit) Reset() { *m = Commit{} } @@ -769,6 +775,20 @@ func (m *Commit) GetThresholdVoteExtensions() []*VoteExtension { return nil } +func (m *Commit) GetBeacon() []byte { + if m != nil { + return m.Beacon + } + return nil +} + +func (m *Commit) GetAppHash() []byte { + if m != nil { + return m.AppHash + } + return nil +} + type Proposal struct { Type SignedMsgType `protobuf:"varint,1,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` @@ -1150,106 +1170,107 @@ func init() { func init() { proto.RegisterFile("tendermint/types/types.proto", fileDescriptor_d3a6e55e2345de56) } var fileDescriptor_d3a6e55e2345de56 = []byte{ - // 1569 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4b, 0x73, 0x1b, 0xc5, - 0x16, 0xd6, 0x58, 0xef, 0xd6, 0xc3, 0xf2, 0xc4, 0x4e, 0x64, 0x25, 0x91, 0xe6, 0xea, 0xd6, 0xbd, - 0x18, 0x0a, 0xa4, 0x90, 0xa4, 0x78, 0xa4, 0x8a, 0x85, 0x25, 0x3b, 0xb1, 0x2a, 0xb6, 0xac, 0x1a, - 0x29, 0xa6, 0x80, 0xc5, 0xd4, 0x58, 0xd3, 0x91, 0x44, 0xa4, 0xe9, 0x61, 0xa6, 0x65, 0xe4, 0xac, - 0xd8, 0x91, 0xf2, 0x2a, 0x0b, 0x8a, 0xca, 0xc6, 0x55, 0xa4, 0x60, 0xc1, 0x3f, 0x60, 0xcf, 0x2a, - 0xcb, 0xec, 0x60, 0x41, 0x19, 0xca, 0xf9, 0x0b, 0xac, 0x81, 0xea, 0xd3, 0x3d, 0xa3, 0xd1, 0xc3, - 0x26, 0x64, 0xc1, 0x46, 0x35, 0x7d, 0xce, 0x77, 0xba, 0xcf, 0xf9, 0xfa, 0x3b, 0xdd, 0x2d, 0x74, - 0x85, 0x62, 0xd3, 0xc0, 0xf6, 0xa0, 0x67, 0xd2, 0x32, 0x3d, 0xb4, 0xb0, 0xc3, 0x7f, 0x4b, 0x96, - 0x4d, 0x28, 0x91, 0x33, 0x63, 0x6f, 0x09, 0xec, 0xb9, 0xe5, 0x0e, 0xe9, 0x10, 0x70, 0x96, 0xd9, - 0x17, 0xc7, 0xe5, 0x0a, 0x1d, 0x42, 0x3a, 0x7d, 0x5c, 0x86, 0xd1, 0xfe, 0xf0, 0x7e, 0x99, 0xf6, - 0x06, 0xd8, 0xa1, 0xfa, 0xc0, 0x12, 0x80, 0xab, 0xbe, 0x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 0xc4, 0x79, 0xad, 0x90, 0x18, 0x23, 0x1a, - 0x9c, 0x35, 0xc3, 0xc7, 0x15, 0x63, 0x24, 0xe8, 0x71, 0xf5, 0x9e, 0xc8, 0x37, 0x04, 0x6b, 0xe7, - 0x4a, 0xbc, 0xd5, 0x4a, 0x6e, 0xab, 0x95, 0x5a, 0x6e, 0xab, 0x55, 0x62, 0x6c, 0xe1, 0xc7, 0xbf, - 0x16, 0x24, 0x5e, 0x95, 0x5c, 0x45, 0xa9, 0xbe, 0xee, 0x50, 0x6d, 0x9f, 0x11, 0xc7, 0x96, 0x0f, - 0xc3, 0x14, 0xab, 0xb3, 0x7a, 0x11, 0xba, 0x13, 0xa9, 0x27, 0x58, 0x14, 0x37, 0x19, 0xf2, 0x1a, - 0xca, 0xc0, 0x24, 0x6d, 0x32, 0x18, 0xf4, 0x28, 0xdf, 0xb2, 0x08, 0xc8, 0x32, 0xcd, 0xec, 0x55, - 0x30, 0xc3, 0x66, 0x5d, 0x46, 0x71, 0x43, 0xa7, 0x3a, 0x87, 0x44, 0x01, 0x12, 0x63, 0x06, 0x70, - 0xbe, 0x86, 0x16, 0xbd, 0xae, 0x74, 0x38, 0x24, 0xc6, 0x67, 0x19, 0x9b, 0x01, 0x78, 0x0d, 0x2d, - 0x9b, 0x78, 0x44, 0xb5, 0x69, 0x74, 0x1c, 0xd0, 0x32, 0xf3, 0xed, 0x4d, 0x46, 0xfc, 0x0f, 0xa5, - 0xdb, 0x2e, 0xf9, 0x1c, 0x8b, 0x00, 0x9b, 0xf2, 0xac, 0x00, 0x2b, 0xa1, 0x0b, 0x30, 0xf1, 0x14, - 0x36, 0x01, 0xd8, 0x25, 0xe6, 0xaa, 0x4e, 0xe0, 0x57, 0x7d, 0x1a, 0x4d, 0x02, 0xc8, 0x93, 0xe5, - 0x7f, 0x50, 0xd2, 0xc6, 0xce, 0xb0, 0x4f, 0xc5, 0x1c, 0x29, 0x70, 0x27, 0x84, 0x0d, 0x20, 0xff, - 0x45, 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 0x6b, 0x33, 0x23, 0x71, 0x74, 0xc3, - 0xc6, 0xec, 0x58, 0x07, 0xf4, 0x35, 0xb4, 0x3a, 0x07, 0xed, 0x15, 0xb6, 0x74, 0x74, 0xac, 0xa4, - 0x1a, 0x36, 0xe6, 0x4d, 0x08, 0x11, 0x25, 0x94, 0x9d, 0x8d, 0xd8, 0x6d, 0xec, 0x36, 0xd7, 0xb7, - 0x33, 0x4a, 0x2e, 0x73, 0x74, 0xac, 0x24, 0xdd, 0x03, 0x9e, 0xe1, 0xc7, 0x95, 0x55, 0xea, 0xcf, - 0x4e, 0xf3, 0xd2, 0xf3, 0xd3, 0xbc, 0xf4, 0xdb, 0x69, 0x5e, 0x7a, 0xfc, 0x22, 0x1f, 0x78, 0xfe, - 0x22, 0x1f, 0xf8, 0xf9, 0x45, 0x3e, 0xf0, 0xf1, 0xcd, 0x4e, 0x8f, 0x76, 0x87, 0xfb, 0xa5, 0x36, - 0x19, 0xc0, 0x1f, 0x4b, 0x4b, 0x3f, 0x2c, 0x73, 0x01, 0xb0, 0x11, 0xff, 0x57, 0x5b, 0x9e, 0xfe, - 0x97, 0xb9, 0x1f, 0x01, 0xfb, 0x8d, 0xbf, 0x06, 0x00, 0xa8, 0xd9, 0x50, 0xe6, 0x43, 0x0f, 0x00, - 0x00, + // 1587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xbd, 0x6f, 0x1b, 0xc9, + 0x15, 0xe7, 0x8a, 0xdf, 0xc3, 0x0f, 0x51, 0x6b, 0xc9, 0xa6, 0x68, 0x9b, 0xdc, 0x30, 0x48, 0xa2, + 0x04, 0x09, 0xe9, 0xd8, 0x46, 0x3e, 0x0c, 0xa4, 0x10, 0x29, 0xd9, 0x22, 0x2c, 0x51, 0xc4, 0x92, + 0x56, 0x90, 0xa4, 0x58, 0x2c, 0xb9, 0x63, 0x92, 0x31, 0xb9, 0xb3,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3, 0xcf, 0x2a, 0xab, + 0x35, 0xdf, 0x5c, 0x14, 0xa5, 0xb7, 0x17, 0x45, 0xe9, 0xcb, 0x8b, 0xa2, 0xf4, 0xf2, 0x5d, 0x31, + 0xf4, 0xf6, 0x5d, 0x31, 0xf4, 0xd9, 0xbb, 0x62, 0xe8, 0xaf, 0xf7, 0xfb, 0x43, 0x3a, 0x98, 0x74, + 0x2b, 0x3d, 0x32, 0x86, 0xff, 0xa2, 0x96, 0x7e, 0x52, 0xe5, 0x02, 0x60, 0x23, 0xfe, 0x47, 0xb8, + 0x3a, 0xff, 0xc7, 0xb4, 0x1b, 0x03, 0xfb, 0xbd, 0xef, 0x06, 0x00, 0xe4, 0x67, 0x15, 0x21, 0x76, + 0x0f, 0x00, 0x00, } func (m *PartSetHeader) Marshal() (dAtA []byte, err error) { @@ -1737,6 +1758,20 @@ func (m *Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AppHash) > 0 { + i -= len(m.AppHash) + copy(dAtA[i:], m.AppHash) + i = encodeVarintTypes(dAtA, i, uint64(len(m.AppHash))) + i-- + dAtA[i] = 0x42 + } + if len(m.Beacon) > 0 { + i -= len(m.Beacon) + copy(dAtA[i:], m.Beacon) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Beacon))) + i-- + dAtA[i] = 0x3a + } if len(m.ThresholdVoteExtensions) > 0 { for iNdEx := len(m.ThresholdVoteExtensions) - 1; iNdEx >= 0; iNdEx-- { { @@ -2336,6 +2371,14 @@ func (m *Commit) Size() (n int) { n += 1 + l + sovTypes(uint64(l)) } } + l = len(m.Beacon) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.AppHash) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } return n } @@ -4098,6 +4141,74 @@ func (m *Commit) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Beacon", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Beacon = append(m.Beacon[:0], dAtA[iNdEx:postIndex]...) + if m.Beacon == nil { + m.Beacon = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppHash = append(m.AppHash[:0], dAtA[iNdEx:postIndex]...) + if m.AppHash == nil { + m.AppHash = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index ea64fa29dc..bc27a6505e 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -156,6 +156,12 @@ message Commit { bytes quorum_hash = 4; bytes threshold_block_signature = 5; repeated VoteExtension threshold_vote_extensions = 6; + // Random beacon: the threshold signature recovered from the prevotes of the commit round. + // Set from consensus version 2; empty before. + bytes beacon = 7; + // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. + // Set from consensus version 2; empty before. + bytes app_hash = 8; } message Proposal { diff --git a/spec/abci++/abci++_methods.md b/spec/abci++/abci++_methods.md index acd7343f5e..570dc4888a 100644 --- a/spec/abci++/abci++_methods.md +++ b/spec/abci++/abci++_methods.md @@ -582,6 +582,48 @@ Whenever a process is about to save a block and its commit, in consensus, block first calls `RequestVerifyVoteExtension` for the commit, once `ProcessProposal` has processed the block. This includes commits the process assembled from its own +2/3 precommits. +### ApplyBlockRandomness + +#### Parameters and Types + +* **Request**: + + | Name | Type | Description | Field Number | + |--------|-------|--------------------------------------------------------------------------|--------------| + | hash | bytes | The header hash of the block the Prevotes are for. | 1 | + | height | int64 | Height of the block. | 2 | + | round | int32 | Round whose Prevotes produced the beacon. | 3 | + | beacon | bytes | 96-byte BLS threshold signature recovered from the Prevotes of `round`. | 4 | + +* **Response**: + + | Name | Type | Description | Field Number | + |----------|-------|----------------------------------------------------------------------------|--------------| + | app_hash | bytes | App hash after the randomness is applied; the hash the Precommits sign. | 1 | + +* **Usage**: + * Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. + * The beacon is the BLS threshold signature recovered from the Prevotes of round `round` for block `hash`. + Every set of threshold shares recovers the same bytes, and nobody can compute them before the Prevotes exist. + Tenderdash verifies the beacon against the quorum's threshold public key before the call. + * The Application applies the randomness to the state that `ProcessProposal` (or `PrepareProposal`) left for + that block and round, and returns the resulting app hash. When nothing in the block uses randomness, it + returns the header app hash. + * The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign the + returned app hash, and the commit carries it with the beacon (`Commit.app_hash`, `Commit.beacon`, and + `CommitInfo.app_hash`, `CommitInfo.beacon` in `RequestFinalizeBlock`). + * The implementation MUST be deterministic, and MUST return the same `app_hash` when called again for the same + block, round and beacon. + * An ABCI error is fatal, as for `ExtendVote`. + +#### When does Tenderdash call it? + +* On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is + recovered, before `ExtendVote` and before signing its Precommit for _v_. +* On every path that finalizes a block from a commit (block sync, replay, a node that did not vote): after + `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and before + `FinalizeBlock`. Tenderdash compares the returned `app_hash` with the commit's and stops on a mismatch. + ### FinalizeBlock #### Parameters and Types @@ -806,12 +848,14 @@ enum VoteExtensionType { * **Fields**: - | Name | Type | Description | Field Number | - |----------------|-------|----------------------------------------------------------------------------------------------|--------------| - | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 | - | QuorumHash | bytes | Quorum hash of a current height. | 3 | - | BlockSignature | bytes | Block signature. | 4 | - | StateSignature | bytes | State signature. | 5 | + | Name | Type | Description | Field Number | + |---------------------------|------------------------------------------|----------------------------------------------------------------------------------------------|--------------| + | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 | + | quorum_hash | bytes | Quorum hash of a current height. | 2 | + | block_signature | bytes | Block signature. | 3 | + | threshold_vote_extensions | repeated [VoteExtension](#voteextension) | Threshold-recovered vote extensions of the commit. | 4 | + | beacon | bytes | Random beacon of the commit round. Set from consensus version 2; empty before. | 5 | + | app_hash | bytes | App hash the commit signs, returned by `ApplyBlockRandomness`. From consensus version 2. | 6 | ### ExtendedCommitInfo diff --git a/spec/abci++/api.md b/spec/abci++/api.md index 93099a33a3..1c7c30eed0 100644 --- a/spec/abci++/api.md +++ b/spec/abci++/api.md @@ -13,6 +13,7 @@ - [Misbehavior](#tendermint-abci-Misbehavior) - [QuorumHashUpdate](#tendermint-abci-QuorumHashUpdate) - [Request](#tendermint-abci-Request) + - [RequestApplyBlockRandomness](#tendermint-abci-RequestApplyBlockRandomness) - [RequestApplySnapshotChunk](#tendermint-abci-RequestApplySnapshotChunk) - [RequestCheckTx](#tendermint-abci-RequestCheckTx) - [RequestEcho](#tendermint-abci-RequestEcho) @@ -29,6 +30,7 @@ - [RequestQuery](#tendermint-abci-RequestQuery) - [RequestVerifyVoteExtension](#tendermint-abci-RequestVerifyVoteExtension) - [Response](#tendermint-abci-Response) + - [ResponseApplyBlockRandomness](#tendermint-abci-ResponseApplyBlockRandomness) - [ResponseApplySnapshotChunk](#tendermint-abci-ResponseApplySnapshotChunk) - [ResponseCheckTx](#tendermint-abci-ResponseCheckTx) - [ResponseEcho](#tendermint-abci-ResponseEcho) @@ -87,6 +89,8 @@ | quorum_hash | [bytes](#bytes) | | | | block_signature | [bytes](#bytes) | | | | threshold_vote_extensions | [tendermint.types.VoteExtension](#tendermint-types-VoteExtension) | repeated | | +| beacon | [bytes](#bytes) | | Random beacon of the committed block: the threshold signature recovered from the prevotes of the commit round. Set from consensus version 2; empty before. | +| app_hash | [bytes](#bytes) | | App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and round. Set from consensus version 2; empty before. | @@ -252,6 +256,51 @@ Request types | extend_vote | [RequestExtendVote](#tendermint-abci-RequestExtendVote) | | | | verify_vote_extension | [RequestVerifyVoteExtension](#tendermint-abci-RequestVerifyVoteExtension) | | | | finalize_block | [RequestFinalizeBlock](#tendermint-abci-RequestFinalizeBlock) | | | +| apply_block_randomness | [RequestApplyBlockRandomness](#tendermint-abci-RequestApplyBlockRandomness) | | | + + + + + + + + +### RequestApplyBlockRandomness +Applies the block's randomness and returns the app hash the Precommit signs. + +#### Usage + +- Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. +- `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold + signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against + the quorum's threshold public key before the call. +- The Application applies the randomness to the state that `ProcessProposal` (or `PrepareProposal`) left for + that block and round, and returns the resulting Merkle root hash in `ResponseApplyBlockRandomness.app_hash`. + When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. +- The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign + `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +- The implementation MUST be deterministic: every process that applies the same beacon to the same block + and round MUST return the same `app_hash`. +- Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return + the same `app_hash` each time. +- An ABCI error is fatal, as for `ExtendVote`. + +#### When does Tenderdash call it? + +- On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is + recovered, before `ExtendVote` and before signing its Precommit for _v_. +- On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a + node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the + commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with + `Commit.app_hash` and stops on a mismatch. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| hash | [bytes](#bytes) | | The header hash of the block the Prevotes are for. | +| height | [int64](#int64) | | Height of the block. | +| round | [int32](#int32) | | Round whose Prevotes produced the beacon. | +| beacon | [bytes](#bytes) | | 96-byte BLS threshold signature recovered from those Prevotes. | @@ -874,6 +923,22 @@ block. This includes commits the process assembled from its own +2/3 precomm | extend_vote | [ResponseExtendVote](#tendermint-abci-ResponseExtendVote) | | | | verify_vote_extension | [ResponseVerifyVoteExtension](#tendermint-abci-ResponseVerifyVoteExtension) | | | | finalize_block | [ResponseFinalizeBlock](#tendermint-abci-ResponseFinalizeBlock) | | | +| apply_block_randomness | [ResponseApplyBlockRandomness](#tendermint-abci-ResponseApplyBlockRandomness) | | | + + + + + + + + +### ResponseApplyBlockRandomness + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| app_hash | [bytes](#bytes) | | The Merkle root hash of the application state after the randomness is applied. 32 bytes. Equals the header app hash when nothing in the block uses randomness. | @@ -1430,6 +1495,7 @@ TxAction contains App-provided information on what to do with a transaction that | ExtendVote | [RequestExtendVote](#tendermint-abci-RequestExtendVote) | [ResponseExtendVote](#tendermint-abci-ResponseExtendVote) | | | VerifyVoteExtension | [RequestVerifyVoteExtension](#tendermint-abci-RequestVerifyVoteExtension) | [ResponseVerifyVoteExtension](#tendermint-abci-ResponseVerifyVoteExtension) | | | FinalizeBlock | [RequestFinalizeBlock](#tendermint-abci-RequestFinalizeBlock) | [ResponseFinalizeBlock](#tendermint-abci-ResponseFinalizeBlock) | | +| ApplyBlockRandomness | [RequestApplyBlockRandomness](#tendermint-abci-RequestApplyBlockRandomness) | [ResponseApplyBlockRandomness](#tendermint-abci-ResponseApplyBlockRandomness) | | diff --git a/types/block.go b/types/block.go index 7d281e4cb5..f1f60cc895 100644 --- a/types/block.go +++ b/types/block.go @@ -745,8 +745,9 @@ const ( const ( // MaxCommitOverheadBytes is the max size of commit, with overhead but without vote extensions: // (110+2) for BlockID, (8+2) for Height, (4+2) for Round, - // (32+2) for QuorumHash, (96+2) for Block signature. - MaxCommitOverheadBytes int64 = (110 + 2) + (8 + 2) + (4 + 2) + (32 + 2) + (96 + 2) + 0 + // (32+2) for QuorumHash, (96+2) for Block signature, + // (96+2) for Beacon, (32+2) for AppHash. + MaxCommitOverheadBytes int64 = (110 + 2) + (8 + 2) + (4 + 2) + (32 + 2) + (96 + 2) + (96 + 2) + (32 + 2) + 0 ) //------------------------------------- @@ -765,6 +766,12 @@ type Commit struct { ThresholdBlockSignature []byte `json:"threshold_block_signature"` // ThresholdVoteExtensions keeps the list of recovered threshold signatures for vote-extensions ThresholdVoteExtensions tmproto.VoteExtensions `json:"threshold_vote_extensions"` + // Beacon is the threshold signature recovered from the prevotes of the commit round. + // Set from consensus version 2; empty before. + Beacon []byte `json:"beacon,omitempty"` + // AppHash is the app hash the precommits sign: the result of ApplyBlockRandomness for this + // block and round. Set from consensus version 2; empty before. + AppHash tmbytes.HexBytes `json:"app_hash,omitempty"` // Memoized in first call to corresponding method. // NOTE: can't memoize in constructor because constructor isn't used for @@ -797,6 +804,8 @@ func (commit *Commit) ToCommitInfo() types.CommitInfo { QuorumHash: commit.QuorumHash, BlockSignature: commit.ThresholdBlockSignature, ThresholdVoteExtensions: commit.ThresholdVoteExtensions, + Beacon: commit.Beacon, + AppHash: commit.AppHash, } } @@ -1005,6 +1014,8 @@ func (commit *Commit) ToProto() *tmproto.Commit { c.ThresholdBlockSignature = commit.ThresholdBlockSignature c.ThresholdVoteExtensions = commit.ThresholdVoteExtensions c.QuorumHash = commit.QuorumHash + c.Beacon = commit.Beacon + c.AppHash = commit.AppHash return c } @@ -1031,6 +1042,8 @@ func CommitFromProto(cp *tmproto.Commit) (*Commit, error) { commit.QuorumHash = cp.QuorumHash commit.ThresholdBlockSignature = cp.ThresholdBlockSignature commit.ThresholdVoteExtensions = cp.ThresholdVoteExtensions + commit.Beacon = cp.Beacon + commit.AppHash = cp.AppHash commit.Height = cp.Height commit.Round = cp.Round diff --git a/types/block_test.go b/types/block_test.go index a65a2f20a0..bcc384c082 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -314,6 +314,33 @@ func TestCommit(t *testing.T) { assert.True(t, commit.IsCommit()) } +// TestCommitBeaconFields checks that the beacon and the app hash of a commit survive the protobuf +// round trip and reach the CommitInfo passed to the application. +func TestCommitBeaconFields(t *testing.T) { + commit := &Commit{ + Height: 3, + Round: 1, + BlockID: BlockID{ + Hash: crypto.Checksum([]byte("block")), + PartSetHeader: PartSetHeader{Total: 1, Hash: crypto.Checksum([]byte("parts"))}, + StateID: RandStateID().Hash(), + }, + QuorumHash: crypto.RandQuorumHash(), + ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: crypto.CRandBytes(SignatureSize), + AppHash: crypto.Checksum([]byte("final app hash")), + } + + decoded, err := CommitFromProto(commit.ToProto()) + require.NoError(t, err) + assert.Equal(t, commit.Beacon, decoded.Beacon) + assert.Equal(t, commit.AppHash, decoded.AppHash) + + info := commit.ToCommitInfo() + assert.Equal(t, commit.Beacon, info.Beacon) + assert.EqualValues(t, commit.AppHash, info.AppHash) +} + func TestCommitValidateBasic(t *testing.T) { const height int64 = 5 testCases := []struct { @@ -357,6 +384,8 @@ func TestMaxCommitBytes(t *testing.T) { }, QuorumHash: crypto.Checksum([]byte("QuorumHash")), ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: crypto.CRandBytes(SignatureSize), + AppHash: crypto.Checksum([]byte("AppHash")), } bIDProto := commit.BlockID.ToProto() @@ -595,7 +624,7 @@ func TestBlockMaxDataBytes(t *testing.T) { func TestBlockMaxDataBytesNoEvidence(t *testing.T) { // minBlockSize is minimum correct size of a block - const minBlockSize = 1129 + const minBlockSize = 1261 testCases := []struct { maxBytes int64 From 90884b8bb4d7406c3d22ef7c5ecfa9aa779447d0 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 02:10:13 +0700 Subject: [PATCH 02/25] feat(consensus)!: recover a beacon from prevotes and sign precommits over the randomness-applied app hash At consensus version 2 the threshold signature recovered from a block's prevotes is the block's random beacon. Validators hand it to the application with ApplyBlockRandomness, and precommits and the commit sign the app hash it returns. Nothing changes before the application sets consensus version 2. - params: CONSENSUS_VERSION_2, VersionParams.RandomBeacon(), unknown consensus versions refused; proposer selection as in version 1. - vote set: WithRandomBeacon makes a prevote majority for a block count only once its threshold signature is recovered, since the majority gate can be below the recovery threshold; ThresholdBlockSignature exposes the beacon. - precommit signing: ApplyBlockRandomness with the round's beacon, state ID over the returned app hash, then ExtendVote, then sign; the state ID is cached per height, round and block so a node never signs two. - commit: carries the beacon and the final app hash; Commit.VerifyRandomBeacon checks the beacon against the quorum key over the prevote sign item and the state ID against the header with that app hash. Commits built from own precommits wait for the beacon or a peer's commit. Pre-version-2 peer commits have both fields dropped; parked commit keys include them. - BlockID.SameBlock for commit-vs-proposal comparisons; FinalizeBlock uses the commit's BlockID, applies the commit's beacon before the application's FinalizeBlock and stops on an app hash mismatch; state.LastAppHash is the commit's app hash; new State.LastBlockBeacon, which the next block's LastCommit must match. - block sync, replay, peer commits: randomness applied after ProcessProposal and before the commit's extension check, stopping on a mismatch; rollback restores the commit's BlockID, app hash and beacon. - light client and state sync use the app hash the commit signs; state sync restores LastAppHash and LastBlockBeacon from the snapshot commit at version 2. - kvstore example: toy translation sha256(app hash || beacon). Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- abci/example/kvstore/kvstore.go | 35 ++- abci/example/kvstore/kvstore_test.go | 40 ++- abci/example/kvstore/state.go | 6 + internal/blocksync/applier.go | 22 ++ internal/blocksync/random_beacon_test.go | 125 +++++++++ internal/consensus/block_executor.go | 50 +++- internal/consensus/commit_candidates.go | 14 +- internal/consensus/commit_candidates_test.go | 2 + internal/consensus/common_test.go | 16 +- internal/consensus/random_beacon_test.go | 254 ++++++++++++++++++ .../replay_commit_extensions_test.go | 7 +- internal/consensus/replay_stubs.go | 6 + internal/consensus/replayer.go | 60 ++++- internal/consensus/state.go | 1 + internal/consensus/state_add_vote.go | 8 + internal/consensus/state_data.go | 15 +- internal/consensus/state_proposaler.go | 8 +- internal/consensus/state_try_add_commit.go | 34 +++ .../consensus/state_try_finalize_commit.go | 8 + internal/consensus/types/height_vote_set.go | 13 +- .../selectproposer/proposer_selector.go | 2 +- internal/consensus/vote_signer.go | 78 ++++++ internal/state/errors.go | 3 + internal/state/execution.go | 91 ++++++- internal/state/export_test.go | 6 + internal/state/mocks/executor.go | 81 ++++++ internal/state/random_beacon_test.go | 145 ++++++++++ internal/state/rollback.go | 21 ++ internal/state/rollback_test.go | 76 +++++- internal/state/state.go | 11 +- internal/state/validation.go | 29 +- internal/statesync/random_beacon_test.go | 120 +++++++++ internal/statesync/stateprovider.go | 41 ++- light/rpc/client.go | 12 +- proto/tendermint/state/types.pb.go | 156 +++++++---- proto/tendermint/state/types.proto | 4 + proto/tendermint/types/params.pb.go | 114 ++++---- proto/tendermint/types/params.proto | 4 + types/block.go | 9 + types/light.go | 9 +- types/params.go | 11 + types/random_beacon.go | 138 ++++++++++ types/random_beacon_test.go | 252 +++++++++++++++++ types/vote_set.go | 48 +++- 44 files changed, 2021 insertions(+), 164 deletions(-) create mode 100644 internal/blocksync/random_beacon_test.go create mode 100644 internal/consensus/random_beacon_test.go create mode 100644 internal/state/random_beacon_test.go create mode 100644 internal/statesync/random_beacon_test.go create mode 100644 types/random_beacon.go create mode 100644 types/random_beacon_test.go diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index 82016f0eda..83947d646c 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -472,7 +472,18 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali time.Sleep(time.Duration(app.cfg.FinalizeBlockDelayMS) * time.Millisecond) } - err := app.newHeight(appHash, req.Height, req.Round) + // From consensus version 2 the commit carries the round's random beacon and the app hash after it + // is applied, and that is the state committed. + var committedAppHash tmbytes.HexBytes + if len(req.Commit.Beacon) > 0 { + committedAppHash = randomAppHash(roundState.GetAppHash(), req.Commit.Beacon) + if !committedAppHash.Equal(req.Commit.AppHash) { + return &abci.ResponseFinalizeBlock{}, fmt.Errorf("commit app hash %X does not match the app hash %X after applying the beacon", + tmbytes.HexBytes(req.Commit.AppHash), committedAppHash) + } + } + + err := app.newHeight(appHash, req.Height, req.Round, committedAppHash) if err != nil { return &abci.ResponseFinalizeBlock{}, err } @@ -490,8 +501,9 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali return resp, nil } -// ApplyBlockRandomness implements ABCI. The example application uses no randomness, so it returns -// the app hash of the state that PrepareProposal or ProcessProposal left for the block and round. +// ApplyBlockRandomness implements ABCI. The example application applies a toy translation: the app hash +// after the randomness is the hash of the app hash that PrepareProposal or ProcessProposal left for the +// block and round, followed by the beacon. It is deterministic, and always differs from the header's. func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { app.mu.Lock() defer app.mu.Unlock() @@ -500,12 +512,20 @@ func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.Reques if err != nil { return nil, fmt.Errorf("apply block randomness (hash: %X): %w", req.Hash, err) } + if len(req.Beacon) == 0 { + return nil, fmt.Errorf("apply block randomness (hash: %X): empty beacon", req.Hash) + } - resp := &abci.ResponseApplyBlockRandomness{AppHash: roundState.GetAppHash()} + resp := &abci.ResponseApplyBlockRandomness{AppHash: randomAppHash(roundState.GetAppHash(), req.Beacon)} app.logger.Debug("ApplyBlockRandomness", "req", req, "resp", resp) return resp, nil } +// randomAppHash is the example application's translation of an app hash with a block's random beacon. +func randomAppHash(appHash tmbytes.HexBytes, beacon []byte) tmbytes.HexBytes { + return crypto.Checksum(append(appHash.Copy(), beacon...)) +} + // processedRoundState returns the state of the proposal executed at the given height and round. // Caller should lock the Application. func (app *Application) processedRoundState(height int64, round int32) (State, error) { @@ -789,8 +809,10 @@ func (app *Application) Close() error { } // newHeight frees resources from previous height and starts new height. +// finalAppHash, when set, replaces the committed state's app hash: it is the app hash after the +// block's randomness is applied (consensus version 2). // Caller should lock the Application. -func (app *Application) newHeight(committedAppHash tmbytes.HexBytes, height int64, round int32) error { +func (app *Application) newHeight(committedAppHash tmbytes.HexBytes, height int64, round int32, finalAppHash tmbytes.HexBytes) error { // Committed round becomes new state committedState := app.roundStates[roundKey(committedAppHash, height, round)] if committedState == nil { @@ -800,6 +822,9 @@ func (app *Application) newHeight(committedAppHash tmbytes.HexBytes, height int6 if err != nil { return err } + if finalAppHash != nil { + app.LastCommittedState.SetAppHash(finalAppHash) + } app.resetDuplicateDetection(app.preparedProposals != nil && app.processedProposals != nil) diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index d541b83b5f..66cdf46d9d 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -441,12 +441,14 @@ func testClient(ctx context.Context, t *testing.T, app abciclient.Client, height require.False(t, rpp.TxResults[0].IsErr()) require.Len(t, rpp.Events, 1) + beacon := tmcrypto.CRandBytes(tmtypes.SignatureSize) rabr, err := app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{ Height: height, - Beacon: tmcrypto.CRandBytes(tmtypes.SignatureSize), + Beacon: beacon, }) require.NoError(t, err) - require.Equal(t, rpp.AppHash, rabr.AppHash, "no randomness is applied, so the app hash is unchanged") + require.EqualValues(t, randomAppHash(rpp.AppHash, beacon), rabr.AppHash) + require.NotEqualValues(t, rpp.AppHash, rabr.AppHash) rfb := &types.RequestFinalizeBlock{Height: height} rfb.Block, rfb.BlockID = makeBlock(t, height, [][]byte{tx}, rpp.AppHash) @@ -652,16 +654,19 @@ func TestProcessProposalRoundReprocessing(t *testing.T) { require.NoError(t, err) } -// TestApplyBlockRandomness checks that ApplyBlockRandomness answers for the round that was processed, -// gives the same answer when called again, and fails for a round that was not processed. +// TestApplyBlockRandomness checks the example application's toy translation: ApplyBlockRandomness answers +// the hash of the processed round's app hash and the beacon, gives the same answer when called again, and +// fails for a round that was not processed; FinalizeBlock commits that app hash when the commit carries +// the beacon, and refuses a commit whose app hash differs. func TestApplyBlockRandomness(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() app := newKvApp(ctx, t, 1) const height = 1 + tx := []byte(testKey) resp, err := app.ProcessProposal(ctx, &types.RequestProcessProposal{ - Txs: [][]byte{[]byte(testKey)}, + Txs: [][]byte{tx}, Hash: []byte("block-hash"), Height: height, Round: 1, @@ -669,20 +674,39 @@ func TestApplyBlockRandomness(t *testing.T) { }) require.NoError(t, err) + beacon := tmcrypto.CRandBytes(tmtypes.SignatureSize) req := &types.RequestApplyBlockRandomness{ Hash: []byte("block-hash"), Height: height, Round: 1, - Beacon: tmcrypto.CRandBytes(tmtypes.SignatureSize), + Beacon: beacon, } first, err := app.ApplyBlockRandomness(ctx, req) require.NoError(t, err) - require.Equal(t, resp.AppHash, first.AppHash) + require.EqualValues(t, randomAppHash(resp.AppHash, beacon), first.AppHash) + require.NotEqualValues(t, resp.AppHash, first.AppHash) again, err := app.ApplyBlockRandomness(ctx, req) require.NoError(t, err) require.Equal(t, first.AppHash, again.AppHash) - _, err = app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{Height: height, Round: 0}) + _, err = app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{Height: height, Round: 0, Beacon: beacon}) require.ErrorContains(t, err, "no proposal executed") + + finalize := func(appHash []byte) error { + reqFin := &types.RequestFinalizeBlock{ + Height: height, + Round: 1, + Commit: types.CommitInfo{Round: 1, Beacon: beacon, AppHash: appHash}, + } + reqFin.Block, reqFin.BlockID = makeBlock(t, height, [][]byte{tx}, resp.AppHash) + _, err := app.FinalizeBlock(ctx, reqFin) + return err + } + require.ErrorContains(t, finalize(resp.AppHash), "does not match the app hash") + require.NoError(t, finalize(first.AppHash)) + + info, err := app.Info(ctx, &types.RequestInfo{}) + require.NoError(t, err) + assertRespInfo(t, height, first.AppHash, *info) } diff --git a/abci/example/kvstore/state.go b/abci/example/kvstore/state.go index cfdfd14256..66fdc676b5 100644 --- a/abci/example/kvstore/state.go +++ b/abci/example/kvstore/state.go @@ -42,6 +42,8 @@ type State interface { // GetAppHash returns app hash for the state. You need to call UpdateAppHash() beforehand. GetAppHash() tmbytes.HexBytes + // SetAppHash replaces the app hash of the state, as the block's randomness does (consensus version 2). + SetAppHash(appHash tmbytes.HexBytes) // UpdateAppHash regenerates apphash for the state. It accepts transactions and tx results from current round. // It is deterministic for a given state, txs and txResults. @@ -170,6 +172,10 @@ func (state kvState) GetAppHash() tmbytes.HexBytes { return state.AppHash.Copy() } +func (state *kvState) SetAppHash(appHash tmbytes.HexBytes) { + state.AppHash = appHash.Copy() +} + func (state *kvState) UpdateAppHash(lastCommittedState State, _txs types1.Txs, txResults []*types.ExecTxResult) error { // UpdateAppHash updates app hash for the current app state. txResultsHash, err := types.TxResultsHash(txResults) diff --git a/internal/blocksync/applier.go b/internal/blocksync/applier.go index 66e7c61fa5..633837026d 100644 --- a/internal/blocksync/applier.go +++ b/internal/blocksync/applier.go @@ -93,6 +93,23 @@ func (e *blockApplier) Apply(ctx context.Context, block *types.Block, commit *ty blockID := block.BlockID(blockParts) partSetTime := e.observeSince("partset", start) + // From consensus version 2 the commit signs a state ID with the app hash after the block's + // randomness is applied, and carries that app hash and the round's random beacon: both are + // checked against the block, and the commit's BlockID is the block's from here on. Before, a + // commit carries neither. + randomBeacon := e.state.ConsensusParams.Version.RandomBeacon() + if randomBeacon { + if !blockID.SameBlock(commit.BlockID) { + return fmt.Errorf("invalid a commit: block ID %v does not name block %v", commit.BlockID, blockID) + } + if err := commit.VerifyRandomBeacon(e.state.ChainID, e.state.Validators, &block.Header); err != nil { + return fmt.Errorf("invalid a commit: %w", err) + } + blockID = commit.BlockID + } else { + commit = commit.WithoutRandomBeacon() + } + start = time.Now() verified, err := e.verify(ctx, blockID, block, commit) if err != nil { @@ -114,6 +131,11 @@ func (e *blockApplier) Apply(ctx context.Context, block *types.Block, commit *ty } e.processedState = &processed } + if randomBeacon { + if err := sm.VerifyBlockRandomness(ctx, e.blockExec, block, commit); err != nil { + panic(fmt.Sprintf("failed to apply the randomness of committed block (%d:%X): %v", block.Height, block.Hash(), err)) + } + } if err := sm.VerifyCommitExtensions(ctx, e.blockExec, commit); err != nil { e.metrics.CommitVerifyFailures.With("reason", consensus.CommitVerifyFailureReason(err)).Add(1) return err diff --git a/internal/blocksync/random_beacon_test.go b/internal/blocksync/random_beacon_test.go new file mode 100644 index 0000000000..80cbb2ff06 --- /dev/null +++ b/internal/blocksync/random_beacon_test.go @@ -0,0 +1,125 @@ +package blocksync + +import ( + "context" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + "github.com/dashpay/tenderdash/crypto" + sm "github.com/dashpay/tenderdash/internal/state" + "github.com/dashpay/tenderdash/internal/state/mocks" + statefactory "github.com/dashpay/tenderdash/internal/state/test/factory" + "github.com/dashpay/tenderdash/internal/test/factory" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" + "github.com/dashpay/tenderdash/types" +) + +// recoverPrevoteBeacon signs a prevote for blockID with every validator and returns the threshold +// signature recovered from them: the random beacon of the block and round. +func recoverPrevoteBeacon( + ctx context.Context, + t *testing.T, + state sm.State, + privVals []types.PrivValidator, + height int64, + round int32, + blockID types.BlockID, +) []byte { + t.Helper() + valSet := state.Validators + voteSet := types.NewVoteSet(state.ChainID, height, round, tmproto.PrevoteType, valSet, types.WithRandomBeacon(true)) + for _, privVal := range privVals { + proTxHash, err := privVal.GetProTxHash(ctx) + require.NoError(t, err) + idx, _ := valSet.GetByProTxHash(proTxHash) + vote := &types.Vote{ + ValidatorProTxHash: proTxHash, + ValidatorIndex: idx, + Height: height, + Round: round, + Type: tmproto.PrevoteType, + BlockID: blockID, + } + protoVote := vote.ToProto() + require.NoError(t, privVal.SignVote(ctx, state.ChainID, valSet.QuorumType, valSet.QuorumHash, protoVote, nil)) + require.NoError(t, vote.PopulateSignsFromProto(protoVote)) + _, err = voteSet.AddVote(vote) + require.NoError(t, err) + } + beacon := voteSet.ThresholdBlockSignature() + require.Len(t, beacon, types.SignatureSize) + return beacon +} + +// TestBlockApplierRandomBeacon checks block sync at consensus version 2: the commit's beacon and app hash +// are verified against the block before anything else, the application applies the beacon after +// ProcessProposal and before the commit's extensions are checked, the block ID verified and finalized +// is the commit's, and an application reaching another app hash stops the node. +func TestBlockApplierRandomBeacon(t *testing.T) { + ctx := context.Background() + valSet, privVals := factory.MockValidatorSet() + initialState := fakeInitialState(valSet) + initialState.ConsensusParams = *types.DefaultConsensusParams() + initialState.ConsensusParams.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + state := initialState.Copy() + blocks := statefactory.MakeBlocks(ctx, t, 2, &state, privVals, 1) + block := blocks[0] + blockParts, err := block.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + headerBlockID := block.BlockID(blockParts) + + signedCommit := blocks[1].LastCommit + beacon := recoverPrevoteBeacon(ctx, t, initialState, privVals, block.Height, signedCommit.Round, headerBlockID) + finalAppHash := tmbytes.HexBytes(crypto.Checksum(append(block.AppHash.Copy(), beacon...))) + makeCommit := func() *types.Commit { + commit := *signedCommit + commit.BlockID = headerBlockID.Copy() + commit.BlockID.StateID = block.Header.StateIDWithAppHash(finalAppHash).Hash() + commit.Beacon = beacon + commit.AppHash = finalAppHash + return &commit + } + + expectApply := func(exec *mocks.Executor, commit *types.Commit, appHash tmbytes.HexBytes) { + exec.On("VerifyCommit", initialState, commit.BlockID, block.Height, commit).Once(). + Return(types.VerifiedCommit{}, nil) + exec.On("ValidateBlock", mock.Anything, initialState, block, types.VerifiedCommit{}).Once().Return(nil) + exec.On("ProcessProposal", mock.Anything, block, commit.Round, initialState, true, types.VerifiedCommit{}).Once(). + Return(sm.CurrentRoundState{}, nil) + exec.On("ApplyBlockRandomness", mock.Anything, block, commit.Round, beacon).Once().Return(appHash, nil) + } + + t.Run("applies the commit's randomness and finalizes the commit's block ID", func(t *testing.T) { + exec := mocks.NewExecutor(t) + store := mocks.NewBlockStore(t) + commit := makeCommit() + expectApply(exec, commit, finalAppHash) + acceptCommitExtensions(exec, store.On("SaveBlock", block, blockParts, commit).Once()) + exec.On("FinalizeBlock", mock.Anything, initialState, sm.CurrentRoundState{}, commit.BlockID, block, commit, + types.VerifiedCommit{}).Once().Return(state, nil, nil) + + applier := newBlockApplier(exec, store, applierWithState(initialState)) + require.NoError(t, applier.Apply(ctx, block, commit)) + }) + + t.Run("refuses a commit whose beacon does not verify", func(t *testing.T) { + exec := mocks.NewExecutor(t) + store := mocks.NewBlockStore(t) + commit := makeCommit() + commit.Beacon = signedCommit.ThresholdBlockSignature + applier := newBlockApplier(exec, store, applierWithState(initialState)) + require.ErrorIs(t, applier.Apply(ctx, block, commit), types.ErrInvalidCommitBeacon) + }) + + t.Run("stops when the application reaches another app hash", func(t *testing.T) { + exec := mocks.NewExecutor(t) + store := mocks.NewBlockStore(t) + commit := makeCommit() + expectApply(exec, commit, crypto.Checksum([]byte("diverged"))) + applier := newBlockApplier(exec, store, applierWithState(initialState)) + require.Panics(t, func() { _ = applier.Apply(ctx, block, commit) }) + }) +} diff --git a/internal/consensus/block_executor.go b/internal/consensus/block_executor.go index d8f55d8159..ffd2584c40 100644 --- a/internal/consensus/block_executor.go +++ b/internal/consensus/block_executor.go @@ -218,6 +218,40 @@ func errRejectedBefore(commit *types.Commit) error { commit.Height, commit.Round, commit.BlockID.Hash, sm.ErrCommitExtensionsRejected) } +// errBeaconNotRecovered means this node has not recovered the random beacon of the commit round from +// its prevotes, so it cannot complete a commit built from its own precommits. +var errBeaconNotRecovered = errors.New("random beacon of the commit round not recovered") + +// completeCommit gives commit, built from this node's own precommits at consensus version 2, the random +// beacon and the app hash it carries: the beacon recovered from the prevotes of the commit round, and +// the app hash the application returns from ApplyBlockRandomness for it. The block must be processed +// for commit.Round. +// +// It returns errBeaconNotRecovered while this node has no prevote majority with a recovered beacon for +// the block in that round; a peer's commit or the missing prevotes can still finish the height. It +// panics if the application fails, or reaches an app hash whose state ID is not the one the precommits +// signed: this node has diverged from the validators that committed the block. +func (c *blockExecutor) completeCommit(ctx context.Context, stateData *StateData, commit *types.Commit) error { + prevotes := stateData.Votes.Prevotes(commit.Round) + polka, ok := prevotes.TwoThirdsMajority() + beacon := prevotes.ThresholdBlockSignature() + if !ok || !polka.SameBlock(commit.BlockID) || len(beacon) == 0 { + return errBeaconNotRecovered + } + block := stateData.ProposalBlock + appHash, err := c.blockExec.ApplyBlockRandomness(ctx, block, commit.Round, beacon) + if err != nil { + panic(fmt.Errorf("ApplyBlockRandomness call failed: %w", err)) + } + commit.Beacon = beacon + commit.AppHash = appHash + if err := commit.VerifyRandomBeacon(stateData.state.ChainID, stateData.Validators, &block.Header); err != nil { + panic(fmt.Errorf("the application's app hash after applying the randomness of block %X at height %d round %d "+ + "does not match the commit: %w", block.Hash(), commit.Height, commit.Round, err)) + } + return nil +} + func (c *blockExecutor) mustEnsureProcess(ctx context.Context, rs *cstypes.RoundState, round int32) { err := c.ensureProcess(ctx, rs, round) if err != nil { @@ -228,15 +262,21 @@ func (c *blockExecutor) mustEnsureProcess(ctx context.Context, rs *cstypes.Round func (c *blockExecutor) finalize(ctx context.Context, stateData *StateData, commit *types.Commit) (sm.State, *abci.ResponseFinalizeBlock, error) { block := stateData.ProposalBlock blockParts := stateData.ProposalBlockParts + // The block ID the commit signs, which becomes the next header's LastBlockID. From consensus + // version 2 its state ID carries the app hash the commit signs, not the header's. + blockID := types.BlockID{ + Hash: block.Hash(), + PartSetHeader: blockParts.Header(), + StateID: block.StateID().Hash(), + } + if commit != nil { + blockID = commit.BlockID + } return c.blockExec.FinalizeBlock( ctx, stateData.state.Copy(), stateData.CurrentRoundState, - types.BlockID{ - Hash: block.Hash(), - PartSetHeader: blockParts.Header(), - StateID: block.StateID().Hash(), - }, + blockID, block, commit, // consensus holds no proof for the block's LastCommit, so it is verified diff --git a/internal/consensus/commit_candidates.go b/internal/consensus/commit_candidates.go index 65a938626d..8aaf68e89c 100644 --- a/internal/consensus/commit_candidates.go +++ b/internal/consensus/commit_candidates.go @@ -10,14 +10,17 @@ import ( ) // commitKey identifies a commit by what the application's extension check -// depends on: height, round, block and extension vector. Commits with equal keys -// differ at most in their quorum hash and threshold block signature, which that -// check does not read. +// depends on: height, round, block and extension vector, and by the random beacon +// and app hash checked against the block from consensus version 2. Neither is +// covered by the threshold signature, so a copy carrying others must not pass for +// one already tried. Commits with equal keys differ at most in their quorum hash +// and threshold block signature, which those checks do not read. type commitKey struct { height int64 round int32 blockID string extensions [sha256.Size]byte + randomness [sha256.Size]byte } func newCommitKey(commit *types.Commit) commitKey { @@ -30,11 +33,16 @@ func newCommitKey(commit *types.Commit) commitKey { buf = binary.AppendUvarint(buf, uint64(len(bz))) buf = append(buf, bz...) } + var randomness []byte + randomness = binary.AppendUvarint(randomness, uint64(len(commit.Beacon))) + randomness = append(randomness, commit.Beacon...) + randomness = append(randomness, commit.AppHash...) return commitKey{ height: commit.Height, round: commit.Round, blockID: commit.BlockID.Key(), extensions: sha256.Sum256(buf), + randomness: sha256.Sum256(randomness), } } diff --git a/internal/consensus/commit_candidates_test.go b/internal/consensus/commit_candidates_test.go index 41f98b8522..5b3fe70845 100644 --- a/internal/consensus/commit_candidates_test.go +++ b/internal/consensus/commit_candidates_test.go @@ -99,6 +99,8 @@ func TestCommitKey(t *testing.T) { c.ThresholdVoteExtensions = tmproto.VoteExtensions{{Extension: []byte("a")}, {}} }, "stripped": func(c *types.Commit) { c.ThresholdVoteExtensions = nil }, + "beacon": func(c *types.Commit) { c.Beacon = []byte("beacon") }, + "app hash": func(c *types.Commit) { c.AppHash = []byte("app hash") }, } { changed := *base change(&changed) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 17e442283d..713505776f 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -852,17 +852,31 @@ func consensusLogger(t *testing.T) log.Logger { } func makeConsensusState( + ctx context.Context, + t *testing.T, + cfg *config.Config, + nValidators int, + testName string, + tickerFunc func() TimeoutTicker, + configOpts ...func(*config.Config), +) []*State { + t.Helper() + return makeConsensusStateWithParams(ctx, t, cfg, nValidators, testName, tickerFunc, factory.ConsensusParams(), configOpts...) +} + +func makeConsensusStateWithParams( ctx context.Context, t *testing.T, _cfg *config.Config, nValidators int, testName string, tickerFunc func() TimeoutTicker, + params *types.ConsensusParams, configOpts ...func(*config.Config), ) []*State { t.Helper() - genDoc, privVals := factory.RandGenesisDoc(nValidators, factory.ConsensusParams()) + genDoc, privVals := factory.RandGenesisDoc(nValidators, params) css := make([]*State, nValidators) logger := consensusLogger(t) diff --git a/internal/consensus/random_beacon_test.go b/internal/consensus/random_beacon_test.go new file mode 100644 index 0000000000..660c84a964 --- /dev/null +++ b/internal/consensus/random_beacon_test.go @@ -0,0 +1,254 @@ +package consensus + +import ( + "bytes" + "context" + "testing" + "time" + + sync "github.com/sasha-s/go-deadlock" + "github.com/stretchr/testify/require" + + abciclient "github.com/dashpay/tenderdash/abci/client" + "github.com/dashpay/tenderdash/abci/example/kvstore" + abci "github.com/dashpay/tenderdash/abci/types" + "github.com/dashpay/tenderdash/crypto" + sm "github.com/dashpay/tenderdash/internal/state" + sf "github.com/dashpay/tenderdash/internal/state/test/factory" + "github.com/dashpay/tenderdash/internal/test/factory" + dbm "github.com/dashpay/tenderdash/libs/db" + "github.com/dashpay/tenderdash/libs/log" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" + "github.com/dashpay/tenderdash/types" +) + +// randomBeaconApp is the kvstore application recording the order of the calls made around a precommit. +type randomBeaconApp struct { + *kvstore.Application + + mtx sync.Mutex + calls []string +} + +func (app *randomBeaconApp) record(call string) { + app.mtx.Lock() + defer app.mtx.Unlock() + app.calls = append(app.calls, call) +} + +func (app *randomBeaconApp) recorded() []string { + app.mtx.Lock() + defer app.mtx.Unlock() + return append([]string(nil), app.calls...) +} + +func (app *randomBeaconApp) ApplyBlockRandomness(ctx context.Context, req *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { + app.record("apply_block_randomness") + return app.Application.ApplyBlockRandomness(ctx, req) +} + +func (app *randomBeaconApp) ExtendVote(ctx context.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + app.record("extend_vote") + return app.Application.ExtendVote(ctx, req) +} + +func (app *randomBeaconApp) FinalizeBlock(ctx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { + app.record("finalize_block") + return app.Application.FinalizeBlock(ctx, req) +} + +// TestRandomBeaconConsensusVersion2 runs a single validator at consensus version 2 and checks the whole +// chain of the random beacon: the precommit signs the state ID of the app hash ApplyBlockRandomness +// returned, which the kvstore example makes differ from the header's; ApplyBlockRandomness runs before +// ExtendVote; the commit carries the verified beacon and that app hash; the state and the next header +// name the commit's BlockID; and the next block, whose LastCommit carries them, validates and commits. +func TestRandomBeaconConsensusVersion2(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + kvApp, err := kvstore.NewMemoryApp() + require.NoError(t, err) + app := &randomBeaconApp{Application: kvApp} + params := factory.ConsensusParams(func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + }) + cs, _ := makeState(ctx, t, makeStateArgs{validators: 1, application: app, consensusParams: params}) + stateData := cs.GetStateData() + height, round := stateData.Height, stateData.Round + + voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote) + propCh := subscribe(ctx, t, cs.eventBus, types.EventQueryCompleteProposal) + newRoundCh := subscribe(ctx, t, cs.eventBus, types.EventQueryNewRound) + + startTestRound(ctx, cs, height, round) + ensureNewRound(t, newRoundCh, height, round) + propBlockID := ensureNewProposal(t, propCh, height, round) + + prevote := ensureMessageBeforeTimeout(t, voteCh, ensureTimeout).Data().(types.EventDataVote).Vote + require.Equal(t, tmproto.PrevoteType, prevote.Type) + require.True(t, prevote.BlockID.Equals(propBlockID), "the prevote signs the header's state ID") + + precommit := ensureMessageBeforeTimeout(t, voteCh, ensureTimeout).Data().(types.EventDataVote).Vote + require.Equal(t, tmproto.PrecommitType, precommit.Type) + require.True(t, precommit.BlockID.SameBlock(propBlockID)) + require.False(t, precommit.BlockID.Equals(propBlockID), "the precommit signs the state ID after the randomness") + + ensureNewRound(t, newRoundCh, height+1, 0) + + block := cs.blockStore.LoadBlock(height) + require.NotNil(t, block) + commit := cs.blockStore.LoadSeenCommit() + require.NotNil(t, commit) + require.Equal(t, height, commit.Height) + require.True(t, commit.BlockID.Equals(precommit.BlockID)) + require.Len(t, commit.Beacon, types.SignatureSize) + require.NoError(t, commit.VerifyRandomBeacon(stateData.state.ChainID, stateData.Validators, &block.Header)) + require.EqualValues(t, crypto.Checksum(append(block.AppHash.Copy(), commit.Beacon...)), commit.AppHash, + "the kvstore example's translation of the header app hash with the beacon") + require.False(t, bytes.Equal(block.AppHash, commit.AppHash)) + + calls := app.recorded() + require.Equal(t, []string{"apply_block_randomness", "extend_vote"}, calls[:2], + "the randomness is applied before the vote is extended") + require.Contains(t, calls, "finalize_block") + + next := cs.GetStateData() + require.True(t, next.state.LastBlockID.Equals(commit.BlockID), "the state names the commit's BlockID") + require.EqualValues(t, commit.AppHash, next.state.LastAppHash) + require.Equal(t, commit.Beacon, next.state.LastBlockBeacon) + + info, err := kvApp.Info(ctx, &abci.RequestInfo{}) + require.NoError(t, err) + require.EqualValues(t, commit.AppHash, info.LastBlockAppHash, "the application committed the final app hash") + + // The next block carries the commit as its LastCommit and the commit's BlockID as its LastBlockID. + ensureNewRound(t, newRoundCh, height+2, 0) + nextBlock := cs.blockStore.LoadBlock(height + 1) + require.NotNil(t, nextBlock) + require.True(t, nextBlock.LastBlockID.Equals(commit.BlockID)) + require.Equal(t, commit.Beacon, nextBlock.LastCommit.Beacon) + require.EqualValues(t, commit.AppHash, nextBlock.LastCommit.AppHash) +} + +// TestReactorRandomBeaconConsensusVersion2 runs four validators at consensus version 2, where every +// precommit needs the threshold signature recovered from the other validators' prevotes, and checks that +// all of them commit the same beacon and final app hash, which verify against the block. +func TestReactorRandomBeaconConsensusVersion2(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + const n = 4 + params := factory.ConsensusParams(func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + }) + states := makeConsensusStateWithParams(ctx, t, configSetup(t), n, "consensus_random_beacon_test", + newTickerFunc(), params) + rts := setup(ctx, t, n, states, 100) + rts.switchToConsensus(ctx) + + const lastHeight = int64(3) + require.Eventually(t, func() bool { + for _, state := range rts.states { + if state.blockStore.Height() < lastHeight { + return false + } + } + return true + }, 45*time.Second, 50*time.Millisecond, "every node commits %d blocks", lastHeight) + + for height := int64(1); height < lastHeight; height++ { + var want *types.Commit + for _, state := range rts.states { + block := state.blockStore.LoadBlock(height) + commit := state.blockStore.LoadBlockCommit(height) + require.NotNil(t, block) + require.NotNil(t, commit) + require.Len(t, commit.Beacon, types.SignatureSize) + stateData := state.GetStateData() + require.NoError(t, commit.VerifyRandomBeacon(stateData.state.ChainID, stateData.Validators, &block.Header)) + require.False(t, bytes.Equal(block.AppHash, commit.AppHash)) + if want == nil { + want = commit + continue + } + require.Equal(t, want.Beacon, commit.Beacon, "height %d", height) + require.EqualValues(t, want.AppHash, commit.AppHash, "height %d", height) + require.True(t, want.BlockID.Equals(commit.BlockID), "height %d", height) + } + } +} + +// replayRandomnessApp records the calls the replayer makes and answers ApplyBlockRandomness with appHash. +type replayRandomnessApp struct { + abci.BaseApplication + block *types.Block + appHash []byte + calls []string +} + +func (a *replayRandomnessApp) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + a.calls = append(a.calls, "process") + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT, AppHash: a.block.AppHash, + TxResults: factory.ExecTxResults(types.NewTxs(req.Txs))}, nil +} + +func (a *replayRandomnessApp) ApplyBlockRandomness(_ context.Context, _ *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { + a.calls = append(a.calls, "randomness") + return &abci.ResponseApplyBlockRandomness{AppHash: a.appHash}, nil +} + +func (a *replayRandomnessApp) VerifyVoteExtension(_ context.Context, _ *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + a.calls = append(a.calls, "verify") + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil +} + +func (a *replayRandomnessApp) FinalizeBlock(_ context.Context, _ *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { + a.calls = append(a.calls, "finalize") + return &abci.ResponseFinalizeBlock{}, nil +} + +// TestReplayBlockRandomBeacon checks that the handshake replay of a block committed at consensus version 2 +// applies the commit's beacon after ProcessProposal and before the commit's extensions are checked and the +// block is finalized, reports the commit's app hash as the one the application committed, and stops +// before FinalizeBlock when the application reaches another app hash. +func TestReplayBlockRandomBeacon(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + params := factory.ConsensusParams(func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + }) + state, _ := makeGenesisState(ctx, t, nil, genesisStateArgs{Params: params, Validators: 1}) + stateStore := sm.NewStore(dbm.NewMemDB()) + require.NoError(t, stateStore.Save(state)) + block, err := sf.MakeBlock(state, state.InitialHeight, &types.Commit{}, kvstore.ProtocolVersion) + require.NoError(t, err) + + finalAppHash := crypto.Checksum([]byte("final app hash")) + blockID := block.BlockID(nil) + blockID.StateID = block.Header.StateIDWithAppHash(finalAppHash).Hash() + commit := &types.Commit{ + Height: block.Height, + BlockID: blockID, + Beacon: crypto.CRandBytes(types.SignatureSize), + AppHash: finalAppHash, + } + + replay := func(appHash []byte) (*replayRandomnessApp, []byte, error) { + app := &replayRandomnessApp{block: block, appHash: appHash} + client := abciclient.NewLocalClient(log.NewNopLogger(), app) + exec := sm.NewBlockExecutor(stateStore, client, nil, nil, nil, nil) + replayer := NewBlockReplayer(client, stateStore, nil, nil, nil, exec) + _, committed, err := replayer.replayBlock(ctx, block, commit, state, block.Height) + return app, committed, err + } + + app, committed, err := replay(finalAppHash) + require.NoError(t, err) + require.Equal(t, []string{"process", "randomness", "verify", "finalize"}, app.calls) + require.EqualValues(t, finalAppHash, committed) + + app, _, err = replay(crypto.Checksum([]byte("diverged"))) + require.ErrorIs(t, err, sm.ErrAppHashMismatch) + require.Equal(t, []string{"process", "randomness"}, app.calls) +} diff --git a/internal/consensus/replay_commit_extensions_test.go b/internal/consensus/replay_commit_extensions_test.go index e4032f6d1a..1dc3b742cd 100644 --- a/internal/consensus/replay_commit_extensions_test.go +++ b/internal/consensus/replay_commit_extensions_test.go @@ -11,6 +11,7 @@ import ( "github.com/dashpay/tenderdash/dash" sm "github.com/dashpay/tenderdash/internal/state" "github.com/dashpay/tenderdash/internal/test/factory" + dbm "github.com/dashpay/tenderdash/libs/db" "github.com/dashpay/tenderdash/libs/log" "github.com/dashpay/tenderdash/types" ) @@ -31,12 +32,14 @@ func TestReplayRejectsCommitExtensionsBeforeFinalize(t *testing.T) { client := abciclient.NewLocalClient(log.NewNopLogger(), app) exec := sm.NewBlockExecutor(nil, client, nil, nil, nil, nil) n.node.blockStore.SaveBlock(n.block, n.parts, n.commit) - replayer := NewBlockReplayer(client, nil, n.node.blockStore, nil, nil, exec) + stateStore := sm.NewStore(dbm.NewMemDB()) + require.NoError(t, stateStore.Save(sd.state)) + replayer := NewBlockReplayer(client, stateStore, n.node.blockStore, nil, nil, exec) var err error if applyState { _, err = replayer.syncStateAt(ctx, sd.state, n.block.Height, exec) } else { - _, err = replayer.replayBlock(ctx, n.block, n.commit, sd.state, n.block.Height) + _, _, err = replayer.replayBlock(ctx, n.block, n.commit, sd.state, n.block.Height) } require.ErrorIs(t, err, sm.ErrCommitExtensionsRejected) require.ErrorContains(t, err, "roll back or re-sync the node", "both paths give the operator's remedy") diff --git a/internal/consensus/replay_stubs.go b/internal/consensus/replay_stubs.go index 99726c3fc0..39a966c220 100644 --- a/internal/consensus/replay_stubs.go +++ b/internal/consensus/replay_stubs.go @@ -113,6 +113,12 @@ func (mock *mockProxyApp) ProcessProposal(_ context.Context, _req *abci.RequestP return r, nil } +// ApplyBlockRandomness returns the app hash the real application committed: the +// mock replays a block the application has already finalized. +func (mock *mockProxyApp) ApplyBlockRandomness(_ context.Context, _req *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { + return &abci.ResponseApplyBlockRandomness{AppHash: mock.appHash}, nil +} + func (mock *mockProxyApp) FinalizeBlock(_ context.Context, _req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { mock.txCount++ diff --git a/internal/consensus/replayer.go b/internal/consensus/replayer.go index 6650f49838..322bdbab84 100644 --- a/internal/consensus/replayer.go +++ b/internal/consensus/replayer.go @@ -236,22 +236,22 @@ func (r *BlockReplayer) replayBlocks( block *types.Block commit *types.Commit ucState sm.CurrentRoundState + appHash []byte ) for i := firstBlock; i <= finalBlock; i++ { block = r.store.LoadBlock(i) commit = r.store.LoadSeenCommitAt(i) - ucState, err = r.replayBlock(ctx, block, commit, state, i) + ucState, appHash, err = r.replayBlock(ctx, block, commit, state, i) if err != nil { return nil, err } } if !mutateState { - err = r.publishEvents(block, ucState) + err = r.publishEvents(block, commit.BlockID, ucState) if err != nil { return nil, err } } - appHash := ucState.AppHash if mutateState { // sync the final block state, err = r.syncStateAt(ctx, state, rs.storeHeight, r.blockExec) @@ -266,40 +266,76 @@ func (r *BlockReplayer) replayBlocks( return appHash, nil } -// replayBlock adds block at height H to the application +// replayBlock adds block at height H to the application. It returns the +// ProcessProposal result and the app hash the application committed: from +// consensus version 2 the one the commit signs, otherwise the header's. func (r *BlockReplayer) replayBlock( ctx context.Context, block *types.Block, commit *types.Commit, state sm.State, height int64, -) (sm.CurrentRoundState, error) { +) (sm.CurrentRoundState, []byte, error) { r.logger.Info("Replay: applying block", "height", height) // Extra check to ensure the app was not changed in a way it shouldn't have. // The replayer holds no proof for block.LastCommit. ucState, err := r.blockExec.ProcessProposal(ctx, block, commit.Round, state, false, types.VerifiedCommit{}) if err != nil { - return sm.CurrentRoundState{}, fmt.Errorf("blockReplayer process proposal: %w", err) + return sm.CurrentRoundState{}, nil, fmt.Errorf("blockReplayer process proposal: %w", err) + } + // ucState is the ProcessProposal result, so its app hash is the header's even + // at consensus version 2, where the commit signs the app hash after the + // block's randomness is applied; that one is checked here. + committedAppHash, err := r.replayBlockRandomness(ctx, block, commit, height) + if err != nil { + return sm.CurrentRoundState{}, nil, err + } + if committedAppHash == nil { + committedAppHash = ucState.AppHash } // Pre-upgrade stores may contain unchecked extensions. Rejecting them must stop // replay before FinalizeBlock, even though the commit is already persisted. if err := sm.VerifyCommitExtensions(ctx, r.blockExec, commit); err != nil { - return sm.CurrentRoundState{}, commitExtensionsReplayError(block, commit, err) + return sm.CurrentRoundState{}, nil, commitExtensionsReplayError(block, commit, err) } // We emit events for the index services at the final block due to the sync issue when // the node shutdown during the block committing status. // For all other cases, we disable emitting events by providing blockExec=nil in ExecReplayedCommitBlock _, err = sm.ExecReplayedCommitBlock(ctx, r.appClient, block, commit, r.logger) if err != nil { - return sm.CurrentRoundState{}, err + return sm.CurrentRoundState{}, nil, err } // Extra check to ensure the app was not changed in a way it shouldn't have. if err := checkAppHashEqualsOneFromBlock(ucState.AppHash, block); err != nil { - return sm.CurrentRoundState{}, err + return sm.CurrentRoundState{}, nil, err } r.nBlocks++ - return ucState, nil + return ucState, committedAppHash, nil +} + +// replayBlockRandomness applies, when block was committed at consensus version 2, +// the commit's random beacon for the commit round and returns the app hash the +// application reached, after checking that it is the one the commit signs. It +// returns nil for a block committed before consensus version 2. The consensus +// version is the one of the block's height: it can change in either direction. +func (r *BlockReplayer) replayBlockRandomness( + ctx context.Context, + block *types.Block, + commit *types.Commit, + height int64, +) ([]byte, error) { + params, err := r.stateStore.LoadConsensusParams(height) + if err != nil { + return nil, fmt.Errorf("blockReplayer load consensus params at height %d: %w", height, err) + } + if !params.Version.RandomBeacon() { + return nil, nil + } + if err := sm.VerifyBlockRandomness(ctx, r.blockExec, block, commit); err != nil { + return nil, fmt.Errorf("blockReplayer at height %d: %w", height, err) + } + return commit.AppHash, nil } // syncStateAt loads block's data for a height H to sync it with the application. @@ -409,11 +445,13 @@ func (r *BlockReplayer) execInitChain(ctx context.Context, rs *replayState, stat return r.stateStore.Save(*state) } +// publishEvents publishes the events of block, committed with the block ID blockID: the commit's, +// whose state ID carries the app hash the commit signs from consensus version 2. func (r *BlockReplayer) publishEvents( block *types.Block, + blockID types.BlockID, ucState sm.CurrentRoundState, ) error { - blockID := block.BlockID(nil) es := sm.NewFullEventSet(block, blockID, ucState, ucState.NextValidators) err := es.Publish(r.publisher) if err != nil { diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 1237ba3d8e..5d7fd0904c 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -317,6 +317,7 @@ func NewState( queueSender: cs.msgInfoQueue, wal: wal, voteExtender: cs.blockExec, + randomness: cs.blockExec, } cs.blockExecutor = &blockExecutor{ logger: cs.logger, diff --git a/internal/consensus/state_add_vote.go b/internal/consensus/state_add_vote.go index 9289c54d92..b8704d472c 100644 --- a/internal/consensus/state_add_vote.go +++ b/internal/consensus/state_add_vote.go @@ -195,6 +195,14 @@ func addVoteDispatchPrevoteMw(ctrl *Controller) AddVoteMiddlewareFunc { height := stateData.Height // If +2/3 prevotes for *anything* for future round: switch { + case stateData.Step == cstypes.RoundStepApplyCommit && vote.Round == stateData.CommitRound && + stateData.state.ConsensusParams.Version.RandomBeacon(): + // A commit of this node's own precommits waits for the random beacon of the commit round + // (consensus version 2); this prevote may have completed it. + if blockID, ok := prevotes.TwoThirdsMajority(); ok && !blockID.IsNil() { + _ = ctrl.Dispatch(ctx, &TryFinalizeCommitEvent{Height: height}, stateData) + } + case stateData.Round < vote.Round && prevotes.HasTwoThirdsAny(): // Round-skip if there is any 2/3+ of votes ahead of us _ = ctrl.Dispatch(ctx, &EnterNewRoundEvent{Height: height, Round: vote.Round}, stateData) diff --git a/internal/consensus/state_data.go b/internal/consensus/state_data.go index db85c71d43..8cdd1d136c 100644 --- a/internal/consensus/state_data.go +++ b/internal/consensus/state_data.go @@ -246,6 +246,12 @@ func (s *StateData) updateToState(state sm.State, commit *types.Commit, blockSto } precommits := s.Votes.Precommits(s.CommitRound) s.LastCommit = precommits.MakeCommit() + // From consensus version 2 the commit also carries the beacon and the app hash the state was + // finalized with. + if len(state.LastBlockBeacon) > 0 { + s.LastCommit.Beacon = state.LastBlockBeacon + s.LastCommit.AppHash = state.LastAppHash + } case commit != nil: s.LastCommit = commit case s.LastCommit == nil: @@ -316,7 +322,8 @@ func (s *StateData) updateToState(state sm.State, commit *types.Commit, blockSto s.ValidBlock = nil s.ValidBlockParts = nil s.Commit = nil - s.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators, cstypes.WithLogger(s.logger)) + s.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators, cstypes.WithLogger(s.logger), + cstypes.WithRandomBeacon(state.ConsensusParams.Version.RandomBeacon())) s.CommitRound = -1 s.LastValidators = state.LastValidators s.TriggeredTimeoutPrecommit = false @@ -593,8 +600,12 @@ func (s *StateData) retargetTo(blockID types.BlockID, reason retargetReason) { // question about the whole BlockID: a part set header that happens to match says // nothing about the hash or the state ID. A Proposal that outlives the block it // names rejects the real block's last part over its core chain locked height. +// +// The state IDs are not compared: from consensus version 2 a commit or a precommit +// majority names the block with the state ID of the app hash ApplyBlockRandomness +// returned, while the Proposal carries the header's, and both describe one block. func (s *StateData) dropStaleProposal(blockID types.BlockID, reason retargetReason) { - if s.Proposal == nil || s.Proposal.BlockID.Equals(blockID) { + if s.Proposal == nil || s.Proposal.BlockID.SameBlock(blockID) { return } s.logger.Debug("dropping proposal for a block the round no longer tracks", diff --git a/internal/consensus/state_proposaler.go b/internal/consensus/state_proposaler.go index 96f8ecb49d..78936049a2 100644 --- a/internal/consensus/state_proposaler.go +++ b/internal/consensus/state_proposaler.go @@ -65,7 +65,7 @@ func (p *Proposaler) Set( // Keep a later-round proposal from disrupting the committed-block download. if rs.Commit != nil && rs.ProposalBlockParts.HasHeader(rs.Commit.BlockID.PartSetHeader) && - !proposal.BlockID.Equals(rs.Commit.BlockID) { + !proposal.BlockID.SameBlock(rs.Commit.BlockID) { return nil } @@ -339,7 +339,7 @@ func (p *Proposaler) checkProposalAgainstRoundState( func roundStateRefusal(proposal *types.Proposal, rs *cstypes.RoundState) error { commit := rs.Commit if commit != nil && commit.Height == proposal.Height && commit.Round == proposal.Round && - !proposal.BlockID.Equals(commit.BlockID) { + !proposal.BlockID.SameBlock(commit.BlockID) { return ErrInvalidProposalForCommit } if rs.ProposalBlockParts != nil && !rs.ProposalBlockParts.HasHeader(proposal.BlockID.PartSetHeader) { @@ -361,7 +361,9 @@ func (p *Proposaler) verifyProposalForNonValidatorSet(proposal *types.Proposal, // We received a proposal we can not check return ErrUnableToVerifyProposal } - if !proposal.BlockID.Equals(commit.BlockID) { + // Hash and part set header only: from consensus version 2 the commit carries + // the state ID of the app hash it signs, not the header's. + if !proposal.BlockID.SameBlock(commit.BlockID) { return ErrInvalidProposalForCommit } return nil diff --git a/internal/consensus/state_try_add_commit.go b/internal/consensus/state_try_add_commit.go index b311ae6830..0c2058ba23 100644 --- a/internal/consensus/state_try_add_commit.go +++ b/internal/consensus/state_try_add_commit.go @@ -45,6 +45,13 @@ func (cs *TryAddCommitAction) Execute(ctx context.Context, stateEvent StateEvent event := stateEvent.Data.(*TryAddCommitEvent) stateData := stateEvent.StateData commit := event.Commit + if !stateData.state.ConsensusParams.Version.RandomBeacon() { + // Before consensus version 2 a commit carries no beacon; see WithoutRandomBeacon. + commit = commit.WithoutRandomBeacon() + stripped := *event + stripped.Commit = commit + event = &stripped + } peerID := event.PeerID fromReplay := event.FromReplay ctx = ctxWithPeerVerificationBudget(ctx, peerID, fromReplay, cs.verificationBudget) @@ -255,6 +262,24 @@ func verifyCommitBlock( // applied against this block and then recorded carrying its own BlockID. The // next height compares that record against the state this block produced; // they disagree, and no proposer at any round can satisfy both. + // + // From consensus version 2 the commit's state ID carries the app hash the + // commit signs instead of the header's, and the commit carries that app hash + // and the round's random beacon: both are checked against this block. + if stateData.state.ConsensusParams.Version.RandomBeacon() { + if err := commit.VerifyRandomBeacon(stateData.state.ChainID, stateData.Validators, &block.Header); err != nil { + // Debug: the commit's signature does not cover its beacon or app hash, so a + // peer can alter them freely and must not be able to flood the error log. + logger.Debug("commit random beacon does not match the block it commits", + "height", commit.Height, + "node_proTxHash", proTxHash.ShortString(), + "commit_state_id", commit.BlockID.StateID, + "error", err, + ) + return false, fmt.Errorf("cannot finalize commit: %w", err) + } + return true, nil + } if !bytes.Equal(block.StateID().Hash(), commit.BlockID.StateID) { logger.Error("commit state ID does not match the block it commits", "height", commit.Height, @@ -339,5 +364,14 @@ func verifyProcessedCommit(ctx context.Context, blockExec *blockExecutor, stateD if err := blockExec.validate(ctx, stateData); err != nil { return fmt.Errorf("+2/3 committed an invalid block: %w", err) } + // From consensus version 2 the application applies the commit's beacon before + // it checks the extensions, in the order a validator signing a precommit uses. + // The beacon and app hash were verified against the block by verifyCommitBlock; + // an application that reaches another app hash has diverged. + if stateData.state.ConsensusParams.Version.RandomBeacon() { + if err := sm.VerifyBlockRandomness(ctx, blockExec.blockExec, stateData.ProposalBlock, commit); err != nil { + panic(fmt.Errorf("cannot finalize commit at height %d round %d: %w", commit.Height, commit.Round, err)) + } + } return blockExec.verifyCommitExtensions(ctx, &stateData.RoundState, commit) } diff --git a/internal/consensus/state_try_finalize_commit.go b/internal/consensus/state_try_finalize_commit.go index 5c90dbcbf7..ea11f833eb 100644 --- a/internal/consensus/state_try_finalize_commit.go +++ b/internal/consensus/state_try_finalize_commit.go @@ -110,6 +110,14 @@ func (cs *TryFinalizeCommitAction) finalizeCommit(ctx context.Context, ctrl *Con err := cs.blockExec.refuseUnprocessedCommit(&stateData.RoundState, seenCommit) if err == nil { cs.blockExec.mustEnsureProcess(ctx, &stateData.RoundState, seenCommit.Round) + // From consensus version 2 the commit carries the random beacon and the app hash it signs. + if stateData.state.ConsensusParams.Version.RandomBeacon() { + if err := cs.blockExec.completeCommit(ctx, stateData, seenCommit); err != nil { + logger.Info("waiting for the random beacon of the commit round, or a peer's commit", + "commit_round", seenCommit.Round, "error", err) + return + } + } err = cs.blockExec.verifyCommitExtensions(ctx, &stateData.RoundState, seenCommit) } if err != nil { diff --git a/internal/consensus/types/height_vote_set.go b/internal/consensus/types/height_vote_set.go index c212ebc46b..2d2b69fffe 100644 --- a/internal/consensus/types/height_vote_set.go +++ b/internal/consensus/types/height_vote_set.go @@ -46,6 +46,8 @@ type HeightVoteSet struct { height int64 valSet *types.ValidatorSet logger log.Logger + // randomBeacon makes prevote majorities count only once their beacon is recovered + randomBeacon bool mtx sync.Mutex round int32 // max tracked round @@ -66,6 +68,14 @@ func WithLogger(logger log.Logger) HeightVoteSetOption { } } +// WithRandomBeacon makes every prevote VoteSet this HeightVoteSet constructs recover the random beacon +// of a +2/3 majority for a block (consensus version 2); see types.WithRandomBeacon. +func WithRandomBeacon(enabled bool) HeightVoteSetOption { + return func(hvs *HeightVoteSet) { + hvs.randomBeacon = enabled + } +} + func NewHeightVoteSet( chainID string, height int64, @@ -135,7 +145,8 @@ func (hvs *HeightVoteSet) addRound(round int32) { } rvs := RoundVoteSet{} if hvs.valSet.HasPublicKeys { - rvs.Prevotes = types.NewVoteSet(hvs.chainID, hvs.height, round, tmproto.PrevoteType, hvs.valSet, types.WithLogger(hvs.logger)) + rvs.Prevotes = types.NewVoteSet(hvs.chainID, hvs.height, round, tmproto.PrevoteType, hvs.valSet, + types.WithLogger(hvs.logger), types.WithRandomBeacon(hvs.randomBeacon)) rvs.Precommits = types.NewVoteSet(hvs.chainID, hvs.height, round, tmproto.PrecommitType, hvs.valSet, types.WithLogger(hvs.logger)) } hvs.roundVoteSets[round] = rvs diff --git a/internal/consensus/versioned/selectproposer/proposer_selector.go b/internal/consensus/versioned/selectproposer/proposer_selector.go index 403a8e4c49..3b828506cb 100644 --- a/internal/consensus/versioned/selectproposer/proposer_selector.go +++ b/internal/consensus/versioned/selectproposer/proposer_selector.go @@ -59,7 +59,7 @@ func NewProposerSelector(cp types.ConsensusParams, valSet *types.ValidatorSet, v switch cp.Version.ConsensusVersion { case int32(tmtypes.VersionParams_CONSENSUS_VERSION_0): return NewHeightProposerSelector(valSet, valsetHeight, bs, logger) - case int32(tmtypes.VersionParams_CONSENSUS_VERSION_1): + case int32(tmtypes.VersionParams_CONSENSUS_VERSION_1), int32(tmtypes.VersionParams_CONSENSUS_VERSION_2): return NewHeightRoundProposerSelector(valSet, valsetHeight, valsetRound, bs, logger) default: return nil, fmt.Errorf("unknown consensus version: %v", cp.Version.ConsensusVersion) diff --git a/internal/consensus/vote_signer.go b/internal/consensus/vote_signer.go index e649261147..4707d19cc1 100644 --- a/internal/consensus/vote_signer.go +++ b/internal/consensus/vote_signer.go @@ -2,15 +2,30 @@ package consensus import ( "context" + "errors" + "fmt" "time" sm "github.com/dashpay/tenderdash/internal/state" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" "github.com/dashpay/tenderdash/libs/eventemitter" "github.com/dashpay/tenderdash/libs/log" tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" "github.com/dashpay/tenderdash/types" ) +// blockRandomnessApplier applies a block's random beacon through the application; see +// sm.Executor.ApplyBlockRandomness. +type blockRandomnessApplier interface { + ApplyBlockRandomness(ctx context.Context, block *types.Block, round int32, beacon []byte) (tmbytes.HexBytes, error) +} + +// precommitStateKey identifies the block and round a precommit's final state ID is computed for. +type precommitStateKey struct { + round int32 + hash string +} + // voteSigner provides the ability to sign and add a vote type voteSigner struct { privValidator privValidator @@ -18,6 +33,14 @@ type voteSigner struct { queueSender queueSender wal WALWriteFlusher voteExtender sm.VoteExtender + // randomness applies the round's random beacon before a precommit is signed (consensus version 2) + randomness blockRandomnessApplier + + // finalStateIDs caches, for finalStateHeight, the state ID each non-nil precommit was signed over + // (consensus version 2), so this node never signs two state IDs for the same block and round: + // that is duplicate-vote evidence. Only the consensus goroutine signs votes, so it needs no lock. + finalStateHeight int64 + finalStateIDs map[precommitStateKey]tmbytes.HexBytes } // signAddVote signs a vote and sends it to internalMsgQueue @@ -86,6 +109,15 @@ func (s *voteSigner) signVote( timeout := time.Second if msgType == tmproto.PrecommitType && !vote.BlockID.IsNil() { timeout = stateData.voteTimeout(stateData.Round) + // From consensus version 2 the precommit signs the state with the block's randomness applied. + // The application applies it before ExtendVote, so the extensions see that state. + if stateData.state.ConsensusParams.Version.RandomBeacon() { + stateID, err := s.finalStateID(ctx, stateData, vote.BlockID) + if err != nil { + return nil, err + } + vote.BlockID.StateID = stateID + } // if the signedMessage type is for a precommit, add VoteExtension s.voteExtender.ExtendVote(ctx, vote) } @@ -112,6 +144,52 @@ func (s *voteSigner) signVote( return vote, nil } +// finalStateID returns the state ID a precommit for blockID signs at consensus version 2: the hash of the +// block header's StateID with the app hash the application returns from ApplyBlockRandomness, given the +// random beacon recovered from this round's prevotes for the block. blockID is the prevote majority's, +// with the header's state ID. +// +// The result is cached per block and round, and a cached value is returned without asking the +// application again. Like an ExtendVote failure, an ApplyBlockRandomness failure panics: the +// application cannot go on. +func (s *voteSigner) finalStateID(ctx context.Context, stateData *StateData, blockID types.BlockID) (tmbytes.HexBytes, error) { + height, round := stateData.Height, stateData.Round + if s.finalStateHeight != height || s.finalStateIDs == nil { + s.finalStateHeight = height + s.finalStateIDs = make(map[precommitStateKey]tmbytes.HexBytes) + } + key := precommitStateKey{round: round, hash: string(blockID.Hash)} + if stateID, ok := s.finalStateIDs[key]; ok { + return stateID.Copy(), nil + } + + block := stateData.ProposalBlock + if !block.HashesTo(blockID.Hash) { + return nil, fmt.Errorf("cannot apply the randomness of block %X: it is not the proposal block", blockID.Hash) + } + prevotes := stateData.Votes.Prevotes(round) + polka, ok := prevotes.TwoThirdsMajority() + if !ok || !polka.SameBlock(blockID) { + return nil, fmt.Errorf("no prevote majority for block %X in round %d", blockID.Hash, round) + } + beacon := prevotes.ThresholdBlockSignature() + if len(beacon) == 0 { + return nil, errors.New("random beacon of the prevote majority not recovered") + } + if s.randomness == nil { + return nil, errors.New("no application to apply the block's randomness") + } + appHash, err := s.randomness.ApplyBlockRandomness(ctx, block, round, beacon) + if err != nil { + panic(fmt.Errorf("ApplyBlockRandomness call failed: %w", err)) + } + stateID := block.StateIDWithAppHash(appHash) + s.finalStateIDs[key] = stateID.Hash() + s.logger.Debug("applied block randomness", "height", height, "round", round, + "block_app_hash", block.AppHash, "app_hash", appHash) + return s.finalStateIDs[key].Copy(), nil +} + func (s *voteSigner) Subscribe(emitter *eventemitter.EventEmitter) { emitter.AddListener(setPrivValidatorEventName, func(obj eventemitter.EventData) error { s.privValidator = obj.(privValidator) diff --git a/internal/state/errors.go b/internal/state/errors.go index a7e84130e0..0d8b763cb3 100644 --- a/internal/state/errors.go +++ b/internal/state/errors.go @@ -8,6 +8,9 @@ import ( var ( ErrBlockRejected = errors.New("block not accepted by abci app") ErrCommitExtensionsRejected = errors.New("commit vote extensions not accepted by abci app") + // ErrAppHashMismatch means the application reached another app hash than the one a commit signs + // after applying the block's randomness: this node has diverged. + ErrAppHashMismatch = errors.New("app hash after ApplyBlockRandomness does not match the commit") ) type ( diff --git a/internal/state/execution.go b/internal/state/execution.go index c196489fe6..bb048aa989 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -15,6 +15,7 @@ import ( "github.com/dashpay/tenderdash/crypto" "github.com/dashpay/tenderdash/internal/eventbus" "github.com/dashpay/tenderdash/internal/mempool" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" "github.com/dashpay/tenderdash/libs/log" tmstate "github.com/dashpay/tenderdash/proto/tendermint/state" "github.com/dashpay/tenderdash/types" @@ -108,6 +109,12 @@ type Executor interface { // when it is empty. It returns an error on REJECT and panics if the ABCI // call itself fails. VerifyVoteExtension(ctx context.Context, vote *types.Vote) error + + // ApplyBlockRandomness asks the application to apply beacon, the random beacon of block for + // round, to the state ProcessProposal left for that block and round, and returns the app hash + // that precommits and the commit sign (consensus version 2). The block must already be processed + // for round. An error means the application failed or answered with an invalid app hash. + ApplyBlockRandomness(ctx context.Context, block *types.Block, round int32, beacon []byte) (tmbytes.HexBytes, error) } // BlockExecutor provides the context and accessories for properly executing a block. @@ -543,6 +550,13 @@ func (blockExec *BlockExecutor) ValidateBlockWithRoundState( // and uncommittedState is the result of the latest such call, for commit.Round. The application must have // accepted commit's extension vector through VerifyCommitExtensions; FinalizeBlock does not check it. // See also ApplyBlock() to deliver proposal and finalize it in one step. +// +// From consensus version 2, blockID must name the same block as commit.BlockID, and FinalizeBlock uses +// commit.BlockID, whose state ID carries the app hash the commit signs. Before FinalizeBlock reaches the +// application it calls ApplyBlockRandomness with the commit's beacon and round, and fails if the app hash +// returned differs from commit.AppHash: this node has diverged from the validators that signed the +// commit. The commit's beacon and app hash must already be verified against the block (see +// types.Commit.VerifyRandomBeacon); the new state's LastAppHash and LastBlockBeacon are taken from it. func (blockExec *BlockExecutor) FinalizeBlock( ctx context.Context, @@ -578,8 +592,20 @@ func (blockExec *BlockExecutor) FinalizeBlock( } stages.done("finalize_save_abci_responses") + randomBeacon := state.ConsensusParams.Version.RandomBeacon() + if randomBeacon { + if !blockID.SameBlock(commit.BlockID) { + return state, nil, fmt.Errorf("commit block ID %v does not name the finalized block %v", commit.BlockID, blockID) + } + blockID = commit.BlockID + if err := VerifyBlockRandomness(ctx, blockExec, block, commit); err != nil { + return state, nil, err + } + stages.done("finalize_apply_block_randomness") + } + startTime := time.Now().UnixNano() - fbResp, err := execBlockWithoutState(ctx, blockExec.appClient, block, commit, blockExec.logger) + fbResp, err := execBlockWithoutState(ctx, blockExec.appClient, block, blockID, commit, blockExec.logger) if err != nil { return state, nil, ErrInvalidBlock{err} } @@ -590,6 +616,10 @@ func (blockExec *BlockExecutor) FinalizeBlock( if state, err = state.Update(blockID, &block.Header, &uncommittedState); err != nil { return state, nil, fmt.Errorf("commit failed for application: %w", err) } + if randomBeacon { + state.LastAppHash = commit.AppHash.Copy() + state.LastBlockBeacon = bytes.Clone(commit.Beacon) + } stages.done("finalize_state_update") // Lock mempool, commit app state, update mempoool. @@ -650,6 +680,11 @@ func (blockExec *BlockExecutor) ApplyBlock( if err != nil { return state, err } + if state.ConsensusParams.Version.RandomBeacon() { + if err := VerifyBlockRandomness(ctx, blockExec, block, commit); err != nil { + return state, err + } + } if err := VerifyCommitExtensions(ctx, blockExec, commit); err != nil { return state, err } @@ -696,6 +731,50 @@ func (blockExec *BlockExecutor) ExtendVote(ctx context.Context, vote *types.Vote vote.VoteExtensions = extensions } +// ApplyBlockRandomness asks the application to apply beacon, the random beacon of block for round, and +// returns the app hash it answers with. The block must already be processed for round. +func (blockExec *BlockExecutor) ApplyBlockRandomness( + ctx context.Context, + block *types.Block, + round int32, + beacon []byte, +) (tmbytes.HexBytes, error) { + resp, err := blockExec.appClient.ApplyBlockRandomness(ctx, &abci.RequestApplyBlockRandomness{ + Hash: block.Hash(), + Height: block.Height, + Round: round, + Beacon: bytes.Clone(beacon), + }) + if err != nil { + return nil, fmt.Errorf("ApplyBlockRandomness at height %d round %d: %w", block.Height, round, err) + } + if len(resp.GetAppHash()) != blockExec.appHashSize { + return nil, fmt.Errorf("ApplyBlockRandomness at height %d round %d returned an app hash of %d bytes, expected %d", + block.Height, round, len(resp.GetAppHash()), blockExec.appHashSize) + } + return resp.AppHash, nil +} + +// VerifyBlockRandomness asks the application to apply commit's random beacon to block for the commit +// round (consensus version 2) and checks that it reaches the app hash the commit signs. Callers run it +// after ProcessProposal of the block for the commit round and before FinalizeBlock, which runs it again: +// the application answers a repeated call from its cache. An error wrapping ErrAppHashMismatch means +// this node has diverged from the validators that signed the commit, so the block must not be finalized. +func VerifyBlockRandomness(ctx context.Context, executor Executor, block *types.Block, commit *types.Commit) error { + if len(commit.Beacon) != types.SignatureSize || len(commit.AppHash) == 0 { + return fmt.Errorf("commit at height %d round %d carries no random beacon or app hash", commit.Height, commit.Round) + } + appHash, err := executor.ApplyBlockRandomness(ctx, block, commit.Round, commit.Beacon) + if err != nil { + return err + } + if !bytes.Equal(appHash, commit.AppHash) { + return fmt.Errorf("%w: the application's app hash %X after applying the block's randomness at height %d round %d "+ + "differs from the app hash %X the commit signs", ErrAppHashMismatch, appHash, block.Height, commit.Round, commit.AppHash) + } + return nil +} + func (blockExec *BlockExecutor) VerifyVoteExtension(ctx context.Context, vote *types.Vote) error { var extensions []*abci.ExtendVoteExtension if vote.VoteExtensions != nil { @@ -822,10 +901,14 @@ func (blockExec *BlockExecutor) SetAppHashSize(size int) { blockExec.appHashSize = size } +// execBlock sends block to the application's FinalizeBlock. blockID is the block ID the commit signs: +// from consensus version 2 its state ID carries the app hash ApplyBlockRandomness returned, not the +// header's. func execBlock( ctx context.Context, appConn abciclient.Client, block *types.Block, + blockID types.BlockID, commit *types.Commit, logger log.Logger, ) (*abci.ResponseFinalizeBlock, error) { @@ -835,7 +918,6 @@ func execBlock( if err != nil { return nil, err } - blockID := block.BlockID(nil) protoBlockID := blockID.ToProto() responseFinalizeBlock, err := appConn.FinalizeBlock( @@ -872,7 +954,7 @@ func ExecReplayedCommitBlock( commit *types.Commit, logger log.Logger, ) (*abci.ResponseFinalizeBlock, error) { - fbResp, err := execBlockWithoutState(ctx, appConn, block, commit, logger) + fbResp, err := execBlockWithoutState(ctx, appConn, block, commit.BlockID, commit, logger) if err != nil { return nil, err } @@ -884,10 +966,11 @@ func execBlockWithoutState( ctx context.Context, appConn abciclient.Client, block *types.Block, + blockID types.BlockID, commit *types.Commit, logger log.Logger, ) (*abci.ResponseFinalizeBlock, error) { - return execBlock(ctx, appConn, block, commit, logger) + return execBlock(ctx, appConn, block, blockID, commit, logger) } func (blockExec *BlockExecutor) pruneBlocks(retainHeight int64) { diff --git a/internal/state/export_test.go b/internal/state/export_test.go index d99b509777..b8058cab96 100644 --- a/internal/state/export_test.go +++ b/internal/state/export_test.go @@ -10,3 +10,9 @@ import ( func ValidateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, params types.ValidatorParams) error { return validateValidatorUpdates(abciUpdates, params) } + +// VerifyLastCommitBeacon is an alias for verifyLastCommitBeacon exported from validation.go, exclusively +// and explicitly for testing. +func VerifyLastCommitBeacon(state State, block *types.Block) error { + return verifyLastCommitBeacon(state, block) +} diff --git a/internal/state/mocks/executor.go b/internal/state/mocks/executor.go index b916806ca0..9eee1e7b43 100644 --- a/internal/state/mocks/executor.go +++ b/internal/state/mocks/executor.go @@ -9,6 +9,7 @@ import ( types0 "github.com/dashpay/tenderdash/abci/types" "github.com/dashpay/tenderdash/internal/state" + "github.com/dashpay/tenderdash/libs/bytes" "github.com/dashpay/tenderdash/types" mock "github.com/stretchr/testify/mock" ) @@ -139,6 +140,86 @@ func (_c *Executor_ApplyBlock_Call) RunAndReturn(run func(ctx context.Context, s return _c } +// ApplyBlockRandomness provides a mock function for the type Executor +func (_mock *Executor) ApplyBlockRandomness(ctx context.Context, block *types.Block, round int32, beacon []byte) (bytes.HexBytes, error) { + ret := _mock.Called(ctx, block, round, beacon) + + if len(ret) == 0 { + panic("no return value specified for ApplyBlockRandomness") + } + + var r0 bytes.HexBytes + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Block, int32, []byte) (bytes.HexBytes, error)); ok { + return returnFunc(ctx, block, round, beacon) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Block, int32, []byte) bytes.HexBytes); ok { + r0 = returnFunc(ctx, block, round, beacon) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(bytes.HexBytes) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, *types.Block, int32, []byte) error); ok { + r1 = returnFunc(ctx, block, round, beacon) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// Executor_ApplyBlockRandomness_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyBlockRandomness' +type Executor_ApplyBlockRandomness_Call struct { + *mock.Call +} + +// ApplyBlockRandomness is a helper method to define mock.On call +// - ctx context.Context +// - block *types.Block +// - round int32 +// - beacon []byte +func (_e *Executor_Expecter) ApplyBlockRandomness(ctx any, block any, round any, beacon any) *Executor_ApplyBlockRandomness_Call { + return &Executor_ApplyBlockRandomness_Call{Call: _e.mock.On("ApplyBlockRandomness", ctx, block, round, beacon)} +} + +func (_c *Executor_ApplyBlockRandomness_Call) Run(run func(ctx context.Context, block *types.Block, round int32, beacon []byte)) *Executor_ApplyBlockRandomness_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *types.Block + if args[1] != nil { + arg1 = args[1].(*types.Block) + } + var arg2 int32 + if args[2] != nil { + arg2 = args[2].(int32) + } + var arg3 []byte + if args[3] != nil { + arg3 = args[3].([]byte) + } + run( + arg0, + arg1, + arg2, + arg3, + ) + }) + return _c +} + +func (_c *Executor_ApplyBlockRandomness_Call) Return(hexBytes bytes.HexBytes, err error) *Executor_ApplyBlockRandomness_Call { + _c.Call.Return(hexBytes, err) + return _c +} + +func (_c *Executor_ApplyBlockRandomness_Call) RunAndReturn(run func(ctx context.Context, block *types.Block, round int32, beacon []byte) (bytes.HexBytes, error)) *Executor_ApplyBlockRandomness_Call { + _c.Call.Return(run) + return _c +} + // CreateProposalBlock provides a mock function for the type Executor func (_mock *Executor) CreateProposalBlock(ctx context.Context, height int64, round int32, state1 state.State, commit *types.Commit, proposerProTxHash []byte, proposedAppVersion uint64) (*types.Block, state.CurrentRoundState, error) { ret := _mock.Called(ctx, height, round, state1, commit, proposerProTxHash, proposedAppVersion) diff --git a/internal/state/random_beacon_test.go b/internal/state/random_beacon_test.go new file mode 100644 index 0000000000..9e94e3e0ef --- /dev/null +++ b/internal/state/random_beacon_test.go @@ -0,0 +1,145 @@ +package state_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + abciclient "github.com/dashpay/tenderdash/abci/client" + abci "github.com/dashpay/tenderdash/abci/types" + "github.com/dashpay/tenderdash/crypto" + "github.com/dashpay/tenderdash/dash" + "github.com/dashpay/tenderdash/internal/eventbus" + mpmocks "github.com/dashpay/tenderdash/internal/mempool/mocks" + "github.com/dashpay/tenderdash/internal/proxy" + sm "github.com/dashpay/tenderdash/internal/state" + "github.com/dashpay/tenderdash/internal/store" + dbm "github.com/dashpay/tenderdash/libs/db" + "github.com/dashpay/tenderdash/libs/log" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" + "github.com/dashpay/tenderdash/types" +) + +// randomnessApp is testApp answering ApplyBlockRandomness with a fixed app hash, and recording the calls +// and the block ID FinalizeBlock receives. +type randomnessApp struct { + testApp + + appHash []byte + randomnessCalls int + finalizeBlockID *tmproto.BlockID +} + +func (app *randomnessApp) ApplyBlockRandomness(_ context.Context, _ *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { + app.randomnessCalls++ + return &abci.ResponseApplyBlockRandomness{AppHash: app.appHash}, nil +} + +func (app *randomnessApp) FinalizeBlock(ctx context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { + app.finalizeBlockID = req.BlockID + return app.testApp.FinalizeBlock(ctx, req) +} + +// TestFinalizeBlockRandomBeacon checks FinalizeBlock at consensus version 2: it applies the commit's beacon +// before FinalizeBlock reaches the application, refuses an app hash that differs from the commit's, sends +// and records the commit's BlockID, and keeps the commit's app hash and beacon in the new state. Before +// consensus version 2 none of this happens. +func TestFinalizeBlockRandomBeacon(t *testing.T) { + finalAppHash := crypto.Checksum([]byte("final app hash")) + beacon := crypto.CRandBytes(types.SignatureSize) + + setup := func(t *testing.T, consensusVersion int32) (context.Context, *randomnessApp, *sm.BlockExecutor, sm.State, *types.Block, sm.CurrentRoundState) { + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + app := &randomnessApp{appHash: finalAppHash} + logger := log.NewNopLogger() + proxyApp := proxy.New(abciclient.NewLocalClient(logger, app), logger, proxy.NopMetrics()) + require.NoError(t, proxyApp.Start(ctx)) + + state, stateDB, _ := makeState(t, 1, 1) + state.ConsensusParams.Version.ConsensusVersion = consensusVersion + nodeProTxHash := state.Validators.Validators[0].ProTxHash + ctx = dash.ContextWithProTxHash(ctx, nodeProTxHash) + + mp := &mpmocks.Mempool{} + mp.On("Lock").Return() + mp.On("Unlock").Return() + mp.On("FlushAppConn", mock.Anything).Return(nil) + mp.On("Update", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, + mock.Anything).Return(nil) + mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) + eventBus := eventbus.NewDefault(logger) + require.NoError(t, eventBus.Start(ctx)) + blockExec := sm.NewBlockExecutor(sm.NewStore(stateDB), proxyApp, mp, sm.EmptyEvidencePool{}, + store.NewBlockStore(dbm.NewMemDB()), eventBus) + + block, uncommittedState, err := blockExec.CreateProposalBlock(ctx, 1, 0, state, + types.NewCommit(state.LastBlockHeight, 0, state.LastBlockID, nil, nil), nodeProTxHash, 1) + require.NoError(t, err) + return ctx, app, blockExec, state, block, uncommittedState + } + commitFor := func(block *types.Block, appHash []byte) *types.Commit { + blockID := block.BlockID(nil) + blockID.StateID = block.Header.StateIDWithAppHash(appHash).Hash() + return &types.Commit{Height: block.Height, BlockID: blockID, Beacon: beacon, AppHash: appHash} + } + + t.Run("consensus version 2", func(t *testing.T) { + ctx, app, blockExec, state, block, uncommittedState := setup(t, 2) + commit := commitFor(block, finalAppHash) + next, _, err := blockExec.FinalizeBlock(ctx, state, uncommittedState, block.BlockID(nil), block, commit, + types.VerifiedCommit{}) + require.NoError(t, err) + require.Equal(t, 1, app.randomnessCalls) + require.NotNil(t, app.finalizeBlockID) + require.EqualValues(t, commit.BlockID.StateID, app.finalizeBlockID.StateID, "FinalizeBlock gets the commit's BlockID") + require.True(t, next.LastBlockID.Equals(commit.BlockID)) + require.EqualValues(t, finalAppHash, next.LastAppHash) + require.Equal(t, beacon, next.LastBlockBeacon) + }) + + t.Run("consensus version 2, the application diverged", func(t *testing.T) { + ctx, app, blockExec, state, block, uncommittedState := setup(t, 2) + otherAppHash := crypto.Checksum([]byte("other app hash")) + commit := commitFor(block, otherAppHash) + _, _, err := blockExec.FinalizeBlock(ctx, state, uncommittedState, block.BlockID(nil), block, commit, + types.VerifiedCommit{}) + require.ErrorIs(t, err, sm.ErrAppHashMismatch) + require.Nil(t, app.finalizeBlockID, "the block does not reach FinalizeBlock") + }) + + t.Run("before consensus version 2", func(t *testing.T) { + ctx, app, blockExec, state, block, uncommittedState := setup(t, 1) + blockID := block.BlockID(nil) + next, _, err := blockExec.FinalizeBlock(ctx, state, uncommittedState, blockID, block, + &types.Commit{Height: block.Height, BlockID: blockID}, types.VerifiedCommit{}) + require.NoError(t, err) + require.Zero(t, app.randomnessCalls) + require.True(t, next.LastBlockID.Equals(blockID)) + require.EqualValues(t, block.AppHash, next.LastAppHash) + require.Empty(t, next.LastBlockBeacon) + }) +} + +// TestVerifyLastCommitBeacon checks that, once the last block was committed at consensus version 2, the +// next block's LastCommit must carry the beacon and the app hash of the commit the last block was +// finalized with, and that both are ignored before. +func TestVerifyLastCommitBeacon(t *testing.T) { + beacon := crypto.CRandBytes(types.SignatureSize) + appHash := crypto.Checksum([]byte("final app hash")) + block := &types.Block{LastCommit: &types.Commit{Beacon: beacon, AppHash: appHash}} + + state := sm.State{LastBlockBeacon: beacon, LastAppHash: appHash} + require.NoError(t, sm.VerifyLastCommitBeacon(state, block)) + + state.LastBlockBeacon = crypto.CRandBytes(types.SignatureSize) + require.ErrorContains(t, sm.VerifyLastCommitBeacon(state, block), "LastCommit.Beacon") + + state = sm.State{LastBlockBeacon: beacon, LastAppHash: crypto.Checksum([]byte("other"))} + require.ErrorContains(t, sm.VerifyLastCommitBeacon(state, block), "LastCommit.AppHash") + + // Before consensus version 2 the fields are not checked, whatever they hold. + require.NoError(t, sm.VerifyLastCommitBeacon(sm.State{LastAppHash: crypto.Checksum([]byte("other"))}, block)) +} diff --git a/internal/state/rollback.go b/internal/state/rollback.go index 5690778629..df807b6ad6 100644 --- a/internal/state/rollback.go +++ b/internal/state/rollback.go @@ -101,6 +101,27 @@ func Rollback(bs BlockStore, ss Store) (int64, []byte, error) { LastAppHash: latestBlock.Header.AppHash, } + // From consensus version 2, the commit of the rolled back block signs a state ID with the app hash + // ApplyBlockRandomness returned, and the next block's LastCommit must carry its beacon and app hash. + // Take all three from that commit: the latest block's LastCommit. + rollbackParams, err := ss.LoadConsensusParams(rollbackHeight) + if err != nil { + return -1, nil, err + } + if rollbackParams.Version.RandomBeacon() { + commit := bs.LoadBlockCommit(rollbackHeight) + if commit == nil { + return -1, nil, fmt.Errorf("commit at height %d not found", rollbackHeight) + } + if !commit.BlockID.SameBlock(rollbackBlock.BlockID) { + return -1, nil, fmt.Errorf("commit at height %d is for block %v, not %v", + rollbackHeight, commit.BlockID, rollbackBlock.BlockID) + } + rolledBackState.LastBlockID = commit.BlockID + rolledBackState.LastAppHash = commit.AppHash + rolledBackState.LastBlockBeacon = commit.Beacon + } + // persist the new state. This overrides the invalid one. NOTE: this will also // persist the validator set and consensus params over the existing structures, // but both should be the same diff --git a/internal/state/rollback_test.go b/internal/state/rollback_test.go index 1681a6002f..c112326c36 100644 --- a/internal/state/rollback_test.go +++ b/internal/state/rollback_test.go @@ -118,12 +118,15 @@ func TestRollbackDifferentStateHeight(t *testing.T) { require.Equal(t, err.Error(), "statestore height (100) is not one below or equal to blockstore height (102)") } -func setupStateStore(t *testing.T, height int64) state.Store { +func setupStateStore(t *testing.T, height int64, paramsOpts ...func(*types.ConsensusParams)) state.Store { stateStore := state.NewStore(dbm.NewMemDB()) valSet, _ := types.RandValidatorSet(5) params := types.DefaultConsensusParams() params.Version.AppVersion = 10 + for _, opt := range paramsOpts { + opt(params) + } initialState := state.State{ Version: state.Version{ @@ -145,6 +148,77 @@ func setupStateStore(t *testing.T, height int64) state.Store { ConsensusParams: *params, LastHeightConsensusParamsChanged: height + 1, } + // The state of the previous height holds the consensus params of this one, as in a node's store. + previousState := initialState.Copy() + previousState.LastBlockHeight = height - 1 + previousState.LastHeightConsensusParamsChanged = height + require.NoError(t, stateStore.Bootstrap(previousState)) require.NoError(t, stateStore.Bootstrap(initialState)) return stateStore } + +// TestRollbackRandomBeacon checks that rolling back a block committed at consensus version 2 restores the +// commit's BlockID, app hash and beacon, which the next block's header and LastCommit carry. +func TestRollbackRandomBeacon(t *testing.T) { + const ( + height int64 = 100 + nextHeight int64 = 101 + ) + stateStore := setupStateStore(t, height, func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = 2 + }) + initialState, err := stateStore.Load() + require.NoError(t, err) + + nextState := initialState.Copy() + nextState.LastBlockHeight = nextHeight + nextState.LastBlockID = factory.MakeBlockID() + nextState.LastAppHash = factory.RandomHash() + nextState.LastValidators = initialState.Validators + nextState.LastHeightConsensusParamsChanged = nextHeight + 1 + require.NoError(t, stateStore.Save(nextState)) + + headerBlockID := factory.MakeBlockID() + commit := &types.Commit{ + Height: height, + BlockID: headerBlockID.Copy(), + Beacon: factory.RandomHash(), + AppHash: factory.RandomHash(), + } + commit.BlockID.StateID = factory.RandomHash() + block := &types.BlockMeta{ + BlockID: headerBlockID, + Header: types.Header{ + Height: height, + AppHash: factory.RandomHash(), + ProposerProTxHash: initialState.Validators.Validators[0].ProTxHash, + ValidatorsHash: initialState.Validators.Hash(), + }, + } + nextBlock := &types.BlockMeta{ + BlockID: factory.MakeBlockID(), + Header: types.Header{ + Height: nextHeight, + AppHash: factory.RandomHash(), + LastBlockID: commit.BlockID, + ProposerProTxHash: nextState.Validators.Validators[1].ProTxHash, + ValidatorsHash: nextState.Validators.Hash(), + }, + } + blockStore := &mocks.BlockStore{} + blockStore.On("LoadBlockMeta", height).Return(block) + blockStore.On("LoadBlockMeta", nextHeight).Return(nextBlock) + blockStore.On("LoadBlockCommit", height).Return(commit) + blockStore.On("Height").Return(nextHeight) + blockStore.On("Base").Return(height) + + rollbackHeight, _, err := state.Rollback(blockStore, stateStore) + require.NoError(t, err) + require.EqualValues(t, height, rollbackHeight) + + loaded, err := stateStore.Load() + require.NoError(t, err) + require.True(t, loaded.LastBlockID.Equals(commit.BlockID)) + require.EqualValues(t, commit.AppHash, loaded.LastAppHash) + require.Equal(t, commit.Beacon, loaded.LastBlockBeacon) +} diff --git a/internal/state/state.go b/internal/state/state.go index 34e256fd18..894c1416ca 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -107,7 +107,13 @@ type State struct { LastResultsHash tmbytes.HexBytes // the latest LastAppHash we've received from calling abci.Commit() + // From consensus version 2, it is the app hash the last block's commit signs, as returned by + // ApplyBlockRandomness, which can differ from the app hash in that block's header. LastAppHash tmbytes.HexBytes + + // LastBlockBeacon is the random beacon carried by the last block's commit, from consensus version 2; + // empty before. The next block's LastCommit must carry the same beacon. + LastBlockBeacon []byte } // NewRound changes the State to apply settings new round and height to it. @@ -142,7 +148,8 @@ func (state State) Copy() State { ConsensusParams: state.ConsensusParams, LastHeightConsensusParamsChanged: state.LastHeightConsensusParamsChanged, - LastAppHash: state.LastAppHash, + LastAppHash: state.LastAppHash, + LastBlockBeacon: state.LastBlockBeacon, LastResultsHash: state.LastResultsHash, } @@ -217,6 +224,7 @@ func (state *State) ToProto() (*tmstate.State, error) { sm.LastHeightConsensusParamsChanged = state.LastHeightConsensusParamsChanged sm.LastResultsHash = state.LastResultsHash sm.AppHash = state.LastAppHash + sm.LastBlockBeacon = state.LastBlockBeacon return sm, nil } @@ -262,6 +270,7 @@ func FromProto(pb *tmstate.State) (*State, error) { //nolint:golint state.LastHeightConsensusParamsChanged = pb.LastHeightConsensusParamsChanged state.LastResultsHash = pb.LastResultsHash state.LastAppHash = pb.AppHash + state.LastBlockBeacon = pb.LastBlockBeacon return state, nil } diff --git a/internal/state/validation.go b/internal/state/validation.go index a9bb3bc703..dcc9cdd92c 100644 --- a/internal/state/validation.go +++ b/internal/state/validation.go @@ -82,8 +82,13 @@ func validateBlock(state State, block *types.Block, lastCommit types.VerifiedCom if len(block.LastCommit.ThresholdBlockSignature) != 0 { return errors.New("initial block can't have ThresholdBlockSignature set") } - } else if err := verifyLastCommit(state, block, lastCommit, metrics); err != nil { - return err + } else { + if err := verifyLastCommit(state, block, lastCommit, metrics); err != nil { + return err + } + if err := verifyLastCommitBeacon(state, block); err != nil { + return err + } } // NOTE: We can't actually verify it's the right proposer because we don't @@ -152,6 +157,26 @@ func verifyLastCommit(state State, block *types.Block, lastCommit types.Verified return nil } +// verifyLastCommitBeacon checks the random beacon and the app hash of block.LastCommit when the last +// block was committed at consensus version 2 or later, that is when state.LastBlockBeacon is set. They +// must be the ones of the commit the last block was finalized with: its threshold signature covers +// neither, and a block whose LastCommit carried others would hand block sync and light clients a +// commit for the last block that fails verification. Before that, both fields are ignored. +func verifyLastCommitBeacon(state State, block *types.Block) error { + if len(state.LastBlockBeacon) == 0 { + return nil + } + if !bytes.Equal(block.LastCommit.Beacon, state.LastBlockBeacon) { + return fmt.Errorf("wrong Block.LastCommit.Beacon. Expected %X, got %X", + state.LastBlockBeacon, block.LastCommit.Beacon) + } + if !bytes.Equal(block.LastCommit.AppHash, state.LastAppHash) { + return fmt.Errorf("wrong Block.LastCommit.AppHash. Expected %X, got %X", + state.LastAppHash, block.LastCommit.AppHash) + } + return nil +} + // ValidateBlockChainLock validates the given block chain lock against the given state. // If the block is invalid, it returns an error. // Validation does not mutate state, but does require historical information from the stateDB, diff --git a/internal/statesync/random_beacon_test.go b/internal/statesync/random_beacon_test.go new file mode 100644 index 0000000000..1e02885bdd --- /dev/null +++ b/internal/statesync/random_beacon_test.go @@ -0,0 +1,120 @@ +package statesync + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/dashpay/tenderdash/crypto" + sm "github.com/dashpay/tenderdash/internal/state" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" + "github.com/dashpay/tenderdash/types" + "github.com/dashpay/tenderdash/version" +) + +// TestSetLastBlockRandomness checks the state restored from a snapshot taken at a block committed at +// consensus version 2: its LastAppHash is the app hash the commit signs and its LastBlockBeacon the +// commit's verified beacon. Before consensus version 2, or when the snapshot block's header does not +// commit to the next height's parameters, the state is left as it is. +func TestSetLastBlockRandomness(t *testing.T) { + ctx := context.Background() + const chainID = "test-chain" + const round = int32(1) + valSet, privVals := types.RandValidatorSet(4) + params := *types.DefaultConsensusParams() + params.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + + header := &types.Header{ + Version: version.Consensus{Block: version.BlockProtocol, App: 1}, + ChainID: chainID, + Height: 10, + Time: time.Now(), + ValidatorsHash: valSet.Hash(), + NextValidatorsHash: valSet.Hash(), + ConsensusHash: params.HashConsensusParams(), + AppHash: crypto.Checksum([]byte("header app hash")), + ProposerProTxHash: valSet.Validators[0].ProTxHash, + } + prevoteBlockID := types.BlockID{ + Hash: header.Hash(), + PartSetHeader: types.PartSetHeader{Total: 1, Hash: crypto.Checksum([]byte("parts"))}, + StateID: header.StateID().Hash(), + } + + voteSet := types.NewVoteSet(chainID, header.Height, round, tmproto.PrevoteType, valSet, types.WithRandomBeacon(true)) + for i, privVal := range privVals { + proTxHash, err := privVal.GetProTxHash(ctx) + require.NoError(t, err) + vote := &types.Vote{ + ValidatorProTxHash: proTxHash, + ValidatorIndex: int32(i), + Height: header.Height, + Round: round, + Type: tmproto.PrevoteType, + BlockID: prevoteBlockID, + } + protoVote := vote.ToProto() + require.NoError(t, privVal.SignVote(ctx, chainID, valSet.QuorumType, valSet.QuorumHash, protoVote, nil)) + require.NoError(t, vote.PopulateSignsFromProto(protoVote)) + _, err = voteSet.AddVote(vote) + require.NoError(t, err) + } + beacon := voteSet.ThresholdBlockSignature() + require.Len(t, beacon, types.SignatureSize) + + finalAppHash := tmbytes.HexBytes(crypto.Checksum(append(header.AppHash.Copy(), beacon...))) + commitBlockID := prevoteBlockID.Copy() + commitBlockID.StateID = header.StateIDWithAppHash(finalAppHash).Hash() + lightBlock := func(beacon []byte) *types.LightBlock { + return &types.LightBlock{ + SignedHeader: &types.SignedHeader{Header: header, Commit: &types.Commit{ + Height: header.Height, + Round: round, + BlockID: commitBlockID, + Beacon: beacon, + AppHash: finalAppHash, + }}, + ValidatorSet: valSet, + } + } + newState := func(consensusVersion int32) sm.State { + p := params + p.Version.ConsensusVersion = consensusVersion + return sm.State{ChainID: chainID, LastValidators: valSet, ConsensusParams: p, + LastAppHash: crypto.Checksum([]byte("next header app hash"))} + } + + t.Run("consensus version 2", func(t *testing.T) { + state := newState(2) + require.NoError(t, setLastBlockRandomness(&state, lightBlock(beacon))) + require.EqualValues(t, finalAppHash, state.LastAppHash) + require.Equal(t, beacon, state.LastBlockBeacon) + }) + + t.Run("a beacon that does not verify", func(t *testing.T) { + state := newState(2) + require.ErrorIs(t, setLastBlockRandomness(&state, lightBlock(crypto.CRandBytes(types.SignatureSize))), + types.ErrInvalidCommitBeacon) + }) + + for name, consensusVersion := range map[string]int32{ + "before consensus version 2": 1, + // The next height uses version 2, but the snapshot header commits to other hashed parameters, as at + // the activation height. + "activation height": 2, + } { + t.Run(name, func(t *testing.T) { + state := newState(consensusVersion) + if name == "activation height" { + state.ConsensusParams.Block.MaxBytes++ + } + before := state.LastAppHash + require.NoError(t, setLastBlockRandomness(&state, lightBlock(beacon))) + require.Equal(t, before, state.LastAppHash) + require.Empty(t, state.LastBlockBeacon) + }) + } +} diff --git a/internal/statesync/stateprovider.go b/internal/statesync/stateprovider.go index 7de84607d1..0463aef0f8 100644 --- a/internal/statesync/stateprovider.go +++ b/internal/statesync/stateprovider.go @@ -132,7 +132,9 @@ func (s *stateProviderRPC) AppHash(ctx context.Context, height uint64) (tmbytes. return nil, err } - return header.AppHash, nil + // The app hash the commit signs: from consensus version 2 the one after the + // block's randomness is applied, which the application holds; before, the header's. + return header.CommittedAppHash() } // Commit implements StateProvider. @@ -220,6 +222,9 @@ func (s *stateProviderRPC) State(ctx context.Context, height uint64) (sm.State, state.ConsensusParams = result.ConsensusParams applyVotingPowerThreshold(&state) state.LastHeightConsensusParamsChanged = currentLightBlock.Height + if err := setLastBlockRandomness(&state, lastLightBlock); err != nil { + return sm.State{}, err + } return state, nil } @@ -289,7 +294,9 @@ func (s *stateProviderP2P) AppHash(ctx context.Context, height uint64) (tmbytes. return nil, err } - return header.AppHash, nil + // The app hash the commit signs: from consensus version 2 the one after the + // block's randomness is applied, which the application holds; before, the header's. + return header.CommittedAppHash() } // Commit implements StateProvider. @@ -367,10 +374,40 @@ func (s *stateProviderP2P) State(ctx context.Context, height uint64) (sm.State, applyVotingPowerThreshold(&state) // set the last height changed to the current height state.LastHeightConsensusParamsChanged = currentLightBlock.Height + if err := setLastBlockRandomness(&state, lastLightBlock); err != nil { + return sm.State{}, err + } return state, nil } +// setLastBlockRandomness sets, when the snapshot block lastLightBlock was committed at consensus version +// 2, the state's LastAppHash to the app hash its commit signs, the one after the block's randomness is +// applied and the one the application holds, and LastBlockBeacon to its commit's verified beacon. The +// next block's LastCommit must carry both. +// +// The block used consensus version 2 when the next height does (state.ConsensusParams) and its header +// commits to the same hashed parameters, the consensus version among them. Otherwise, at the activation +// height or across a change of the other hashed parameters, the state is left as it is and the next +// block's LastCommit beacon is not checked: the validators that committed that block did. +func setLastBlockRandomness(state *sm.State, lastLightBlock *types.LightBlock) error { + params := state.ConsensusParams + if !params.Version.RandomBeacon() || !bytes.Equal(lastLightBlock.ConsensusHash, params.HashConsensusParams()) { + return nil + } + appHash, err := lastLightBlock.CommittedAppHash() + if err != nil { + return fmt.Errorf("app hash of the commit at height %d: %w", lastLightBlock.Height, err) + } + commit := lastLightBlock.Commit + if err := commit.VerifyRandomBeacon(state.ChainID, state.LastValidators, lastLightBlock.Header); err != nil { + return fmt.Errorf("random beacon of the commit at height %d: %w", lastLightBlock.Height, err) + } + state.LastAppHash = appHash + state.LastBlockBeacon = bytes.Clone(commit.Beacon) + return nil +} + // authenticateStateSyncValidatorSet replaces validator membership and live // consensus controls supplied by a light-block peer with values from local Dash // Core and the signed header. The legacy ValidatorsHash authenticates only the diff --git a/light/rpc/client.go b/light/rpc/client.go index ba0081de85..1edf995961 100644 --- a/light/rpc/client.go +++ b/light/rpc/client.go @@ -193,7 +193,13 @@ func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data tmb return nil, err } - // Validate the value proof against the trusted header. + // Validate the value proof against the trusted header. From consensus version 2 + // the state is the one after the block's randomness is applied, whose app hash + // the commit signs. + appHash, err := l.CommittedAppHash() + if err != nil { + return nil, err + } // build a Merkle key path from path and resp.Key if c.keyPathFn == nil { @@ -207,12 +213,12 @@ func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data tmb // verify value if resp.Value != nil { - err = c.prt.VerifyValue(resp.ProofOps, l.AppHash, kp.String(), resp.Value) + err = c.prt.VerifyValue(resp.ProofOps, appHash, kp.String(), resp.Value) if err != nil { return nil, fmt.Errorf("verify value proof: %w", err) } } else { // OR validate the absence proof against the trusted header. - err = c.prt.VerifyAbsence(resp.ProofOps, l.AppHash, kp.String()) + err = c.prt.VerifyAbsence(resp.ProofOps, appHash, kp.String()) if err != nil { return nil, fmt.Errorf("verify absence proof: %w", err) } diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index 428f224a0f..2142053fca 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -264,6 +264,9 @@ type State struct { NextCoreChainLock *types1.CoreChainLock `protobuf:"bytes,15,opt,name=next_core_chain_lock,json=nextCoreChainLock,proto3" json:"next_core_chain_lock,omitempty"` // last_block_round is the round number at which the last block was committed. LastBlockRound int32 `protobuf:"varint,16,opt,name=last_block_round,json=lastBlockRound,proto3" json:"last_block_round,omitempty"` + // last_block_beacon is the random beacon carried by the commit of the last block, from consensus version 2. + // The next block's LastCommit must carry the same beacon. + LastBlockBeacon []byte `protobuf:"bytes,17,opt,name=last_block_beacon,json=lastBlockBeacon,proto3" json:"last_block_beacon,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -411,6 +414,13 @@ func (m *State) GetLastBlockRound() int32 { return 0 } +func (m *State) GetLastBlockBeacon() []byte { + if m != nil { + return m.LastBlockBeacon + } + return nil +} + func init() { proto.RegisterType((*ABCIResponses)(nil), "tendermint.state.ABCIResponses") proto.RegisterType((*ValidatorsInfo)(nil), "tendermint.state.ValidatorsInfo") @@ -422,57 +432,58 @@ func init() { func init() { proto.RegisterFile("tendermint/state/types.proto", fileDescriptor_ccfacf933f22bf93) } var fileDescriptor_ccfacf933f22bf93 = []byte{ - // 790 bytes of a gzipped FileDescriptorProto + // 805 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xbb, 0x6e, 0xdb, 0x48, 0x14, 0x15, 0xd7, 0x0f, 0x49, 0x23, 0xeb, 0x61, 0xda, 0x05, 0x2d, 0xaf, 0x29, 0xad, 0xf6, 0x01, - 0x61, 0x0b, 0x0a, 0xd8, 0x4d, 0x93, 0x26, 0x80, 0x25, 0x03, 0xb1, 0x10, 0xc3, 0x30, 0xc6, 0x81, - 0x8a, 0x34, 0xc4, 0x88, 0x1c, 0x8b, 0x44, 0x24, 0x0e, 0xc1, 0x19, 0x39, 0xf1, 0x07, 0xa4, 0x77, - 0x9b, 0x3f, 0x72, 0xe9, 0x32, 0x95, 0x13, 0xc8, 0x45, 0x7e, 0x23, 0x98, 0x07, 0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, 0xb6, 0xd1, 0xdd, 0x91, 0xfe, 0x81, 0x32, 0x7e, 0x8a, 0x68, 0x60, 0x1e, 0x80, 0x12, - 0x8a, 0x63, 0x99, 0x52, 0x15, 0x29, 0x45, 0x14, 0xc7, 0x02, 0x7a, 0x03, 0xfe, 0x14, 0x34, 0x1e, - 0x49, 0xb0, 0x2b, 0xfd, 0xcd, 0x1f, 0x15, 0xfb, 0x79, 0x63, 0xd6, 0xda, 0x46, 0xb7, 0x0a, 0xc5, - 0x68, 0x07, 0x24, 0xc1, 0xc2, 0xf4, 0x67, 0x22, 0x4f, 0xf7, 0xe9, 0x08, 0xec, 0x47, 0xf8, 0xe3, - 0x1a, 0x99, 0x55, 0x17, 0xb3, 0x6b, 0x3d, 0x35, 0x3b, 0x8d, 0x4b, 0x4c, 0xce, 0x80, 0xbb, 0x9c, - 0x22, 0x07, 0x98, 0x5d, 0xd0, 0xd0, 0xbc, 0x9a, 0x90, 0x79, 0xe4, 0x5b, 0x8d, 0xb6, 0xd1, 0xdd, - 0x92, 0xcf, 0x2f, 0x24, 0x40, 0x1e, 0xed, 0x9f, 0xdf, 0x2d, 0x6c, 0xe3, 0x7e, 0x61, 0x1b, 0xdf, - 0x16, 0xb6, 0x71, 0xfb, 0x68, 0x17, 0xee, 0x1f, 0xed, 0xc2, 0x97, 0x47, 0xbb, 0xf0, 0xee, 0xc5, - 0x24, 0x64, 0xc1, 0x7c, 0xec, 0x78, 0x64, 0x26, 0x7e, 0x48, 0x31, 0xba, 0xe9, 0x49, 0x3d, 0xfc, - 0x24, 0xff, 0x17, 0xbd, 0xd5, 0x7f, 0xe7, 0x78, 0x5b, 0xc4, 0xff, 0xff, 0x31, 0x00, 0x4b, 0x9d, - 0x59, 0xc2, 0x56, 0x07, 0x00, 0x00, + 0x61, 0x0b, 0x0a, 0xd8, 0x4d, 0x93, 0x26, 0x80, 0x29, 0x03, 0xb1, 0x10, 0xc3, 0x30, 0xe8, 0x40, + 0x45, 0x1a, 0x62, 0x44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 0xd0, 0xce, 0x4e, 0xe2, + 0xdf, 0x32, 0x58, 0xfd, 0xcf, 0x4e, 0xb6, 0x79, 0xfc, 0xff, 0x1f, 0x03, 0x00, 0xe5, 0x41, 0xb4, + 0xc4, 0x82, 0x07, 0x00, 0x00, } func (m *ABCIResponses) Marshal() (dAtA []byte, err error) { @@ -663,6 +674,15 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.LastBlockBeacon) > 0 { + i -= len(m.LastBlockBeacon) + copy(dAtA[i:], m.LastBlockBeacon) + i = encodeVarintTypes(dAtA, i, uint64(len(m.LastBlockBeacon))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } if m.LastBlockRound != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.LastBlockRound)) i-- @@ -918,6 +938,10 @@ func (m *State) Size() (n int) { if m.LastBlockRound != 0 { n += 2 + sovTypes(uint64(m.LastBlockRound)) } + l = len(m.LastBlockBeacon) + if l > 0 { + n += 2 + l + sovTypes(uint64(l)) + } return n } @@ -1818,6 +1842,40 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastBlockBeacon", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastBlockBeacon = append(m.LastBlockBeacon[:0], dAtA[iNdEx:postIndex]...) + if m.LastBlockBeacon == nil { + m.LastBlockBeacon = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/state/types.proto b/proto/tendermint/state/types.proto index 10dd0a0315..2fd2b3bf59 100644 --- a/proto/tendermint/state/types.proto +++ b/proto/tendermint/state/types.proto @@ -72,4 +72,8 @@ message State { // last_block_round is the round number at which the last block was committed. int32 last_block_round = 16; + + // last_block_beacon is the random beacon carried by the commit of the last block, from consensus version 2. + // The next block's LastCommit must carry the same beacon. + bytes last_block_beacon = 17; } diff --git a/proto/tendermint/types/params.pb.go b/proto/tendermint/types/params.pb.go index 30e77c5387..fc74cd9613 100644 --- a/proto/tendermint/types/params.pb.go +++ b/proto/tendermint/types/params.pb.go @@ -34,16 +34,22 @@ const ( VersionParams_CONSENSUS_VERSION_0 VersionParams_ConsensusVersion = 0 // CONSENSUS_VERSION_1 changes proposer selection algorithm to not double-propose when previous proposer is offline. VersionParams_CONSENSUS_VERSION_1 VersionParams_ConsensusVersion = 1 + // CONSENSUS_VERSION_2 adds same-block randomness: the threshold signature recovered from a block's prevotes is + // the block's random beacon, the application applies it with ApplyBlockRandomness, and precommits sign the + // resulting app hash. Proposer selection is the same as in CONSENSUS_VERSION_1. + VersionParams_CONSENSUS_VERSION_2 VersionParams_ConsensusVersion = 2 ) var VersionParams_ConsensusVersion_name = map[int32]string{ 0: "CONSENSUS_VERSION_0", 1: "CONSENSUS_VERSION_1", + 2: "CONSENSUS_VERSION_2", } var VersionParams_ConsensusVersion_value = map[string]int32{ "CONSENSUS_VERSION_0": 0, "CONSENSUS_VERSION_1": 1, + "CONSENSUS_VERSION_2": 2, } func (x VersionParams_ConsensusVersion) String() string { @@ -696,60 +702,60 @@ func init() { func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) } var fileDescriptor_e12598271a686f57 = []byte{ - // 844 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0xc7, 0xb5, 0x11, 0x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, 0xde, 0xac, 0xbb, 0x00, - 0x8b, 0x17, 0x18, 0xde, 0x07, 0x48, 0xa9, 0x3f, 0xa6, 0xfe, 0x85, 0x9b, 0xcd, 0x64, 0xc5, 0xea, - 0x4e, 0x43, 0xed, 0x9c, 0xcf, 0xfa, 0xce, 0x6f, 0x97, 0x5d, 0xf4, 0xf2, 0xb2, 0x8b, 0x5e, 0x5d, - 0x76, 0xd1, 0x7f, 0x97, 0x5d, 0xf4, 0xf3, 0x55, 0xb7, 0xf2, 0xea, 0xaa, 0x5b, 0xf9, 0xfb, 0xaa, - 0x5b, 0xf9, 0xe6, 0xd3, 0x20, 0xcc, 0xc6, 0xb9, 0x67, 0xfb, 0x2c, 0xea, 0x8d, 0x08, 0x1f, 0x27, - 0xa4, 0xe8, 0x95, 0xc3, 0x23, 0x56, 0xe5, 0xf7, 0xad, 0xb7, 0xfa, 0xcd, 0xf4, 0x6a, 0x72, 0xff, - 0xf8, 0xff, 0x01, 0x00, 0xb2, 0xb1, 0x36, 0x07, 0x4e, 0x07, 0x00, 0x00, + // 848 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0xcf, 0x34, 0x6e, 0x9a, 0xbc, 0x34, 0x8d, 0x19, 0x16, 0xea, 0x5d, 0x68, 0x5a, 0x7c, 0x40, + 0x2b, 0xad, 0x64, 0x97, 0x96, 0xcb, 0x4a, 0xfc, 0xd1, 0xa6, 0xad, 0xf6, 0x0f, 0xda, 0xee, 0xca, + 0x29, 0x7b, 0x40, 0x5a, 0x59, 0x63, 0x67, 0x70, 0xac, 0xc6, 0x1e, 0xcb, 0x63, 0x87, 0xf8, 0x13, + 0x80, 0xc4, 0x85, 0x13, 0xe2, 0x23, 0xc0, 0x05, 0xf1, 0x31, 0xf6, 0xb8, 0x47, 0x4e, 0x80, 0xda, + 0x3b, 0x9f, 0x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+ 0x4e, 0x72, 0xef, 0x2b, 0x5a, 0x5c, 0x88, 0x10, 0xbe, 0x0f, 0xef, 0x4f, 0x58, 0x16, 0xc6, 0x81, + 0x9b, 0xb0, 0xef, 0x68, 0xea, 0x66, 0xa3, 0x94, 0xf2, 0x11, 0x1b, 0x0f, 0xe5, 0x49, 0xb5, 0x47, + 0x35, 0xe7, 0x56, 0x89, 0x3f, 0x17, 0xf0, 0x45, 0x85, 0xfe, 0x80, 0x50, 0xff, 0x36, 0xec, 0xba, + 0xab, 0xb5, 0xe6, 0xbf, 0x08, 0x3a, 0x0b, 0x3e, 0xc2, 0xfb, 0xd0, 0x26, 0x49, 0xe2, 0x56, 0xee, + 0x13, 0x1d, 0xd3, 0x1c, 0x20, 0x49, 0xa2, 0x68, 0xf8, 0x25, 0xbc, 0xe3, 0x57, 0x37, 0x6c, 0x46, + 0x13, 0x67, 0xd8, 0x39, 0x3a, 0x7c, 0x8b, 0x49, 0xad, 0xd9, 0xd5, 0x54, 0x61, 0x47, 0xf7, 0x97, + 0x22, 0xe6, 0x4b, 0xd0, 0x97, 0x59, 0x78, 0x17, 0xde, 0x3d, 0x79, 0x76, 0x3e, 0x38, 0x3b, 0x1f, + 0x7c, 0x3d, 0x70, 0x5f, 0x9c, 0x39, 0x83, 0xc7, 0xcf, 0xce, 0xdd, 0x43, 0xbd, 0xb6, 0x1a, 0xf8, + 0x44, 0x47, 0xab, 0x81, 0x23, 0x7d, 0xc3, 0xfc, 0x1e, 0xc1, 0xf6, 0x23, 0xc2, 0x47, 0x74, 0xa8, + 0xea, 0xfd, 0x18, 0xba, 0xd2, 0x1c, 0xee, 0xb2, 0xef, 0x3a, 0x32, 0xfc, 0xb4, 0x32, 0x9f, 0x09, + 0x9d, 0x39, 0x6f, 0x6e, 0xc1, 0x76, 0xc5, 0x7a, 0x48, 0x84, 0xe9, 0x56, 0xb4, 0x46, 0x18, 0x60, + 0x73, 0x45, 0xa1, 0x3f, 0x23, 0xe8, 0x2e, 0xdd,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0x66, 0xa3, 0xdc, 0xb3, 0x7c, 0x16, + 0xd9, 0x43, 0xc2, 0x47, 0x09, 0x29, 0xec, 0xf2, 0x56, 0x89, 0x55, 0xf9, 0xe1, 0xb3, 0x97, 0x3f, + 0xa6, 0x5e, 0x43, 0xc6, 0x8f, 0xff, 0x1b, 0x00, 0x93, 0x5b, 0xf7, 0x44, 0x67, 0x07, 0x00, 0x00, } func (this *ConsensusParams) Equal(that interface{}) bool { diff --git a/proto/tendermint/types/params.proto b/proto/tendermint/types/params.proto index ebfc8bf8a4..8f0133eaf5 100644 --- a/proto/tendermint/types/params.proto +++ b/proto/tendermint/types/params.proto @@ -92,6 +92,10 @@ message VersionParams { CONSENSUS_VERSION_0 = 0; // CONSENSUS_VERSION_1 changes proposer selection algorithm to not double-propose when previous proposer is offline. CONSENSUS_VERSION_1 = 1; + // CONSENSUS_VERSION_2 adds same-block randomness: the threshold signature recovered from a block's prevotes is + // the block's random beacon, the application applies it with ApplyBlockRandomness, and precommits sign the + // resulting app hash. Proposer selection is the same as in CONSENSUS_VERSION_1. + CONSENSUS_VERSION_2 = 2; } } diff --git a/types/block.go b/types/block.go index f1f60cc895..77d59f880e 100644 --- a/types/block.go +++ b/types/block.go @@ -1158,6 +1158,15 @@ func (blockID BlockID) Equals(other BlockID) bool { blockID.StateID.Equal(other.StateID) } +// SameBlock reports whether two BlockIDs name the same block: the same hash and part set header. +// The state IDs may differ. From consensus version 2, proposals and prevotes carry the state ID of +// the header, while precommits and the commit carry the state ID with the app hash returned by +// ApplyBlockRandomness, so a commit's BlockID and the BlockID derived from its block differ there. +func (blockID BlockID) SameBlock(other BlockID) bool { + return bytes.Equal(blockID.Hash, other.Hash) && + blockID.PartSetHeader.Equals(other.PartSetHeader) +} + // Key returns a machine-readable string representation of the BlockID func (blockID BlockID) Key() string { pbph := blockID.PartSetHeader.ToProto() diff --git a/types/light.go b/types/light.go index ab67f31144..9762430934 100644 --- a/types/light.go +++ b/types/light.go @@ -57,11 +57,10 @@ func (lb LightBlock) ValidateBasic(chainID string) error { return fmt.Errorf("invalid validator public-key shares: %w", err) } } - // Validate StateID height - stateID := lb.StateID().Hash() - - if !lb.Commit.BlockID.StateID.Equal(stateID) { - return fmt.Errorf("invalid commit state id hash %X != %X for light block", lb.Commit.BlockID.StateID, stateID) + // The commit's state ID must describe the header. From consensus version 2 it + // carries the app hash the commit signs (Commit.AppHash) instead of the header's. + if _, err := lb.Commit.VerifyAppHash(lb.Header); err != nil { + return fmt.Errorf("invalid commit state id for light block: %w", err) } // make sure the validator set is consistent with the header diff --git a/types/params.go b/types/params.go index 4b411be6ad..4ea6ae5c15 100644 --- a/types/params.go +++ b/types/params.go @@ -77,6 +77,13 @@ type VersionParams struct { ConsensusVersion int32 `json:"consensus,string"` } +// RandomBeacon reports whether same-block randomness is on (consensus version 2 and later): the +// threshold signature recovered from a block's prevotes is its random beacon, the application applies +// it with ApplyBlockRandomness, and precommits and the commit sign the app hash it returns. +func (params VersionParams) RandomBeacon() bool { + return params.ConsensusVersion >= int32(tmproto.VersionParams_CONSENSUS_VERSION_2) +} + // SynchronyParams influence the validity of block timestamps. // For more information on the relationship of the synchrony parameters to // block validity, see the Proposer-Based Timestamps specification: @@ -353,6 +360,10 @@ func (params ConsensusParams) ValidateConsensusParams() error { return errors.New("len(Validator.PubKeyTypes) must be greater than 0") } + if _, ok := tmproto.VersionParams_ConsensusVersion_name[params.Version.ConsensusVersion]; !ok { + return fmt.Errorf("version.ConsensusVersion %d is unknown", params.Version.ConsensusVersion) + } + // Check if keyType is a known ABCIPubKeyType for i := 0; i < len(params.Validator.PubKeyTypes); i++ { keyType := params.Validator.PubKeyTypes[i] diff --git a/types/random_beacon.go b/types/random_beacon.go new file mode 100644 index 0000000000..ae911343c5 --- /dev/null +++ b/types/random_beacon.go @@ -0,0 +1,138 @@ +package types + +import ( + "bytes" + "errors" + "fmt" + + "github.com/dashpay/dashd-go/btcjson" + + "github.com/dashpay/tenderdash/crypto" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" +) + +// ErrInvalidCommitBeacon is returned when the random beacon or the app hash a commit carries from +// consensus version 2 does not match the block it commits. +var ErrInvalidCommitBeacon = errors.New("invalid commit random beacon") + +// RandomBeaconSignItem returns the sign item of a prevote for blockID at height and round. Every such +// prevote signs these bytes, and the random beacon of the block and round is the threshold signature +// recovered from those prevotes, so it verifies against this item and the quorum's threshold public key. +// +// blockID must carry the state ID derived from the block's header, as prevotes do. +func RandomBeaconSignItem( + chainID string, + quorumType btcjson.LLMQType, + quorumHash crypto.QuorumHash, + height int64, + round int32, + blockID BlockID, +) SignItem { + prevote := tmproto.Vote{ + Type: tmproto.PrevoteType, + Height: height, + Round: round, + BlockID: blockID.ToProto(), + } + return MakeBlockSignItem(chainID, &prevote, quorumType, quorumHash) +} + +// StateIDWithAppHash returns the header's StateID with its app hash replaced by appHash. From +// consensus version 2, precommits and the commit sign the hash of this state ID with the app hash +// returned by ApplyBlockRandomness. +func (h *Header) StateIDWithAppHash(appHash []byte) tmproto.StateID { + stateID := h.StateID() + stateID.AppHash = bytes.Clone(appHash) + return stateID +} + +// VerifyAppHash returns the app hash that commit's state ID commits to for header, the header of the +// block commit commits: commit.AppHash when the commit carries one, otherwise header.AppHash. It fails +// unless commit.BlockID.StateID is the hash of header's StateID with that app hash. +// +// The threshold signature of a commit covers commit.BlockID.StateID, so once it is verified, the +// returned app hash is the one the validators signed, whatever consensus version the block used. +func (commit *Commit) VerifyAppHash(header *Header) (tmbytes.HexBytes, error) { + if commit == nil || header == nil { + return nil, errors.New("nil commit or header") + } + if len(commit.AppHash) == 0 { + if !bytes.Equal(header.StateID().Hash(), commit.BlockID.StateID) { + return nil, fmt.Errorf("commit state ID %X does not match the header's state ID", commit.BlockID.StateID) + } + return header.AppHash, nil + } + if len(commit.AppHash) != crypto.DefaultAppHashSize { + return nil, fmt.Errorf("%w: app hash size is %d, expected %d", + ErrInvalidCommitBeacon, len(commit.AppHash), crypto.DefaultAppHashSize) + } + stateID := header.StateIDWithAppHash(commit.AppHash) + if !bytes.Equal(stateID.Hash(), commit.BlockID.StateID) { + return nil, fmt.Errorf("%w: commit state ID %X is not the state ID of the header with app hash %X", + ErrInvalidCommitBeacon, commit.BlockID.StateID, commit.AppHash) + } + return commit.AppHash, nil +} + +// CommittedAppHash returns the app hash the signed header's commit signs: from consensus version 2 the +// one after the block's randomness is applied (Commit.AppHash), otherwise the header's. Proofs of the +// application state at this height verify against it. See Commit.VerifyAppHash. +func (sh SignedHeader) CommittedAppHash() (tmbytes.HexBytes, error) { + return sh.Commit.VerifyAppHash(sh.Header) +} + +// VerifyRandomBeacon checks, for a block at consensus version 2 or later, the random beacon and the +// app hash that commit carries against header, the header of the block it commits, and vals, the +// validator set that voted for it: +// +// - the beacon is the threshold signature of vals over the prevote sign item rebuilt from header +// and the commit round (see RandomBeaconSignItem); +// - commit.BlockID.StateID is the hash of header's StateID with commit.AppHash. +// +// It does not verify the commit's own threshold signature; see ValidatorSet.VerifyCommit. +func (commit *Commit) VerifyRandomBeacon(chainID string, vals *ValidatorSet, header *Header) error { + if commit == nil || header == nil || vals == nil { + return fmt.Errorf("%w: nil commit, header or validator set", ErrInvalidCommitBeacon) + } + if len(commit.Beacon) != SignatureSize { + return fmt.Errorf("%w: beacon size is %d, expected %d", ErrInvalidCommitBeacon, len(commit.Beacon), SignatureSize) + } + if len(commit.AppHash) == 0 { + return fmt.Errorf("%w: missing app hash", ErrInvalidCommitBeacon) + } + if header.Height != commit.Height { + return fmt.Errorf("%w: header height %d, commit height %d", ErrInvalidCommitBeacon, header.Height, commit.Height) + } + if !bytes.Equal(header.Hash(), commit.BlockID.Hash) { + return fmt.Errorf("%w: header hash %X does not match commit block hash %X", + ErrInvalidCommitBeacon, header.Hash(), commit.BlockID.Hash) + } + if _, err := commit.VerifyAppHash(header); err != nil { + return err + } + prevoteBlockID := BlockID{ + Hash: commit.BlockID.Hash, + PartSetHeader: commit.BlockID.PartSetHeader, + StateID: header.StateID().Hash(), + } + signItem := RandomBeaconSignItem(chainID, vals.QuorumType, vals.QuorumHash, commit.Height, commit.Round, prevoteBlockID) + if vals.ThresholdPublicKey == nil || !signItem.VerifySignature(vals.ThresholdPublicKey, commit.Beacon) { + return fmt.Errorf("%w: beacon does not verify against the quorum's threshold public key", ErrInvalidCommitBeacon) + } + return nil +} + +// WithoutRandomBeacon returns commit without its random beacon and app hash. Before consensus version 2 +// both fields must be empty, but neither is covered by the commit's threshold signature, so a peer could +// fill them; nodes drop them from commits of such heights instead of storing or passing them on. It +// returns commit itself when both are already empty. +func (commit *Commit) WithoutRandomBeacon() *Commit { + if commit == nil || (len(commit.Beacon) == 0 && len(commit.AppHash) == 0) { + return commit + } + stripped := *commit + stripped.Beacon = nil + stripped.AppHash = nil + return &stripped +} diff --git a/types/random_beacon_test.go b/types/random_beacon_test.go new file mode 100644 index 0000000000..41c4041bce --- /dev/null +++ b/types/random_beacon_test.go @@ -0,0 +1,252 @@ +package types + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/dashpay/tenderdash/crypto" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" +) + +// randomBeaconFixture holds a block header, the BlockID its prevotes carry, and a prevote vote set +// over a validator set whose majority gate is below the voting power BLS recovery needs. +type randomBeaconFixture struct { + header Header + blockID BlockID + valSet *ValidatorSet + privVals []PrivValidator +} + +const randomBeaconTestRound = int32(2) + +func newRandomBeaconFixture(t *testing.T) randomBeaconFixture { + t.Helper() + valSet, privVals := RandValidatorSet(10) + // A majority gate of two validators, far below the seven the recovery needs. + valSet.VotingPowerThreshold = uint64(2 * DefaultDashVotingPower) + require.Less(t, valSet.QuorumVotingThresholdPower(), valSet.QuorumTypeThresholdVotingPower()) + + header := MakeRandHeader() + header.ChainID = "test_chain_id" + header.Height = 5 + header.ValidatorsHash = valSet.Hash() + blockID := BlockID{ + Hash: header.Hash(), + PartSetHeader: PartSetHeader{Total: 3, Hash: crypto.Checksum([]byte("parts"))}, + StateID: header.StateID().Hash(), + } + return randomBeaconFixture{header: header, blockID: blockID, valSet: valSet, privVals: privVals} +} + +// addPrevotes signs prevotes for the fixture's block from validators [from, to) into voteSet. +func (f randomBeaconFixture) addPrevotes(ctx context.Context, t *testing.T, voteSet *VoteSet, from, to int) { + t.Helper() + for i := from; i < to; i++ { + proTxHash, err := f.privVals[i].GetProTxHash(ctx) + require.NoError(t, err) + vote := &Vote{ + ValidatorProTxHash: proTxHash, + ValidatorIndex: int32(i), + Height: f.header.Height, + Round: randomBeaconTestRound, + Type: tmproto.PrevoteType, + BlockID: f.blockID, + } + added, err := signAddVote(ctx, f.privVals[i], vote, voteSet) + require.NoError(t, err) + require.True(t, added) + } +} + +// recoverBeacon returns the random beacon recovered from the prevotes of every validator. +func (f randomBeaconFixture) recoverBeacon(ctx context.Context, t *testing.T) []byte { + t.Helper() + voteSet := NewVoteSet(f.header.ChainID, f.header.Height, randomBeaconTestRound, tmproto.PrevoteType, f.valSet, + WithRandomBeacon(true)) + f.addPrevotes(ctx, t, voteSet, 0, len(f.privVals)) + beacon := voteSet.ThresholdBlockSignature() + require.Len(t, beacon, SignatureSize) + return beacon +} + +// TestVoteSetRandomBeaconPrevoteMajority checks that, with WithRandomBeacon, a prevote majority counts only +// once its threshold signature is recovered, even when the majority gate is lower, and that the recovered +// signature verifies as the random beacon of the block and round. +func TestVoteSetRandomBeaconPrevoteMajority(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + f := newRandomBeaconFixture(t) + threshold := int(f.valSet.QuorumTypeThresholdVotingPower() / DefaultDashVotingPower) + + t.Run("without random beacon, the gate alone forms the majority", func(t *testing.T) { + voteSet := NewVoteSet(f.header.ChainID, f.header.Height, randomBeaconTestRound, tmproto.PrevoteType, f.valSet) + f.addPrevotes(ctx, t, voteSet, 0, 2) + blockID, ok := voteSet.TwoThirdsMajority() + require.True(t, ok) + require.True(t, blockID.Equals(f.blockID)) + require.Nil(t, voteSet.ThresholdBlockSignature(), "prevotes are not recovered") + }) + + t.Run("with random beacon, the majority waits for recovery", func(t *testing.T) { + voteSet := NewVoteSet(f.header.ChainID, f.header.Height, randomBeaconTestRound, tmproto.PrevoteType, f.valSet, + WithRandomBeacon(true)) + f.addPrevotes(ctx, t, voteSet, 0, threshold-1) + _, ok := voteSet.TwoThirdsMajority() + require.False(t, ok, "the gate is reached, but the beacon cannot be recovered yet") + require.Nil(t, voteSet.ThresholdBlockSignature()) + + f.addPrevotes(ctx, t, voteSet, threshold-1, threshold) + blockID, ok := voteSet.TwoThirdsMajority() + require.True(t, ok) + require.True(t, blockID.Equals(f.blockID)) + beacon := voteSet.ThresholdBlockSignature() + require.Len(t, beacon, SignatureSize) + + signItem := RandomBeaconSignItem(f.header.ChainID, f.valSet.QuorumType, f.valSet.QuorumHash, + f.header.Height, randomBeaconTestRound, f.blockID) + require.True(t, signItem.VerifySignature(f.valSet.ThresholdPublicKey, beacon)) + + // Any other set of threshold shares recovers the same beacon. + others := NewVoteSet(f.header.ChainID, f.header.Height, randomBeaconTestRound, tmproto.PrevoteType, f.valSet, + WithRandomBeacon(true)) + f.addPrevotes(ctx, t, others, len(f.privVals)-threshold, len(f.privVals)) + require.Equal(t, beacon, others.ThresholdBlockSignature()) + }) +} + +// TestCommitVerifyRandomBeacon checks the commit fields of consensus version 2 against the block header. +func TestCommitVerifyRandomBeacon(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + f := newRandomBeaconFixture(t) + beacon := f.recoverBeacon(ctx, t) + finalAppHash := crypto.Checksum(append(f.header.AppHash.Copy(), beacon...)) + + makeCommit := func() *Commit { + return &Commit{ + Height: f.header.Height, + Round: randomBeaconTestRound, + BlockID: BlockID{ + Hash: f.blockID.Hash, + PartSetHeader: f.blockID.PartSetHeader, + StateID: f.header.StateIDWithAppHash(finalAppHash).Hash(), + }, + QuorumHash: f.valSet.QuorumHash, + ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: beacon, + AppHash: finalAppHash, + } + } + + commit := makeCommit() + require.NoError(t, commit.VerifyRandomBeacon(f.header.ChainID, f.valSet, &f.header)) + appHash, err := commit.VerifyAppHash(&f.header) + require.NoError(t, err) + require.EqualValues(t, finalAppHash, appHash) + assert.True(t, commit.BlockID.SameBlock(f.blockID)) + assert.False(t, commit.BlockID.Equals(f.blockID), "the commit signs another state ID than the prevotes") + + testCases := map[string]func(c *Commit){ + "app hash not the one signed": func(c *Commit) { c.AppHash = f.header.AppHash.Copy() }, + "missing app hash": func(c *Commit) { c.AppHash = nil }, + "missing beacon": func(c *Commit) { c.Beacon = nil }, + "beacon of another signature": func(c *Commit) { c.Beacon = c.ThresholdBlockSignature }, + "beacon of another round": func(c *Commit) { c.Round++ }, + "commit of another block hash": func(c *Commit) { c.BlockID.Hash = crypto.Checksum([]byte("other")) }, + } + for name, mutate := range testCases { + t.Run(name, func(t *testing.T) { + c := makeCommit() + mutate(c) + require.ErrorIs(t, c.VerifyRandomBeacon(f.header.ChainID, f.valSet, &f.header), ErrInvalidCommitBeacon) + }) + } + + t.Run("before consensus version 2 the header app hash is signed", func(t *testing.T) { + c := makeCommit() + c.BlockID.StateID = f.header.StateID().Hash() + c.AppHash = nil + appHash, err := c.VerifyAppHash(&f.header) + require.NoError(t, err) + require.EqualValues(t, f.header.AppHash, appHash) + + c.BlockID.StateID = RandStateID().Hash() + _, err = c.VerifyAppHash(&f.header) + require.Error(t, err) + }) + + t.Run("without random beacon fields", func(t *testing.T) { + c := makeCommit() + stripped := c.WithoutRandomBeacon() + require.Nil(t, stripped.Beacon) + require.Nil(t, stripped.AppHash) + require.NotNil(t, c.Beacon, "the original commit is not changed") + require.Same(t, stripped, stripped.WithoutRandomBeacon()) + }) +} + +// TestLightBlockRandomBeacon checks that a light block whose commit signs the app hash after the block's +// randomness validates, and that proofs are verified against that app hash. +func TestLightBlockRandomBeacon(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + f := newRandomBeaconFixture(t) + beacon := f.recoverBeacon(ctx, t) + finalAppHash := crypto.Checksum(append(f.header.AppHash.Copy(), beacon...)) + commit := &Commit{ + Height: f.header.Height, + Round: randomBeaconTestRound, + BlockID: BlockID{ + Hash: f.blockID.Hash, + PartSetHeader: f.blockID.PartSetHeader, + StateID: f.header.StateIDWithAppHash(finalAppHash).Hash(), + }, + QuorumHash: f.valSet.QuorumHash, + ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: beacon, + AppHash: finalAppHash, + } + lightBlock := LightBlock{ + SignedHeader: &SignedHeader{Header: &f.header, Commit: commit}, + ValidatorSet: f.valSet, + } + require.NoError(t, lightBlock.ValidateBasic(f.header.ChainID)) + appHash, err := lightBlock.CommittedAppHash() + require.NoError(t, err) + require.EqualValues(t, finalAppHash, appHash) + + // The header's app hash is not the one the commit signs. + commit.AppHash = f.header.AppHash.Copy() + require.Error(t, lightBlock.ValidateBasic(f.header.ChainID)) +} + +func TestBlockIDSameBlock(t *testing.T) { + blockID := makeBlockIDRandom() + other := blockID.Copy() + other.StateID = RandStateID().Hash() + assert.True(t, blockID.SameBlock(other)) + assert.False(t, blockID.Equals(other)) + + other.PartSetHeader.Total++ + assert.False(t, blockID.SameBlock(other)) + other = blockID.Copy() + other.Hash = crypto.Checksum([]byte("other")) + assert.False(t, blockID.SameBlock(other)) +} + +func TestConsensusParamsConsensusVersion(t *testing.T) { + for version, valid := range map[int32]bool{0: true, 1: true, 2: true, 3: false, -1: false} { + params := DefaultConsensusParams() + params.Version.ConsensusVersion = version + err := params.ValidateConsensusParams() + if valid { + assert.NoError(t, err, "version %d", version) + } else { + assert.Error(t, err, "version %d", version) + } + assert.Equal(t, version >= 2, params.Version.RandomBeacon(), "version %d", version) + } +} diff --git a/types/vote_set.go b/types/vote_set.go index 5518330144..1d6f99754a 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -87,6 +87,10 @@ type VoteSet struct { // dash fields thresholdBlockSig []byte // If a 2/3 majority is seen, recover the block sig thresholdVoteExtSigs VoteExtensions // If a 2/3 majority is seen, recover the vote extension sigs + + // randomBeacon makes a prevote majority for a block count only once its threshold signature, + // the block's random beacon for the round, is recovered (consensus version 2). + randomBeacon bool } type maj23Info struct { @@ -108,6 +112,19 @@ func WithLogger(logger log.Logger) VoteSetOption { } } +// WithRandomBeacon makes a prevote VoteSet recover the threshold signature of a +2/3 majority for a +// block, as precommit VoteSets do, and count the majority only once that succeeds. The recovered +// signature is the block's random beacon for the round (consensus version 2); see +// ThresholdBlockSignature. It has no effect on other vote types. +// +// The majority gate (QuorumVotingThresholdPower) can be below the voting power the recovery needs +// (QuorumTypeThresholdVotingPower), so without this a polka could form before the beacon exists. +func WithRandomBeacon(enabled bool) VoteSetOption { + return func(voteSet *VoteSet) { + voteSet.randomBeacon = enabled + } +} + // NewVoteSet instantiates all fields of a new vote set. This constructor requires // that no vote extension data be present on the votes that are added to the set. func NewVoteSet(chainID string, height int64, round int32, @@ -433,7 +450,7 @@ func (voteSet *VoteSet) addVerifiedVote( // is actually finalized (the whole method runs under voteSet.mtx). maj23BlockID := vote.BlockID voteSet.maj23 = &maj23BlockID - if voteSet.signedMsgType == tmproto.PrecommitType { + if voteSet.recoversThresholdSigns(vote) { if err := voteSet.recoverThresholdSignsAndVerify(votesByBlock); err != nil { // Keep the vote and retry when a complete extension group crosses the // recovery threshold; remote input must not turn failure into a panic. @@ -467,6 +484,20 @@ func (voteSet *VoteSet) addVerifiedVote( return true, conflicting } +// recoversThresholdSigns reports whether a +2/3 majority for vote's block counts only once its +// threshold signatures are recovered: always for precommits, and for prevotes for a block (not nil) +// with WithRandomBeacon. +func (voteSet *VoteSet) recoversThresholdSigns(vote *Vote) bool { + switch voteSet.signedMsgType { + case tmproto.PrecommitType: + return true + case tmproto.PrevoteType: + return voteSet.randomBeacon && !vote.BlockID.IsNil() + default: + return false + } +} + // recoverThresholdSignsAndVerify recovers threshold signatures and verifies them. // precondition: quorum reached func (voteSet *VoteSet) recoverThresholdSignsAndVerify(blockVotes *blockVotes) error { @@ -728,6 +759,21 @@ func (voteSet *VoteSet) IsCommit() bool { return voteSet.maj23 != nil } +// ThresholdBlockSignature returns a copy of the threshold block signature recovered from the votes +// of the +2/3 majority, or nil when there is none. For a prevote VoteSet created WithRandomBeacon, it +// is the random beacon of the majority block for this round. +func (voteSet *VoteSet) ThresholdBlockSignature() []byte { + if voteSet == nil { + return nil + } + voteSet.mtx.Lock() + defer voteSet.mtx.Unlock() + if voteSet.maj23 == nil { + return nil + } + return bytes.Clone(voteSet.thresholdBlockSig) +} + // IsQuorumReached returns true if quorum was reached otherwise returns false. // // WARNING: this reads maj23 WITHOUT holding voteSet.mtx. It is intentionally From 33ac41a303b1820b414bca7c4ea32a8ce98f5446 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 02:15:43 +0700 Subject: [PATCH 03/25] test(consensus): cover re-voted blocks, non-voting nodes and e2e activation of the random beacon - A block locked in round 0 and voted again in round 1 gets the round 1 beacon: the round 1 precommit signs another final state ID, and the block commits at round 1 with that beacon. - The final state ID a validator signs is cached per block and round: a second precommit does not ask the application again, even if it would answer differently. - A node outside the validator set finalizes every block from peers' commits at consensus version 2 and reaches the validators' beacon and final app hash. - The rotate e2e network activates consensus version 2 at height 1010, so state sync, block sync and restarts run with it before the network moves back to versions 1 and 0. TestApp_Hash and TestBlock_Header compare with the app hash the commit signs instead of the header's. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- internal/consensus/random_beacon_test.go | 204 +++++++++++++++++++++++ test/e2e/networks/rotate.toml | 3 + test/e2e/tests/app_test.go | 10 +- test/e2e/tests/block_test.go | 7 +- 4 files changed, 219 insertions(+), 5 deletions(-) diff --git a/internal/consensus/random_beacon_test.go b/internal/consensus/random_beacon_test.go index 660c84a964..199299e089 100644 --- a/internal/consensus/random_beacon_test.go +++ b/internal/consensus/random_beacon_test.go @@ -13,9 +13,11 @@ import ( "github.com/dashpay/tenderdash/abci/example/kvstore" abci "github.com/dashpay/tenderdash/abci/types" "github.com/dashpay/tenderdash/crypto" + cstypes "github.com/dashpay/tenderdash/internal/consensus/types" sm "github.com/dashpay/tenderdash/internal/state" sf "github.com/dashpay/tenderdash/internal/state/test/factory" "github.com/dashpay/tenderdash/internal/test/factory" + tmbytes "github.com/dashpay/tenderdash/libs/bytes" dbm "github.com/dashpay/tenderdash/libs/db" "github.com/dashpay/tenderdash/libs/log" tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" @@ -252,3 +254,205 @@ func TestReplayBlockRandomBeacon(t *testing.T) { require.ErrorIs(t, err, sm.ErrAppHashMismatch) require.Equal(t, []string{"process", "randomness"}, app.calls) } + +// TestRandomBeaconRelockNewBeacon checks that a block locked in round 0 and voted again in round 1 at +// consensus version 2 gets the beacon of round 1: the validator's round 1 precommit signs another final +// state ID than its round 0 precommit, and the block commits at round 1 with the round 1 beacon. +func TestRandomBeaconRelockNewBeacon(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + config := configSetup(t) + + params := factory.ConsensusParams(func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + }) + cs1, vss := makeState(ctx, t, makeStateArgs{config: config, consensusParams: params}) + vs2, vs3, vs4 := vss[1], vss[2], vss[3] + stateData := cs1.GetStateData() + height, round := stateData.Height, stateData.Round + + timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait) + proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) + proTxHash, err := cs1.privValidator.GetProTxHash(ctx) + require.NoError(t, err) + voteCh := subscribeToVoter(ctx, t, cs1, proTxHash) + newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound) + ownVote := func(voteType tmproto.SignedMsgType) *types.Vote { + t.Helper() + vote := ensureMessageBeforeTimeout(t, voteCh, ensureTimeout).Data().(types.EventDataVote).Vote + require.Equal(t, voteType, vote.Type) + return vote + } + + // Round 0: lock on the block, then everyone else precommits nil. + startTestRound(ctx, cs1, height, round) + ensureNewRound(t, newRoundCh, height, round) + ensureNewProposal(t, proposalCh, height, round) + stateData = cs1.GetStateData() + blockID := stateData.BlockID() + theBlock := stateData.ProposalBlock + theBlockParts := stateData.ProposalBlockParts + ownVote(tmproto.PrevoteType) + signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4) + precommitR0 := ownVote(tmproto.PrecommitType) + require.True(t, precommitR0.BlockID.SameBlock(blockID)) + require.False(t, precommitR0.BlockID.Equals(blockID)) + signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4) + ensureNewTimeout(t, timeoutWaitCh, height, round, stateData.voteTimeout(round).Nanoseconds()) + + // Round 1: the same block is proposed again and prevoted again. + incrementRound(vs2, vs3, vs4) + round++ + propR1 := types.NewProposal(height, 1, round, 0, blockID, theBlock.Time) + p := propR1.ToProto() + _, valSet := cs1.GetValidatorSet() + _, err = vs2.SignProposal(ctx, stateData.state.ChainID, valSet.QuorumType, valSet.QuorumHash, p) + require.NoError(t, err) + propR1.Signature = p.Signature + require.NoError(t, cs1.SetProposalAndBlock(ctx, propR1, theBlockParts, "")) + ensureNewRound(t, newRoundCh, height, round) + ensureNewProposal(t, proposalCh, height, round) + ownVote(tmproto.PrevoteType) + signAddVotes(ctx, t, cs1, tmproto.PrevoteType, config.ChainID(), blockID, vs2, vs3, vs4) + precommitR1 := ownVote(tmproto.PrecommitType) + require.True(t, precommitR1.BlockID.SameBlock(blockID)) + require.False(t, precommitR1.BlockID.Equals(precommitR0.BlockID), + "round 1 has another beacon, so another final app hash") + + // Everyone precommits the round 1 final state: the block commits at round 1. + signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), precommitR1.BlockID, vs2, vs3, vs4) + ensureNewRound(t, newRoundCh, height+1, 0) + + commit := cs1.blockStore.LoadSeenCommit() + require.NotNil(t, commit) + require.Equal(t, round, commit.Round) + require.True(t, commit.BlockID.Equals(precommitR1.BlockID)) + require.NoError(t, commit.VerifyRandomBeacon(stateData.state.ChainID, valSet, &theBlock.Header)) + require.EqualValues(t, crypto.Checksum(append(theBlock.AppHash.Copy(), commit.Beacon...)), commit.AppHash) +} + +// countingRandomness answers ApplyBlockRandomness with appHash and counts the calls. +type countingRandomness struct { + appHash []byte + calls int +} + +func (r *countingRandomness) ApplyBlockRandomness(_ context.Context, _ *types.Block, _ int32, _ []byte) (tmbytes.HexBytes, error) { + r.calls++ + return r.appHash, nil +} + +// TestVoteSignerFinalStateIDCached checks that a validator signs a single final state ID per block and +// round: once computed, it is returned without asking the application again, even if the application +// would now answer differently. Signing two would be duplicate-vote evidence. +func TestVoteSignerFinalStateIDCached(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + const chainID = "test-chain" + const height, round = int64(3), int32(1) + valSet, privVals := types.RandValidatorSet(4) + block := types.MakeBlock(height, nil, &types.Commit{}, nil) + block.ChainID = chainID + block.ValidatorsHash = valSet.Hash() + block.AppHash = crypto.Checksum([]byte("header app hash")) + blockID := block.BlockID(nil) + + votes := cstypes.NewHeightVoteSet(chainID, height, valSet, cstypes.WithRandomBeacon(true)) + votes.SetRound(round) + for i, privVal := range privVals { + proTxHash, err := privVal.GetProTxHash(ctx) + require.NoError(t, err) + vote := &types.Vote{ValidatorProTxHash: proTxHash, ValidatorIndex: int32(i), Height: height, Round: round, + Type: tmproto.PrevoteType, BlockID: blockID} + protoVote := vote.ToProto() + require.NoError(t, privVal.SignVote(ctx, chainID, valSet.QuorumType, valSet.QuorumHash, protoVote, nil)) + require.NoError(t, vote.PopulateSignsFromProto(protoVote)) + _, err = votes.AddVote(vote) + require.NoError(t, err) + } + require.NotEmpty(t, votes.Prevotes(round).ThresholdBlockSignature()) + + stateData := &StateData{RoundState: cstypes.RoundState{ + Height: height, Round: round, ProposalBlock: block, Votes: votes, + }} + randomness := &countingRandomness{appHash: crypto.Checksum([]byte("final app hash"))} + signer := &voteSigner{logger: log.NewNopLogger(), randomness: randomness} + + first, err := signer.finalStateID(ctx, stateData, blockID) + require.NoError(t, err) + require.EqualValues(t, block.StateIDWithAppHash(randomness.appHash).Hash(), first) + require.Equal(t, 1, randomness.calls) + + randomness.appHash = crypto.Checksum([]byte("another final app hash")) + again, err := signer.finalStateID(ctx, stateData, blockID) + require.NoError(t, err) + require.Equal(t, first, again, "the state ID signed first is signed again") + require.Equal(t, 1, randomness.calls, "the application is not asked again") +} + +// TestReactorRandomBeaconNonValidator runs four validators and a node outside the validator set at +// consensus version 2. That node never votes and receives no votes: it finalizes every block from a +// peer's commit, checking the commit's beacon and applying it with ApplyBlockRandomness itself, and must +// reach the same final app hash and state as the validators. +func TestReactorRandomBeaconNonValidator(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + const nVals, nPeers = 4, 5 + gen := consensusNetGen{ + cfg: configSetup(t), + nPeers: nPeers, + nVals: nVals, + appFunc: newKVStoreFunc(t), + tickerFun: newTickerFunc(), + consensusParams: factory.ConsensusParams(func(cp *types.ConsensusParams) { + cp.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + cp.Timeout.Propose = 2 * time.Second + }), + } + states, _, _, _ := gen.generate(ctx, t) + rts := setup(ctx, t, nPeers, states, 100) + rts.switchToConsensus(ctx) + + var observer *State + for _, state := range states { + stateData := state.GetStateData() + if !stateData.Validators.HasProTxHash(state.privValidator.ProTxHash) { + observer = state + } + } + require.NotNil(t, observer, "one node is outside the validator set") + + const lastHeight = int64(3) + require.Eventually(t, func() bool { + for _, state := range states { + if state.blockStore.Height() < lastHeight { + return false + } + } + return true + }, 45*time.Second, 50*time.Millisecond, "every node commits %d blocks", lastHeight) + + for height := int64(1); height < lastHeight; height++ { + block := observer.blockStore.LoadBlock(height) + commit := observer.blockStore.LoadBlockCommit(height) + require.NotNil(t, block) + require.NotNil(t, commit) + stateData := observer.GetStateData() + require.NoError(t, commit.VerifyRandomBeacon(stateData.state.ChainID, stateData.Validators, &block.Header)) + for _, state := range states { + other := state.blockStore.LoadBlockCommit(height) + require.Equal(t, commit.Beacon, other.Beacon, "height %d", height) + require.EqualValues(t, commit.AppHash, other.AppHash, "height %d", height) + } + } + // The observer's own state follows the commits it finalized. + stateData := observer.GetStateData() + last := observer.blockStore.LoadSeenCommit() + require.NotNil(t, last) + if last.Height == stateData.state.LastBlockHeight { + require.EqualValues(t, last.AppHash, stateData.state.LastAppHash) + require.True(t, last.BlockID.Equals(stateData.state.LastBlockID)) + } +} diff --git a/test/e2e/networks/rotate.toml b/test/e2e/networks/rotate.toml index 30f6943097..fe98da02ad 100644 --- a/test/e2e/networks/rotate.toml +++ b/test/e2e/networks/rotate.toml @@ -98,6 +98,9 @@ validator11 = 100 [consensus_version_updates] +# Same-block randomness from 1011: nodes state sync, block sync and restart at consensus version 2, +# then the network moves back to versions 1 and 0. +1010 = 2 1070 = 1 1076 = 0 1079 = 1 diff --git a/test/e2e/tests/app_test.go b/test/e2e/tests/app_test.go index 5287da03db..cb7d316e56 100644 --- a/test/e2e/tests/app_test.go +++ b/test/e2e/tests/app_test.go @@ -134,10 +134,16 @@ func TestApp_Hash(t *testing.T) { block, err := client.Block(ctx, &blockHeight) require.NoError(t, err) require.Equal(t, blockHeight, block.Block.Height) + // The app hash the block's commit signs: the header's, or from consensus version 2 + // the one after the block's randomness is applied. + commit, err := client.Commit(ctx, &blockHeight) + require.NoError(t, err) + committedAppHash, err := commit.CommittedAppHash() + require.NoError(t, err) require.EqualValues(t, info.Response.LastBlockAppHash, - block.Block.AppHash.Bytes(), - "app hash does not match last block's app hash at height %d", blockHeight) + committedAppHash.Bytes(), + "app hash does not match the app hash committed at height %d", blockHeight) }) } diff --git a/test/e2e/tests/block_test.go b/test/e2e/tests/block_test.go index 84d133c43d..a201be3f7d 100644 --- a/test/e2e/tests/block_test.go +++ b/test/e2e/tests/block_test.go @@ -51,10 +51,11 @@ func TestBlock_Header(t *testing.T) { require.NoError(t, resp.Block.ValidateBasic(), "block at height %d is invalid", block.Header.Height) - // validate StateID from last commit + // validate StateID from last commit: the previous header's, with the app hash + // the commit carries from consensus version 2 (after the block's randomness) if prevBlock != nil { - stateID := prevBlock.Header.StateID() - assert.EqualValues(t, stateID.Hash(), block.LastCommit.BlockID.StateID) + _, err := block.LastCommit.VerifyAppHash(&prevBlock.Header) + assert.NoError(t, err, "last commit state ID of block at height %d", block.Height) } prevBlock = resp.Block From 61934c68696a43ace6ded7980b5292a974cd4a1d Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 03:25:06 +0700 Subject: [PATCH 04/25] test(consensus): fix a data race in the re-vote beacon test TestRandomBeaconRelockNewBeacon copied the validator set with GetValidatorSet while the consensus goroutine was entering round 1, which moves the set's proposer index in place. Copy the set before consensus starts: the test only reads its quorum type, hash and threshold key, which do not change within the height. Co-Authored-By: Claude Opus 5.5 --- internal/consensus/random_beacon_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/consensus/random_beacon_test.go b/internal/consensus/random_beacon_test.go index 199299e089..f091df3c57 100644 --- a/internal/consensus/random_beacon_test.go +++ b/internal/consensus/random_beacon_test.go @@ -270,6 +270,9 @@ func TestRandomBeaconRelockNewBeacon(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] stateData := cs1.GetStateData() height, round := stateData.Height, stateData.Round + // Copied before consensus starts: the consensus goroutine moves the set's proposer index in place + // on every round change, so copying it later races with that write. + _, valSet := cs1.GetValidatorSet() timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait) proposalCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryCompleteProposal) @@ -305,7 +308,6 @@ func TestRandomBeaconRelockNewBeacon(t *testing.T) { round++ propR1 := types.NewProposal(height, 1, round, 0, blockID, theBlock.Time) p := propR1.ToProto() - _, valSet := cs1.GetValidatorSet() _, err = vs2.SignProposal(ctx, stateData.state.ChainID, valSet.QuorumType, valSet.QuorumHash, p) require.NoError(t, err) propR1.Signature = p.Signature From fec2860eae770a84e6cdefd241a32336f475e5c1 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:05:10 +0700 Subject: [PATCH 05/25] fix(types): refuse commits whose beacon or app hash has the wrong size Commit.beacon and Commit.app_hash are covered neither by the commit hash nor by its threshold signature, so a peer relaying a validly signed commit could fill them with any bytes. Before this fix a block sync peer could pad the beacon of an honest commit: the node verified the signature, stored the padded commit as its seen commit and passed it to FinalizeBlock. Over gRPC ABCI a beacon above 4 MB made FinalizeBlock fail and the node crash on every restart, and a beacon larger than Block.MaxBytes left it unable to propose. Commit.ValidateBasic now refuses a commit unless both fields are empty or exactly 96 and 32 bytes, whatever the consensus version. Every path that accepts a commit on its own decodes it through CommitFromProto or validates it with ValidateBasic (block sync responses, consensus Commit messages, light blocks, stored commits), so such a commit is refused before it is stored or passed on. A block's LastCommit is not refused for these fields: releases before them skip them as unknown, so refusing such a block would split an upgraded node from them. BlockFromProto decodes it without the malformed fields instead, so they are never read, kept or passed on. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- internal/blocksync/commit_randomness_test.go | 58 +++++++++++++++ internal/consensus/msgs_test.go | 22 ++++++ proto/tendermint/types/types.pb.go | 4 +- proto/tendermint/types/types.proto | 4 +- types/block.go | 38 +++++++++- types/block_test.go | 78 ++++++++++++++++++++ 6 files changed, 201 insertions(+), 3 deletions(-) create mode 100644 internal/blocksync/commit_randomness_test.go diff --git a/internal/blocksync/commit_randomness_test.go b/internal/blocksync/commit_randomness_test.go new file mode 100644 index 0000000000..d440361b11 --- /dev/null +++ b/internal/blocksync/commit_randomness_test.go @@ -0,0 +1,58 @@ +package blocksync + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + sm "github.com/dashpay/tenderdash/internal/state" + "github.com/dashpay/tenderdash/internal/test/factory" + bcproto "github.com/dashpay/tenderdash/proto/tendermint/blocksync" + "github.com/dashpay/tenderdash/types" +) + +// TestBlockResponseRefusesPaddedCommitBeacon is the regression test for a block sync peer relaying an +// honest block and its validly signed commit with the commit's beacon padded: neither the commit hash +// nor its threshold signature covers the beacon, so before the size bound the padded commit passed +// verification, was stored as the seen commit and reached the application. The response is now +// refused while it is decoded, before anything is verified, stored or passed on. +func TestBlockResponseRefusesPaddedCommitBeacon(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + genDoc, privVals := factory.RandGenesisDoc(1, factory.ConsensusParams()) + state, err := sm.MakeGenesisState(genDoc) + require.NoError(t, err) + block, _, _, seen := makeNextBlock(ctx, t, state, privVals[0], 1, types.NewCommit(0, 0, types.BlockID{}, nil, nil)) + + response := func(beacon, appHash []byte) (*BlockResponse, error) { + t.Helper() + pbBlock, err := block.ToProto() + require.NoError(t, err) + pbCommit := seen.ToProto() + pbCommit.Beacon = beacon + pbCommit.AppHash = appHash + bz, err := (&bcproto.BlockResponse{Block: pbBlock, Commit: pbCommit}).Marshal() + require.NoError(t, err) + var decoded bcproto.BlockResponse + require.NoError(t, decoded.Unmarshal(bz)) + return BlockResponseFromProto(&decoded, "peer") + } + + honest, err := response(nil, nil) + require.NoError(t, err) + require.Equal(t, seen.Hash(), honest.Commit.Hash()) + + for name, fields := range map[string][2][]byte{ + "25 MiB beacon": {make([]byte, 25<<20), []byte("junk")}, + "5 MiB beacon": {make([]byte, 5<<20), make([]byte, 32)}, + "app hash without beacon": {nil, make([]byte, 32)}, + } { + t.Run(name, func(t *testing.T) { + resp, err := response(fields[0], fields[1]) + require.ErrorIs(t, err, types.ErrInvalidCommitRandomness) + require.Nil(t, resp) + }) + } +} diff --git a/internal/consensus/msgs_test.go b/internal/consensus/msgs_test.go index 726d616a4a..1bc066b436 100644 --- a/internal/consensus/msgs_test.go +++ b/internal/consensus/msgs_test.go @@ -761,3 +761,25 @@ func TestHasVoteMessageValidateBasic(t *testing.T) { }) } } + +// TestCommitMessageRefusesMalformedRandomness checks that a commit gossiped with a beacon or app hash +// of the wrong size is refused when the message is decoded: the commit's signature covers neither, so +// a relaying peer could otherwise attach any bytes to a valid commit. +func TestCommitMessageRefusesMalformedRandomness(t *testing.T) { + commit := &types.Commit{ + Height: 2, + BlockID: types.BlockID{Hash: crypto.CRandBytes(crypto.HashSize), PartSetHeader: types.PartSetHeader{Total: 1, Hash: crypto.CRandBytes(crypto.HashSize)}, StateID: crypto.CRandBytes(crypto.HashSize)}, + QuorumHash: crypto.RandQuorumHash(), + ThresholdBlockSignature: crypto.CRandBytes(types.SignatureSize), + } + decode := func(beacon, appHash []byte) error { + pb := commit.ToProto() + pb.Beacon = beacon + pb.AppHash = appHash + _, err := MsgFromProto(&tmcons.Commit{Commit: pb}) + return err + } + require.NoError(t, decode(nil, nil)) + require.NoError(t, decode(crypto.CRandBytes(types.SignatureSize), crypto.CRandBytes(crypto.DefaultAppHashSize))) + require.ErrorIs(t, decode(make([]byte, 900<<10), []byte("junk")), types.ErrInvalidCommitRandomness) +} diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index cbe25466a6..cc51e0dbf0 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -693,7 +693,9 @@ type Commit struct { ThresholdBlockSignature []byte `protobuf:"bytes,5,opt,name=threshold_block_signature,json=thresholdBlockSignature,proto3" json:"threshold_block_signature,omitempty"` ThresholdVoteExtensions []*VoteExtension `protobuf:"bytes,6,rep,name=threshold_vote_extensions,json=thresholdVoteExtensions,proto3" json:"threshold_vote_extensions,omitempty"` // Random beacon: the threshold signature recovered from the prevotes of the commit round. - // Set from consensus version 2; empty before. + // Set from consensus version 2; empty before. Neither this field nor app_hash is covered by the + // commit's signature: a commit is refused unless both are empty or they are exactly 96 and 32 + // bytes, and a block's last commit is read without them when they are not. Beacon []byte `protobuf:"bytes,7,opt,name=beacon,proto3" json:"beacon,omitempty"` // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. // Set from consensus version 2; empty before. diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index bc27a6505e..513e865884 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -157,7 +157,9 @@ message Commit { bytes threshold_block_signature = 5; repeated VoteExtension threshold_vote_extensions = 6; // Random beacon: the threshold signature recovered from the prevotes of the commit round. - // Set from consensus version 2; empty before. + // Set from consensus version 2; empty before. Neither this field nor app_hash is covered by the + // commit's signature: a commit is refused unless both are empty or they are exactly 96 and 32 + // bytes, and a block's last commit is read without them when they are not. bytes beacon = 7; // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. // Set from consensus version 2; empty before. diff --git a/types/block.go b/types/block.go index f1f60cc895..46af9e1588 100644 --- a/types/block.go +++ b/types/block.go @@ -337,7 +337,7 @@ func BlockFromProto(bp *tmproto.Block) (*Block, error) { b.CoreChainLock = coreChainLock if bp.LastCommit != nil { - lc, err := CommitFromProto(bp.LastCommit) + lc, err := CommitFromProto(lastCommitWithoutMalformedRandomness(bp.LastCommit)) if err != nil { return nil, err } @@ -347,6 +347,23 @@ func BlockFromProto(bp *tmproto.Block) (*Block, error) { return b, b.ValidateBasic() } +// lastCommitWithoutMalformedRandomness returns the block's LastCommit without its beacon and app hash +// when they do not have the sizes ValidateBasic requires, and cp itself otherwise. +// +// A block's LastCommit is not refused for them, unlike a commit received on its own: releases before +// these fields skip them as unknown, so they accept such a block, and an upgraded node refusing it +// would split from them. Neither field is covered by the block hash, and dropping them here keeps +// them from being read, stored in the decoded block, or passed on. +func lastCommitWithoutMalformedRandomness(cp *tmproto.Commit) *tmproto.Commit { + if validRandomBeaconSizes(cp.Beacon, cp.AppHash) { + return cp + } + stripped := *cp + stripped.Beacon = nil + stripped.AppHash = nil + return &stripped +} + //----------------------------------------------------------------------------- // MaxDataBytes returns the maximum size of block's data. @@ -752,6 +769,17 @@ const ( //------------------------------------- +// ErrInvalidCommitRandomness is returned for a commit whose beacon and app hash are neither both empty +// nor exactly a threshold signature and an app hash. +var ErrInvalidCommitRandomness = errors.New("invalid commit beacon or app hash size") + +// validRandomBeaconSizes reports whether a commit's beacon and app hash are both empty, or a threshold +// signature and an app hash: the only forms a commit can carry them in. +func validRandomBeaconSizes(beacon, appHash []byte) bool { + return (len(beacon) == 0 && len(appHash) == 0) || + (len(beacon) == SignatureSize && len(appHash) == crypto.DefaultAppHashSize) +} + // Commit contains the evidence that a block was committed by a set of validators. // NOTE: Commit is empty for height 1, but never nil. type Commit struct { @@ -902,6 +930,14 @@ func (commit *Commit) ValidateBasic() error { } } + // Neither field is covered by the commit hash or its threshold signature, so a peer can fill them + // in a commit it relays. Bounding them here refuses such a commit before it is stored or passed + // to the application, whatever the consensus version. + if !validRandomBeaconSizes(commit.Beacon, commit.AppHash) { + return fmt.Errorf("%w: beacon of %d bytes and app hash of %d bytes, expected both empty or %d and %d bytes", + ErrInvalidCommitRandomness, len(commit.Beacon), len(commit.AppHash), SignatureSize, crypto.DefaultAppHashSize) + } + // Reject extension types nothing can dispatch on: proto3's open enums let an // undefined varint decode untouched, and no other check rejects it. Type only — // each extension's contents are covered by its own threshold signature. diff --git a/types/block_test.go b/types/block_test.go index bcc384c082..a7a586cafb 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -1523,3 +1523,81 @@ func TestCommit_ValidateBasic_RejectsUnknownExtensionType(t *testing.T) { "a nil extension must not reach a consumer that will dereference it") require.EqualError(t, nilErr, "nil vote extension at index 0") } + +// TestCommitValidateBasicRandomnessSizes checks that a commit's beacon and app hash must be both empty +// or exactly a threshold signature and an app hash. Neither is covered by the commit hash or its +// signature, so a peer relaying a commit can fill them with anything. +func TestCommitValidateBasicRandomnessSizes(t *testing.T) { + testCases := map[string]struct { + beacon []byte + appHash []byte + valid bool + }{ + "both empty": {valid: true}, + "both set": {beacon: crypto.CRandBytes(SignatureSize), appHash: crypto.CRandBytes(crypto.DefaultAppHashSize), valid: true}, + "beacon only": {beacon: crypto.CRandBytes(SignatureSize)}, + "app hash only": {appHash: crypto.CRandBytes(crypto.DefaultAppHashSize)}, + "long beacon": {beacon: crypto.CRandBytes(SignatureSize + 1), appHash: crypto.CRandBytes(crypto.DefaultAppHashSize)}, + "short app hash": {beacon: crypto.CRandBytes(SignatureSize), appHash: crypto.CRandBytes(crypto.DefaultAppHashSize - 1)}, + "one MiB of beacon": {beacon: make([]byte, 1<<20), appHash: crypto.CRandBytes(crypto.DefaultAppHashSize)}, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + commit := &Commit{ + Height: 3, + BlockID: makeBlockIDRandom(), + QuorumHash: crypto.RandQuorumHash(), + ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: tc.beacon, + AppHash: tc.appHash, + } + _, err := CommitFromProto(commit.ToProto()) + if tc.valid { + require.NoError(t, err) + } else { + require.ErrorIs(t, err, ErrInvalidCommitRandomness) + } + }) + } +} + +// TestBlockFromProtoMalformedLastCommitRandomness checks that a block whose LastCommit carries a beacon +// or app hash of the wrong size is decoded without them rather than refused: releases before these +// fields skip them, and refusing such a block would split an upgraded node from them. +func TestBlockFromProtoMalformedLastCommitRandomness(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + lastID := makeBlockIDRandom() + voteSet, _, vals := randVoteSet(ctx, t, 2, 1, tmproto.PrecommitType, 4) + lastCommit, err := makeCommit(ctx, lastID, 2, 1, voteSet, vals) + require.NoError(t, err) + block := MakeBlock(3, []Tx{Tx("tx")}, lastCommit, nil) + block.ProposerProTxHash = crypto.RandProTxHash() + block.ValidatorsHash = crypto.CRandBytes(crypto.HashSize) + + decode := func(beacon, appHash []byte) *Block { + t.Helper() + pb, err := block.ToProto() + require.NoError(t, err) + pb.LastCommit.Beacon = beacon + pb.LastCommit.AppHash = appHash + bz, err := pb.Marshal() + require.NoError(t, err) + var decoded tmproto.Block + require.NoError(t, decoded.Unmarshal(bz)) + got, err := BlockFromProto(&decoded) + require.NoError(t, err) + return got + } + + got := decode(make([]byte, 10), []byte("junk")) + require.Empty(t, got.LastCommit.Beacon, "a malformed beacon is dropped, not stored") + require.Empty(t, got.LastCommit.AppHash) + require.Equal(t, block.LastCommit.Hash(), got.LastCommit.Hash(), "the commit hash covers neither field") + + beacon, appHash := crypto.CRandBytes(SignatureSize), crypto.CRandBytes(crypto.DefaultAppHashSize) + got = decode(beacon, appHash) + require.Equal(t, beacon, got.LastCommit.Beacon, "well-formed fields are kept") + require.EqualValues(t, appHash, got.LastCommit.AppHash) +} From b1a88aece7a5b7f873d571172d974ccc76e3150e Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:05:10 +0700 Subject: [PATCH 06/25] fix(types): decode blocks whose LastCommit carries mistyped beacon fields Releases before Commit.beacon and Commit.app_hash (fields 7 and 8) skip those fields whatever their wire type. The generated decoder of this release instead refuses the whole block when its LastCommit carries one with a wire type other than bytes. In a network still running older releases, a byzantine proposer could therefore get such a block committed by the older validators while upgraded nodes could not decode it, and an older node that stored it would panic loading it after upgrading. types.UnmarshalBlockProto decodes block bytes as before and, only when that fails, drops the mistyped occurrences of those two fields from the block's LastCommit and decodes again, so an upgraded node reads every block an older one does. Consensus block part assembly and BlockStore.LoadBlock use it. google.golang.org/protobuf becomes a direct dependency for its wire format parser. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- go.mod | 2 +- internal/consensus/state_add_prop_block.go | 6 +- internal/store/store.go | 3 +- internal/store/store_test.go | 23 ++++++ types/block_decode.go | 95 ++++++++++++++++++++++ types/block_decode_test.go | 56 +++++++++++++ 6 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 types/block_decode.go create mode 100644 types/block_decode_test.go diff --git a/go.mod b/go.mod index 41918fab1b..319c81c4b2 100644 --- a/go.mod +++ b/go.mod @@ -275,7 +275,6 @@ require ( golang.org/x/tools v0.52.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20261005182115-fad411399dd8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20261005182115-fad411399dd8 // indirect - google.golang.org/protobuf v1.36.12 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect honnef.co/go/tools v0.8.2 // indirect mvdan.cc/gofumpt v0.12.0 // indirect @@ -336,6 +335,7 @@ require ( golang.org/x/term v0.47.0 golang.org/x/time v0.16.0 google.golang.org/grpc v1.83.2 + google.golang.org/protobuf v1.36.12 pgregory.net/rapid v1.3.0 ) diff --git a/internal/consensus/state_add_prop_block.go b/internal/consensus/state_add_prop_block.go index 9ab668c4a0..a5596a5006 100644 --- a/internal/consensus/state_add_prop_block.go +++ b/internal/consensus/state_add_prop_block.go @@ -10,12 +10,9 @@ import ( "slices" "time" - "github.com/cosmos/gogoproto/proto" - cstypes "github.com/dashpay/tenderdash/internal/consensus/types" tmstrings "github.com/dashpay/tenderdash/internal/libs/strings" "github.com/dashpay/tenderdash/libs/log" - tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" "github.com/dashpay/tenderdash/types" ) @@ -170,8 +167,7 @@ func (c *AddProposalBlockPartAction) addProposalBlockPart( return added, err } - var pbb = new(tmproto.Block) - err = proto.Unmarshal(bz, pbb) + pbb, err := types.UnmarshalBlockProto(bz) if err != nil { return added, err } diff --git a/internal/store/store.go b/internal/store/store.go index ef88c6ce8c..29d6799d82 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -183,7 +183,6 @@ func (bs *BlockStore) LoadBlock(height int64) *types.Block { return nil } - pbb := new(tmproto.Block) buf := []byte{} for i := 0; i < int(blockMeta.BlockID.PartSetHeader.Total); i++ { part := bs.LoadBlockPart(height, i) @@ -194,7 +193,7 @@ func (bs *BlockStore) LoadBlock(height int64) *types.Block { } buf = append(buf, part.Bytes...) } - err := proto.Unmarshal(buf, pbb) + pbb, err := types.UnmarshalBlockProto(buf) if err != nil { // NOTE: The existence of meta should imply the existence of the // block. So, make sure meta is only saved after blocks are saved. diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 447ba59cfe..f5d4add5ba 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -597,3 +597,26 @@ func newBlock(hdr types.Header, lastCommit *types.Commit) *types.Block { LastCommit: lastCommit, } } + +// TestLoadBlockMistypedLastCommitRandomness is the regression test for a block an older release +// stored while its LastCommit carried the beacon field with the varint wire type: that release skips +// the field, so it commits and stores such a block from a byzantine proposer, and an upgraded node +// panicked when loading it. It now loads the block without the field. +func TestLoadBlockMistypedLastCommitRandomness(t *testing.T) { + state, bs := makeStateAndBlockStore(t, t.TempDir()) + block, err := factory.MakeBlock(state, 1, new(types.Commit), 0) + require.NoError(t, err) + pb, err := block.ToProto() + require.NoError(t, err) + bz, err := pb.Marshal() + require.NoError(t, err) + // another occurrence of last_commit (field 4) holding field 7 with wire type 0 + raw := append(append([]byte{}, bz...), 0x22, 0x02, 0x38, 0x01) + parts := types.NewPartSetFromData(raw, types.BlockPartSizeBytes) + bs.SaveBlock(block, parts, makeTestCommit(t, state, block.Height)) + + var loaded *types.Block + require.NotPanics(t, func() { loaded = bs.LoadBlock(1) }) + require.NotNil(t, loaded) + require.Equal(t, block.Hash(), loaded.Hash()) +} diff --git a/types/block_decode.go b/types/block_decode.go new file mode 100644 index 0000000000..fc5df68593 --- /dev/null +++ b/types/block_decode.go @@ -0,0 +1,95 @@ +package types + +import ( + "github.com/cosmos/gogoproto/proto" + "google.golang.org/protobuf/encoding/protowire" + + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" +) + +// Field numbers of tendermint.types.Block.last_commit and of tendermint.types.Commit.beacon and +// app_hash. +const ( + blockLastCommitField protowire.Number = 4 + commitBeaconField protowire.Number = 7 + commitAppHashField protowire.Number = 8 + commitRandomnessWType = protowire.BytesType +) + +// UnmarshalBlockProto decodes the bytes of a block, as joined from its parts. +// +// The beacon and app hash fields of a commit (fields 7 and 8) are unknown to releases before them, +// which skip them whatever their wire type. A block whose LastCommit carries one of them with another +// wire type is therefore valid to those releases, which can commit and store it, while strict +// decoding refuses it. Such occurrences are dropped here, so an upgraded node decodes every block an +// older one does. Blocks without them decode exactly as with proto.Unmarshal. +func UnmarshalBlockProto(bz []byte) (*tmproto.Block, error) { + pb := new(tmproto.Block) + err := proto.Unmarshal(bz, pb) + if err == nil { + return pb, nil + } + cleaned, dropped := dropMistypedLastCommitRandomness(bz) + if !dropped { + return nil, err + } + pb = new(tmproto.Block) + if err := proto.Unmarshal(cleaned, pb); err != nil { + return nil, err + } + return pb, nil +} + +// dropMistypedLastCommitRandomness returns the block bytes bz without the occurrences of the +// LastCommit beacon and app hash fields that do not have the bytes wire type, and whether there were +// any. It returns false for bytes it cannot parse. +func dropMistypedLastCommitRandomness(bz []byte) ([]byte, bool) { + out := make([]byte, 0, len(bz)) + dropped := false + for len(bz) > 0 { + num, typ, n := protowire.ConsumeTag(bz) + if n < 0 { + return nil, false + } + m := protowire.ConsumeFieldValue(num, typ, bz[n:]) + if m < 0 { + return nil, false + } + field := bz[:n+m] + if num == blockLastCommitField && typ == protowire.BytesType { + commit, _ := protowire.ConsumeBytes(bz[n:]) + cleaned, ok := dropMistypedCommitRandomness(commit) + if ok { + dropped = true + field = protowire.AppendBytes(protowire.AppendTag(nil, num, typ), cleaned) + } + } + out = append(out, field...) + bz = bz[n+m:] + } + return out, dropped +} + +// dropMistypedCommitRandomness returns the commit bytes bz without the beacon and app hash fields that +// do not have the bytes wire type, and whether there were any. +func dropMistypedCommitRandomness(bz []byte) ([]byte, bool) { + out := make([]byte, 0, len(bz)) + dropped := false + for len(bz) > 0 { + num, typ, n := protowire.ConsumeTag(bz) + if n < 0 { + return nil, false + } + m := protowire.ConsumeFieldValue(num, typ, bz[n:]) + if m < 0 { + return nil, false + } + if (num == commitBeaconField || num == commitAppHashField) && typ != commitRandomnessWType { + dropped = true + } else { + out = append(out, bz[:n+m]...) + } + bz = bz[n+m:] + } + return out, dropped +} diff --git a/types/block_decode_test.go b/types/block_decode_test.go new file mode 100644 index 0000000000..0192cf9d05 --- /dev/null +++ b/types/block_decode_test.go @@ -0,0 +1,56 @@ +package types + +import ( + "testing" + + "github.com/cosmos/gogoproto/proto" + "github.com/stretchr/testify/require" + + "github.com/dashpay/tenderdash/crypto" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" +) + +// TestUnmarshalBlockProtoMistypedLastCommitRandomness checks that a block whose LastCommit carries the +// beacon or app hash field with a wire type other than bytes decodes as releases before those fields +// decode it, without them, instead of failing: such a block is valid to those releases, which can +// commit it while upgraded nodes could not read it. +func TestUnmarshalBlockProtoMistypedLastCommitRandomness(t *testing.T) { + block := MakeBlock(3, []Tx{Tx("tx")}, &Commit{ + Height: 2, + BlockID: makeBlockIDRandom(), + ThresholdBlockSignature: make([]byte, SignatureSize), + }, nil) + block.ProposerProTxHash = crypto.RandProTxHash() + block.ValidatorsHash = crypto.CRandBytes(crypto.HashSize) + pb, err := block.ToProto() + require.NoError(t, err) + bz, err := pb.Marshal() + require.NoError(t, err) + + plain, err := UnmarshalBlockProto(bz) + require.NoError(t, err) + require.True(t, proto.Equal(pb, plain), "a block without such fields decodes as with proto.Unmarshal") + + // Each suffix is another occurrence of last_commit (field 4), which protobuf merges into the first. + for name, suffix := range map[string][]byte{ + "beacon as varint": {0x22, 0x02, 0x38, 0x01}, // field 7, wire type 0 + "app hash as fixed32": {0x22, 0x05, 0x45, 0x01, 0x02, 0x03, 0x04}, // field 8, wire type 5 + "beacon as fixed64": {0x22, 0x09, 0x39, 1, 2, 3, 4, 5, 6, 7, 8}, // field 7, wire type 1 + } { + t.Run(name, func(t *testing.T) { + raw := append(append([]byte{}, bz...), suffix...) + var strict tmproto.Block + require.Error(t, proto.Unmarshal(raw, &strict), "strict decoding refuses it") + + decoded, err := UnmarshalBlockProto(raw) + require.NoError(t, err) + require.True(t, proto.Equal(pb, decoded), "decodes to the block without the mistyped field") + got, err := BlockFromProto(decoded) + require.NoError(t, err) + require.Equal(t, block.Hash(), got.Hash()) + }) + } + + _, err = UnmarshalBlockProto(append(append([]byte{}, bz...), 0x22, 0x05, 0x38)) + require.Error(t, err, "truncated bytes still fail") +} From db6670047bf6b1afebb8f29e5bb68437bdc5b2b6 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:05:10 +0700 Subject: [PATCH 07/25] fix(kvstore): pick the ApplyBlockRandomness state by block hash The example application looked up the state for ApplyBlockRandomness by height and round only. A node that executed two blocks of one round, as with an equivocating proposer whose second block the network commits after a later round was processed, failed with "more than one proposal executed", which the spec makes fatal, and a block that was not processed silently got another block's app hash. ProcessProposal now records which state each block hash left at each round, and ApplyBlockRandomness answers for the block the request names, refusing one that was not processed. Without a hash it still uses the only state of that height and round. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- abci/example/kvstore/kvstore.go | 36 ++++++++++++++--- abci/example/kvstore/kvstore_test.go | 59 ++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index 82016f0eda..3a46484bb3 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -47,8 +47,12 @@ type Application struct { // LastCommittedState is last state that was committed by Tenderdash and finalized with abci.FinalizeBlock() LastCommittedState State // roundStates contains state for each round, indexed by roundKey() - roundStates map[string]State - RetainBlocks int64 // blocks to retain after commit (via ResponseCommit.RetainHeight) + roundStates map[string]State + // processedBlocks maps each block ProcessProposal executed at this height, by round and block hash, + // to its key in roundStates. Two blocks of one round, from an equivocating proposer, have + // different keys. + processedBlocks map[processedBlock]string + RetainBlocks int64 // blocks to retain after commit (via ResponseCommit.RetainHeight) // preparedProposals stores info about all rounds that got PrepareProposal executed, used to detect // duplicate PrepareProposal calls. @@ -218,6 +222,7 @@ func newApplication(stateStore StoreFactory, opts ...OptFunc) (*Application, err logger: log.NewNopLogger(), LastCommittedState: NewKvState(dbm.NewMemDB(), initialHeight), // initial state to avoid InitChain() in unit tests roundStates: map[string]State{}, + processedBlocks: map[processedBlock]string{}, preparedProposals: map[int32]bool{}, processedProposals: map[int32][]byte{}, validatorSetUpdates: map[int64]abci.ValidatorSetUpdate{}, @@ -392,6 +397,10 @@ func (app *Application) ProcessProposal(_ context.Context, req *abci.RequestProc Status: abci.ResponseProcessProposal_REJECT, }, err } + if len(req.Hash) > 0 { + block := processedBlock{round: req.Round, hash: string(req.Hash)} + app.processedBlocks[block] = roundKey(roundState.GetAppHash(), roundState.GetHeight(), roundState.GetRound()) + } if req.Version.App != app.appVersionForHeight(req.Height) { app.logger.Error("app version mismatch in process proposal request", @@ -496,7 +505,7 @@ func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.Reques app.mu.Lock() defer app.mu.Unlock() - roundState, err := app.processedRoundState(req.Height, req.Round) + roundState, err := app.processedRoundState(req.Hash, req.Height, req.Round) if err != nil { return nil, fmt.Errorf("apply block randomness (hash: %X): %w", req.Hash, err) } @@ -506,9 +515,25 @@ func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.Reques return resp, nil } -// processedRoundState returns the state of the proposal executed at the given height and round. +// processedBlock identifies a block ProcessProposal executed at the current height. +type processedBlock struct { + round int32 + hash string +} + +// processedRoundState returns the state ProcessProposal left for the block with the given hash at +// the given height and round. Without a hash, it returns the only state executed at that height and +// round, by PrepareProposal or ProcessProposal. // Caller should lock the Application. -func (app *Application) processedRoundState(height int64, round int32) (State, error) { +func (app *Application) processedRoundState(hash []byte, height int64, round int32) (State, error) { + if len(hash) > 0 { + key, ok := app.processedBlocks[processedBlock{round: round, hash: string(hash)}] + state := app.roundStates[key] + if !ok || state == nil || state.GetHeight() != height { + return nil, fmt.Errorf("block not processed at height %d round %d", height, round) + } + return state, nil + } var found State for _, state := range app.roundStates { if state.GetHeight() != height || state.GetRound() != round { @@ -827,6 +852,7 @@ func (app *Application) resetRoundStates() { state.Close() } app.roundStates = map[string]State{} + app.processedBlocks = map[processedBlock]string{} } // executeProposal executes transactions and creates new candidate state diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index d541b83b5f..02f4a49075 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -686,3 +686,62 @@ func TestApplyBlockRandomness(t *testing.T) { _, err = app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{Height: height, Round: 0}) require.ErrorContains(t, err, "no proposal executed") } + +// TestApplyBlockRandomnessEquivocation is the regression test for a node that executed two blocks of +// one round, as with an equivocating proposer: it processed block A at round 0, then a block at round 1, +// which lets round 0 be processed again, then the other round 0 block B, which the network committed. +// ApplyBlockRandomness used to pick the state by height and round only and failed with "more than one +// proposal executed", which is fatal; it now picks the state of the block the request names, and +// refuses a block that was not processed. +func TestApplyBlockRandomnessEquivocation(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + app := newKvApp(ctx, t, 1) + process := func(height int64, round int32, hash string, txs ...string) *types.ResponseProcessProposal { + t.Helper() + resp, err := app.ProcessProposal(ctx, &types.RequestProcessProposal{ + Txs: bytes2TxsBytes(txs), + Hash: []byte(hash), + Height: height, + Round: round, + Version: &pbversion.Consensus{App: uint64(height)}, + }) + require.NoError(t, err) + return resp + } + // The app hash changes with the txs only after the initial height. + h1 := process(1, 0, "h1", "k=v") + reqFin := &types.RequestFinalizeBlock{Height: 1} + reqFin.Block, reqFin.BlockID = makeBlock(t, 1, [][]byte{[]byte("k=v")}, h1.AppHash) + _, err := app.FinalizeBlock(ctx, reqFin) + require.NoError(t, err) + + const height = 2 + a := process(height, 0, "block-A", "a=1") + process(height, 1, "block-X", "x=3") + b := process(height, 0, "block-B", "b=2", "c=4") + require.NotEqual(t, a.AppHash, b.AppHash, "two states for round 0") + + apply := func(hash string) (*types.ResponseApplyBlockRandomness, error) { + return app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{ + Hash: []byte(hash), Height: height, Round: 0, Beacon: tmcrypto.CRandBytes(tmtypes.SignatureSize), + }) + } + respB, err := apply("block-B") + require.NoError(t, err) + require.EqualValues(t, b.AppHash, respB.AppHash) + respA, err := apply("block-A") + require.NoError(t, err) + require.EqualValues(t, a.AppHash, respA.AppHash) + _, err = apply("block-never-processed") + require.ErrorContains(t, err, "block not processed") +} + +func bytes2TxsBytes(txs []string) [][]byte { + out := make([][]byte, 0, len(txs)) + for _, tx := range txs { + out = append(out, []byte(tx)) + } + return out +} From 616ef06fd37a21ea32b4d558ce6606c730afd077 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:11:22 +0700 Subject: [PATCH 08/25] fix(state): pass the last commit's beacon and app hash to Prepare/ProcessProposal At consensus version 2, RequestFinalizeBlock.commit carried the commit's beacon and app hash, but local_last_commit and proposed_last_commit of the next height's PrepareProposal and ProcessProposal always carried them empty, although CommitInfo documents both as set from consensus version 2. buildLastCommitInfo now sets them at version 2, from the state, which holds the values the last block was finalized with. The proposer's copy in block.LastCommit is checked against them only when the block is validated, after ProcessProposal, so it is never passed to the application. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- internal/state/execution.go | 22 +++++++-- internal/state/random_beacon_test.go | 71 ++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 5 deletions(-) diff --git a/internal/state/execution.go b/internal/state/execution.go index bb048aa989..0b604c8167 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -252,7 +252,7 @@ func (blockExec *BlockExecutor) CreateProposalBlock( numRequestedTxs := txs.Len() block := state.MakeBlock(height, txs, commit, evidence, proposerProTxHash, proposedAppVersion) - localLastCommit := buildLastCommitInfo(block, state.InitialHeight) + localLastCommit := buildLastCommitInfo(block, state) version := block.Version.ToProto() request := abci.RequestPrepareProposal{ MaxTxBytes: maxDataBytes, @@ -383,7 +383,7 @@ func (blockExec *BlockExecutor) ProcessProposal( Round: round, Time: block.Header.Time, Txs: block.Data.Txs.ToSliceOfBytes(), - ProposedLastCommit: buildLastCommitInfo(block, state.InitialHeight), + ProposedLastCommit: buildLastCommitInfo(block, state), Misbehavior: block.Evidence.ToABCI(), NextValidatorsHash: block.NextValidatorsHash, @@ -848,18 +848,30 @@ func (blockExec *BlockExecutor) flushMempool( return err } -func buildLastCommitInfo(block *types.Block, initialHeight int64) abci.CommitInfo { - if block.Height == initialHeight { +// buildLastCommitInfo returns the CommitInfo of block.LastCommit, the commit of the block state was +// last updated with. +// +// From consensus version 2 it also carries that commit's beacon and app hash. They are taken from +// state, which holds the values the last block was finalized with: block.LastCommit carries the +// proposer's copy, which is checked against them only when the block is validated, after +// ProcessProposal. +func buildLastCommitInfo(block *types.Block, state State) abci.CommitInfo { + if block.Height == state.InitialHeight { // there is no last commit for the initial height. // return an empty value. return abci.CommitInfo{} } - return abci.CommitInfo{ + info := abci.CommitInfo{ Round: block.LastCommit.Round, QuorumHash: block.LastCommit.QuorumHash, BlockSignature: block.LastCommit.ThresholdBlockSignature, ThresholdVoteExtensions: block.LastCommit.ThresholdVoteExtensions, } + if len(state.LastBlockBeacon) > 0 { + info.Beacon = bytes.Clone(state.LastBlockBeacon) + info.AppHash = bytes.Clone(state.LastAppHash) + } + return info } // Update returns a copy of state with the fields set using the arguments passed in. diff --git a/internal/state/random_beacon_test.go b/internal/state/random_beacon_test.go index 9e94e3e0ef..2d364a28b7 100644 --- a/internal/state/random_beacon_test.go +++ b/internal/state/random_beacon_test.go @@ -143,3 +143,74 @@ func TestVerifyLastCommitBeacon(t *testing.T) { // Before consensus version 2 the fields are not checked, whatever they hold. require.NoError(t, sm.VerifyLastCommitBeacon(sm.State{LastAppHash: crypto.Checksum([]byte("other"))}, block)) } + +// lastCommitInfoApp is testApp recording the last commit info PrepareProposal and ProcessProposal get. +type lastCommitInfoApp struct { + testApp + + local, proposed abci.CommitInfo +} + +func (app *lastCommitInfoApp) PrepareProposal(ctx context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + app.local = req.LocalLastCommit + return app.testApp.PrepareProposal(ctx, req) +} + +func (app *lastCommitInfoApp) ProcessProposal(ctx context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + app.proposed = req.ProposedLastCommit + return app.testApp.ProcessProposal(ctx, req) +} + +// TestLastCommitInfoRandomBeacon checks that, once the last block was committed at consensus version 2, +// PrepareProposal's local_last_commit and ProcessProposal's proposed_last_commit carry the beacon and +// app hash it was finalized with, as RequestFinalizeBlock.commit did, taken from the state and not from +// the proposer's copy in the block; before, both stay empty. +func TestLastCommitInfoRandomBeacon(t *testing.T) { + beacon := crypto.CRandBytes(types.SignatureSize) + appHash := crypto.Checksum([]byte("final app hash")) + + run := func(t *testing.T, lastBlockBeacon []byte) *lastCommitInfoApp { + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + app := &lastCommitInfoApp{} + logger := log.NewNopLogger() + proxyApp := proxy.New(abciclient.NewLocalClient(logger, app), logger, proxy.NopMetrics()) + require.NoError(t, proxyApp.Start(ctx)) + + state, stateDB, _ := makeState(t, 1, 2) + state.LastBlockBeacon = lastBlockBeacon + state.LastAppHash = appHash + nodeProTxHash := state.Validators.Validators[0].ProTxHash + ctx = dash.ContextWithProTxHash(ctx, nodeProTxHash) + mp := &mpmocks.Mempool{} + mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) + blockExec := sm.NewBlockExecutor(sm.NewStore(stateDB), proxyApp, mp, sm.EmptyEvidencePool{}, + store.NewBlockStore(dbm.NewMemDB()), eventbus.NewDefault(logger)) + + // The proposer's copy carries other values: they must not reach the application. + lastCommit := types.NewCommit(state.LastBlockHeight, 0, state.LastBlockID, nil, nil) + lastCommit.Beacon = crypto.CRandBytes(types.SignatureSize) + lastCommit.AppHash = crypto.Checksum([]byte("proposer's app hash")) + block, _, err := blockExec.CreateProposalBlock(ctx, state.LastBlockHeight+1, 0, state, lastCommit, nodeProTxHash, 1) + require.NoError(t, err) + _, err = blockExec.ProcessProposal(ctx, block, 0, state, false, types.VerifiedCommit{}) + require.NoError(t, err) + return app + } + + t.Run("consensus version 2", func(t *testing.T) { + app := run(t, beacon) + for _, info := range []abci.CommitInfo{app.local, app.proposed} { + require.Equal(t, beacon, info.Beacon) + require.EqualValues(t, appHash, info.AppHash) + } + }) + + t.Run("before consensus version 2", func(t *testing.T) { + app := run(t, nil) + for _, info := range []abci.CommitInfo{app.local, app.proposed} { + require.Empty(t, info.Beacon) + require.Empty(t, info.AppHash) + } + }) +} From 0b5391b4cd36bfbb8540696f273b680b8dc59c9a Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:11:22 +0700 Subject: [PATCH 09/25] fix(types): take a commit's app hash from the state ID its signature covers Commit.app_hash is not covered by the commit's signature. Before consensus version 2 a proposer could fill a block's LastCommit with a 32-byte app hash that binds nothing; VerifyAppHash, used by light blocks and state sync, then refused the height for good, so light clients could not verify it. VerifyAppHash now returns the header's app hash whenever the signed state ID is the header's, and requires the commit's app hash to bind the state ID only otherwise. VerifyRandomBeacon still requires the commit's own app hash to be the signed one. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- types/random_beacon.go | 35 +++++++++++++++++++++++++---------- types/random_beacon_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/types/random_beacon.go b/types/random_beacon.go index ae911343c5..ee8ecc1737 100644 --- a/types/random_beacon.go +++ b/types/random_beacon.go @@ -48,31 +48,44 @@ func (h *Header) StateIDWithAppHash(appHash []byte) tmproto.StateID { } // VerifyAppHash returns the app hash that commit's state ID commits to for header, the header of the -// block commit commits: commit.AppHash when the commit carries one, otherwise header.AppHash. It fails -// unless commit.BlockID.StateID is the hash of header's StateID with that app hash. +// block commit commits. It is header.AppHash when commit.BlockID.StateID is the hash of header's +// StateID, as before consensus version 2 and whenever the block's randomness left the app hash +// unchanged, and otherwise commit.AppHash, which then must be the app hash whose state ID the commit +// signs. Any other commit fails. // // The threshold signature of a commit covers commit.BlockID.StateID, so once it is verified, the // returned app hash is the one the validators signed, whatever consensus version the block used. +// commit.AppHash is not covered by the signature: before consensus version 2 a proposer can fill a +// block's LastCommit with an app hash that binds nothing, and the state ID still decides. func (commit *Commit) VerifyAppHash(header *Header) (tmbytes.HexBytes, error) { if commit == nil || header == nil { return nil, errors.New("nil commit or header") } - if len(commit.AppHash) == 0 { - if !bytes.Equal(header.StateID().Hash(), commit.BlockID.StateID) { - return nil, fmt.Errorf("commit state ID %X does not match the header's state ID", commit.BlockID.StateID) - } + if bytes.Equal(header.StateID().Hash(), commit.BlockID.StateID) { return header.AppHash, nil } + if len(commit.AppHash) == 0 { + return nil, fmt.Errorf("commit state ID %X does not match the header's state ID", commit.BlockID.StateID) + } + if err := commit.verifySignedAppHash(header); err != nil { + return nil, err + } + return commit.AppHash, nil +} + +// verifySignedAppHash checks that commit.BlockID.StateID is the hash of header's StateID with +// commit.AppHash. +func (commit *Commit) verifySignedAppHash(header *Header) error { if len(commit.AppHash) != crypto.DefaultAppHashSize { - return nil, fmt.Errorf("%w: app hash size is %d, expected %d", + return fmt.Errorf("%w: app hash size is %d, expected %d", ErrInvalidCommitBeacon, len(commit.AppHash), crypto.DefaultAppHashSize) } stateID := header.StateIDWithAppHash(commit.AppHash) if !bytes.Equal(stateID.Hash(), commit.BlockID.StateID) { - return nil, fmt.Errorf("%w: commit state ID %X is not the state ID of the header with app hash %X", + return fmt.Errorf("%w: commit state ID %X is not the state ID of the header with app hash %X", ErrInvalidCommitBeacon, commit.BlockID.StateID, commit.AppHash) } - return commit.AppHash, nil + return nil } // CommittedAppHash returns the app hash the signed header's commit signs: from consensus version 2 the @@ -108,7 +121,9 @@ func (commit *Commit) VerifyRandomBeacon(chainID string, vals *ValidatorSet, hea return fmt.Errorf("%w: header hash %X does not match commit block hash %X", ErrInvalidCommitBeacon, header.Hash(), commit.BlockID.Hash) } - if _, err := commit.VerifyAppHash(header); err != nil { + // The commit's own app hash must be the signed one: unlike VerifyAppHash, this does not fall back + // to the header's when the state IDs happen to match. + if err := commit.verifySignedAppHash(header); err != nil { return err } prevoteBlockID := BlockID{ diff --git a/types/random_beacon_test.go b/types/random_beacon_test.go index 41c4041bce..e5a7f95e25 100644 --- a/types/random_beacon_test.go +++ b/types/random_beacon_test.go @@ -250,3 +250,34 @@ func TestConsensusParamsConsensusVersion(t *testing.T) { assert.Equal(t, version >= 2, params.Version.RandomBeacon(), "version %d", version) } } + +// TestVerifyAppHashIgnoresUnsignedAppHash checks the commit of a block before consensus version 2 whose +// app hash a proposer filled with 32 bytes that bind nothing (the size bound lets them through, and the +// commit's signature does not cover them): the signed state ID is the header's, so the header's app hash +// is the committed one and light blocks still validate. VerifyRandomBeacon, which needs the commit's own +// app hash to be the signed one, still refuses it. +func TestVerifyAppHashIgnoresUnsignedAppHash(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + f := newRandomBeaconFixture(t) + commit := &Commit{ + Height: f.header.Height, + Round: randomBeaconTestRound, + BlockID: f.blockID, + QuorumHash: f.valSet.QuorumHash, + ThresholdBlockSignature: crypto.CRandBytes(SignatureSize), + Beacon: f.recoverBeacon(ctx, t), + AppHash: crypto.CRandBytes(crypto.DefaultAppHashSize), + } + + appHash, err := commit.VerifyAppHash(&f.header) + require.NoError(t, err) + require.EqualValues(t, f.header.AppHash, appHash) + lightBlock := LightBlock{ + SignedHeader: &SignedHeader{Header: &f.header, Commit: commit}, + ValidatorSet: f.valSet, + } + require.NoError(t, lightBlock.ValidateBasic(f.header.ChainID)) + + require.ErrorIs(t, commit.VerifyRandomBeacon(f.header.ChainID, f.valSet, &f.header), ErrInvalidCommitBeacon) +} From 846b8e10ad41817bd2cc2b5ef00ccca7de1429f4 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:41:51 +0700 Subject: [PATCH 10/25] docs(abci): state what the randomness may change and what FinalizeBlock commits The ApplyBlockRandomness contract left four things open: - Vote extensions: Tenderdash calls ApplyBlockRandomness before ExtendVote, but other processes verify a Precommit's extensions against the state ProcessProposal left, possibly before they recover the beacon. Extensions and their verification must not depend on the beacon. - What the randomness may change: only the state behind the returned app hash. Transaction results, events and validator set or consensus parameter updates come from ProcessProposal and are fixed by the header the Prevotes signed. - FinalizeBlock: from consensus version 2 the committed state is the candidate with the commit's beacon applied, and its root must equal commit.app_hash, so an application in same-block execution mode reads the randomness fields as well as the hash. - When it is called: on every path that finalizes a block from a commit, the node's own included; the proto said only commits the node did not assemble itself. The ABCI call grammar gains the method, and the CommitInfo table links VoteExtension to its proto instead of a missing anchor. Regenerated types.pb.go and api.md (comments only). Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- abci/types/application.go | 2 +- abci/types/types.pb.go | 28 ++++++++++--- proto/tendermint/abci/types.proto | 28 ++++++++++--- spec/abci++/abci++_methods.md | 40 +++++++++++++------ spec/abci++/abci++_tmint_expected_behavior.md | 22 ++++++---- spec/abci++/api.md | 27 ++++++++++--- 6 files changed, 109 insertions(+), 38 deletions(-) diff --git a/abci/types/application.go b/abci/types/application.go index a77149b554..157fa5c802 100644 --- a/abci/types/application.go +++ b/abci/types/application.go @@ -46,7 +46,7 @@ type Application interface { VerifyVoteExtension(context.Context, *RequestVerifyVoteExtension) (*ResponseVerifyVoteExtension, error) // Deliver the decided block with its txs to the Application FinalizeBlock(context.Context, *RequestFinalizeBlock) (*ResponseFinalizeBlock, error) - // Apply the block's random beacon and return the app hash the precommit signs (consensus version 2) + // Apply the block's random beacon and return the app hash the precommit signs (consensus version 2). ApplyBlockRandomness(context.Context, *RequestApplyBlockRandomness) (*ResponseApplyBlockRandomness, error) } diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 972df8ed8f..af6ef23aaa 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -1646,6 +1646,10 @@ func (m *RequestProcessProposal) GetQuorumHash() []byte { // `VerifyVoteExtension` rejection that follows `ProcessProposal` of that block and round, to learn the // vector a commit of that block and round must carry; see `VerifyVoteExtension`. An ABCI error or an // invalid response from this call is fatal, as on the Precommit path. +// - From consensus version 2, Tenderdash calls `ApplyBlockRandomness` before `ExtendVote`, but the extensions +// MUST NOT depend on the beacon or on the state `ApplyBlockRandomness` produced: other processes verify them +// against the state `ProcessProposal` left, possibly before they recover the round's beacon, or without ever +// recovering it. // // #### When does Tenderdash call it? // @@ -1911,7 +1915,12 @@ func (m *RequestVerifyVoteExtension) GetVoteExtensions() []*ExtendVoteExtension // already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`. // If the Application is in same-block execution mode, it applies the right candidate state here // (rather than executing the whole block). In this case the Application disregards all parameters in -// `RequestFinalizeBlock` except `RequestFinalizeBlock.hash`. +// `RequestFinalizeBlock` except `RequestFinalizeBlock.hash` and, from consensus version 2, the +// randomness fields below. +// - From consensus version 2, the state to commit is the candidate state of the block for +// `RequestFinalizeBlock.round` with `RequestFinalizeBlock.commit.beacon` applied, as `ApplyBlockRandomness` +// applies it, and its Merkle root hash MUST equal `RequestFinalizeBlock.commit.app_hash`. Committing the +// candidate state without the randomness diverges from the rest of the network. type RequestFinalizeBlock struct { // Info about the current commit Commit CommitInfo `protobuf:"bytes,1,opt,name=commit,proto3" json:"commit"` @@ -2024,6 +2033,12 @@ func (m *RequestFinalizeBlock) GetBlockID() *types1.BlockID { // When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. // - The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign // `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +// - The randomness may change only the application state behind `app_hash`. Transaction results, events, +// validator set updates, consensus parameter updates and the other outputs of `ProcessProposal` are fixed +// by the header the Prevotes signed: they MUST NOT depend on the beacon, and Tenderdash keeps the ones +// `ProcessProposal` returned. +// - Vote extensions and their verification MUST NOT depend on the beacon or on the state this call produces; +// see `ExtendVote`. // - The implementation MUST be deterministic: every process that applies the same beacon to the same block // and round MUST return the same `app_hash`. // - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return @@ -2034,10 +2049,10 @@ func (m *RequestFinalizeBlock) GetBlockID() *types1.BlockID { // // - On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is // recovered, before `ExtendVote` and before signing its Precommit for _v_. -// - On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a -// node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the -// commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with -// `Commit.app_hash` and stops on a mismatch. +// - On every path that finalizes a block from a commit (consensus, block sync, replay, a node that did not +// vote): after `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and +// before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with `Commit.app_hash` and stops on a +// mismatch. type RequestApplyBlockRandomness struct { Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` @@ -3547,7 +3562,8 @@ func (m *ResponseFinalizeBlock) GetProposeNextBlockImmediately() bool { type ResponseApplyBlockRandomness struct { // The Merkle root hash of the application state after the randomness is applied. 32 bytes. - // Equals the header app hash when nothing in the block uses randomness. + // Equals the header app hash when nothing in the block uses randomness. The randomness changes + // nothing but this state: the other results of the block are the ones ProcessProposal returned. AppHash []byte `protobuf:"bytes,1,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index 780dfabb47..43acabfc2d 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -399,6 +399,10 @@ message RequestProcessProposal { // `VerifyVoteExtension` rejection that follows `ProcessProposal` of that block and round, to learn the // vector a commit of that block and round must carry; see `VerifyVoteExtension`. An ABCI error or an // invalid response from this call is fatal, as on the Precommit path. +// - From consensus version 2, Tenderdash calls `ApplyBlockRandomness` before `ExtendVote`, but the extensions +// MUST NOT depend on the beacon or on the state `ApplyBlockRandomness` produced: other processes verify them +// against the state `ProcessProposal` left, possibly before they recover the round's beacon, or without ever +// recovering it. // // #### When does Tenderdash call it? // @@ -542,7 +546,12 @@ message RequestVerifyVoteExtension { // already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`. // If the Application is in same-block execution mode, it applies the right candidate state here // (rather than executing the whole block). In this case the Application disregards all parameters in -// `RequestFinalizeBlock` except `RequestFinalizeBlock.hash`. +// `RequestFinalizeBlock` except `RequestFinalizeBlock.hash` and, from consensus version 2, the +// randomness fields below. +// - From consensus version 2, the state to commit is the candidate state of the block for +// `RequestFinalizeBlock.round` with `RequestFinalizeBlock.commit.beacon` applied, as `ApplyBlockRandomness` +// applies it, and its Merkle root hash MUST equal `RequestFinalizeBlock.commit.app_hash`. Committing the +// candidate state without the randomness diverges from the rest of the network. message RequestFinalizeBlock { // Info about the current commit CommitInfo commit = 1 [(gogoproto.nullable) = false]; @@ -573,6 +582,12 @@ message RequestFinalizeBlock { // When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. // - The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign // `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +// - The randomness may change only the application state behind `app_hash`. Transaction results, events, +// validator set updates, consensus parameter updates and the other outputs of `ProcessProposal` are fixed +// by the header the Prevotes signed: they MUST NOT depend on the beacon, and Tenderdash keeps the ones +// `ProcessProposal` returned. +// - Vote extensions and their verification MUST NOT depend on the beacon or on the state this call produces; +// see `ExtendVote`. // - The implementation MUST be deterministic: every process that applies the same beacon to the same block // and round MUST return the same `app_hash`. // - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return @@ -583,10 +598,10 @@ message RequestFinalizeBlock { // // - On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is // recovered, before `ExtendVote` and before signing its Precommit for _v_. -// - On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a -// node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the -// commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with -// `Commit.app_hash` and stops on a mismatch. +// - On every path that finalizes a block from a commit (consensus, block sync, replay, a node that did not +// vote): after `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and +// before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with `Commit.app_hash` and stops on a +// mismatch. message RequestApplyBlockRandomness { bytes hash = 1; // The header hash of the block the Prevotes are for. int64 height = 2; // Height of the block. @@ -821,7 +836,8 @@ message ResponseFinalizeBlock { message ResponseApplyBlockRandomness { // The Merkle root hash of the application state after the randomness is applied. 32 bytes. - // Equals the header app hash when nothing in the block uses randomness. + // Equals the header app hash when nothing in the block uses randomness. The randomness changes + // nothing but this state: the other results of the block are the ones ProcessProposal returned. bytes app_hash = 1; } diff --git a/spec/abci++/abci++_methods.md b/spec/abci++/abci++_methods.md index 570dc4888a..82cf2affc6 100644 --- a/spec/abci++/abci++_methods.md +++ b/spec/abci++/abci++_methods.md @@ -459,6 +459,10 @@ When a validator _p_ enters Tendermint consensus round _r_, height _h_, in which round, to learn the vector a commit of that block and round must carry; see [VerifyVoteExtension](#verifyvoteextension). An ABCI error or an invalid response from this call is fatal, as on the Precommit path. + * From consensus version 2, Tenderdash calls [ApplyBlockRandomness](#applyblockrandomness) before + `ExtendVote`, but the extensions MUST NOT depend on the beacon or on the state `ApplyBlockRandomness` + produced: other processes verify them against the state `ProcessProposal` left, possibly before they + recover the round's beacon, or without ever recovering it. #### When does Tendermint call it? @@ -612,6 +616,12 @@ block. This includes commits the process assembled from its own +2/3 precommits. * The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign the returned app hash, and the commit carries it with the beacon (`Commit.app_hash`, `Commit.beacon`, and `CommitInfo.app_hash`, `CommitInfo.beacon` in `RequestFinalizeBlock`). + * The randomness may change only the application state behind `app_hash`. Transaction results, events, + validator set updates, consensus parameter updates and the other outputs of `ProcessProposal` are fixed by + the header the Prevotes signed: they MUST NOT depend on the beacon, and Tenderdash keeps the ones + `ProcessProposal` returned. + * Vote extensions and their verification MUST NOT depend on the beacon or on the state this call produces; + see [ExtendVote](#extendvote). * The implementation MUST be deterministic, and MUST return the same `app_hash` when called again for the same block, round and beacon. * An ABCI error is fatal, as for `ExtendVote`. @@ -620,9 +630,9 @@ block. This includes commits the process assembled from its own +2/3 precommits. * On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is recovered, before `ExtendVote` and before signing its Precommit for _v_. -* On every path that finalizes a block from a commit (block sync, replay, a node that did not vote): after - `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and before - `FinalizeBlock`. Tenderdash compares the returned `app_hash` with the commit's and stops on a mismatch. +* On every path that finalizes a block from a commit (consensus, block sync, replay, a node that did not + vote): after `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and + before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with the commit's and stops on a mismatch. ### FinalizeBlock @@ -662,7 +672,13 @@ block. This includes commits the process assembled from its own +2/3 precommits. already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`. If the Application is in same-block execution mode, it applies the right candidate state here (rather than executing the whole block). In this case the Application disregards all parameters in - `RequestFinalizeBlock` except `RequestFinalizeBlock.hash`. + `RequestFinalizeBlock` except `RequestFinalizeBlock.hash` and, from consensus version 2, the + randomness fields below. + * From consensus version 2, the state to commit is the candidate state of the block for + `RequestFinalizeBlock.round` with `RequestFinalizeBlock.commit.beacon` applied, as + [ApplyBlockRandomness](#applyblockrandomness) applies it, and its Merkle root hash MUST equal + `RequestFinalizeBlock.commit.app_hash`. Committing the candidate state without the randomness diverges + from the rest of the network. #### When does Tendermint call it? @@ -848,14 +864,14 @@ enum VoteExtensionType { * **Fields**: - | Name | Type | Description | Field Number | - |---------------------------|------------------------------------------|----------------------------------------------------------------------------------------------|--------------| - | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 | - | quorum_hash | bytes | Quorum hash of a current height. | 2 | - | block_signature | bytes | Block signature. | 3 | - | threshold_vote_extensions | repeated [VoteExtension](#voteextension) | Threshold-recovered vote extensions of the commit. | 4 | - | beacon | bytes | Random beacon of the commit round. Set from consensus version 2; empty before. | 5 | - | app_hash | bytes | App hash the commit signs, returned by `ApplyBlockRandomness`. From consensus version 2. | 6 | + | Name | Type | Description | Field Number | + |---------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------|--------------| + | round | int32 | Commit round. Reflects the round at which the block proposer decided in the previous height. | 1 | + | quorum_hash | bytes | Quorum hash of a current height. | 2 | + | block_signature | bytes | Block signature. | 3 | + | threshold_vote_extensions | repeated [VoteExtension](../../proto/tendermint/types/dash.proto) | Threshold-recovered vote extensions of the commit. | 4 | + | beacon | bytes | Random beacon of the commit round. Set from consensus version 2; empty before. | 5 | + | app_hash | bytes | App hash the commit signs, returned by `ApplyBlockRandomness`. From consensus version 2. | 6 | ### ExtendedCommitInfo diff --git a/spec/abci++/abci++_tmint_expected_behavior.md b/spec/abci++/abci++_tmint_expected_behavior.md index 0b4ddcc4c6..035eff9320 100644 --- a/spec/abci++/abci++_tmint_expected_behavior.md +++ b/spec/abci++/abci++_tmint_expected_behavior.md @@ -55,11 +55,12 @@ success-sync = offer-snapshot 1*apply-chunk recovery = info consensus-exec consensus-exec = (inf)consensus-height -consensus-height = *consensus-round 1*verify-commit decide commit +consensus-height = *consensus-round 1*check-commit [apply-randomness] decide commit +check-commit = [apply-randomness] verify-commit consensus-round = proposer / non-proposer proposer = *got-vote prepare-proposal *got-vote process-proposal [extend] -extend = *got-vote extend-vote *got-vote +extend = *got-vote [apply-randomness] extend-vote *got-vote non-proposer = *got-vote [process-proposal] [extend] init-chain = %s"" @@ -69,6 +70,7 @@ info = %s"" prepare-proposal = %s"" process-proposal = %s"" extend-vote = %s"" +apply-randomness = %s"" got-vote = %s"" verify-commit = %s"" decide = %s"" @@ -158,21 +160,26 @@ Let us now examine the grammar line by line, providing further details. completes successfully. During startup replay/catch-up, rejection of a stored commit instead terminates the run before `FinalizeBlock` and `Commit`, without retry; see the [VerifyVoteExtension REJECT paths](abci++_methods.md#verifyvoteextension). + From consensus version 2, Tenderdash applies the commit's beacon with `ApplyBlockRandomness` + (`apply-randomness`) before verifying a commit and again before `FinalizeBlock`, and the Application + commits the candidate state with that randomness applied. Before version 2 it never calls it. >```abnf ->consensus-height = *consensus-round 1*verify-commit decide commit +>consensus-height = *consensus-round 1*check-commit [apply-randomness] decide commit +>check-commit = [apply-randomness] verify-commit >consensus-round = proposer / non-proposer >``` * For every round, if the local process is the proposer of the current round, Tendermint starts by calling `PrepareProposal`, followed by `ProcessProposal`. Then, optionally, the Application is - asked to extend its vote for that round. Calls to `VerifyVoteExtension` can come at any time: the - local process may be slightly late in the current round, or votes may come from a future round - of this height. + asked to extend its vote for that round; from consensus version 2, `ApplyBlockRandomness` comes + first, with the beacon recovered from the round's Prevotes. Calls to `VerifyVoteExtension` can + come at any time: the local process may be slightly late in the current round, or votes may come + from a future round of this height. >```abnf >proposer = *got-vote prepare-proposal *got-vote process-proposal [extend] ->extend = *got-vote extend-vote *got-vote +>extend = *got-vote [apply-randomness] extend-vote *got-vote >``` * Also for every round, if the local process is _not_ the proposer of the current round, Tendermint @@ -197,6 +204,7 @@ Let us now examine the grammar line by line, providing further details. >prepare-proposal = %s"" >process-proposal = %s"" >extend-vote = %s"" +>apply-randomness = %s"" >got-vote = %s"" >verify-commit = %s"" >decide = %s"" diff --git a/spec/abci++/api.md b/spec/abci++/api.md index 1c7c30eed0..6dcba074a2 100644 --- a/spec/abci++/api.md +++ b/spec/abci++/api.md @@ -279,6 +279,12 @@ Applies the block's randomness and returns the app hash the Precommit signs. When nothing in the block uses randomness, `app_hash` equals the app hash of the block header. - The header keeps the app hash from `ProcessProposal`, which Prevotes sign. Precommits and the commit sign `ResponseApplyBlockRandomness.app_hash`, and the commit carries it in `Commit.app_hash`. +- The randomness may change only the application state behind `app_hash`. Transaction results, events, + validator set updates, consensus parameter updates and the other outputs of `ProcessProposal` are fixed + by the header the Prevotes signed: they MUST NOT depend on the beacon, and Tenderdash keeps the ones + `ProcessProposal` returned. +- Vote extensions and their verification MUST NOT depend on the beacon or on the state this call produces; + see `ExtendVote`. - The implementation MUST be deterministic: every process that applies the same beacon to the same block and round MUST return the same `app_hash`. - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return @@ -289,10 +295,10 @@ Applies the block's randomness and returns the app hash the Precommit signs. - On a validator, once the Prevotes of round _r_ for block _v_ reach the threshold and their signature is recovered, before `ExtendVote` and before signing its Precommit for _v_. -- On every path that finalizes a block from a commit it did not assemble itself (block sync, replay, a - node that did not vote): after `ProcessProposal` of the committed block for the commit round, with the - commit's beacon, and before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with - `Commit.app_hash` and stops on a mismatch. +- On every path that finalizes a block from a commit (consensus, block sync, replay, a node that did not + vote): after `ProcessProposal` of the committed block for the commit round, with the commit's beacon, and + before `FinalizeBlock`. Tenderdash compares the returned `app_hash` with `Commit.app_hash` and stops on a + mismatch. | Field | Type | Label | Description | @@ -398,6 +404,10 @@ Extends a vote with application-side injection `VerifyVoteExtension` rejection that follows `ProcessProposal` of that block and round, to learn the vector a commit of that block and round must carry; see `VerifyVoteExtension`. An ABCI error or an invalid response from this call is fatal, as on the Precommit path. +- From consensus version 2, Tenderdash calls `ApplyBlockRandomness` before `ExtendVote`, but the extensions + MUST NOT depend on the beacon or on the state `ApplyBlockRandomness` produced: other processes verify them + against the state `ProcessProposal` left, possibly before they recover the round's beacon, or without ever + recovering it. #### When does Tenderdash call it? @@ -471,7 +481,12 @@ Finalize newly decided block. already passed on to the Application via `RequestPrepareProposal` or `RequestProcessProposal`. If the Application is in same-block execution mode, it applies the right candidate state here (rather than executing the whole block). In this case the Application disregards all parameters in - `RequestFinalizeBlock` except `RequestFinalizeBlock.hash`. + `RequestFinalizeBlock` except `RequestFinalizeBlock.hash` and, from consensus version 2, the + randomness fields below. +- From consensus version 2, the state to commit is the candidate state of the block for + `RequestFinalizeBlock.round` with `RequestFinalizeBlock.commit.beacon` applied, as `ApplyBlockRandomness` + applies it, and its Merkle root hash MUST equal `RequestFinalizeBlock.commit.app_hash`. Committing the + candidate state without the randomness diverges from the rest of the network. | Field | Type | Label | Description | @@ -938,7 +953,7 @@ block. This includes commits the process assembled from its own +2/3 precomm | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| app_hash | [bytes](#bytes) | | The Merkle root hash of the application state after the randomness is applied. 32 bytes. Equals the header app hash when nothing in the block uses randomness. | +| app_hash | [bytes](#bytes) | | The Merkle root hash of the application state after the randomness is applied. 32 bytes. Equals the header app hash when nothing in the block uses randomness. The randomness changes nothing but this state: the other results of the block are the ones ProcessProposal returned. | From 952361e161674321d81fceb0293daa83bdf512ee Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:42:12 +0700 Subject: [PATCH 11/25] chore(abci): bump ABCISemVer to 1.5.0 The ABCI interface gained the ApplyBlockRandomness method and the CommitInfo beacon and app_hash fields. RELEASES.md makes interface changes a minor bump, and v1.8.0 to v1.8.2 already report 1.4.0, so an application built against these protos could not tell from RequestInfo.abci_version that a Tenderdash without them is too old. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version.go b/version/version.go index c5c9dd67a9..fe2023260a 100644 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const ( // when not using git describe. It is formatted with semantic versioning. TMVersionDefault = "1.8.2" // ABCISemVer is the semantic version of the ABCI library - ABCISemVer = "1.4.0" + ABCISemVer = "1.5.0" ABCIVersion = ABCISemVer ) From 720a335fbdb1cf610ce302b8569e4c294fa1d8be Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:42:12 +0700 Subject: [PATCH 12/25] fix(types): keep the commit's randomness bytes out of the base commit reserve MaxCommitOverheadBytes had grown by the 132 bytes of a commit's beacon and app hash, but its only runtime use is the mempool's per-transaction size pre-check, and commits carry those fields only from consensus version 2. Before that, every chain lost 132 bytes of transaction size at CheckTx, and one with Block.MaxBytes between 1129 and 1260 refused every transaction while its proposals still had room. MaxCommitOverheadBytes is back to the commit without the fields, and the new MaxCommitRandomnessBytes holds them, for the consensus version 2 check to add. Commit.String, StringIndented and its log fields now show the beacon and the app hash, so two commits that differ only there can be told apart. TestCommitBeaconFields encodes and decodes Commit and CommitInfo on the wire and compares whole structs. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- internal/state/tx_filter_test.go | 2 +- node/node_test.go | 2 +- types/block.go | 18 ++++++++++++++---- types/block_test.go | 30 +++++++++++++++++++++++------- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/internal/state/tx_filter_test.go b/internal/state/tx_filter_test.go index ef1e833f09..3456fed3b1 100644 --- a/internal/state/tx_filter_test.go +++ b/internal/state/tx_filter_test.go @@ -15,7 +15,7 @@ import ( func TestTxFilter(t *testing.T) { const maxBlockBytes = 3241 - maxTxSize := maxBlockBytes - 1264 + maxTxSize := maxBlockBytes - 1132 genDoc := factory.MinimalGenesisDoc() genDoc.ConsensusParams.Block.MaxBytes = maxBlockBytes genDoc.ConsensusParams.Evidence.MaxBytes = 1500 diff --git a/node/node_test.go b/node/node_test.go index ce33a25126..96ac662944 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -875,7 +875,7 @@ func TestMaxProposalBlockSize(t *testing.T) { // require that the header and commit be the max possible size require.Equal(t, types.MaxHeaderBytes, int64(pb.Header.Size())) - require.Equal(t, types.MaxCommitOverheadBytes, int64(pb.LastCommit.Size())) + require.Equal(t, types.MaxCommitOverheadBytes+types.MaxCommitRandomnessBytes, int64(pb.LastCommit.Size())) // make sure that the block is less than the max possible size assert.Equal(t, int64(1248+cfg.Mempool.MaxTxBytes), int64(pb.Size())) // because of the proto overhead we expect the part set bytes to be equal or diff --git a/types/block.go b/types/block.go index 46af9e1588..3e163cabec 100644 --- a/types/block.go +++ b/types/block.go @@ -762,9 +762,11 @@ const ( const ( // MaxCommitOverheadBytes is the max size of commit, with overhead but without vote extensions: // (110+2) for BlockID, (8+2) for Height, (4+2) for Round, - // (32+2) for QuorumHash, (96+2) for Block signature, - // (96+2) for Beacon, (32+2) for AppHash. - MaxCommitOverheadBytes int64 = (110 + 2) + (8 + 2) + (4 + 2) + (32 + 2) + (96 + 2) + (96 + 2) + (32 + 2) + 0 + // (32+2) for QuorumHash, (96+2) for Block signature. + MaxCommitOverheadBytes int64 = (110 + 2) + (8 + 2) + (4 + 2) + (32 + 2) + (96 + 2) + 0 + // MaxCommitRandomnessBytes is what a commit grows by when it carries a random beacon (consensus + // version 2): (96+2) for Beacon, (32+2) for AppHash. + MaxCommitRandomnessBytes int64 = (96 + 2) + (32 + 2) ) //------------------------------------- @@ -998,12 +1000,14 @@ func (commit *Commit) String() string { return "nil-Commit" } return fmt.Sprintf( - `Commit{H: %d, R: %d, BlockID: %v, QuorumHash %v, BlockSignature: %v}#%v`, + `Commit{H: %d, R: %d, BlockID: %v, QuorumHash %v, BlockSignature: %v, Beacon: %v, AppHash: %v}#%v`, commit.Height, commit.Round, commit.BlockID, commit.QuorumHash, base64.StdEncoding.EncodeToString(commit.ThresholdBlockSignature), + base64.StdEncoding.EncodeToString(commit.Beacon), + commit.AppHash, commit.hash) } @@ -1017,11 +1021,15 @@ func (commit *Commit) StringIndented(indent string) string { %s Round: %d %s BlockID: %v %s BlockSignature: %v +%s Beacon: %v +%s AppHash: %v %s}#%v`, indent, commit.Height, indent, commit.Round, indent, commit.BlockID, indent, base64.StdEncoding.EncodeToString(commit.ThresholdBlockSignature), + indent, base64.StdEncoding.EncodeToString(commit.Beacon), + indent, commit.AppHash, indent, commit.hash) } @@ -1032,6 +1040,8 @@ func (commit *Commit) MarshalZerologObject(e *zerolog.Event) { e.Int32("round", commit.Round) e.Str("BlockID.Hash", commit.BlockID.Hash.String()) e.Str("BlockSignature", hex.EncodeToString(commit.ThresholdBlockSignature)) + e.Str("Beacon", hex.EncodeToString(commit.Beacon)) + e.Str("AppHash", commit.AppHash.String()) } } diff --git a/types/block_test.go b/types/block_test.go index a7a586cafb..b736aced6f 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -18,6 +18,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + abci "github.com/dashpay/tenderdash/abci/types" "github.com/dashpay/tenderdash/crypto" "github.com/dashpay/tenderdash/crypto/bls12381" "github.com/dashpay/tenderdash/crypto/merkle" @@ -314,8 +315,9 @@ func TestCommit(t *testing.T) { assert.True(t, commit.IsCommit()) } -// TestCommitBeaconFields checks that the beacon and the app hash of a commit survive the protobuf -// round trip and reach the CommitInfo passed to the application. +// TestCommitBeaconFields checks that the beacon and the app hash of a commit survive protobuf +// encoding and decoding, reach the CommitInfo passed to the application, and show in the commit's +// string form. func TestCommitBeaconFields(t *testing.T) { commit := &Commit{ Height: 3, @@ -331,14 +333,25 @@ func TestCommitBeaconFields(t *testing.T) { AppHash: crypto.Checksum([]byte("final app hash")), } - decoded, err := CommitFromProto(commit.ToProto()) + bz, err := commit.ToProto().Marshal() require.NoError(t, err) - assert.Equal(t, commit.Beacon, decoded.Beacon) - assert.Equal(t, commit.AppHash, decoded.AppHash) + var pb tmproto.Commit + require.NoError(t, pb.Unmarshal(bz)) + decoded, err := CommitFromProto(&pb) + require.NoError(t, err) + require.Equal(t, commit, decoded) info := commit.ToCommitInfo() assert.Equal(t, commit.Beacon, info.Beacon) assert.EqualValues(t, commit.AppHash, info.AppHash) + bz, err = info.Marshal() + require.NoError(t, err) + var decodedInfo abci.CommitInfo + require.NoError(t, decodedInfo.Unmarshal(bz)) + require.Equal(t, info, decodedInfo) + + assert.Contains(t, commit.String(), commit.AppHash.String()) + assert.Contains(t, commit.StringIndented(""), commit.AppHash.String()) } func TestCommitValidateBasic(t *testing.T) { @@ -393,7 +406,10 @@ func TestMaxCommitBytes(t *testing.T) { pb := commit.ToProto() pbSize := int64(pb.Size()) - assert.EqualValues(t, MaxCommitOverheadBytes, pbSize) + assert.EqualValues(t, MaxCommitOverheadBytes+MaxCommitRandomnessBytes, pbSize) + + commit.Beacon, commit.AppHash = nil, nil + assert.EqualValues(t, MaxCommitOverheadBytes, commit.ToProto().Size()) } func TestHeaderHash(t *testing.T) { @@ -624,7 +640,7 @@ func TestBlockMaxDataBytes(t *testing.T) { func TestBlockMaxDataBytesNoEvidence(t *testing.T) { // minBlockSize is minimum correct size of a block - const minBlockSize = 1261 + const minBlockSize = 1129 testCases := []struct { maxBytes int64 From c0e8c7f451414e8ec6c319ead45a9c76e3f56c9a Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:42:12 +0700 Subject: [PATCH 13/25] test(abci): cover ApplyBlockRandomness in the routed and proxy clients TestRouting routes ApplyBlockRandomness to its configured client and checks the response type, and TestApplyBlockRandomnessMetrics checks that the proxy client records the call under apply_block_randomness, for success and failure. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- abci/client/routed_client_test.go | 10 ++++++++++ internal/proxy/client_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/abci/client/routed_client_test.go b/abci/client/routed_client_test.go index 99883da542..b2fa440f86 100644 --- a/abci/client/routed_client_test.go +++ b/abci/client/routed_client_test.go @@ -25,6 +25,7 @@ import ( // * when a request of type FinalizeBlock is made, it should be first routed to queryApp, then to consensusApp // * when a request of type CheckTx is made, it should be routed to queryApp // * when a request of type PrepareProposal is made, it should be routed to to consensusApp +// * when a request of type ApplyBlockRandomness is made, it should be routed to consensusApp func TestRouting(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -64,10 +65,14 @@ func TestRouting(t *testing.T) { consensusApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&types.ResponseFinalizeBlock{ RetainHeight: 1, }, nil).Once() + consensusApp.On("ApplyBlockRandomness", mock.Anything, mock.Anything).Return(&types.ResponseApplyBlockRandomness{ + AppHash: []byte("final apphash"), + }, nil).Once() addr := fmt.Sprintf("CheckTx:socket:%s", querySocket) + fmt.Sprintf(",FinalizeBlock:socket:%s,FinalizeBlock:socket:%s", querySocket, consensusSocket) + fmt.Sprintf(",PrepareProposal:socket:%s", consensusSocket) + + fmt.Sprintf(",ApplyBlockRandomness:socket:%s", consensusSocket) + fmt.Sprintf(",*:socket:%s", defaultSocket) logger.Info("configuring routed abci client with address", "addr", addr) @@ -101,6 +106,11 @@ func TestRouting(t *testing.T) { _, err = routedClient.PrepareProposal(ctx, &types.RequestPrepareProposal{}) assert.NoError(t, err) + // ApplyBlockRandomness + randomness, err := routedClient.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{}) + assert.NoError(t, err) + assert.EqualValues(t, "final apphash", randomness.AppHash) + // unlock info assert.False(t, infoExecuted) infoMtx.Unlock() diff --git a/internal/proxy/client_test.go b/internal/proxy/client_test.go index 8821ef7ea5..d14d0cd131 100644 --- a/internal/proxy/client_test.go +++ b/internal/proxy/client_test.go @@ -285,6 +285,36 @@ func TestFailureMetrics(t *testing.T) { assert.Equal(t, 2, hst.count["method=check_tx,type=sync,success=true"]) } +// TestApplyBlockRandomnessMetrics checks that the proxy client forwards ApplyBlockRandomness and records +// its timing under the apply_block_randomness method. +func TestApplyBlockRandomnessMetrics(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + logger := log.NewTestingLogger(t) + mtr := mockMetrics() + hst := mtr.MethodTiming.(*mockMetric) + + app := mocks.NewApplication(t) + app.On("ApplyBlockRandomness", mock.Anything, mock.Anything). + Return(&types.ResponseApplyBlockRandomness{AppHash: []byte("final apphash")}, nil).Once() + app.On("ApplyBlockRandomness", mock.Anything, mock.Anything). + Return(nil, errors.New("some error")).Once() + + proxy := New(abciclient.NewLocalClient(logger, app), log.NewNopLogger(), mtr) + + res, err := proxy.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{}) + require.NoError(t, err) + assert.EqualValues(t, "final apphash", res.AppHash) + _, err = proxy.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{}) + assert.Error(t, err) + + cancel() + proxy.Wait() + assert.Equal(t, 1, hst.count["method=apply_block_randomness,type=sync,success=true"]) + assert.Equal(t, 1, hst.count["method=apply_block_randomness,type=sync,success=false"]) +} + func mockMetrics() *Metrics { return &Metrics{ MethodTiming: &mockMetric{ From 8ffdc4bbf237b1bdd77f7050906be42c407a9b78 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 04:44:36 +0700 Subject: [PATCH 14/25] fix(state): reserve the commit's beacon bytes in the mempool check at consensus version 2 The mempool's per-transaction size pre-check reserves room for the next block's last commit. From consensus version 2 that commit also carries its beacon and app hash, so TxPreCheckForState now subtracts MaxCommitRandomnessBytes when the consensus params use the random beacon, and only then. Refs dashpay/platform#4682 Co-Authored-By: Claude Opus 5.5 --- internal/state/tx_filter.go | 4 ++++ internal/state/tx_filter_test.go | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/internal/state/tx_filter.go b/internal/state/tx_filter.go index 4b1afd8d87..cb81cb6b89 100644 --- a/internal/state/tx_filter.go +++ b/internal/state/tx_filter.go @@ -60,6 +60,10 @@ func TxPreCheckForState(state State) mempool.PreCheckFunc { if err != nil { return err } + if state.ConsensusParams.Version.RandomBeacon() { + // From consensus version 2, the last commit also carries its beacon and app hash. + maxDataBytes -= types.MaxCommitRandomnessBytes + } return mempool.PreCheckMaxBytes(maxDataBytes)(tx) } } diff --git a/internal/state/tx_filter_test.go b/internal/state/tx_filter_test.go index 3456fed3b1..6b7dec49cb 100644 --- a/internal/state/tx_filter_test.go +++ b/internal/state/tx_filter_test.go @@ -10,9 +10,29 @@ import ( sm "github.com/dashpay/tenderdash/internal/state" "github.com/dashpay/tenderdash/internal/test/factory" tmrand "github.com/dashpay/tenderdash/libs/rand" + tmproto "github.com/dashpay/tenderdash/proto/tendermint/types" "github.com/dashpay/tenderdash/types" ) +// TestTxFilterRandomBeacon checks that the pre-check reserves room for the last commit's beacon and +// app hash from consensus version 2, and only then. +func TestTxFilterRandomBeacon(t *testing.T) { + const maxBlockBytes = 3241 + maxTxSize := maxBlockBytes - 1132 + genDoc := factory.MinimalGenesisDoc() + genDoc.ConsensusParams.Block.MaxBytes = maxBlockBytes + genDoc.ConsensusParams.Evidence.MaxBytes = 1500 + state, err := sm.MakeGenesisState(&genDoc) + require.NoError(t, err) + require.NoError(t, sm.TxPreCheckForState(state)(types.Tx(tmrand.Bytes(maxTxSize)))) + + state.ConsensusParams.Version.ConsensusVersion = int32(tmproto.VersionParams_CONSENSUS_VERSION_2) + f := sm.TxPreCheckForState(state) + maxTxSize -= int(types.MaxCommitRandomnessBytes) + require.NoError(t, f(types.Tx(tmrand.Bytes(maxTxSize)))) + require.Error(t, f(types.Tx(tmrand.Bytes(maxTxSize+1)))) +} + func TestTxFilter(t *testing.T) { const maxBlockBytes = 3241 maxTxSize := maxBlockBytes - 1132 From 3bd58e3d0072a9c328f542a5ee962c76014712b7 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 15:30:05 +0700 Subject: [PATCH 15/25] fix(types): split a block into fields as the generated decoder does when dropping mistyped commit fields The fallback in UnmarshalBlockProto drops a LastCommit's beacon and app hash fields that do not have the bytes wire type, so an upgraded node decodes every block an older one does. It split the bytes with protowire, which refuses encodings the generated decoder of older releases skips: a group closed by an end-group of another field number, and a ten-byte varint whose last byte overflows 64 bits. A proposer could then send a block that older validators accept and upgraded ones cannot decode. The scanner now reads tags, varints and skipped fields with the rules of the code gogoproto generates. The test checks each case against gogotypes.Empty, whose generated decoder skips every field as older releases skip fields 7 and 8, both for blocks it accepts and for blocks it still refuses. Co-Authored-By: Claude Opus 5.5 --- types/block_decode.go | 122 +++++++++++++++++++++++++++++++------ types/block_decode_test.go | 26 +++++++- 2 files changed, 127 insertions(+), 21 deletions(-) diff --git a/types/block_decode.go b/types/block_decode.go index fc5df68593..b245106e5c 100644 --- a/types/block_decode.go +++ b/types/block_decode.go @@ -42,30 +42,28 @@ func UnmarshalBlockProto(bz []byte) (*tmproto.Block, error) { // dropMistypedLastCommitRandomness returns the block bytes bz without the occurrences of the // LastCommit beacon and app hash fields that do not have the bytes wire type, and whether there were -// any. It returns false for bytes it cannot parse. +// any. It splits the bytes into fields as the generated decoder does, and returns false where that +// decoder fails. func dropMistypedLastCommitRandomness(bz []byte) ([]byte, bool) { out := make([]byte, 0, len(bz)) dropped := false for len(bz) > 0 { - num, typ, n := protowire.ConsumeTag(bz) - if n < 0 { + num, typ, n, ok := consumeGeneratedField(bz) + if !ok { return nil, false } - m := protowire.ConsumeFieldValue(num, typ, bz[n:]) - if m < 0 { - return nil, false - } - field := bz[:n+m] + field := bz[:n] if num == blockLastCommitField && typ == protowire.BytesType { - commit, _ := protowire.ConsumeBytes(bz[n:]) - cleaned, ok := dropMistypedCommitRandomness(commit) + _, tagLen, _ := consumeGeneratedVarint(field) + _, lenLen, _ := consumeGeneratedVarint(field[tagLen:]) + cleaned, ok := dropMistypedCommitRandomness(field[tagLen+lenLen:]) if ok { dropped = true field = protowire.AppendBytes(protowire.AppendTag(nil, num, typ), cleaned) } } out = append(out, field...) - bz = bz[n+m:] + bz = bz[n:] } return out, dropped } @@ -76,20 +74,106 @@ func dropMistypedCommitRandomness(bz []byte) ([]byte, bool) { out := make([]byte, 0, len(bz)) dropped := false for len(bz) > 0 { - num, typ, n := protowire.ConsumeTag(bz) - if n < 0 { - return nil, false - } - m := protowire.ConsumeFieldValue(num, typ, bz[n:]) - if m < 0 { + num, typ, n, ok := consumeGeneratedField(bz) + if !ok { return nil, false } if (num == commitBeaconField || num == commitAppHashField) && typ != commitRandomnessWType { dropped = true } else { - out = append(out, bz[:n+m]...) + out = append(out, bz[:n]...) } - bz = bz[n+m:] + bz = bz[n:] } return out, dropped } + +// consumeGeneratedField returns the number, the wire type and the length, tag included, of the field at +// the start of bz, as the Unmarshal methods that gogoproto generates read a field they skip: the +// field number is the tag shifted right by 3 and truncated to 32 bits. It returns false where those +// methods fail. +// +// Releases before the beacon skip fields 7 and 8 of a commit with these rules, which accept more than +// protowire does, so the bytes must be split with the same rules to drop exactly those fields. +func consumeGeneratedField(bz []byte) (protowire.Number, protowire.Type, int, bool) { + tag, _, ok := consumeGeneratedVarint(bz) + if !ok { + return 0, 0, 0, false + } + num, typ := protowire.Number(int32(tag>>3)), protowire.Type(tag&0x7) + if typ == protowire.EndGroupType || num <= 0 { + return 0, 0, 0, false + } + n, ok := skipGeneratedField(bz) + if !ok || n > len(bz) { + return 0, 0, 0, false + } + return num, typ, n, true +} + +// skipGeneratedField returns the length, tag included, of the field at the start of bz, computed as +// the skip functions that gogoproto generates compute it. The length may exceed len(bz), which the +// caller checks. A group ends at the first end-group tag that brings the nesting depth back to zero, +// whatever its field number. +func skipGeneratedField(bz []byte) (int, bool) { + i, depth := 0, 0 + for i < len(bz) { + tag, n, ok := consumeGeneratedVarint(bz[i:]) + if !ok { + return 0, false + } + i += n + switch protowire.Type(tag & 0x7) { + case protowire.VarintType: + _, n, ok := consumeGeneratedVarint(bz[i:]) + if !ok { + return 0, false + } + i += n + case protowire.Fixed64Type: + i += 8 + case protowire.BytesType: + length, n, ok := consumeGeneratedVarint(bz[i:]) + if !ok || int(length) < 0 { + return 0, false + } + i += n + int(length) + case protowire.StartGroupType: + depth++ + case protowire.EndGroupType: + if depth == 0 { + return 0, false + } + depth-- + case protowire.Fixed32Type: + i += 4 + default: + return 0, false + } + if i < 0 { + return 0, false + } + if depth == 0 { + return i, true + } + } + return 0, false +} + +// consumeGeneratedVarint reads the varint at the start of bz as the code that gogoproto generates +// does, and returns it with its length. Unlike protowire, it drops the bits of a tenth byte past the +// 64th instead of failing. +func consumeGeneratedVarint(bz []byte) (uint64, int, bool) { + var v uint64 + for i, shift := 0, uint(0); shift < 64; i, shift = i+1, shift+7 { + if i >= len(bz) { + return 0, 0, false + } + b := bz[i] + v |= uint64(b&0x7F) << shift + if b < 0x80 { + return v, i + 1, true + } + } + return 0, 0, false +} diff --git a/types/block_decode_test.go b/types/block_decode_test.go index 0192cf9d05..ab71d50617 100644 --- a/types/block_decode_test.go +++ b/types/block_decode_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/cosmos/gogoproto/proto" + gogotypes "github.com/cosmos/gogoproto/types" "github.com/stretchr/testify/require" "github.com/dashpay/tenderdash/crypto" @@ -32,12 +33,21 @@ func TestUnmarshalBlockProtoMistypedLastCommitRandomness(t *testing.T) { require.True(t, proto.Equal(pb, plain), "a block without such fields decodes as with proto.Unmarshal") // Each suffix is another occurrence of last_commit (field 4), which protobuf merges into the first. + // Releases before the beacon read its content as a message that knows none of its fields, which + // gogotypes.Empty stands for: their generated decoder skips fields 7 and 8 as Empty's does. for name, suffix := range map[string][]byte{ "beacon as varint": {0x22, 0x02, 0x38, 0x01}, // field 7, wire type 0 "app hash as fixed32": {0x22, 0x05, 0x45, 0x01, 0x02, 0x03, 0x04}, // field 8, wire type 5 "beacon as fixed64": {0x22, 0x09, 0x39, 1, 2, 3, 4, 5, 6, 7, 8}, // field 7, wire type 1 + // field 7 start-group closed by a field 8 end-group: the generated skip does not match them + "beacon as group closed by app hash": {0x22, 0x02, 0x3b, 0x44}, + // field 7, wire type 0, a ten-byte varint whose last byte overflows 64 bits + "beacon as overflowing varint": {0x22, 0x0b, 0x38, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x02}, + // field 8 group holding a varint and an empty field 7 group + "app hash as nested group": {0x22, 0x06, 0x43, 0x08, 0x01, 0x3b, 0x3c, 0x44}, } { t.Run(name, func(t *testing.T) { + require.NoError(t, new(gogotypes.Empty).Unmarshal(suffix[2:]), "releases before the beacon accept it") raw := append(append([]byte{}, bz...), suffix...) var strict tmproto.Block require.Error(t, proto.Unmarshal(raw, &strict), "strict decoding refuses it") @@ -51,6 +61,18 @@ func TestUnmarshalBlockProtoMistypedLastCommitRandomness(t *testing.T) { }) } - _, err = UnmarshalBlockProto(append(append([]byte{}, bz...), 0x22, 0x05, 0x38)) - require.Error(t, err, "truncated bytes still fail") + for name, suffix := range map[string][]byte{ + "truncated": {0x22, 0x05, 0x38}, + "end-group without start": {0x22, 0x01, 0x3c}, + "unclosed group": {0x22, 0x01, 0x3b}, + "end-group past the group": {0x22, 0x03, 0x3b, 0x3c, 0x44}, + // field 7, wire type 0, an eleven-byte varint + "varint past ten bytes": {0x22, 0x0c, 0x38, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01}, + } { + t.Run(name, func(t *testing.T) { + require.Error(t, new(gogotypes.Empty).Unmarshal(suffix[2:]), "releases before the beacon refuse it") + _, err := UnmarshalBlockProto(append(append([]byte{}, bz...), suffix...)) + require.Error(t, err, "still refused") + }) + } } From 774a2545b5554ba31e0c4f4c6655b874cea1d279 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 15:30:06 +0700 Subject: [PATCH 16/25] fix(state): pass the last commit's beacon and app hash in proposal requests buildLastCommitInfo built RequestPrepareProposal.LocalLastCommit and RequestProcessProposal.ProposedLastCommit field by field and left out the commit's beacon and app hash. It now keeps its initial-height guard and delegates to Commit.ToCommitInfo. Co-Authored-By: Claude Opus 5.5 --- internal/state/execution.go | 7 +--- internal/state/execution_test.go | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/internal/state/execution.go b/internal/state/execution.go index c196489fe6..198b65220e 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -775,12 +775,7 @@ func buildLastCommitInfo(block *types.Block, initialHeight int64) abci.CommitInf // return an empty value. return abci.CommitInfo{} } - return abci.CommitInfo{ - Round: block.LastCommit.Round, - QuorumHash: block.LastCommit.QuorumHash, - BlockSignature: block.LastCommit.ThresholdBlockSignature, - ThresholdVoteExtensions: block.LastCommit.ThresholdVoteExtensions, - } + return block.LastCommit.ToCommitInfo() } // Update returns a copy of state with the fields set using the arguments passed in. diff --git a/internal/state/execution_test.go b/internal/state/execution_test.go index f876aabb4c..8c9faf448d 100644 --- a/internal/state/execution_test.go +++ b/internal/state/execution_test.go @@ -898,6 +898,72 @@ func TestEmptyPrepareProposal(t *testing.T) { require.NoError(t, err) } +// TestProposalRequestsCarryLastCommitRandomness checks that PrepareProposal and ProcessProposal pass +// the last commit's beacon and app hash to the application, with its other fields. +func TestProposalRequestsCarryLastCommitRandomness(t *testing.T) { + const height = 2 + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + logger := log.NewNopLogger() + + eventBus := eventbus.NewDefault(logger) + require.NoError(t, eventBus.Start(ctx)) + state, stateDB, privVals := makeState(t, 1, height) + + var prepareReq *abci.RequestPrepareProposal + var processReq *abci.RequestProcessProposal + app := abcimocks.NewApplication(t) + app.On("PrepareProposal", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + prepareReq = args.Get(1).(*abci.RequestPrepareProposal) + }).Return(&abci.ResponsePrepareProposal{ + AppHash: make([]byte, crypto.DefaultAppHashSize), AppVersion: 1, + }, nil) + app.On("ProcessProposal", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + processReq = args.Get(1).(*abci.RequestProcessProposal) + }).Return(&abci.ResponseProcessProposal{ + AppHash: make([]byte, crypto.DefaultAppHashSize), + Status: abci.ResponseProcessProposal_ACCEPT, + }, nil) + cc := abciclient.NewLocalClient(logger, app) + proxyApp := proxy.New(cc, logger, proxy.NopMetrics()) + require.NoError(t, proxyApp.Start(ctx)) + + mp := &mpmocks.Mempool{} + mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) + + blockExec := sm.NewBlockExecutor( + sm.NewStore(stateDB), + proxyApp, + mp, + sm.EmptyEvidencePool{}, + nil, + eventBus, + ) + proposer := state.Validators.GetByIndex(0) + commit, _ := makeValidCommit(ctx, t, height, types.BlockID{}, state.Validators, privVals) + commit.Beacon = crypto.CRandBytes(bls12381.SignatureSize) + commit.AppHash = crypto.CRandBytes(crypto.DefaultAppHashSize) + expected := abci.CommitInfo{ + Round: commit.Round, + QuorumHash: commit.QuorumHash, + BlockSignature: commit.ThresholdBlockSignature, + ThresholdVoteExtensions: commit.ThresholdVoteExtensions, + Beacon: commit.Beacon, + AppHash: commit.AppHash, + } + + block, _, err := blockExec.CreateProposalBlock(ctx, height, 0, state, commit, proposer.ProTxHash, 0) + require.NoError(t, err) + require.NotNil(t, prepareReq) + assert.Equal(t, expected, prepareReq.LocalLastCommit) + + _, err = blockExec.ProcessProposal(ctx, block, 0, state, false, types.VerifiedCommit{}) + require.NoError(t, err) + require.NotNil(t, processReq) + assert.Equal(t, expected, processReq.ProposedLastCommit) +} + // TestPrepareProposalErrorOnNonExistingRemoved tests that the block creation logic returns // an error if the ResponsePrepareProposal returned from the application marks // From 5a2eff50356a300018ed71e2e966193ccb77c645 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 15:33:53 +0700 Subject: [PATCH 17/25] chore(types): mark the block decoder's wrapping conversions for gosec The fallback scanner truncates the field number to 32 bits and reads a length into an int that may wrap, as the code gogoproto generates does; gosec flagged both as G115. The conversions must stay as they are, so they carry nolint comments with the reason. Co-Authored-By: Claude Opus 5.5 --- types/block_decode.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/types/block_decode.go b/types/block_decode.go index b245106e5c..9d5bc017a6 100644 --- a/types/block_decode.go +++ b/types/block_decode.go @@ -100,7 +100,7 @@ func consumeGeneratedField(bz []byte) (protowire.Number, protowire.Type, int, bo if !ok { return 0, 0, 0, false } - num, typ := protowire.Number(int32(tag>>3)), protowire.Type(tag&0x7) + num, typ := protowire.Number(int32(tag>>3)), protowire.Type(tag&0x7) //nolint:gosec // truncated as generated code does if typ == protowire.EndGroupType || num <= 0 { return 0, 0, 0, false } @@ -134,10 +134,11 @@ func skipGeneratedField(bz []byte) (int, bool) { i += 8 case protowire.BytesType: length, n, ok := consumeGeneratedVarint(bz[i:]) - if !ok || int(length) < 0 { + size := int(length) //nolint:gosec // wraps as the int length of generated code does + if !ok || size < 0 { return 0, false } - i += n + int(length) + i += n + size case protowire.StartGroupType: depth++ case protowire.EndGroupType: From 2be9a72a55383ab13665fe847188bda3a12ebf63 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 18:35:38 +0700 Subject: [PATCH 18/25] fix(state): drop a relayed commit's beacon and app hash from proposals A peer can add a correctly sized beacon and app hash to a validly signed commit: neither is covered by the commit's hash or threshold signature, so the commit is accepted and becomes the next proposal's LastCommit. Releases before the beacon drop both fields when they decode a block, and block sync rebuilds the block's parts from what it decoded, so they could not block sync a block an honest proposer built from that commit. CreateProposalBlock now drops both fields from the commit it is given, through the new Commit.WithoutRandomBeacon, which copies the commit rather than changing it. Co-Authored-By: Claude Opus 5.5 --- internal/state/execution.go | 5 +++ internal/state/execution_test.go | 76 ++++++++++++++++++++++++++++++-- types/block.go | 14 ++++++ 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/internal/state/execution.go b/internal/state/execution.go index 198b65220e..2b4388a3a1 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -233,6 +233,11 @@ func (blockExec *BlockExecutor) CreateProposalBlock( maxBytes := state.ConsensusParams.Block.MaxBytes maxGas := state.ConsensusParams.Block.MaxGas + // The commit may come from a peer, which can set its beacon and app hash: they are empty before + // consensus version 2, and releases before them drop them when they decode a block, so block sync + // on those releases would rebuild a block that carried them into parts the next commit does not sign. + commit = commit.WithoutRandomBeacon() + evidence, evSize := blockExec.evpool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes) // Fetch a limited amount of valid txs diff --git a/internal/state/execution_test.go b/internal/state/execution_test.go index 8c9faf448d..4f5a028203 100644 --- a/internal/state/execution_test.go +++ b/internal/state/execution_test.go @@ -898,8 +898,10 @@ func TestEmptyPrepareProposal(t *testing.T) { require.NoError(t, err) } -// TestProposalRequestsCarryLastCommitRandomness checks that PrepareProposal and ProcessProposal pass -// the last commit's beacon and app hash to the application, with its other fields. +// TestProposalRequestsCarryLastCommitRandomness checks that ProcessProposal passes the beacon and app +// hash of the proposed block's last commit to the application, with its other fields, and that +// PrepareProposal passes the other fields of the commit the proposer was given, whose beacon and app +// hash it drops (see TestProposalDropsRelayedCommitRandomness). func TestProposalRequestsCarryLastCommitRandomness(t *testing.T) { const height = 2 ctx, cancel := context.WithCancel(context.Background()) @@ -956,14 +958,82 @@ func TestProposalRequestsCarryLastCommitRandomness(t *testing.T) { block, _, err := blockExec.CreateProposalBlock(ctx, height, 0, state, commit, proposer.ProTxHash, 0) require.NoError(t, err) require.NotNil(t, prepareReq) - assert.Equal(t, expected, prepareReq.LocalLastCommit) + withoutRandomness := expected + withoutRandomness.Beacon, withoutRandomness.AppHash = nil, nil + assert.Equal(t, withoutRandomness, prepareReq.LocalLastCommit) + block.LastCommit = commit _, err = blockExec.ProcessProposal(ctx, block, 0, state, false, types.VerifiedCommit{}) require.NoError(t, err) require.NotNil(t, processReq) assert.Equal(t, expected, processReq.ProposedLastCommit) } +// TestProposalDropsRelayedCommitRandomness is the regression test for a peer relaying a validly +// signed commit with a correctly sized beacon and app hash added: neither is covered by the commit's +// hash or threshold signature, so the commit is accepted and becomes the next proposal's LastCommit. +// Releases before the beacon drop both fields when they decode a block, and block sync rebuilds the +// parts of the block from what it decoded, so a proposal that kept them could not be block synced by +// those releases. The proposer drops them instead. +func TestProposalDropsRelayedCommitRandomness(t *testing.T) { + const height = 2 + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + logger := log.NewNopLogger() + + eventBus := eventbus.NewDefault(logger) + require.NoError(t, eventBus.Start(ctx)) + state, stateDB, privVals := makeState(t, 1, height) + + var prepareReq *abci.RequestPrepareProposal + app := abcimocks.NewApplication(t) + app.On("PrepareProposal", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + prepareReq = args.Get(1).(*abci.RequestPrepareProposal) + }).Return(&abci.ResponsePrepareProposal{ + AppHash: make([]byte, crypto.DefaultAppHashSize), AppVersion: 1, + }, nil) + cc := abciclient.NewLocalClient(logger, app) + proxyApp := proxy.New(cc, logger, proxy.NopMetrics()) + require.NoError(t, proxyApp.Start(ctx)) + + mp := &mpmocks.Mempool{} + mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) + + blockExec := sm.NewBlockExecutor(sm.NewStore(stateDB), proxyApp, mp, sm.EmptyEvidencePool{}, nil, eventBus) + proposer := state.Validators.GetByIndex(0) + commit, _ := makeValidCommit(ctx, t, height, factory.MakeBlockID(), state.Validators, privVals) + beacon := crypto.CRandBytes(bls12381.SignatureSize) + appHash := crypto.CRandBytes(crypto.DefaultAppHashSize) + commit.Beacon, commit.AppHash = beacon, appHash + relayed, err := types.CommitFromProto(commit.ToProto()) + require.NoError(t, err) + require.Equal(t, commit.Hash(), relayed.Hash(), "the beacon and app hash are not part of the commit hash") + + block, _, err := blockExec.CreateProposalBlock(ctx, height, 0, state, relayed, proposer.ProTxHash, 0) + require.NoError(t, err) + assert.Empty(t, block.LastCommit.Beacon) + assert.Empty(t, block.LastCommit.AppHash) + require.NotNil(t, prepareReq) + assert.Empty(t, prepareReq.LocalLastCommit.Beacon) + assert.Empty(t, prepareReq.LocalLastCommit.AppHash) + assert.Equal(t, beacon, relayed.Beacon, "the relayed commit is not changed") + assert.EqualValues(t, appHash, relayed.AppHash, "the relayed commit is not changed") + + // A release before the beacon decodes the block without fields 7 and 8 of its LastCommit, and + // block sync checks the parts it rebuilds from that block against the next commit's BlockID. + parts, err := block.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + pb, err := block.ToProto() + require.NoError(t, err) + pb.LastCommit.Beacon, pb.LastCommit.AppHash = nil, nil + legacy, err := types.BlockFromProto(pb) + require.NoError(t, err) + legacyParts, err := legacy.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + assert.Equal(t, parts.Header(), legacyParts.Header()) +} + // TestPrepareProposalErrorOnNonExistingRemoved tests that the block creation logic returns // an error if the ResponsePrepareProposal returned from the application marks // diff --git a/types/block.go b/types/block.go index 3e163cabec..e6217b3eb9 100644 --- a/types/block.go +++ b/types/block.go @@ -839,6 +839,20 @@ func (commit *Commit) ToCommitInfo() types.CommitInfo { } } +// WithoutRandomBeacon returns commit without its random beacon and app hash. Before consensus version 2 +// both fields must be empty, but neither is covered by the commit's threshold signature, so a peer could +// fill them; nodes drop them from commits of such heights instead of storing or passing them on. It +// returns commit itself when both are already empty. +func (commit *Commit) WithoutRandomBeacon() *Commit { + if commit == nil || (len(commit.Beacon) == 0 && len(commit.AppHash) == 0) { + return commit + } + stripped := *commit + stripped.Beacon = nil + stripped.AppHash = nil + return &stripped +} + // GetCanonicalVote returns the message that is being voted on in the form of a vote without signatures. // It returns an error if the commit carries a vote extension of an unknown type. func (commit *Commit) GetCanonicalVote() (*Vote, error) { From 2c9287da81e1c963da24b06d3c63dfb3e356b39f Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Wed, 4 Nov 2026 19:21:34 +0700 Subject: [PATCH 19/25] test(node): expect proposals to drop the commit's beacon and app hash TestMaxProposalBlockSize gives CreateProposalBlock a commit with a beacon and an app hash, which the proposal now drops, so its LastCommit and the block are back to their sizes without them. Co-Authored-By: Claude Opus 5.5 --- node/node_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/node_test.go b/node/node_test.go index 96ac662944..3e6c4e688f 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -873,11 +873,12 @@ func TestMaxProposalBlockSize(t *testing.T) { pb, err := block.ToProto() require.NoError(t, err) - // require that the header and commit be the max possible size + // require that the header and commit be the max possible size; the proposal drops the beacon and + // app hash of the commit before consensus version 2 require.Equal(t, types.MaxHeaderBytes, int64(pb.Header.Size())) - require.Equal(t, types.MaxCommitOverheadBytes+types.MaxCommitRandomnessBytes, int64(pb.LastCommit.Size())) + require.Equal(t, types.MaxCommitOverheadBytes, int64(pb.LastCommit.Size())) // make sure that the block is less than the max possible size - assert.Equal(t, int64(1248+cfg.Mempool.MaxTxBytes), int64(pb.Size())) + assert.Equal(t, int64(1116+cfg.Mempool.MaxTxBytes), int64(pb.Size())) // because of the proto overhead we expect the part set bytes to be equal or // less than the pb block size assert.LessOrEqual(t, partSet.ByteSize(), int64(pb.Size())) From 0ef2a67b7337021c541b916c0a7eb0a84d1db084 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Thu, 5 Nov 2026 02:44:43 +0700 Subject: [PATCH 20/25] fix: drop a commit's unsigned beacon and app hash before consensus version 2 Neither field is covered by the commit hash or its threshold signature, and both are empty before consensus version 2, which this release does not define. A peer relaying a validly signed commit could still add correctly sized ones, which nodes stored as the seen commit, passed to FinalizeBlock and served on; a proposer could put them in its block's LastCommit, which reached ProcessProposal. Drop both where a commit is adopted (consensus Commit messages, block sync, state sync and its backfill) and from the last commit passed in proposal requests. One test now covers the proposer side, with a block that keeps the fields as a negative control for older releases' block sync, replacing the two overlapping ones; another covers block sync. Co-Authored-By: Claude Opus 5.5 --- internal/blocksync/applier.go | 3 + internal/blocksync/commit_randomness_test.go | 68 +++++++++++ internal/consensus/state_try_add_commit.go | 7 ++ internal/state/execution.go | 5 +- internal/state/execution_test.go | 120 ++++++------------- internal/statesync/reactor.go | 9 +- types/block.go | 10 +- 7 files changed, 134 insertions(+), 88 deletions(-) diff --git a/internal/blocksync/applier.go b/internal/blocksync/applier.go index 66e7c61fa5..f9a7e07665 100644 --- a/internal/blocksync/applier.go +++ b/internal/blocksync/applier.go @@ -93,6 +93,9 @@ func (e *blockApplier) Apply(ctx context.Context, block *types.Block, commit *ty blockID := block.BlockID(blockParts) partSetTime := e.observeSince("partset", start) + // Before consensus version 2 a commit carries no beacon; see WithoutRandomBeacon. + commit = commit.WithoutRandomBeacon() + start = time.Now() verified, err := e.verify(ctx, blockID, block, commit) if err != nil { diff --git a/internal/blocksync/commit_randomness_test.go b/internal/blocksync/commit_randomness_test.go index d440361b11..e239c7adc1 100644 --- a/internal/blocksync/commit_randomness_test.go +++ b/internal/blocksync/commit_randomness_test.go @@ -4,10 +4,20 @@ import ( "context" "testing" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + abciclient "github.com/dashpay/tenderdash/abci/client" + abci "github.com/dashpay/tenderdash/abci/types" + "github.com/dashpay/tenderdash/crypto" + "github.com/dashpay/tenderdash/internal/eventbus" + mpmocks "github.com/dashpay/tenderdash/internal/mempool/mocks" + "github.com/dashpay/tenderdash/internal/proxy" sm "github.com/dashpay/tenderdash/internal/state" + "github.com/dashpay/tenderdash/internal/store" "github.com/dashpay/tenderdash/internal/test/factory" + dbm "github.com/dashpay/tenderdash/libs/db" + "github.com/dashpay/tenderdash/libs/log" bcproto "github.com/dashpay/tenderdash/proto/tendermint/blocksync" "github.com/dashpay/tenderdash/types" ) @@ -56,3 +66,61 @@ func TestBlockResponseRefusesPaddedCommitBeacon(t *testing.T) { }) } } + +// finalizeRecorder records the last commit FinalizeBlock received. +type finalizeRecorder struct { + abci.BaseApplication + commit abci.CommitInfo +} + +func (r *finalizeRecorder) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { + r.commit = req.Commit + return &abci.ResponseFinalizeBlock{}, nil +} + +// TestBlockSyncDropsRelayedCommitRandomness is the regression test for a block sync peer relaying an +// honest block and its validly signed commit with a correctly sized beacon and app hash added: neither +// is covered by the commit's hash or threshold signature, so the commit passes verification. Before +// consensus version 2 a commit carries neither, and the applier drops both, so they are neither passed +// to the application nor stored as the seen commit this node serves. +func TestBlockSyncDropsRelayedCommitRandomness(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + logger := log.NewNopLogger() + + genDoc, privVals := factory.RandGenesisDoc(1, factory.ConsensusParams()) + state, err := sm.MakeGenesisState(genDoc) + require.NoError(t, err) + stateStore := sm.NewStore(dbm.NewMemDB()) + require.NoError(t, stateStore.Save(state)) + blockStore := store.NewBlockStore(dbm.NewMemDB()) + app := &finalizeRecorder{} + proxyApp := proxy.New(abciclient.NewLocalClient(logger, app), logger, proxy.NopMetrics()) + require.NoError(t, proxyApp.Start(ctx)) + eventBus := eventbus.NewDefault(logger) + require.NoError(t, eventBus.Start(ctx)) + mp := &mpmocks.Mempool{} + mp.On("Lock").Return() + mp.On("Unlock").Return() + mp.On("FlushAppConn", mock.Anything).Return(nil) + mp.On("Update", mock.Anything, mock.Anything, mock.Anything, mock.Anything, + mock.Anything, mock.Anything, mock.Anything).Return(nil) + blockExec := sm.NewBlockExecutor(stateStore, proxyApp, mp, sm.EmptyEvidencePool{}, blockStore, eventBus) + applier := newBlockApplier(blockExec, blockStore, applierWithState(state)) + + block, _, _, seen := makeNextBlock(ctx, t, state, privVals[0], 1, types.NewCommit(0, 0, types.BlockID{}, nil, nil)) + pbBlock, err := block.ToProto() + require.NoError(t, err) + pbCommit := seen.ToProto() + pbCommit.Beacon = crypto.CRandBytes(types.SignatureSize) + pbCommit.AppHash = crypto.CRandBytes(crypto.DefaultAppHashSize) + resp, err := BlockResponseFromProto(&bcproto.BlockResponse{Block: pbBlock, Commit: pbCommit}, "peer") + require.NoError(t, err, "a correctly sized beacon and app hash pass the size bound") + + require.NoError(t, applier.Apply(ctx, resp.Block, resp.Commit)) + require.Equal(t, seen.ToCommitInfo(), app.commit) + stored := blockStore.LoadSeenCommitAt(1) + require.Empty(t, stored.Beacon) + require.Empty(t, stored.AppHash) + require.Equal(t, seen.Hash(), stored.Hash()) +} diff --git a/internal/consensus/state_try_add_commit.go b/internal/consensus/state_try_add_commit.go index b311ae6830..0a9279449e 100644 --- a/internal/consensus/state_try_add_commit.go +++ b/internal/consensus/state_try_add_commit.go @@ -45,6 +45,13 @@ func (cs *TryAddCommitAction) Execute(ctx context.Context, stateEvent StateEvent event := stateEvent.Data.(*TryAddCommitEvent) stateData := stateEvent.StateData commit := event.Commit + if stripped := commit.WithoutRandomBeacon(); stripped != commit { + // Before consensus version 2 a commit carries no beacon; see WithoutRandomBeacon. + commit = stripped + withoutBeacon := *event + withoutBeacon.Commit = commit + event = &withoutBeacon + } peerID := event.PeerID fromReplay := event.FromReplay ctx = ctxWithPeerVerificationBudget(ctx, peerID, fromReplay, cs.verificationBudget) diff --git a/internal/state/execution.go b/internal/state/execution.go index 2b4388a3a1..a4a92659c0 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -774,13 +774,16 @@ func (blockExec *BlockExecutor) flushMempool( return err } +// buildLastCommitInfo returns the CommitInfo of block.LastCommit for the application, without its +// beacon and app hash: they are empty before consensus version 2, and neither the block hash nor the +// commit's signature covers them, so the proposer could have set any. func buildLastCommitInfo(block *types.Block, initialHeight int64) abci.CommitInfo { if block.Height == initialHeight { // there is no last commit for the initial height. // return an empty value. return abci.CommitInfo{} } - return block.LastCommit.ToCommitInfo() + return block.LastCommit.WithoutRandomBeacon().ToCommitInfo() } // Update returns a copy of state with the fields set using the arguments passed in. diff --git a/internal/state/execution_test.go b/internal/state/execution_test.go index 4f5a028203..26dd14f1c1 100644 --- a/internal/state/execution_test.go +++ b/internal/state/execution_test.go @@ -898,11 +898,16 @@ func TestEmptyPrepareProposal(t *testing.T) { require.NoError(t, err) } -// TestProposalRequestsCarryLastCommitRandomness checks that ProcessProposal passes the beacon and app -// hash of the proposed block's last commit to the application, with its other fields, and that -// PrepareProposal passes the other fields of the commit the proposer was given, whose beacon and app -// hash it drops (see TestProposalDropsRelayedCommitRandomness). -func TestProposalRequestsCarryLastCommitRandomness(t *testing.T) { +// TestProposalDropsRelayedCommitRandomness is the regression test for a peer relaying a validly +// signed commit with a correctly sized beacon and app hash added, and for a proposer putting them in +// its block's LastCommit: neither is covered by the commit's hash or threshold signature, and both are +// empty before consensus version 2. +// +// The proposer drops them from the commit it builds on. Releases before the beacon drop both fields +// when they decode a block, and block sync rebuilds the parts of the block from what it decoded, so a +// proposal that kept them could not be block synced by those releases. PrepareProposal and +// ProcessProposal pass the other fields of the last commit to the application, without them. +func TestProposalDropsRelayedCommitRandomness(t *testing.T) { const height = 2 ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -934,72 +939,6 @@ func TestProposalRequestsCarryLastCommitRandomness(t *testing.T) { mp := &mpmocks.Mempool{} mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) - blockExec := sm.NewBlockExecutor( - sm.NewStore(stateDB), - proxyApp, - mp, - sm.EmptyEvidencePool{}, - nil, - eventBus, - ) - proposer := state.Validators.GetByIndex(0) - commit, _ := makeValidCommit(ctx, t, height, types.BlockID{}, state.Validators, privVals) - commit.Beacon = crypto.CRandBytes(bls12381.SignatureSize) - commit.AppHash = crypto.CRandBytes(crypto.DefaultAppHashSize) - expected := abci.CommitInfo{ - Round: commit.Round, - QuorumHash: commit.QuorumHash, - BlockSignature: commit.ThresholdBlockSignature, - ThresholdVoteExtensions: commit.ThresholdVoteExtensions, - Beacon: commit.Beacon, - AppHash: commit.AppHash, - } - - block, _, err := blockExec.CreateProposalBlock(ctx, height, 0, state, commit, proposer.ProTxHash, 0) - require.NoError(t, err) - require.NotNil(t, prepareReq) - withoutRandomness := expected - withoutRandomness.Beacon, withoutRandomness.AppHash = nil, nil - assert.Equal(t, withoutRandomness, prepareReq.LocalLastCommit) - - block.LastCommit = commit - _, err = blockExec.ProcessProposal(ctx, block, 0, state, false, types.VerifiedCommit{}) - require.NoError(t, err) - require.NotNil(t, processReq) - assert.Equal(t, expected, processReq.ProposedLastCommit) -} - -// TestProposalDropsRelayedCommitRandomness is the regression test for a peer relaying a validly -// signed commit with a correctly sized beacon and app hash added: neither is covered by the commit's -// hash or threshold signature, so the commit is accepted and becomes the next proposal's LastCommit. -// Releases before the beacon drop both fields when they decode a block, and block sync rebuilds the -// parts of the block from what it decoded, so a proposal that kept them could not be block synced by -// those releases. The proposer drops them instead. -func TestProposalDropsRelayedCommitRandomness(t *testing.T) { - const height = 2 - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - logger := log.NewNopLogger() - - eventBus := eventbus.NewDefault(logger) - require.NoError(t, eventBus.Start(ctx)) - state, stateDB, privVals := makeState(t, 1, height) - - var prepareReq *abci.RequestPrepareProposal - app := abcimocks.NewApplication(t) - app.On("PrepareProposal", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { - prepareReq = args.Get(1).(*abci.RequestPrepareProposal) - }).Return(&abci.ResponsePrepareProposal{ - AppHash: make([]byte, crypto.DefaultAppHashSize), AppVersion: 1, - }, nil) - cc := abciclient.NewLocalClient(logger, app) - proxyApp := proxy.New(cc, logger, proxy.NopMetrics()) - require.NoError(t, proxyApp.Start(ctx)) - - mp := &mpmocks.Mempool{} - mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs{}) - blockExec := sm.NewBlockExecutor(sm.NewStore(stateDB), proxyApp, mp, sm.EmptyEvidencePool{}, nil, eventBus) proposer := state.Validators.GetByIndex(0) commit, _ := makeValidCommit(ctx, t, height, factory.MakeBlockID(), state.Validators, privVals) @@ -1009,29 +948,48 @@ func TestProposalDropsRelayedCommitRandomness(t *testing.T) { relayed, err := types.CommitFromProto(commit.ToProto()) require.NoError(t, err) require.Equal(t, commit.Hash(), relayed.Hash(), "the beacon and app hash are not part of the commit hash") + expected := relayed.WithoutRandomBeacon().ToCommitInfo() block, _, err := blockExec.CreateProposalBlock(ctx, height, 0, state, relayed, proposer.ProTxHash, 0) require.NoError(t, err) assert.Empty(t, block.LastCommit.Beacon) assert.Empty(t, block.LastCommit.AppHash) require.NotNil(t, prepareReq) - assert.Empty(t, prepareReq.LocalLastCommit.Beacon) - assert.Empty(t, prepareReq.LocalLastCommit.AppHash) + assert.Equal(t, expected, prepareReq.LocalLastCommit) assert.Equal(t, beacon, relayed.Beacon, "the relayed commit is not changed") assert.EqualValues(t, appHash, relayed.AppHash, "the relayed commit is not changed") - // A release before the beacon decodes the block without fields 7 and 8 of its LastCommit, and - // block sync checks the parts it rebuilds from that block against the next commit's BlockID. - parts, err := block.MakePartSet(types.BlockPartSizeBytes) - require.NoError(t, err) + // A block whose LastCommit keeps them, as a byzantine proposer can build. pb, err := block.ToProto() require.NoError(t, err) - pb.LastCommit.Beacon, pb.LastCommit.AppHash = nil, nil - legacy, err := types.BlockFromProto(pb) + pb.LastCommit = relayed.ToProto() + byzantine, err := types.BlockFromProto(pb) require.NoError(t, err) - legacyParts, err := legacy.MakePartSet(types.BlockPartSizeBytes) + require.Equal(t, beacon, byzantine.LastCommit.Beacon) + + // A release before the beacon decodes a block without fields 7 and 8 of its LastCommit, and block + // sync checks the parts it rebuilds from that block against the next commit's BlockID: they match + // for the proposal, and not for a block that kept the relayed fields. + partSetHeader := func(b *types.Block, legacy bool) types.PartSetHeader { + t.Helper() + pb, err := b.ToProto() + require.NoError(t, err) + if legacy { + pb.LastCommit.Beacon, pb.LastCommit.AppHash = nil, nil + } + decoded, err := types.BlockFromProto(pb) + require.NoError(t, err) + parts, err := decoded.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + return parts.Header() + } + assert.Equal(t, partSetHeader(block, false), partSetHeader(block, true)) + assert.NotEqual(t, partSetHeader(byzantine, false), partSetHeader(byzantine, true)) + + _, err = blockExec.ProcessProposal(ctx, byzantine, 0, state, false, types.VerifiedCommit{}) require.NoError(t, err) - assert.Equal(t, parts.Header(), legacyParts.Header()) + require.NotNil(t, processReq) + assert.Equal(t, expected, processReq.ProposedLastCommit) } // TestPrepareProposalErrorOnNonExistingRemoved tests that the block creation logic returns diff --git a/internal/statesync/reactor.go b/internal/statesync/reactor.go index 6df321458b..e6e09d0c0f 100644 --- a/internal/statesync/reactor.go +++ b/internal/statesync/reactor.go @@ -399,6 +399,8 @@ func (r *Reactor) Sync(ctx context.Context) (sm.State, error) { if err != nil { return sm.State{}, fmt.Errorf("sync any: %w", err) } + // Before consensus version 2 a commit carries no beacon; see WithoutRandomBeacon. + commit = commit.WithoutRandomBeacon() err = r.publishCommitEvent(commit) if err != nil { @@ -911,8 +913,11 @@ func (r *Reactor) backfill( return fmt.Errorf("authenticating backfill validator set at height %d: %w", resp.block.Height, err) } - // save the signed headers - if err := r.blockStore.SaveSignedHeader(resp.block.SignedHeader, trustedBlockID); err != nil { + // save the signed headers; before consensus version 2 a commit carries no beacon, see + // WithoutRandomBeacon + signedHeader := *resp.block.SignedHeader + signedHeader.Commit = signedHeader.Commit.WithoutRandomBeacon() + if err := r.blockStore.SaveSignedHeader(&signedHeader, trustedBlockID); err != nil { return err } diff --git a/types/block.go b/types/block.go index e6217b3eb9..9b308d73b2 100644 --- a/types/block.go +++ b/types/block.go @@ -799,8 +799,9 @@ type Commit struct { // Beacon is the threshold signature recovered from the prevotes of the commit round. // Set from consensus version 2; empty before. Beacon []byte `json:"beacon,omitempty"` - // AppHash is the app hash the precommits sign: the result of ApplyBlockRandomness for this - // block and round. Set from consensus version 2; empty before. + // AppHash is the result of ApplyBlockRandomness for this block and round. The precommits sign it + // only through BlockID.StateID, the hash of the header's state ID with this app hash: the field + // itself is not signed. Set from consensus version 2; empty before. AppHash tmbytes.HexBytes `json:"app_hash,omitempty"` // Memoized in first call to corresponding method. @@ -947,8 +948,9 @@ func (commit *Commit) ValidateBasic() error { } // Neither field is covered by the commit hash or its threshold signature, so a peer can fill them - // in a commit it relays. Bounding them here refuses such a commit before it is stored or passed - // to the application, whatever the consensus version. + // in a commit it relays. Bounding them here refuses a commit with wrongly sized ones before it is + // stored or passed to the application, whatever the consensus version; before consensus version 2, + // nodes also drop well-sized ones where they adopt a commit (see WithoutRandomBeacon). if !validRandomBeaconSizes(commit.Beacon, commit.AppHash) { return fmt.Errorf("%w: beacon of %d bytes and app hash of %d bytes, expected both empty or %d and %d bytes", ErrInvalidCommitRandomness, len(commit.Beacon), len(commit.AppHash), SignatureSize, crypto.DefaultAppHashSize) From 003c02201c972fb8db438424ef65bcf6923baafb Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Thu, 5 Nov 2026 02:44:43 +0700 Subject: [PATCH 21/25] perf(types): allocate once in the tolerant block decoder The fallback allocated a copy of the whole block and one buffer per LastCommit occurrence before it knew whether anything had to be dropped. It now allocates nothing until the first field it drops, then writes everything into one buffer: 1 allocation instead of about 1M on 2 MiB of mistyped occurrences, and none when nothing is dropped. Varints are read with gogoproto's proto.DecodeVarint, which matches the generated code, instead of a copy of it. Co-Authored-By: Claude Opus 5.5 --- types/block_decode.go | 112 +++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/types/block_decode.go b/types/block_decode.go index 9d5bc017a6..4a00f9c458 100644 --- a/types/block_decode.go +++ b/types/block_decode.go @@ -43,61 +43,89 @@ func UnmarshalBlockProto(bz []byte) (*tmproto.Block, error) { // dropMistypedLastCommitRandomness returns the block bytes bz without the occurrences of the // LastCommit beacon and app hash fields that do not have the bytes wire type, and whether there were // any. It splits the bytes into fields as the generated decoder does, and returns false where that -// decoder fails. +// decoder fails. It allocates nothing before the first field it drops, and then only the bytes it +// returns. func dropMistypedLastCommitRandomness(bz []byte) ([]byte, bool) { - out := make([]byte, 0, len(bz)) - dropped := false - for len(bz) > 0 { - num, typ, n, ok := consumeGeneratedField(bz) + var out []byte + for i := 0; i < len(bz); { + num, typ, n, ok := consumeGeneratedField(bz[i:]) if !ok { return nil, false } - field := bz[:n] + field := bz[i : i+n] if num == blockLastCommitField && typ == protowire.BytesType { - _, tagLen, _ := consumeGeneratedVarint(field) - _, lenLen, _ := consumeGeneratedVarint(field[tagLen:]) - cleaned, ok := dropMistypedCommitRandomness(field[tagLen+lenLen:]) - if ok { - dropped = true - field = protowire.AppendBytes(protowire.AppendTag(nil, num, typ), cleaned) + _, tagLen := proto.DecodeVarint(field) + _, lenLen := proto.DecodeVarint(field[tagLen:]) + commit := field[tagLen+lenLen:] + if kept, ok := keptCommitLength(commit); ok && kept < len(commit) { + if out == nil { + out = append(make([]byte, 0, len(bz)), bz[:i]...) + } + out = protowire.AppendTag(out, num, typ) + out = protowire.AppendVarint(out, uint64(kept)) //nolint:gosec // a length, never negative + out = appendKeptCommitFields(out, commit) + i += n + continue } } - out = append(out, field...) + if out != nil { + out = append(out, field...) + } + i += n + } + return out, out != nil +} + +// keptCommitLength returns the length of the commit bytes bz without the beacon and app hash fields +// that do not have the bytes wire type, and false where the generated decoder fails. +func keptCommitLength(bz []byte) (int, bool) { + kept := 0 + for len(bz) > 0 { + num, typ, n, ok := consumeGeneratedField(bz) + if !ok { + return 0, false + } + if !mistypedCommitRandomness(num, typ) { + kept += n + } bz = bz[n:] } - return out, dropped + return kept, true } -// dropMistypedCommitRandomness returns the commit bytes bz without the beacon and app hash fields that -// do not have the bytes wire type, and whether there were any. -func dropMistypedCommitRandomness(bz []byte) ([]byte, bool) { - out := make([]byte, 0, len(bz)) - dropped := false +// appendKeptCommitFields appends to out the fields of the commit bytes bz that keptCommitLength +// counts. +func appendKeptCommitFields(out, bz []byte) []byte { for len(bz) > 0 { num, typ, n, ok := consumeGeneratedField(bz) if !ok { - return nil, false + break } - if (num == commitBeaconField || num == commitAppHashField) && typ != commitRandomnessWType { - dropped = true - } else { + if !mistypedCommitRandomness(num, typ) { out = append(out, bz[:n]...) } bz = bz[n:] } - return out, dropped + return out +} + +// mistypedCommitRandomness reports whether a commit field is a beacon or an app hash without the bytes +// wire type. +func mistypedCommitRandomness(num protowire.Number, typ protowire.Type) bool { + return (num == commitBeaconField || num == commitAppHashField) && typ != commitRandomnessWType } // consumeGeneratedField returns the number, the wire type and the length, tag included, of the field at // the start of bz, as the Unmarshal methods that gogoproto generates read a field they skip: the // field number is the tag shifted right by 3 and truncated to 32 bits. It returns false where those -// methods fail. +// methods fail. Varints are read with proto.DecodeVarint, which, like those methods and unlike +// protowire, drops the bits of a tenth byte past the 64th instead of failing. // // Releases before the beacon skip fields 7 and 8 of a commit with these rules, which accept more than // protowire does, so the bytes must be split with the same rules to drop exactly those fields. func consumeGeneratedField(bz []byte) (protowire.Number, protowire.Type, int, bool) { - tag, _, ok := consumeGeneratedVarint(bz) - if !ok { + tag, n := proto.DecodeVarint(bz) + if n == 0 { return 0, 0, 0, false } num, typ := protowire.Number(int32(tag>>3)), protowire.Type(tag&0x7) //nolint:gosec // truncated as generated code does @@ -118,24 +146,24 @@ func consumeGeneratedField(bz []byte) (protowire.Number, protowire.Type, int, bo func skipGeneratedField(bz []byte) (int, bool) { i, depth := 0, 0 for i < len(bz) { - tag, n, ok := consumeGeneratedVarint(bz[i:]) - if !ok { + tag, n := proto.DecodeVarint(bz[i:]) + if n == 0 { return 0, false } i += n switch protowire.Type(tag & 0x7) { case protowire.VarintType: - _, n, ok := consumeGeneratedVarint(bz[i:]) - if !ok { + _, n := proto.DecodeVarint(bz[i:]) + if n == 0 { return 0, false } i += n case protowire.Fixed64Type: i += 8 case protowire.BytesType: - length, n, ok := consumeGeneratedVarint(bz[i:]) + length, n := proto.DecodeVarint(bz[i:]) size := int(length) //nolint:gosec // wraps as the int length of generated code does - if !ok || size < 0 { + if n == 0 || size < 0 { return 0, false } i += n + size @@ -160,21 +188,3 @@ func skipGeneratedField(bz []byte) (int, bool) { } return 0, false } - -// consumeGeneratedVarint reads the varint at the start of bz as the code that gogoproto generates -// does, and returns it with its length. Unlike protowire, it drops the bits of a tenth byte past the -// 64th instead of failing. -func consumeGeneratedVarint(bz []byte) (uint64, int, bool) { - var v uint64 - for i, shift := 0, uint(0); shift < 64; i, shift = i+1, shift+7 { - if i >= len(bz) { - return 0, 0, false - } - b := bz[i] - v |= uint64(b&0x7F) << shift - if b < 0x80 { - return v, i + 1, true - } - } - return 0, 0, false -} From f494ed8d5b0d02357f71ceda959fb9d08a9159d3 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Thu, 5 Nov 2026 02:44:43 +0700 Subject: [PATCH 22/25] refactor(kvstore): look up ApplyBlockRandomness by block hash only Tenderdash always sends the block hash, so the height and round fallback for requests without one served only tests. ProcessProposal now records every block under its round and hash, and the lookup has one path. Co-Authored-By: Claude Opus 5.5 --- abci/example/kvstore/kvstore.go | 36 +++++++--------------------- abci/example/kvstore/kvstore_test.go | 2 +- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index 3a46484bb3..2b8d3075ac 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -397,10 +397,8 @@ func (app *Application) ProcessProposal(_ context.Context, req *abci.RequestProc Status: abci.ResponseProcessProposal_REJECT, }, err } - if len(req.Hash) > 0 { - block := processedBlock{round: req.Round, hash: string(req.Hash)} - app.processedBlocks[block] = roundKey(roundState.GetAppHash(), roundState.GetHeight(), roundState.GetRound()) - } + block := processedBlock{round: req.Round, hash: string(req.Hash)} + app.processedBlocks[block] = roundKey(roundState.GetAppHash(), roundState.GetHeight(), roundState.GetRound()) if req.Version.App != app.appVersionForHeight(req.Height) { app.logger.Error("app version mismatch in process proposal request", @@ -500,7 +498,7 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali } // ApplyBlockRandomness implements ABCI. The example application uses no randomness, so it returns -// the app hash of the state that PrepareProposal or ProcessProposal left for the block and round. +// the app hash of the state that ProcessProposal left for the block and round. func (app *Application) ApplyBlockRandomness(_ context.Context, req *abci.RequestApplyBlockRandomness) (*abci.ResponseApplyBlockRandomness, error) { app.mu.Lock() defer app.mu.Unlock() @@ -522,32 +520,14 @@ type processedBlock struct { } // processedRoundState returns the state ProcessProposal left for the block with the given hash at -// the given height and round. Without a hash, it returns the only state executed at that height and -// round, by PrepareProposal or ProcessProposal. +// the given height and round. // Caller should lock the Application. func (app *Application) processedRoundState(hash []byte, height int64, round int32) (State, error) { - if len(hash) > 0 { - key, ok := app.processedBlocks[processedBlock{round: round, hash: string(hash)}] - state := app.roundStates[key] - if !ok || state == nil || state.GetHeight() != height { - return nil, fmt.Errorf("block not processed at height %d round %d", height, round) - } - return state, nil - } - var found State - for _, state := range app.roundStates { - if state.GetHeight() != height || state.GetRound() != round { - continue - } - if found != nil { - return nil, fmt.Errorf("more than one proposal executed at height %d round %d", height, round) - } - found = state - } - if found == nil { - return nil, fmt.Errorf("no proposal executed at height %d round %d", height, round) + state := app.roundStates[app.processedBlocks[processedBlock{round: round, hash: string(hash)}]] + if state == nil || state.GetHeight() != height { + return nil, fmt.Errorf("block not processed at height %d round %d", height, round) } - return found, nil + return state, nil } // eventValUpdate generates an event that contains info about current validator set diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index 02f4a49075..43343a6c84 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -684,7 +684,7 @@ func TestApplyBlockRandomness(t *testing.T) { require.Equal(t, first.AppHash, again.AppHash) _, err = app.ApplyBlockRandomness(ctx, &types.RequestApplyBlockRandomness{Height: height, Round: 0}) - require.ErrorContains(t, err, "no proposal executed") + require.ErrorContains(t, err, "block not processed") } // TestApplyBlockRandomnessEquivocation is the regression test for a node that executed two blocks of From fef45324fee5b318fa17add5dd1f6c83addcac8e Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Thu, 5 Nov 2026 02:44:43 +0700 Subject: [PATCH 23/25] docs: document the commit beacon fields and ApplyBlockRandomness rules - spec/core/data_structures.md, consensus.md, consensus-commit.md: the Commit fields Beacon and AppHash, their size rule, and how a block's LastCommit with malformed ones is read. - Requirement 10 and the ABCI overviews: ApplyBlockRandomness must not modify the committed state, since it can run for rounds that never commit. - Commit.app_hash and CommitInfo.app_hash: the commit signs it only through its state ID. - ApplyBlockRandomness: this release defines consensus versions 0 and 1 only, so it never calls it. - UPGRADING.md: the new method, BaseApplication's error, ABCI 1.5.0, the commit size rule and routing with the routed transport. Co-Authored-By: Claude Opus 5.5 --- UPGRADING.md | 18 ++++++++++++++++++ abci/types/types.pb.go | 8 ++++++-- proto/tendermint/abci/types.proto | 8 ++++++-- proto/tendermint/types/types.pb.go | 12 +++++++----- proto/tendermint/types/types.proto | 12 +++++++----- spec/abci++/abci++_app_requirements.md | 6 ++++-- spec/abci++/abci++_basic_concepts.md | 10 ++++++---- spec/abci++/abci++_methods.md | 5 ++++- spec/abci++/abci++_tmint_expected_behavior.md | 2 ++ spec/abci++/api.md | 5 ++++- spec/consensus/consensus-commit.md | 3 ++- spec/consensus/consensus.md | 2 +- spec/core/data_structures.md | 4 +++- 13 files changed, 70 insertions(+), 25 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 100579551d..3cea871798 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -37,6 +37,24 @@ opening context or calling `Stop`/`Wait` alone does not close the head file. See [service lifecycle](docs/architecture/service-lifecycle.md) for ownership and migration boundaries. +### ABCI: ApplyBlockRandomness and commit beacon fields + +The ABCI version is 1.5.0. The `Application` interface and the gRPC `ABCIApplication` service gain +`ApplyBlockRandomness`, which hands the application a block's random beacon from consensus version 2. +This release defines consensus versions 0 and 1 only and never calls it. + +- Go applications that do not embed `abci/types.BaseApplication` must implement the method to + compile. `BaseApplication.ApplyBlockRandomness` returns `ErrApplyBlockRandomnessNotImplemented`, + not an empty response, so an application must implement it before its chain moves to consensus + version 2. +- With the routed ABCI transport, a method no routing rule names goes to the `*` client. Route + `ApplyBlockRandomness` to the client that runs `ProcessProposal`, since it answers for the state + `ProcessProposal` left. +- `Commit` and `CommitInfo` gain `beacon` and `app_hash`. At every consensus version, a commit whose + beacon and app hash are not both empty, or exactly 96 and 32 bytes, is refused, and a block's + last commit is read without malformed ones. Before consensus version 2, nodes drop well-sized ones + from the commits they adopt and from the last commit they pass to the application. + ### ABCI: commit vote-extension verification Tenderdash now calls `VerifyVoteExtension` after `ProcessProposal` and before it diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index af6ef23aaa..db4d23c6ed 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -2025,6 +2025,7 @@ func (m *RequestFinalizeBlock) GetBlockID() *types1.BlockID { // #### Usage // // - Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. +// This release defines consensus versions 0 and 1 only, so it never calls it. // - `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold // signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against // the quorum's threshold public key before the call. @@ -2043,6 +2044,8 @@ func (m *RequestFinalizeBlock) GetBlockID() *types1.BlockID { // and round MUST return the same `app_hash`. // - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return // the same `app_hash` each time. +// - It MUST NOT modify the committed state: Tenderdash may call it for a round that never commits, and +// `FinalizeBlock` commits the state for the commit round. // - An ABCI error is fatal, as for `ExtendVote`. // // #### When does Tenderdash call it? @@ -3615,8 +3618,9 @@ type CommitInfo struct { // Random beacon of the committed block: the threshold signature recovered from the prevotes of // the commit round. Set from consensus version 2; empty before. Beacon []byte `protobuf:"bytes,5,opt,name=beacon,proto3" json:"beacon,omitempty"` - // App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and - // round. Set from consensus version 2; empty before. + // App hash after `ApplyBlockRandomness` for the committed block and round. The commit signs it + // through the state ID of its block ID, which Tenderdash checks before passing it on. + // Set from consensus version 2; empty before. AppHash []byte `protobuf:"bytes,6,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index 43acabfc2d..2dae4d2351 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -574,6 +574,7 @@ message RequestFinalizeBlock { // #### Usage // // - Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. +// This release defines consensus versions 0 and 1 only, so it never calls it. // - `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold // signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against // the quorum's threshold public key before the call. @@ -592,6 +593,8 @@ message RequestFinalizeBlock { // and round MUST return the same `app_hash`. // - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return // the same `app_hash` each time. +// - It MUST NOT modify the committed state: Tenderdash may call it for a round that never commits, and +// `FinalizeBlock` commits the state for the commit round. // - An ABCI error is fatal, as for `ExtendVote`. // // #### When does Tenderdash call it? @@ -852,8 +855,9 @@ message CommitInfo { // Random beacon of the committed block: the threshold signature recovered from the prevotes of // the commit round. Set from consensus version 2; empty before. bytes beacon = 5; - // App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and - // round. Set from consensus version 2; empty before. + // App hash after `ApplyBlockRandomness` for the committed block and round. The commit signs it + // through the state ID of its block ID, which Tenderdash checks before passing it on. + // Set from consensus version 2; empty before. bytes app_hash = 6; } diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index cc51e0dbf0..0b1c83586e 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -692,13 +692,15 @@ type Commit struct { QuorumHash []byte `protobuf:"bytes,4,opt,name=quorum_hash,json=quorumHash,proto3" json:"quorum_hash,omitempty"` ThresholdBlockSignature []byte `protobuf:"bytes,5,opt,name=threshold_block_signature,json=thresholdBlockSignature,proto3" json:"threshold_block_signature,omitempty"` ThresholdVoteExtensions []*VoteExtension `protobuf:"bytes,6,rep,name=threshold_vote_extensions,json=thresholdVoteExtensions,proto3" json:"threshold_vote_extensions,omitempty"` - // Random beacon: the threshold signature recovered from the prevotes of the commit round. - // Set from consensus version 2; empty before. Neither this field nor app_hash is covered by the - // commit's signature: a commit is refused unless both are empty or they are exactly 96 and 32 + // Random beacon: the threshold signature recovered from the prevotes of the commit round, which + // verifies against their sign item and the quorum's threshold public key. + // Set from consensus version 2; empty before. The commit's signature covers neither this field + // nor app_hash as bytes: a commit is refused unless both are empty or they are exactly 96 and 32 // bytes, and a block's last commit is read without them when they are not. Beacon []byte `protobuf:"bytes,7,opt,name=beacon,proto3" json:"beacon,omitempty"` - // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. - // Set from consensus version 2; empty before. + // App hash returned by ApplyBlockRandomness for this block and round. The precommits sign it only + // through block_id.state_id, the hash of the block header's state ID with its app hash replaced by + // this one: trust this field only once that hash matches. Set from consensus version 2; empty before. AppHash []byte `protobuf:"bytes,8,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index 513e865884..524e4d339c 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -156,13 +156,15 @@ message Commit { bytes quorum_hash = 4; bytes threshold_block_signature = 5; repeated VoteExtension threshold_vote_extensions = 6; - // Random beacon: the threshold signature recovered from the prevotes of the commit round. - // Set from consensus version 2; empty before. Neither this field nor app_hash is covered by the - // commit's signature: a commit is refused unless both are empty or they are exactly 96 and 32 + // Random beacon: the threshold signature recovered from the prevotes of the commit round, which + // verifies against their sign item and the quorum's threshold public key. + // Set from consensus version 2; empty before. The commit's signature covers neither this field + // nor app_hash as bytes: a commit is refused unless both are empty or they are exactly 96 and 32 // bytes, and a block's last commit is read without them when they are not. bytes beacon = 7; - // App hash the precommits sign, returned by ApplyBlockRandomness for this block and round. - // Set from consensus version 2; empty before. + // App hash returned by ApplyBlockRandomness for this block and round. The precommits sign it only + // through block_id.state_id, the hash of the block header's state ID with its app hash replaced by + // this one: trust this field only once that hash matches. Set from consensus version 2; empty before. bytes app_hash = 8; } diff --git a/spec/abci++/abci++_app_requirements.md b/spec/abci++/abci++_app_requirements.md index e3065b5b29..922a382ee2 100644 --- a/spec/abci++/abci++_app_requirements.md +++ b/spec/abci++/abci++_app_requirements.md @@ -131,8 +131,10 @@ for the block can pass it. See [VerifyVoteExtension](./abci++_methods.md#verifyv Tenderdash does on each path when a commit is rejected. * Requirement 10 [_all_, no-side-effects]: $p$'s calls to `RequestPrepareProposal`, - `RequestProcessProposal`, `RequestExtendVote`, and `RequestVerifyVoteExtension` at height $h$ do - not modify $s_{p,h-1}$. + `RequestProcessProposal`, `RequestApplyBlockRandomness`, `RequestExtendVote`, and + `RequestVerifyVoteExtension` at height $h$ do not modify $s_{p,h-1}$. Tendermint may call + `RequestApplyBlockRandomness` for a round that never commits, so the randomized state it produces + stays a candidate until `FinalizeBlock` commits the one for the commit round. * Requirement 11 [`ExtendVote`, `FinalizeBlock`, non-dependency]: for any correct process $p$, and any vote extensions $e$ that $p$ received at height $h$, the computation of diff --git a/spec/abci++/abci++_basic_concepts.md b/spec/abci++/abci++_basic_concepts.md index c2efbabb0e..f74d9e5f79 100644 --- a/spec/abci++/abci++_basic_concepts.md +++ b/spec/abci++/abci++_basic_concepts.md @@ -42,7 +42,7 @@ The first time a new blockchain is started, Tendermint calls `InitChain`. From then on, method `FinalizeBlock` is executed at the end of each block, resulting in an updated Application state. During consensus execution of a block height, before method `FinalizeBlock` is -called, methods `PrepareProposal`, `ProcessProposal`, `ExtendVote`, and +called, methods `PrepareProposal`, `ProcessProposal`, `ApplyBlockRandomness`, `ExtendVote`, and `VerifyVoteExtension` may be called several times. See [Tendermint's expected behavior](abci++_tmint_expected_behavior.md) for details on the possible call sequences of these methods. @@ -66,6 +66,8 @@ SHOULD accept a prepared proposal passed via `ProcessProposal`, even if a part o the proposal is invalid (e.g., an invalid transaction); the Application can ignore the invalid part of the prepared proposal at block execution time. +* [**ApplyBlockRandomness:**](./abci++_methods.md#applyblockrandomness) From consensus version 2, it hands the Application the random beacon of a block and round, recovered from the Prevotes, and the Application applies it to the candidate state that `ProcessProposal` left for that block and round. Tendermint calls it before `ExtendVote` and before signing a Precommit for the block, and may call it for rounds that never commit, so it must not modify the committed state. + * [**ExtendVote:**](./abci++_methods.md#extendvote) It allows applications to force their validators to do more than just validate within consensus. `ExtendVote` allows applications to include deterministic and non-deterministic data, opaque to Tendermint, to precommit messages (the final round of voting. The data, called _vote extensions_, will also be made available to the application in the next height, along with the vote it is extending, in the rounds @@ -210,9 +212,9 @@ transactions and compute the same results. Some Applications may choose to execute the blocks that are about to be proposed (via `PrepareProposal`), or those that the Application is asked to validate -(via `ProcessProposal`). However, the state changes caused by processing those -proposed blocks must never replace the previous state until `FinalizeBlock` and `Commit` confirms -the block decided. +(via `ProcessProposal`), and apply their randomness (via `ApplyBlockRandomness`). However, the +state changes caused by processing those proposed blocks must never replace the previous state +until `FinalizeBlock` and `Commit` confirms the block decided. Additionally, vote extensions or the validation thereof (via `ExtendVote` or `VerifyVoteExtension`) must _never_ have side effects on the current state. diff --git a/spec/abci++/abci++_methods.md b/spec/abci++/abci++_methods.md index 82cf2affc6..e1c941931d 100644 --- a/spec/abci++/abci++_methods.md +++ b/spec/abci++/abci++_methods.md @@ -607,6 +607,7 @@ block. This includes commits the process assembled from its own +2/3 precommits. * **Usage**: * Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. + This release defines consensus versions 0 and 1 only, so it never calls it. * The beacon is the BLS threshold signature recovered from the Prevotes of round `round` for block `hash`. Every set of threshold shares recovers the same bytes, and nobody can compute them before the Prevotes exist. Tenderdash verifies the beacon against the quorum's threshold public key before the call. @@ -624,6 +625,8 @@ block. This includes commits the process assembled from its own +2/3 precommits. see [ExtendVote](#extendvote). * The implementation MUST be deterministic, and MUST return the same `app_hash` when called again for the same block, round and beacon. + * It MUST NOT modify the committed state: Tenderdash may call it for a round that never commits, and + `FinalizeBlock` commits the state for the commit round. * An ABCI error is fatal, as for `ExtendVote`. #### When does Tenderdash call it? @@ -871,7 +874,7 @@ enum VoteExtensionType { | block_signature | bytes | Block signature. | 3 | | threshold_vote_extensions | repeated [VoteExtension](../../proto/tendermint/types/dash.proto) | Threshold-recovered vote extensions of the commit. | 4 | | beacon | bytes | Random beacon of the commit round. Set from consensus version 2; empty before. | 5 | - | app_hash | bytes | App hash the commit signs, returned by `ApplyBlockRandomness`. From consensus version 2. | 6 | + | app_hash | bytes | App hash returned by `ApplyBlockRandomness`, which the commit signs through the state ID of its block ID. Set from consensus version 2; empty before. | 6 | ### ExtendedCommitInfo diff --git a/spec/abci++/abci++_tmint_expected_behavior.md b/spec/abci++/abci++_tmint_expected_behavior.md index c4fb398ddb..3d55af54ae 100644 --- a/spec/abci++/abci++_tmint_expected_behavior.md +++ b/spec/abci++/abci++_tmint_expected_behavior.md @@ -235,6 +235,8 @@ As for the new methods: (`RequestPrepareProposal.max_tx_bytes`). If so, the Application must remove transactions at the end of the list until the total byte size is at or below the limit. * `ProcessProposal` must set `ResponseProcessProposal.accept` to _true_ and return. +* `ApplyBlockRandomness`, which uses no randomness in a legacy application, is to return the app hash + that `ProcessProposal` returned for the block and round, without changing any state. * `ExtendVote` is to set `ResponseExtendVote.extension` to an empty byte array and return. * `VerifyVoteExtension` must set `ResponseVerifyVoteExtension.status` to `ACCEPT` if the extension list is empty and to `REJECT` otherwise, then return. This holds for commit verification too diff --git a/spec/abci++/api.md b/spec/abci++/api.md index 6dcba074a2..9bc06eda83 100644 --- a/spec/abci++/api.md +++ b/spec/abci++/api.md @@ -90,7 +90,7 @@ | block_signature | [bytes](#bytes) | | | | threshold_vote_extensions | [tendermint.types.VoteExtension](#tendermint-types-VoteExtension) | repeated | | | beacon | [bytes](#bytes) | | Random beacon of the committed block: the threshold signature recovered from the prevotes of the commit round. Set from consensus version 2; empty before. | -| app_hash | [bytes](#bytes) | | App hash the commit signs: the result of `ApplyBlockRandomness` for the committed block and round. Set from consensus version 2; empty before. | +| app_hash | [bytes](#bytes) | | App hash after `ApplyBlockRandomness` for the committed block and round. The commit signs it through the state ID of its block ID, which Tenderdash checks before passing it on. Set from consensus version 2; empty before. | @@ -271,6 +271,7 @@ Applies the block's randomness and returns the app hash the Precommit signs. #### Usage - Used from consensus version 2 (`VersionParams.consensus_version`). Before that, Tenderdash never calls it. + This release defines consensus versions 0 and 1 only, so it never calls it. - `RequestApplyBlockRandomness.beacon` is the random beacon of the block and round: the 96-byte BLS threshold signature recovered from the Prevotes of round `round` for the block `hash`. Tenderdash has verified it against the quorum's threshold public key before the call. @@ -289,6 +290,8 @@ Applies the block's randomness and returns the app hash the Precommit signs. and round MUST return the same `app_hash`. - Tenderdash may call it more than once for the same block, round and beacon; the Application MUST return the same `app_hash` each time. +- It MUST NOT modify the committed state: Tenderdash may call it for a round that never commits, and + `FinalizeBlock` commits the state for the commit round. - An ABCI error is fatal, as for `ExtendVote`. #### When does Tenderdash call it? diff --git a/spec/consensus/consensus-commit.md b/spec/consensus/consensus-commit.md index 6fa6708e15..23d266fa14 100644 --- a/spec/consensus/consensus-commit.md +++ b/spec/consensus/consensus-commit.md @@ -5,7 +5,8 @@ order: 6 # Commit handling A *commit* for height `h` is `(Height, Round, BlockID, QuorumHash, -ThresholdBlockSignature, ThresholdVoteExtensions)` (`types.Commit`). A node +ThresholdBlockSignature, ThresholdVoteExtensions, Beacon, AppHash)` (`types.Commit`); Beacon and +AppHash are set from consensus version 2 and are not covered by the signature. A node obtains one in two ways: 1. **locally**, from its own precommit vote set once the threshold signature diff --git a/spec/consensus/consensus.md b/spec/consensus/consensus.md index 02ea72e485..f242273423 100644 --- a/spec/consensus/consensus.md +++ b/spec/consensus/consensus.md @@ -67,7 +67,7 @@ numbers are omitted because they drift. | **POLRound** | The round whose polka a proposal claims as justification; `-1` when the proposal claims none. | `types.Proposal.POLRound` | | **BlockID** | `(Hash, PartSetHeader, StateID)`. Nil block id = all three empty. | `types/block.go`, `types/block_meta.go` | | **StateID** | Hash of `{AppVersion, Height, AppHash, CoreChainLockedHeight, Time}` of the block header; the app hash is the state **after** executing that block (same-block execution). | `Header.StateID` in `types/block.go` | -| **Commit** | `(Height, Round, BlockID, QuorumHash, ThresholdBlockSignature, ThresholdVoteExtensions)`: a single aggregate BLS threshold signature plus one threshold signature per threshold-recoverable vote extension. There are no per-validator signatures in a commit. | `types.Commit` in `types/block.go` | +| **Commit** | `(Height, Round, BlockID, QuorumHash, ThresholdBlockSignature, ThresholdVoteExtensions, Beacon, AppHash)`: a single aggregate BLS threshold signature plus one threshold signature per threshold-recoverable vote extension. There are no per-validator signatures in a commit. Beacon and AppHash, set from consensus version 2, are not covered by the signature; before it, nodes drop them where they adopt a commit. | `types.Commit` in `types/block.go` | | **Locked block / round** | The block the node precommitted most recently and the round it did so; `-1`/nil when none. | `RoundState.LockedRound/LockedBlock` | | **Valid block / round** | The most recent block (and round) for which the node saw a polka in a round `≥` any previous one. | `RoundState.ValidRound/ValidBlock` | | **CurrentRoundState** | The application's answer to the latest `PrepareProposal`/`ProcessProposal` for the block held in `ProposalBlock`, tagged with the round it was processed for. | `RoundState.CurrentRoundState`, `RoundState.ProcessedBlockID`; `processedFor` in `internal/consensus/block_executor.go` | diff --git a/spec/core/data_structures.md b/spec/core/data_structures.md index 8befeb340f..4e1cdd03df 100644 --- a/spec/core/data_structures.md +++ b/spec/core/data_structures.md @@ -55,7 +55,7 @@ and a list of evidence of malfeasance (ie. signing conflicting votes). | Header | [Header](#header) | Header corresponding to the block. This field contains information used throughout consensus and other areas of the protocol. To find out what it contains, visit [header] (#header) | Must adhere to the validation rules of [header](#header) | | Data | [Data](#data) | Data contains a list of transactions. The contents of the transaction is unknown to Tendermint. | This field can be empty or populated, but no validation is performed. Applications can perform validation on individual transactions prior to block creation using [checkTx](../abci/abci.md#checktx). | | Evidence | [EvidenceList](#evidencelist) | Evidence contains a list of infractions committed by validators. | Can be empty, but when populated the validations rules from [evidenceList](#evidencelist) apply | -| LastCommit | [Commit](#commit) | The threshold-signed commit of the previous block. | Must not be nil, must carry no threshold block signature at the initial height, and must adhere to the validation rules of [commit](#commit). | +| LastCommit | [Commit](#commit) | The threshold-signed commit of the previous block. | Must not be nil, must carry no threshold block signature at the initial height, and must adhere to the validation rules of [commit](#commit), except for Beacon and AppHash: a LastCommit whose Beacon or AppHash breaks their rule, or does not have the bytes wire type, is read without both instead of refused, as releases that do not know the fields skip them. | | CoreChainLock | `CoreChainLock` (optional) | Core chain lock carried by the block. | When present, must pass `CoreChainLock.ValidateBasic`. | ## Execution @@ -207,6 +207,8 @@ Commit proves that a quorum decided a block: it carries the threshold-recovered | QuorumHash | slice of bytes (`[]byte`) | Hash of the quorum that signed the commit. | | | ThresholdBlockSignature | [Signature](#signature) | Threshold-recovered block signature. | At height >= 1, must be of length 96 | | ThresholdVoteExtensions | Array of [VoteExtension](#voteextension) | Threshold-recovered vote extensions. | No nil entries; every type must be a defined enum value | +| Beacon | slice of bytes (`[]byte`) | Random beacon: the threshold signature recovered from the prevotes of the commit round. Set from consensus version 2; empty before. Not covered by the commit's signature. | Must be empty with an empty AppHash, or 96 bytes with a 32-byte AppHash | +| AppHash | slice of bytes (`[]byte`) | App hash returned by `ApplyBlockRandomness` for the block and round, which the precommits sign through `BlockID.StateID`. Set from consensus version 2; empty before. Not covered by the commit's signature. | Must be empty with an empty Beacon, or 32 bytes with a 96-byte Beacon | ## BlockIDFlag From cd6b4ec820ee29fd5ca39f36f5ce5c2981f40d83 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Sat, 7 Nov 2026 00:28:23 +0700 Subject: [PATCH 24/25] fix(store): keep unsigned randomness out of the canonical commit Nothing signs the beacon and app hash of a block's LastCommit, so a proposer can fill them with well-sized values. SaveBlock stored them as the canonical commit of the previous height, and LoadBlockCommit then served them through /commit and state sync. Drop them from that record. The block's parts keep them, as the encoding the next commit signs. Co-Authored-By: Claude Opus 5.5 --- UPGRADING.md | 3 ++- internal/store/store.go | 4 +++- internal/store/store_test.go | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index b845d5504d..7d78eb5b9d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -86,7 +86,8 @@ This release defines consensus versions 0 and 1 only and never calls it. - `Commit` and `CommitInfo` gain `beacon` and `app_hash`. At every consensus version, a commit whose beacon and app hash are not both empty, or exactly 96 and 32 bytes, is refused, and a block's last commit is read without malformed ones. Before consensus version 2, nodes drop well-sized ones - from the commits they adopt and from the last commit they pass to the application. + from the commits they adopt, from the previous height's commit they store from a block, and from the + last commit they pass to the application. ### ABCI: commit vote-extension verification diff --git a/internal/store/store.go b/internal/store/store.go index 29d6799d82..7eb8cad09c 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -602,7 +602,9 @@ func (bs *BlockStore) saveBlockToBatch(batch dbm.Batch, block *types.Block, bloc return err } - pbc := block.LastCommit.ToProto() + // Nothing signs the beacon and app hash of block.LastCommit, so a proposer can fill them. The block's + // parts keep them, as the encoding the next commit signs, but they are not the previous height's commit. + pbc := block.LastCommit.WithoutRandomBeacon().ToProto() blockCommitBytes := mustEncode(pbc) if err := batch.Set(blockCommitKey(height-1), blockCommitBytes); err != nil { return err diff --git a/internal/store/store_test.go b/internal/store/store_test.go index f5d4add5ba..d61dcd2329 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -1,6 +1,7 @@ package store import ( + "bytes" "context" "fmt" "os" @@ -620,3 +621,38 @@ func TestLoadBlockMistypedLastCommitRandomness(t *testing.T) { require.NotNil(t, loaded) require.Equal(t, block.Hash(), loaded.Hash()) } + +// TestSaveBlockDropsLastCommitRandomness is the regression test for a proposer that fills the beacon +// and app hash of its block's LastCommit, which nothing signs: they were stored as the canonical +// commit of the previous height, and served from there. The block's parts keep them, as the encoding +// the next commit signs. +func TestSaveBlockDropsLastCommitRandomness(t *testing.T) { + state, bs := makeStateAndBlockStore(t, t.TempDir()) + const height = int64(2) + state.LastBlockHeight = height - 1 + + lastCommit := makeTestCommit(t, state, height-1) + lastCommit.Beacon = bytes.Repeat([]byte{0x01}, types.SignatureSize) + lastCommit.AppHash = bytes.Repeat([]byte{0x02}, crypto.DefaultAppHashSize) + block, err := factory.MakeBlock(state, height, lastCommit, 0) + require.NoError(t, err) + parts, err := block.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + + bs.SaveBlock(block, parts, makeTestCommit(t, state, height)) + + canonical := bs.LoadBlockCommit(height - 1) + require.NotNil(t, canonical) + require.Empty(t, canonical.Beacon) + require.Empty(t, canonical.AppHash) + require.Equal(t, lastCommit.Hash(), canonical.Hash()) + + for i := 0; i < int(parts.Total()); i++ { + require.Equal(t, parts.GetPart(i).Bytes, bs.LoadBlockPart(height, i).Bytes) + } + loaded := bs.LoadBlock(height) + require.NotNil(t, loaded) + require.Equal(t, lastCommit.Beacon, loaded.LastCommit.Beacon) + require.Equal(t, lastCommit.AppHash, loaded.LastCommit.AppHash) + require.NotEmpty(t, block.LastCommit.Beacon, "saving must not change the block") +} From 1b1713022ed63912e7dd38ba12c4be9d2de48c30 Mon Sep 17 00:00:00 2001 From: QuantumExplorer Date: Sat, 7 Nov 2026 00:31:07 +0700 Subject: [PATCH 25/25] fix(store): keep a verified beacon in the canonical commit The base branch drops the beacon and app hash of block.LastCommit from the stored previous-height commit, since nothing signs them. From consensus version 2 that record has to keep them for /commit and state sync. Keep them only when they match the commit this node saved for that height, which holds for no pre-version-2 commit and for every block validateBlock accepted after. Co-Authored-By: Claude Opus 5.5 --- internal/store/store.go | 22 +++++++++++++++--- internal/store/store_test.go | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/internal/store/store.go b/internal/store/store.go index 7eb8cad09c..bcadf2e070 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -602,9 +602,7 @@ func (bs *BlockStore) saveBlockToBatch(batch dbm.Batch, block *types.Block, bloc return err } - // Nothing signs the beacon and app hash of block.LastCommit, so a proposer can fill them. The block's - // parts keep them, as the encoding the next commit signs, but they are not the previous height's commit. - pbc := block.LastCommit.WithoutRandomBeacon().ToProto() + pbc := bs.canonicalLastCommit(block).ToProto() blockCommitBytes := mustEncode(pbc) if err := batch.Set(blockCommitKey(height-1), blockCommitBytes); err != nil { return err @@ -625,6 +623,24 @@ func (bs *BlockStore) saveBlockToBatch(batch dbm.Batch, block *types.Block, bloc return nil } +// canonicalLastCommit returns the commit SaveBlock stores for the previous height. Nothing signs the +// beacon and app hash of block.LastCommit, so a proposer can fill them, and validateBlock checks them +// only when the last block was committed with a beacon. So they are kept only when they are the ones in +// the commit this node saved for that height; before consensus version 2 that commit has neither. The +// block's parts keep them either way, as the encoding the next commit signs. +func (bs *BlockStore) canonicalLastCommit(block *types.Block) *types.Commit { + commit := block.LastCommit + if commit == nil || (len(commit.Beacon) == 0 && len(commit.AppHash) == 0) { + return commit + } + seen := bs.LoadSeenCommit() + if seen != nil && seen.Height == commit.Height && + bytes.Equal(seen.Beacon, commit.Beacon) && bytes.Equal(seen.AppHash, commit.AppHash) { + return commit + } + return commit.WithoutRandomBeacon() +} + func (bs *BlockStore) saveBlockPart(height int64, index int, part *types.Part, batch dbm.Batch) { pbp, err := part.ToProto() if err != nil { diff --git a/internal/store/store_test.go b/internal/store/store_test.go index d61dcd2329..2b6b59a360 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -656,3 +656,48 @@ func TestSaveBlockDropsLastCommitRandomness(t *testing.T) { require.Equal(t, lastCommit.AppHash, loaded.LastCommit.AppHash) require.NotEmpty(t, block.LastCommit.Beacon, "saving must not change the block") } + +// TestSaveBlockKeepsSeenLastCommitRandomness checks the canonical commit from consensus version 2: it +// keeps a beacon and app hash that match the commit this node saved for that height, and drops others. +func TestSaveBlockKeepsSeenLastCommitRandomness(t *testing.T) { + beacon := bytes.Repeat([]byte{0x01}, types.SignatureSize) + appHash := bytes.Repeat([]byte{0x02}, crypto.DefaultAppHashSize) + forged := bytes.Repeat([]byte{0x03}, types.SignatureSize) + + testCases := []struct { + name string + lastBeacon []byte + expectedBeacon []byte + expectedApp []byte + }{ + {name: "matches the seen commit", lastBeacon: beacon, expectedBeacon: beacon, expectedApp: appHash}, + {name: "differs from the seen commit", lastBeacon: forged}, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + state, bs := makeStateAndBlockStore(t, t.TempDir()) + + first, err := factory.MakeBlock(state, 1, new(types.Commit), 0) + require.NoError(t, err) + firstParts, err := first.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + seen := makeTestCommit(t, state, 1) + seen.Beacon, seen.AppHash = beacon, appHash + bs.SaveBlock(first, firstParts, seen) + + state.LastBlockHeight = 1 + lastCommit := makeTestCommit(t, state, 1) + lastCommit.Beacon, lastCommit.AppHash = tc.lastBeacon, appHash + second, err := factory.MakeBlock(state, 2, lastCommit, 0) + require.NoError(t, err) + secondParts, err := second.MakePartSet(types.BlockPartSizeBytes) + require.NoError(t, err) + bs.SaveBlock(second, secondParts, makeTestCommit(t, state, 2)) + + canonical := bs.LoadBlockCommit(1) + require.NotNil(t, canonical) + require.EqualValues(t, tc.expectedBeacon, canonical.Beacon) + require.EqualValues(t, tc.expectedApp, canonical.AppHash) + }) + } +}