Skip to content

Commit bbe46be

Browse files
committed
fix data block hash
1 parent 4d922e0 commit bbe46be

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

internal/consensus/state.go

+10
Original file line numberDiff line numberDiff line change
@@ -2090,8 +2090,10 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) {
20902090
defer storeBlockSpan.End()
20912091
seenExtendedCommit := cs.Votes.Precommits(cs.CommitRound).MakeExtendedCommit()
20922092
if cs.state.ConsensusParams.ABCI.VoteExtensionsEnabled(block.Height) {
2093+
logger.Info("PSULOG - saving block with extension with data", "len of txs", len(block.Data.Txs))
20932094
cs.blockStore.SaveBlockWithExtendedCommit(block, blockParts, seenExtendedCommit)
20942095
} else {
2096+
logger.Info("PSULOG - saving block without extension with data", "len of txs", len(block.Data.Txs), "block parts", blockParts)
20952097
cs.blockStore.SaveBlock(block, blockParts, seenExtendedCommit.ToCommit())
20962098
}
20972099
storeBlockSpan.End()
@@ -2380,7 +2382,15 @@ func (cs *State) addProposalBlockPart(
23802382
cs.logger.Info("PSULOG - populating txs with keys", "keys", txKeys)
23812383
txs := cs.blockExec.GetTxsForKeys(txKeys)
23822384
block.Data.Txs = txs
2385+
block.DataHash = block.Data.Hash()
23832386
cs.ProposalBlock = block
2387+
cs.logger.Info("PSULOG - setting proposal block", "block", block)
2388+
partSet, err := block.MakePartSet(types.BlockPartSizeBytes)
2389+
if err != nil {
2390+
return false, nil
2391+
}
2392+
2393+
cs.ProposalBlockParts = partSet
23842394
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
23852395
cs.logger.Info("received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash(), "time", time.Now().UnixMilli())
23862396
}

proto/tendermint/consensus/types.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ message HasVote {
6464
int32 index = 4;
6565
}
6666

67-
// VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes.
6867
message VoteSetMaj23 {
68+
// VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes.
6969
int64 height = 1;
7070
int32 round = 2;
7171
tendermint.types.SignedMsgType type = 3;

rpc/client/http/http.go

+17-15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package http
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"net/http"
78
"time"
89

@@ -33,24 +34,24 @@ the example for more details.
3334
3435
Example:
3536
36-
c, err := New("http://192.168.1.10:26657")
37-
if err != nil {
38-
// handle error
39-
}
37+
c, err := New("http://192.168.1.10:26657")
38+
if err != nil {
39+
// handle error
40+
}
4041
41-
// call Start/Stop if you're subscribing to events
42-
err = c.Start()
43-
if err != nil {
44-
// handle error
45-
}
46-
defer c.Stop()
42+
// call Start/Stop if you're subscribing to events
43+
err = c.Start()
44+
if err != nil {
45+
// handle error
46+
}
47+
defer c.Stop()
4748
48-
res, err := c.Status()
49-
if err != nil {
50-
// handle error
51-
}
49+
res, err := c.Status()
50+
if err != nil {
51+
// handle error
52+
}
5253
53-
// handle result
54+
// handle result
5455
*/
5556
type HTTP struct {
5657
remote string
@@ -428,6 +429,7 @@ func (c *baseRPCClient) Commit(ctx context.Context, height *int64) (*coretypes.R
428429

429430
func (c *baseRPCClient) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error) {
430431
result := new(coretypes.ResultTx)
432+
fmt.Println("Calling tx search")
431433
if err := c.caller.Call(ctx, "tx", &coretypes.RequestTx{Hash: hash, Prove: prove}, result); err != nil {
432434
return nil, err
433435
}

rpc/jsonrpc/client/decode.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func unmarshalResponseBytes(responseBytes []byte, expectedID string, result inte
1212
// into the correct type.
1313
var response rpctypes.RPCResponse
1414
if err := json.Unmarshal(responseBytes, &response); err != nil {
15-
return fmt.Errorf("unmarshaling response: %w", err)
15+
return fmt.Errorf("unmarshaling response test: %w, bytes: %d", err, len(responseBytes))
1616
}
1717

1818
if response.Error != nil {

types/block.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (b *Block) ValidateBasic() error {
7676

7777
// NOTE: b.Data.Txs may be nil, but b.Data.Hash() still works fine.
7878
if w, g := b.Data.Hash(), b.DataHash; !bytes.Equal(w, g) {
79-
return fmt.Errorf("wrong Header.DataHash. Expected %X, got %X", w, g)
79+
return fmt.Errorf("wrong Header.DataHash. Expected %X, got %X. Len of txs %d", w, g, len(b.Data.Txs))
8080
}
8181

8282
// NOTE: b.Evidence may be nil, but we're just looping.
@@ -1306,9 +1306,9 @@ func (data *Data) Hash() tmbytes.HexBytes {
13061306
if data == nil {
13071307
return (Txs{}).Hash()
13081308
}
1309-
if data.hash == nil {
1310-
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
1311-
}
1309+
//if data.hash == nil {
1310+
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
1311+
//}
13121312
return data.hash
13131313
}
13141314

0 commit comments

Comments
 (0)