Skip to content

Commit

Permalink
simplify base application and other implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Jun 19, 2023
1 parent 842a367 commit 6a6a610
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
3 changes: 3 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (BaseApplication) ApplySnapshotChunk(req RequestApplySnapshotChunk) Respons
func (BaseApplication) PrepareProposal(req RequestPrepareProposal) ResponsePrepareProposal {
squareSizeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(squareSizeBytes, 0)

// placeholderDataHash and placeholderSquareSizeBytes are expected to be
// overwritten by celestia-app.
req.Txs = append(req.Txs, tmhash.Sum(nil), squareSizeBytes)
return ResponsePrepareProposal{Txs: req.Txs}
}
Expand Down
13 changes: 0 additions & 13 deletions consensus/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,3 @@ func (app *CounterApplication) Commit() abci.ResponseCommit {
binary.BigEndian.PutUint64(hash, uint64(app.txCount))
return abci.ResponseCommit{Data: hash}
}

func (app *CounterApplication) PrepareProposal(
req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
dataHash := types.ToTxs(req.Txs).Hash()
squareSize := len(req.Txs)
if squareSize == 0 {
squareSize = 1
}
squareSizeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(squareSizeBytes, uint64(squareSize))
req.Txs = append(req.Txs, dataHash, squareSizeBytes)
return abci.ResponsePrepareProposal{Txs: req.Txs}
}
20 changes: 0 additions & 20 deletions test/e2e/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package app
import (
"bytes"
"encoding/base64"
"encoding/binary"
"errors"
"fmt"
"os"
Expand All @@ -13,7 +12,6 @@ import (
"github.com/tendermint/tendermint/abci/example/code"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"
)

Expand Down Expand Up @@ -259,24 +257,6 @@ func (app *Application) ApplySnapshotChunk(req abci.RequestApplySnapshotChunk) a
return abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ACCEPT}
}

func (app *Application) PrepareProposal(
req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
dataHash := types.ToTxs(req.Txs).Hash()
squareSize := len(req.Txs)
if squareSize == 0 {
squareSize = 1
}
squareSizeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(squareSizeBytes, uint64(squareSize))
req.Txs = append(req.Txs, dataHash, squareSizeBytes)
return abci.ResponsePrepareProposal{Txs: req.Txs}
}

func (app *Application) ProcessProposal(
req abci.RequestProcessProposal) abci.ResponseProcessProposal {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}
}

func (app *Application) Rollback() error {
return app.state.Rollback()
}
Expand Down

0 comments on commit 6a6a610

Please sign in to comment.