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

feat!: drop support for infectious #154

Merged
merged 3 commits into from
Mar 16, 2023
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
3 changes: 0 additions & 3 deletions codecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const (
// uses 8-bit leopard for shards less than or equal to 256. The Leopard
// codec uses 16-bit leopard for shards greater than 256.
Leopard = "Leopard"
// RSGF8 stands for Reed-Solomon Galois Field 8-bit mode. This codec uses
// https://pkg.go.dev/github.com/vivint/infectious.
RSGF8 = "RSGF8"
)

type Codec interface {
Expand Down
3 changes: 0 additions & 3 deletions extendeddatacrossword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestRepairExtendedDataSquare(t *testing.T) {
codec Codec
}{
{"leopard", bufferSize, NewLeoRSCodec()},
{"infectiousGF8", bufferSize, NewRSGF8Codec()},
}

for _, test := range tests {
Expand Down Expand Up @@ -96,7 +95,6 @@ func TestValidFraudProof(t *testing.T) {
codec Codec
}{
{"leopard", bufferSize, NewLeoRSCodec()},
{"infectiousGF8", bufferSize, NewRSGF8Codec()},
}

for _, test := range tests {
Expand Down Expand Up @@ -147,7 +145,6 @@ func TestCannotRepairSquareWithBadRoots(t *testing.T) {
codec Codec
}{
{"leopard", bufferSize, NewLeoRSCodec()},
{"infectiousGF8", bufferSize, NewRSGF8Codec()},
}

for _, test := range tests {
Expand Down
90 changes: 67 additions & 23 deletions extendeddatasquare_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,81 @@
package rsmt2d

import (
"bytes"
"crypto/rand"
"encoding/json"
"fmt"
"reflect"
"testing"

"github.com/stretchr/testify/assert"
)

const SHARD_SIZE = 64

var (
zeros = bytes.Repeat([]byte{0}, SHARD_SIZE)
ones = bytes.Repeat([]byte{1}, SHARD_SIZE)
twos = bytes.Repeat([]byte{2}, SHARD_SIZE)
threes = bytes.Repeat([]byte{3}, SHARD_SIZE)
fours = bytes.Repeat([]byte{4}, SHARD_SIZE)
fives = bytes.Repeat([]byte{5}, SHARD_SIZE)
eights = bytes.Repeat([]byte{8}, SHARD_SIZE)
elevens = bytes.Repeat([]byte{11}, SHARD_SIZE)
thirteens = bytes.Repeat([]byte{13}, SHARD_SIZE)
fifteens = bytes.Repeat([]byte{15}, SHARD_SIZE)
)

func TestComputeExtendedDataSquare(t *testing.T) {
codec := NewRSGF8Codec()
result, err := ComputeExtendedDataSquare([][]byte{
{1}, {2},
{3}, {4},
}, codec, NewDefaultTree)
if err != nil {
panic(err)
codec := NewLeoRSCodec()

type testCase struct {
name string
data [][]byte
want [][][]byte
}
if !reflect.DeepEqual(result.squareRow, [][][]byte{
{{1}, {2}, {7}, {13}},
{{3}, {4}, {13}, {31}},
{{5}, {14}, {19}, {41}},
{{9}, {26}, {47}, {69}},
}) {
t.Errorf("NewExtendedDataSquare failed for 2x2 square with chunk size 1")
testCases := []testCase{
{
name: "1x1",
// NOTE: data must contain byte slices that are a multiple of 64
// bytes.
// See https://github.com/catid/leopard/blob/22ddc7804998d31c8f1a2617ee720e063b1fa6cd/README.md?plain=1#L27
// See https://github.com/klauspost/reedsolomon/blob/fd3e6910a7e457563469172968f456ad9b7696b6/README.md?plain=1#L403
data: [][]byte{ones},
want: [][][]byte{
{ones, ones},
{ones, ones},
},
},
{
name: "2x2",
data: [][]byte{
ones, twos,
threes, fours,
},
want: [][][]byte{
{ones, twos, zeros, threes},
{threes, fours, eights, fifteens},
{twos, elevens, thirteens, fours},
{zeros, thirteens, fives, eights},
},
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result, err := ComputeExtendedDataSquare(tc.data, codec, NewDefaultTree)
assert.NoError(t, err)
assert.Equal(t, tc.want, result.squareRow)
})
}
}

func TestMarshalJSON(t *testing.T) {
codec := NewRSGF8Codec()
codec := NewLeoRSCodec()
result, err := ComputeExtendedDataSquare([][]byte{
{1}, {2},
{3}, {4},
ones, twos,
threes, fours,
}, codec, NewDefaultTree)
if err != nil {
panic(err)
Expand All @@ -53,10 +97,10 @@ func TestMarshalJSON(t *testing.T) {
}

func TestImmutableRoots(t *testing.T) {
codec := NewRSGF8Codec()
codec := NewLeoRSCodec()
result, err := ComputeExtendedDataSquare([][]byte{
{1}, {2},
{3}, {4},
ones, twos,
threes, fours,
}, codec, NewDefaultTree)
if err != nil {
panic(err)
Expand All @@ -76,10 +120,10 @@ func TestImmutableRoots(t *testing.T) {
}

func TestEDSRowColImmutable(t *testing.T) {
codec := NewRSGF8Codec()
codec := NewLeoRSCodec()
result, err := ComputeExtendedDataSquare([][]byte{
{1}, {2},
{3}, {4},
ones, twos,
threes, fours,
}, codec, NewDefaultTree)
if err != nil {
panic(err)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.19
require (
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4
github.com/stretchr/testify v1.7.0
github.com/vivint/infectious v0.0.0-20200605153912-25a574ae18a3
)

require (
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vivint/infectious v0.0.0-20200605153912-25a574ae18a3 h1:zMsHhfK9+Wdl1F7sIKLyx3wrOFofpb3rWFbA4HgcK5k=
github.com/vivint/infectious v0.0.0-20200605153912-25a574ae18a3/go.mod h1:R0Gbuw7ElaGSLOZUSwBm/GgVwMd30jWxBDdAyMOeTuc=
gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8=
gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975 h1:L/ENs/Ar1bFzUeKx6m3XjlmBgIUlykX9dzvp5k9NGxc=
gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8=
Expand All @@ -38,7 +36,6 @@ golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 h1:cu5kTvlzcw1Q5S9f5ip1/cpi
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
98 changes: 0 additions & 98 deletions infectiousRSGF8.go

This file was deleted.

2 changes: 0 additions & 2 deletions rsmt2d_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func TestEdsRepairRoundtripSimple(t *testing.T) {
codec rsmt2d.Codec
}{
{"leopard", bufferSize, rsmt2d.NewLeoRSCodec()},
{"infectiousGF8", bufferSize, rsmt2d.NewRSGF8Codec()},
}

for _, tt := range tests {
Expand Down Expand Up @@ -84,7 +83,6 @@ func TestEdsRepairTwice(t *testing.T) {
codec rsmt2d.Codec
}{
{"leopard", bufferSize, rsmt2d.NewLeoRSCodec()},
{"infectiousGF8", bufferSize, rsmt2d.NewRSGF8Codec()},
}

for _, tt := range tests {
Expand Down