Skip to content

Commit

Permalink
remove square size from the abci parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Aug 22, 2023
1 parent f84fa8a commit 6ae7e20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
7 changes: 2 additions & 5 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"context"
"encoding/binary"

"github.com/tendermint/tendermint/crypto/tmhash"
)
Expand Down Expand Up @@ -96,10 +95,8 @@ func (BaseApplication) ApplySnapshotChunk(req RequestApplySnapshotChunk) Respons
}

func (BaseApplication) PrepareProposal(req RequestPrepareProposal) ResponsePrepareProposal {
// we use placeholder values for the hash and square size
squareSizeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(squareSizeBytes, 0)
req.Txs = append(req.Txs, tmhash.Sum(nil), squareSizeBytes)
// we use placeholder values for the hash
req.Txs = append(req.Txs, tmhash.Sum(nil))
return ResponsePrepareProposal{Txs: req.Txs}
}

Expand Down
16 changes: 5 additions & 11 deletions state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,21 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
panic(err)
}

// Celestia passes the data root back as the second to last transaction
// and the big endian encoding of the square size as the last transaction.
if len(rpp.Txs) < 2 {
// Celestia passes the data root back as the last transaction
if len(rpp.Txs) < 1 {
panic("state machine returned an invalid prepare proposal response: expected at least 2 transactions")
}

if len(rpp.Txs[len(rpp.Txs)-2]) != tmhash.Size {
if len(rpp.Txs[len(rpp.Txs)-1]) != tmhash.Size {
panic(fmt.Sprintf("state machine returned an invalid prepare proposal response: expected second to last transaction to be a hash, got %d bytes", len(rpp.Txs[len(rpp.Txs)-2])))
}

if len(rpp.Txs[len(rpp.Txs)-1]) != 8 {
panic("state machine returned an invalid prepare proposal response: expected last transaction to be a uint64 (square size)")
}

// update the block with the response from PrepareProposal
block.Data, _ = types.DataFromProto(&cmtproto.Data{
Txs: rpp.Txs[:len(rpp.Txs)-2],
Txs: rpp.Txs[:len(rpp.Txs)-1],
})

block.DataHash = rpp.Txs[len(rpp.Txs)-2]
block.SquareSize = binary.BigEndian.Uint64(rpp.Txs[len(rpp.Txs)-1])
block.DataHash = rpp.Txs[len(rpp.Txs)-1]

var blockDataSize int
for _, tx := range block.Txs {
Expand Down

0 comments on commit 6ae7e20

Please sign in to comment.