Skip to content

Commit

Permalink
Use consistent hash type across headers (cosmos#698)
Browse files Browse the repository at this point in the history
Closes cosmos#689
  • Loading branch information
Manav-Aggarwal authored Jan 22, 2023
1 parent 018e42a commit 9bf4b1d
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 124 deletions.
8 changes: 3 additions & 5 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
"go.uber.org/multierr"

"github.com/celestiaorg/go-header"

"github.com/celestiaorg/rollmint/config"
"github.com/celestiaorg/rollmint/da"
"github.com/celestiaorg/rollmint/log"
Expand Down Expand Up @@ -422,7 +420,7 @@ func (m *Manager) getCommit(header types.Header) (*types.Commit, error) {

func (m *Manager) publishBlock(ctx context.Context) error {
var lastCommit *types.Commit
var lastHeaderHash header.Hash
var lastHeaderHash types.Hash
var err error
height := m.store.Height()
newHeight := height + 1
Expand Down Expand Up @@ -572,7 +570,7 @@ func updateState(s *types.State, res *abci.ResponseInitChain) {
// the state. We don't set appHash since we don't want the genesis doc app hash
// recorded in the genesis block. We should probably just remove GenesisDoc.AppHash.
if len(res.AppHash) > 0 {
copy(s.AppHash[:], res.AppHash)
s.AppHash = res.AppHash
}

if res.ConsensusParams != nil {
Expand All @@ -597,7 +595,7 @@ func updateState(s *types.State, res *abci.ResponseInitChain) {
s.Version.Consensus.App = s.ConsensusParams.Version.AppVersion
}
// We update the last results hash with the empty hash, to conform with RFC-6962.
copy(s.LastResultsHash[:], merkle.HashFromByteSlices(nil))
s.LastResultsHash = merkle.HashFromByteSlices(nil)

if len(res.Validators) > 0 {
vals, err := tmtypes.PB2TM.ValidatorUpdates(res.Validators)
Expand Down
16 changes: 8 additions & 8 deletions conv/abci/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ func ToABCIHeader(header *types.Header) (tmtypes.Header, error) {
Height: int64(header.Height()),
Time: header.Time(),
LastBlockID: tmtypes.BlockID{
Hash: header.LastHeaderHash[:],
Hash: tmbytes.HexBytes(header.LastHeaderHash),
PartSetHeader: tmtypes.PartSetHeader{
Total: 0,
Hash: nil,
},
},
LastCommitHash: header.LastCommitHash[:],
DataHash: header.DataHash[:],
ValidatorsHash: header.AggregatorsHash[:],
LastCommitHash: tmbytes.HexBytes(header.LastCommitHash),
DataHash: tmbytes.HexBytes(header.DataHash),
ValidatorsHash: tmbytes.HexBytes(header.AggregatorsHash),
NextValidatorsHash: nil,
ConsensusHash: header.ConsensusHash[:],
AppHash: header.AppHash[:],
LastResultsHash: header.LastResultsHash[:],
ConsensusHash: tmbytes.HexBytes(header.ConsensusHash),
AppHash: tmbytes.HexBytes(header.AppHash),
LastResultsHash: tmbytes.HexBytes(header.LastResultsHash),
EvidenceHash: new(tmtypes.EvidenceData).Hash(),
ProposerAddress: header.ProposerAddress,
ChainID: header.ChainID(),
Expand Down Expand Up @@ -92,7 +92,7 @@ func ToABCIBlock(block *types.Block) (*tmtypes.Block, error) {
for i := range block.Data.Txs {
abciBlock.Data.Txs[i] = tmtypes.Tx(block.Data.Txs[i])
}
abciBlock.Header.DataHash = block.Header.DataHash[:]
abciBlock.Header.DataHash = tmbytes.HexBytes(block.Header.DataHash)

return &abciBlock, nil
}
Expand Down
3 changes: 2 additions & 1 deletion da/test/da_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func getRandomBlock(height uint64, nTxs int) *types.Block {
BaseHeader: types.BaseHeader{
Height: height,
},
AggregatorsHash: make([]byte, 32),
},
Data: types.Data{
Txs: make(types.Txs, nTxs),
Expand All @@ -252,7 +253,7 @@ func getRandomBlock(height uint64, nTxs int) *types.Block {
},
},
}
copy(block.Header.AppHash[:], getRandomBytes(32))
block.Header.AppHash = getRandomBytes(32)

for i := 0; i < nTxs; i++ {
block.Data.Txs[i] = getRandomTx()
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.21
go.uber.org/multierr v1.9.0
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
golang.org/x/net v0.5.0
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
)
Expand Down Expand Up @@ -161,11 +161,11 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/tools v0.1.12 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -795,6 +797,8 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU=
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -896,6 +900,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 h1:OK7RB6t2WQX54srQQYSXMW8dF5C6/8+oA/s5QBmmto4=
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -908,6 +914,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -969,6 +977,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
56 changes: 28 additions & 28 deletions node/full_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/tendermint/tendermint/proxy"
rpcclient "github.com/tendermint/tendermint/rpc/client"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"

rconfig "github.com/celestiaorg/rollmint/config"
Expand All @@ -46,7 +46,7 @@ var _ rpcclient.Client = &FullClient{}
//
// This is the type that is used in communication between cosmos-sdk app and rollmint.
type FullClient struct {
*types.EventBus
*tmtypes.EventBus
config *config.RPCConfig

node *FullNode
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *FullClient) ABCIQueryWithOptions(ctx context.Context, path string, data

// BroadcastTxCommit returns with the responses from CheckTx and DeliverTx.
// More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_commit
func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
// This implementation corresponds to Tendermints implementation from rpc/core/mempool.go.
// ctx.RemoteAddr godoc: If neither HTTPReq nor WSConn is set, an empty string is returned.
// This code is a local client, so we can assume that subscriber is ""
Expand All @@ -111,7 +111,7 @@ func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctype
// Subscribe to tx being committed in block.
subCtx, cancel := context.WithTimeout(ctx, subscribeTimeout)
defer cancel()
q := types.EventQueryTxFor(tx)
q := tmtypes.EventQueryTxFor(tx)
deliverTxSub, err := c.EventBus.Subscribe(subCtx, subscriber, q)
if err != nil {
err = fmt.Errorf("failed to subscribe to tx: %w", err)
Expand Down Expand Up @@ -152,7 +152,7 @@ func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctype
// Wait for the tx to be included in a block or timeout.
select {
case msg := <-deliverTxSub.Out(): // The tx was included in a block.
deliverTxRes := msg.Data().(types.EventDataTx)
deliverTxRes := msg.Data().(tmtypes.EventDataTx)
return &ctypes.ResultBroadcastTxCommit{
CheckTx: *checkTxRes,
DeliverTx: deliverTxRes.Result,
Expand Down Expand Up @@ -187,7 +187,7 @@ func (c *FullClient) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctype
// BroadcastTxAsync returns right away, with no response. Does not wait for
// CheckTx nor DeliverTx results.
// More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_async
func (c *FullClient) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c *FullClient) BroadcastTxAsync(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
err := c.node.Mempool.CheckTx(tx, nil, mempool.TxInfo{})
if err != nil {
return nil, err
Expand All @@ -203,7 +203,7 @@ func (c *FullClient) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes
// BroadcastTxSync returns with the response from CheckTx. Does not wait for
// DeliverTx result.
// More: https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync
func (c *FullClient) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
func (c *FullClient) BroadcastTxSync(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultBroadcastTx, error) {
resCh := make(chan *abci.Response, 1)
err := c.node.Mempool.CheckTx(tx, func(res *abci.Response) {
resCh <- res
Expand Down Expand Up @@ -250,7 +250,7 @@ func (c *FullClient) Subscribe(ctx context.Context, subscriber, query string, ou
outCap = outCapacity[0]
}

var sub types.Subscription
var sub tmtypes.Subscription
if outCap > 0 {
sub, err = c.EventBus.Subscribe(ctx, subscriber, q, outCap)
} else {
Expand Down Expand Up @@ -322,7 +322,7 @@ func (c *FullClient) BlockchainInfo(ctx context.Context, minHeight, maxHeight in
}
c.Logger.Debug("BlockchainInfo", "maxHeight", maxHeight, "minHeight", minHeight)

blocks := make([]*types.BlockMeta, 0, maxHeight-minHeight+1)
blocks := make([]*tmtypes.BlockMeta, 0, maxHeight-minHeight+1)
for height := maxHeight; height >= minHeight; height-- {
block, err := c.node.Store.LoadBlock(uint64(height))
if err != nil {
Expand Down Expand Up @@ -425,9 +425,9 @@ func (c *FullClient) Block(ctx context.Context, height *int64) (*ctypes.ResultBl
return nil, err
}
return &ctypes.ResultBlock{
BlockID: types.BlockID{
Hash: hash[:],
PartSetHeader: types.PartSetHeader{
BlockID: tmtypes.BlockID{
Hash: tmbytes.HexBytes(hash),
PartSetHeader: tmtypes.PartSetHeader{
Total: 0,
Hash: nil,
},
Expand All @@ -448,9 +448,9 @@ func (c *FullClient) BlockByHash(ctx context.Context, hash []byte) (*ctypes.Resu
return nil, err
}
return &ctypes.ResultBlock{
BlockID: types.BlockID{
BlockID: tmtypes.BlockID{
Hash: hash,
PartSetHeader: types.PartSetHeader{
PartSetHeader: tmtypes.PartSetHeader{
Total: 0,
Hash: nil,
},
Expand Down Expand Up @@ -541,13 +541,13 @@ func (c *FullClient) Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.R
height := res.Height
index := res.Index

var proof types.TxProof
var proof tmtypes.TxProof
if prove {
block, _ := c.node.Store.LoadBlock(uint64(height))
blockProof := block.Data.Txs.Proof(int(index)) // XXX: overflow on 32-bit machines
proof = types.TxProof{
proof = tmtypes.TxProof{
RootHash: blockProof.RootHash,
Data: types.Tx(blockProof.Data),
Data: tmtypes.Tx(blockProof.Data),
Proof: blockProof.Proof,
}
}
Expand Down Expand Up @@ -610,14 +610,14 @@ func (c *FullClient) TxSearch(ctx context.Context, query string, prove bool, pag
for i := skipCount; i < skipCount+pageSize; i++ {
r := results[i]

var proof types.TxProof
var proof tmtypes.TxProof
/*if prove {
block := nil //env.BlockStore.LoadBlock(r.Height)
proof = block.Data.Txs.Proof(int(r.Index)) // XXX: overflow on 32-bit machines
}*/

apiResults = append(apiResults, &ctypes.ResultTx{
Hash: types.Tx(r.Tx).Hash(),
Hash: tmtypes.Tx(r.Tx).Hash(),
Height: r.Height,
Index: r.Index,
TxResult: r.Result,
Expand Down Expand Up @@ -682,7 +682,7 @@ func (c *FullClient) BlockSearch(ctx context.Context, query string, page, perPag
}
blocks = append(blocks, &ctypes.ResultBlock{
Block: block,
BlockID: types.BlockID{
BlockID: tmtypes.BlockID{
Hash: block.Hash(),
},
})
Expand Down Expand Up @@ -735,12 +735,12 @@ func (c *FullClient) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
},
},
SyncInfo: ctypes.SyncInfo{
LatestBlockHash: latest.Header.DataHash[:],
LatestAppHash: latest.Header.AppHash[:],
LatestBlockHash: tmbytes.HexBytes(latest.Header.DataHash),
LatestAppHash: tmbytes.HexBytes(latest.Header.AppHash),
LatestBlockHeight: latest.Header.Height(),
LatestBlockTime: latest.Header.Time(),
EarliestBlockHash: initial.Header.DataHash[:],
EarliestAppHash: initial.Header.AppHash[:],
EarliestBlockHash: tmbytes.HexBytes(initial.Header.DataHash),
EarliestAppHash: tmbytes.HexBytes(initial.Header.AppHash),
EarliestBlockHeight: initial.Header.Height(),
EarliestBlockTime: initial.Header.Time(),
CatchingUp: true, // the client is always syncing in the background to the latest height
Expand All @@ -755,7 +755,7 @@ func (c *FullClient) Status(ctx context.Context) (*ctypes.ResultStatus, error) {
}

// BroadcastEvidence is not yet implemented.
func (c *FullClient) BroadcastEvidence(ctx context.Context, evidence types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
func (c *FullClient) BroadcastEvidence(ctx context.Context, evidence tmtypes.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
return &ctypes.ResultBroadcastEvidence{
Hash: evidence.Hash(),
}, nil
Expand Down Expand Up @@ -787,15 +787,15 @@ func (c *FullClient) UnconfirmedTxs(ctx context.Context, limitPtr *int) (*ctypes
// CheckTx executes a new transaction against the application to determine its validity.
//
// If valid, the tx is automatically added to the mempool.
func (c *FullClient) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
func (c *FullClient) CheckTx(ctx context.Context, tx tmtypes.Tx) (*ctypes.ResultCheckTx, error) {
res, err := c.appClient().CheckTxSync(abci.RequestCheckTx{Tx: tx})
if err != nil {
return nil, err
}
return &ctypes.ResultCheckTx{ResponseCheckTx: *res}, nil
}

func (c *FullClient) eventsRoutine(sub types.Subscription, subscriber string, q tmpubsub.Query, outc chan<- ctypes.ResultEvent) {
func (c *FullClient) eventsRoutine(sub tmtypes.Subscription, subscriber string, q tmpubsub.Query, outc chan<- ctypes.ResultEvent) {
defer close(outc)
for {
select {
Expand Down Expand Up @@ -827,7 +827,7 @@ func (c *FullClient) eventsRoutine(sub types.Subscription, subscriber string, q
}

// Try to resubscribe with exponential backoff.
func (c *FullClient) resubscribe(subscriber string, q tmpubsub.Query) types.Subscription {
func (c *FullClient) resubscribe(subscriber string, q tmpubsub.Query) tmtypes.Subscription {
attempts := 0
for {
if !c.IsRunning() {
Expand Down
9 changes: 6 additions & 3 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func TestGetBlockByHash(t *testing.T) {
require.NoError(err)
require.NotNil(retrievedBlock)
assert.Equal(abciBlock, retrievedBlock.Block)
assert.Equal(abciBlock.Hash(), retrievedBlock.Block.Header.Hash())
assert.Equal(abciBlock.Hash(), retrievedBlock.Block.Hash())

blockHash := block.Header.Hash()
blockResp, err := rpc.BlockByHash(context.Background(), blockHash[:])
Expand Down Expand Up @@ -724,6 +724,7 @@ func getRandomBlockWithProposer(height uint64, nTxs int, proposerAddr []byte) *t
},
Version: types.Version{Block: types.InitStateVersion.Consensus.Block},
ProposerAddress: proposerAddr,
AggregatorsHash: make([]byte, 32),
},
Data: types.Data{
Txs: make(types.Txs, nTxs),
Expand All @@ -732,7 +733,7 @@ func getRandomBlockWithProposer(height uint64, nTxs int, proposerAddr []byte) *t
},
},
}
copy(block.Header.AppHash[:], getRandomBytes(32))
block.Header.AppHash = getRandomBytes(32)

for i := 0; i < nTxs; i++ {
block.Data.Txs[i] = getRandomTx()
Expand All @@ -749,7 +750,9 @@ func getRandomBlockWithProposer(height uint64, nTxs int, proposerAddr []byte) *t
if err != nil {
return nil
}
copy(block.Header.LastCommitHash[:], tmprotoLC.Hash())
lastCommitHash := make(types.Hash, 32)
copy(lastCommitHash, tmprotoLC.Hash().Bytes())
block.Header.LastCommitHash = lastCommitHash

return block
}
Expand Down
Loading

0 comments on commit 9bf4b1d

Please sign in to comment.