Skip to content

Commit

Permalink
Merge pull request #20 from sunriselayer/txs-empty-byte
Browse files Browse the repository at this point in the history
Txs empty byte
  • Loading branch information
Senna46 committed May 2, 2024
2 parents 8519448 + 3680ecd commit 143b135
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1,811 deletions.
2 changes: 2 additions & 0 deletions app/abci_prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func (app *App) PrepareProposal(req *abci.RequestPrepareProposal) (*abci.Respons
}

func AppendInfoInTxs(txs [][]byte, dataHash []byte, squareSize uint64) [][]byte {
// add empty byte slice
txs = append(txs, []byte{})
txs = append(txs, dataHash)
squareSizeBigEndican := make([]byte, 8)
binary.BigEndian.PutUint64(squareSizeBigEndican, squareSize)
Expand Down
24 changes: 8 additions & 16 deletions app/abci_process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,14 @@ func accept() (*abci.ResponseProcessProposal, error) {

func ExtractInfoFromTxs(txsWithInfo [][]byte) (txs [][]byte, dataHash []byte, squareSize uint64, err error) {
length := len(txsWithInfo)
if length == 0 {
txs = txsWithInfo
dataHash = nil
squareSize = 0
return
}

if length < 2 {
err = fmt.Errorf("txs must contain the data hash and the square size at the end, and its length must not be lower than 2")
return
txs = txsWithInfo
if length >= 3 {
if len(txsWithInfo[length-3]) == 0 {
txs = txsWithInfo[:length-3]
dataHash = txsWithInfo[length-2]
squareSizeBigEndian := txsWithInfo[length-1]
squareSize = binary.BigEndian.Uint64(squareSizeBigEndian)
}
}

txs = txsWithInfo[:length-2]
dataHash = txsWithInfo[length-2]
squareSizeBigEndian := txsWithInfo[length-1]
squareSize = binary.BigEndian.Uint64(squareSizeBigEndian)

return
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.21.5

replace (
// sunrise-core
github.com/cometbft/cometbft => github.com/sunriselayer/sunrise-core v0.0.2-cmt-v0.38.2
github.com/cometbft/cometbft => github.com/sunriselayer/sunrise-core v0.38.3-0.20240501122917-4aaf7f2fc839
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

github.com/sunriselayer/sunrise-app/pkg/blob => ./pkg/blob
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,8 @@ github.com/sunrise-zone/sunrise-app/pkg/blob v0.0.0-20240106110541-17a39acb5414
github.com/sunrise-zone/sunrise-app/pkg/blob v0.0.0-20240106110541-17a39acb5414/go.mod h1:lKWVDRG4sv50z+TJycD8+Vf8b3AmWVwiNoLWxJlbte8=
github.com/sunrise-zone/sunrise-app/pkg/namespace v0.0.0-20240106114425-fcbe9cdfd972 h1:G/7AApJQ6KU+DEqQ0y1BQDcLySj21RoSg/sRqtodaB8=
github.com/sunrise-zone/sunrise-app/pkg/namespace v0.0.0-20240106114425-fcbe9cdfd972/go.mod h1:u36JI/3vny+qvLQqKS2wTZeK9xQ55ijkmlcp6YodBtA=
github.com/sunriselayer/sunrise-core v0.0.2-cmt-v0.38.2 h1:8LnGInUBOx/2WcFwf6uiCprUzKYBeSsLBNYHvSMSF18=
github.com/sunriselayer/sunrise-core v0.0.2-cmt-v0.38.2/go.mod h1:y+21SZ2TVD1qS7lvEXfDKI15hEryT9sNvJ+t3LyAFi0=
github.com/sunriselayer/sunrise-core v0.38.3-0.20240501122917-4aaf7f2fc839 h1:cA9pp+VKXzkcBaLGl06TJAmjZHt6aLdAr8VBz0W7wbM=
github.com/sunriselayer/sunrise-core v0.38.3-0.20240501122917-4aaf7f2fc839/go.mod h1:y+21SZ2TVD1qS7lvEXfDKI15hEryT9sNvJ+t3LyAFi0=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
Expand Down

0 comments on commit 143b135

Please sign in to comment.