Skip to content

Compute shares#60

Closed
liamsi wants to merge 20 commits intomasterfrom
ismail/integrate_nmt_rsmt2d
Closed

Compute shares#60
liamsi wants to merge 20 commits intomasterfrom
ismail/integrate_nmt_rsmt2d

Conversation

@liamsi
Copy link
Member

@liamsi liamsi commented Sep 16, 2020

Description

Closes: #XXX

@liamsi liamsi marked this pull request as draft September 16, 2020 12:19
"encoding/binary"
"fmt"

"github.com/gogo/protobuf/proto"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a minor note: I would be wary of adding gogoproto further into the repo. The upstream repo will work on removing this dependency in the future.

Copy link
Member Author

@liamsi liamsi Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, thanks! As soon as upstream will remove this, we'll upgrade too. Here, we only use it to "decorate" (gogo) proto.Messages with a MarshalDelimited method. For Tx, and (LL) Message, I have to length prefix manually anyways though.
I'll be careful to not introduce it in packages that do not already use it (types does depend on it anyways).

types/shares.go Outdated
Comment on lines +86 to +116
func MakeShares(data []LenDelimitedMarshaler, shareSize int, nidFunc func(elem interface{}) namespace.ID) NamespacedShares {
if shareSize <= 0 {
panic("invalid shareSize")
}
shares := make([]NamespacedShare, 0)
for _, element := range data {
// TODO: implement a helper that also returns the size
// to make it possible to (cleanly) implement:
// https://github.com/lazyledger/lazyledger-specs/issues/69
// For now, we do not squeeze multiple Tx into one share and
// hence can ignore prefixing with the starting location of the
// first start of a transaction in the share (aka SHARE_RESERVED_BYTES)
rawData, err := element.MarshalDelimited()
if err != nil {
// The (abci) app has to guarantee that it only includes messages
// that can be encoded without an error (equivalently tendermint
// must not include any Tx, Evidence etc that is unencodable)
panic(fmt.Sprintf("can not encode %v", element))
}
nid := nidFunc(element)
if len(rawData) < shareSize {
rawShare := rawData
paddedShare := zeroPadIfNecessary(rawShare, shareSize)
share := NamespacedShare{paddedShare, nid}
shares = append(shares, share)
} else { // len(rawData) >= shareWithoutNidSize:
shares = append(shares, split(rawData, shareSize, nid)...)
}
}
return shares
}
Copy link
Member Author

@liamsi liamsi Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adlerjohn I'll leave away prefixing with the reserved share bytes and initially treat Tx, Evidence etc no different than (LL) Messages in the sense that one share will contain one Tx.

Copy link
Member Author

@liamsi liamsi Sep 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning, I'm intentionally skipping the * in https://github.com/lazyledger/lazyledger-specs/blob/master/specs/figures/share.svg as there is always only one Tx per share in the first version.

ref: celestiaorg/celestia-specs#69

@github-actions
Copy link

github-actions bot commented Oct 3, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 3, 2020
@github-actions github-actions bot closed this Oct 7, 2020
@liamsi liamsi removed the Stale label Oct 7, 2020
@liamsi liamsi reopened this Oct 7, 2020
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 18, 2020
@github-actions github-actions bot closed this Oct 22, 2020
@liamsi liamsi mentioned this pull request Oct 26, 2020
6 tasks
@liamsi liamsi deleted the ismail/integrate_nmt_rsmt2d branch December 15, 2020 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants