Skip to content

Commit

Permalink
Merge branch 'evan/nmt-subroot-path-gen' of https://github.com/celest…
Browse files Browse the repository at this point in the history
…iaorg/celestia-app into evan/nmt-subroot-path-gen
  • Loading branch information
evan-forbes committed Aug 19, 2022
2 parents b607473 + b2db386 commit d2d645b
Show file tree
Hide file tree
Showing 15 changed files with 1,379 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build
coverage.txt
tools-stamp
.vscode
profile.out
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ build-docker:
include contrib/devtools/Makefile
include contrib/devtools/sims.mk

test: test-unit test-build
test: test-unit

test-all: check test-race test-cover

Expand All @@ -83,5 +83,5 @@ benchmark:
@go test -mod=readonly -bench=. ./...

test-cover:
@export VERSION=$(VERSION); bash -x contrib/test_cover.sh
@export VERSION=$(VERSION); bash -x scripts/test_cover.sh
.PHONY: test-cover
21 changes: 16 additions & 5 deletions app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"bytes"

shares "github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/x/payment/types"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -54,6 +55,8 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
rejectedPropBlockLog,
"reason",
"varying number of messages and payForData txs in the same block",
"proposerAddress",
req.Header.ProposerAddress,
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
Expand All @@ -70,6 +73,8 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
"found a message that uses an invalid namespace id",
"error",
err.Error(),
"proposerAddress",
req.Header.ProposerAddress,
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
Expand All @@ -84,6 +89,8 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
"failure to create commitment for included message",
"error",
err.Error(),
"proposerAddress",
req.Header.ProposerAddress,
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
Expand All @@ -92,7 +99,7 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr

// TODO: refactor to actually check for subtree roots instead of simply inclusion see issues #382 and #383
if _, has := commitments[string(commit)]; !has {
app.Logger().Info(rejectedPropBlockLog, "reason", "missing MsgPayForData for included message")
app.Logger().Error(rejectedPropBlockLog, "reason", "missing MsgPayForData for included message", "proposerAddress", req.Header.ProposerAddress)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
Expand All @@ -101,7 +108,7 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr

data, err := coretypes.DataFromProto(req.BlockData)
if err != nil {
app.Logger().Error(rejectedPropBlockLog, "reason", "failure to unmarshal block data:", "error", err)
app.Logger().Error(rejectedPropBlockLog, "reason", "failure to unmarshal block data:", "error", err, "proposerAddress", req.Header.ProposerAddress)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
Expand All @@ -114,22 +121,24 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
}
}

shares, _, err := data.ComputeShares(req.BlockData.OriginalSquareSize)
nsshares, _, err := shares.ComputeShares(&data, req.BlockData.OriginalSquareSize)
if err != nil {
app.Logger().Error(rejectedPropBlockLog, "reason", "failure to compute shares from block data:", "error", err)
app.Logger().Error(rejectedPropBlockLog, "reason", "failure to compute shares from block data:", "error", err, "proposerAddress", req.Header.ProposerAddress)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
}

eds, err := da.ExtendShares(req.BlockData.OriginalSquareSize, shares.RawShares())
eds, err := da.ExtendShares(req.BlockData.OriginalSquareSize, nsshares.RawShares())
if err != nil {
app.Logger().Error(
rejectedPropBlockLog,
"reason",
"failure to erasure the data square",
"error",
err,
"proposerAddress",
req.Header.ProposerAddress,
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
Expand All @@ -143,6 +152,8 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr
rejectedPropBlockLog,
"reason",
"proposed data root differs from calculated data root",
"proposerAddress",
req.Header.ProposerAddress,
)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
Expand Down
3 changes: 2 additions & 1 deletion app/split_shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/sha256"
"sort"

shares "github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/x/payment/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
Expand Down Expand Up @@ -136,7 +137,7 @@ func newShareSplitter(txConf client.TxConfig, squareSize uint64, data *core.Data
if err != nil {
panic(err)
}
sqwr.evdShares = evdData.SplitIntoShares().RawShares()
sqwr.evdShares = shares.SplitEvidenceIntoShares(evdData).RawShares()

sqwr.txWriter = coretypes.NewContiguousShareWriter(consts.TxNamespaceID)
sqwr.msgWriter = coretypes.NewMessageShareWriter()
Expand Down
7 changes: 4 additions & 3 deletions app/test/process_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
shares "github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/testutil"
"github.com/celestiaorg/celestia-app/x/payment/types"
"github.com/celestiaorg/nmt/namespace"
Expand Down Expand Up @@ -150,7 +151,7 @@ func TestMessageInclusionCheck(t *testing.T) {
data, err := coretypes.DataFromProto(tt.input.BlockData)
require.NoError(t, err)

shares, _, err := data.ComputeShares(tt.input.BlockData.OriginalSquareSize)
shares, _, err := shares.ComputeShares(&data, tt.input.BlockData.OriginalSquareSize)
require.NoError(t, err)

rawShares := shares.RawShares()
Expand Down Expand Up @@ -206,7 +207,7 @@ func TestProcessMessagesWithReservedNamespaces(t *testing.T) {
data, err := coretypes.DataFromProto(input.BlockData)
require.NoError(t, err)

shares, _, err := data.ComputeShares(input.BlockData.OriginalSquareSize)
shares, _, err := shares.ComputeShares(&data, input.BlockData.OriginalSquareSize)
require.NoError(t, err)

rawShares := shares.RawShares()
Expand Down Expand Up @@ -257,7 +258,7 @@ func TestProcessMessageWithUnsortedMessages(t *testing.T) {
data, err := coretypes.DataFromProto(input.BlockData)
require.NoError(t, err)

shares, _, err := data.ComputeShares(input.BlockData.OriginalSquareSize)
shares, _, err := shares.ComputeShares(&data, input.BlockData.OriginalSquareSize)
require.NoError(t, err)

rawShares := shares.RawShares()
Expand Down
3 changes: 2 additions & 1 deletion app/test/split_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
shares "github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -105,7 +106,7 @@ func TestSplitShares(t *testing.T) {

assert.Equal(t, data.Txs, parsedData.Txs.ToSliceOfBytes())

parsedShares, _, err := parsedData.ComputeShares(tt.squareSize)
parsedShares, _, err := shares.ComputeShares(&parsedData, tt.squareSize)
require.NoError(t, err)

require.Equal(t, square, parsedShares.RawShares())
Expand Down
4 changes: 2 additions & 2 deletions contrib/Dockerfile.test → docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY . .

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES && \
make install
make install

# Final image
FROM alpine:edge
Expand All @@ -27,7 +27,7 @@ WORKDIR /root
# Copy over binaries from the build-env
COPY --from=build-env /go/bin/celestia-appd /usr/bin/celestia-appd

COPY ./contrib/single-node.sh .
COPY ./scripts/single-node.sh .

EXPOSE 26657

Expand Down
Loading

0 comments on commit d2d645b

Please sign in to comment.