From eebd330c1b492dbbead822966576bd5f0ecdd3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Mon, 30 Sep 2024 10:26:10 +0200 Subject: [PATCH 1/8] feat: WIP implementation - return a single batch WIP. Test should fail. --- go.mod | 9 ++++- go.sum | 12 ++++-- sequencer.go | 22 +++++++++-- sequencer_test.go | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 sequencer_test.go diff --git a/go.mod b/go.mod index b642001..230bd44 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,22 @@ module github.com/rollkit/based-sequencer go 1.23.1 require ( - github.com/rollkit/go-da v0.7.0 - github.com/rollkit/go-sequencing v0.1.0 + github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 + github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072 + github.com/stretchr/testify v1.9.0 ) require ( github.com/cosmos/gogoproto v1.7.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect google.golang.org/grpc v1.67.0 // indirect google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4cc56f8..12bb8da 100644 --- a/go.sum +++ b/go.sum @@ -8,10 +8,12 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rollkit/go-da v0.7.0 h1:b4o5dWCCqwH0fbbhfNOoLraAsCHjN5PV1Z2rNkUB+pU= -github.com/rollkit/go-da v0.7.0/go.mod h1:9YCbEhUkF/QHbbKPBe5uvu93Co/mgPRtYjlwj6GPuhI= -github.com/rollkit/go-sequencing v0.1.0 h1:LL6QT5pekydPLxeU8ncRoRlkdbJpM8fcsu+Uw15H4sE= -github.com/rollkit/go-sequencing v0.1.0/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= +github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 h1:MkNGLP+SIC4MiA0ZXxDqebc7Xv8duTEwqS29/z5Gn1Q= +github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20/go.mod h1:3eHWK5gkv8lhwq6bjOZOi82WwHyS2B9rQOlUrE1GGws= +github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072 h1:ryzQ53hpEZ/tzsweDkEFUP3ovFcmi0IBye4JhCNIs+8= +github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= @@ -26,5 +28,7 @@ google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sequencer.go b/sequencer.go index 89db3ab..e0f5ce0 100644 --- a/sequencer.go +++ b/sequencer.go @@ -25,14 +25,28 @@ var _ sequencing.Sequencer = (*BasedSequencer)(nil) // SubmitRollupTransaction submits a transaction directly to DA, as a single blob. func (b *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error { - //TODO implement me - panic("implement me") + _, err := b.da.Submit(ctx, []da.Blob{tx}, 0, rollupId) + if err != nil { + return err + } + return nil } // GetNextBatch reads data from namespace in DA and builds transactions batches. func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { - //TODO implement me - panic("implement me") + // TODO(tzdybal): this needs to be a field + lastHeight := uint64(1) + namespace := []byte("test namespace") + result, err := b.da.GetIDs(ctx, lastHeight, namespace) + if err != nil { + return nil, time.Time{}, err + } + blobs, err := b.da.Get(ctx, result.IDs, namespace) + if err != nil { + return nil, time.Time{}, err + } + + return &sequencing.Batch{Transactions: blobs}, result.Timestamp, nil } // VerifyBatch ensures data-availability of a batch in DA. diff --git a/sequencer_test.go b/sequencer_test.go new file mode 100644 index 0000000..4d732bb --- /dev/null +++ b/sequencer_test.go @@ -0,0 +1,98 @@ +package based_sequencer + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + + "github.com/rollkit/go-da" + "github.com/rollkit/go-da/mocks" + "github.com/rollkit/go-sequencing" +) + +func TestNewSequencer(t *testing.T) { + mockDA := mocks.NewMockDA(t) + seq := NewSequencer(mockDA) + require.NotNil(t, seq) +} + +// TestSubmitRollupTransaction ensures that single rollup transaction submitted to sequencer is submitted as one blob to DA. +func TestSubmitRollupTransaction(t *testing.T) { + mockDA := mocks.NewMockDA(t) + seq := NewSequencer(mockDA) + require.NotNil(t, seq) + + const ( + rollupId = "test rollup" + testTx = "this is a random transaction" + ) + + // make sure that sequencer submits only one blob, and transaction is included in this blob + // this is not `Equals` test, because the actual tx -> blob mapping is not yet defined + mockDA.On("Submit", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Run(func(args mock.Arguments) { + blobs, ok := args.Get(1).([]da.Blob) + require.True(t, ok) + require.Len(t, blobs, 1) + require.Contains(t, string(blobs[0]), testTx) + }).Return(nil, nil).Once() + + err := seq.SubmitRollupTransaction(context.Background(), sequencing.RollupId(rollupId), sequencing.Tx(testTx)) + require.NoError(t, err) + + mockDA.AssertExpectations(t) +} + +func TestGetNextBatch(t *testing.T) { + var ( + testNamespace = []byte("test namespace") + //blockTime = 1 * time.Second + ) + + mockDA := mocks.NewMockDA(t) + + // sequencer needs to ask about MaxBytes + mockDA.On("MaxBlobSize", mock.Anything).Return(int64(1000), nil) + // some IDs are returned, so mocked blobs can be easily handled + mockDA.On("GetIDs", mock.Anything, uint64(1), testNamespace).Return(&da.GetIDsResult{ + IDs: []da.ID{{1}, {2}, {3}}, + Timestamp: time.Now(), + }, nil).Once() + //mockDA.On("GetIDs", mock.Anything, uint64(2), testNamespace).Return(da.GetIDsResult{ + // IDs: []da.ID{{4}, {4}}, + // Timestamp: time.Now().Add(blockTime), + //}, nil).Once() + //mockDA.On("GetIDs", mock.Anything, uint64(3), testNamespace).Return(da.GetIDsResult{ + // IDs: []da.ID{{6}, {7}, {8}, {9}}, + // Timestamp: time.Now().Add(2 * blockTime), + //}, nil).Once() + + transactions := make([][]byte, 10) + for i := 0; i < len(transactions); i++ { + transactions[i] = []byte(fmt.Sprintf("transaction %d", i)) + } + mockDA.On("Get", mock.Anything, mock.Anything, testNamespace).Return( + func(ctx context.Context, ids []da.ID, namespace da.Namespace) ([]da.Blob, error) { + blobs := make([]da.Blob, len(ids)) + for i := range ids { + blobs[i] = transactions[i] + } + return blobs, nil + }) + + seq := NewSequencer(mockDA) + require.NotNil(t, seq) + + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + t.Cleanup(cancel) + + batch, ts, err := seq.GetNextBatch(ctx, nil) + require.NoError(t, err) + require.NotNil(t, batch) + require.NotEmpty(t, ts) + + mockDA.AssertExpectations(t) +} From 1b5b783b1f0a619784640af18f19848f126e47c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Mon, 30 Sep 2024 12:52:01 +0200 Subject: [PATCH 2/8] feat: add DA height tracking to sequencer WIP. `lastBatchHash` is still ignored, but sequencer is traversing DA. --- sequencer.go | 27 ++++++++++++++++---- sequencer_test.go | 63 ++++++++++++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/sequencer.go b/sequencer.go index e0f5ce0..d0f302c 100644 --- a/sequencer.go +++ b/sequencer.go @@ -2,6 +2,8 @@ package based_sequencer import ( "context" + "strings" + "sync/atomic" "time" "github.com/rollkit/go-da" @@ -14,11 +16,15 @@ import ( // When batch is requested DA blocks are scanned to read all blobs from given namespace at given height. type BasedSequencer struct { da da.DA + + daHeight atomic.Uint64 } // NewSequencer initializes a BasedSequencer with the provided DA implementation. func NewSequencer(da da.DA) *BasedSequencer { - return &BasedSequencer{da: da} + seq := &BasedSequencer{da: da} + seq.daHeight.Store(1) // TODO(tzdybal): this needs to be config or constructor param + return seq } var _ sequencing.Sequencer = (*BasedSequencer)(nil) @@ -35,12 +41,23 @@ func (b *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId s // GetNextBatch reads data from namespace in DA and builds transactions batches. func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { // TODO(tzdybal): this needs to be a field - lastHeight := uint64(1) namespace := []byte("test namespace") - result, err := b.da.GetIDs(ctx, lastHeight, namespace) - if err != nil { - return nil, time.Time{}, err + + var err error + result := &da.GetIDsResult{} + + for ctx.Err() == nil && len(result.IDs) == 0 { + result, err = b.da.GetIDs(ctx, b.daHeight.Load(), namespace) + if err != nil { + if strings.Contains(err.Error(), "given height is from the future") { + time.Sleep(100 * time.Millisecond) // TODO(tzdybal): this needs to be configurable + continue + } + return nil, time.Time{}, err + } + b.daHeight.Add(1) } + blobs, err := b.da.Get(ctx, result.IDs, namespace) if err != nil { return nil, time.Time{}, err diff --git a/sequencer_test.go b/sequencer_test.go index 4d732bb..07070bf 100644 --- a/sequencer_test.go +++ b/sequencer_test.go @@ -49,39 +49,45 @@ func TestSubmitRollupTransaction(t *testing.T) { func TestGetNextBatch(t *testing.T) { var ( testNamespace = []byte("test namespace") - //blockTime = 1 * time.Second + blockTime = 1 * time.Second ) mockDA := mocks.NewMockDA(t) // sequencer needs to ask about MaxBytes - mockDA.On("MaxBlobSize", mock.Anything).Return(int64(1000), nil) + //mockDA.On("MaxBlobSize", mock.Anything).Return(int64(1000), nil) // some IDs are returned, so mocked blobs can be easily handled - mockDA.On("GetIDs", mock.Anything, uint64(1), testNamespace).Return(&da.GetIDsResult{ - IDs: []da.ID{{1}, {2}, {3}}, - Timestamp: time.Now(), - }, nil).Once() - //mockDA.On("GetIDs", mock.Anything, uint64(2), testNamespace).Return(da.GetIDsResult{ - // IDs: []da.ID{{4}, {4}}, - // Timestamp: time.Now().Add(blockTime), - //}, nil).Once() - //mockDA.On("GetIDs", mock.Anything, uint64(3), testNamespace).Return(da.GetIDsResult{ - // IDs: []da.ID{{6}, {7}, {8}, {9}}, - // Timestamp: time.Now().Add(2 * blockTime), - //}, nil).Once() + batchIds := [][]da.ID{ + {{1}, {2}, {3}}, + {{4}, {4}}, + {{6}, {7}, {8}, {9}}, + } + + ts := time.Now() + for i := range batchIds { + mockDA.On("GetIDs", mock.Anything, uint64(i+1), testNamespace).Return(&da.GetIDsResult{ + IDs: batchIds[i], + Timestamp: ts, + }, nil).Once() + ts = ts.Add(blockTime) + } + // handle other requests, as GetNextBatch might iterate + mockDA.On("GetIDs", mock.Anything, mock.Anything, testNamespace).Return(&da.GetIDsResult{Timestamp: time.Now()}) transactions := make([][]byte, 10) for i := 0; i < len(transactions); i++ { transactions[i] = []byte(fmt.Sprintf("transaction %d", i)) } - mockDA.On("Get", mock.Anything, mock.Anything, testNamespace).Return( - func(ctx context.Context, ids []da.ID, namespace da.Namespace) ([]da.Blob, error) { - blobs := make([]da.Blob, len(ids)) - for i := range ids { - blobs[i] = transactions[i] - } - return blobs, nil - }) + makeBatch := func(ids []da.ID) []da.Blob { + blobs := make([]da.Blob, len(ids)) + for i := range ids { + blobs[i] = transactions[i] + } + return blobs + } + mockDA.On("Get", mock.Anything, mock.Anything, testNamespace).Return(func(_ context.Context, ids []da.ID, _ da.Namespace) ([]da.Blob, error) { + return makeBatch(ids), nil + }) seq := NewSequencer(mockDA) require.NotNil(t, seq) @@ -89,10 +95,15 @@ func TestGetNextBatch(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) t.Cleanup(cancel) - batch, ts, err := seq.GetNextBatch(ctx, nil) - require.NoError(t, err) - require.NotNil(t, batch) - require.NotEmpty(t, ts) + for i := 0; i < len(batchIds); i++ { + batch, ts, err := seq.GetNextBatch(ctx, nil) + require.NoError(t, err) + require.NotNil(t, batch) + require.NotEmpty(t, ts) + require.NoError(t, err) + expected := makeBatch(batchIds[i]) + require.Equal(t, expected, batch.Transactions) + } mockDA.AssertExpectations(t) } From cae2b5bc53f7975b00137ff7eec6485c7b96e19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Mon, 30 Sep 2024 13:19:28 +0200 Subject: [PATCH 3/8] test: add batch hashing --- sequencer.go | 10 ++++++++++ sequencer_test.go | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sequencer.go b/sequencer.go index d0f302c..4230143 100644 --- a/sequencer.go +++ b/sequencer.go @@ -2,6 +2,7 @@ package based_sequencer import ( "context" + "crypto/sha256" "strings" "sync/atomic" "time" @@ -71,3 +72,12 @@ func (b *BasedSequencer) VerifyBatch(ctx context.Context, batchHash sequencing.H //TODO implement me panic("implement me") } + +func BatchHash(batch *sequencing.Batch) (sequencing.Hash, error) { + batchBytes, err := batch.Marshal() + if err != nil { + return nil, err + } + h := sha256.Sum256(batchBytes) + return h[:], nil +} diff --git a/sequencer_test.go b/sequencer_test.go index 07070bf..c0c923b 100644 --- a/sequencer_test.go +++ b/sequencer_test.go @@ -95,14 +95,17 @@ func TestGetNextBatch(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) t.Cleanup(cancel) + var lastBatchHash sequencing.Hash for i := 0; i < len(batchIds); i++ { - batch, ts, err := seq.GetNextBatch(ctx, nil) + batch, ts, err := seq.GetNextBatch(ctx, lastBatchHash) require.NoError(t, err) require.NotNil(t, batch) require.NotEmpty(t, ts) require.NoError(t, err) expected := makeBatch(batchIds[i]) require.Equal(t, expected, batch.Transactions) + lastBatchHash, err = BatchHash(batch) + require.NoError(t, err) } mockDA.AssertExpectations(t) From 98a99e1d6c01cdcb6fa2f0fb0c2ad75532d90fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Mon, 30 Sep 2024 20:08:00 +0200 Subject: [PATCH 4/8] feat: introduce Store interface --- go.mod | 3 +++ go.sum | 7 ++++++ sequencer.go | 67 ++++++++++++++++++++++++++++++++++++++++++---------- store.go | 49 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 store.go diff --git a/go.mod b/go.mod index 230bd44..367496e 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,9 @@ require ( github.com/cosmos/gogoproto v1.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/ipfs/go-datastore v0.6.0 // indirect + github.com/jbenet/goprocess v0.1.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.2 // indirect golang.org/x/net v0.28.0 // indirect diff --git a/go.sum b/go.sum index 12bb8da..37bf6f8 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,13 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 h1:MkNGLP+SIC4MiA0ZXxDqebc7Xv8duTEwqS29/z5Gn1Q= diff --git a/sequencer.go b/sequencer.go index 4230143..cf37fee 100644 --- a/sequencer.go +++ b/sequencer.go @@ -3,10 +3,14 @@ package based_sequencer import ( "context" "crypto/sha256" + "errors" + "fmt" "strings" "sync/atomic" "time" + ds "github.com/ipfs/go-datastore" + "github.com/rollkit/go-da" "github.com/rollkit/go-sequencing" ) @@ -19,12 +23,15 @@ type BasedSequencer struct { da da.DA daHeight atomic.Uint64 + + store Store } // NewSequencer initializes a BasedSequencer with the provided DA implementation. func NewSequencer(da da.DA) *BasedSequencer { seq := &BasedSequencer{da: da} - seq.daHeight.Store(1) // TODO(tzdybal): this needs to be config or constructor param + seq.daHeight.Store(1) // TODO(tzdybal): this needs to be config or constructor param + seq.store = &KVStore{} // TODO(tzdybal): extract parameter return seq } @@ -41,14 +48,24 @@ func (b *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId s // GetNextBatch reads data from namespace in DA and builds transactions batches. func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { - // TODO(tzdybal): this needs to be a field - namespace := []byte("test namespace") + // optimistic case - we already know the hash after lastBatchHash + nextBatchHash, err := b.store.GetNextHash(ctx, lastBatchHash) + if err == nil { + height, err := b.store.GetHashMapping(ctx, nextBatchHash) + if err != nil { + return nil, time.Time{}, fmt.Errorf("store contents inconsistent: %w", err) + } + return b.getBatchByHeight(ctx, height) + } - var err error - result := &da.GetIDsResult{} + // if there is no indexing information in store, it's not an error + if !errors.Is(err, ds.ErrNotFound) { + return nil, time.Time{}, err + } - for ctx.Err() == nil && len(result.IDs) == 0 { - result, err = b.da.GetIDs(ctx, b.daHeight.Load(), namespace) + // we need to search for next batch + for ctx.Err() == nil { + batch, ts, err := b.getBatchByHeight(ctx, b.daHeight.Load()) if err != nil { if strings.Contains(err.Error(), "given height is from the future") { time.Sleep(100 * time.Millisecond) // TODO(tzdybal): this needs to be configurable @@ -56,15 +73,23 @@ func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequenc } return nil, time.Time{}, err } - b.daHeight.Add(1) - } - blobs, err := b.da.Get(ctx, result.IDs, namespace) - if err != nil { - return nil, time.Time{}, err + // TODO(tzdybal): extract method + hash, err := BatchHash(batch) + if err != nil { + return nil, time.Time{}, err + } + if err = b.store.SetNextHash(ctx, lastBatchHash, hash); err != nil { + return nil, time.Time{}, err + } + if err = b.store.SetHashMapping(ctx, hash, b.daHeight.Load()); err != nil { + return nil, time.Time{}, err + } + b.daHeight.Add(1) + return batch, ts, err } - return &sequencing.Batch{Transactions: blobs}, result.Timestamp, nil + return nil, time.Time{}, ctx.Err() } // VerifyBatch ensures data-availability of a batch in DA. @@ -81,3 +106,19 @@ func BatchHash(batch *sequencing.Batch) (sequencing.Hash, error) { h := sha256.Sum256(batchBytes) return h[:], nil } + +func (b *BasedSequencer) getBatchByHeight(ctx context.Context, height uint64) (*sequencing.Batch, time.Time, error) { + // TODO(tzdybal): this needs to be a field + namespace := []byte("test namespace") + result, err := b.da.GetIDs(ctx, height, namespace) + if err != nil { + return nil, time.Time{}, err + } + + blobs, err := b.da.Get(ctx, result.IDs, namespace) + if err != nil { + return nil, time.Time{}, err + } + + return &sequencing.Batch{Transactions: blobs}, result.Timestamp, nil +} diff --git a/store.go b/store.go new file mode 100644 index 0000000..da3ef72 --- /dev/null +++ b/store.go @@ -0,0 +1,49 @@ +package based_sequencer + +import "context" + +type Store interface { + GetLastDAHeight(ctx context.Context) (uint64, error) + SetLastDAHeight(ctx context.Context, height uint64) error + + SetHashMapping(ctx context.Context, hash []byte, height uint64) error + GetHashMapping(ctx context.Context, hash []byte) (uint64, error) + + SetNextHash(ctx context.Context, currentHash, nextHash []byte) error + GetNextHash(ctx context.Context, currentHash []byte) ([]byte, error) +} + +type KVStore struct { +} + +var _ Store = &KVStore{} + +func (K *KVStore) GetLastDAHeight(ctx context.Context) (uint64, error) { + //TODO implement me + panic("implement me") +} + +func (K *KVStore) SetLastDAHeight(ctx context.Context, height uint64) error { + //TODO implement me + panic("implement me") +} + +func (K *KVStore) SetHashMapping(ctx context.Context, hash []byte, height uint64) error { + //TODO implement me + panic("implement me") +} + +func (K *KVStore) GetHashMapping(ctx context.Context, hash []byte) (uint64, error) { + //TODO implement me + panic("implement me") +} + +func (K *KVStore) SetNextHash(ctx context.Context, currentHash, nextHash []byte) error { + //TODO implement me + panic("implement me") +} + +func (K *KVStore) GetNextHash(ctx context.Context, currentHash []byte) ([]byte, error) { + //TODO implement me + panic("implement me") +} From 5b30e6f93584dfd44ed93de60c91d1dc4c1a2b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Mon, 30 Sep 2024 20:08:54 +0200 Subject: [PATCH 5/8] refactor: rename BasedSequencer receiver --- sequencer.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sequencer.go b/sequencer.go index cf37fee..9c6c161 100644 --- a/sequencer.go +++ b/sequencer.go @@ -38,8 +38,8 @@ func NewSequencer(da da.DA) *BasedSequencer { var _ sequencing.Sequencer = (*BasedSequencer)(nil) // SubmitRollupTransaction submits a transaction directly to DA, as a single blob. -func (b *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error { - _, err := b.da.Submit(ctx, []da.Blob{tx}, 0, rollupId) +func (seq *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error { + _, err := seq.da.Submit(ctx, []da.Blob{tx}, 0, rollupId) if err != nil { return err } @@ -47,15 +47,15 @@ func (b *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId s } // GetNextBatch reads data from namespace in DA and builds transactions batches. -func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { +func (seq *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { // optimistic case - we already know the hash after lastBatchHash - nextBatchHash, err := b.store.GetNextHash(ctx, lastBatchHash) + nextBatchHash, err := seq.store.GetNextHash(ctx, lastBatchHash) if err == nil { - height, err := b.store.GetHashMapping(ctx, nextBatchHash) + height, err := seq.store.GetHashMapping(ctx, nextBatchHash) if err != nil { return nil, time.Time{}, fmt.Errorf("store contents inconsistent: %w", err) } - return b.getBatchByHeight(ctx, height) + return seq.getBatchByHeight(ctx, height) } // if there is no indexing information in store, it's not an error @@ -65,7 +65,7 @@ func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequenc // we need to search for next batch for ctx.Err() == nil { - batch, ts, err := b.getBatchByHeight(ctx, b.daHeight.Load()) + batch, ts, err := seq.getBatchByHeight(ctx, seq.daHeight.Load()) if err != nil { if strings.Contains(err.Error(), "given height is from the future") { time.Sleep(100 * time.Millisecond) // TODO(tzdybal): this needs to be configurable @@ -79,13 +79,13 @@ func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequenc if err != nil { return nil, time.Time{}, err } - if err = b.store.SetNextHash(ctx, lastBatchHash, hash); err != nil { + if err = seq.store.SetNextHash(ctx, lastBatchHash, hash); err != nil { return nil, time.Time{}, err } - if err = b.store.SetHashMapping(ctx, hash, b.daHeight.Load()); err != nil { + if err = seq.store.SetHashMapping(ctx, hash, seq.daHeight.Load()); err != nil { return nil, time.Time{}, err } - b.daHeight.Add(1) + seq.daHeight.Add(1) return batch, ts, err } @@ -93,7 +93,7 @@ func (b *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequenc } // VerifyBatch ensures data-availability of a batch in DA. -func (b *BasedSequencer) VerifyBatch(ctx context.Context, batchHash sequencing.Hash) (bool, error) { +func (seq *BasedSequencer) VerifyBatch(ctx context.Context, batchHash sequencing.Hash) (bool, error) { //TODO implement me panic("implement me") } @@ -107,15 +107,15 @@ func BatchHash(batch *sequencing.Batch) (sequencing.Hash, error) { return h[:], nil } -func (b *BasedSequencer) getBatchByHeight(ctx context.Context, height uint64) (*sequencing.Batch, time.Time, error) { +func (seq *BasedSequencer) getBatchByHeight(ctx context.Context, height uint64) (*sequencing.Batch, time.Time, error) { // TODO(tzdybal): this needs to be a field namespace := []byte("test namespace") - result, err := b.da.GetIDs(ctx, height, namespace) + result, err := seq.da.GetIDs(ctx, height, namespace) if err != nil { return nil, time.Time{}, err } - blobs, err := b.da.Get(ctx, result.IDs, namespace) + blobs, err := seq.da.Get(ctx, result.IDs, namespace) if err != nil { return nil, time.Time{}, err } From c63a9bad2179ec0e71d0ccbde41ac4fe51f93788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Thu, 3 Oct 2024 17:27:26 +0200 Subject: [PATCH 6/8] refactor: update sequencing methods to use go-sequencing v0.2.0 Refactored methods to use request/response structures for better readability and maintainability. Adjusted tests accordingly. --- go.mod | 4 ++-- go.sum | 6 ++++++ sequencer.go | 54 +++++++++++++++++++---------------------------- sequencer_test.go | 12 ++++++----- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index 367496e..a91cb3d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.1 require ( github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 - github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072 + github.com/rollkit/go-sequencing v0.2.0 github.com/stretchr/testify v1.9.0 ) @@ -21,7 +21,7 @@ require ( golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect - google.golang.org/grpc v1.67.0 // indirect + google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 37bf6f8..b72ef74 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,10 @@ github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 h1:MkNGLP+SIC4MiA0 github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20/go.mod h1:3eHWK5gkv8lhwq6bjOZOi82WwHyS2B9rQOlUrE1GGws= github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072 h1:ryzQ53hpEZ/tzsweDkEFUP3ovFcmi0IBye4JhCNIs+8= github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= +github.com/rollkit/go-sequencing v0.1.0 h1:LL6QT5pekydPLxeU8ncRoRlkdbJpM8fcsu+Uw15H4sE= +github.com/rollkit/go-sequencing v0.1.0/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= +github.com/rollkit/go-sequencing v0.2.0 h1:IrEA29p07zPDbqY29AzI+q2zUqm7QACAoR+/PBpexvw= +github.com/rollkit/go-sequencing v0.2.0/go.mod h1:P/cQXTw3rWpPqhqnCwKzlkS39XM8ugmyf2u63twBgG8= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= @@ -33,6 +37,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/sequencer.go b/sequencer.go index 9c6c161..5684b92 100644 --- a/sequencer.go +++ b/sequencer.go @@ -2,7 +2,6 @@ package based_sequencer import ( "context" - "crypto/sha256" "errors" "fmt" "strings" @@ -38,87 +37,78 @@ func NewSequencer(da da.DA) *BasedSequencer { var _ sequencing.Sequencer = (*BasedSequencer)(nil) // SubmitRollupTransaction submits a transaction directly to DA, as a single blob. -func (seq *BasedSequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error { - _, err := seq.da.Submit(ctx, []da.Blob{tx}, 0, rollupId) +func (seq *BasedSequencer) SubmitRollupTransaction(ctx context.Context, req sequencing.SubmitRollupTransactionRequest) (*sequencing.SubmitRollupTransactionResponse, error) { + _, err := seq.da.Submit(ctx, []da.Blob{req.Tx}, 0, req.RollupId) if err != nil { - return err + return nil, err } - return nil + return &sequencing.SubmitRollupTransactionResponse{}, nil } // GetNextBatch reads data from namespace in DA and builds transactions batches. -func (seq *BasedSequencer) GetNextBatch(ctx context.Context, lastBatchHash sequencing.Hash) (*sequencing.Batch, time.Time, error) { +func (seq *BasedSequencer) GetNextBatch(ctx context.Context, req sequencing.GetNextBatchRequest) (*sequencing.GetNextBatchResponse, error) { // optimistic case - we already know the hash after lastBatchHash - nextBatchHash, err := seq.store.GetNextHash(ctx, lastBatchHash) + nextBatchHash, err := seq.store.GetNextHash(ctx, req.LastBatchHash) if err == nil { height, err := seq.store.GetHashMapping(ctx, nextBatchHash) if err != nil { - return nil, time.Time{}, fmt.Errorf("store contents inconsistent: %w", err) + return nil, fmt.Errorf("store contents inconsistent: %w", err) } return seq.getBatchByHeight(ctx, height) } // if there is no indexing information in store, it's not an error if !errors.Is(err, ds.ErrNotFound) { - return nil, time.Time{}, err + return nil, err } // we need to search for next batch for ctx.Err() == nil { - batch, ts, err := seq.getBatchByHeight(ctx, seq.daHeight.Load()) + resp, err := seq.getBatchByHeight(ctx, seq.daHeight.Load()) if err != nil { if strings.Contains(err.Error(), "given height is from the future") { time.Sleep(100 * time.Millisecond) // TODO(tzdybal): this needs to be configurable continue } - return nil, time.Time{}, err + return nil, err } // TODO(tzdybal): extract method - hash, err := BatchHash(batch) + hash, err := resp.Batch.Hash() if err != nil { - return nil, time.Time{}, err + return nil, err } - if err = seq.store.SetNextHash(ctx, lastBatchHash, hash); err != nil { - return nil, time.Time{}, err + if err = seq.store.SetNextHash(ctx, req.LastBatchHash, hash); err != nil { + return nil, err } if err = seq.store.SetHashMapping(ctx, hash, seq.daHeight.Load()); err != nil { - return nil, time.Time{}, err + return nil, err } seq.daHeight.Add(1) - return batch, ts, err + return resp, err } - return nil, time.Time{}, ctx.Err() + return nil, ctx.Err() } // VerifyBatch ensures data-availability of a batch in DA. -func (seq *BasedSequencer) VerifyBatch(ctx context.Context, batchHash sequencing.Hash) (bool, error) { +func (seq *BasedSequencer) VerifyBatch(ctx context.Context, req sequencing.VerifyBatchRequest) (*sequencing.VerifyBatchResponse, error) { //TODO implement me panic("implement me") } -func BatchHash(batch *sequencing.Batch) (sequencing.Hash, error) { - batchBytes, err := batch.Marshal() - if err != nil { - return nil, err - } - h := sha256.Sum256(batchBytes) - return h[:], nil -} - -func (seq *BasedSequencer) getBatchByHeight(ctx context.Context, height uint64) (*sequencing.Batch, time.Time, error) { +func (seq *BasedSequencer) getBatchByHeight(ctx context.Context, height uint64) (*sequencing.GetNextBatchResponse, error) { // TODO(tzdybal): this needs to be a field namespace := []byte("test namespace") result, err := seq.da.GetIDs(ctx, height, namespace) if err != nil { - return nil, time.Time{}, err + return nil, err } blobs, err := seq.da.Get(ctx, result.IDs, namespace) if err != nil { - return nil, time.Time{}, err + return nil, err } - return &sequencing.Batch{Transactions: blobs}, result.Timestamp, nil + return &sequencing.GetNextBatchResponse{Batch: &sequencing.Batch{Transactions: blobs}, Timestamp: result.Timestamp}, nil } diff --git a/sequencer_test.go b/sequencer_test.go index c0c923b..f1eaf71 100644 --- a/sequencer_test.go +++ b/sequencer_test.go @@ -40,8 +40,10 @@ func TestSubmitRollupTransaction(t *testing.T) { require.Contains(t, string(blobs[0]), testTx) }).Return(nil, nil).Once() - err := seq.SubmitRollupTransaction(context.Background(), sequencing.RollupId(rollupId), sequencing.Tx(testTx)) + resp, err := seq.SubmitRollupTransaction(context.Background(), + sequencing.SubmitRollupTransactionRequest{RollupId: sequencing.RollupId(rollupId), Tx: sequencing.Tx(testTx)}) require.NoError(t, err) + require.NotNil(t, resp) mockDA.AssertExpectations(t) } @@ -97,14 +99,14 @@ func TestGetNextBatch(t *testing.T) { var lastBatchHash sequencing.Hash for i := 0; i < len(batchIds); i++ { - batch, ts, err := seq.GetNextBatch(ctx, lastBatchHash) + resp, err := seq.GetNextBatch(ctx, sequencing.GetNextBatchRequest{LastBatchHash: lastBatchHash}) require.NoError(t, err) - require.NotNil(t, batch) + require.NotNil(t, resp) require.NotEmpty(t, ts) require.NoError(t, err) expected := makeBatch(batchIds[i]) - require.Equal(t, expected, batch.Transactions) - lastBatchHash, err = BatchHash(batch) + require.Equal(t, expected, resp.Batch.Transactions) + lastBatchHash, err = resp.Batch.Hash() require.NoError(t, err) } From e1b4820963666d939a6c68ca14395a354ec036a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Thu, 3 Oct 2024 17:51:43 +0200 Subject: [PATCH 7/8] feat: implement KVStore add in-memory badger based store used for testing --- go.mod | 21 ++++++- go.sum | 149 +++++++++++++++++++++++++++++++++++++++++++--- sequencer.go | 12 ++-- sequencer_test.go | 9 ++- store.go | 74 +++++++++++++++++------ 5 files changed, 231 insertions(+), 34 deletions(-) diff --git a/go.mod b/go.mod index a91cb3d..40088a3 100644 --- a/go.mod +++ b/go.mod @@ -3,20 +3,39 @@ module github.com/rollkit/based-sequencer go 1.23.1 require ( + github.com/ipfs/go-datastore v0.6.0 + github.com/ipfs/go-ds-badger4 v0.1.5 github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 github.com/rollkit/go-sequencing v0.2.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cosmos/gogoproto v1.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgraph-io/badger/v4 v4.2.0 // indirect + github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.2.2 // indirect + github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/snappy v0.0.3 // indirect + github.com/google/flatbuffers v1.12.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/ipfs/go-datastore v0.6.0 // indirect + github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/jbenet/goprocess v0.1.4 // indirect + github.com/klauspost/compress v1.12.3 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.2 // indirect + go.opencensus.io v0.22.5 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.19.1 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect diff --git a/go.sum b/go.sum index b72ef74..d0ba8be 100644 --- a/go.sum +++ b/go.sum @@ -1,47 +1,182 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= +github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= +github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= +github.com/ipfs/go-ds-badger4 v0.1.5 h1:MwrTsIUJIqH/ChuDdUOzxwxMxHx/Li1ECoSCKsCUxiA= +github.com/ipfs/go-ds-badger4 v0.1.5/go.mod h1:LUU2FbhNdmhAbJmMeoahVRbe4GsduAODSJHWJJh2Vo4= +github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= +github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 h1:MkNGLP+SIC4MiA0ZXxDqebc7Xv8duTEwqS29/z5Gn1Q= github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20/go.mod h1:3eHWK5gkv8lhwq6bjOZOi82WwHyS2B9rQOlUrE1GGws= -github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072 h1:ryzQ53hpEZ/tzsweDkEFUP3ovFcmi0IBye4JhCNIs+8= -github.com/rollkit/go-sequencing v0.0.0-20240924073851-5e3b8522a072/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= -github.com/rollkit/go-sequencing v0.1.0 h1:LL6QT5pekydPLxeU8ncRoRlkdbJpM8fcsu+Uw15H4sE= -github.com/rollkit/go-sequencing v0.1.0/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A= github.com/rollkit/go-sequencing v0.2.0 h1:IrEA29p07zPDbqY29AzI+q2zUqm7QACAoR+/PBpexvw= github.com/rollkit/go-sequencing v0.2.0/go.mod h1:P/cQXTw3rWpPqhqnCwKzlkS39XM8ugmyf2u63twBgG8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +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-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg= google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= -google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/sequencer.go b/sequencer.go index 5684b92..791d7f9 100644 --- a/sequencer.go +++ b/sequencer.go @@ -27,11 +27,15 @@ type BasedSequencer struct { } // NewSequencer initializes a BasedSequencer with the provided DA implementation. -func NewSequencer(da da.DA) *BasedSequencer { +func NewSequencer(da da.DA) (*BasedSequencer, error) { seq := &BasedSequencer{da: da} - seq.daHeight.Store(1) // TODO(tzdybal): this needs to be config or constructor param - seq.store = &KVStore{} // TODO(tzdybal): extract parameter - return seq + seq.daHeight.Store(1) // TODO(tzdybal): this needs to be config or constructor param + inMem, err := NewInMemoryStore() + if err != nil { + return nil, err + } + seq.store = NewStore(inMem) // TODO(tzdybal): extract parameter + return seq, nil } var _ sequencing.Sequencer = (*BasedSequencer)(nil) diff --git a/sequencer_test.go b/sequencer_test.go index f1eaf71..e4bc1a6 100644 --- a/sequencer_test.go +++ b/sequencer_test.go @@ -16,14 +16,16 @@ import ( func TestNewSequencer(t *testing.T) { mockDA := mocks.NewMockDA(t) - seq := NewSequencer(mockDA) + seq, err := NewSequencer(mockDA) + require.NoError(t, err) require.NotNil(t, seq) } // TestSubmitRollupTransaction ensures that single rollup transaction submitted to sequencer is submitted as one blob to DA. func TestSubmitRollupTransaction(t *testing.T) { mockDA := mocks.NewMockDA(t) - seq := NewSequencer(mockDA) + seq, err := NewSequencer(mockDA) + require.NoError(t, err) require.NotNil(t, seq) const ( @@ -91,7 +93,8 @@ func TestGetNextBatch(t *testing.T) { return makeBatch(ids), nil }) - seq := NewSequencer(mockDA) + seq, err := NewSequencer(mockDA) + require.NoError(t, err) require.NotNil(t, seq) ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) diff --git a/store.go b/store.go index da3ef72..f04e01c 100644 --- a/store.go +++ b/store.go @@ -1,6 +1,13 @@ package based_sequencer -import "context" +import ( + "context" + "encoding/binary" + "time" + + ds "github.com/ipfs/go-datastore" + badger4 "github.com/ipfs/go-ds-badger4" +) type Store interface { GetLastDAHeight(ctx context.Context) (uint64, error) @@ -14,36 +21,65 @@ type Store interface { } type KVStore struct { + store ds.Batching } var _ Store = &KVStore{} -func (K *KVStore) GetLastDAHeight(ctx context.Context) (uint64, error) { - //TODO implement me - panic("implement me") +func NewStore(underlying ds.Batching) *KVStore { + return &KVStore{ + store: underlying, + } +} +func NewInMemoryStore() (ds.Batching, error) { + inMemoryOptions := &badger4.Options{ + GcDiscardRatio: 0.2, + GcInterval: 15 * time.Minute, + GcSleep: 10 * time.Second, + Options: badger4.DefaultOptions.WithInMemory(true), + } + return badger4.NewDatastore("", inMemoryOptions) + +} + +const ( + lastHeightKey = "height" + hashHashPrefix = "hash/" + hashHeightPrefix = "height/" +) + +func (store *KVStore) GetLastDAHeight(ctx context.Context) (uint64, error) { + bytes, err := store.store.Get(ctx, ds.NewKey(lastHeightKey)) + if err != nil { + return 0, err + } + return binary.LittleEndian.Uint64(bytes), nil } -func (K *KVStore) SetLastDAHeight(ctx context.Context, height uint64) error { - //TODO implement me - panic("implement me") +func (store *KVStore) SetLastDAHeight(ctx context.Context, height uint64) error { + return store.store.Put(ctx, ds.NewKey(lastHeightKey), binary.LittleEndian.AppendUint64(nil, height)) } -func (K *KVStore) SetHashMapping(ctx context.Context, hash []byte, height uint64) error { - //TODO implement me - panic("implement me") +func (store *KVStore) SetHashMapping(ctx context.Context, hash []byte, height uint64) error { + return store.store.Put(ctx, ds.NewKey(hashHeightPrefix+string(hash)), binary.LittleEndian.AppendUint64(nil, height)) } -func (K *KVStore) GetHashMapping(ctx context.Context, hash []byte) (uint64, error) { - //TODO implement me - panic("implement me") +func (store *KVStore) GetHashMapping(ctx context.Context, hash []byte) (uint64, error) { + bytes, err := store.store.Get(ctx, ds.NewKey(hashHeightPrefix+string(hash))) + if err != nil { + return 0, err + } + return binary.LittleEndian.Uint64(bytes), nil } -func (K *KVStore) SetNextHash(ctx context.Context, currentHash, nextHash []byte) error { - //TODO implement me - panic("implement me") +func (store *KVStore) SetNextHash(ctx context.Context, currentHash, nextHash []byte) error { + return store.store.Put(ctx, ds.NewKey(hashHashPrefix+string(currentHash)), nextHash) } -func (K *KVStore) GetNextHash(ctx context.Context, currentHash []byte) ([]byte, error) { - //TODO implement me - panic("implement me") +func (store *KVStore) GetNextHash(ctx context.Context, currentHash []byte) ([]byte, error) { + nextHash, err := store.store.Get(ctx, ds.NewKey(hashHashPrefix+string(currentHash))) + if err != nil { + return nil, err + } + return nextHash, nil } From d4e78b64a86911b8ffbf728d871dffe050370a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zdyba=C5=82?= Date: Fri, 4 Oct 2024 21:05:12 +0200 Subject: [PATCH 8/8] refactor: replace go-datastore with native badger DB Migrated all store operations from go-datastore to Badger DB. This simplifies the codebase by removing unnecessary abstractions and leveraging native Badger functionalities for better performance and maintainability. --- go.mod | 27 ++++------ go.sum | 137 ++++++++++++++++++++++----------------------------- sequencer.go | 9 ++-- store.go | 92 +++++++++++++++++++++------------- 4 files changed, 132 insertions(+), 133 deletions(-) diff --git a/go.mod b/go.mod index 40088a3..55500a8 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/rollkit/based-sequencer go 1.23.1 require ( - github.com/ipfs/go-datastore v0.6.0 - github.com/ipfs/go-ds-badger4 v0.1.5 + github.com/dgraph-io/badger/v4 v4.3.0 github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 github.com/rollkit/go-sequencing v0.2.0 github.com/stretchr/testify v1.9.0 @@ -14,33 +13,25 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cosmos/gogoproto v1.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/badger/v4 v4.2.0 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dustin/go-humanize v1.0.0 // indirect + github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.2 // indirect - github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.3 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/flatbuffers v1.12.1 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/jbenet/goprocess v0.1.4 // indirect - github.com/klauspost/compress v1.12.3 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/kr/pretty v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.2 // indirect - go.opencensus.io v0.22.5 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.19.1 // indirect + go.opencensus.io v0.24.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index d0ba8be..c787113 100644 --- a/go.sum +++ b/go.sum @@ -1,100 +1,87 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= -github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dgraph-io/badger/v4 v4.3.0 h1:lcsCE1/1qrRhqP+zYx6xDZb8n7U+QlwNicpc676Ub40= +github.com/dgraph-io/badger/v4 v4.3.0/go.mod h1:Sc0T595g8zqAQRDf44n+z3wG4BOqLwceaFntt8KPxUM= +github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 h1:Pux6+xANi0I7RRo5E1gflI4EZ2yx3BGZ75JkAIvGEOA= +github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91/go.mod h1:swkazRqnUf1N62d0Nutz7KIj2UKqsm/H8tD0nBJAXqM= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= -github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= -github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= -github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= -github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= -github.com/ipfs/go-ds-badger4 v0.1.5 h1:MwrTsIUJIqH/ChuDdUOzxwxMxHx/Li1ECoSCKsCUxiA= -github.com/ipfs/go-ds-badger4 v0.1.5/go.mod h1:LUU2FbhNdmhAbJmMeoahVRbe4GsduAODSJHWJJh2Vo4= -github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= -github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= -github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= -github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.12.3 h1:G5AfA94pHPysR56qqrkO2pxEexdDzrpFJ6yt/VqWxVU= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20 h1:MkNGLP+SIC4MiA0ZXxDqebc7Xv8duTEwqS29/z5Gn1Q= github.com/rollkit/go-da v0.7.1-0.20240927084534-0289b27dbd20/go.mod h1:3eHWK5gkv8lhwq6bjOZOi82WwHyS2B9rQOlUrE1GGws= github.com/rollkit/go-sequencing v0.2.0 h1:IrEA29p07zPDbqY29AzI+q2zUqm7QACAoR+/PBpexvw= github.com/rollkit/go-sequencing v0.2.0/go.mod h1:P/cQXTw3rWpPqhqnCwKzlkS39XM8ugmyf2u63twBgG8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= -go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -102,10 +89,8 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -114,30 +99,21 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 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-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= @@ -146,10 +122,10 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -157,26 +133,33 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed h1:J6izYgfBXAI3xTKLgxzTmUltdYaLsuBxFCgDHWJ/eXg= google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/sequencer.go b/sequencer.go index 791d7f9..c0074fb 100644 --- a/sequencer.go +++ b/sequencer.go @@ -4,12 +4,11 @@ import ( "context" "errors" "fmt" + "github.com/dgraph-io/badger/v4" "strings" "sync/atomic" "time" - ds "github.com/ipfs/go-datastore" - "github.com/rollkit/go-da" "github.com/rollkit/go-sequencing" ) @@ -56,13 +55,13 @@ func (seq *BasedSequencer) GetNextBatch(ctx context.Context, req sequencing.GetN if err == nil { height, err := seq.store.GetHashMapping(ctx, nextBatchHash) if err != nil { - return nil, fmt.Errorf("store contents inconsistent: %w", err) + return nil, fmt.Errorf("kv contents inconsistent: %w", err) } return seq.getBatchByHeight(ctx, height) } - // if there is no indexing information in store, it's not an error - if !errors.Is(err, ds.ErrNotFound) { + // if there is no indexing information in kv, it's not an error + if !errors.Is(err, badger.ErrKeyNotFound) { return nil, err } diff --git a/store.go b/store.go index f04e01c..4843f55 100644 --- a/store.go +++ b/store.go @@ -3,10 +3,7 @@ package based_sequencer import ( "context" "encoding/binary" - "time" - - ds "github.com/ipfs/go-datastore" - badger4 "github.com/ipfs/go-ds-badger4" + "github.com/dgraph-io/badger/v4" ) type Store interface { @@ -21,25 +18,24 @@ type Store interface { } type KVStore struct { - store ds.Batching + kv *badger.DB } var _ Store = &KVStore{} -func NewStore(underlying ds.Batching) *KVStore { +func NewStore(underlying *badger.DB) *KVStore { return &KVStore{ - store: underlying, + kv: underlying, } } -func NewInMemoryStore() (ds.Batching, error) { - inMemoryOptions := &badger4.Options{ - GcDiscardRatio: 0.2, - GcInterval: 15 * time.Minute, - GcSleep: 10 * time.Second, - Options: badger4.DefaultOptions.WithInMemory(true), - } - return badger4.NewDatastore("", inMemoryOptions) +func NewInMemoryStore() (*badger.DB, error) { + opts := badger.DefaultOptions("").WithInMemory(true) + return badger.Open(opts) +} + +func (store *KVStore) Close() error { + return store.kv.Close() } const ( @@ -49,37 +45,67 @@ const ( ) func (store *KVStore) GetLastDAHeight(ctx context.Context) (uint64, error) { - bytes, err := store.store.Get(ctx, ds.NewKey(lastHeightKey)) - if err != nil { - return 0, err - } - return binary.LittleEndian.Uint64(bytes), nil + var lastDAHeight uint64 + err := store.kv.View(func(txn *badger.Txn) error { + item, err := txn.Get([]byte(lastHeightKey)) + if err != nil { + return err + } + bytes, err := item.ValueCopy(nil) + if err != nil { + return err + } + lastDAHeight = binary.LittleEndian.Uint64(bytes) + return nil + }) + + return lastDAHeight, err } func (store *KVStore) SetLastDAHeight(ctx context.Context, height uint64) error { - return store.store.Put(ctx, ds.NewKey(lastHeightKey), binary.LittleEndian.AppendUint64(nil, height)) + return store.kv.Update(func(txn *badger.Txn) error { + return txn.Set([]byte(lastHeightKey), binary.LittleEndian.AppendUint64(nil, height)) + }) } func (store *KVStore) SetHashMapping(ctx context.Context, hash []byte, height uint64) error { - return store.store.Put(ctx, ds.NewKey(hashHeightPrefix+string(hash)), binary.LittleEndian.AppendUint64(nil, height)) + return store.kv.Update(func(txn *badger.Txn) error { + return txn.Set([]byte(hashHeightPrefix+string(hash)), binary.LittleEndian.AppendUint64(nil, height)) + }) } func (store *KVStore) GetHashMapping(ctx context.Context, hash []byte) (uint64, error) { - bytes, err := store.store.Get(ctx, ds.NewKey(hashHeightPrefix+string(hash))) - if err != nil { - return 0, err - } - return binary.LittleEndian.Uint64(bytes), nil + var hashMapping uint64 + err := store.kv.View(func(txn *badger.Txn) error { + item, err := txn.Get([]byte(hashHeightPrefix + string(hash))) + if err != nil { + return err + } + bytes, err := item.ValueCopy(nil) + if err != nil { + return err + } + hashMapping = binary.LittleEndian.Uint64(bytes) + return nil + }) + return hashMapping, err } func (store *KVStore) SetNextHash(ctx context.Context, currentHash, nextHash []byte) error { - return store.store.Put(ctx, ds.NewKey(hashHashPrefix+string(currentHash)), nextHash) + return store.kv.Update(func(txn *badger.Txn) error { + return txn.Set([]byte(hashHashPrefix+string(currentHash)), nextHash) + }) } func (store *KVStore) GetNextHash(ctx context.Context, currentHash []byte) ([]byte, error) { - nextHash, err := store.store.Get(ctx, ds.NewKey(hashHashPrefix+string(currentHash))) - if err != nil { - return nil, err - } - return nextHash, nil + var nextHash []byte + err := store.kv.View(func(txn *badger.Txn) error { + item, err := txn.Get([]byte(hashHashPrefix + string(currentHash))) + if err != nil { + return err + } + nextHash, err = item.ValueCopy(nil) + return nil + }) + return nextHash, err }