From 5a4a56a781215bb28d1b420f3cf782085fbf2348 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Tue, 8 Jun 2021 18:26:35 +0200 Subject: [PATCH] abciresponse, blok events, indexer, some tests --- consensus/replay_test.go | 2 +- proto/tendermint/state/types.pb.go | 249 +++++++-------------------- proto/tendermint/state/types.proto | 4 +- state/execution.go | 63 +++---- state/helpers_test.go | 13 +- state/indexer/block/kv/kv.go | 7 +- state/indexer/block/kv/kv_test.go | 40 +---- state/indexer/sink/kv/kv_test.go | 41 +---- state/indexer/sink/psql/psql.go | 11 +- state/indexer/sink/psql/psql_test.go | 18 +- state/store.go | 6 +- types/events.go | 8 +- types/tx.go | 11 ++ 13 files changed, 120 insertions(+), 353 deletions(-) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index e7290d6cb..8bc360454 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -650,7 +650,7 @@ func TestMockProxyApp(t *testing.T) { mock.SetResponseCallback(proxyCb) someTx := []byte("tx") - _, err = mock.DeliverTxAsync(context.Background(), abci.RequestDeliverTx{Tx: someTx}) + _, err = mock.FinalizeBlockAsync(context.Background(), abci.RequestFinalizeBlock{Txs: [][]byte{someTx}}) assert.NoError(t, err) }) assert.True(t, validTxs == 1) diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index 85f38cada..af5c64ecf 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -34,9 +34,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // of the various ABCI calls during block processing. // It is persisted to disk for each height before calling Commit. type ABCIResponses struct { - DeliverTxs []*types.ResponseDeliverTx `protobuf:"bytes,1,rep,name=deliver_txs,json=deliverTxs,proto3" json:"deliver_txs,omitempty"` - EndBlock *types.ResponseEndBlock `protobuf:"bytes,2,opt,name=end_block,json=endBlock,proto3" json:"end_block,omitempty"` - BeginBlock *types.ResponseBeginBlock `protobuf:"bytes,3,opt,name=begin_block,json=beginBlock,proto3" json:"begin_block,omitempty"` + FinalizeBlock *types.ResponseFinalizeBlock `protobuf:"bytes,2,opt,name=finalize_block,json=finalizeBlock,proto3" json:"finalize_block,omitempty"` } func (m *ABCIResponses) Reset() { *m = ABCIResponses{} } @@ -72,23 +70,9 @@ func (m *ABCIResponses) XXX_DiscardUnknown() { var xxx_messageInfo_ABCIResponses proto.InternalMessageInfo -func (m *ABCIResponses) GetDeliverTxs() []*types.ResponseDeliverTx { +func (m *ABCIResponses) GetFinalizeBlock() *types.ResponseFinalizeBlock { if m != nil { - return m.DeliverTxs - } - return nil -} - -func (m *ABCIResponses) GetEndBlock() *types.ResponseEndBlock { - if m != nil { - return m.EndBlock - } - return nil -} - -func (m *ABCIResponses) GetBeginBlock() *types.ResponseBeginBlock { - if m != nil { - return m.BeginBlock + return m.FinalizeBlock } return nil } @@ -422,55 +406,52 @@ func init() { func init() { proto.RegisterFile("tendermint/state/types.proto", fileDescriptor_ccfacf933f22bf93) } var fileDescriptor_ccfacf933f22bf93 = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x6f, 0xd3, 0x30, - 0x14, 0x6e, 0xe8, 0xb6, 0xb6, 0xce, 0xda, 0x0e, 0x8f, 0x43, 0xd6, 0xb1, 0xb4, 0x2b, 0x3f, 0x34, - 0x71, 0x48, 0xa5, 0x71, 0x40, 0x5c, 0x26, 0x2d, 0x2d, 0x62, 0x95, 0x26, 0x04, 0xd9, 0xb4, 0x03, - 0x97, 0xc8, 0x6d, 0xbc, 0x24, 0xa2, 0x4d, 0xa2, 0xd8, 0x2d, 0xe3, 0x0f, 0xe0, 0xbe, 0x2b, 0xff, - 0xd1, 0x8e, 0x3b, 0x22, 0x0e, 0x03, 0xba, 0x7f, 0x04, 0xd9, 0xce, 0x0f, 0xb7, 0x65, 0xd2, 0x10, - 0x37, 0xfb, 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0xe1, 0x8f, 0xb5, 0x9d, 0x37, 0x76, 0x9e, 0x9d, 0xb4, 0xf8, 0x5f, - 0xc7, 0x0c, 0xfc, 0xe7, 0x98, 0xbd, 0x03, 0x4f, 0xe7, 0xc6, 0x6c, 0x41, 0x3f, 0xb3, 0xa7, 0x72, - 0x7b, 0x2d, 0x69, 0xee, 0xe6, 0x85, 0x52, 0x8f, 0x69, 0x23, 0xc6, 0x98, 0x4c, 0x46, 0x94, 0xd8, - 0x1e, 0x22, 0x9e, 0xb6, 0xde, 0x52, 0xf6, 0xd6, 0x45, 0x23, 0x5a, 0x22, 0x7e, 0x84, 0x88, 0x07, - 0xb7, 0x40, 0x19, 0x45, 0x91, 0xa0, 0x54, 0x39, 0xa5, 0x84, 0xa2, 0x88, 0x41, 0xe6, 0x87, 0xab, - 0x99, 0xae, 0x5c, 0xcf, 0x74, 0xe5, 0xd7, 0x4c, 0x57, 0x2e, 0x6f, 0xf5, 0xc2, 0xf5, 0xad, 0x5e, - 0xf8, 0x7e, 0xab, 0x17, 0x3e, 0xbe, 0x72, 0x7d, 0xea, 0x4d, 0x06, 0xc6, 0x30, 0x1c, 0x77, 0xe4, - 0x3f, 0x25, 0x5f, 0x8a, 0x8f, 0x6d, 0xf1, 0x4b, 0x1c, 0xac, 0xf1, 0xf8, 0xcb, 0x3f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xa5, 0x17, 0xac, 0x23, 0x2d, 0x07, 0x00, 0x00, + // 717 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x6f, 0xd3, 0x4a, + 0x14, 0x8d, 0x5f, 0x3f, 0x92, 0x4c, 0x9a, 0xa4, 0x6f, 0xfa, 0x16, 0x69, 0xfa, 0xea, 0xe4, 0x45, + 0x8f, 0xaa, 0x62, 0xe1, 0x48, 0xb0, 0x40, 0x6c, 0x90, 0x9a, 0x54, 0x50, 0x4b, 0x05, 0x81, 0x8b, + 0xba, 0x60, 0x81, 0x35, 0x71, 0x26, 0xf6, 0x08, 0xc7, 0xb6, 0x3c, 0x93, 0xf2, 0xb1, 0x67, 0xdf, + 0x2d, 0xff, 0xa8, 0xcb, 0x2e, 0x59, 0x15, 0x48, 0xff, 0x08, 0x9a, 0x0f, 0xdb, 0x93, 0x84, 0x45, + 0x11, 0xbb, 0xcc, 0x3d, 0xe7, 0x9e, 0x7b, 0xe6, 0xce, 0xbd, 0x31, 0xf8, 0x97, 0xe1, 0x68, 0x8c, + 0xd3, 0x29, 0x89, 0x58, 0x9f, 0x32, 0xc4, 0x70, 0x9f, 0x7d, 0x4c, 0x30, 0xb5, 0x92, 0x34, 0x66, + 0x31, 0xdc, 0x2e, 0x50, 0x4b, 0xa0, 0xed, 0x7f, 0xfc, 0xd8, 0x8f, 0x05, 0xd8, 0xe7, 0xbf, 0x24, + 0xaf, 0xbd, 0xa7, 0xa9, 0xa0, 0x91, 0x47, 0x74, 0x91, 0xb6, 0x5e, 0x42, 0xc4, 0x17, 0xd0, 0xee, + 0x0a, 0x7a, 0x81, 0x42, 0x32, 0x46, 0x2c, 0x4e, 0x15, 0x63, 0x7f, 0x85, 0x91, 0xa0, 0x14, 0x4d, + 0x33, 0x01, 0x53, 0x83, 0x2f, 0x70, 0x4a, 0x49, 0x1c, 0x2d, 0x14, 0xe8, 0xf8, 0x71, 0xec, 0x87, + 0xb8, 0x2f, 0x4e, 0xa3, 0xd9, 0xa4, 0xcf, 0xc8, 0x14, 0x53, 0x86, 0xa6, 0x89, 0x24, 0xf4, 0xde, + 0x82, 0xfa, 0xd1, 0x60, 0x68, 0x3b, 0x98, 0x26, 0x71, 0x44, 0x31, 0x85, 0xcf, 0x41, 0x63, 0x42, + 0x22, 0x14, 0x92, 0x4f, 0xd8, 0x1d, 0x85, 0xb1, 0xf7, 0xae, 0xf5, 0x57, 0xd7, 0x38, 0xac, 0x3d, + 0x38, 0xb0, 0xb4, 0x76, 0xf0, 0x6b, 0x5a, 0x59, 0xce, 0x53, 0x45, 0x1f, 0x70, 0xb6, 0x53, 0x9f, + 0xe8, 0xc7, 0xde, 0x67, 0x03, 0x34, 0xce, 0xb3, 0x3b, 0x51, 0x3b, 0x9a, 0xc4, 0x70, 0x08, 0xea, + 0xf9, 0x2d, 0x5d, 0x8a, 0x59, 0xcb, 0x10, 0x05, 0x4c, 0xbd, 0x80, 0xbc, 0x43, 0x9e, 0x78, 0x86, + 0x99, 0xb3, 0x75, 0xa1, 0x9d, 0xa0, 0x05, 0x76, 0x42, 0x44, 0x99, 0x1b, 0x60, 0xe2, 0x07, 0xcc, + 0xf5, 0x02, 0x14, 0xf9, 0x78, 0x2c, 0xbc, 0xae, 0x39, 0x7f, 0x73, 0xe8, 0x44, 0x20, 0x43, 0x09, + 0xf4, 0xbe, 0x18, 0x60, 0x67, 0xc8, 0xdd, 0x46, 0x74, 0x46, 0x5f, 0x8a, 0x16, 0x0a, 0x33, 0x0e, + 0xd8, 0xf6, 0xb2, 0xb0, 0x2b, 0x5b, 0xab, 0xfc, 0xfc, 0xb7, 0xea, 0x67, 0x49, 0x60, 0xb0, 0x7e, + 0x75, 0xd3, 0x29, 0x39, 0x4d, 0x6f, 0x31, 0xfc, 0xdb, 0xde, 0x02, 0x50, 0x3e, 0x97, 0x6f, 0x07, + 0x8f, 0x40, 0x35, 0x57, 0x53, 0x3e, 0xf6, 0x75, 0x1f, 0xea, 0x8d, 0x0b, 0x27, 0xca, 0x43, 0x91, + 0x05, 0xdb, 0xa0, 0x42, 0xe3, 0x09, 0x7b, 0x8f, 0x52, 0x2c, 0x4a, 0x56, 0x9d, 0xfc, 0xdc, 0xfb, + 0xb1, 0x09, 0x36, 0xce, 0xf8, 0x28, 0xc3, 0xc7, 0xa0, 0xac, 0xb4, 0x54, 0x99, 0x5d, 0x6b, 0x79, + 0xdc, 0x2d, 0x65, 0x4a, 0x95, 0xc8, 0xf8, 0xf0, 0x00, 0x54, 0xbc, 0x00, 0x91,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0x06, 0xfe, 0x70, 0xcd, 0x5e, 0x80, 0xff, 0x17, 0xd6, 0x6c, 0x49, 0x3f, 0xb7, 0x57, + 0x13, 0xf6, 0xba, 0xda, 0xde, 0x2d, 0x0a, 0x65, 0x1e, 0xb3, 0x41, 0x4c, 0x31, 0x9d, 0x85, 0x8c, + 0xba, 0x01, 0xa2, 0x41, 0x6b, 0xab, 0x6b, 0x1c, 0x6e, 0xc9, 0x41, 0x74, 0x64, 0xfc, 0x04, 0xd1, + 0x00, 0xee, 0x82, 0x0a, 0x4a, 0x12, 0x49, 0xa9, 0x0b, 0x4a, 0x19, 0x25, 0x09, 0x87, 0x06, 0xaf, + 0xae, 0xe6, 0xa6, 0x71, 0x3d, 0x37, 0x8d, 0xef, 0x73, 0xd3, 0xb8, 0xbc, 0x35, 0x4b, 0xd7, 0xb7, + 0x66, 0xe9, 0xeb, 0xad, 0x59, 0x7a, 0xf3, 0xc8, 0x27, 0x2c, 0x98, 0x8d, 0x2c, 0x2f, 0x9e, 0xf6, + 0xf5, 0xbf, 0xf5, 0xe2, 0xa7, 0xfc, 0xb6, 0x2c, 0x7f, 0x95, 0x46, 0x9b, 0x22, 0xfe, 0xf0, 0x67, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0xe8, 0x4c, 0x4d, 0xb0, 0x06, 0x00, 0x00, } func (m *ABCIResponses) Marshal() (dAtA []byte, err error) { @@ -493,21 +474,9 @@ func (m *ABCIResponses) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.BeginBlock != nil { + if m.FinalizeBlock != nil { { - size, err := m.BeginBlock.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.EndBlock != nil { - { - size, err := m.EndBlock.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.FinalizeBlock.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -517,20 +486,6 @@ func (m *ABCIResponses) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.DeliverTxs) > 0 { - for iNdEx := len(m.DeliverTxs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DeliverTxs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } return len(dAtA) - i, nil } @@ -747,12 +702,12 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 } - n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) - if err10 != nil { - return 0, err10 + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) + if err9 != nil { + return 0, err9 } - i -= n10 - i = encodeVarintTypes(dAtA, i, uint64(n10)) + i -= n9 + i = encodeVarintTypes(dAtA, i, uint64(n9)) i-- dAtA[i] = 0x2a { @@ -807,18 +762,8 @@ func (m *ABCIResponses) Size() (n int) { } var l int _ = l - if len(m.DeliverTxs) > 0 { - for _, e := range m.DeliverTxs { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } - } - if m.EndBlock != nil { - l = m.EndBlock.Size() - n += 1 + l + sovTypes(uint64(l)) - } - if m.BeginBlock != nil { - l = m.BeginBlock.Size() + if m.FinalizeBlock != nil { + l = m.FinalizeBlock.Size() n += 1 + l + sovTypes(uint64(l)) } return n @@ -957,43 +902,9 @@ func (m *ABCIResponses) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: ABCIResponses: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeliverTxs", 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 - } - m.DeliverTxs = append(m.DeliverTxs, &types.ResponseDeliverTx{}) - if err := m.DeliverTxs[len(m.DeliverTxs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EndBlock", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FinalizeBlock", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1020,46 +931,10 @@ func (m *ABCIResponses) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.EndBlock == nil { - m.EndBlock = &types.ResponseEndBlock{} + if m.FinalizeBlock == nil { + m.FinalizeBlock = &types.ResponseFinalizeBlock{} } - if err := m.EndBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BeginBlock", 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 - } - if m.BeginBlock == nil { - m.BeginBlock = &types.ResponseBeginBlock{} - } - if err := m.BeginBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.FinalizeBlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/proto/tendermint/state/types.proto b/proto/tendermint/state/types.proto index 919da91e5..35eab761d 100644 --- a/proto/tendermint/state/types.proto +++ b/proto/tendermint/state/types.proto @@ -15,9 +15,7 @@ import "google/protobuf/timestamp.proto"; // of the various ABCI calls during block processing. // It is persisted to disk for each height before calling Commit. message ABCIResponses { - repeated tendermint.abci.ResponseDeliverTx deliver_txs = 1; - tendermint.abci.ResponseEndBlock end_block = 2; - tendermint.abci.ResponseBeginBlock begin_block = 3; + tendermint.abci.ResponseFinalizeBlock finalize_block = 2; } // ValidatorsInfo represents the latest validator set, or the last height it changed diff --git a/state/execution.go b/state/execution.go index 20f47c5b0..219a4275c 100644 --- a/state/execution.go +++ b/state/execution.go @@ -172,7 +172,7 @@ func (blockExec *BlockExecutor) ApplyBlock( fail.Fail() // XXX // validate the validator updates and convert to tendermint types - abciValUpdates := abciResponses.EndBlock.ValidatorUpdates + abciValUpdates := abciResponses.FinalizeBlock.ValidatorUpdates err = validateValidatorUpdates(abciValUpdates, state.ConsensusParams.Validator) if err != nil { return state, 0, fmt.Errorf("error in validator updates: %v", err) @@ -193,7 +193,7 @@ func (blockExec *BlockExecutor) ApplyBlock( } // Lock mempool, commit app state, update mempoool. - appHash, retainHeight, err := blockExec.Commit(state, block, abciResponses.DeliverTxs) + appHash, retainHeight, err := blockExec.Commit(state, block, abciResponses.FinalizeBlock.Txs) if err != nil { return state, 0, fmt.Errorf("commit failed for application: %v", err) } @@ -287,7 +287,7 @@ func execBlockOnProxyApp( txIndex := 0 abciResponses := new(tmstate.ABCIResponses) dtxs := make([]*abci.ResponseDeliverTx, len(block.Txs)) - abciResponses.DeliverTxs = dtxs + abciResponses.FinalizeBlock.Txs = dtxs // Execute transactions and get hash. proxyCb := func(req *abci.Request, res *abci.Response) { @@ -303,7 +303,7 @@ func execBlockOnProxyApp( invalidTxs++ } - abciResponses.DeliverTxs[txIndex] = txRes + abciResponses.FinalizeBlock.Txs[txIndex] = txRes txIndex++ } } @@ -325,34 +325,17 @@ func execBlockOnProxyApp( return nil, errors.New("nil header") } - abciResponses.BeginBlock, err = proxyAppConn.BeginBlockSync( - ctx, - abci.RequestBeginBlock{ - Hash: block.Hash(), - Header: *pbh, - LastCommitInfo: commitInfo, - ByzantineValidators: byzVals, - }, - ) + abciResponses.FinalizeBlock, err = proxyAppConn.FinalizeBlockSync(ctx, abci.RequestFinalizeBlock{ + Hash: block.Hash(), + Header: *pbh, + LastCommitInfo: commitInfo, + ByzantineValidators: byzVals, + Txs: block.Txs.ToSliceOfBytes(), + }) if err != nil { - logger.Error("error in proxyAppConn.BeginBlock", "err", err) + logger.Error("error in proxyAppConn.FinalizeBlock", "err", err) return nil, err } - - // run txs of block - for _, tx := range block.Txs { - _, err = proxyAppConn.DeliverTxAsync(ctx, abci.RequestDeliverTx{Tx: tx}) - if err != nil { - return nil, err - } - } - - abciResponses.EndBlock, err = proxyAppConn.EndBlockSync(ctx, abci.RequestEndBlock{Height: block.Height}) - if err != nil { - logger.Error("error in proxyAppConn.EndBlock", "err", err) - return nil, err - } - logger.Info("executed block", "height", block.Height, "num_valid_txs", validTxs, "num_invalid_txs", invalidTxs) return abciResponses, nil } @@ -452,9 +435,9 @@ func updateState( // Update the params with the latest abciResponses. nextParams := state.ConsensusParams lastHeightParamsChanged := state.LastHeightConsensusParamsChanged - if abciResponses.EndBlock.ConsensusParamUpdates != nil { + if abciResponses.FinalizeBlock.ConsensusParamUpdates != nil { // NOTE: must not mutate s.ConsensusParams - nextParams = state.ConsensusParams.UpdateConsensusParams(abciResponses.EndBlock.ConsensusParamUpdates) + nextParams = state.ConsensusParams.UpdateConsensusParams(abciResponses.FinalizeBlock.ConsensusParamUpdates) err := nextParams.ValidateConsensusParams() if err != nil { return state, fmt.Errorf("error updating consensus params: %v", err) @@ -500,19 +483,17 @@ func fireEvents( validatorUpdates []*types.Validator, ) { if err := eventBus.PublishEventNewBlock(types.EventDataNewBlock{ - Block: block, - BlockID: blockID, - ResultBeginBlock: *abciResponses.BeginBlock, - ResultEndBlock: *abciResponses.EndBlock, + Block: block, + BlockID: blockID, + ResultFinalizeBlock: *abciResponses.FinalizeBlock, }); err != nil { logger.Error("failed publishing new block", "err", err) } if err := eventBus.PublishEventNewBlockHeader(types.EventDataNewBlockHeader{ - Header: block.Header, - NumTxs: int64(len(block.Txs)), - ResultBeginBlock: *abciResponses.BeginBlock, - ResultEndBlock: *abciResponses.EndBlock, + Header: block.Header, + NumTxs: int64(len(block.Txs)), + ResultFinalizeBlock: *abciResponses.FinalizeBlock, }); err != nil { logger.Error("failed publishing new block header", "err", err) } @@ -533,7 +514,7 @@ func fireEvents( Height: block.Height, Index: uint32(i), Tx: tx, - Result: *(abciResponses.DeliverTxs[i]), + Result: *(abciResponses.FinalizeBlock.Txs[i]), }}); err != nil { logger.Error("failed publishing event TX", "err", err) } @@ -569,7 +550,7 @@ func ExecCommitBlock( // the BlockExecutor condition is using for the final block replay process. if be != nil { - abciValUpdates := abciResponses.EndBlock.ValidatorUpdates + abciValUpdates := abciResponses.FinalizeBlock.ValidatorUpdates err = validateValidatorUpdates(abciValUpdates, s.ConsensusParams.Validator) if err != nil { logger.Error("err", err) diff --git a/state/helpers_test.go b/state/helpers_test.go index 8163345b3..5ec56bc10 100644 --- a/state/helpers_test.go +++ b/state/helpers_test.go @@ -159,8 +159,7 @@ func makeHeaderPartsResponsesValPubKeyChange( block := makeBlock(state, state.LastBlockHeight+1) abciResponses := &tmstate.ABCIResponses{ - BeginBlock: &abci.ResponseBeginBlock{}, - EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: nil}, + FinalizeBlock: &abci.ResponseFinalizeBlock{ValidatorUpdates: nil}, } // If the pubkey is new, remove the old and add the new. _, val := state.NextValidators.GetByIndex(0) @@ -173,7 +172,7 @@ func makeHeaderPartsResponsesValPubKeyChange( if err != nil { panic(err) } - abciResponses.EndBlock = &abci.ResponseEndBlock{ + abciResponses.FinalizeBlock = &abci.ResponseFinalizeBlock{ ValidatorUpdates: []abci.ValidatorUpdate{ {PubKey: vPbPk, Power: 0}, {PubKey: pbPk, Power: 10}, @@ -191,8 +190,7 @@ func makeHeaderPartsResponsesValPowerChange( block := makeBlock(state, state.LastBlockHeight+1) abciResponses := &tmstate.ABCIResponses{ - BeginBlock: &abci.ResponseBeginBlock{}, - EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: nil}, + FinalizeBlock: &abci.ResponseFinalizeBlock{ValidatorUpdates: nil}, } // If the pubkey is new, remove the old and add the new. @@ -202,7 +200,7 @@ func makeHeaderPartsResponsesValPowerChange( if err != nil { panic(err) } - abciResponses.EndBlock = &abci.ResponseEndBlock{ + abciResponses.FinalizeBlock = &abci.ResponseFinalizeBlock{ ValidatorUpdates: []abci.ValidatorUpdate{ {PubKey: vPbPk, Power: power}, }, @@ -220,8 +218,7 @@ func makeHeaderPartsResponsesParams( block := makeBlock(state, state.LastBlockHeight+1) pbParams := params.ToProto() abciResponses := &tmstate.ABCIResponses{ - BeginBlock: &abci.ResponseBeginBlock{}, - EndBlock: &abci.ResponseEndBlock{ConsensusParamUpdates: &pbParams}, + FinalizeBlock: &abci.ResponseFinalizeBlock{ConsensusParamUpdates: &pbParams}, } return block.Header, types.BlockID{Hash: block.Hash(), PartSetHeader: types.PartSetHeader{}}, abciResponses } diff --git a/state/indexer/block/kv/kv.go b/state/indexer/block/kv/kv.go index 1787be9ef..07cb61f65 100644 --- a/state/indexer/block/kv/kv.go +++ b/state/indexer/block/kv/kv.go @@ -65,15 +65,10 @@ func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockHeader) error { } // 2. index BeginBlock events - if err := idx.indexEvents(batch, bh.ResultBeginBlock.Events, "begin_block", height); err != nil { + if err := idx.indexEvents(batch, bh.ResultFinalizeBlock.Events, "begin_block", height); err != nil { return fmt.Errorf("failed to index BeginBlock events: %w", err) } - // 3. index EndBlock events - if err := idx.indexEvents(batch, bh.ResultEndBlock.Events, "end_block", height); err != nil { - return fmt.Errorf("failed to index EndBlock events: %w", err) - } - return batch.WriteSync() } diff --git a/state/indexer/block/kv/kv_test.go b/state/indexer/block/kv/kv_test.go index 2a342f870..eb42782f1 100644 --- a/state/indexer/block/kv/kv_test.go +++ b/state/indexer/block/kv/kv_test.go @@ -2,7 +2,6 @@ package kv_test import ( "context" - "fmt" "testing" "github.com/stretchr/testify/require" @@ -19,7 +18,7 @@ func TestBlockIndexer(t *testing.T) { require.NoError(t, indexer.Index(types.EventDataNewBlockHeader{ Header: types.Header{Height: 1}, - ResultBeginBlock: abci.ResponseBeginBlock{ + ResultFinalizeBlock: abci.ResponseFinalizeBlock{ Events: []abci.Event{ { Type: "begin_event", @@ -33,34 +32,15 @@ func TestBlockIndexer(t *testing.T) { }, }, }, - ResultEndBlock: abci.ResponseEndBlock{ - Events: []abci.Event{ - { - Type: "end_event", - Attributes: []abci.EventAttribute{ - { - Key: "foo", - Value: "100", - Index: true, - }, - }, - }, - }, - }, })) for i := 2; i < 12; i++ { - var index bool - if i%2 == 0 { - index = true - } - require.NoError(t, indexer.Index(types.EventDataNewBlockHeader{ Header: types.Header{Height: int64(i)}, - ResultBeginBlock: abci.ResponseBeginBlock{ + ResultFinalizeBlock: abci.ResponseFinalizeBlock{ Events: []abci.Event{ { - Type: "begin_event", + Type: "finalize_event", Attributes: []abci.EventAttribute{ { Key: "proposer", @@ -71,20 +51,6 @@ func TestBlockIndexer(t *testing.T) { }, }, }, - ResultEndBlock: abci.ResponseEndBlock{ - Events: []abci.Event{ - { - Type: "end_event", - Attributes: []abci.EventAttribute{ - { - Key: "foo", - Value: fmt.Sprintf("%d", i), - Index: index, - }, - }, - }, - }, - }, })) } diff --git a/state/indexer/sink/kv/kv_test.go b/state/indexer/sink/kv/kv_test.go index a5d2dd81e..65ad20c7e 100644 --- a/state/indexer/sink/kv/kv_test.go +++ b/state/indexer/sink/kv/kv_test.go @@ -32,10 +32,10 @@ func TestBlockFuncs(t *testing.T) { require.NoError(t, indexer.IndexBlockEvents(types.EventDataNewBlockHeader{ Header: types.Header{Height: 1}, - ResultBeginBlock: abci.ResponseBeginBlock{ + ResultFinalizeBlock: abci.ResponseFinalizeBlock{ Events: []abci.Event{ { - Type: "begin_event", + Type: "finalize_event", Attributes: []abci.EventAttribute{ { Key: "proposer", @@ -46,20 +46,6 @@ func TestBlockFuncs(t *testing.T) { }, }, }, - ResultEndBlock: abci.ResponseEndBlock{ - Events: []abci.Event{ - { - Type: "end_event", - Attributes: []abci.EventAttribute{ - { - Key: "foo", - Value: "100", - Index: true, - }, - }, - }, - }, - }, })) b, e := indexer.HasBlock(1) @@ -67,17 +53,12 @@ func TestBlockFuncs(t *testing.T) { assert.True(t, b) for i := 2; i < 12; i++ { - var index bool - if i%2 == 0 { - index = true - } - require.NoError(t, indexer.IndexBlockEvents(types.EventDataNewBlockHeader{ Header: types.Header{Height: int64(i)}, - ResultBeginBlock: abci.ResponseBeginBlock{ + ResultFinalizeBlock: abci.ResponseFinalizeBlock{ Events: []abci.Event{ { - Type: "begin_event", + Type: "finalize_event", Attributes: []abci.EventAttribute{ { Key: "proposer", @@ -88,20 +69,6 @@ func TestBlockFuncs(t *testing.T) { }, }, }, - ResultEndBlock: abci.ResponseEndBlock{ - Events: []abci.Event{ - { - Type: "end_event", - Attributes: []abci.EventAttribute{ - { - Key: "foo", - Value: fmt.Sprintf("%d", i), - Index: index, - }, - }, - }, - }, - }, })) } diff --git a/state/indexer/sink/psql/psql.go b/state/indexer/sink/psql/psql.go index 0e66d6117..1e11d6efa 100644 --- a/state/indexer/sink/psql/psql.go +++ b/state/indexer/sink/psql/psql.go @@ -57,16 +57,9 @@ func (es *EventSink) IndexBlockEvents(h types.EventDataNewBlockHeader) error { sqlStmt = sqlStmt. Values(types.BlockHeightKey, fmt.Sprint(h.Header.Height), h.Header.Height, "", ts, es.chainID) - // index begin_block events + // index finalize_block events sqlStmt, err := indexBlockEvents( - sqlStmt, h.ResultBeginBlock.Events, types.EventTypeBeginBlock, h.Header.Height, ts, es.chainID) - if err != nil { - return err - } - - // index end_block events - sqlStmt, err = indexBlockEvents( - sqlStmt, h.ResultEndBlock.Events, types.EventTypeEndBlock, h.Header.Height, ts, es.chainID) + sqlStmt, h.ResultFinalizeBlock.Events, types.EventTypeBeginBlock, h.Header.Height, ts, es.chainID) if err != nil { return err } diff --git a/state/indexer/sink/psql/psql_test.go b/state/indexer/sink/psql/psql_test.go index 591d23edd..4f94986d7 100644 --- a/state/indexer/sink/psql/psql_test.go +++ b/state/indexer/sink/psql/psql_test.go @@ -121,10 +121,10 @@ func TestStop(t *testing.T) { func getTestBlockHeader() types.EventDataNewBlockHeader { return types.EventDataNewBlockHeader{ Header: types.Header{Height: 1}, - ResultBeginBlock: abci.ResponseBeginBlock{ + ResultFinalizeBlock: abci.ResponseFinalizeBlock{ Events: []abci.Event{ { - Type: "begin_event", + Type: "finalize_event", Attributes: []abci.EventAttribute{ { Key: "proposer", @@ -135,20 +135,6 @@ func getTestBlockHeader() types.EventDataNewBlockHeader { }, }, }, - ResultEndBlock: abci.ResponseEndBlock{ - Events: []abci.Event{ - { - Type: "end_event", - Attributes: []abci.EventAttribute{ - { - Key: "foo", - Value: "100", - Index: true, - }, - }, - }, - }, - }, } } diff --git a/state/store.go b/state/store.go index a488d0722..d4349ec49 100644 --- a/state/store.go +++ b/state/store.go @@ -442,7 +442,7 @@ func (store dbStore) reverseBatchDelete(batch dbm.Batch, start, end []byte) ([]b // // See merkle.SimpleHashFromByteSlices func ABCIResponsesResultsHash(ar *tmstate.ABCIResponses) []byte { - return types.NewResults(ar.DeliverTxs).Hash() + return types.NewResults(ar.FinalizeBlock.Txs).Hash() } // LoadABCIResponses loads the ABCIResponses for the given height from the @@ -486,13 +486,13 @@ func (store dbStore) SaveABCIResponses(height int64, abciResponses *tmstate.ABCI func (store dbStore) saveABCIResponses(height int64, abciResponses *tmstate.ABCIResponses) error { var dtxs []*abci.ResponseDeliverTx // strip nil values, - for _, tx := range abciResponses.DeliverTxs { + for _, tx := range abciResponses.FinalizeBlock.Txs { if tx != nil { dtxs = append(dtxs, tx) } } - abciResponses.DeliverTxs = dtxs + abciResponses.FinalizeBlock.Txs = dtxs bz, err := abciResponses.Marshal() if err != nil { diff --git a/types/events.go b/types/events.go index 684160d6f..ac88b9e1e 100644 --- a/types/events.go +++ b/types/events.go @@ -65,16 +65,14 @@ type EventDataNewBlock struct { Block *Block `json:"block"` BlockID BlockID `json:"block_id"` - ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` - ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` + ResultFinalizeBlock abci.ResponseFinalizeBlock `json:"result_finalize_block"` } type EventDataNewBlockHeader struct { Header Header `json:"header"` - NumTxs int64 `json:"num_txs"` // Number of txs in a block - ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` - ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` + NumTxs int64 `json:"num_txs"` // Number of txs in a block + ResultFinalizeBlock abci.ResponseFinalizeBlock `json:"result_finalize_block"` } type EventDataNewEvidence struct { diff --git a/types/tx.go b/types/tx.go index 92df92f13..c51df24a9 100644 --- a/types/tx.go +++ b/types/tx.go @@ -79,6 +79,17 @@ func (txs Txs) Proof(i int) TxProof { } } +// Convert []Txs to [][]Byte +// This method should become obsolete once Txs is switched to [][]byte, +// ref #2603 +func (txs Txs) ToSliceOfBytes() [][]byte { + txBzs := make([][]byte, len(txs)) + for i := 0; i < len(txs); i++ { + txBzs[i] = txs[i] + } + return txBzs +} + // TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. type TxProof struct { RootHash tmbytes.HexBytes `json:"root_hash"`