Skip to content

Commit

Permalink
feat: Txs To Shares Roundtrip (rollkit#889)
Browse files Browse the repository at this point in the history
Adds ability to:
- Convert `TxWithISRs` to Shares
- Convert Shares to byte array (that will be posted on celestia)
- Convert above byte array back to Shares
- Convert Shares back to `TxWithISRs`
- Parse Out of Context Shares

Adds relevant roundtrip tests

Resolves rollkit#881
Resolves rollkit#934
Resolves rollkit#886
Resolves rollkit#925

Note: All shares are written and interpreted as compact shares so they
contain reserved bytes (see
https://celestiaorg.github.io/celestia-app/specs/data_structures.html#compact-share)

Related PR in `celestia-app`:
celestiaorg/celestia-app#1770
  • Loading branch information
Manav-Aggarwal authored and chandiniv1 committed Oct 31, 2023
1 parent c5efeb6 commit 87b5b3b
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions third_party/celestia-app/testfactory/txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,3 @@ func GenerateRandomTxs(count, size int) types.Txs {
}
return txs
}
<<<<<<< HEAD

// GetRandomSubSlice returns two integers representing a randomly sized range in the interval [0, size]
func GetRandomSubSlice(size int) (start int, length int) {
length = mrand.Intn(size + 1) //nolint:gosec
start = mrand.Intn(size - length + 1) //nolint:gosec
return start, length
}

// CheckSubArray returns whether subTxList is a subarray of txList
func CheckSubArray(txList []types.Tx, subTxList []types.Tx) bool {
for i := 0; i <= len(txList)-len(subTxList); i++ {
j := 0
for j = 0; j < len(subTxList); j++ {
tx := txList[i+j]
subTx := subTxList[j]
if !bytes.Equal([]byte(tx), []byte(subTx)) {
break
}
}
if j == len(subTxList) {
return true
}
}
return false
}
=======
>>>>>>> d71f90e (chore: repo refactoring (#1217))

0 comments on commit 87b5b3b

Please sign in to comment.