Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simplified version of ABCI++ #214

Merged
merged 3 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions app/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
// PreprocessTxs fullfills the celestia-core version of the ACBI interface, by
// performing basic validation for the incoming txs, and by cleanly separating
// share messages from transactions
func (app *App) PreprocessTxs(txs abci.RequestPreprocessTxs) abci.ResponsePreprocessTxs {
func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePrepareProposal {
squareSize := app.SquareSize()
shareCounter := uint64(0)
var shareMsgs []*core.Message
var processedTxs [][]byte
for _, rawTx := range txs.Txs {
for _, rawTx := range req.BlockData.Txs {
// decode the Tx
tx, err := app.txConfig.TxDecoder()(rawTx)
if err != nil {
Expand Down Expand Up @@ -101,9 +101,12 @@ func (app *App) PreprocessTxs(txs abci.RequestPreprocessTxs) abci.ResponsePrepro
return bytes.Compare(shareMsgs[i].NamespaceId, shareMsgs[j].NamespaceId) < 0
})

return abci.ResponsePreprocessTxs{
Txs: processedTxs,
Messages: &core.Messages{MessagesList: shareMsgs},
return abci.ResponsePrepareProposal{
BlockData: &core.Data{
Txs: processedTxs,
Evidence: req.BlockData.Evidence,
Messages: core.Messages{MessagesList: shareMsgs},
},
}
}

Expand All @@ -121,4 +124,4 @@ func hasWirePayForMessage(tx sdk.Tx) bool {
// hardcoded. todo(evan): don't hardcode the square size
func (app *App) SquareSize() uint64 {
return consts.MaxSquareSize
}
}
16 changes: 9 additions & 7 deletions app/test/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
core "github.com/tendermint/tendermint/proto/tendermint/types"
)

func TestPreprocessTxs(t *testing.T) {
func TestPrepareProposal(t *testing.T) {
signer := testutil.GenerateKeyringSigner(t, testAccName)
info := signer.GetSignerInfo()

Expand All @@ -26,7 +26,7 @@ func TestPreprocessTxs(t *testing.T) {
testApp := testutil.SetupTestApp(t, info.GetAddress())

type test struct {
input abci.RequestPreprocessTxs
input abci.RequestPrepareProposal
expectedMessages []*core.Message
expectedTxs int
}
Expand All @@ -45,8 +45,10 @@ func TestPreprocessTxs(t *testing.T) {

tests := []test{
{
input: abci.RequestPreprocessTxs{
Txs: [][]byte{firstRawTx, secondRawTx, thirdRawTx},
input: abci.RequestPrepareProposal{
BlockData: &core.Data{
Txs: [][]byte{firstRawTx, secondRawTx, thirdRawTx},
},
},
expectedMessages: []*core.Message{
{
Expand All @@ -67,9 +69,9 @@ func TestPreprocessTxs(t *testing.T) {
}

for _, tt := range tests {
res := testApp.PreprocessTxs(tt.input)
assert.Equal(t, tt.expectedMessages, res.Messages.MessagesList)
assert.Equal(t, tt.expectedTxs, len(res.Txs))
res := testApp.PrepareProposal(tt.input)
assert.Equal(t, tt.expectedMessages, res.BlockData.Messages.MessagesList)
assert.Equal(t, tt.expectedTxs, len(res.BlockData.Txs))
}
}

Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ go 1.17

require (
github.com/celestiaorg/nmt v0.8.0
github.com/cosmos/cosmos-sdk v0.44.0
github.com/cosmos/ibc-go v1.2.0
github.com/cosmos/cosmos-sdk v0.44.3
github.com/cosmos/ibc-go v1.2.2
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.3.0
github.com/stretchr/testify v1.7.0
github.com/tendermint/spm v0.1.5
github.com/tendermint/tendermint v0.34.13
github.com/tendermint/tm-db v0.6.4
github.com/tendermint/spm v0.1.9
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.6
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
Expand Down Expand Up @@ -78,7 +78,7 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.11.7 // indirect
github.com/lib/pq v1.2.0 // indirect
github.com/lib/pq v1.10.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -93,7 +93,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.29.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
Expand All @@ -113,7 +113,7 @@ require (
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/vivint/infectious v0.0.0-20200605153912-25a574ae18a3 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
Expand All @@ -124,8 +124,8 @@ require (

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.44.1-celestia
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v0.44.2-celestia-rc-1
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v0.34.14-celestia.0.20220119223021-e54097114e14
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v0.34.16-celestia-rc-1
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading