From b9a991e5aa6c857a8abff3ca49b23395a5a72cdf Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Tue, 10 Dec 2024 16:53:29 +0100 Subject: [PATCH 01/62] wip: key-value object --- commonspace/object/keyvalue/element.go | 28 ++++ .../object/keyvalue/keyvaluestore/store.go | 129 ++++++++++++++++ .../keyvalue/keyvaluestore/store_test.go | 146 ++++++++++++++++++ .../spacesyncproto/protos/spacesync.proto | 23 +++ coordinator/coordinatorproto/errors.go | 2 +- go.mod | 16 +- go.sum | 24 +++ 7 files changed, 364 insertions(+), 4 deletions(-) create mode 100644 commonspace/object/keyvalue/element.go create mode 100644 commonspace/object/keyvalue/keyvaluestore/store.go create mode 100644 commonspace/object/keyvalue/keyvaluestore/store_test.go diff --git a/commonspace/object/keyvalue/element.go b/commonspace/object/keyvalue/element.go new file mode 100644 index 00000000..ed0eeb71 --- /dev/null +++ b/commonspace/object/keyvalue/element.go @@ -0,0 +1,28 @@ +package keyvalue + +import ( + "encoding/hex" + + "github.com/anyproto/any-store/anyenc" + "github.com/zeebo/blake3" +) + +type KeyValue struct { + Key string + Value []byte + TimestampMilli int +} + +func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { + obj := a.NewObject() + obj.Set("id", a.NewString(kv.Key)) + if len(kv.Value) == 0 { + obj.Set("d", a.NewTrue()) + } else { + obj.Set("v", a.NewBinary(kv.Value)) + hash := blake3.Sum256(kv.Value) + obj.Set("h", a.NewString(hex.EncodeToString(hash[:]))) + } + obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) + return obj +} diff --git a/commonspace/object/keyvalue/keyvaluestore/store.go b/commonspace/object/keyvalue/keyvaluestore/store.go new file mode 100644 index 00000000..4545f44e --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestore/store.go @@ -0,0 +1,129 @@ +package keyvaluestore + +import ( + "context" + "errors" + "strconv" + + anystore "github.com/anyproto/any-store" + "github.com/anyproto/any-store/anyenc" + + "github.com/anyproto/any-sync/app/ldiff" + "github.com/anyproto/any-sync/commonspace/object/keyvalue" +) + +var ( + parserPool = &anyenc.ParserPool{} + arenaPool = &anyenc.ArenaPool{} +) + +/** + +any-store document structure: + id (string) - key + v (bytes) - value + h (string) - value hash + t (int) - timestamp + d (bool) - isDeleted +*/ + +func NewKeyValueStore(ctx context.Context, collection anystore.Collection) (KeyValueStore, error) { + k := &keyValueStore{collection: collection} + if err := k.init(ctx); err != nil { + return nil, err + } + return k, nil +} + +type KeyValueStore interface { + Set(ctx context.Context, values ...keyvalue.KeyValue) (err error) + ldiff.Remote +} + +type keyValueStore struct { + collection anystore.Collection + ldiff.Diff +} + +func (k *keyValueStore) init(ctx context.Context) (err error) { + k.Diff = ldiff.New(32, 256) + iter, err := k.collection.Find(nil).Iter(ctx) + if err != nil { + return + } + defer func() { + _ = iter.Close() + }() + var doc anystore.Doc + for iter.Next() { + if doc, err = iter.Doc(); err != nil { + return + } + k.Diff.Set(anyEncToElement(doc.Value())) + } + return +} + +func (k *keyValueStore) Set(ctx context.Context, values ...keyvalue.KeyValue) (err error) { + elements, err := k.updateValues(ctx, values...) + if err != nil { + return + } + k.Diff.Set(elements...) + return +} + +func (k *keyValueStore) updateValues(ctx context.Context, values ...keyvalue.KeyValue) (elements []ldiff.Element, err error) { + tx, err := k.collection.WriteTx(ctx) + if err != nil { + return + } + defer func() { + if err != nil { + _ = tx.Rollback() + } else { + err = tx.Commit() + } + }() + ctx = tx.Context() + parser := parserPool.Get() + defer parserPool.Put(parser) + arena := arenaPool.Get() + defer arenaPool.Put(arena) + + elements = make([]ldiff.Element, 0, len(values)) + var doc anystore.Doc + for _, value := range values { + doc, err = k.collection.FindIdWithParser(ctx, parser, value.Key) + isNotFound := errors.Is(err, anystore.ErrDocNotFound) + if err != nil && !isNotFound { + return + } + if !isNotFound { + if doc.Value().GetInt("t") >= value.TimestampMilli { + // newest doc is already present + continue + } + } + arena.Reset() + val := value.AnyEnc(arena) + if err = k.collection.UpsertOne(ctx, val); err != nil { + return + } + elements = append(elements, anyEncToElement(val)) + } + return +} + +func anyEncToElement(val *anyenc.Value) ldiff.Element { + head := strconv.Itoa(val.GetInt("t")) + "/" + if val.GetBool("d") { + head += "del" + } else { + head += val.GetString("h") + } + return ldiff.Element{ + Id: val.GetString("id"), + Head: head, + } +} diff --git a/commonspace/object/keyvalue/keyvaluestore/store_test.go b/commonspace/object/keyvalue/keyvaluestore/store_test.go new file mode 100644 index 00000000..08051a90 --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestore/store_test.go @@ -0,0 +1,146 @@ +package keyvaluestore + +import ( + "context" + "os" + "path/filepath" + "testing" + + anystore "github.com/anyproto/any-store" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/anyproto/any-sync/commonspace/object/keyvalue" +) + +var ctx = context.Background() + +func TestKeyValueStore_Set(t *testing.T) { + var values = []keyvalue.KeyValue{ + { + Key: "1", + Value: []byte("1"), + TimestampMilli: 1, + }, + { + Key: "2", + Value: []byte("2"), + TimestampMilli: 1, + }, + { + Key: "3", + Value: []byte("4"), + TimestampMilli: 1, + }, + } + + t.Run("new", func(t *testing.T) { + fx := newFixture(t) + err := fx.Set(ctx, values...) + assert.NoError(t, err) + count, _ := fx.coll.Count(ctx) + assert.Equal(t, 3, count) + assert.Equal(t, 3, fx.Diff.Len()) + }) + t.Run("restore", func(t *testing.T) { + fx := newFixture(t) + err := fx.Set(ctx, values...) + assert.NoError(t, err) + hash := fx.Diff.Hash() + kv2, err := NewKeyValueStore(ctx, fx.coll) + require.NoError(t, err) + assert.Equal(t, kv2.(*keyValueStore).Diff.Hash(), hash) + }) + t.Run("update", func(t *testing.T) { + fx := newFixture(t) + err := fx.Set(ctx, values...) + assert.NoError(t, err) + hash := fx.Diff.Hash() + + // do not update because timestamp is not greater + require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "1", TimestampMilli: 1})) + assert.Equal(t, hash, fx.Diff.Hash()) + // should be updated + require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "2", TimestampMilli: 2, Value: []byte("22")})) + assert.NotEqual(t, hash, fx.Diff.Hash()) + }) + t.Run("delete", func(t *testing.T) { + fx := newFixture(t) + err := fx.Set(ctx, values...) + assert.NoError(t, err) + hash := fx.Diff.Hash() + + require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "1", TimestampMilli: 3})) + assert.NotEqual(t, hash, fx.Diff.Hash()) + }) +} + +func TestKeyValueStore_E2E(t *testing.T) { + fx1 := newFixture(t) + fx2 := newFixture(t) + + newIds, changedIds, remodedIds, err := fx1.Diff.Diff(ctx, fx2) + require.NoError(t, err) + assert.Len(t, newIds, 0) + assert.Len(t, changedIds, 0) + assert.Len(t, remodedIds, 0) + + require.NoError(t, fx1.Set(ctx, []keyvalue.KeyValue{ + {Key: "1", Value: []byte("1"), TimestampMilli: 1}, + {Key: "2", Value: []byte("1"), TimestampMilli: 1}, + {Key: "3", Value: []byte("1"), TimestampMilli: 1}, + {Key: "4", Value: []byte("1"), TimestampMilli: 1}, + {Key: "5", Value: []byte("1"), TimestampMilli: 1}, + }...)) + + newIds, changedIds, remodedIds, err = fx1.Diff.Diff(ctx, fx2) + require.NoError(t, err) + assert.Len(t, newIds, 0) + assert.Len(t, changedIds, 0) + assert.Len(t, remodedIds, 5) + + require.NoError(t, fx2.Set(ctx, []keyvalue.KeyValue{ + {Key: "1", Value: []byte("1"), TimestampMilli: 1}, + {Key: "2", Value: []byte("1"), TimestampMilli: 1}, + {Key: "3", Value: []byte("1"), TimestampMilli: 1}, + {Key: "4", Value: []byte("1"), TimestampMilli: 1}, + {Key: "5", Value: []byte("1"), TimestampMilli: 1}, + }...)) + + newIds, changedIds, remodedIds, err = fx1.Diff.Diff(ctx, fx2) + require.NoError(t, err) + assert.Len(t, newIds, 0) + assert.Len(t, changedIds, 0) + assert.Len(t, remodedIds, 0) +} + +func newFixture(t testing.TB) *fixture { + tmpDir, err := os.MkdirTemp("", "") + require.NoError(t, err) + db, err := anystore.Open(ctx, filepath.Join(tmpDir, "test.db"), nil) + require.NoError(t, err) + coll, err := db.Collection(ctx, "test") + require.NoError(t, err) + kv, err := NewKeyValueStore(ctx, coll) + require.NoError(t, err) + fx := &fixture{ + keyValueStore: kv.(*keyValueStore), + db: db, + coll: coll, + } + t.Cleanup(func() { + fx.finish(t) + _ = os.RemoveAll(tmpDir) + }) + return fx +} + +type fixture struct { + *keyValueStore + db anystore.DB + coll anystore.Collection +} + +func (fx *fixture) finish(t testing.TB) { + assert.NoError(t, fx.db.Close()) +} diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index e3b02c18..ae6b86e4 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -196,6 +196,29 @@ message AclGetRecordsResponse { repeated bytes records = 1; } + +message KVHeadSyncRequest { + repeated HeadSyncRange ranges = 3; +} + +message KVHeadSyncResponse { + repeated HeadSyncResult results = 1; +} + +message KVGetValuesRequest { + repeated string keys = 1; +} + +message KVGetValuesResponse { + repeated KeyValue values = 1; +} + +message KeyValue { + string key = 1; + bytes value = 2; + int64 timestampMilli = 3; +} + // DiffType is a type of diff enum DiffType { Initial = 0; diff --git a/coordinator/coordinatorproto/errors.go b/coordinator/coordinatorproto/errors.go index 713dd0cc..0f5fe434 100644 --- a/coordinator/coordinatorproto/errors.go +++ b/coordinator/coordinatorproto/errors.go @@ -3,7 +3,7 @@ package coordinatorproto import ( "errors" - "github.com/anyproto/any-sync/net/rpc/rpcerr" + "github.com/anyproto/any-sync/net/rpc/rpcerr"u ) var ( diff --git a/go.mod b/go.mod index 9bebe3cd..a78029a1 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( go.uber.org/mock v0.5.0 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.29.0 - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c + golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f golang.org/x/net v0.31.0 golang.org/x/time v0.8.0 gopkg.in/yaml.v3 v3.0.1 @@ -43,6 +43,7 @@ require ( require ( github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect + github.com/anyproto/any-store v0.1.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -51,6 +52,7 @@ require ( github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/disintegration/imaging v1.6.2 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/flopp/go-findfont v0.1.0 // indirect github.com/fogleman/gg v1.3.0 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -83,14 +85,17 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect github.com/onsi/ginkgo/v2 v2.20.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.60.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/tetratelabs/wazero v1.8.1 // indirect + github.com/valyala/fastjson v1.6.4 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/zeebo/errs v1.3.0 // indirect go.opentelemetry.io/otel v1.31.0 // indirect @@ -98,11 +103,16 @@ require ( go.opentelemetry.io/otel/trace v1.31.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/image v0.21.0 // indirect - golang.org/x/mod v0.21.0 // indirect + golang.org/x/mod v0.22.0 // indirect golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect golang.org/x/text v0.20.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/tools v0.27.0 // indirect google.golang.org/protobuf v1.35.1 // indirect lukechampine.com/blake3 v1.3.0 // indirect + modernc.org/libc v1.61.2 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.8.0 // indirect + modernc.org/sqlite v1.34.1 // indirect + zombiezen.com/go/sqlite v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 071192a8..d312835a 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs= +github.com/anyproto/any-store v0.1.2 h1:/WKsPOQxK1jOHS7efTIosnyJTvy0O3gYg/DSnt41DT0= +github.com/anyproto/any-store v0.1.2/go.mod h1:SDlN2AzysAfs8CDd28rrs6boUUtf5H/ydCvwmj+EbsE= github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY= github.com/anyproto/go-chash v0.1.0/go.mod h1:0UjNQi3PDazP0fINpFYu6VKhuna+W/V+1vpXHAfNgLY= github.com/anyproto/go-slip10 v1.0.0 h1:uAEtSuudR3jJBOfkOXf3bErxVoxbuKwdoJN55M1i6IA= @@ -58,6 +60,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnN github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= +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/flopp/go-findfont v0.1.0 h1:lPn0BymDUtJo+ZkV01VS3661HL6F4qFlkhcJN55u6mU= github.com/flopp/go-findfont v0.1.0/go.mod h1:wKKxRDjD024Rh7VMwoU90i6ikQRCr+JTHB5n4Ejkqvw= github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= @@ -218,6 +222,8 @@ github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/n github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -278,6 +284,8 @@ github.com/quic-go/quic-go v0.48.1 h1:y/8xmfWI9qmGTc+lBr4jKRUWLGSlSigv847ULJ4hYX github.com/quic-go/quic-go v0.48.1/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs= github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 h1:4WFk6u3sOT6pLa1kQ50ZVdm8BQFgJNA117cepZxtLIg= github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66/go.mod h1:Vp72IJajgeOL6ddqrAhmp7IM9zbTcgkQxD/YdxrVwMw= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -306,6 +314,8 @@ github.com/tetratelabs/wazero v1.8.1/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= github.com/warpfork/go-testmark v0.12.1 h1:rMgCpJfwy1sJ50x0M0NgyphxYYPMOODIJHhsXyEHU0s= github.com/warpfork/go-testmark v0.12.1/go.mod h1:kHwy7wfvGSPh1rQJYKayD4AbtNaeyZdcGi9tNJTaa5Y= github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ= @@ -355,6 +365,8 @@ golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s= golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78= @@ -364,6 +376,7 @@ 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/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/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= @@ -409,6 +422,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= 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= @@ -432,5 +446,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +modernc.org/libc v1.61.2 h1:dkO4DlowfClcJYsvf/RiK6fUwvzCQTmB34bJLt0CAGQ= +modernc.org/libc v1.61.2/go.mod h1:4QGjNyX3h+rn7V5oHpJY2yH0QN6frt1X+5BkXzwLPCo= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= +modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= +modernc.org/sqlite v1.34.1 h1:u3Yi6M0N8t9yKRDwhXcyp1eS5/ErhPTBggxWFuR6Hfk= +modernc.org/sqlite v1.34.1/go.mod h1:pXV2xHxhzXZsgT/RtTFAPY6JJDEvOTcTdwADQCCWD4k= storj.io/drpc v0.0.34 h1:q9zlQKfJ5A7x8NQNFk8x7eKUF78FMhmAbZLnFK+og7I= storj.io/drpc v0.0.34/go.mod h1:Y9LZaa8esL1PW2IDMqJE7CFSNq7d5bQ3RI7mGPtmKMg= +zombiezen.com/go/sqlite v1.4.0 h1:N1s3RIljwtp4541Y8rM880qgGIgq3fTD2yks1xftnKU= +zombiezen.com/go/sqlite v1.4.0/go.mod h1:0w9F1DN9IZj9AcLS9YDKMboubCACkwYCGkzoy3eG5ik= From 6bc50c5409b76f4fb683a43e974cbfead1456679 Mon Sep 17 00:00:00 2001 From: AnastasiaShemyakinskaya Date: Fri, 21 Mar 2025 11:09:02 +0100 Subject: [PATCH 02/62] GO-5297: fix Signed-off-by: AnastasiaShemyakinskaya --- go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 25f70240..8a0a8d08 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/anyproto/any-sync -go 1.23 +go 1.23.0 + toolchain go1.23.5 require ( From 84238793490c42e57e416248ea8638e773b4f366 Mon Sep 17 00:00:00 2001 From: AnastasiaShemyakinskaya Date: Fri, 21 Mar 2025 18:50:08 +0100 Subject: [PATCH 03/62] GO-5297: add FirstMetadataKey func Signed-off-by: AnastasiaShemyakinskaya --- commonspace/object/acl/list/aclstate.go | 12 +++++ commonspace/object/acl/list/aclstate_test.go | 55 ++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/commonspace/object/acl/list/aclstate.go b/commonspace/object/acl/list/aclstate.go index c9d0dbb0..38f8223c 100644 --- a/commonspace/object/acl/list/aclstate.go +++ b/commonspace/object/acl/list/aclstate.go @@ -151,6 +151,18 @@ func (st *AclState) CurrentMetadataKey() (crypto.PubKey, error) { return curKeys.MetadataPubKey, nil } +func (st *AclState) FirstMetadataKey() (crypto.PrivKey, error) { + if len(st.readKeyChanges) == 0 { + return nil, ErrNoMetadataKey + } + firstReadKeyChangeId := st.readKeyChanges[0] + key, exists := st.keys[firstReadKeyChangeId] + if !exists { + return nil, ErrNoMetadataKey + } + return key.MetadataPrivKey, nil +} + func (st *AclState) Keys() map[string]AclKeys { return st.keys } diff --git a/commonspace/object/acl/list/aclstate_test.go b/commonspace/object/acl/list/aclstate_test.go index cae40dc8..b56f7b64 100644 --- a/commonspace/object/acl/list/aclstate_test.go +++ b/commonspace/object/acl/list/aclstate_test.go @@ -1,6 +1,8 @@ package list import ( + "crypto/rand" + "github.com/anyproto/any-sync/util/crypto" "testing" "github.com/stretchr/testify/require" @@ -68,3 +70,56 @@ func TestAclStateIsEmpty(t *testing.T) { require.True(t, st.IsEmpty()) }) } + +func TestAclState_FirstMetadataKey(t *testing.T) { + t.Run("returns first metadata key successfully", func(t *testing.T) { + // given + privKey, _, err := crypto.GenerateEd25519Key(rand.Reader) + require.NoError(t, err) + pubKey := privKey.GetPublic() + readKey := crypto.NewAES() + + // Create an AclState + state := &AclState{ + readKeyChanges: []string{"recordId"}, + keys: map[string]AclKeys{ + "recordId": { + ReadKey: readKey, + MetadataPrivKey: privKey, + MetadataPubKey: pubKey, + }, + }, + } + + // when + key, err := state.FirstMetadataKey() + + // then + require.NoError(t, err) + require.Equal(t, privKey, key) + }) + + t.Run("returns error when no read key changes", func(t *testing.T) { + // given + state := &AclState{readKeyChanges: []string{}} + + // when + _, err := state.FirstMetadataKey() + + // then + require.ErrorIs(t, err, ErrNoMetadataKey) + }) + + t.Run("returns error when first read key change is missing", func(t *testing.T) { + // given + state := &AclState{ + readKeyChanges: []string{"missingRecord"}, + keys: make(map[string]AclKeys)} + + // when + _, err := state.FirstMetadataKey() + + // then + require.ErrorIs(t, err, ErrNoMetadataKey) + }) +} From e2082b9b37817725553f41c126006304ec43cf23 Mon Sep 17 00:00:00 2001 From: AnastasiaShemyakinskaya Date: Fri, 21 Mar 2025 18:51:40 +0100 Subject: [PATCH 04/62] GO-5297: remove comment Signed-off-by: AnastasiaShemyakinskaya --- commonspace/object/acl/list/aclstate_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/commonspace/object/acl/list/aclstate_test.go b/commonspace/object/acl/list/aclstate_test.go index b56f7b64..997499a1 100644 --- a/commonspace/object/acl/list/aclstate_test.go +++ b/commonspace/object/acl/list/aclstate_test.go @@ -79,7 +79,6 @@ func TestAclState_FirstMetadataKey(t *testing.T) { pubKey := privKey.GetPublic() readKey := crypto.NewAES() - // Create an AclState state := &AclState{ readKeyChanges: []string{"recordId"}, keys: map[string]AclKeys{ From bee7c4f261df294e24c96f0bc6ac7d1857f26d26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 15:18:34 +0000 Subject: [PATCH 05/62] build(deps): bump github.com/libp2p/go-libp2p from 0.41.0 to 0.41.1 Bumps [github.com/libp2p/go-libp2p](https://github.com/libp2p/go-libp2p) from 0.41.0 to 0.41.1. - [Release notes](https://github.com/libp2p/go-libp2p/releases) - [Changelog](https://github.com/libp2p/go-libp2p/blob/master/CHANGELOG.md) - [Commits](https://github.com/libp2p/go-libp2p/compare/v0.41.0...v0.41.1) --- updated-dependencies: - dependency-name: github.com/libp2p/go-libp2p dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 5df18009..a0a84e75 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/anyproto/any-sync go 1.23.0 -toolchain go1.23.5 +toolchain go1.24.1 require ( filippo.io/edwards25519 v1.1.0 @@ -25,7 +25,7 @@ require ( github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.5.0 github.com/ipfs/go-ipld-format v0.6.0 - github.com/libp2p/go-libp2p v0.41.0 + github.com/libp2p/go-libp2p v0.41.1 github.com/mr-tron/base58 v1.2.0 github.com/multiformats/go-multibase v0.2.0 github.com/multiformats/go-multihash v0.2.3 diff --git a/go.sum b/go.sum index 17d68734..91022c99 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/libp2p/go-flow-metrics v0.2.0 h1:EIZzjmeOE6c8Dav0sNv35vhZxATIXWZg6j/C08XmmDw= github.com/libp2p/go-flow-metrics v0.2.0/go.mod h1:st3qqfu8+pMfh+9Mzqb2GTiwrAGjIPszEjZmtksN8Jc= -github.com/libp2p/go-libp2p v0.41.0 h1:JRaD39dqf/tBBGapJ0T38N73vOaDCsWgcx3mE6HgXWk= -github.com/libp2p/go-libp2p v0.41.0/go.mod h1:Be8QYqC4JW6Xq8buukNeoZJjyT1XUDcGoIooCHm1ye4= +github.com/libp2p/go-libp2p v0.41.1 h1:8ecNQVT5ev/jqALTvisSJeVNvXYJyK4NhQx1nNRXQZE= +github.com/libp2p/go-libp2p v0.41.1/go.mod h1:DcGTovJzQl/I7HMrby5ZRjeD0kQkGiy+9w6aEkSZpRI= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg= @@ -246,8 +246,8 @@ github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U= github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg= -github.com/pion/ice/v4 v4.0.6 h1:jmM9HwI9lfetQV/39uD0nY4y++XZNPhvzIPCb8EwxUM= -github.com/pion/ice/v4 v4.0.6/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw= +github.com/pion/ice/v4 v4.0.8 h1:ajNx0idNG+S+v9Phu4LSn2cs8JEfTsA1/tEjkkAVpFY= +github.com/pion/ice/v4 v4.0.8/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw= github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI= github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y= github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI= @@ -260,8 +260,8 @@ github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo= github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0= github.com/pion/rtp v1.8.11 h1:17xjnY5WO5hgO6SD3/NTIUPvSFw/PbLsIJyz1r1yNIk= github.com/pion/rtp v1.8.11/go.mod h1:8uMBJj32Pa1wwx8Fuv/AsFhn8jsgw+3rUC2PfoBZ8p4= -github.com/pion/sctp v1.8.36 h1:owNudmnz1xmhfYje5L/FCav3V9wpPRePHle3Zi+P+M0= -github.com/pion/sctp v1.8.36/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE= +github.com/pion/sctp v1.8.37 h1:ZDmGPtRPX9mKCiVXtMbTWybFw3z/hVKAZgU81wcOrqs= +github.com/pion/sctp v1.8.37/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE= github.com/pion/sdp/v3 v3.0.10 h1:6MChLE/1xYB+CjumMw+gZ9ufp2DPApuVSnDT8t5MIgA= github.com/pion/sdp/v3 v3.0.10/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E= github.com/pion/srtp/v3 v3.0.4 h1:2Z6vDVxzrX3UHEgrUyIGM4rRouoC7v+NiF1IHtp9B5M= From e03f2e6efd111755ae1cc088b82d0a529c0bbf7c Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 2 Apr 2025 16:36:23 +0200 Subject: [PATCH 06/62] Add compare diff --- app/ldiff/diff.go | 86 +++++++++++++++++++++++++++++++++++++++--- app/ldiff/diff_test.go | 29 ++++++++++++++ 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/app/ldiff/diff.go b/app/ldiff/diff.go index 0278037d..83b4c214 100644 --- a/app/ldiff/diff.go +++ b/app/ldiff/diff.go @@ -42,6 +42,11 @@ type Diff interface { DiffType() spacesyncproto.DiffType } +type CompareDiff interface { + CompareDiff(ctx context.Context, dl Remote) (newIds, ourChangedIds, theirChangedIds, removedIds []string, err error) + Diff +} + // New creates precalculated Diff container // // divideFactor - means how many hashes you want to ask for once @@ -273,17 +278,18 @@ func (d *diff) Ranges(ctx context.Context, ranges []Range, resBuf []RangeResult) } type diffCtx struct { - newIds, changedIds, removedIds []string + newIds, changedIds, theirChangedIds, removedIds []string toSend, prepare []Range myRes, otherRes []RangeResult + compareFunc func(dctx *diffCtx, my, other []Element) } var errMismatched = errors.New("query and results mismatched") // Diff makes diff with remote container func (d *diff) Diff(ctx context.Context, dl Remote) (newIds, changedIds, removedIds []string, err error) { - dctx := &diffCtx{} + dctx := &diffCtx{compareFunc: d.compareElementsEqual} dctx.toSend = append(dctx.toSend, Range{ From: 0, To: math.MaxUint64, @@ -314,18 +320,51 @@ func (d *diff) Diff(ctx context.Context, dl Remote) (newIds, changedIds, removed return dctx.newIds, dctx.changedIds, dctx.removedIds, nil } +func (d *diff) CompareDiff(ctx context.Context, dl Remote) (newIds, ourChangedIds, theirChangedIds, removedIds []string, err error) { + dctx := &diffCtx{compareFunc: d.compareElementsGreater} + dctx.toSend = append(dctx.toSend, Range{ + From: 0, + To: math.MaxUint64, + }) + for len(dctx.toSend) > 0 { + select { + case <-ctx.Done(): + err = ctx.Err() + return + default: + } + if dctx.otherRes, err = dl.Ranges(ctx, dctx.toSend, dctx.otherRes); err != nil { + return + } + if dctx.myRes, err = d.Ranges(ctx, dctx.toSend, dctx.myRes); err != nil { + return + } + if len(dctx.otherRes) != len(dctx.toSend) || len(dctx.myRes) != len(dctx.toSend) { + err = errMismatched + return + } + for i, r := range dctx.toSend { + d.compareResults(dctx, r, dctx.myRes[i], dctx.otherRes[i]) + } + dctx.toSend, dctx.prepare = dctx.prepare, dctx.toSend + dctx.prepare = dctx.prepare[:0] + } + return dctx.newIds, dctx.changedIds, dctx.theirChangedIds, dctx.removedIds, nil +} + func (d *diff) compareResults(dctx *diffCtx, r Range, myRes, otherRes RangeResult) { // both hash equals - do nothing if bytes.Equal(myRes.Hash, otherRes.Hash) { return } + // other has elements if len(otherRes.Elements) == otherRes.Count { if len(myRes.Elements) == myRes.Count { - d.compareElements(dctx, myRes.Elements, otherRes.Elements) + dctx.compareFunc(dctx, myRes.Elements, otherRes.Elements) } else { r.Elements = true - d.compareElements(dctx, d.getRange(r).Elements, otherRes.Elements) + dctx.compareFunc(dctx, d.getRange(r).Elements, otherRes.Elements) } return } @@ -341,7 +380,7 @@ func (d *diff) compareResults(dctx *diffCtx, r Range, myRes, otherRes RangeResul return } -func (d *diff) compareElements(dctx *diffCtx, my, other []Element) { +func (d *diff) compareElementsEqual(dctx *diffCtx, my, other []Element) { find := func(list []Element, targetEl Element) (has, eq bool) { for _, el := range list { if el.Id == targetEl.Id { @@ -369,3 +408,40 @@ func (d *diff) compareElements(dctx *diffCtx, my, other []Element) { } } } + +func (d *diff) compareElementsGreater(dctx *diffCtx, my, other []Element) { + find := func(list []Element, targetEl Element) (has, equal, greater bool) { + for _, el := range list { + if el.Id == targetEl.Id { + if el.Head == targetEl.Head { + return true, true, false + } + return true, false, el.Head > targetEl.Head + } + } + return false, false, false + } + + for _, el := range my { + has, eq, theirGreater := find(other, el) + if !has { + dctx.removedIds = append(dctx.removedIds, el.Id) + continue + } else { + if eq { + continue + } + if theirGreater { + dctx.theirChangedIds = append(dctx.theirChangedIds, el.Id) + } else { + dctx.changedIds = append(dctx.changedIds, el.Id) + } + } + } + + for _, el := range other { + if has, _, _ := find(my, el); !has { + dctx.newIds = append(dctx.newIds, el.Id) + } + } +} diff --git a/app/ldiff/diff_test.go b/app/ldiff/diff_test.go index d572647f..9e651526 100644 --- a/app/ldiff/diff_test.go +++ b/app/ldiff/diff_test.go @@ -139,6 +139,35 @@ func TestDiff_Diff(t *testing.T) { assert.Len(t, changedIds, length/2) assert.Len(t, removedIds, 0) }) + t.Run("compare diff", func(t *testing.T) { + d1 := New(16, 128).(CompareDiff) + d2 := New(16, 128) + + length := 10000 + for i := 0; i < length; i++ { + id := fmt.Sprint(i) + head := "a" + uuid.NewString() + d1.Set(Element{ + Id: id, + Head: head, + }) + } + for i := 0; i < length; i++ { + id := fmt.Sprint(i) + head := "b" + uuid.NewString() + d2.Set(Element{ + Id: id, + Head: head, + }) + } + + newIds, changedIds, theirChangedIds, removedIds, err := d1.CompareDiff(ctx, d2) + require.NoError(t, err) + assert.Len(t, newIds, 0) + assert.Len(t, changedIds, 0) + assert.Len(t, theirChangedIds, length) + assert.Len(t, removedIds, 0) + }) t.Run("empty", func(t *testing.T) { d1 := New(16, 16) d2 := New(16, 16) From bdcb1bf35b5c9fb40a57378f24485ce2ae5427e5 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 2 Apr 2025 17:03:27 +0200 Subject: [PATCH 07/62] Add protos --- .../spacesyncproto/protos/spacesync.proto | 19 +- commonspace/spacesyncproto/spacesync.pb.go | 816 ++++++++++++++++-- .../spacesyncproto/spacesync_drpc.pb.go | 133 ++- 3 files changed, 866 insertions(+), 102 deletions(-) diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index 38a090c4..838ff1d7 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -20,6 +20,10 @@ enum ErrCodes { service SpaceSync { // HeadSync compares all objects and their hashes in a space rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse); + // StoreDiff compares all objects and their hashes in a space + rpc StoreDiff(StoreDiffRequest) returns (StoreDiffResponse); + // StoreElements exchanges elements between peers + rpc StoreElements(stream StoreKeyValue) returns (stream StoreKeyValue); // SpacePush sends new space to the node rpc SpacePush(SpacePushRequest) returns (SpacePushResponse); // SpacePull gets space from the remote peer @@ -196,24 +200,15 @@ message AclGetRecordsResponse { repeated bytes records = 1; } - -message KVHeadSyncRequest { +message StoreDiffRequest { repeated HeadSyncRange ranges = 3; } -message KVHeadSyncResponse { +message StoreDiffResponse { repeated HeadSyncResult results = 1; } -message KVGetValuesRequest { - repeated string keys = 1; -} - -message KVGetValuesResponse { - repeated KeyValue values = 1; -} - -message KeyValue { +message StoreKeyValue { string key = 1; bytes value = 2; int64 timestampMilli = 3; diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index f5bf4e66..c2530a5d 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1683,6 +1683,178 @@ func (m *AclGetRecordsResponse) GetRecords() [][]byte { return nil } +type StoreDiffRequest struct { + Ranges []*HeadSyncRange `protobuf:"bytes,3,rep,name=ranges,proto3" json:"ranges,omitempty"` +} + +func (m *StoreDiffRequest) Reset() { *m = StoreDiffRequest{} } +func (m *StoreDiffRequest) String() string { return proto.CompactTextString(m) } +func (*StoreDiffRequest) ProtoMessage() {} +func (*StoreDiffRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{24} +} +func (m *StoreDiffRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreDiffRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreDiffRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreDiffRequest) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreDiffRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreDiffRequest.Merge(m, src) +} +func (m *StoreDiffRequest) XXX_Size() int { + return m.Size() +} +func (m *StoreDiffRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StoreDiffRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreDiffRequest proto.InternalMessageInfo + +func (m *StoreDiffRequest) GetRanges() []*HeadSyncRange { + if m != nil { + return m.Ranges + } + return nil +} + +type StoreDiffResponse struct { + Results []*HeadSyncResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +} + +func (m *StoreDiffResponse) Reset() { *m = StoreDiffResponse{} } +func (m *StoreDiffResponse) String() string { return proto.CompactTextString(m) } +func (*StoreDiffResponse) ProtoMessage() {} +func (*StoreDiffResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{25} +} +func (m *StoreDiffResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreDiffResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreDiffResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreDiffResponse) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreDiffResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreDiffResponse.Merge(m, src) +} +func (m *StoreDiffResponse) XXX_Size() int { + return m.Size() +} +func (m *StoreDiffResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StoreDiffResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreDiffResponse proto.InternalMessageInfo + +func (m *StoreDiffResponse) GetResults() []*HeadSyncResult { + if m != nil { + return m.Results + } + return nil +} + +type StoreKeyValue struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + TimestampMilli int64 `protobuf:"varint,3,opt,name=timestampMilli,proto3" json:"timestampMilli,omitempty"` +} + +func (m *StoreKeyValue) Reset() { *m = StoreKeyValue{} } +func (m *StoreKeyValue) String() string { return proto.CompactTextString(m) } +func (*StoreKeyValue) ProtoMessage() {} +func (*StoreKeyValue) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{26} +} +func (m *StoreKeyValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreKeyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreKeyValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreKeyValue) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreKeyValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreKeyValue.Merge(m, src) +} +func (m *StoreKeyValue) XXX_Size() int { + return m.Size() +} +func (m *StoreKeyValue) XXX_DiscardUnknown() { + xxx_messageInfo_StoreKeyValue.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreKeyValue proto.InternalMessageInfo + +func (m *StoreKeyValue) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *StoreKeyValue) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *StoreKeyValue) GetTimestampMilli() int64 { + if m != nil { + return m.TimestampMilli + } + return 0 +} + func init() { proto.RegisterEnum("spacesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("spacesync.SpaceSubscriptionAction", SpaceSubscriptionAction_name, SpaceSubscriptionAction_value) @@ -1711,6 +1883,9 @@ func init() { proto.RegisterType((*AclAddRecordResponse)(nil), "spacesync.AclAddRecordResponse") proto.RegisterType((*AclGetRecordsRequest)(nil), "spacesync.AclGetRecordsRequest") proto.RegisterType((*AclGetRecordsResponse)(nil), "spacesync.AclGetRecordsResponse") + proto.RegisterType((*StoreDiffRequest)(nil), "spacesync.StoreDiffRequest") + proto.RegisterType((*StoreDiffResponse)(nil), "spacesync.StoreDiffResponse") + proto.RegisterType((*StoreKeyValue)(nil), "spacesync.StoreKeyValue") } func init() { @@ -1718,89 +1893,95 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcb, 0x73, 0xdb, 0x44, - 0x18, 0xb7, 0x14, 0xc7, 0x8f, 0x2f, 0x8a, 0xab, 0x6e, 0xdc, 0xc6, 0xb8, 0x1d, 0xd7, 0xa3, 0x61, - 0x20, 0xd3, 0x43, 0xdb, 0xb8, 0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0xdf, 0xcb, 0x62, 0x2f, 0x02, - 0xec, 0xc7, 0x8a, 0x99, 0x0f, 0x11, 0x95, 0x13, 0x4e, 0x83, 0x34, 0x2a, 0x49, 0x58, 0x9f, 0xc0, - 0x8d, 0x52, 0x43, 0x91, 0x94, 0xe7, 0x4a, 0xf7, 0x4d, 0xac, 0x7b, 0xae, 0x0c, 0x88, 0x12, 0x57, - 0xa6, 0xd9, 0xc4, 0xf2, 0xdb, 0xfa, 0x59, 0x83, 0x6b, 0x99, 0xf5, 0x0f, 0x53, 0xca, 0x38, 0xea, - 0x40, 0x5d, 0xc6, 0x64, 0x27, 0xc6, 0x09, 0x89, 0x1e, 0x40, 0x2d, 0x12, 0x35, 0x4c, 0x82, 0xef, - 0x94, 0x05, 0x2f, 0x14, 0xb0, 0xd2, 0x43, 0xf7, 0xa1, 0xe1, 0x7a, 0xa7, 0xa7, 0xcf, 0x67, 0x13, - 0x2a, 0xa3, 0x6e, 0x0d, 0x36, 0x72, 0x36, 0x7b, 0x4a, 0x84, 0x53, 0x25, 0xeb, 0x1c, 0xcc, 0x5c, - 0x36, 0x93, 0x30, 0x60, 0x14, 0x3d, 0x84, 0x7a, 0x24, 0x33, 0x63, 0x1d, 0x4d, 0xfa, 0x7d, 0x6f, - 0x69, 0xd1, 0x70, 0xa2, 0x59, 0xf0, 0xac, 0xbf, 0x8d, 0xe7, 0xdf, 0x34, 0xb8, 0x7e, 0x74, 0xf2, - 0x1d, 0x75, 0xb8, 0x80, 0x3b, 0xa4, 0x8c, 0x91, 0x33, 0x7a, 0x45, 0x31, 0x6e, 0x43, 0x33, 0x8a, - 0x2b, 0x66, 0x27, 0x35, 0xcd, 0x18, 0xc2, 0x2e, 0xa2, 0x13, 0x7f, 0x66, 0xbb, 0x32, 0xef, 0x26, - 0x4e, 0x48, 0x21, 0x99, 0x90, 0x99, 0x1f, 0x12, 0x57, 0x0e, 0x91, 0x81, 0x13, 0x52, 0xcc, 0x57, - 0x28, 0x03, 0xb0, 0xdd, 0xce, 0xaa, 0x34, 0x4a, 0x69, 0x8b, 0x82, 0x39, 0x14, 0x8e, 0x8f, 0xa7, - 0x6c, 0x94, 0x34, 0x6a, 0x3b, 0x43, 0x12, 0xb1, 0xad, 0x0d, 0x36, 0x73, 0x19, 0xc6, 0xda, 0xb1, - 0x38, 0x73, 0xd1, 0x03, 0xd8, 0x8d, 0xa8, 0x4b, 0x03, 0xee, 0x11, 0x5f, 0x46, 0x6d, 0xe0, 0x1c, - 0xc7, 0xda, 0x80, 0xeb, 0x39, 0x37, 0x71, 0xfd, 0x2d, 0x2b, 0xf5, 0xed, 0xfb, 0x89, 0xef, 0xb9, - 0xe1, 0xb2, 0x9e, 0xa6, 0x86, 0x42, 0x47, 0x35, 0xee, 0xff, 0x07, 0x68, 0xfd, 0xa8, 0x83, 0x91, - 0x97, 0xa0, 0x1d, 0x58, 0x93, 0x36, 0xa2, 0xcf, 0x34, 0x52, 0x38, 0x77, 0x72, 0x38, 0x98, 0xbc, - 0x1e, 0x66, 0x0a, 0x2f, 0x3d, 0x3e, 0xb2, 0x5d, 0x9c, 0xb7, 0x11, 0x49, 0x13, 0xc7, 0x57, 0x80, - 0x49, 0xd2, 0x19, 0x07, 0x59, 0x60, 0x64, 0x54, 0xda, 0xb0, 0x02, 0x0f, 0x0d, 0xa0, 0x2d, 0x21, - 0x87, 0x94, 0x73, 0x2f, 0x38, 0x63, 0xc7, 0x85, 0x16, 0x96, 0xca, 0xd0, 0xc7, 0x70, 0xb3, 0x8c, - 0x9f, 0x76, 0x77, 0x89, 0xd4, 0xfa, 0x43, 0x83, 0xb5, 0x5c, 0x4a, 0x62, 0x2e, 0x3c, 0xd9, 0x20, - 0x3e, 0x53, 0xdb, 0x24, 0xa5, 0xc5, 0x14, 0x72, 0x6f, 0x4c, 0x19, 0x27, 0xe3, 0x89, 0x4c, 0x6d, - 0x05, 0x67, 0x0c, 0x21, 0x95, 0x3e, 0xd2, 0xf3, 0xd7, 0xc4, 0x19, 0x03, 0x7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x8e, 0xb3, 0x08, 0xaf, 0x97, 0xc1, 0xff, 0xa4, 0x81, 0x91, 0x40, 0xef, 0x11, 0x4e, 0xd0, - 0x23, 0xa8, 0x3b, 0x71, 0x4d, 0xd5, 0xf6, 0xbe, 0x33, 0x5f, 0x85, 0xb9, 0xd2, 0xe3, 0x44, 0x5f, - 0x5c, 0x97, 0x4c, 0x45, 0xa7, 0x2a, 0xd8, 0x5f, 0x66, 0x9b, 0x64, 0x81, 0x53, 0x0b, 0xeb, 0x7b, - 0xb5, 0x92, 0x86, 0xd3, 0x13, 0xe6, 0x44, 0xde, 0x44, 0x8c, 0xb3, 0x38, 0x4b, 0x6a, 0x81, 0x27, - 0x29, 0xa6, 0x34, 0x7a, 0x0c, 0x35, 0xe2, 0x08, 0x2d, 0x75, 0x61, 0x58, 0x0b, 0xce, 0x72, 0x48, - 0x3b, 0x52, 0x13, 0x2b, 0x0b, 0xcb, 0x86, 0x8d, 0x1d, 0xc7, 0xdf, 0x71, 0x5d, 0x4c, 0x9d, 0x30, - 0x72, 0xff, 0xfb, 0x2e, 0xcd, 0x5d, 0x03, 0x7a, 0xe1, 0x1a, 0xb0, 0xbe, 0x82, 0x76, 0x11, 0x4a, - 0x6d, 0xd3, 0x2e, 0x34, 0x22, 0xc9, 0x49, 0xc1, 0x52, 0xfa, 0x0a, 0xb4, 0x2f, 0x24, 0xda, 0xe7, - 0x94, 0xc7, 0x68, 0xec, 0xad, 0x22, 0x23, 0x8e, 0x7f, 0x90, 0x3d, 0x15, 0x12, 0xd2, 0xda, 0x86, - 0x1b, 0x73, 0x58, 0x2a, 0x34, 0x79, 0xdb, 0x49, 0x96, 0x2c, 0xaa, 0x81, 0x13, 0xf2, 0xee, 0xdf, - 0x1a, 0x34, 0xf6, 0xa3, 0x68, 0x37, 0x74, 0x29, 0x43, 0x2d, 0x80, 0x17, 0x01, 0x3d, 0x9f, 0x50, - 0x87, 0x53, 0xd7, 0xac, 0x20, 0x53, 0xed, 0xfa, 0x43, 0x8f, 0x31, 0x2f, 0x38, 0x33, 0x35, 0x74, - 0x4d, 0x4d, 0xf4, 0xfe, 0xb9, 0xc7, 0x38, 0x33, 0x75, 0xb4, 0x01, 0xd7, 0x24, 0xe3, 0x59, 0xc8, - 0xed, 0x60, 0x97, 0x38, 0x23, 0x6a, 0xae, 0x20, 0x04, 0x2d, 0xc9, 0xb4, 0x59, 0x3c, 0xf9, 0xae, - 0x59, 0x45, 0x1d, 0x68, 0xcb, 0x09, 0x64, 0xcf, 0x42, 0xae, 0xe2, 0xf2, 0x4e, 0x7c, 0x6a, 0xae, - 0xa2, 0x36, 0x98, 0x98, 0x3a, 0xd4, 0x9b, 0x70, 0x9b, 0xd9, 0xc1, 0x2b, 0xe2, 0x7b, 0xae, 0x59, - 0x13, 0x18, 0x8a, 0x50, 0x2b, 0xca, 0xac, 0x0b, 0xcd, 0xbd, 0x69, 0xbc, 0xfa, 0xa8, 0xaa, 0x93, - 0xd9, 0x40, 0xb7, 0x60, 0xf3, 0x79, 0x18, 0x1e, 0x92, 0x60, 0xa6, 0x78, 0xec, 0x69, 0x14, 0x8e, - 0x85, 0x33, 0xb3, 0x29, 0x02, 0xde, 0x8f, 0xa2, 0x30, 0x3a, 0x3a, 0x3d, 0x65, 0x94, 0x9b, 0xee, - 0xdd, 0x47, 0xb0, 0xb9, 0x64, 0x56, 0xd0, 0x3a, 0x34, 0x15, 0xf7, 0x84, 0x9a, 0x15, 0x61, 0xfa, - 0x22, 0x60, 0x29, 0x43, 0xbb, 0xfb, 0x21, 0x34, 0x92, 0x77, 0x09, 0x5a, 0x83, 0xba, 0x1d, 0x78, - 0xe2, 0x4e, 0x36, 0x2b, 0xa8, 0x06, 0xfa, 0xd7, 0xdb, 0xa6, 0x26, 0x7f, 0x07, 0xa6, 0x3e, 0xf8, - 0xa7, 0x0a, 0xcd, 0xd8, 0xc9, 0x2c, 0x70, 0xd0, 0x2e, 0x34, 0x92, 0x47, 0x10, 0xea, 0x96, 0xbe, - 0x8c, 0x64, 0xd4, 0xdd, 0x5b, 0xe5, 0xaf, 0xa6, 0xb8, 0x83, 0x4f, 0x15, 0xa2, 0xb8, 0xf8, 0xd1, - 0xad, 0x85, 0x6b, 0x3a, 0x7b, 0x75, 0x74, 0x6f, 0x97, 0x0b, 0x17, 0x70, 0x7c, 0xbf, 0x0c, 0x27, - 0x7d, 0x41, 0x94, 0xe1, 0xe4, 0x9e, 0x0e, 0x18, 0xcc, 0xec, 0x31, 0x36, 0xe4, 0x11, 0x25, 0x63, - 0x74, 0x7b, 0x61, 0xf9, 0xe6, 0x5e, 0x6a, 0xdd, 0x2b, 0xa5, 0x5b, 0xda, 0x03, 0x0d, 0x1d, 0x00, - 0x64, 0x82, 0x77, 0x41, 0x43, 0x2f, 0x61, 0x33, 0x63, 0xaa, 0x84, 0xde, 0x3d, 0xc8, 0x07, 0x1a, - 0x3a, 0x02, 0x23, 0x7f, 0xf6, 0x51, 0x2f, 0xa7, 0x5f, 0xb2, 0x5f, 0xba, 0x77, 0x96, 0xca, 0xd3, - 0x3a, 0xae, 0x17, 0x8e, 0x2c, 0x9a, 0xb3, 0x58, 0x58, 0x0c, 0xdd, 0xfe, 0x72, 0x85, 0x18, 0xf3, - 0xc9, 0x47, 0xbf, 0x5f, 0xf4, 0xb4, 0x37, 0x17, 0x3d, 0xed, 0xaf, 0x8b, 0x9e, 0xf6, 0xcb, 0x65, - 0xaf, 0xf2, 0xe6, 0xb2, 0x57, 0xf9, 0xf3, 0xb2, 0x57, 0xf9, 0xa6, 0xbb, 0xfc, 0x5f, 0xb5, 0x93, - 0x9a, 0xfc, 0x79, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x04, 0x49, 0x74, 0xcf, 0x0d, - 0x00, 0x00, + // 1399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcf, 0x6f, 0xdb, 0xb6, + 0x17, 0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d, 0xf7, + 0x72, 0x55, 0x8c, 0x7b, 0x00, 0x39, 0xe3, 0x22, 0x68, 0xe8, 0x05, 0xac, 0xe5, 0x44, 0x1d, 0xd0, + 0xc5, 0x9d, 0xbc, 0x63, 0xa1, 0x03, 0x68, 0x9a, 0xd3, 0x17, 0xf5, 0x0c, 0xf9, 0x92, 0x09, 0xdf, + 0xbd, 0x31, 0x97, 0x9f, 0xe5, 0x71, 0xa5, 0x30, 0x34, 0xd1, 0x8c, 0xc6, 0xb9, 0xd1, 0xdc, 0xed, + 0xcf, 0x17, 0x48, 0x30, 0x1f, 0x7c, 0xf2, 0xfb, 0xdb, 0x9e, 0xf5, 0xe6, 0x6d, 0xcf, 0xfa, 0xeb, + 0x6d, 0xcf, 0xfa, 0xe5, 0x5d, 0xaf, 0xf2, 0xe6, 0x5d, 0xaf, 0xf2, 0xe7, 0xbb, 0x5e, 0xe5, 0xeb, + 0xee, 0xfc, 0x7f, 0x96, 0x8f, 0x6a, 0xea, 0xe7, 0xee, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, + 0xb4, 0x95, 0xdb, 0x51, 0x0f, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -2816,6 +2997,122 @@ func (m *AclGetRecordsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StoreDiffRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreDiffRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreDiffRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ranges) > 0 { + for iNdEx := len(m.Ranges) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ranges[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + return len(dAtA) - i, nil +} + +func (m *StoreDiffResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreDiffResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreDiffResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *StoreKeyValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreKeyValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimestampMilli != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.TimestampMilli)) + i-- + dAtA[i] = 0x18 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -3286,6 +3583,56 @@ func (m *AclGetRecordsResponse) Size() (n int) { return n } +func (m *StoreDiffRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Ranges) > 0 { + for _, e := range m.Ranges { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + +func (m *StoreDiffResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + +func (m *StoreKeyValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.TimestampMilli != 0 { + n += 1 + sovSpacesync(uint64(m.TimestampMilli)) + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -6179,6 +6526,309 @@ func (m *AclGetRecordsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *StoreDiffRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreDiffRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreDiffRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ranges", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ranges = append(m.Ranges, &HeadSyncRange{}) + if err := m.Ranges[len(m.Ranges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreDiffResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreDiffResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreDiffResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Results = append(m.Results, &HeadSyncResult{}) + if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreKeyValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreKeyValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimestampMilli", wireType) + } + m.TimestampMilli = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimestampMilli |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipSpacesync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/commonspace/spacesyncproto/spacesync_drpc.pb.go b/commonspace/spacesyncproto/spacesync_drpc.pb.go index 7612fe36..fe93109b 100644 --- a/commonspace/spacesyncproto/spacesync_drpc.pb.go +++ b/commonspace/spacesyncproto/spacesync_drpc.pb.go @@ -41,6 +41,8 @@ type DRPCSpaceSyncClient interface { DRPCConn() drpc.Conn HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) + StoreDiff(ctx context.Context, in *StoreDiffRequest) (*StoreDiffResponse, error) + StoreElements(ctx context.Context) (DRPCSpaceSync_StoreElementsClient, error) SpacePush(ctx context.Context, in *SpacePushRequest) (*SpacePushResponse, error) SpacePull(ctx context.Context, in *SpacePullRequest) (*SpacePullResponse, error) ObjectSyncStream(ctx context.Context) (DRPCSpaceSync_ObjectSyncStreamClient, error) @@ -69,6 +71,54 @@ func (c *drpcSpaceSyncClient) HeadSync(ctx context.Context, in *HeadSyncRequest) return out, nil } +func (c *drpcSpaceSyncClient) StoreDiff(ctx context.Context, in *StoreDiffRequest) (*StoreDiffResponse, error) { + out := new(StoreDiffResponse) + err := c.cc.Invoke(ctx, "/spacesync.SpaceSync/StoreDiff", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcSpaceSyncClient) StoreElements(ctx context.Context) (DRPCSpaceSync_StoreElementsClient, error) { + stream, err := c.cc.NewStream(ctx, "/spacesync.SpaceSync/StoreElements", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}) + if err != nil { + return nil, err + } + x := &drpcSpaceSync_StoreElementsClient{stream} + return x, nil +} + +type DRPCSpaceSync_StoreElementsClient interface { + drpc.Stream + Send(*StoreKeyValue) error + Recv() (*StoreKeyValue, error) +} + +type drpcSpaceSync_StoreElementsClient struct { + drpc.Stream +} + +func (x *drpcSpaceSync_StoreElementsClient) GetStream() drpc.Stream { + return x.Stream +} + +func (x *drpcSpaceSync_StoreElementsClient) Send(m *StoreKeyValue) error { + return x.MsgSend(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + +func (x *drpcSpaceSync_StoreElementsClient) Recv() (*StoreKeyValue, error) { + m := new(StoreKeyValue) + if err := x.MsgRecv(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcSpaceSync_StoreElementsClient) RecvMsg(m *StoreKeyValue) error { + return x.MsgRecv(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + func (c *drpcSpaceSyncClient) SpacePush(ctx context.Context, in *SpacePushRequest) (*SpacePushResponse, error) { out := new(SpacePushResponse) err := c.cc.Invoke(ctx, "/spacesync.SpaceSync/SpacePush", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, in, out) @@ -195,6 +245,8 @@ func (c *drpcSpaceSyncClient) AclGetRecords(ctx context.Context, in *AclGetRecor type DRPCSpaceSyncServer interface { HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) + StoreDiff(context.Context, *StoreDiffRequest) (*StoreDiffResponse, error) + StoreElements(DRPCSpaceSync_StoreElementsStream) error SpacePush(context.Context, *SpacePushRequest) (*SpacePushResponse, error) SpacePull(context.Context, *SpacePullRequest) (*SpacePullResponse, error) ObjectSyncStream(DRPCSpaceSync_ObjectSyncStreamStream) error @@ -210,6 +262,14 @@ func (s *DRPCSpaceSyncUnimplementedServer) HeadSync(context.Context, *HeadSyncRe return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } +func (s *DRPCSpaceSyncUnimplementedServer) StoreDiff(context.Context, *StoreDiffRequest) (*StoreDiffResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCSpaceSyncUnimplementedServer) StoreElements(DRPCSpaceSync_StoreElementsStream) error { + return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + func (s *DRPCSpaceSyncUnimplementedServer) SpacePush(context.Context, *SpacePushRequest) (*SpacePushResponse, error) { return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } @@ -240,7 +300,7 @@ func (s *DRPCSpaceSyncUnimplementedServer) AclGetRecords(context.Context, *AclGe type DRPCSpaceSyncDescription struct{} -func (DRPCSpaceSyncDescription) NumMethods() int { return 8 } +func (DRPCSpaceSyncDescription) NumMethods() int { return 10 } func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { switch n { @@ -254,6 +314,23 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei ) }, DRPCSpaceSyncServer.HeadSync, true case 1: + return "/spacesync.SpaceSync/StoreDiff", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCSpaceSyncServer). + StoreDiff( + ctx, + in1.(*StoreDiffRequest), + ) + }, DRPCSpaceSyncServer.StoreDiff, true + case 2: + return "/spacesync.SpaceSync/StoreElements", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return nil, srv.(DRPCSpaceSyncServer). + StoreElements( + &drpcSpaceSync_StoreElementsStream{in1.(drpc.Stream)}, + ) + }, DRPCSpaceSyncServer.StoreElements, true + case 3: return "/spacesync.SpaceSync/SpacePush", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return srv.(DRPCSpaceSyncServer). @@ -262,7 +339,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei in1.(*SpacePushRequest), ) }, DRPCSpaceSyncServer.SpacePush, true - case 2: + case 4: return "/spacesync.SpaceSync/SpacePull", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return srv.(DRPCSpaceSyncServer). @@ -271,7 +348,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei in1.(*SpacePullRequest), ) }, DRPCSpaceSyncServer.SpacePull, true - case 3: + case 5: return "/spacesync.SpaceSync/ObjectSyncStream", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return nil, srv.(DRPCSpaceSyncServer). @@ -279,7 +356,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei &drpcSpaceSync_ObjectSyncStreamStream{in1.(drpc.Stream)}, ) }, DRPCSpaceSyncServer.ObjectSyncStream, true - case 4: + case 6: return "/spacesync.SpaceSync/ObjectSync", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return srv.(DRPCSpaceSyncServer). @@ -288,7 +365,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei in1.(*ObjectSyncMessage), ) }, DRPCSpaceSyncServer.ObjectSync, true - case 5: + case 7: return "/spacesync.SpaceSync/ObjectSyncRequestStream", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return nil, srv.(DRPCSpaceSyncServer). @@ -297,7 +374,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei &drpcSpaceSync_ObjectSyncRequestStreamStream{in2.(drpc.Stream)}, ) }, DRPCSpaceSyncServer.ObjectSyncRequestStream, true - case 6: + case 8: return "/spacesync.SpaceSync/AclAddRecord", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return srv.(DRPCSpaceSyncServer). @@ -306,7 +383,7 @@ func (DRPCSpaceSyncDescription) Method(n int) (string, drpc.Encoding, drpc.Recei in1.(*AclAddRecordRequest), ) }, DRPCSpaceSyncServer.AclAddRecord, true - case 7: + case 9: return "/spacesync.SpaceSync/AclGetRecords", drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return srv.(DRPCSpaceSyncServer). @@ -340,6 +417,48 @@ func (x *drpcSpaceSync_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { return x.CloseSend() } +type DRPCSpaceSync_StoreDiffStream interface { + drpc.Stream + SendAndClose(*StoreDiffResponse) error +} + +type drpcSpaceSync_StoreDiffStream struct { + drpc.Stream +} + +func (x *drpcSpaceSync_StoreDiffStream) SendAndClose(m *StoreDiffResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCSpaceSync_StoreElementsStream interface { + drpc.Stream + Send(*StoreKeyValue) error + Recv() (*StoreKeyValue, error) +} + +type drpcSpaceSync_StoreElementsStream struct { + drpc.Stream +} + +func (x *drpcSpaceSync_StoreElementsStream) Send(m *StoreKeyValue) error { + return x.MsgSend(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + +func (x *drpcSpaceSync_StoreElementsStream) Recv() (*StoreKeyValue, error) { + m := new(StoreKeyValue) + if err := x.MsgRecv(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcSpaceSync_StoreElementsStream) RecvMsg(m *StoreKeyValue) error { + return x.MsgRecv(m, drpcEncoding_File_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + type DRPCSpaceSync_SpacePushStream interface { drpc.Stream SendAndClose(*SpacePushResponse) error From 8140ae1c0bd58404a6e35c2d767b499e34daae63 Mon Sep 17 00:00:00 2001 From: AnastasiaShemyakinskaya Date: Thu, 3 Apr 2025 10:34:57 +0200 Subject: [PATCH 08/62] GO-5297: fix Signed-off-by: AnastasiaShemyakinskaya --- commonspace/object/acl/list/aclstate.go | 14 +++++++++----- commonspace/object/acl/list/aclstate_test.go | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/commonspace/object/acl/list/aclstate.go b/commonspace/object/acl/list/aclstate.go index 38f8223c..0aded280 100644 --- a/commonspace/object/acl/list/aclstate.go +++ b/commonspace/object/acl/list/aclstate.go @@ -155,12 +155,16 @@ func (st *AclState) FirstMetadataKey() (crypto.PrivKey, error) { if len(st.readKeyChanges) == 0 { return nil, ErrNoMetadataKey } - firstReadKeyChangeId := st.readKeyChanges[0] - key, exists := st.keys[firstReadKeyChangeId] - if !exists { - return nil, ErrNoMetadataKey + for _, change := range st.readKeyChanges { + key, exists := st.keys[change] + if !exists { + continue + } + if key.MetadataPrivKey != nil { + return key.MetadataPrivKey, nil + } } - return key.MetadataPrivKey, nil + return nil, ErrNoMetadataKey } func (st *AclState) Keys() map[string]AclKeys { diff --git a/commonspace/object/acl/list/aclstate_test.go b/commonspace/object/acl/list/aclstate_test.go index 997499a1..5c90b997 100644 --- a/commonspace/object/acl/list/aclstate_test.go +++ b/commonspace/object/acl/list/aclstate_test.go @@ -97,7 +97,24 @@ func TestAclState_FirstMetadataKey(t *testing.T) { require.NoError(t, err) require.Equal(t, privKey, key) }) + t.Run("first metadata is nil", func(t *testing.T) { + // given + state := &AclState{ + readKeyChanges: []string{"recordId"}, + keys: map[string]AclKeys{ + "recordId": { + ReadKey: crypto.NewAES(), + }, + }, + } + // when + key, err := state.FirstMetadataKey() + + // then + require.ErrorIs(t, err, ErrNoMetadataKey) + require.Nil(t, key) + }) t.Run("returns error when no read key changes", func(t *testing.T) { // given state := &AclState{readKeyChanges: []string{}} From b21c98f49753d8be873245224891ab6717fbf785 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 11:36:07 +0200 Subject: [PATCH 09/62] Update test --- commonspace/spacerpc_test.go | 10 ++++++++++ coordinator/coordinatorproto/errors.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/commonspace/spacerpc_test.go b/commonspace/spacerpc_test.go index 273ad3fd..dd44695b 100644 --- a/commonspace/spacerpc_test.go +++ b/commonspace/spacerpc_test.go @@ -93,6 +93,16 @@ type RpcServer struct { sync.Mutex } +func (r *RpcServer) StoreDiff(ctx2 context.Context, request *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { + //TODO implement me + panic("implement me") +} + +func (r *RpcServer) StoreElements(stream spacesyncproto.DRPCSpaceSync_StoreElementsStream) error { + //TODO implement me + panic("implement me") +} + func NewRpcServer() *RpcServer { return &RpcServer{ spaces: make(map[string]Space), diff --git a/coordinator/coordinatorproto/errors.go b/coordinator/coordinatorproto/errors.go index 0f5fe434..713dd0cc 100644 --- a/coordinator/coordinatorproto/errors.go +++ b/coordinator/coordinatorproto/errors.go @@ -3,7 +3,7 @@ package coordinatorproto import ( "errors" - "github.com/anyproto/any-sync/net/rpc/rpcerr"u + "github.com/anyproto/any-sync/net/rpc/rpcerr" ) var ( From 12ea073b984654a959ba5db0fb63ff0ec0ae4ca1 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 11:57:45 +0200 Subject: [PATCH 10/62] Add object type to message for ignore purposes # Conflicts: # commonspace/spacesyncproto/protos/spacesync.proto # commonspace/spacesyncproto/spacesync.pb.go --- commonspace/object/acl/syncacl/headupdate.go | 5 + .../object/tree/synctree/headupdate.go | 5 + .../spacesyncproto/protos/spacesync.proto | 10 +- commonspace/spacesyncproto/spacesync.pb.go | 244 +++++++++++------- .../objectsync/objectmessages/headupdate.go | 31 ++- commonspace/sync/sync.go | 4 + commonspace/sync/sync_test.go | 15 +- commonspace/sync/syncdeps/message.go | 3 + 8 files changed, 216 insertions(+), 101 deletions(-) diff --git a/commonspace/object/acl/syncacl/headupdate.go b/commonspace/object/acl/syncacl/headupdate.go index a7bf2ed2..0cd189a5 100644 --- a/commonspace/object/acl/syncacl/headupdate.go +++ b/commonspace/object/acl/syncacl/headupdate.go @@ -1,6 +1,7 @@ package syncacl import ( + "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" "github.com/anyproto/any-sync/consensus/consensusproto" ) @@ -24,6 +25,10 @@ func (h *InnerHeadUpdate) MsgSize() uint64 { return size + uint64(len(h.head)) + uint64(len(h.root.Id)) + uint64(len(h.root.Payload)) } +func (h *InnerHeadUpdate) ObjectType() spacesyncproto.ObjectType { + return spacesyncproto.ObjectType_Acl +} + func (h *InnerHeadUpdate) Prepare() error { logMsg := consensusproto.WrapHeadUpdate(&consensusproto.LogHeadUpdate{ Head: h.head, diff --git a/commonspace/object/tree/synctree/headupdate.go b/commonspace/object/tree/synctree/headupdate.go index e828ae46..4e847aa0 100644 --- a/commonspace/object/tree/synctree/headupdate.go +++ b/commonspace/object/tree/synctree/headupdate.go @@ -4,6 +4,7 @@ import ( "slices" "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" ) @@ -21,6 +22,10 @@ func (h *InnerHeadUpdate) MsgSize() (size uint64) { return uint64(len(h.prepared)) } +func (h *InnerHeadUpdate) ObjectType() spacesyncproto.ObjectType { + return spacesyncproto.ObjectType_Tree +} + func (h *InnerHeadUpdate) Prepare() error { treeMsg := treechangeproto.WrapHeadUpdate(&treechangeproto.TreeHeadUpdate{ Heads: h.heads, diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index e3b02c18..7212e58c 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -79,6 +79,7 @@ message ObjectSyncMessage { string replyId = 3; bytes payload = 4; string objectId = 5; + ObjectType objectType = 6; } // SpacePushRequest is a request to add space on a node containing only one acl record @@ -200,4 +201,11 @@ message AclGetRecordsResponse { enum DiffType { Initial = 0; Precalculated = 1; -} \ No newline at end of file +} + +// ObjectType is a type of object +enum ObjectType { + Tree = 0; + Acl = 1; + KeyValue = 2; +} diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 3f95b78e..29620079 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -126,6 +126,35 @@ func (DiffType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_80e49f1f4ac27799, []int{2} } +// ObjectType is a type of object +type ObjectType int32 + +const ( + ObjectType_Tree ObjectType = 0 + ObjectType_Acl ObjectType = 1 + ObjectType_KeyValue ObjectType = 2 +) + +var ObjectType_name = map[int32]string{ + 0: "Tree", + 1: "Acl", + 2: "KeyValue", +} + +var ObjectType_value = map[string]int32{ + "Tree": 0, + "Acl": 1, + "KeyValue": 2, +} + +func (x ObjectType) String() string { + return proto.EnumName(ObjectType_name, int32(x)) +} + +func (ObjectType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{3} +} + // HeadSyncRange presenting a request for one range type HeadSyncRange struct { From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` @@ -466,11 +495,12 @@ func (m *HeadSyncResponse) GetDiffType() DiffType { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` - ReplyId string `protobuf:"bytes,3,opt,name=replyId,proto3" json:"replyId,omitempty"` - Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` - ObjectId string `protobuf:"bytes,5,opt,name=objectId,proto3" json:"objectId,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + RequestId string `protobuf:"bytes,2,opt,name=requestId,proto3" json:"requestId,omitempty"` + ReplyId string `protobuf:"bytes,3,opt,name=replyId,proto3" json:"replyId,omitempty"` + Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` + ObjectId string `protobuf:"bytes,5,opt,name=objectId,proto3" json:"objectId,omitempty"` + ObjectType ObjectType `protobuf:"varint,6,opt,name=objectType,proto3,enum=spacesync.ObjectType" json:"objectType,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -549,6 +579,13 @@ func (m *ObjectSyncMessage) GetObjectId() string { return "" } +func (m *ObjectSyncMessage) GetObjectType() ObjectType { + if m != nil { + return m.ObjectType + } + return ObjectType_Tree +} + // SpacePushRequest is a request to add space on a node containing only one acl record type SpacePushRequest struct { Payload *SpacePayload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` @@ -1685,6 +1722,7 @@ func init() { proto.RegisterEnum("spacesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("spacesync.SpaceSubscriptionAction", SpaceSubscriptionAction_name, SpaceSubscriptionAction_value) proto.RegisterEnum("spacesync.DiffType", DiffType_name, DiffType_value) + proto.RegisterEnum("spacesync.ObjectType", ObjectType_name, ObjectType_value) proto.RegisterType((*HeadSyncRange)(nil), "spacesync.HeadSyncRange") proto.RegisterType((*HeadSyncResult)(nil), "spacesync.HeadSyncResult") proto.RegisterType((*HeadSyncResultElement)(nil), "spacesync.HeadSyncResultElement") @@ -1716,89 +1754,92 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1308 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x3d, 0x6f, 0xdb, 0xc6, - 0x1b, 0x17, 0xe9, 0x17, 0x49, 0x8f, 0x29, 0x85, 0x39, 0x2b, 0xb1, 0xfe, 0x4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, 0xc0, 0xd6, 0x0d, 0x00, 0x00, + // 1358 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4d, 0x73, 0xdb, 0xc4, + 0x1b, 0xb7, 0x14, 0x27, 0xb6, 0x9f, 0x28, 0xae, 0xba, 0x71, 0x1a, 0xff, 0xdd, 0x8e, 0xeb, 0xd1, + 0xfc, 0x87, 0xc9, 0x64, 0x86, 0xbe, 0x24, 0xc0, 0x4c, 0x0b, 0x1c, 0xd2, 0x24, 0x25, 0xa2, 0xb4, + 0xc9, 0xac, 0x5b, 0x3a, 0xc3, 0x0c, 0x87, 0x8d, 0xb4, 0x49, 0x04, 0xb2, 0x64, 0xb4, 0xeb, 0x36, + 0x3e, 0x72, 0xe2, 0xca, 0x70, 0xe4, 0x13, 0x71, 0x2c, 0x9c, 0x38, 0x32, 0xed, 0x9d, 0x4f, 0xc0, + 0x81, 0xd9, 0xd5, 0x4a, 0x5a, 0xd9, 0x72, 0x81, 0xe9, 0xc5, 0xd1, 0xf3, 0xf6, 0x7b, 0x5e, 0xf7, + 0xd9, 0x0d, 0xdc, 0xf5, 0xe2, 0xd1, 0x28, 0x8e, 0xd8, 0x98, 0x78, 0xf4, 0xb6, 0xfc, 0x65, 0xd3, + 0xc8, 0x1b, 0x27, 0x31, 0x8f, 0x6f, 0xcb, 0x5f, 0x56, 0x70, 0x6f, 0x49, 0x06, 0x6a, 0xe5, 0x0c, + 0x87, 0xc2, 0xda, 0x11, 0x25, 0xfe, 0x70, 0x1a, 0x79, 0x98, 0x44, 0xe7, 0x14, 0x21, 0xa8, 0x9f, + 0x25, 0xf1, 0xa8, 0x6b, 0x0c, 0x8c, 0xad, 0x3a, 0x96, 0xdf, 0xa8, 0x0d, 0x26, 0x8f, 0xbb, 0xa6, + 0xe4, 0x98, 0x3c, 0x46, 0x1d, 0x58, 0x0e, 0x83, 0x51, 0xc0, 0xbb, 0x4b, 0x03, 0x63, 0x6b, 0x0d, + 0xa7, 0x04, 0xea, 0x41, 0x93, 0x86, 0x74, 0x44, 0x23, 0xce, 0xba, 0xf5, 0x81, 0xb1, 0xd5, 0xc4, + 0x39, 0xed, 0x5c, 0x42, 0x3b, 0x77, 0x43, 0xd9, 0x24, 0xe4, 0xc2, 0xcf, 0x05, 0x61, 0x17, 0xd2, + 0x8f, 0x85, 0xe5, 0x37, 0xfa, 0x44, 0x43, 0x30, 0x07, 0x4b, 0x5b, 0xab, 0x3b, 0x83, 0x5b, 0x45, + 0xec, 0x65, 0x80, 0xc3, 0x54, 0xb1, 0xf0, 0x21, 0xa2, 0xf2, 0xe2, 0x49, 0x94, 0x47, 0x25, 0x09, + 0xe7, 0x63, 0xd8, 0xa8, 0x34, 0x14, 0x49, 0x05, 0xbe, 0x74, 0xdf, 0xc2, 0x66, 0xe0, 0xcb, 0x80, + 0x28, 0xf1, 0x65, 0x9a, 0x2d, 0x2c, 0xbf, 0x9d, 0x9f, 0x0c, 0xb8, 0x52, 0x58, 0x7f, 0x37, 0xa1, + 0x8c, 0xa3, 0x2e, 0x34, 0x64, 0x4c, 0x6e, 0x66, 0x9c, 0x91, 0xe8, 0x0e, 0xac, 0x24, 0xa2, 0x86, + 0x59, 0xf0, 0xdd, 0xaa, 0xe0, 0x85, 0x02, 0x56, 0x7a, 0x68, 0x17, 0x9a, 0x7e, 0x70, 0x76, 0xf6, + 0x74, 0x3a, 0xa6, 0x32, 0xea, 0xf6, 0xce, 0xba, 0x66, 0x73, 0xa0, 0x44, 0x0f, 0xcc, 0xae, 0x81, + 0x73, 0x45, 0xe7, 0x12, 0x6c, 0x2d, 0xa3, 0x71, 0x1c, 0x31, 0x8a, 0x76, 0xa1, 0x91, 0xc8, 0xec, + 0x58, 0xd7, 0x90, 0xbe, 0xff, 0xb7, 0xb0, 0x70, 0x38, 0xd3, 0x44, 0xb7, 0x35, 0xef, 0xe6, 0x42, + 0xef, 0x9a, 0xe7, 0xdf, 0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 0x66, 0xc1, 0x54, 0x09, 0xbd, 0x7b, 0x90, 0x77, 0x0c, 0x74, 0x0c, 0x96, 0xbe, + 0x2d, 0x50, 0x5f, 0xd3, 0xaf, 0xd8, 0x48, 0xbd, 0x9b, 0x0b, 0xe5, 0x79, 0x1d, 0xd7, 0x4a, 0x87, + 0x1c, 0xcd, 0x58, 0xcc, 0xad, 0x92, 0xde, 0x60, 0xb1, 0x42, 0x8a, 0xf9, 0xe0, 0x83, 0x5f, 0x5e, + 0xf7, 0x8d, 0x57, 0xaf, 0xfb, 0xc6, 0x1f, 0xaf, 0xfb, 0xc6, 0x8f, 0x6f, 0xfa, 0xb5, 0x57, 0x6f, + 0xfa, 0xb5, 0xdf, 0xdf, 0xf4, 0x6b, 0x5f, 0xf5, 0x16, 0xff, 0x5f, 0x78, 0xba, 0x22, 0xff, 0xec, + 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x46, 0x42, 0x1b, 0xb6, 0x3c, 0x0e, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -2046,6 +2087,11 @@ func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ObjectType != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.ObjectType)) + i-- + dAtA[i] = 0x30 + } if len(m.ObjectId) > 0 { i -= len(m.ObjectId) copy(dAtA[i:], m.ObjectId) @@ -2951,6 +2997,9 @@ func (m *ObjectSyncMessage) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } + if m.ObjectType != 0 { + n += 1 + sovSpacesync(uint64(m.ObjectType)) + } return n } @@ -4097,6 +4146,25 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { } m.ObjectId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectType", wireType) + } + m.ObjectType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ObjectType |= ObjectType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) diff --git a/commonspace/sync/objectsync/objectmessages/headupdate.go b/commonspace/sync/objectsync/objectmessages/headupdate.go index 2d9c3e02..d667c9dd 100644 --- a/commonspace/sync/objectsync/objectmessages/headupdate.go +++ b/commonspace/sync/objectsync/objectmessages/headupdate.go @@ -39,6 +39,7 @@ type InnerHeadUpdate interface { Prepare() error Heads() []string MsgSize() uint64 + ObjectType() spacesyncproto.ObjectType } type ObjectMeta struct { @@ -48,10 +49,11 @@ type ObjectMeta struct { } type HeadUpdate struct { - Meta ObjectMeta - Bytes []byte - Update InnerHeadUpdate - msg *spacesyncproto.ObjectSyncMessage + Meta ObjectMeta + Bytes []byte + Update InnerHeadUpdate + objectType spacesyncproto.ObjectType + msg *spacesyncproto.ObjectSyncMessage } func (h *HeadUpdate) MsgSize() uint64 { @@ -84,6 +86,7 @@ func (h *HeadUpdate) SetProtoMessage(message proto.Message) error { h.Bytes = msg.GetPayload() h.Meta.SpaceId = msg.SpaceId h.Meta.ObjectId = msg.ObjectId + h.objectType = msg.GetObjectType() return nil } @@ -94,14 +97,19 @@ func (h *HeadUpdate) ProtoMessage() (proto.Message, error) { return nil, err } return &spacesyncproto.ObjectSyncMessage{ - SpaceId: h.Meta.SpaceId, - Payload: payload, - ObjectId: h.Meta.ObjectId, + SpaceId: h.Meta.SpaceId, + Payload: payload, + ObjectId: h.Meta.ObjectId, + ObjectType: h.objectType, }, nil } return NewMessage(), nil } +func (h *HeadUpdate) ObjectType() spacesyncproto.ObjectType { + return h.objectType +} + func (h *HeadUpdate) SpaceId() string { return h.Meta.SpaceId } @@ -116,9 +124,10 @@ func (h *HeadUpdate) ObjectId() string { func (h *HeadUpdate) Copy() drpc.Message { return &HeadUpdate{ - Meta: h.Meta, - Bytes: h.Bytes, - Update: h.Update, - msg: h.msg, + Meta: h.Meta, + Bytes: h.Bytes, + Update: h.Update, + msg: h.msg, + objectType: h.objectType, } } diff --git a/commonspace/sync/sync.go b/commonspace/sync/sync.go index b58d75db..bbc173fb 100644 --- a/commonspace/sync/sync.go +++ b/commonspace/sync/sync.go @@ -12,6 +12,7 @@ import ( "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace/peermanager" "github.com/anyproto/any-sync/commonspace/spacestate" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/sync/syncdeps" "github.com/anyproto/any-sync/metric" "github.com/anyproto/any-sync/nodeconf" @@ -117,6 +118,9 @@ func (s *syncService) HandleMessage(ctx context.Context, msg drpc.Message) error if !ok { return ErrUnexpectedMessage } + if idMsg.ObjectType() == spacesyncproto.ObjectType_KeyValue { + return nil + } objectId := idMsg.ObjectId() err := s.receiveQueue.Add(ctx, objectId, msgCtx{ ctx: ctx, diff --git a/commonspace/sync/sync_test.go b/commonspace/sync/sync_test.go index c1070c18..7a2fbe0b 100644 --- a/commonspace/sync/sync_test.go +++ b/commonspace/sync/sync_test.go @@ -115,6 +115,14 @@ func TestSyncService(t *testing.T) { } require.Equal(t, headUpdate, f.syncHandler.headUpdate) }) + t.Run("handle key value message no op", func(t *testing.T) { + f := newFixture(t) + headUpdate := &testMessage{objectId: "objectId", objectType: spacesyncproto.ObjectType_KeyValue} + err := f.HandleMessage(ctx, headUpdate) + require.NoError(t, err) + f.Close(t) + require.Nil(t, f.syncHandler.headUpdate) + }) t.Run("handle message", func(t *testing.T) { f := newFixture(t) f.syncHandler.toReceiveData = map[string][]*testResponse{ @@ -386,7 +394,12 @@ func (r *testRequest) MsgSize() uint64 { } type testMessage struct { - objectId string + objectId string + objectType spacesyncproto.ObjectType +} + +func (t *testMessage) ObjectType() spacesyncproto.ObjectType { + return t.objectType } func (t *testMessage) ObjectId() string { diff --git a/commonspace/sync/syncdeps/message.go b/commonspace/sync/syncdeps/message.go index c1844098..26a0fac3 100644 --- a/commonspace/sync/syncdeps/message.go +++ b/commonspace/sync/syncdeps/message.go @@ -1,6 +1,9 @@ package syncdeps +import "github.com/anyproto/any-sync/commonspace/spacesyncproto" + type Message interface { ObjectId() string MsgSize() uint64 + ObjectType() spacesyncproto.ObjectType } From ab5caa097eeb6c3de51af5de83ca081ca890e2e2 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 13:15:16 +0200 Subject: [PATCH 11/62] Update secureservice with new proto version --- net/secureservice/secureservice.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/secureservice/secureservice.go b/net/secureservice/secureservice.go index 046434ab..3f38e5da 100644 --- a/net/secureservice/secureservice.go +++ b/net/secureservice/secureservice.go @@ -30,12 +30,14 @@ var ( // ProtoVersion 3 - acl with breaking changes / multiplayer // ProtoVersion 4 - new sync compatible version // ProtoVersion 5 - sync with no entry space + // ProtoVersion 6 - sync with key value messages CompatibleVersion = uint32(4) ProtoVersion = uint32(5) + KeyValueVersion = uint32(6) ) var ( - compatibleVersions = []uint32{CompatibleVersion, ProtoVersion} + compatibleVersions = []uint32{CompatibleVersion, ProtoVersion, KeyValueVersion} ) func New() SecureService { From 01b04d7dd2e1355820c3affd0fea713a2dd984ab Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 14:45:07 +0200 Subject: [PATCH 12/62] Correctly send object type --- commonspace/sync/objectsync/objectmessages/headupdate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonspace/sync/objectsync/objectmessages/headupdate.go b/commonspace/sync/objectsync/objectmessages/headupdate.go index d667c9dd..e8510f0e 100644 --- a/commonspace/sync/objectsync/objectmessages/headupdate.go +++ b/commonspace/sync/objectsync/objectmessages/headupdate.go @@ -100,7 +100,7 @@ func (h *HeadUpdate) ProtoMessage() (proto.Message, error) { SpaceId: h.Meta.SpaceId, Payload: payload, ObjectId: h.Meta.ObjectId, - ObjectType: h.objectType, + ObjectType: h.Update.ObjectType(), }, nil } return NewMessage(), nil From c788051efe89d8ca40b979a3a2067ece5f2ed937 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 22:53:02 +0200 Subject: [PATCH 13/62] WIP inner storage --- commonspace/object/keyvalue/element.go | 28 - commonspace/object/keyvalue/keyvalue.go | 11 + .../keyvaluestorage/innerstorage/element.go | 44 ++ .../innerstorage/keyvaluestorage.go | 213 ++++++ .../keyvalue/keyvaluestorage/storage.go | 37 + .../object/keyvalue/keyvaluestore/store.go | 129 ---- .../keyvalue/keyvaluestore/store_test.go | 146 ---- .../spacesyncproto/protos/spacesync.proto | 11 +- commonspace/spacesyncproto/spacesync.pb.go | 639 +++++++++++++++--- 9 files changed, 858 insertions(+), 400 deletions(-) delete mode 100644 commonspace/object/keyvalue/element.go create mode 100644 commonspace/object/keyvalue/keyvalue.go create mode 100644 commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go create mode 100644 commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go create mode 100644 commonspace/object/keyvalue/keyvaluestorage/storage.go delete mode 100644 commonspace/object/keyvalue/keyvaluestore/store.go delete mode 100644 commonspace/object/keyvalue/keyvaluestore/store_test.go diff --git a/commonspace/object/keyvalue/element.go b/commonspace/object/keyvalue/element.go deleted file mode 100644 index ed0eeb71..00000000 --- a/commonspace/object/keyvalue/element.go +++ /dev/null @@ -1,28 +0,0 @@ -package keyvalue - -import ( - "encoding/hex" - - "github.com/anyproto/any-store/anyenc" - "github.com/zeebo/blake3" -) - -type KeyValue struct { - Key string - Value []byte - TimestampMilli int -} - -func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { - obj := a.NewObject() - obj.Set("id", a.NewString(kv.Key)) - if len(kv.Value) == 0 { - obj.Set("d", a.NewTrue()) - } else { - obj.Set("v", a.NewBinary(kv.Value)) - hash := blake3.Sum256(kv.Value) - obj.Set("h", a.NewString(hex.EncodeToString(hash[:]))) - } - obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) - return obj -} diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go new file mode 100644 index 00000000..b7bd9e09 --- /dev/null +++ b/commonspace/object/keyvalue/keyvalue.go @@ -0,0 +1,11 @@ +package keyvalue + +import ( + "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" +) + +type KeyValueService interface { + app.ComponentRunnable + DefaultStore() innerstorage.KeyValueStorage +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go new file mode 100644 index 00000000..e2d0acef --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -0,0 +1,44 @@ +package innerstorage + +import ( + "github.com/anyproto/any-store/anyenc" + + "github.com/anyproto/any-sync/commonspace/spacesyncproto" +) + +type KeyValue struct { + Key string + Value Value + TimestampMilli int +} + +type Value struct { + Value []byte + PeerSignature []byte + IdentitySignature []byte +} + +func (v Value) AnyEnc(a *anyenc.Arena) *anyenc.Value { + obj := a.NewObject() + obj.Set("v", a.NewBinary(v.Value)) + obj.Set("p", a.NewBinary(v.PeerSignature)) + obj.Set("i", a.NewBinary(v.IdentitySignature)) + return obj +} + +func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { + obj := a.NewObject() + obj.Set("id", a.NewString(kv.Key)) + obj.Set("v", kv.Value.AnyEnc(a)) + obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) + return obj +} + +func (kv KeyValue) Proto() *spacesyncproto.StoreKeyValue { + return &spacesyncproto.StoreKeyValue{ + Key: kv.Key, + Value: kv.Value.Value, + PeerSignature: kv.Value.PeerSignature, + IdentitySignature: kv.Value.IdentitySignature, + } +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go new file mode 100644 index 00000000..7997eaf5 --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -0,0 +1,213 @@ +package innerstorage + +import ( + "context" + "encoding/binary" + "errors" + + anystore "github.com/anyproto/any-store" + "github.com/anyproto/any-store/anyenc" + + "github.com/anyproto/any-sync/app/ldiff" + "github.com/anyproto/any-sync/commonspace/headsync/headstorage" +) + +var ( + parserPool = &anyenc.ParserPool{} + arenaPool = &anyenc.ArenaPool{} +) + +type KeyValueStorage interface { + Set(ctx context.Context, keyValues ...KeyValue) (err error) + Diff() ldiff.CompareDiff + Get(ctx context.Context, key string) (keyValue KeyValue, err error) + IterateValues(context.Context, func(kv KeyValue) (bool, error)) (err error) +} + +type storage struct { + diff ldiff.CompareDiff + headStorage headstorage.HeadStorage + collection anystore.Collection + store anystore.DB +} + +func New(ctx context.Context, storageName string, headStorage headstorage.HeadStorage, store anystore.DB) (kv KeyValueStorage, err error) { + collection, err := store.Collection(ctx, storageName) + if err != nil { + return nil, err + } + tx, err := store.WriteTx(ctx) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + _ = tx.Rollback() + } else { + err = tx.Commit() + } + }() + storage := &storage{ + headStorage: headStorage, + collection: collection, + store: store, + diff: ldiff.New(32, 256).(ldiff.CompareDiff), + } + iter, err := storage.collection.Find(nil).Iter(ctx) + if err != nil { + return + } + defer func() { + _ = iter.Close() + }() + var ( + doc anystore.Doc + elements []ldiff.Element + ) + for iter.Next() { + if doc, err = iter.Doc(); err != nil { + return + } + elements = append(elements, anyEncToElement(doc.Value())) + } + storage.diff.Set(elements...) + hash := storage.diff.Hash() + err = headStorage.UpdateEntryTx(tx.Context(), headstorage.HeadsUpdate{ + Id: storageName, + Heads: []string{hash}, + }) + return storage, err +} + +func (s *storage) Diff() ldiff.CompareDiff { + return s.diff +} + +func (s *storage) Get(ctx context.Context, key string) (value KeyValue, err error) { + doc, err := s.collection.FindId(ctx, key) + if err != nil { + if errors.Is(err, anystore.ErrDocNotFound) { + return KeyValue{}, nil + } + return + } + return s.keyValueFromDoc(doc), nil +} + +func (s *storage) IterateValues(ctx context.Context, iterFunc func(kv KeyValue) (bool, error)) (err error) { + iter, err := s.collection.Find(nil).Iter(ctx) + if err != nil { + return + } + defer func() { + _ = iter.Close() + }() + var doc anystore.Doc + for iter.Next() { + if doc, err = iter.Doc(); err != nil { + return + } + continueIteration, err := iterFunc(s.keyValueFromDoc(doc)) + if err != nil { + return err + } + if !continueIteration { + break + } + } + return nil +} + +func (s *storage) keyValueFromDoc(doc anystore.Doc) KeyValue { + valueObj := doc.Value().GetObject("v") + value := Value{ + Value: valueObj.Get("v").GetBytes(), + PeerSignature: valueObj.Get("p").GetBytes(), + IdentitySignature: valueObj.Get("i").GetBytes(), + } + return KeyValue{ + Key: doc.Value().GetString("id"), + Value: value, + TimestampMilli: doc.Value().GetInt("t"), + } +} + +func (s *storage) init(ctx context.Context) (err error) { + s.diff = ldiff.New(32, 256).(ldiff.CompareDiff) + iter, err := s.collection.Find(nil).Iter(ctx) + if err != nil { + return + } + defer func() { + _ = iter.Close() + }() + var doc anystore.Doc + var elements []ldiff.Element + for iter.Next() { + if doc, err = iter.Doc(); err != nil { + return + } + elements = append(elements, anyEncToElement(doc.Value())) + } + s.diff.Set(elements...) + return +} + +func (s *storage) Set(ctx context.Context, values ...KeyValue) (err error) { + tx, err := s.collection.WriteTx(ctx) + if err != nil { + return + } + defer func() { + if err != nil { + _ = tx.Rollback() + } else { + err = tx.Commit() + } + }() + ctx = tx.Context() + elements, err := s.updateValues(ctx, values...) + if err != nil { + return + } + s.diff.Set(elements...) + return +} + +func (s *storage) updateValues(ctx context.Context, values ...KeyValue) (elements []ldiff.Element, err error) { + parser := parserPool.Get() + defer parserPool.Put(parser) + arena := arenaPool.Get() + defer arenaPool.Put(arena) + + elements = make([]ldiff.Element, 0, len(values)) + var doc anystore.Doc + for _, value := range values { + doc, err = s.collection.FindIdWithParser(ctx, parser, value.Key) + isNotFound := errors.Is(err, anystore.ErrDocNotFound) + if err != nil && !isNotFound { + return + } + if !isNotFound { + if doc.Value().GetInt("t") >= value.TimestampMilli { + continue + } + } + arena.Reset() + val := value.AnyEnc(arena) + if err = s.collection.UpsertOne(ctx, val); err != nil { + return + } + elements = append(elements, anyEncToElement(val)) + } + return +} + +func anyEncToElement(val *anyenc.Value) ldiff.Element { + byteRepr := make([]byte, 8) + binary.BigEndian.PutUint64(byteRepr, uint64(val.GetInt("t"))) + return ldiff.Element{ + Id: val.GetString("id"), + Head: string(byteRepr), + } +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go new file mode 100644 index 00000000..006bca4d --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -0,0 +1,37 @@ +package keyvaluestorage + +import ( + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" +) + +type Storage interface { + Set(key string, value []byte) error + SetRaw(keyValue *spacesyncproto.StoreKeyValue) error + GetAll(key string) (values []innerstorage.KeyValue, err error) + InnerStorage() innerstorage.KeyValueStorage +} +// +//type storage struct { +// +//} +// +//func (s *storage) Set(key string, value []byte) error { +// //TODO implement me +// panic("implement me") +//} +// +//func (s *storage) SetRaw(keyValue *spacesyncproto.StoreKeyValue) error { +// //TODO implement me +// panic("implement me") +//} +// +//func (s *storage) GetAll(key string) (values []innerstorage.KeyValue, err error) { +// //TODO implement me +// panic("implement me") +//} +// +//func (s *storage) InnerStorage() innerstorage.KeyValueStorage { +// //TODO implement me +// panic("implement me") +//} diff --git a/commonspace/object/keyvalue/keyvaluestore/store.go b/commonspace/object/keyvalue/keyvaluestore/store.go deleted file mode 100644 index 4545f44e..00000000 --- a/commonspace/object/keyvalue/keyvaluestore/store.go +++ /dev/null @@ -1,129 +0,0 @@ -package keyvaluestore - -import ( - "context" - "errors" - "strconv" - - anystore "github.com/anyproto/any-store" - "github.com/anyproto/any-store/anyenc" - - "github.com/anyproto/any-sync/app/ldiff" - "github.com/anyproto/any-sync/commonspace/object/keyvalue" -) - -var ( - parserPool = &anyenc.ParserPool{} - arenaPool = &anyenc.ArenaPool{} -) - -/** - -any-store document structure: - id (string) - key - v (bytes) - value - h (string) - value hash - t (int) - timestamp - d (bool) - isDeleted -*/ - -func NewKeyValueStore(ctx context.Context, collection anystore.Collection) (KeyValueStore, error) { - k := &keyValueStore{collection: collection} - if err := k.init(ctx); err != nil { - return nil, err - } - return k, nil -} - -type KeyValueStore interface { - Set(ctx context.Context, values ...keyvalue.KeyValue) (err error) - ldiff.Remote -} - -type keyValueStore struct { - collection anystore.Collection - ldiff.Diff -} - -func (k *keyValueStore) init(ctx context.Context) (err error) { - k.Diff = ldiff.New(32, 256) - iter, err := k.collection.Find(nil).Iter(ctx) - if err != nil { - return - } - defer func() { - _ = iter.Close() - }() - var doc anystore.Doc - for iter.Next() { - if doc, err = iter.Doc(); err != nil { - return - } - k.Diff.Set(anyEncToElement(doc.Value())) - } - return -} - -func (k *keyValueStore) Set(ctx context.Context, values ...keyvalue.KeyValue) (err error) { - elements, err := k.updateValues(ctx, values...) - if err != nil { - return - } - k.Diff.Set(elements...) - return -} - -func (k *keyValueStore) updateValues(ctx context.Context, values ...keyvalue.KeyValue) (elements []ldiff.Element, err error) { - tx, err := k.collection.WriteTx(ctx) - if err != nil { - return - } - defer func() { - if err != nil { - _ = tx.Rollback() - } else { - err = tx.Commit() - } - }() - ctx = tx.Context() - parser := parserPool.Get() - defer parserPool.Put(parser) - arena := arenaPool.Get() - defer arenaPool.Put(arena) - - elements = make([]ldiff.Element, 0, len(values)) - var doc anystore.Doc - for _, value := range values { - doc, err = k.collection.FindIdWithParser(ctx, parser, value.Key) - isNotFound := errors.Is(err, anystore.ErrDocNotFound) - if err != nil && !isNotFound { - return - } - if !isNotFound { - if doc.Value().GetInt("t") >= value.TimestampMilli { - // newest doc is already present - continue - } - } - arena.Reset() - val := value.AnyEnc(arena) - if err = k.collection.UpsertOne(ctx, val); err != nil { - return - } - elements = append(elements, anyEncToElement(val)) - } - return -} - -func anyEncToElement(val *anyenc.Value) ldiff.Element { - head := strconv.Itoa(val.GetInt("t")) + "/" - if val.GetBool("d") { - head += "del" - } else { - head += val.GetString("h") - } - return ldiff.Element{ - Id: val.GetString("id"), - Head: head, - } -} diff --git a/commonspace/object/keyvalue/keyvaluestore/store_test.go b/commonspace/object/keyvalue/keyvaluestore/store_test.go deleted file mode 100644 index 08051a90..00000000 --- a/commonspace/object/keyvalue/keyvaluestore/store_test.go +++ /dev/null @@ -1,146 +0,0 @@ -package keyvaluestore - -import ( - "context" - "os" - "path/filepath" - "testing" - - anystore "github.com/anyproto/any-store" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/anyproto/any-sync/commonspace/object/keyvalue" -) - -var ctx = context.Background() - -func TestKeyValueStore_Set(t *testing.T) { - var values = []keyvalue.KeyValue{ - { - Key: "1", - Value: []byte("1"), - TimestampMilli: 1, - }, - { - Key: "2", - Value: []byte("2"), - TimestampMilli: 1, - }, - { - Key: "3", - Value: []byte("4"), - TimestampMilli: 1, - }, - } - - t.Run("new", func(t *testing.T) { - fx := newFixture(t) - err := fx.Set(ctx, values...) - assert.NoError(t, err) - count, _ := fx.coll.Count(ctx) - assert.Equal(t, 3, count) - assert.Equal(t, 3, fx.Diff.Len()) - }) - t.Run("restore", func(t *testing.T) { - fx := newFixture(t) - err := fx.Set(ctx, values...) - assert.NoError(t, err) - hash := fx.Diff.Hash() - kv2, err := NewKeyValueStore(ctx, fx.coll) - require.NoError(t, err) - assert.Equal(t, kv2.(*keyValueStore).Diff.Hash(), hash) - }) - t.Run("update", func(t *testing.T) { - fx := newFixture(t) - err := fx.Set(ctx, values...) - assert.NoError(t, err) - hash := fx.Diff.Hash() - - // do not update because timestamp is not greater - require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "1", TimestampMilli: 1})) - assert.Equal(t, hash, fx.Diff.Hash()) - // should be updated - require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "2", TimestampMilli: 2, Value: []byte("22")})) - assert.NotEqual(t, hash, fx.Diff.Hash()) - }) - t.Run("delete", func(t *testing.T) { - fx := newFixture(t) - err := fx.Set(ctx, values...) - assert.NoError(t, err) - hash := fx.Diff.Hash() - - require.NoError(t, fx.Set(ctx, keyvalue.KeyValue{Key: "1", TimestampMilli: 3})) - assert.NotEqual(t, hash, fx.Diff.Hash()) - }) -} - -func TestKeyValueStore_E2E(t *testing.T) { - fx1 := newFixture(t) - fx2 := newFixture(t) - - newIds, changedIds, remodedIds, err := fx1.Diff.Diff(ctx, fx2) - require.NoError(t, err) - assert.Len(t, newIds, 0) - assert.Len(t, changedIds, 0) - assert.Len(t, remodedIds, 0) - - require.NoError(t, fx1.Set(ctx, []keyvalue.KeyValue{ - {Key: "1", Value: []byte("1"), TimestampMilli: 1}, - {Key: "2", Value: []byte("1"), TimestampMilli: 1}, - {Key: "3", Value: []byte("1"), TimestampMilli: 1}, - {Key: "4", Value: []byte("1"), TimestampMilli: 1}, - {Key: "5", Value: []byte("1"), TimestampMilli: 1}, - }...)) - - newIds, changedIds, remodedIds, err = fx1.Diff.Diff(ctx, fx2) - require.NoError(t, err) - assert.Len(t, newIds, 0) - assert.Len(t, changedIds, 0) - assert.Len(t, remodedIds, 5) - - require.NoError(t, fx2.Set(ctx, []keyvalue.KeyValue{ - {Key: "1", Value: []byte("1"), TimestampMilli: 1}, - {Key: "2", Value: []byte("1"), TimestampMilli: 1}, - {Key: "3", Value: []byte("1"), TimestampMilli: 1}, - {Key: "4", Value: []byte("1"), TimestampMilli: 1}, - {Key: "5", Value: []byte("1"), TimestampMilli: 1}, - }...)) - - newIds, changedIds, remodedIds, err = fx1.Diff.Diff(ctx, fx2) - require.NoError(t, err) - assert.Len(t, newIds, 0) - assert.Len(t, changedIds, 0) - assert.Len(t, remodedIds, 0) -} - -func newFixture(t testing.TB) *fixture { - tmpDir, err := os.MkdirTemp("", "") - require.NoError(t, err) - db, err := anystore.Open(ctx, filepath.Join(tmpDir, "test.db"), nil) - require.NoError(t, err) - coll, err := db.Collection(ctx, "test") - require.NoError(t, err) - kv, err := NewKeyValueStore(ctx, coll) - require.NoError(t, err) - fx := &fixture{ - keyValueStore: kv.(*keyValueStore), - db: db, - coll: coll, - } - t.Cleanup(func() { - fx.finish(t) - _ = os.RemoveAll(tmpDir) - }) - return fx -} - -type fixture struct { - *keyValueStore - db anystore.DB - coll anystore.Collection -} - -func (fx *fixture) finish(t testing.TB) { - assert.NoError(t, fx.db.Close()) -} diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index 838ff1d7..4b867c90 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -211,7 +211,16 @@ message StoreDiffResponse { message StoreKeyValue { string key = 1; bytes value = 2; - int64 timestampMilli = 3; + bytes identitySignature = 3; + bytes peerSignature = 4; +} + +message StoreKeyInner { + bytes peer = 1; + bytes identity = 2; + bytes value = 3; + int64 timestampMilli = 4; + string aclHeadId = 5; } // DiffType is a type of diff diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index c2530a5d..79a3fc14 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1788,9 +1788,10 @@ func (m *StoreDiffResponse) GetResults() []*HeadSyncResult { } type StoreKeyValue struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - TimestampMilli int64 `protobuf:"varint,3,opt,name=timestampMilli,proto3" json:"timestampMilli,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + IdentitySignature []byte `protobuf:"bytes,3,opt,name=identitySignature,proto3" json:"identitySignature,omitempty"` + PeerSignature []byte `protobuf:"bytes,4,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"` } func (m *StoreKeyValue) Reset() { *m = StoreKeyValue{} } @@ -1848,13 +1849,104 @@ func (m *StoreKeyValue) GetValue() []byte { return nil } -func (m *StoreKeyValue) GetTimestampMilli() int64 { +func (m *StoreKeyValue) GetIdentitySignature() []byte { + if m != nil { + return m.IdentitySignature + } + return nil +} + +func (m *StoreKeyValue) GetPeerSignature() []byte { + if m != nil { + return m.PeerSignature + } + return nil +} + +type StoreKeyInner struct { + Peer []byte `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + TimestampMilli int64 `protobuf:"varint,4,opt,name=timestampMilli,proto3" json:"timestampMilli,omitempty"` + AclHeadId string `protobuf:"bytes,5,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` +} + +func (m *StoreKeyInner) Reset() { *m = StoreKeyInner{} } +func (m *StoreKeyInner) String() string { return proto.CompactTextString(m) } +func (*StoreKeyInner) ProtoMessage() {} +func (*StoreKeyInner) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{27} +} +func (m *StoreKeyInner) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreKeyInner) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreKeyInner.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreKeyInner) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreKeyInner) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreKeyInner.Merge(m, src) +} +func (m *StoreKeyInner) XXX_Size() int { + return m.Size() +} +func (m *StoreKeyInner) XXX_DiscardUnknown() { + xxx_messageInfo_StoreKeyInner.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreKeyInner proto.InternalMessageInfo + +func (m *StoreKeyInner) GetPeer() []byte { + if m != nil { + return m.Peer + } + return nil +} + +func (m *StoreKeyInner) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *StoreKeyInner) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *StoreKeyInner) GetTimestampMilli() int64 { if m != nil { return m.TimestampMilli } return 0 } +func (m *StoreKeyInner) GetAclHeadId() string { + if m != nil { + return m.AclHeadId + } + return "" +} + func init() { proto.RegisterEnum("spacesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("spacesync.SpaceSubscriptionAction", SpaceSubscriptionAction_name, SpaceSubscriptionAction_value) @@ -1886,6 +1978,7 @@ func init() { proto.RegisterType((*StoreDiffRequest)(nil), "spacesync.StoreDiffRequest") proto.RegisterType((*StoreDiffResponse)(nil), "spacesync.StoreDiffResponse") proto.RegisterType((*StoreKeyValue)(nil), "spacesync.StoreKeyValue") + proto.RegisterType((*StoreKeyInner)(nil), "spacesync.StoreKeyInner") } func init() { @@ -1893,95 +1986,99 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1399 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcf, 0x6f, 0xdb, 0xb6, - 0x17, 0xb7, 0xe4, 0xc4, 0xb1, 0x5f, 0x1c, 0x57, 0x65, 0xdc, 0xc6, 0x5f, 0xb7, 0x70, 0x0d, 0xe2, - 0x8b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0xd0, - 0xc5, 0x9d, 0xbc, 0x63, 0xa1, 0x03, 0x68, 0x9a, 0xd3, 0x17, 0xf5, 0x0c, 0xf9, 0x92, 0x09, 0xdf, - 0xbd, 0x31, 0x97, 0x9f, 0xe5, 0x71, 0xa5, 0x30, 0x34, 0xd1, 0x8c, 0xc6, 0xb9, 0xd1, 0xdc, 0xed, - 0xcf, 0x17, 0x48, 0x30, 0x1f, 0x7c, 0xf2, 0xfb, 0xdb, 0x9e, 0xf5, 0xe6, 0x6d, 0xcf, 0xfa, 0xeb, - 0x6d, 0xcf, 0xfa, 0xe5, 0x5d, 0xaf, 0xf2, 0xe6, 0x5d, 0xaf, 0xf2, 0xe7, 0xbb, 0x5e, 0xe5, 0xeb, - 0xee, 0xfc, 0x7f, 0x96, 0x8f, 0x6a, 0xea, 0xe7, 0xee, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, - 0xb4, 0x95, 0xdb, 0x51, 0x0f, 0x00, 0x00, + // 1458 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x17, 0x4b, 0x6f, 0xdb, 0x46, + 0x53, 0xa4, 0x6c, 0x59, 0x1a, 0xcb, 0x0a, 0xbd, 0x56, 0x62, 0x7d, 0x4a, 0xa0, 0x08, 0xc4, 0x87, + 0xd4, 0x08, 0x8a, 0x24, 0x76, 0x8a, 0x02, 0x49, 0xdb, 0x83, 0x63, 0x3b, 0xb1, 0x9a, 0x3a, 0x36, + 0x56, 0x79, 0x00, 0x05, 0x7a, 0xa0, 0xc9, 0xb5, 0xcd, 0x86, 0x22, 0x55, 0xee, 0x2a, 0xb1, 0x8e, + 0x3d, 0xf5, 0x50, 0xb4, 0xe8, 0xb9, 0xfd, 0x43, 0x3d, 0xa6, 0xb7, 0x1e, 0x8b, 0xe4, 0xde, 0xdf, + 0x50, 0xec, 0x72, 0xb9, 0x5c, 0x52, 0x54, 0x9a, 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0x0c, 0xe8, 0xe2, 0x4e, 0xde, 0x31, + 0xd0, 0x21, 0x34, 0xf5, 0x45, 0x82, 0x7a, 0x1a, 0x7f, 0xc9, 0xb2, 0xea, 0x5e, 0x9f, 0x4b, 0x57, + 0x79, 0x5c, 0xc9, 0xcd, 0x7f, 0x54, 0x90, 0x98, 0xd9, 0x32, 0xdd, 0xfe, 0x7c, 0x86, 0x44, 0xe7, + 0x83, 0x4f, 0x7e, 0x7f, 0xdb, 0x33, 0xde, 0xbc, 0xed, 0x19, 0x7f, 0xbd, 0xed, 0x19, 0xbf, 0xbc, + 0xeb, 0x55, 0xde, 0xbc, 0xeb, 0x55, 0xfe, 0x7c, 0xd7, 0xab, 0x7c, 0xdd, 0x9d, 0xff, 0xbb, 0xff, + 0xb8, 0x26, 0xfe, 0xdd, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x64, 0xaf, 0x73, 0x0c, 0x1c, 0x10, + 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3091,10 +3188,19 @@ func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.TimestampMilli != 0 { - i = encodeVarintSpacesync(dAtA, i, uint64(m.TimestampMilli)) + if len(m.PeerSignature) > 0 { + i -= len(m.PeerSignature) + copy(dAtA[i:], m.PeerSignature) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.PeerSignature))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x22 + } + if len(m.IdentitySignature) > 0 { + i -= len(m.IdentitySignature) + copy(dAtA[i:], m.IdentitySignature) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.IdentitySignature))) + i-- + dAtA[i] = 0x1a } if len(m.Value) > 0 { i -= len(m.Value) @@ -3113,6 +3219,62 @@ func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StoreKeyInner) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreKeyInner) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreKeyInner) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AclHeadId) > 0 { + i -= len(m.AclHeadId) + copy(dAtA[i:], m.AclHeadId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.AclHeadId))) + i-- + dAtA[i] = 0x2a + } + if m.TimestampMilli != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.TimestampMilli)) + i-- + dAtA[i] = 0x20 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.Peer) > 0 { + i -= len(m.Peer) + copy(dAtA[i:], m.Peer) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Peer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -3627,9 +3789,42 @@ func (m *StoreKeyValue) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } + l = len(m.IdentitySignature) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.PeerSignature) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + +func (m *StoreKeyInner) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Peer) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } if m.TimestampMilli != 0 { n += 1 + sovSpacesync(uint64(m.TimestampMilli)) } + l = len(m.AclHeadId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } return n } @@ -6790,6 +6985,226 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdentitySignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IdentitySignature = append(m.IdentitySignature[:0], dAtA[iNdEx:postIndex]...) + if m.IdentitySignature == nil { + m.IdentitySignature = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeerSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PeerSignature = append(m.PeerSignature[:0], dAtA[iNdEx:postIndex]...) + if m.PeerSignature == nil { + m.PeerSignature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreKeyInner: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreKeyInner: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Peer", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Peer = append(m.Peer[:0], dAtA[iNdEx:postIndex]...) + if m.Peer == nil { + m.Peer = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimestampMilli", wireType) } @@ -6808,6 +7223,38 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclHeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) From 998056d70f04bf43e5ea5a1ce9944c1641ee4a29 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 3 Apr 2025 23:19:29 +0200 Subject: [PATCH 14/62] Update storage --- .../keyvaluestorage/innerstorage/element.go | 4 ++ .../innerstorage/keyvaluestorage.go | 31 +++++++++ .../keyvalue/keyvaluestorage/storage.go | 66 +++++++++++-------- 3 files changed, 74 insertions(+), 27 deletions(-) diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go index e2d0acef..eeb0e64f 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -10,6 +10,8 @@ type KeyValue struct { Key string Value Value TimestampMilli int + Identity string + PeerId string } type Value struct { @@ -31,6 +33,8 @@ func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { obj.Set("id", a.NewString(kv.Key)) obj.Set("v", kv.Value.AnyEnc(a)) obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) + obj.Set("i", a.NewString(kv.Identity)) + obj.Set("p", a.NewString(kv.PeerId)) return obj } diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index 7997eaf5..db32316d 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -4,9 +4,11 @@ import ( "context" "encoding/binary" "errors" + "strings" anystore "github.com/anyproto/any-store" "github.com/anyproto/any-store/anyenc" + "github.com/anyproto/any-store/query" "github.com/anyproto/any-sync/app/ldiff" "github.com/anyproto/any-sync/commonspace/headsync/headstorage" @@ -22,6 +24,7 @@ type KeyValueStorage interface { Diff() ldiff.CompareDiff Get(ctx context.Context, key string) (keyValue KeyValue, err error) IterateValues(context.Context, func(kv KeyValue) (bool, error)) (err error) + IteratePrefix(context.Context, string, func(kv KeyValue) error) (err error) } type storage struct { @@ -118,6 +121,32 @@ func (s *storage) IterateValues(ctx context.Context, iterFunc func(kv KeyValue) return nil } +func (s *storage) IteratePrefix(ctx context.Context, prefix string, iterFunc func(kv KeyValue) error) (err error) { + filter := query.Key{Path: []string{"id"}, Filter: query.NewComp(query.CompOpGte, prefix)} + qry := s.collection.Find(filter).Sort("id") + iter, err := s.collection.Find(qry).Iter(ctx) + if err != nil { + return + } + defer func() { + _ = iter.Close() + }() + var doc anystore.Doc + for iter.Next() { + if doc, err = iter.Doc(); err != nil { + return + } + if !strings.Contains(doc.Value().GetString("id"), prefix) { + break + } + err := iterFunc(s.keyValueFromDoc(doc)) + if err != nil { + return err + } + } + return nil +} + func (s *storage) keyValueFromDoc(doc anystore.Doc) KeyValue { valueObj := doc.Value().GetObject("v") value := Value{ @@ -129,6 +158,8 @@ func (s *storage) keyValueFromDoc(doc anystore.Doc) KeyValue { Key: doc.Value().GetString("id"), Value: value, TimestampMilli: doc.Value().GetInt("t"), + Identity: doc.Value().GetString("i"), + PeerId: doc.Value().GetString("p"), } } diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 006bca4d..87078c10 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -1,37 +1,49 @@ package keyvaluestorage import ( + "context" + + "github.com/anyproto/any-sync/commonspace/object/accountdata" + "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" ) +type Indexer interface { + Index(keyValue innerstorage.KeyValue) error +} + type Storage interface { - Set(key string, value []byte) error - SetRaw(keyValue *spacesyncproto.StoreKeyValue) error - GetAll(key string) (values []innerstorage.KeyValue, err error) + Set(ctx context.Context, key string, value []byte) error + SetRaw(ctx context.Context, keyValue *spacesyncproto.StoreKeyValue) error + GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) InnerStorage() innerstorage.KeyValueStorage } -// -//type storage struct { -// -//} -// -//func (s *storage) Set(key string, value []byte) error { -// //TODO implement me -// panic("implement me") -//} -// -//func (s *storage) SetRaw(keyValue *spacesyncproto.StoreKeyValue) error { -// //TODO implement me -// panic("implement me") -//} -// -//func (s *storage) GetAll(key string) (values []innerstorage.KeyValue, err error) { -// //TODO implement me -// panic("implement me") -//} -// -//func (s *storage) InnerStorage() innerstorage.KeyValueStorage { -// //TODO implement me -// panic("implement me") -//} + +type storage struct { + inner innerstorage.KeyValueStorage + keys *accountdata.AccountKeys + aclList list.AclList +} + +func (s *storage) Set(ctx context.Context, key string, value []byte) error { + //TODO implement me + panic("implement me") +} + +func (s *storage) SetRaw(ctx context.Context, keyValue *spacesyncproto.StoreKeyValue) error { + //TODO implement me + panic("implement me") +} + +func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) { + err = s.inner.IteratePrefix(ctx, key, func(kv innerstorage.KeyValue) error { + values = append(values, kv) + return nil + }) + return +} + +func (s *storage) InnerStorage() innerstorage.KeyValueStorage { + return s.inner +} From d5233fc418f4de676760b9b7d7c531a40e3e7196 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 11:28:50 +0200 Subject: [PATCH 15/62] Implement key value set --- .../keyvaluestorage/innerstorage/element.go | 36 +++ .../keyvalue/keyvaluestorage/storage.go | 98 +++++++- .../spacesyncproto/protos/spacesync.proto | 1 + commonspace/spacesyncproto/spacesync.pb.go | 237 +++++++++++------- 4 files changed, 272 insertions(+), 100 deletions(-) diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go index eeb0e64f..38358852 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -1,11 +1,16 @@ package innerstorage import ( + "errors" + "github.com/anyproto/any-store/anyenc" "github.com/anyproto/any-sync/commonspace/spacesyncproto" + "github.com/anyproto/any-sync/util/crypto" ) +var ErrInvalidSignature = errors.New("invalid signature") + type KeyValue struct { Key string Value Value @@ -20,6 +25,37 @@ type Value struct { IdentitySignature []byte } +func KeyValueFromProto(proto *spacesyncproto.StoreKeyValue, verify bool) (kv KeyValue, err error) { + kv.Key = proto.Key + kv.Value.Value = proto.Value + kv.Value.PeerSignature = proto.PeerSignature + kv.Value.IdentitySignature = proto.IdentitySignature + innerValue := &spacesyncproto.StoreKeyInner{} + if err = innerValue.Unmarshal(proto.Value); err != nil { + return kv, err + } + kv.TimestampMilli = int(innerValue.TimestampMilli) + identity, err := crypto.UnmarshalEd25519PublicKeyProto(innerValue.Identity) + if err != nil { + return kv, err + } + peerId, err := crypto.UnmarshalEd25519PublicKeyProto(innerValue.Peer) + if err != nil { + return kv, err + } + kv.Identity = identity.Account() + kv.PeerId = peerId.PeerId() + if verify { + if verify, _ = identity.Verify(proto.Value, proto.IdentitySignature); !verify { + return kv, ErrInvalidSignature + } + if verify, _ = peerId.Verify(proto.Value, proto.PeerSignature); !verify { + return kv, ErrInvalidSignature + } + } + return kv, nil +} + func (v Value) AnyEnc(a *anyenc.Arena) *anyenc.Value { obj := a.NewObject() obj.Set("v", a.NewBinary(v.Value)) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 87078c10..3e022ce7 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -2,20 +2,27 @@ package keyvaluestorage import ( "context" + "sync" + "time" + "go.uber.org/zap" + + "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace/object/accountdata" "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" ) +var log = logger.NewNamed("common.keyvalue.keyvaluestorage") + type Indexer interface { - Index(keyValue innerstorage.KeyValue) error + Index(keyValue ...innerstorage.KeyValue) error } type Storage interface { Set(ctx context.Context, key string, value []byte) error - SetRaw(ctx context.Context, keyValue *spacesyncproto.StoreKeyValue) error + SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) InnerStorage() innerstorage.KeyValueStorage } @@ -24,16 +31,93 @@ type storage struct { inner innerstorage.KeyValueStorage keys *accountdata.AccountKeys aclList list.AclList + indexer Indexer + mx sync.Mutex } func (s *storage) Set(ctx context.Context, key string, value []byte) error { - //TODO implement me - panic("implement me") + s.mx.Lock() + defer s.mx.Unlock() + s.aclList.RLock() + headId := s.aclList.Head().Id + if !s.aclList.AclState().Permissions(s.aclList.AclState().Identity()).CanWrite() { + s.aclList.RUnlock() + return list.ErrInsufficientPermissions + } + s.aclList.RUnlock() + peerIdKey := s.keys.PeerKey + identityKey := s.keys.SignKey + protoPeerKey, err := peerIdKey.GetPublic().Marshall() + if err != nil { + return err + } + protoIdentityKey, err := identityKey.GetPublic().Marshall() + if err != nil { + return err + } + timestampMilli := time.Now().UnixMilli() + inner := spacesyncproto.StoreKeyInner{ + Peer: protoPeerKey, + Identity: protoIdentityKey, + Value: value, + TimestampMilli: timestampMilli, + AclHeadId: headId, + Key: key, + } + innerBytes, err := inner.Marshal() + if err != nil { + return err + } + peerSig, err := peerIdKey.Sign(innerBytes) + if err != nil { + return err + } + identitySig, err := identityKey.Sign(innerBytes) + if err != nil { + return err + } + keyValue := innerstorage.KeyValue{ + Key: key, + Value: innerstorage.Value{ + Value: value, + PeerSignature: peerSig, + IdentitySignature: identitySig, + }, + TimestampMilli: int(timestampMilli), + Identity: identityKey.GetPublic().Account(), + PeerId: peerIdKey.GetPublic().PeerId(), + } + err = s.inner.Set(ctx, keyValue) + if err != nil { + return err + } + indexErr := s.indexer.Index(keyValue) + if indexErr != nil { + log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) + } + return nil } -func (s *storage) SetRaw(ctx context.Context, keyValue *spacesyncproto.StoreKeyValue) error { - //TODO implement me - panic("implement me") +func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error { + s.mx.Lock() + defer s.mx.Unlock() + keyValues := make([]innerstorage.KeyValue, len(keyValue)) + for _, kv := range keyValue { + innerKv, err := innerstorage.KeyValueFromProto(kv, true) + if err != nil { + return err + } + keyValues = append(keyValues, innerKv) + } + err := s.inner.Set(ctx, keyValues...) + if err != nil { + return err + } + indexErr := s.indexer.Index(keyValues...) + if indexErr != nil { + log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) + } + return nil } func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) { diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index 4b867c90..b6576d3b 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -221,6 +221,7 @@ message StoreKeyInner { bytes value = 3; int64 timestampMilli = 4; string aclHeadId = 5; + string key = 6; } // DiffType is a type of diff diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 79a3fc14..5eb5f394 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1869,6 +1869,7 @@ type StoreKeyInner struct { Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` TimestampMilli int64 `protobuf:"varint,4,opt,name=timestampMilli,proto3" json:"timestampMilli,omitempty"` AclHeadId string `protobuf:"bytes,5,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` } func (m *StoreKeyInner) Reset() { *m = StoreKeyInner{} } @@ -1947,6 +1948,13 @@ func (m *StoreKeyInner) GetAclHeadId() string { return "" } +func (m *StoreKeyInner) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + func init() { proto.RegisterEnum("spacesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("spacesync.SpaceSubscriptionAction", SpaceSubscriptionAction_name, SpaceSubscriptionAction_value) @@ -1986,99 +1994,99 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x17, 0x4b, 0x6f, 0xdb, 0x46, - 0x53, 0xa4, 0x6c, 0x59, 0x1a, 0xcb, 0x0a, 0xbd, 0x56, 0x62, 0x7d, 0x4a, 0xa0, 0x08, 0xc4, 0x87, - 0xd4, 0x08, 0x8a, 0x24, 0x76, 0x8a, 0x02, 0x49, 0xdb, 0x83, 0x63, 0x3b, 0xb1, 0x9a, 0x3a, 0x36, - 0x56, 0x79, 0x00, 0x05, 0x7a, 0xa0, 0xc9, 0xb5, 0xcd, 0x86, 0x22, 0x55, 0xee, 0x2a, 0xb1, 0x8e, - 0x3d, 0xf5, 0x50, 0xb4, 0xe8, 0xb9, 0xfd, 0x43, 0x3d, 0xa6, 0xb7, 0x1e, 0x8b, 0xe4, 0xde, 0xdf, - 0x50, 0xec, 0x72, 0xb9, 0x5c, 0x52, 0x54, 0x9a, 0xc2, 0x17, 0x9b, 0xf3, 0x7e, 0xee, 0xcc, 0x08, - 0x36, 0xdd, 0x68, 0x34, 0x8a, 0x42, 0x3a, 0x76, 0x5c, 0x72, 0x5b, 0xfc, 0xa5, 0xd3, 0xd0, 0x1d, - 0xc7, 0x11, 0x8b,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b, 0xea, 0x9e, 0x7f, 0x72, 0xf2, 0x74, - 0x3a, 0x26, 0xc2, 0xeb, 0xd6, 0xd6, 0x9a, 0x26, 0xb3, 0x2b, 0x49, 0x58, 0x31, 0xd9, 0xe7, 0x60, - 0x69, 0xd1, 0x8c, 0xa3, 0x90, 0x12, 0x74, 0x17, 0x96, 0x62, 0x11, 0x19, 0xed, 0x18, 0xc2, 0xee, - 0xff, 0xe6, 0x26, 0x0d, 0xa7, 0x9c, 0x39, 0xcb, 0xe6, 0x87, 0x58, 0xfe, 0xcd, 0x80, 0xd5, 0xc3, - 0xe3, 0x6f, 0x89, 0xcb, 0xb8, 0xba, 0x03, 0x42, 0xa9, 0x73, 0x4a, 0xde, 0x93, 0x8c, 0x6b, 0xd0, - 0x88, 0x93, 0x8c, 0x0d, 0xd2, 0x9c, 0x66, 0x08, 0x2e, 0x17, 0x93, 0x71, 0x30, 0x1d, 0x78, 0x22, - 0xee, 0x06, 0x4e, 0x41, 0x4e, 0x19, 0x3b, 0xd3, 0x20, 0x72, 0x3c, 0xd1, 0x44, 0x4d, 0x9c, 0x82, - 0xbc, 0xbf, 0x22, 0xe1, 0xc0, 0xc0, 0xeb, 0x2c, 0x0a, 0x21, 0x05, 0xdb, 0x04, 0xac, 0x21, 0x37, - 0x7c, 0x34, 0xa1, 0x67, 0x69, 0xa1, 0x36, 0x33, 0x4d, 0xdc, 0xb7, 0xe5, 0xad, 0x75, 0x2d, 0xc2, - 0x84, 0x3b, 0x21, 0x67, 0x26, 0x7a, 0x00, 0x3b, 0x31, 0xf1, 0x48, 0xc8, 0x7c, 0x27, 0x10, 0x5e, - 0x37, 0xb1, 0x86, 0xb1, 0xd7, 0x60, 0x55, 0x33, 0x93, 0xe4, 0xdf, 0xb6, 0x95, 0xed, 0x20, 0x48, - 0x6d, 0x17, 0x9a, 0xcb, 0x7e, 0xa8, 0x04, 0x39, 0x8f, 0x2c, 0xdc, 0x7f, 0x77, 0xd0, 0xfe, 0xde, - 0x84, 0x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, 0x54, 0x90, 0x98, 0xd9, 0x32, 0xdd, 0xfe, 0x7c, 0x86, 0x44, 0xe7, - 0x83, 0x4f, 0x7e, 0x7f, 0xdb, 0x33, 0xde, 0xbc, 0xed, 0x19, 0x7f, 0xbd, 0xed, 0x19, 0xbf, 0xbc, - 0xeb, 0x55, 0xde, 0xbc, 0xeb, 0x55, 0xfe, 0x7c, 0xd7, 0xab, 0x7c, 0xdd, 0x9d, 0xff, 0xbb, 0xff, - 0xb8, 0x26, 0xfe, 0xdd, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x64, 0xaf, 0x73, 0x0c, 0x1c, 0x10, - 0x00, 0x00, + // 1465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x18, 0x4d, 0x6f, 0x1b, 0x45, + 0xd4, 0xbb, 0x4e, 0x1c, 0xfb, 0xc5, 0x71, 0x37, 0x13, 0xb7, 0x31, 0x6e, 0xe5, 0x5a, 0x2b, 0x54, + 0xa2, 0x0a, 0xb5, 0x4d, 0x8a, 0x90, 0x5a, 0xe0, 0x90, 0x26, 0x69, 0x63, 0x4a, 0x9a, 0x68, 0xdc, + 0x0f, 0x09, 0x89, 0xc3, 0x66, 0x77, 0x92, 0x2c, 0x5d, 0xef, 0x9a, 0x9d, 0x71, 0x1b, 0x1f, 0x39, + 0x71, 0x40, 0x20, 0xce, 0xf0, 0x1b, 0xf8, 0x1f, 0x1c, 0xcb, 0x8d, 0x23, 0x6a, 0xef, 0xfc, 0x06, + 0x34, 0xb3, 0xb3, 0xb3, 0xb3, 0xeb, 0x75, 0x29, 0xea, 0x25, 0xd9, 0xf7, 0xfd, 0x39, 0xef, 0xbd, + 0x04, 0x36, 0xdd, 0x68, 0x34, 0x8a, 0x42, 0x3a, 0x76, 0x5c, 0x72, 0x53, 0xfc, 0xa4, 0xd3, 0xd0, + 0x1d, 0xc7, 0x11, 0x8b, 0x6e, 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x9e, 0x7f, 0x72, 0xf2, + 0x78, 0x3a, 0x26, 0xc2, 0xeb, 0xd6, 0xd6, 0x9a, 0x26, 0xb3, 0x2b, 0x49, 0x58, 0x31, 0xd9, 0xe7, + 0x60, 0x69, 0xd1, 0x8c, 0xa3, 0x90, 0x12, 0x74, 0x1b, 0x96, 0x62, 0x11, 0x19, 0xed, 0x18, 0xc2, + 0xee, 0x07, 0x73, 0x93, 0x86, 0x53, 0xce, 0x9c, 0x65, 0xf3, 0x5d, 0x2c, 0xff, 0x66, 0xc0, 0xea, + 0xe1, 0xf1, 0xb7, 0xc4, 0x65, 0x5c, 0xdd, 0x01, 0xa1, 0xd4, 0x39, 0x25, 0x6f, 0x49, 0xc6, 0x15, + 0x68, 0xc4, 0x49, 0xc6, 0x06, 0x69, 0x4e, 0x33, 0x04, 0x97, 0x8b, 0xc9, 0x38, 0x98, 0x0e, 0x3c, + 0x11, 0x77, 0x03, 0xa7, 0x20, 0xa7, 0x8c, 0x9d, 0x69, 0x10, 0x39, 0x9e, 0x68, 0xa2, 0x26, 0x4e, + 0x41, 0xde, 0x5f, 0x91, 0x70, 0x60, 0xe0, 0x75, 0x16, 0x85, 0x90, 0x82, 0x6d, 0x02, 0xd6, 0x90, + 0x1b, 0x3e, 0x9a, 0xd0, 0xb3, 0xb4, 0x50, 0x9b, 0x99, 0x26, 0xee, 0xdb, 0xf2, 0xd6, 0xba, 0x16, + 0x61, 0xc2, 0x9d, 0x90, 0x33, 0x13, 0x3d, 0x80, 0x9d, 0x98, 0x78, 0x24, 0x64, 0xbe, 0x13, 0x08, + 0xaf, 0x9b, 0x58, 0xc3, 0xd8, 0x6b, 0xb0, 0xaa, 0x99, 0x49, 0xf2, 0x6f, 0xdb, 0xca, 0x76, 0x10, + 0xa4, 0xb6, 0x0b, 0xcd, 0x65, 0xdf, 0x57, 0x82, 0x9c, 0x47, 0x16, 0xee, 0xff, 0x3b, 0x68, 0x7f, + 0x6f, 0x42, 0x53, 0xa7, 0xa0, 0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74, 0x95, 0xc7, 0x95, 0xdc, 0x46, 0x40, 0x05, 0x89, 0x99, 0xbd, + 0xd3, 0xed, 0xcf, 0x67, 0x48, 0x74, 0xde, 0xfb, 0xe4, 0x8f, 0xd7, 0x3d, 0xe3, 0xd5, 0xeb, 0x9e, + 0xf1, 0xf7, 0xeb, 0x9e, 0xf1, 0xcb, 0x9b, 0x5e, 0xe5, 0xd5, 0x9b, 0x5e, 0xe5, 0xaf, 0x37, 0xbd, + 0xca, 0xd7, 0xdd, 0xf9, 0xff, 0x09, 0x38, 0xae, 0x89, 0x5f, 0xb7, 0xff, 0x0d, 0x00, 0x00, 0xff, + 0xff, 0x32, 0xb2, 0xfa, 0x44, 0x2e, 0x10, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3239,6 +3247,13 @@ func (m *StoreKeyInner) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x32 + } if len(m.AclHeadId) > 0 { i -= len(m.AclHeadId) copy(dAtA[i:], m.AclHeadId) @@ -3825,6 +3840,10 @@ func (m *StoreKeyInner) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } return n } @@ -7255,6 +7274,38 @@ func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { } m.AclHeadId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) From 3def39b70219d8ea94f13e73ab72198ba5b6fb60 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 11:45:07 +0200 Subject: [PATCH 16/62] KeyPeerId fixes --- commonspace/object/keyvalue/keyvalue.go | 4 + .../keyvaluestorage/innerstorage/element.go | 10 +- .../innerstorage/keyvaluestorage.go | 11 +- .../keyvalue/keyvaluestorage/storage.go | 35 +++- .../spacesyncproto/protos/spacesync.proto | 2 +- commonspace/spacesyncproto/spacesync.pb.go | 198 +++++++++--------- 6 files changed, 147 insertions(+), 113 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index b7bd9e09..23b6f944 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -9,3 +9,7 @@ type KeyValueService interface { app.ComponentRunnable DefaultStore() innerstorage.KeyValueStorage } + +type keyValueService struct { + +} \ No newline at end of file diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go index 38358852..8fd74004 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -12,6 +12,7 @@ import ( var ErrInvalidSignature = errors.New("invalid signature") type KeyValue struct { + KeyPeerId string Key string Value Value TimestampMilli int @@ -26,7 +27,7 @@ type Value struct { } func KeyValueFromProto(proto *spacesyncproto.StoreKeyValue, verify bool) (kv KeyValue, err error) { - kv.Key = proto.Key + kv.KeyPeerId = proto.KeyPeerId kv.Value.Value = proto.Value kv.Value.PeerSignature = proto.PeerSignature kv.Value.IdentitySignature = proto.IdentitySignature @@ -45,6 +46,8 @@ func KeyValueFromProto(proto *spacesyncproto.StoreKeyValue, verify bool) (kv Key } kv.Identity = identity.Account() kv.PeerId = peerId.PeerId() + kv.Key = innerValue.Key + // TODO: check that key-peerId is equal to key+peerId? if verify { if verify, _ = identity.Verify(proto.Value, proto.IdentitySignature); !verify { return kv, ErrInvalidSignature @@ -66,7 +69,8 @@ func (v Value) AnyEnc(a *anyenc.Arena) *anyenc.Value { func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { obj := a.NewObject() - obj.Set("id", a.NewString(kv.Key)) + obj.Set("id", a.NewString(kv.KeyPeerId)) + obj.Set("k", a.NewString(kv.Key)) obj.Set("v", kv.Value.AnyEnc(a)) obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) obj.Set("i", a.NewString(kv.Identity)) @@ -76,7 +80,7 @@ func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { func (kv KeyValue) Proto() *spacesyncproto.StoreKeyValue { return &spacesyncproto.StoreKeyValue{ - Key: kv.Key, + KeyPeerId: kv.KeyPeerId, Value: kv.Value.Value, PeerSignature: kv.Value.PeerSignature, IdentitySignature: kv.Value.IdentitySignature, diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index db32316d..1b62b904 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -22,7 +22,7 @@ var ( type KeyValueStorage interface { Set(ctx context.Context, keyValues ...KeyValue) (err error) Diff() ldiff.CompareDiff - Get(ctx context.Context, key string) (keyValue KeyValue, err error) + GetKeyPeerId(ctx context.Context, keyPeerId string) (keyValue KeyValue, err error) IterateValues(context.Context, func(kv KeyValue) (bool, error)) (err error) IteratePrefix(context.Context, string, func(kv KeyValue) error) (err error) } @@ -86,8 +86,8 @@ func (s *storage) Diff() ldiff.CompareDiff { return s.diff } -func (s *storage) Get(ctx context.Context, key string) (value KeyValue, err error) { - doc, err := s.collection.FindId(ctx, key) +func (s *storage) GetKeyPeerId(ctx context.Context, keyPeerId string) (value KeyValue, err error) { + doc, err := s.collection.FindId(ctx, keyPeerId) if err != nil { if errors.Is(err, anystore.ErrDocNotFound) { return KeyValue{}, nil @@ -155,11 +155,12 @@ func (s *storage) keyValueFromDoc(doc anystore.Doc) KeyValue { IdentitySignature: valueObj.Get("i").GetBytes(), } return KeyValue{ - Key: doc.Value().GetString("id"), + KeyPeerId: doc.Value().GetString("id"), Value: value, TimestampMilli: doc.Value().GetInt("t"), Identity: doc.Value().GetString("i"), PeerId: doc.Value().GetString("p"), + Key: doc.Value().GetString("k"), } } @@ -214,7 +215,7 @@ func (s *storage) updateValues(ctx context.Context, values ...KeyValue) (element elements = make([]ldiff.Element, 0, len(values)) var doc anystore.Doc for _, value := range values { - doc, err = s.collection.FindIdWithParser(ctx, parser, value.Key) + doc, err = s.collection.FindIdWithParser(ctx, parser, value.KeyPeerId) isNotFound := errors.Is(err, anystore.ErrDocNotFound) if err != nil && !isNotFound { return diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 3e022ce7..852f7718 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -5,9 +5,11 @@ import ( "sync" "time" + anystore "github.com/anyproto/any-store" "go.uber.org/zap" "github.com/anyproto/any-sync/app/logger" + "github.com/anyproto/any-sync/commonspace/headsync/headstorage" "github.com/anyproto/any-sync/commonspace/object/accountdata" "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" @@ -35,6 +37,27 @@ type storage struct { mx sync.Mutex } +func New( + storageName string, + ctx context.Context, + store anystore.DB, + headStorage headstorage.HeadStorage, + keys *accountdata.AccountKeys, + aclList list.AclList, + indexer Indexer, +) (Storage, error) { + inner, err := innerstorage.New(ctx, storageName, headStorage, store) + if err != nil { + return nil, err + } + return &storage{ + inner: inner, + keys: keys, + aclList: aclList, + indexer: indexer, + }, nil +} + func (s *storage) Set(ctx context.Context, key string, value []byte) error { s.mx.Lock() defer s.mx.Unlock() @@ -76,16 +99,18 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { if err != nil { return err } + keyPeerId := key + "-" + peerIdKey.GetPublic().PeerId() keyValue := innerstorage.KeyValue{ - Key: key, + KeyPeerId: keyPeerId, + Key: key, + TimestampMilli: int(timestampMilli), + Identity: identityKey.GetPublic().Account(), + PeerId: peerIdKey.GetPublic().PeerId(), Value: innerstorage.Value{ Value: value, PeerSignature: peerSig, IdentitySignature: identitySig, }, - TimestampMilli: int(timestampMilli), - Identity: identityKey.GetPublic().Account(), - PeerId: peerIdKey.GetPublic().PeerId(), } err = s.inner.Set(ctx, keyValue) if err != nil { @@ -115,7 +140,7 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK } indexErr := s.indexer.Index(keyValues...) if indexErr != nil { - log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) + log.Warn("failed to index for keys", zap.Error(indexErr)) } return nil } diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index b6576d3b..a2cefd31 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -209,7 +209,7 @@ message StoreDiffResponse { } message StoreKeyValue { - string key = 1; + string keyPeerId = 1; bytes value = 2; bytes identitySignature = 3; bytes peerSignature = 4; diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 5eb5f394..7bb53b43 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1788,7 +1788,7 @@ func (m *StoreDiffResponse) GetResults() []*HeadSyncResult { } type StoreKeyValue struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + KeyPeerId string `protobuf:"bytes,1,opt,name=keyPeerId,proto3" json:"keyPeerId,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` IdentitySignature []byte `protobuf:"bytes,3,opt,name=identitySignature,proto3" json:"identitySignature,omitempty"` PeerSignature []byte `protobuf:"bytes,4,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"` @@ -1835,9 +1835,9 @@ func (m *StoreKeyValue) XXX_DiscardUnknown() { var xxx_messageInfo_StoreKeyValue proto.InternalMessageInfo -func (m *StoreKeyValue) GetKey() string { +func (m *StoreKeyValue) GetKeyPeerId() string { if m != nil { - return m.Key + return m.KeyPeerId } return "" } @@ -1994,99 +1994,99 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1465 bytes of a gzipped FileDescriptorProto + // 1471 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x18, 0x4d, 0x6f, 0x1b, 0x45, 0xd4, 0xbb, 0x4e, 0x1c, 0xfb, 0xc5, 0x71, 0x37, 0x13, 0xb7, 0x31, 0x6e, 0xe5, 0x5a, 0x2b, 0x54, 0xa2, 0x0a, 0xb5, 0x4d, 0x8a, 0x90, 0x5a, 0xe0, 0x90, 0x26, 0x69, 0x63, 0x4a, 0x9a, 0x68, 0xdc, 0x0f, 0x09, 0x89, 0xc3, 0x66, 0x77, 0x92, 0x2c, 0x5d, 0xef, 0x9a, 0x9d, 0x71, 0x1b, 0x1f, 0x39, - 0x71, 0x40, 0x20, 0xce, 0xf0, 0x1b, 0xf8, 0x1f, 0x1c, 0xcb, 0x8d, 0x23, 0x6a, 0xef, 0xfc, 0x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, 0xfb, 0x67, 0x03, 0x2e, 0x64, 0xd2, 0xdf, 0x4d, 0x08, - 0x65, 0xa8, 0x03, 0x4b, 0xc2, 0xa7, 0x41, 0x2a, 0x9c, 0x82, 0xe8, 0x16, 0xd4, 0x62, 0x9e, 0xc3, - 0xd4, 0xf9, 0x4e, 0x99, 0xf3, 0x9c, 0x01, 0x4b, 0x3e, 0x74, 0x13, 0xea, 0x9e, 0x7f, 0x72, 0xf2, - 0x78, 0x3a, 0x26, 0xc2, 0xeb, 0xd6, 0xd6, 0x9a, 0x26, 0xb3, 0x2b, 0x49, 0x58, 0x31, 0xd9, 0xe7, - 0x60, 0x69, 0xd1, 0x8c, 0xa3, 0x90, 0x12, 0x74, 0x1b, 0x96, 0x62, 0x11, 0x19, 0xed, 0x18, 0xc2, - 0xee, 0x07, 0x73, 0x93, 0x86, 0x53, 0xce, 0x9c, 0x65, 0xf3, 0x5d, 0x2c, 0xff, 0x66, 0xc0, 0xea, - 0xe1, 0xf1, 0xb7, 0xc4, 0x65, 0x5c, 0xdd, 0x01, 0xa1, 0xd4, 0x39, 0x25, 0x6f, 0x49, 0xc6, 0x15, - 0x68, 0xc4, 0x49, 0xc6, 0x06, 0x69, 0x4e, 0x33, 0x04, 0x97, 0x8b, 0xc9, 0x38, 0x98, 0x0e, 0x3c, - 0x11, 0x77, 0x03, 0xa7, 0x20, 0xa7, 0x8c, 0x9d, 0x69, 0x10, 0x39, 0x9e, 0x68, 0xa2, 0x26, 0x4e, - 0x41, 0xde, 0x5f, 0x91, 0x70, 0x60, 0xe0, 0x75, 0x16, 0x85, 0x90, 0x82, 0x6d, 0x02, 0xd6, 0x90, - 0x1b, 0x3e, 0x9a, 0xd0, 0xb3, 0xb4, 0x50, 0x9b, 0x99, 0x26, 0xee, 0xdb, 0xf2, 0xd6, 0xba, 0x16, - 0x61, 0xc2, 0x9d, 0x90, 0x33, 0x13, 0x3d, 0x80, 0x9d, 0x98, 0x78, 0x24, 0x64, 0xbe, 0x13, 0x08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, 0x7b, 0x9f, 0xfc, 0xf1, + 0xba, 0x67, 0xbc, 0x7a, 0xdd, 0x33, 0xfe, 0x7e, 0xdd, 0x33, 0x7e, 0x7e, 0xd3, 0xab, 0xbc, 0x7a, + 0xd3, 0xab, 0xfc, 0xf5, 0xa6, 0x57, 0xf9, 0xba, 0x3b, 0xff, 0xbf, 0x02, 0xc7, 0x35, 0xf1, 0xeb, + 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x65, 0xb1, 0x1e, 0x5b, 0x3a, 0x10, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3217,10 +3217,10 @@ func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Key))) + if len(m.KeyPeerId) > 0 { + i -= len(m.KeyPeerId) + copy(dAtA[i:], m.KeyPeerId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.KeyPeerId))) i-- dAtA[i] = 0xa } @@ -3796,7 +3796,7 @@ func (m *StoreKeyValue) Size() (n int) { } var l int _ = l - l = len(m.Key) + l = len(m.KeyPeerId) if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } @@ -6939,7 +6939,7 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field KeyPeerId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6967,7 +6967,7 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Key = string(dAtA[iNdEx:postIndex]) + m.KeyPeerId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { From fb2404dde8607b978f09c0fdea96ab97763a056d Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 15:00:17 +0200 Subject: [PATCH 17/62] Implement sync client send logic --- commonspace/object/keyvalue/keyvalue.go | 28 +- .../keyvalue/keyvaluestorage/storage.go | 30 +- .../keyvaluestorage/syncstorage/syncclient.go | 68 ++++ .../spacesyncproto/protos/spacesync.proto | 4 + commonspace/spacesyncproto/spacesync.pb.go | 379 +++++++++++++----- 5 files changed, 405 insertions(+), 104 deletions(-) create mode 100644 commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index 23b6f944..bb45e298 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -1,15 +1,41 @@ package keyvalue import ( + "context" + "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/spacestorage" ) +const CName = "common.object.keyvalue" + type KeyValueService interface { app.ComponentRunnable DefaultStore() innerstorage.KeyValueStorage } type keyValueService struct { + spaceStorage spacestorage.SpaceStorage + defaultStore keyvaluestorage.Storage +} -} \ No newline at end of file +func (k *keyValueService) Init(a *app.App) (err error) { + //TODO implement me + panic("implement me") +} + +func (k *keyValueService) Name() (name string) { + return CName +} + +func (k *keyValueService) Run(ctx context.Context) (err error) { + //TODO implement me + panic("implement me") +} + +func (k *keyValueService) Close(ctx context.Context) (err error) { + //TODO implement me + panic("implement me") +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 852f7718..62e01404 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -13,6 +13,7 @@ import ( "github.com/anyproto/any-sync/commonspace/object/accountdata" "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/syncstorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" ) @@ -30,11 +31,12 @@ type Storage interface { } type storage struct { - inner innerstorage.KeyValueStorage - keys *accountdata.AccountKeys - aclList list.AclList - indexer Indexer - mx sync.Mutex + inner innerstorage.KeyValueStorage + keys *accountdata.AccountKeys + aclList list.AclList + syncClient syncstorage.SyncClient + indexer Indexer + mx sync.Mutex } func New( @@ -43,6 +45,7 @@ func New( store anystore.DB, headStorage headstorage.HeadStorage, keys *accountdata.AccountKeys, + syncClient syncstorage.SyncClient, aclList list.AclList, indexer Indexer, ) (Storage, error) { @@ -51,10 +54,11 @@ func New( return nil, err } return &storage{ - inner: inner, - keys: keys, - aclList: aclList, - indexer: indexer, + inner: inner, + keys: keys, + aclList: aclList, + indexer: indexer, + syncClient: syncClient, }, nil } @@ -120,6 +124,10 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { if indexErr != nil { log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) } + sendErr := s.syncClient.Broadcast(ctx, keyValue) + if sendErr != nil { + log.Warn("failed to send key value", zap.String("key", key), zap.Error(sendErr)) + } return nil } @@ -142,6 +150,10 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK if indexErr != nil { log.Warn("failed to index for keys", zap.Error(indexErr)) } + sendErr := s.syncClient.Broadcast(ctx, keyValues...) + if sendErr != nil { + log.Warn("failed to send key values", zap.Error(sendErr)) + } return nil } diff --git a/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go new file mode 100644 index 00000000..82e09d67 --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go @@ -0,0 +1,68 @@ +package syncstorage + +import ( + "context" + "fmt" + + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" + "github.com/anyproto/any-sync/commonspace/sync" + "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" +) + +type innerUpdate struct { + prepared []byte + keyValues []innerstorage.KeyValue +} + +func (i *innerUpdate) Marshall(data objectmessages.ObjectMeta) ([]byte, error) { + if i.prepared != nil { + return i.prepared, nil + } + return nil, fmt.Errorf("no prepared data") +} + +func (i *innerUpdate) Prepare() error { + // TODO: Add peer to ignored peers list + var ( + protoKeyValues []*spacesyncproto.StoreKeyValue + err error + ) + for _, kv := range i.keyValues { + protoKeyValues = append(protoKeyValues, kv.Proto()) + } + keyValues := &spacesyncproto.StoreKeyValues{KeyValues: protoKeyValues} + i.prepared, err = keyValues.Marshal() + return err +} + +func (i *innerUpdate) Heads() []string { + return nil +} + +func (i *innerUpdate) MsgSize() uint64 { + return uint64(len(i.prepared)) +} + +type SyncClient interface { + Broadcast(ctx context.Context, keyValues ...innerstorage.KeyValue) error +} + +type syncClient struct { + spaceId string + syncService sync.SyncService +} + +func (s *syncClient) Broadcast(ctx context.Context, objectId string, keyValue ...innerstorage.KeyValue) error { + inner := &innerUpdate{ + keyValues: keyValue, + } + headUpdate := &objectmessages.HeadUpdate{ + Meta: objectmessages.ObjectMeta{ + ObjectId: objectId, + SpaceId: s.spaceId, + }, + Update: inner, + } + return s.syncService.BroadcastMessage(ctx, headUpdate) +} diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index a2cefd31..221df8ac 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -215,6 +215,10 @@ message StoreKeyValue { bytes peerSignature = 4; } +message StoreKeyValues { + repeated StoreKeyValue keyValues = 1; +} + message StoreKeyInner { bytes peer = 1; bytes identity = 2; diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 7bb53b43..6f8333e0 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1863,6 +1863,58 @@ func (m *StoreKeyValue) GetPeerSignature() []byte { return nil } +type StoreKeyValues struct { + KeyValues []*StoreKeyValue `protobuf:"bytes,1,rep,name=keyValues,proto3" json:"keyValues,omitempty"` +} + +func (m *StoreKeyValues) Reset() { *m = StoreKeyValues{} } +func (m *StoreKeyValues) String() string { return proto.CompactTextString(m) } +func (*StoreKeyValues) ProtoMessage() {} +func (*StoreKeyValues) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{27} +} +func (m *StoreKeyValues) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreKeyValues) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreKeyValues.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreKeyValues) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreKeyValues) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreKeyValues.Merge(m, src) +} +func (m *StoreKeyValues) XXX_Size() int { + return m.Size() +} +func (m *StoreKeyValues) XXX_DiscardUnknown() { + xxx_messageInfo_StoreKeyValues.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreKeyValues proto.InternalMessageInfo + +func (m *StoreKeyValues) GetKeyValues() []*StoreKeyValue { + if m != nil { + return m.KeyValues + } + return nil +} + type StoreKeyInner struct { Peer []byte `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"` Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` @@ -1876,7 +1928,7 @@ func (m *StoreKeyInner) Reset() { *m = StoreKeyInner{} } func (m *StoreKeyInner) String() string { return proto.CompactTextString(m) } func (*StoreKeyInner) ProtoMessage() {} func (*StoreKeyInner) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{27} + return fileDescriptor_80e49f1f4ac27799, []int{28} } func (m *StoreKeyInner) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1986,6 +2038,7 @@ func init() { proto.RegisterType((*StoreDiffRequest)(nil), "spacesync.StoreDiffRequest") proto.RegisterType((*StoreDiffResponse)(nil), "spacesync.StoreDiffResponse") proto.RegisterType((*StoreKeyValue)(nil), "spacesync.StoreKeyValue") + proto.RegisterType((*StoreKeyValues)(nil), "spacesync.StoreKeyValues") proto.RegisterType((*StoreKeyInner)(nil), "spacesync.StoreKeyInner") } @@ -1994,99 +2047,101 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1471 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x18, 0x4d, 0x6f, 0x1b, 0x45, - 0xd4, 0xbb, 0x4e, 0x1c, 0xfb, 0xc5, 0x71, 0x37, 0x13, 0xb7, 0x31, 0x6e, 0xe5, 0x5a, 0x2b, 0x54, - 0xa2, 0x0a, 0xb5, 0x4d, 0x8a, 0x90, 0x5a, 0xe0, 0x90, 0x26, 0x69, 0x63, 0x4a, 0x9a, 0x68, 0xdc, - 0x0f, 0x09, 0x89, 0xc3, 0x66, 0x77, 0x92, 0x2c, 0x5d, 0xef, 0x9a, 0x9d, 0x71, 0x1b, 0x1f, 0x39, - 0x71, 0x02, 0x71, 0x43, 0x82, 0xdf, 0xc0, 0xff, 0xe0, 0x58, 0x6e, 0x1c, 0x51, 0x7b, 0xe7, 0x37, - 0xa0, 0x99, 0x9d, 0x9d, 0x9d, 0x5d, 0xaf, 0x4b, 0x51, 0x2f, 0xc9, 0xbe, 0xef, 0xcf, 0x79, 0xef, - 0x25, 0xb0, 0xe9, 0x46, 0xa3, 0x51, 0x14, 0xd2, 0xb1, 0xe3, 0x92, 0x9b, 0xe2, 0x27, 0x9d, 0x86, - 0xee, 0x38, 0x8e, 0x58, 0x74, 0x53, 0xfc, 0xa4, 0x19, 0xf6, 0x86, 0x40, 0xa0, 0x86, 0x42, 0xd8, - 0x04, 0x56, 0xf6, 0x89, 0xe3, 0x0d, 0xa7, 0xa1, 0x8b, 0x9d, 0xf0, 0x94, 0x20, 0x04, 0x0b, 0x27, - 0x71, 0x34, 0xea, 0x18, 0x7d, 0x63, 0x63, 0x01, 0x8b, 0x6f, 0xd4, 0x02, 0x93, 0x45, 0x1d, 0x53, - 0x60, 0x4c, 0x16, 0xa1, 0x36, 0x2c, 0x06, 0xfe, 0xc8, 0x67, 0x9d, 0x6a, 0xdf, 0xd8, 0x58, 0xc1, - 0x09, 0x80, 0xba, 0x50, 0x27, 0x01, 0x19, 0x91, 0x90, 0xd1, 0xce, 0x42, 0xdf, 0xd8, 0xa8, 0x63, - 0x05, 0xdb, 0xe7, 0xd0, 0x52, 0x66, 0x08, 0x9d, 0x04, 0x8c, 0xdb, 0x39, 0x73, 0xe8, 0x99, 0xb0, - 0xd3, 0xc4, 0xe2, 0x1b, 0x7d, 0xae, 0x69, 0x30, 0xfb, 0xd5, 0x8d, 0xe5, 0xad, 0xfe, 0x8d, 0xcc, - 0xf7, 0xbc, 0x82, 0xbd, 0x84, 0x31, 0xb3, 0xc1, 0xbd, 0x72, 0xa3, 0x49, 0xa8, 0xbc, 0x12, 0x80, - 0xfd, 0x19, 0x5c, 0x2c, 0x15, 0xe4, 0x41, 0xf9, 0x9e, 0x30, 0xdf, 0xc0, 0xa6, 0xef, 0x09, 0x87, - 0x88, 0xe3, 0x89, 0x30, 0x1b, 0x58, 0x7c, 0xdb, 0x3f, 0x19, 0x70, 0x21, 0x93, 0xfe, 0x6e, 0x42, - 0x28, 0x43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aa, 0x88, 0x71, 0x1f, 0x20, 0x23, 0xbc, 0x8f, - 0x36, 0xf4, 0x0c, 0xd6, 0x33, 0xa4, 0x0c, 0xe8, 0xfd, 0x9d, 0xbc, 0x65, 0xa0, 0x43, 0x68, 0xea, - 0x6b, 0x06, 0xf5, 0x34, 0xfe, 0x92, 0x55, 0xd6, 0xbd, 0x3a, 0x97, 0xae, 0xf2, 0xb8, 0x92, 0xdb, - 0x0e, 0xa8, 0x20, 0x31, 0xb3, 0x83, 0xba, 0xfd, 0xf9, 0x0c, 0x89, 0xce, 0x7b, 0x9f, 0xfc, 0xf1, - 0xba, 0x67, 0xbc, 0x7a, 0xdd, 0x33, 0xfe, 0x7e, 0xdd, 0x33, 0x7e, 0x7e, 0xd3, 0xab, 0xbc, 0x7a, - 0xd3, 0xab, 0xfc, 0xf5, 0xa6, 0x57, 0xf9, 0xba, 0x3b, 0xff, 0xbf, 0x02, 0xc7, 0x35, 0xf1, 0xeb, - 0xf6, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x65, 0xb1, 0x1e, 0x5b, 0x3a, 0x10, 0x00, 0x00, + // 1491 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x18, 0x4b, 0x6f, 0x13, 0xc7, + 0x3f, 0xbb, 0xce, 0xc3, 0xfe, 0xc5, 0x31, 0x9b, 0x89, 0x21, 0xfe, 0x1b, 0x64, 0xac, 0xd1, 0x5f, + 0x34, 0x42, 0x15, 0x90, 0x50, 0x21, 0x41, 0xdb, 0x43, 0x48, 0x02, 0x71, 0x69, 0x48, 0x34, 0xe6, + 0x21, 0x55, 0xea, 0x61, 0xb3, 0x3b, 0x49, 0xb6, 0xac, 0x77, 0xdd, 0x9d, 0x31, 0xc4, 0xc7, 0x9e, + 0x7a, 0x6a, 0xd5, 0x5b, 0xa5, 0xf6, 0x33, 0xf4, 0x7b, 0xf4, 0x48, 0x6f, 0x3d, 0x56, 0x70, 0xef, + 0x67, 0xa8, 0x66, 0x76, 0x76, 0x76, 0xd6, 0x5e, 0x53, 0x2a, 0x2e, 0x64, 0x7f, 0xef, 0xc7, 0xfc, + 0x5e, 0x06, 0x36, 0xbd, 0x78, 0x30, 0x88, 0x23, 0x36, 0x74, 0x3d, 0x7a, 0x53, 0xfe, 0xcb, 0xc6, + 0x91, 0x37, 0x4c, 0x62, 0x1e, 0xdf, 0x94, 0xff, 0xb2, 0x1c, 0x7b, 0x43, 0x22, 0x50, 0x4d, 0x23, + 0x30, 0x85, 0x95, 0x7d, 0xea, 0xfa, 0xfd, 0x71, 0xe4, 0x11, 0x37, 0x3a, 0xa5, 0x08, 0xc1, 0xfc, + 0x49, 0x12, 0x0f, 0x5a, 0x56, 0xd7, 0xda, 0x98, 0x27, 0xf2, 0x1b, 0x35, 0xc0, 0xe6, 0x71, 0xcb, + 0x96, 0x18, 0x9b, 0xc7, 0xa8, 0x09, 0x0b, 0x61, 0x30, 0x08, 0x78, 0xab, 0xd2, 0xb5, 0x36, 0x56, + 0x48, 0x0a, 0xa0, 0x36, 0x54, 0x69, 0x48, 0x07, 0x34, 0xe2, 0xac, 0x35, 0xdf, 0xb5, 0x36, 0xaa, + 0x44, 0xc3, 0xf8, 0x1c, 0x1a, 0xda, 0x0c, 0x65, 0xa3, 0x90, 0x0b, 0x3b, 0x67, 0x2e, 0x3b, 0x93, + 0x76, 0xea, 0x44, 0x7e, 0xa3, 0xcf, 0x0c, 0x0d, 0x76, 0xb7, 0xb2, 0xb1, 0xbc, 0xd5, 0xbd, 0x91, + 0xfb, 0x5e, 0x54, 0xb0, 0x97, 0x32, 0xe6, 0x36, 0x84, 0x57, 0x5e, 0x3c, 0x8a, 0xb4, 0x57, 0x12, + 0xc0, 0x9f, 0xc2, 0xc5, 0x52, 0x41, 0x11, 0x54, 0xe0, 0x4b, 0xf3, 0x35, 0x62, 0x07, 0xbe, 0x74, + 0x88, 0xba, 0xbe, 0x0c, 0x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1a, 0xf1, 0xc0, 0x0d, + 0xa5, 0xd7, 0x75, 0x62, 0x60, 0xf0, 0x1a, 0xac, 0x1a, 0x66, 0xd2, 0xfc, 0x63, 0xac, 0x6d, 0x87, + 0x61, 0x66, 0x7b, 0xa2, 0xb8, 0xf0, 0x03, 0x2d, 0x28, 0x78, 0xd4, 0xc3, 0xfd, 0x77, 0x07, 0xf1, + 0x77, 0x36, 0xd4, 0x4d, 0x0a, 0xda, 0x86, 0x65, 0x29, 0x23, 0xde, 0x99, 0x26, 0x4a, 0xcf, 0x55, + 0x43, 0x0f, 0x71, 0x5f, 0xf5, 0x73, 0x86, 0xe7, 0x01, 0x3f, 0xeb, 0xf9, 0xc4, 0x94, 0x11, 0x41, + 0xbb, 0x5e, 0xa8, 0x14, 0x66, 0x41, 0xe7, 0x18, 0x84, 0xa1, 0x9e, 0x43, 0xfa, 0xc1, 0x0a, 0x38, + 0xb4, 0x05, 0x4d, 0xa9, 0xb2, 0x4f, 0x39, 0x0f, 0xa2, 0x53, 0x76, 0x54, 0x78, 0xc2, 0x52, 0x1a, + 0xba, 0x03, 0x97, 0xca, 0xf0, 0xfa, 0x75, 0x67, 0x50, 0xf1, 0x1f, 0x16, 0x2c, 0x1b, 0x21, 0x89, + 0xba, 0x08, 0xe4, 0x03, 0xf1, 0xb1, 0x9a, 0x26, 0x1a, 0x16, 0x55, 0xc8, 0x83, 0x01, 0x65, 0xdc, + 0x1d, 0x0c, 0x65, 0x68, 0x15, 0x92, 0x23, 0x04, 0x55, 0xda, 0xd0, 0xfd, 0x57, 0x23, 0x39, 0x02, + 0x5d, 0x83, 0x86, 0x28, 0xca, 0xc0, 0x73, 0x79, 0x10, 0x47, 0x8f, 0xe8, 0x58, 0x46, 0x33, 0x4f, + 0x26, 0xb0, 0x62, 0x70, 0x30, 0x4a, 0x53, 0xaf, 0xeb, 0x44, 0x7e, 0xa3, 0x1b, 0x80, 0x8c, 0x14, + 0x67, 0xd9, 0x58, 0x94, 0x1c, 0x25, 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0x60, 0x77, 0x96, 0x6c, 0x16, + 0x05, 0xd1, 0x12, 0xf8, 0x85, 0x1a, 0x49, 0xfd, 0xd1, 0x31, 0xf3, 0x92, 0x60, 0x28, 0xca, 0x59, + 0xf4, 0x92, 0x1a, 0xe0, 0x59, 0x88, 0x1a, 0x46, 0xf7, 0x60, 0xd1, 0xf5, 0x04, 0x97, 0x5a, 0x18, + 0x78, 0xca, 0x98, 0xa1, 0x69, 0x5b, 0x72, 0x12, 0x25, 0x81, 0x7b, 0xb0, 0xb6, 0xed, 0x85, 0xdb, + 0xbe, 0x4f, 0xa8, 0x17, 0x27, 0xfe, 0xbf, 0xef, 0x52, 0x63, 0x0d, 0xd8, 0x85, 0x35, 0x80, 0xbf, + 0x84, 0x66, 0x51, 0x95, 0x9a, 0xa6, 0x6d, 0xa8, 0x26, 0x12, 0xa3, 0x95, 0x69, 0xf8, 0x1d, 0xda, + 0xbe, 0x90, 0xda, 0x1e, 0x52, 0x9e, 0x6a, 0x63, 0xef, 0xe5, 0x99, 0xeb, 0x85, 0xfb, 0xf9, 0xa9, + 0x90, 0x81, 0x78, 0x13, 0x2e, 0x4e, 0xe8, 0x52, 0xae, 0xc9, 0x6d, 0x27, 0x51, 0x32, 0xa9, 0x75, + 0x92, 0x81, 0x78, 0x17, 0x9c, 0x3e, 0x8f, 0x13, 0x2a, 0x16, 0x6e, 0x66, 0x3a, 0x3f, 0x23, 0x2a, + 0xef, 0x77, 0x46, 0xe0, 0x7d, 0x58, 0x35, 0xb4, 0x7c, 0xc0, 0x59, 0x80, 0x7f, 0xb6, 0x60, 0x45, + 0xaa, 0x7a, 0x44, 0xc7, 0xcf, 0x44, 0x93, 0x89, 0x79, 0xf1, 0x82, 0x8e, 0x0b, 0x1d, 0x93, 0x23, + 0xc4, 0xcd, 0x25, 0x7b, 0x51, 0xa5, 0x35, 0x05, 0xd0, 0xc7, 0xb0, 0x9a, 0x4d, 0xe0, 0xbe, 0x9e, + 0x50, 0x15, 0xc9, 0x31, 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 0x9f, 0xbd, 0x65, 0x7a, 0x8c, 0x7b, 0x97, 0x80, 0x93, 0xff, 0x82, 0xe8, 0xf3, 0x84, + 0xba, 0x03, 0x74, 0x65, 0xea, 0x62, 0x30, 0x7e, 0x5e, 0xb4, 0xdf, 0x49, 0x95, 0x31, 0xee, 0x03, + 0xe4, 0x84, 0x0f, 0xd1, 0x86, 0x9e, 0xc3, 0x7a, 0x8e, 0x54, 0x01, 0x7d, 0xb8, 0x93, 0xb7, 0x2c, + 0x74, 0x08, 0x75, 0x73, 0x61, 0xa1, 0x8e, 0xc1, 0x5f, 0xb2, 0x14, 0xdb, 0x57, 0x67, 0xd2, 0x75, + 0x1e, 0x57, 0x0a, 0x7b, 0x06, 0x4d, 0x48, 0x4c, 0x6d, 0xb3, 0x76, 0x77, 0x36, 0x43, 0xaa, 0xf3, + 0xfe, 0x27, 0xbf, 0xbf, 0xe9, 0x58, 0xaf, 0xdf, 0x74, 0xac, 0xbf, 0xde, 0x74, 0xac, 0x9f, 0xde, + 0x76, 0xe6, 0x5e, 0xbf, 0xed, 0xcc, 0xfd, 0xf9, 0xb6, 0x33, 0xf7, 0x55, 0x7b, 0xf6, 0xff, 0x2f, + 0x1c, 0x2f, 0xca, 0x3f, 0xb7, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xe0, 0xc2, 0x45, 0xba, 0x84, + 0x10, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3227,6 +3282,43 @@ func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StoreKeyValues) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreKeyValues) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreKeyValues) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.KeyValues) > 0 { + for iNdEx := len(m.KeyValues) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.KeyValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *StoreKeyInner) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3815,6 +3907,21 @@ func (m *StoreKeyValue) Size() (n int) { return n } +func (m *StoreKeyValues) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.KeyValues) > 0 { + for _, e := range m.KeyValues { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + func (m *StoreKeyInner) Size() (n int) { if m == nil { return 0 @@ -7092,6 +7199,90 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { } return nil } +func (m *StoreKeyValues) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreKeyValues: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreKeyValues: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyValues", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyValues = append(m.KeyValues, &StoreKeyValue{}) + if err := m.KeyValues[len(m.KeyValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From fe5dced9194fe66439f52796df48969aad62d5d9 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 20:25:08 +0200 Subject: [PATCH 18/62] WIP key value service, client diff logic --- commonspace/object/keyvalue/keyvalue.go | 141 ++++- .../keyvalue/keyvaluestorage/storage.go | 21 +- .../keyvaluestorage/syncstorage/syncclient.go | 9 +- commonspace/object/keyvalue/remotediff.go | 106 ++++ .../spacesyncproto/protos/spacesync.proto | 8 +- commonspace/spacesyncproto/spacesync.pb.go | 483 ++++++++++++++---- 6 files changed, 651 insertions(+), 117 deletions(-) create mode 100644 commonspace/object/keyvalue/remotediff.go diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index bb45e298..570a8e4b 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -2,28 +2,146 @@ package keyvalue import ( "context" + "errors" + "io" + "github.com/anyproto/protobuf/proto" + "storj.io/drpc" + + "github.com/anyproto/any-sync/accountservice" "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/commonspace/object/acl/list" + "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" - "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/syncstorage" + "github.com/anyproto/any-sync/commonspace/spacestate" "github.com/anyproto/any-sync/commonspace/spacestorage" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" + "github.com/anyproto/any-sync/commonspace/sync" + "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" + "github.com/anyproto/any-sync/net/peer" + "github.com/anyproto/any-sync/net/rpc/rpcerr" ) +var ErrUnexpectedMessageType = errors.New("unexpected message type") + const CName = "common.object.keyvalue" type KeyValueService interface { app.ComponentRunnable - DefaultStore() innerstorage.KeyValueStorage + DefaultStore() keyvaluestorage.Storage + HandleMessage(ctx context.Context, msg objectmessages.HeadUpdate) (err error) } type keyValueService struct { - spaceStorage spacestorage.SpaceStorage - defaultStore keyvaluestorage.Storage + storageId string + spaceId string + ctx context.Context + cancel context.CancelFunc + + spaceStorage spacestorage.SpaceStorage + defaultStore keyvaluestorage.Storage + clientFactory spacesyncproto.ClientFactory + syncService sync.SyncService +} + +func (k *keyValueService) DefaultStore() keyvaluestorage.Storage { + return k.defaultStore +} + +func (k *keyValueService) SyncWithPeer(ctx context.Context, p peer.Peer) (err error) { + if k.syncService == nil { + return nil + } + conn, err := p.AcquireDrpcConn(ctx) + if err != nil { + return + } + defer p.ReleaseDrpcConn(conn) + var ( + client = k.clientFactory.Client(conn) + rdiff = NewRemoteDiff(k.spaceId, client) + diff = k.defaultStore.InnerStorage().Diff() + ) + newIds, changedIds, theirChangedIds, removedIds, err := diff.CompareDiff(ctx, rdiff) + err = rpcerr.Unwrap(err) + if err != nil { + return err + } + innerStorage := k.defaultStore.InnerStorage() + stream, err := client.StoreElements(ctx) + if err != nil { + return err + } + defer stream.CloseSend() + for _, id := range append(newIds, changedIds...) { + kv, err := innerStorage.GetKeyPeerId(ctx, id) + if err != nil { + return err + } + err = stream.Send(kv.Proto()) + if err != nil { + return err + } + } + for _, id := range append(theirChangedIds, removedIds...) { + kv := &spacesyncproto.StoreKeyValue{ + KeyPeerId: id, + } + err := stream.Send(kv) + if err != nil { + return err + } + } + var messages []*spacesyncproto.StoreKeyValue + for { + msg, err := stream.Recv() + if err != nil { + if errors.Is(err, io.EOF) { + break + } + return err + } + messages = append(messages, msg) + } + return k.defaultStore.SetRaw(ctx, messages...) +} + +func (k *keyValueService) HandleMessage(ctx context.Context, headUpdate drpc.Message) (err error) { + update, ok := headUpdate.(*objectmessages.HeadUpdate) + if !ok { + return ErrUnexpectedMessageType + } + keyValueMsg := &spacesyncproto.StoreKeyValues{} + err = proto.Unmarshal(update.Bytes, keyValueMsg) + if err != nil { + objectmessages.FreeHeadUpdate(update) + return err + } + objectmessages.FreeHeadUpdate(update) + return k.defaultStore.SetRaw(ctx, keyValueMsg.KeyValues...) } func (k *keyValueService) Init(a *app.App) (err error) { - //TODO implement me - panic("implement me") + k.ctx, k.cancel = context.WithCancel(context.Background()) + spaceState := a.MustComponent(spacestate.CName).(*spacestate.SpaceState) + k.spaceId = spaceState.SpaceId + accountService := a.MustComponent(accountservice.CName).(accountservice.Service) + aclList := a.MustComponent(syncacl.CName).(list.AclList) + k.spaceStorage = a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) + k.syncService = a.MustComponent(sync.CName).(sync.SyncService) + k.storageId = storageIdFromSpace(k.spaceId) + syncClient := syncstorage.New(spaceState.SpaceId, k.syncService) + k.defaultStore, err = keyvaluestorage.New( + k.ctx, + k.storageId, + k.spaceStorage.AnyStore(), + k.spaceStorage.HeadStorage(), + accountService.Account(), + syncClient, + aclList, + keyvaluestorage.NoOpIndexer{}) + return } func (k *keyValueService) Name() (name string) { @@ -31,11 +149,14 @@ func (k *keyValueService) Name() (name string) { } func (k *keyValueService) Run(ctx context.Context) (err error) { - //TODO implement me - panic("implement me") + return nil } func (k *keyValueService) Close(ctx context.Context) (err error) { - //TODO implement me - panic("implement me") + k.cancel() + return nil +} + +func storageIdFromSpace(spaceId string) (storageId string) { + return spaceId + ".keyvalue" } diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 62e01404..3167b68f 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -23,7 +23,14 @@ type Indexer interface { Index(keyValue ...innerstorage.KeyValue) error } +type NoOpIndexer struct{} + +func (n NoOpIndexer) Index(keyValue ...innerstorage.KeyValue) error { + return nil +} + type Storage interface { + Id() string Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) @@ -36,12 +43,13 @@ type storage struct { aclList list.AclList syncClient syncstorage.SyncClient indexer Indexer + storageId string mx sync.Mutex } func New( - storageName string, ctx context.Context, + storageId string, store anystore.DB, headStorage headstorage.HeadStorage, keys *accountdata.AccountKeys, @@ -49,19 +57,24 @@ func New( aclList list.AclList, indexer Indexer, ) (Storage, error) { - inner, err := innerstorage.New(ctx, storageName, headStorage, store) + inner, err := innerstorage.New(ctx, storageId, headStorage, store) if err != nil { return nil, err } return &storage{ inner: inner, keys: keys, + storageId: storageId, aclList: aclList, indexer: indexer, syncClient: syncClient, }, nil } +func (s *storage) Id() string { + return s.storageId +} + func (s *storage) Set(ctx context.Context, key string, value []byte) error { s.mx.Lock() defer s.mx.Unlock() @@ -124,7 +137,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { if indexErr != nil { log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) } - sendErr := s.syncClient.Broadcast(ctx, keyValue) + sendErr := s.syncClient.Broadcast(ctx, s.storageId, keyValue) if sendErr != nil { log.Warn("failed to send key value", zap.String("key", key), zap.Error(sendErr)) } @@ -150,7 +163,7 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK if indexErr != nil { log.Warn("failed to index for keys", zap.Error(indexErr)) } - sendErr := s.syncClient.Broadcast(ctx, keyValues...) + sendErr := s.syncClient.Broadcast(ctx, s.storageId, keyValues...) if sendErr != nil { log.Warn("failed to send key values", zap.Error(sendErr)) } diff --git a/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go index c0400d3a..50f6ed74 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go +++ b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go @@ -49,7 +49,7 @@ func (i *innerUpdate) ObjectType() spacesyncproto.ObjectType { } type SyncClient interface { - Broadcast(ctx context.Context, keyValues ...innerstorage.KeyValue) error + Broadcast(ctx context.Context, objectId string, keyValues ...innerstorage.KeyValue) error } type syncClient struct { @@ -57,6 +57,13 @@ type syncClient struct { syncService sync.SyncService } +func New(spaceId string, syncService sync.SyncService) SyncClient { + return &syncClient{ + spaceId: spaceId, + syncService: syncService, + } +} + func (s *syncClient) Broadcast(ctx context.Context, objectId string, keyValue ...innerstorage.KeyValue) error { inner := &innerUpdate{ keyValues: keyValue, diff --git a/commonspace/object/keyvalue/remotediff.go b/commonspace/object/keyvalue/remotediff.go new file mode 100644 index 00000000..c0b82e10 --- /dev/null +++ b/commonspace/object/keyvalue/remotediff.go @@ -0,0 +1,106 @@ +package keyvalue + +import ( + "context" + + "github.com/anyproto/any-sync/app/ldiff" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" +) + +type Client interface { + StoreDiff(context.Context, *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) +} + +type RemoteDiff interface { + ldiff.Remote +} + +func NewRemoteDiff(spaceId string, client Client) RemoteDiff { + return &remote{ + spaceId: spaceId, + client: client, + } +} + +type remote struct { + spaceId string + client Client +} + +func (r *remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff.RangeResult) (results []ldiff.RangeResult, err error) { + results = resBuf[:0] + pbRanges := make([]*spacesyncproto.HeadSyncRange, 0, len(ranges)) + for _, rg := range ranges { + pbRanges = append(pbRanges, &spacesyncproto.HeadSyncRange{ + From: rg.From, + To: rg.To, + Elements: rg.Elements, + Limit: uint32(rg.Limit), + }) + } + req := &spacesyncproto.StoreDiffRequest{ + SpaceId: r.spaceId, + Ranges: pbRanges, + } + resp, err := r.client.StoreDiff(ctx, req) + if err != nil { + return + } + for _, rr := range resp.Results { + var elms []ldiff.Element + if len(rr.Elements) > 0 { + elms = make([]ldiff.Element, 0, len(rr.Elements)) + } + for _, e := range rr.Elements { + elms = append(elms, ldiff.Element{ + Id: e.Id, + Head: e.Head, + }) + } + results = append(results, ldiff.RangeResult{ + Hash: rr.Hash, + Elements: elms, + Count: int(rr.Count), + }) + } + return +} + +func HandleRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesyncproto.StoreDiffRequest) (resp *spacesyncproto.StoreDiffResponse, err error) { + ranges := make([]ldiff.Range, 0, len(req.Ranges)) + // basically we gather data applicable for both diffs + for _, reqRange := range req.Ranges { + ranges = append(ranges, ldiff.Range{ + From: reqRange.From, + To: reqRange.To, + Limit: int(reqRange.Limit), + Elements: reqRange.Elements, + }) + } + res, err := d.Ranges(ctx, ranges, nil) + if err != nil { + return + } + + resp = &spacesyncproto.StoreDiffResponse{ + Results: make([]*spacesyncproto.HeadSyncResult, 0, len(res)), + } + for _, rangeRes := range res { + var elements []*spacesyncproto.HeadSyncResultElement + if len(rangeRes.Elements) > 0 { + elements = make([]*spacesyncproto.HeadSyncResultElement, 0, len(rangeRes.Elements)) + for _, el := range rangeRes.Elements { + elements = append(elements, &spacesyncproto.HeadSyncResultElement{ + Id: el.Id, + Head: el.Head, + }) + } + } + resp.Results = append(resp.Results, &spacesyncproto.HeadSyncResult{ + Hash: rangeRes.Hash, + Elements: elements, + Count: uint32(rangeRes.Count), + }) + } + return +} diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index ba0932c4..a563f013 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -202,7 +202,8 @@ message AclGetRecordsResponse { } message StoreDiffRequest { - repeated HeadSyncRange ranges = 3; + string spaceId = 1; + repeated HeadSyncRange ranges = 2; } message StoreDiffResponse { @@ -229,6 +230,11 @@ message StoreKeyInner { string key = 6; } +message StorageHeader { + string spaceId = 1; + string storageName = 2; +} + // DiffType is a type of diff enum DiffType { Initial = 0; diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 2985b432..b0ed2a85 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1721,7 +1721,8 @@ func (m *AclGetRecordsResponse) GetRecords() [][]byte { } type StoreDiffRequest struct { - Ranges []*HeadSyncRange `protobuf:"bytes,3,rep,name=ranges,proto3" json:"ranges,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Ranges []*HeadSyncRange `protobuf:"bytes,2,rep,name=ranges,proto3" json:"ranges,omitempty"` } func (m *StoreDiffRequest) Reset() { *m = StoreDiffRequest{} } @@ -1765,6 +1766,13 @@ func (m *StoreDiffRequest) XXX_DiscardUnknown() { var xxx_messageInfo_StoreDiffRequest proto.InternalMessageInfo +func (m *StoreDiffRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + func (m *StoreDiffRequest) GetRanges() []*HeadSyncRange { if m != nil { return m.Ranges @@ -2044,6 +2052,66 @@ func (m *StoreKeyInner) GetKey() string { return "" } +type StorageHeader struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + StorageName string `protobuf:"bytes,2,opt,name=storageName,proto3" json:"storageName,omitempty"` +} + +func (m *StorageHeader) Reset() { *m = StorageHeader{} } +func (m *StorageHeader) String() string { return proto.CompactTextString(m) } +func (*StorageHeader) ProtoMessage() {} +func (*StorageHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{29} +} +func (m *StorageHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StorageHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StorageHeader.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StorageHeader) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StorageHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_StorageHeader.Merge(m, src) +} +func (m *StorageHeader) XXX_Size() int { + return m.Size() +} +func (m *StorageHeader) XXX_DiscardUnknown() { + xxx_messageInfo_StorageHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_StorageHeader proto.InternalMessageInfo + +func (m *StorageHeader) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *StorageHeader) GetStorageName() string { + if m != nil { + return m.StorageName + } + return "" +} + func init() { proto.RegisterEnum("spacesync.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("spacesync.SpaceSubscriptionAction", SpaceSubscriptionAction_name, SpaceSubscriptionAction_value) @@ -2078,6 +2146,7 @@ func init() { proto.RegisterType((*StoreKeyValue)(nil), "spacesync.StoreKeyValue") proto.RegisterType((*StoreKeyValues)(nil), "spacesync.StoreKeyValues") proto.RegisterType((*StoreKeyInner)(nil), "spacesync.StoreKeyInner") + proto.RegisterType((*StorageHeader)(nil), "spacesync.StorageHeader") } func init() { @@ -2085,104 +2154,105 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1538 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x18, 0x4b, 0x6f, 0xdb, 0x46, - 0x5a, 0xa4, 0x6c, 0x3d, 0x3e, 0xcb, 0x0a, 0x3d, 0x96, 0x63, 0xad, 0x12, 0x28, 0x02, 0xb1, 0xc8, - 0x1a, 0xc6, 0x6e, 0x12, 0x3b, 0xdb, 0x00, 0x49, 0xdb, 0x83, 0x63, 0x3b, 0xb1, 0x9a, 0x3a, 0x36, - 0x46, 0x79, 0x00, 0x05, 0x7a, 0xa0, 0xc9, 0xb1, 0xcd, 0x86, 0x22, 0x55, 0xce, 0x28, 0xb1, 0x8e, - 0x3d, 0xf5, 0xd4, 0xa2, 0xb7, 0x02, 0xfd, 0x0f, 0xfd, 0x1f, 0x3d, 0xa6, 0x3d, 0xf5, 0x58, 0x24, - 0xf7, 0xfe, 0x86, 0x62, 0x86, 0xc3, 0xe1, 0x50, 0xa2, 0xd2, 0x14, 0xb9, 0xc4, 0xfc, 0xde, 0x8f, - 0xf9, 0x5e, 0x0a, 0x6c, 0xb9, 0xd1, 0x70, 0x18, 0x85, 0x74, 0xe4, 0xb8, 0xe4, 0xa6, 0xf8, 0x97, - 0x4e, 0x42, 0x77, 0x14, 0x47, 0x2c, 0xba, 0x29, 0xfe, 0xa5, 0x19, 0xf6, 0x86, 0x40, 0xa0, 0xba, - 0x42, 0xd8, 0x04, 0x96, 0x0f, 0x88, 0xe3, 0x0d, 0x26, 0xa1, 0x8b, 0x9d, 0xf0, 0x8c, 0x20, 0x04, - 0x0b, 0xa7, 0x71, 0x34, 0x6c, 0x1b, 0x3d, 0x63, 0x63, 0x01, 0x8b, 0x6f, 0xd4, 0x04, 0x93, 0x45, - 0x6d, 0x53, 0x60, 0x4c, 0x16, 0xa1, 0x16, 0x2c, 0x06, 0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 0x80, 0x95, 0xa3, 0x93, 0xaf, 0x88, 0xcb, 0xb8, 0xba, 0x43, 0x42, 0xa9, 0x73, 0x46, 0xde, 0x91, - 0x8c, 0xab, 0x50, 0x8f, 0x93, 0x8c, 0xf5, 0xd3, 0x9c, 0x66, 0x08, 0x2e, 0x17, 0x93, 0x51, 0x30, - 0xe9, 0x7b, 0x22, 0xee, 0x3a, 0x4e, 0x41, 0x4e, 0x19, 0x39, 0x93, 0x20, 0x72, 0x3c, 0x51, 0x44, - 0x0d, 0x9c, 0x82, 0xbc, 0xbe, 0x22, 0xe1, 0x40, 0xdf, 0x6b, 0x2f, 0x0a, 0x21, 0x05, 0xa3, 0x8f, - 0x00, 0x92, 0x6f, 0x11, 0x50, 0x45, 0x04, 0xb4, 0xa6, 0x05, 0x74, 0xa4, 0x88, 0x58, 0x63, 0xb4, - 0x09, 0x58, 0x03, 0xce, 0x73, 0x3c, 0xa6, 0xe7, 0xe9, 0xfb, 0x6e, 0x65, 0x0e, 0xf0, 0x90, 0x96, - 0xb6, 0xd7, 0x35, 0x3d, 0x09, 0x77, 0x42, 0xce, 0x3c, 0xeb, 0x02, 0xec, 0xc6, 0xc4, 0x23, 0x21, - 0xf3, 0x9d, 0x40, 0x04, 0xdb, 0xc0, 0x1a, 0xc6, 0x5e, 0x85, 0x15, 0xcd, 0x4c, 0xf2, 0x6c, 0xb6, - 0xad, 0x6c, 0x07, 0x41, 0x6a, 0x7b, 0xaa, 0x26, 0xed, 0x07, 0x4a, 0x90, 0xf3, 0xc8, 0xf7, 0xfe, - 0xe7, 0x0e, 0xda, 0xdf, 0x98, 0xd0, 0xd0, 0x29, 0x68, 0x07, 0x96, 0x84, 0x0c, 0x2f, 0x0f, 0x12, - 0x4b, 0x3d, 0xd7, 0x34, 0x3d, 0xd8, 0x79, 0x35, 0xc8, 0x18, 0x9e, 0xfb, 0xec, 0xbc, 0xef, 0x61, - 0x5d, 0x86, 0x07, 0xed, 0xb8, 0x81, 0x54, 0x98, 0x06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, 0xe1, 0x4e, 0xde, 0x32, 0xd0, - 0x11, 0x34, 0xf4, 0xfd, 0x86, 0xba, 0x1a, 0x7f, 0xc1, 0x0e, 0xed, 0x5c, 0x9b, 0x4b, 0x57, 0x79, - 0x5c, 0xce, 0xad, 0x25, 0x34, 0x25, 0x31, 0xb3, 0xfc, 0x3a, 0xbd, 0xf9, 0x0c, 0x89, 0xce, 0xfb, - 0xff, 0xff, 0xe5, 0x4d, 0xd7, 0x78, 0xfd, 0xa6, 0x6b, 0xfc, 0xf1, 0xa6, 0x6b, 0xfc, 0xf0, 0xb6, - 0x5b, 0x7a, 0xfd, 0xb6, 0x5b, 0xfa, 0xfd, 0x6d, 0xb7, 0xf4, 0x45, 0x67, 0xfe, 0xff, 0x62, 0x9c, - 0x54, 0xc4, 0x9f, 0xdb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x63, 0xb0, 0xc6, 0x5d, 0xea, 0x10, - 0x00, 0x00, + // 1556 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x4b, 0x6f, 0x1b, 0xc5, + 0x3f, 0xbb, 0x4e, 0x1c, 0xfb, 0x17, 0xc7, 0xdd, 0x4c, 0x92, 0xc6, 0x7f, 0xb7, 0x72, 0xad, 0xd1, + 0x5f, 0x25, 0x8a, 0xa0, 0x6d, 0x52, 0xa8, 0xd4, 0x02, 0x87, 0x34, 0x49, 0x1b, 0x53, 0xd2, 0x44, + 0xe3, 0x3e, 0x24, 0x24, 0x90, 0x36, 0xbb, 0x93, 0x64, 0xe9, 0x7a, 0xd7, 0xec, 0x8c, 0xdb, 0xf8, + 0xc8, 0x89, 0x13, 0x88, 0x1b, 0x12, 0xdf, 0x81, 0xef, 0xc1, 0xb1, 0x70, 0xe2, 0x88, 0xda, 0x3b, + 0x9f, 0x01, 0xcd, 0xec, 0xec, 0xec, 0xac, 0x1f, 0xa5, 0xa8, 0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 0xee, 0x59, 0x0b, 0x60, 0x27, 0xa1, 0x3e, 0x8d, 0x78, + 0xe0, 0x86, 0x32, 0xd8, 0x1a, 0x31, 0x30, 0x78, 0x19, 0x96, 0x0c, 0x33, 0xe9, 0xb5, 0x61, 0xac, + 0x6d, 0x87, 0x61, 0x66, 0x7b, 0xa4, 0x26, 0xf1, 0x3d, 0x2d, 0x28, 0x78, 0xd4, 0x7d, 0xff, 0x7b, + 0x07, 0xf1, 0xb7, 0x36, 0xd4, 0x4c, 0x0a, 0xda, 0x86, 0x05, 0x29, 0x23, 0xca, 0x83, 0x26, 0x4a, + 0xcf, 0x15, 0x43, 0x0f, 0x71, 0x5f, 0x74, 0x73, 0x86, 0xa7, 0x01, 0x3f, 0xeb, 0xf8, 0xc4, 0x94, + 0x11, 0x41, 0xbb, 0x5e, 0xa8, 0x14, 0x66, 0x41, 0xe7, 0x18, 0x84, 0xa1, 0x96, 0x43, 0xfa, 0x9e, + 0x0b, 0x38, 0xb4, 0x05, 0x2b, 0x52, 0x65, 0x97, 0x72, 0x1e, 0x44, 0xa7, 0xec, 0xa8, 0x70, 0xf3, + 0x13, 0x69, 0xe8, 0x16, 0x5c, 0x9c, 0x84, 0xd7, 0x45, 0x31, 0x85, 0x8a, 0x7f, 0xb3, 0x60, 0xc1, + 0x08, 0x49, 0x94, 0x53, 0x20, 0x2f, 0x88, 0x0f, 0xd5, 0x10, 0xd2, 0xb0, 0x28, 0x5e, 0x1e, 0xf4, + 0x28, 0xe3, 0x6e, 0xaf, 0x2f, 0x43, 0x2b, 0x91, 0x1c, 0x21, 0xa8, 0xd2, 0x86, 0x6e, 0xdb, 0x2a, + 0xc9, 0x11, 0xe8, 0x2a, 0xd4, 0x45, 0x2d, 0x07, 0x9e, 0xcb, 0x83, 0x38, 0x7a, 0x40, 0x87, 0x32, + 0x9a, 0x59, 0x32, 0x82, 0x15, 0xf3, 0x86, 0x51, 0x9a, 0x7a, 0x5d, 0x23, 0xf2, 0x8c, 0xae, 0x01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0x93, 0x8c, 0x5f, 0x6c, 0x59, 0xa6, 0xbc, 0x53, 0x19, 0x6c, 0x4f, + 0x93, 0xcd, 0xa2, 0x20, 0x5a, 0x02, 0x3f, 0x53, 0x23, 0xa9, 0x3b, 0x38, 0x66, 0x5e, 0x12, 0xf4, + 0x45, 0x39, 0x8b, 0x5e, 0x52, 0x73, 0x3f, 0x0b, 0x51, 0xc3, 0xe8, 0x0e, 0x94, 0x5d, 0x4f, 0x70, + 0xa9, 0x3d, 0x83, 0xc7, 0x8c, 0x19, 0x9a, 0xb6, 0x25, 0x27, 0x51, 0x12, 0xb8, 0x03, 0xcb, 0xdb, + 0x5e, 0xb8, 0xed, 0xfb, 0x84, 0x7a, 0x71, 0xe2, 0xff, 0xf3, 0x0a, 0x36, 0xb6, 0x87, 0x5d, 0xd8, + 0x1e, 0xf8, 0x73, 0x58, 0x29, 0xaa, 0x52, 0xd3, 0xb4, 0x09, 0x95, 0x44, 0x62, 0xb4, 0x32, 0x0d, + 0xbf, 0x41, 0xdb, 0x67, 0x52, 0xdb, 0x7d, 0xca, 0x53, 0x6d, 0xec, 0xad, 0x3c, 0x73, 0xbd, 0x70, + 0x3f, 0x7f, 0x61, 0x64, 0x20, 0xde, 0x84, 0xd5, 0x11, 0x5d, 0xca, 0x35, 0xb9, 0x24, 0x25, 0x4a, + 0x26, 0xb5, 0x46, 0x32, 0x10, 0x7f, 0x05, 0x4e, 0x97, 0xc7, 0x09, 0x15, 0x7b, 0xfa, 0x3f, 0x78, + 0x97, 0xe0, 0x7d, 0x58, 0x32, 0xf4, 0xbf, 0xc3, 0x3b, 0x03, 0xff, 0x64, 0xc1, 0xa2, 0x54, 0xf5, + 0x80, 0x0e, 0x9f, 0x88, 0xf6, 0x13, 0x93, 0xe4, 0x19, 0x1d, 0x16, 0x7a, 0x29, 0x47, 0x88, 0x47, + 0x9c, 0xec, 0x52, 0x95, 0xf0, 0x14, 0x40, 0xef, 0xc3, 0x52, 0x36, 0x9b, 0xbb, 0x7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51, 0x11, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3234,9 +3304,16 @@ func (m *StoreDiffRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintSpacesync(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -3428,6 +3505,43 @@ func (m *StoreKeyInner) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StorageHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StorageHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StorageHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StorageName) > 0 { + i -= len(m.StorageName) + copy(dAtA[i:], m.StorageName) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.StorageName))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -3907,6 +4021,10 @@ func (m *StoreDiffRequest) Size() (n int) { } var l int _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } if len(m.Ranges) > 0 { for _, e := range m.Ranges { l = e.Size() @@ -4003,6 +4121,23 @@ func (m *StoreKeyInner) Size() (n int) { return n } +func (m *StorageHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.StorageName) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -6944,7 +7079,39 @@ func (m *StoreDiffRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: StoreDiffRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 3: + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Ranges", wireType) } @@ -7586,6 +7753,120 @@ func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { } return nil } +func (m *StorageHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StorageHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StorageHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipSpacesync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 3fadc5f589614b89e371310f4b117ec78dca5ed4 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 20:39:29 +0200 Subject: [PATCH 19/62] Add handle functions for key value service --- commonspace/object/keyvalue/keyvalue.go | 62 +++++++++++++++++-- .../keyvalue/keyvaluestorage/storage.go | 3 + 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index 570a8e4b..5357047f 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -3,13 +3,14 @@ package keyvalue import ( "context" "errors" - "io" "github.com/anyproto/protobuf/proto" + "go.uber.org/zap" "storj.io/drpc" "github.com/anyproto/any-sync/accountservice" "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" @@ -25,6 +26,8 @@ import ( var ErrUnexpectedMessageType = errors.New("unexpected message type") +var log = logger.NewNamed(CName) + const CName = "common.object.keyvalue" type KeyValueService interface { @@ -93,20 +96,71 @@ func (k *keyValueService) SyncWithPeer(ctx context.Context, p peer.Peer) (err er return err } } + err = stream.Send(&spacesyncproto.StoreKeyValue{}) + if err != nil { + return err + } var messages []*spacesyncproto.StoreKeyValue for { msg, err := stream.Recv() if err != nil { - if errors.Is(err, io.EOF) { - break - } return err } + if msg.KeyPeerId == "" { + break + } messages = append(messages, msg) } return k.defaultStore.SetRaw(ctx, messages...) } +func (k *keyValueService) HandleStoreDiffRequest(ctx context.Context, req *spacesyncproto.StoreDiffRequest) (resp *spacesyncproto.StoreDiffResponse, err error) { + return HandleRangeRequest(ctx, k.defaultStore.InnerStorage().Diff(), req) +} + +func (k *keyValueService) HandleStoreElementsRequest(ctx context.Context, stream spacesyncproto.DRPCSpaceSync_StoreElementsStream) (err error) { + var ( + messagesToSave []*spacesyncproto.StoreKeyValue + messagesToSend []string + ) + for { + msg, err := stream.Recv() + if err != nil { + return err + } + if msg.KeyPeerId == "" { + break + } + if msg.Value != nil { + messagesToSave = append(messagesToSave, msg) + } else { + messagesToSend = append(messagesToSend, msg.KeyPeerId) + } + } + innerStorage := k.defaultStore.InnerStorage() + isError := false + for _, msg := range messagesToSend { + kv, err := innerStorage.GetKeyPeerId(ctx, msg) + if err != nil { + log.Warn("failed to get key value", zap.String("key", msg), zap.Error(err)) + continue + } + err = stream.Send(kv.Proto()) + if err != nil { + log.Warn("failed to send key value", zap.String("key", msg), zap.Error(err)) + isError = true + break + } + } + if !isError { + err = stream.Send(&spacesyncproto.StoreKeyValue{}) + if err != nil { + return err + } + } + return k.defaultStore.SetRaw(ctx, messagesToSave...) +} + func (k *keyValueService) HandleMessage(ctx context.Context, headUpdate drpc.Message) (err error) { update, ok := headUpdate.(*objectmessages.HeadUpdate) if !ok { diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 3167b68f..bf8d1ddd 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -145,6 +145,9 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { } func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error { + if len(keyValue) == 0 { + return nil + } s.mx.Lock() defer s.mx.Unlock() keyValues := make([]innerstorage.KeyValue, len(keyValue)) From bb63dca331fdb947e1ddf110dd41ab33af03f70e Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 21:10:14 +0200 Subject: [PATCH 20/62] Add sync with peer --- commonspace/object/keyvalue/keyvalue.go | 36 ++++++++----- .../keyvalue/kvinterfaces/interfaces.go | 18 +++++++ commonspace/object/keyvalue/limiter.go | 52 +++++++++++++++++++ commonspace/spaceservice.go | 2 + commonspace/sync/objectsync/synchandler.go | 14 +++-- 5 files changed, 104 insertions(+), 18 deletions(-) create mode 100644 commonspace/object/keyvalue/kvinterfaces/interfaces.go create mode 100644 commonspace/object/keyvalue/limiter.go diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index 5357047f..68ab8d52 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -15,6 +15,7 @@ import ( "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/syncstorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" "github.com/anyproto/any-sync/commonspace/spacestate" "github.com/anyproto/any-sync/commonspace/spacestorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" @@ -26,15 +27,7 @@ import ( var ErrUnexpectedMessageType = errors.New("unexpected message type") -var log = logger.NewNamed(CName) - -const CName = "common.object.keyvalue" - -type KeyValueService interface { - app.ComponentRunnable - DefaultStore() keyvaluestorage.Storage - HandleMessage(ctx context.Context, msg objectmessages.HeadUpdate) (err error) -} +var log = logger.NewNamed(kvinterfaces.CName) type keyValueService struct { storageId string @@ -42,20 +35,32 @@ type keyValueService struct { ctx context.Context cancel context.CancelFunc + limiter *concurrentLimiter spaceStorage spacestorage.SpaceStorage defaultStore keyvaluestorage.Storage clientFactory spacesyncproto.ClientFactory syncService sync.SyncService } +func New() kvinterfaces.KeyValueService { + return &keyValueService{} +} + func (k *keyValueService) DefaultStore() keyvaluestorage.Storage { return k.defaultStore } -func (k *keyValueService) SyncWithPeer(ctx context.Context, p peer.Peer) (err error) { - if k.syncService == nil { - return nil - } +func (k *keyValueService) SyncWithPeer(p peer.Peer) (err error) { + k.limiter.ScheduleRequest(k.ctx, p.Id(), func() { + err = k.syncWithPeer(k.ctx, p) + if err != nil { + log.Error("failed to sync with peer", zap.String("peerId", p.ID()), zap.Error(err)) + } + }) + return nil +} + +func (k *keyValueService) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { conn, err := p.AcquireDrpcConn(ctx) if err != nil { return @@ -180,6 +185,8 @@ func (k *keyValueService) Init(a *app.App) (err error) { k.ctx, k.cancel = context.WithCancel(context.Background()) spaceState := a.MustComponent(spacestate.CName).(*spacestate.SpaceState) k.spaceId = spaceState.SpaceId + k.clientFactory = spacesyncproto.ClientFactoryFunc(spacesyncproto.NewDRPCSpaceSyncClient) + k.limiter = newConcurrentLimiter() accountService := a.MustComponent(accountservice.CName).(accountservice.Service) aclList := a.MustComponent(syncacl.CName).(list.AclList) k.spaceStorage = a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) @@ -199,7 +206,7 @@ func (k *keyValueService) Init(a *app.App) (err error) { } func (k *keyValueService) Name() (name string) { - return CName + return kvinterfaces.CName } func (k *keyValueService) Run(ctx context.Context) (err error) { @@ -208,6 +215,7 @@ func (k *keyValueService) Run(ctx context.Context) (err error) { func (k *keyValueService) Close(ctx context.Context) (err error) { k.cancel() + k.limiter.Close() return nil } diff --git a/commonspace/object/keyvalue/kvinterfaces/interfaces.go b/commonspace/object/keyvalue/kvinterfaces/interfaces.go new file mode 100644 index 00000000..b0416806 --- /dev/null +++ b/commonspace/object/keyvalue/kvinterfaces/interfaces.go @@ -0,0 +1,18 @@ +package kvinterfaces + +import ( + "context" + + "storj.io/drpc" + + "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" +) + +const CName = "common.object.keyvalue" + +type KeyValueService interface { + app.ComponentRunnable + DefaultStore() keyvaluestorage.Storage + HandleMessage(ctx context.Context, msg drpc.Message) (err error) +} \ No newline at end of file diff --git a/commonspace/object/keyvalue/limiter.go b/commonspace/object/keyvalue/limiter.go new file mode 100644 index 00000000..7a36bffd --- /dev/null +++ b/commonspace/object/keyvalue/limiter.go @@ -0,0 +1,52 @@ +package keyvalue + +import ( + "context" + "sync" +) + +type concurrentLimiter struct { + mu sync.Mutex + inProgress map[string]bool + wg sync.WaitGroup +} + +func newConcurrentLimiter() *concurrentLimiter { + return &concurrentLimiter{ + inProgress: make(map[string]bool), + } +} + +func (cl *concurrentLimiter) ScheduleRequest(ctx context.Context, id string, action func()) bool { + cl.mu.Lock() + if cl.inProgress[id] { + cl.mu.Unlock() + return false + } + + cl.inProgress[id] = true + cl.wg.Add(1) + cl.mu.Unlock() + + go func() { + defer func() { + cl.mu.Lock() + delete(cl.inProgress, id) + cl.mu.Unlock() + cl.wg.Done() + }() + + select { + case <-ctx.Done(): + return + default: + action() + } + }() + + return true +} + +func (cl *concurrentLimiter) Close() { + cl.wg.Wait() +} diff --git a/commonspace/spaceservice.go b/commonspace/spaceservice.go index b7e0f447..6b306659 100644 --- a/commonspace/spaceservice.go +++ b/commonspace/spaceservice.go @@ -13,6 +13,7 @@ import ( "github.com/anyproto/any-sync/commonspace/acl/aclclient" "github.com/anyproto/any-sync/commonspace/deletionmanager" + "github.com/anyproto/any-sync/commonspace/object/keyvalue" "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/commonspace/sync" "github.com/anyproto/any-sync/commonspace/sync/objectsync" @@ -184,6 +185,7 @@ func (s *spaceService) NewSpace(ctx context.Context, id string, deps Deps) (Spac Register(deps.SyncStatus). Register(peerManager). Register(st). + Register(keyvalue.New()). Register(objectsync.New()). Register(sync.NewSyncService()). Register(syncacl.New()). diff --git a/commonspace/sync/objectsync/synchandler.go b/commonspace/sync/objectsync/synchandler.go index 382f355c..2cc9d984 100644 --- a/commonspace/sync/objectsync/synchandler.go +++ b/commonspace/sync/objectsync/synchandler.go @@ -11,6 +11,7 @@ import ( "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/app/logger" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/tree/synctree" "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto" "github.com/anyproto/any-sync/commonspace/object/treemanager" @@ -30,10 +31,11 @@ var ErrUnexpectedHeadUpdateType = errors.New("unexpected head update type") var log = logger.NewNamed(syncdeps.CName) type objectSync struct { - spaceId string - pool pool.Service - manager objectmanager.ObjectManager - status syncstatus.StatusUpdater + spaceId string + pool pool.Service + manager objectmanager.ObjectManager + status syncstatus.StatusUpdater + keyValue kvinterfaces.KeyValueService } func New() syncdeps.SyncHandler { @@ -43,6 +45,7 @@ func New() syncdeps.SyncHandler { func (o *objectSync) Init(a *app.App) (err error) { o.manager = a.MustComponent(treemanager.CName).(objectmanager.ObjectManager) o.pool = a.MustComponent(pool.CName).(pool.Service) + o.keyValue = a.MustComponent(kvinterfaces.CName).(kvinterfaces.KeyValueService) o.status = a.MustComponent(syncstatus.CName).(syncstatus.StatusUpdater) o.spaceId = a.MustComponent(spacestate.CName).(*spacestate.SpaceState).SpaceId return @@ -57,6 +60,9 @@ func (o *objectSync) HandleHeadUpdate(ctx context.Context, headUpdate drpc.Messa if !ok { return nil, ErrUnexpectedHeadUpdateType } + if update.ObjectType() == spacesyncproto.ObjectType_KeyValue { + return nil, o.keyValue.HandleMessage(ctx, update) + } peerId, err := peer.CtxPeerId(ctx) if err != nil { return nil, err From 38d822ec486381f692f89b131496c2a84330af02 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 4 Apr 2025 21:34:22 +0200 Subject: [PATCH 21/62] WIP key value architecture --- commonspace/headsync/diffsyncer.go | 43 +++++++++++++++---- commonspace/headsync/headsync.go | 22 ++++++++-- commonspace/object/keyvalue/keyvalue.go | 8 +++- .../keyvalue/keyvaluestorage/storage.go | 12 ++++++ .../keyvalue/kvinterfaces/interfaces.go | 4 +- commonspace/space.go | 10 ++++- 6 files changed, 82 insertions(+), 17 deletions(-) diff --git a/commonspace/headsync/diffsyncer.go b/commonspace/headsync/diffsyncer.go index c0242f91..845646f4 100644 --- a/commonspace/headsync/diffsyncer.go +++ b/commonspace/headsync/diffsyncer.go @@ -8,6 +8,7 @@ import ( "github.com/quic-go/quic-go" "github.com/anyproto/any-sync/commonspace/headsync/headstorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/net/rpc/rpcerr" @@ -42,6 +43,7 @@ func newDiffSyncer(hs *headSync) DiffSyncer { peerManager: hs.peerManager, clientFactory: spacesyncproto.ClientFactoryFunc(spacesyncproto.NewDRPCSpaceSyncClient), credentialProvider: hs.credentialProvider, + keyValue: hs.keyValue, log: newSyncLogger(hs.log, logPeriodSecs), deletionState: hs.deletionState, syncAcl: hs.syncAcl, @@ -63,6 +65,7 @@ type diffSyncer struct { cancel context.CancelFunc deletionState deletionstate.ObjectDeletionState credentialProvider credentialprovider.CredentialProvider + keyValue kvinterfaces.KeyValueService syncAcl syncacl.SyncAcl } @@ -90,10 +93,17 @@ func (d *diffSyncer) updateHeads(update headstorage.HeadsUpdate) { if update.IsDerived != nil && *update.IsDerived && len(update.Heads) == 1 && update.Heads[0] == update.Id { return } - d.diffContainer.Set(ldiff.Element{ - Id: update.Id, - Head: concatStrings(update.Heads), - }) + if update.Id == d.keyValue.DefaultStore().Id() { + d.diffContainer.NewDiff().Set(ldiff.Element{ + Id: update.Id, + Head: concatStrings(update.Heads), + }) + } else { + d.diffContainer.Set(ldiff.Element{ + Id: update.Id, + Head: concatStrings(update.Heads), + }) + } } // probably we should somehow batch the updates oldHash := d.diffContainer.OldDiff().Hash() @@ -126,7 +136,6 @@ func (d *diffSyncer) Sync(ctx context.Context) error { } } d.log.DebugCtx(ctx, "diff done", zap.String("spaceId", d.spaceId), zap.Duration("dur", time.Since(st))) - d.peerManager.KeepAlive(ctx) return nil } @@ -153,6 +162,7 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error) syncAclId = d.syncAcl.Id() newIds, changedIds, removedIds []string ) + storageId := d.keyValue.DefaultStore().Id() needsSync, diff, err := d.diffContainer.DiffTypeCheck(ctx, rdiff) err = rpcerr.Unwrap(err) if err != nil { @@ -169,17 +179,32 @@ func (d *diffSyncer) syncWithPeer(ctx context.Context, p peer.Peer) (err error) // not syncing ids which were removed through settings document missingIds := d.deletionState.Filter(newIds) existingIds := append(d.deletionState.Filter(removedIds), d.deletionState.Filter(changedIds)...) - - prevExistingLen := len(existingIds) + var ( + isStorage = false + isAcl = false + ) existingIds = slice.DiscardFromSlice(existingIds, func(s string) bool { - return s == syncAclId + if s == storageId { + isStorage = true + return true + } + if s == syncAclId { + isAcl = true + return true + } + return false }) // if we removed acl head from the list - if len(existingIds) < prevExistingLen { + if isAcl { if syncErr := d.syncAcl.SyncWithPeer(ctx, p); syncErr != nil { log.Warn("failed to send acl sync message to peer", zap.String("aclId", syncAclId)) } } + if isStorage { + if err = d.keyValue.SyncWithPeer(p); err != nil { + log.Warn("failed to send storage sync message to peer", zap.String("storageId", storageId)) + } + } // treeSyncer should not get acl id, that's why we filter existing ids before err = d.treeSyncer.SyncAll(ctx, p, existingIds, missingIds) diff --git a/commonspace/headsync/headsync.go b/commonspace/headsync/headsync.go index fd95e921..61496628 100644 --- a/commonspace/headsync/headsync.go +++ b/commonspace/headsync/headsync.go @@ -16,6 +16,7 @@ import ( "github.com/anyproto/any-sync/commonspace/deletionstate" "github.com/anyproto/any-sync/commonspace/headsync/headstorage" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/commonspace/peermanager" "github.com/anyproto/any-sync/commonspace/spacestate" @@ -58,6 +59,7 @@ type headSync struct { credentialProvider credentialprovider.CredentialProvider deletionState deletionstate.ObjectDeletionState syncAcl syncacl.SyncAcl + keyValue kvinterfaces.KeyValueService } func New() HeadSync { @@ -80,6 +82,7 @@ func (h *headSync) Init(a *app.App) (err error) { h.credentialProvider = a.MustComponent(credentialprovider.CName).(credentialprovider.CredentialProvider) h.treeSyncer = a.MustComponent(treesyncer.CName).(treesyncer.TreeSyncer) h.deletionState = a.MustComponent(deletionstate.CName).(deletionstate.ObjectDeletionState) + h.keyValue = a.MustComponent(kvinterfaces.CName).(kvinterfaces.KeyValueService) h.syncer = createDiffSyncer(h) sync := func(ctx context.Context) (err error) { return h.syncer.Sync(ctx) @@ -130,14 +133,23 @@ func (h *headSync) Close(ctx context.Context) (err error) { func (h *headSync) fillDiff(ctx context.Context) error { var els = make([]ldiff.Element, 0, 100) + var aclOrStorage []ldiff.Element err := h.storage.HeadStorage().IterateEntries(ctx, headstorage.IterOpts{}, func(entry headstorage.HeadsEntry) (bool, error) { if entry.IsDerived && entry.Heads[0] == entry.Id { return true, nil } - els = append(els, ldiff.Element{ - Id: entry.Id, - Head: concatStrings(entry.Heads), - }) + if entry.CommonSnapshot != "" { + els = append(els, ldiff.Element{ + Id: entry.Id, + Head: concatStrings(entry.Heads), + }) + } else { + // this whole stuff is done to prevent storage hash from being set to old diff + aclOrStorage = append(aclOrStorage, ldiff.Element{ + Id: entry.Id, + Head: concatStrings(entry.Heads), + }) + } return true, nil }) if err != nil { @@ -149,6 +161,8 @@ func (h *headSync) fillDiff(ctx context.Context) error { }) log.Debug("setting acl", zap.String("aclId", h.syncAcl.Id()), zap.String("headId", h.syncAcl.Head().Id)) h.diffContainer.Set(els...) + // acl will be set twice to the diff but it doesn't matter + h.diffContainer.NewDiff().Set(aclOrStorage...) oldHash := h.diffContainer.OldDiff().Hash() newHash := h.diffContainer.NewDiff().Hash() if err := h.storage.StateStorage().SetHash(ctx, oldHash, newHash); err != nil { diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index 68ab8d52..f7b984f9 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -54,7 +54,7 @@ func (k *keyValueService) SyncWithPeer(p peer.Peer) (err error) { k.limiter.ScheduleRequest(k.ctx, p.Id(), func() { err = k.syncWithPeer(k.ctx, p) if err != nil { - log.Error("failed to sync with peer", zap.String("peerId", p.ID()), zap.Error(err)) + log.Error("failed to sync with peer", zap.String("peerId", p.Id()), zap.Error(err)) } }) return nil @@ -192,6 +192,10 @@ func (k *keyValueService) Init(a *app.App) (err error) { k.spaceStorage = a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) k.syncService = a.MustComponent(sync.CName).(sync.SyncService) k.storageId = storageIdFromSpace(k.spaceId) + indexer := a.Component(keyvaluestorage.IndexerCName).(keyvaluestorage.Indexer) + if indexer == nil { + indexer = keyvaluestorage.NoOpIndexer{} + } syncClient := syncstorage.New(spaceState.SpaceId, k.syncService) k.defaultStore, err = keyvaluestorage.New( k.ctx, @@ -201,7 +205,7 @@ func (k *keyValueService) Init(a *app.App) (err error) { accountService.Account(), syncClient, aclList, - keyvaluestorage.NoOpIndexer{}) + indexer) return } diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index bf8d1ddd..f0635211 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -8,6 +8,7 @@ import ( anystore "github.com/anyproto/any-store" "go.uber.org/zap" + "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace/headsync/headstorage" "github.com/anyproto/any-sync/commonspace/object/accountdata" @@ -19,12 +20,23 @@ import ( var log = logger.NewNamed("common.keyvalue.keyvaluestorage") +const IndexerCName = "common.keyvalue.indexer" + type Indexer interface { + app.Component Index(keyValue ...innerstorage.KeyValue) error } type NoOpIndexer struct{} +func (n NoOpIndexer) Init(a *app.App) (err error) { + return nil +} + +func (n NoOpIndexer) Name() (name string) { + return IndexerCName +} + func (n NoOpIndexer) Index(keyValue ...innerstorage.KeyValue) error { return nil } diff --git a/commonspace/object/keyvalue/kvinterfaces/interfaces.go b/commonspace/object/keyvalue/kvinterfaces/interfaces.go index b0416806..56090024 100644 --- a/commonspace/object/keyvalue/kvinterfaces/interfaces.go +++ b/commonspace/object/keyvalue/kvinterfaces/interfaces.go @@ -7,6 +7,7 @@ import ( "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" + "github.com/anyproto/any-sync/net/peer" ) const CName = "common.object.keyvalue" @@ -15,4 +16,5 @@ type KeyValueService interface { app.ComponentRunnable DefaultStore() keyvaluestorage.Storage HandleMessage(ctx context.Context, msg drpc.Message) (err error) -} \ No newline at end of file + SyncWithPeer(p peer.Peer) (err error) +} diff --git a/commonspace/space.go b/commonspace/space.go index 7325ccb3..9c840d27 100644 --- a/commonspace/space.go +++ b/commonspace/space.go @@ -16,6 +16,7 @@ import ( "github.com/anyproto/any-sync/commonspace/headsync/headstorage" "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/commonspace/objecttreebuilder" "github.com/anyproto/any-sync/commonspace/peermanager" @@ -83,6 +84,7 @@ type Space interface { AclClient() aclclient.AclSpaceClient SyncStatus() syncstatus.StatusUpdater Storage() spacestorage.SpaceStorage + KeyValue() kvinterfaces.KeyValueService DeleteTree(ctx context.Context, id string) (err error) GetNodePeers(ctx context.Context) (peer []peer.Peer, err error) @@ -110,6 +112,7 @@ type space struct { settings settings.Settings storage spacestorage.SpaceStorage aclClient aclclient.AclSpaceClient + keyValue kvinterfaces.KeyValueService aclList list.AclList creationTime time.Time } @@ -150,7 +153,7 @@ func (s *space) DebugAllHeads() (heads []headsync.TreeHeads) { s.storage.HeadStorage().IterateEntries(context.Background(), headstorage.IterOpts{}, func(entry headstorage.HeadsEntry) (bool, error) { if entry.CommonSnapshot != "" { heads = append(heads, headsync.TreeHeads{ - Id: entry.Id, + Id: entry.Id, Heads: entry.Heads, }) } @@ -221,6 +224,7 @@ func (s *space) Init(ctx context.Context) (err error) { s.streamPool = s.app.MustComponent(streampool.CName).(streampool.StreamPool) s.treeSyncer = s.app.MustComponent(treesyncer.CName).(treesyncer.TreeSyncer) s.aclClient = s.app.MustComponent(aclclient.CName).(aclclient.AclSpaceClient) + s.keyValue = s.app.MustComponent(kvinterfaces.CName).(kvinterfaces.KeyValueService) return } @@ -228,6 +232,10 @@ func (s *space) SyncStatus() syncstatus.StatusUpdater { return s.syncStatus } +func (s *space) KeyValue() kvinterfaces.KeyValueService { + return s.keyValue +} + func (s *space) Storage() spacestorage.SpaceStorage { return s.storage } From 4054a914a75437e67c52446d37d0d410b62deebd Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 7 Apr 2025 15:44:41 +0200 Subject: [PATCH 22/62] Add noopindexer --- commonspace/spaceservice.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commonspace/spaceservice.go b/commonspace/spaceservice.go index 6b306659..1f0c37b7 100644 --- a/commonspace/spaceservice.go +++ b/commonspace/spaceservice.go @@ -14,6 +14,7 @@ import ( "github.com/anyproto/any-sync/commonspace/acl/aclclient" "github.com/anyproto/any-sync/commonspace/deletionmanager" "github.com/anyproto/any-sync/commonspace/object/keyvalue" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/commonspace/sync" "github.com/anyproto/any-sync/commonspace/sync/objectsync" @@ -70,6 +71,7 @@ type Deps struct { SyncStatus syncstatus.StatusUpdater TreeSyncer treesyncer.TreeSyncer AccountService accountservice.Service + Indexer keyvaluestorage.Indexer } type spaceService struct { @@ -181,10 +183,15 @@ func (s *spaceService) NewSpace(ctx context.Context, id string, deps Deps) (Spac if deps.AccountService != nil { spaceApp.Register(deps.AccountService) } + var keyValueIndexer keyvaluestorage.Indexer = keyvaluestorage.NoOpIndexer{} + if deps.Indexer != nil { + keyValueIndexer = deps.Indexer + } spaceApp.Register(state). Register(deps.SyncStatus). Register(peerManager). Register(st). + Register(keyValueIndexer). Register(keyvalue.New()). Register(objectsync.New()). Register(sync.NewSyncService()). From d2ea2ba75dcd1bc29373542be293f018c91cb7f8 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 7 Apr 2025 15:52:50 +0200 Subject: [PATCH 23/62] Filter keyValue from stored ids --- commonspace/headsync/headsync.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commonspace/headsync/headsync.go b/commonspace/headsync/headsync.go index 61496628..6c701c6b 100644 --- a/commonspace/headsync/headsync.go +++ b/commonspace/headsync/headsync.go @@ -120,8 +120,9 @@ func (h *headSync) AllIds() []string { func (h *headSync) ExternalIds() []string { settingsId := h.storage.StateStorage().SettingsId() aclId := h.syncAcl.Id() + keyValueId := h.keyValue.DefaultStore().Id() return slice.DiscardFromSlice(h.AllIds(), func(id string) bool { - return id == settingsId || id == aclId + return id == settingsId || id == aclId || id == keyValueId }) } From c211ccf26e86891d1313edd2bea97f3eeed0bde7 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 7 Apr 2025 21:37:55 +0200 Subject: [PATCH 24/62] Add encryption --- commonspace/object/acl/list/aclstate.go | 14 ++ .../keyvaluestorage/innerstorage/element.go | 4 + .../innerstorage/keyvaluestorage.go | 3 +- .../keyvalue/keyvaluestorage/storage.go | 124 +++++++++++++++--- util/crypto/derived.go | 5 +- 5 files changed, 131 insertions(+), 19 deletions(-) diff --git a/commonspace/object/acl/list/aclstate.go b/commonspace/object/acl/list/aclstate.go index c9d0dbb0..ea8a7e46 100644 --- a/commonspace/object/acl/list/aclstate.go +++ b/commonspace/object/acl/list/aclstate.go @@ -131,6 +131,20 @@ func (st *AclState) CurrentReadKeyId() string { return st.readKeyChanges[len(st.readKeyChanges)-1] } +func (st *AclState) ReadKeyForAclId(id string) (string, error) { + recIdx, ok := st.list.indexes[id] + if !ok { + return "", ErrNoSuchRecord + } + for i := len(st.readKeyChanges) - 1; i >= 0; i-- { + recId := st.readKeyChanges[i] + if recIdx >= st.list.indexes[recId] { + return recId, nil + } + } + return "", ErrNoSuchRecord +} + func (st *AclState) AccountKey() crypto.PrivKey { return st.key } diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go index 8fd74004..4c9aa8e7 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -13,11 +13,13 @@ var ErrInvalidSignature = errors.New("invalid signature") type KeyValue struct { KeyPeerId string + ReadKeyId string Key string Value Value TimestampMilli int Identity string PeerId string + AclId string } type Value struct { @@ -47,6 +49,7 @@ func KeyValueFromProto(proto *spacesyncproto.StoreKeyValue, verify bool) (kv Key kv.Identity = identity.Account() kv.PeerId = peerId.PeerId() kv.Key = innerValue.Key + kv.AclId = innerValue.AclHeadId // TODO: check that key-peerId is equal to key+peerId? if verify { if verify, _ = identity.Verify(proto.Value, proto.IdentitySignature); !verify { @@ -71,6 +74,7 @@ func (kv KeyValue) AnyEnc(a *anyenc.Arena) *anyenc.Value { obj := a.NewObject() obj.Set("id", a.NewString(kv.KeyPeerId)) obj.Set("k", a.NewString(kv.Key)) + obj.Set("r", a.NewString(kv.ReadKeyId)) obj.Set("v", kv.Value.AnyEnc(a)) obj.Set("t", a.NewNumberInt(kv.TimestampMilli)) obj.Set("i", a.NewString(kv.Identity)) diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index 1b62b904..ac941395 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -156,11 +156,12 @@ func (s *storage) keyValueFromDoc(doc anystore.Doc) KeyValue { } return KeyValue{ KeyPeerId: doc.Value().GetString("id"), + ReadKeyId: doc.Value().GetString("r"), Value: value, TimestampMilli: doc.Value().GetInt("t"), Identity: doc.Value().GetString("i"), PeerId: doc.Value().GetString("p"), - Key: doc.Value().GetString("k"), + Key: doc.Value().GetString("k"), } } diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index f0635211..f0835772 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -2,6 +2,7 @@ package keyvaluestorage import ( "context" + "fmt" "sync" "time" @@ -16,6 +17,8 @@ import ( "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/syncstorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" + "github.com/anyproto/any-sync/util/crypto" + "github.com/anyproto/any-sync/util/slice" ) var log = logger.NewNamed("common.keyvalue.keyvaluestorage") @@ -24,9 +27,11 @@ const IndexerCName = "common.keyvalue.indexer" type Indexer interface { app.Component - Index(keyValue ...innerstorage.KeyValue) error + Index(decryptor Decryptor, keyValue ...innerstorage.KeyValue) error } +type Decryptor = func(kv innerstorage.KeyValue) (value []byte, err error) + type NoOpIndexer struct{} func (n NoOpIndexer) Init(a *app.App) (err error) { @@ -37,7 +42,7 @@ func (n NoOpIndexer) Name() (name string) { return IndexerCName } -func (n NoOpIndexer) Index(keyValue ...innerstorage.KeyValue) error { +func (n NoOpIndexer) Index(decryptor Decryptor, keyValue ...innerstorage.KeyValue) error { return nil } @@ -50,13 +55,15 @@ type Storage interface { } type storage struct { - inner innerstorage.KeyValueStorage - keys *accountdata.AccountKeys - aclList list.AclList - syncClient syncstorage.SyncClient - indexer Indexer - storageId string - mx sync.Mutex + inner innerstorage.KeyValueStorage + keys *accountdata.AccountKeys + aclList list.AclList + syncClient syncstorage.SyncClient + indexer Indexer + storageId string + readKeys map[string]crypto.SymKey + currentReadKey crypto.SymKey + mx sync.Mutex } func New( @@ -80,6 +87,7 @@ func New( aclList: aclList, indexer: indexer, syncClient: syncClient, + readKeys: make(map[string]crypto.SymKey), }, nil } @@ -92,11 +100,21 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { defer s.mx.Unlock() s.aclList.RLock() headId := s.aclList.Head().Id - if !s.aclList.AclState().Permissions(s.aclList.AclState().Identity()).CanWrite() { + state := s.aclList.AclState() + if !s.aclList.AclState().Permissions(state.Identity()).CanWrite() { s.aclList.RUnlock() return list.ErrInsufficientPermissions } + readKeyId := state.CurrentReadKeyId() + err := s.readKeysFromAclState(state) + if err != nil { + return err + } s.aclList.RUnlock() + value, err = s.currentReadKey.Encrypt(value) + if err != nil { + return err + } peerIdKey := s.keys.PeerKey identityKey := s.keys.SignKey protoPeerKey, err := peerIdKey.GetPublic().Marshall() @@ -135,6 +153,8 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { TimestampMilli: int(timestampMilli), Identity: identityKey.GetPublic().Account(), PeerId: peerIdKey.GetPublic().PeerId(), + AclId: headId, + ReadKeyId: readKeyId, Value: innerstorage.Value{ Value: value, PeerSignature: peerSig, @@ -145,7 +165,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { if err != nil { return err } - indexErr := s.indexer.Index(keyValue) + indexErr := s.indexer.Index(s.decrypt, keyValue) if indexErr != nil { log.Warn("failed to index for key", zap.String("key", key), zap.Error(indexErr)) } @@ -156,7 +176,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { return nil } -func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error { +func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) (err error) { if len(keyValue) == 0 { return nil } @@ -170,18 +190,36 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK } keyValues = append(keyValues, innerKv) } - err := s.inner.Set(ctx, keyValues...) + s.aclList.RLock() + state := s.aclList.AclState() + err = s.readKeysFromAclState(state) if err != nil { + s.aclList.RUnlock() return err } - indexErr := s.indexer.Index(keyValues...) - if indexErr != nil { - log.Warn("failed to index for keys", zap.Error(indexErr)) + for _, kv := range keyValues { + kv.ReadKeyId, err = state.ReadKeyForAclId(kv.AclId) + if err != nil { + kv.KeyPeerId = "" + continue + } + } + s.aclList.RUnlock() + keyValues = slice.DiscardFromSlice(keyValues, func(value innerstorage.KeyValue) bool { + return value.KeyPeerId == "" + }) + err = s.inner.Set(ctx, keyValues...) + if err != nil { + return err } sendErr := s.syncClient.Broadcast(ctx, s.storageId, keyValues...) if sendErr != nil { log.Warn("failed to send key values", zap.Error(sendErr)) } + indexErr := s.indexer.Index(s.decrypt, keyValues...) + if indexErr != nil { + log.Warn("failed to index for keys", zap.Error(indexErr)) + } return nil } @@ -196,3 +234,57 @@ func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage func (s *storage) InnerStorage() innerstorage.KeyValueStorage { return s.inner } + +func (s *storage) readKeysFromAclState(state *list.AclState) (err error) { + if len(s.readKeys) == len(state.Keys()) { + return nil + } + if state.AccountKey() == nil || !state.HadReadPermissions(state.AccountKey().GetPublic()) { + return nil + } + for key, value := range state.Keys() { + if _, exists := s.readKeys[key]; exists { + continue + } + if value.ReadKey == nil { + continue + } + treeKey, err := deriveKey(value.ReadKey, s.storageId) + if err != nil { + return err + } + s.readKeys[key] = treeKey + } + curKey, err := state.CurrentReadKey() + if err != nil { + return err + } + if curKey == nil { + return nil + } + s.currentReadKey, err = deriveKey(curKey, s.storageId) + return err +} + +func (s *storage) decrypt(kv innerstorage.KeyValue) (value []byte, err error) { + if kv.ReadKeyId == "" { + return nil, fmt.Errorf("no read key id") + } + key := s.readKeys[kv.ReadKeyId] + if key == nil { + return nil, fmt.Errorf("no read key for %s", kv.ReadKeyId) + } + value, err = key.Decrypt(kv.Value.Value) + if err != nil { + return nil, err + } + return value, nil +} + +func deriveKey(key crypto.SymKey, id string) (crypto.SymKey, error) { + raw, err := key.Raw() + if err != nil { + return nil, err + } + return crypto.DeriveSymmetricKey(raw, fmt.Sprintf(crypto.AnysyncKeyValuePath, id)) +} diff --git a/util/crypto/derived.go b/util/crypto/derived.go index 0318b17a..86f64d0d 100644 --- a/util/crypto/derived.go +++ b/util/crypto/derived.go @@ -5,8 +5,9 @@ import ( ) const ( - AnysyncSpacePath = "m/SLIP-0021/anysync/space" - AnysyncTreePath = "m/SLIP-0021/anysync/tree/%s" + AnysyncSpacePath = "m/SLIP-0021/anysync/space" + AnysyncTreePath = "m/SLIP-0021/anysync/tree/%s" + AnysyncKeyValuePath = "m/SLIP-0021/anysync/keyvalue/%s" ) // DeriveSymmetricKey derives a symmetric key from seed and path using slip-21 From a89b0e501299d2fe876e0d2fd4dc189064e9d379 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 7 Apr 2025 23:56:53 +0200 Subject: [PATCH 25/62] Fixes for message exchange --- .../object/keyvalue/keyvaluestorage/storage.go | 18 ++++++++++++------ .../keyvaluestorage/syncstorage/syncclient.go | 4 ++++ commonspace/sync/sync.go | 4 ---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index f0835772..ec17e555 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -7,6 +7,7 @@ import ( "time" anystore "github.com/anyproto/any-store" + "github.com/anyproto/protobuf/proto" "go.uber.org/zap" "github.com/anyproto/any-sync/app" @@ -156,7 +157,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { AclId: headId, ReadKeyId: readKeyId, Value: innerstorage.Value{ - Value: value, + Value: innerBytes, PeerSignature: peerSig, IdentitySignature: identitySig, }, @@ -182,7 +183,7 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK } s.mx.Lock() defer s.mx.Unlock() - keyValues := make([]innerstorage.KeyValue, len(keyValue)) + keyValues := make([]innerstorage.KeyValue, 0, len(keyValue)) for _, kv := range keyValue { innerKv, err := innerstorage.KeyValueFromProto(kv, true) if err != nil { @@ -197,10 +198,10 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK s.aclList.RUnlock() return err } - for _, kv := range keyValues { - kv.ReadKeyId, err = state.ReadKeyForAclId(kv.AclId) + for i := range keyValues { + keyValues[i].ReadKeyId, err = state.ReadKeyForAclId(keyValues[i].AclId) if err != nil { - kv.KeyPeerId = "" + keyValues[i].KeyPeerId = "" continue } } @@ -274,7 +275,12 @@ func (s *storage) decrypt(kv innerstorage.KeyValue) (value []byte, err error) { if key == nil { return nil, fmt.Errorf("no read key for %s", kv.ReadKeyId) } - value, err = key.Decrypt(kv.Value.Value) + msg := &spacesyncproto.StoreKeyInner{} + err = proto.Unmarshal(kv.Value.Value, msg) + if err != nil { + return nil, err + } + value, err = key.Decrypt(msg.Value) if err != nil { return nil, err } diff --git a/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go index 50f6ed74..3e3839a2 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go +++ b/commonspace/object/keyvalue/keyvaluestorage/syncstorage/syncclient.go @@ -68,6 +68,10 @@ func (s *syncClient) Broadcast(ctx context.Context, objectId string, keyValue .. inner := &innerUpdate{ keyValues: keyValue, } + err := inner.Prepare() + if err != nil { + return err + } headUpdate := &objectmessages.HeadUpdate{ Meta: objectmessages.ObjectMeta{ ObjectId: objectId, diff --git a/commonspace/sync/sync.go b/commonspace/sync/sync.go index bbc173fb..b58d75db 100644 --- a/commonspace/sync/sync.go +++ b/commonspace/sync/sync.go @@ -12,7 +12,6 @@ import ( "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace/peermanager" "github.com/anyproto/any-sync/commonspace/spacestate" - "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/sync/syncdeps" "github.com/anyproto/any-sync/metric" "github.com/anyproto/any-sync/nodeconf" @@ -118,9 +117,6 @@ func (s *syncService) HandleMessage(ctx context.Context, msg drpc.Message) error if !ok { return ErrUnexpectedMessage } - if idMsg.ObjectType() == spacesyncproto.ObjectType_KeyValue { - return nil - } objectId := idMsg.ObjectId() err := s.receiveQueue.Add(ctx, objectId, msgCtx{ ctx: ctx, From 08b3361330c9949f9b0ad30e8b54f27547d0e48e Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Tue, 8 Apr 2025 11:05:29 +0200 Subject: [PATCH 26/62] Fix acllist unlock --- commonspace/object/keyvalue/keyvaluestorage/storage.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index ec17e555..2fe134c1 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -109,6 +109,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { readKeyId := state.CurrentReadKeyId() err := s.readKeysFromAclState(state) if err != nil { + s.aclList.RUnlock() return err } s.aclList.RUnlock() From 22b1457e320571c95ed01274e8b952abbf196f88 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 00:48:26 +0200 Subject: [PATCH 27/62] KeyValue store test infra and refactor payloads --- commonspace/deletion_test.go | 5 +- commonspace/object/keyvalue/keyvalue.go | 12 +- commonspace/object/keyvalue/keyvalue_test.go | 133 ++++++++++++++++++ .../keyvalue/keyvaluestorage/storage.go | 32 +++++ commonspace/space.go | 27 ---- commonspace/{ => spacepayloads}/payloads.go | 38 ++++- .../{ => spacepayloads}/payloads_test.go | 15 +- commonspace/spaceservice.go | 21 +-- commonspace/spacestorage_test.go | 5 +- commonspace/spaceutils_test.go | 5 +- 10 files changed, 232 insertions(+), 61 deletions(-) create mode 100644 commonspace/object/keyvalue/keyvalue_test.go rename commonspace/{ => spacepayloads}/payloads.go (89%) rename commonspace/{ => spacepayloads}/payloads_test.go (98%) diff --git a/commonspace/deletion_test.go b/commonspace/deletion_test.go index b74d5798..add216a5 100644 --- a/commonspace/deletion_test.go +++ b/commonspace/deletion_test.go @@ -11,6 +11,7 @@ import ( "github.com/anyproto/any-sync/commonspace/object/accountdata" "github.com/anyproto/any-sync/commonspace/object/tree/objecttree" + "github.com/anyproto/any-sync/commonspace/spacepayloads" "github.com/anyproto/any-sync/commonspace/spacestorage" "github.com/anyproto/any-sync/commonspace/syncstatus" "github.com/anyproto/any-sync/util/crypto" @@ -47,7 +48,7 @@ func TestSpaceDeleteIdsMarkDeleted(t *testing.T) { totalObjs := 1000 // creating space - sp, err := fx.spaceService.CreateSpace(ctx, SpaceCreatePayload{ + sp, err := fx.spaceService.CreateSpace(ctx, spacepayloads.SpaceCreatePayload{ SigningKey: acc.SignKey, SpaceType: "type", ReadKey: rk, @@ -140,7 +141,7 @@ func TestSpaceDeleteIds(t *testing.T) { totalObjs := 1000 // creating space - sp, err := fx.spaceService.CreateSpace(ctx, SpaceCreatePayload{ + sp, err := fx.spaceService.CreateSpace(ctx, spacepayloads.SpaceCreatePayload{ SigningKey: acc.SignKey, SpaceType: "type", ReadKey: rk, diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index f7b984f9..cde400b9 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -36,10 +36,8 @@ type keyValueService struct { cancel context.CancelFunc limiter *concurrentLimiter - spaceStorage spacestorage.SpaceStorage defaultStore keyvaluestorage.Storage clientFactory spacesyncproto.ClientFactory - syncService sync.SyncService } func New() kvinterfaces.KeyValueService { @@ -189,19 +187,19 @@ func (k *keyValueService) Init(a *app.App) (err error) { k.limiter = newConcurrentLimiter() accountService := a.MustComponent(accountservice.CName).(accountservice.Service) aclList := a.MustComponent(syncacl.CName).(list.AclList) - k.spaceStorage = a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) - k.syncService = a.MustComponent(sync.CName).(sync.SyncService) + spaceStorage := a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) + syncService := a.MustComponent(sync.CName).(sync.SyncService) k.storageId = storageIdFromSpace(k.spaceId) indexer := a.Component(keyvaluestorage.IndexerCName).(keyvaluestorage.Indexer) if indexer == nil { indexer = keyvaluestorage.NoOpIndexer{} } - syncClient := syncstorage.New(spaceState.SpaceId, k.syncService) + syncClient := syncstorage.New(spaceState.SpaceId, syncService) k.defaultStore, err = keyvaluestorage.New( k.ctx, k.storageId, - k.spaceStorage.AnyStore(), - k.spaceStorage.HeadStorage(), + spaceStorage.AnyStore(), + spaceStorage.HeadStorage(), accountService.Account(), syncClient, aclList, diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go new file mode 100644 index 00000000..599128e9 --- /dev/null +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -0,0 +1,133 @@ +package keyvalue + +import ( + "context" + "path/filepath" + "testing" + + anystore "github.com/anyproto/any-store" + "github.com/stretchr/testify/require" + + "github.com/anyproto/any-sync/commonspace/object/accountdata" + "github.com/anyproto/any-sync/commonspace/object/acl/list" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + "github.com/anyproto/any-sync/commonspace/spacepayloads" + "github.com/anyproto/any-sync/commonspace/spacestorage" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" + "github.com/anyproto/any-sync/net/peer" + "github.com/anyproto/any-sync/net/rpc/rpctest" + "github.com/anyproto/any-sync/util/crypto" +) + +func TestKeyValueService(t *testing.T) { + t.Run("basic", func(t *testing.T) { + fxClient, _, serverPeer := prepareFixtures(t) + err := fxClient.SyncWithPeer(serverPeer) + require.NoError(t, err) + fxClient.limiter.Close() + }) +} + +func prepareFixtures(t *testing.T) (fxClient *fixture, fxServer *fixture, serverPeer peer.Peer) { + firstKeys, err := accountdata.NewRandom() + require.NoError(t, err) + secondKeys, err := accountdata.NewRandom() + require.NoError(t, err) + secondKeys.SignKey = firstKeys.SignKey + payload := newStorageCreatePayload(t, firstKeys) + fxClient = newFixture(t, firstKeys, payload) + fxServer = newFixture(t, secondKeys, payload) + serverConn, clientConn := rpctest.MultiConnPair(firstKeys.PeerId, secondKeys.PeerId) + serverPeer, err = peer.NewPeer(serverConn, fxClient.server) + require.NoError(t, err) + _, err = peer.NewPeer(clientConn, fxServer.server) + require.NoError(t, err) + return +} + +var ctx = context.Background() + +type noOpSyncClient struct{} + +func (n noOpSyncClient) Broadcast(ctx context.Context, objectId string, keyValues ...innerstorage.KeyValue) error { + return nil +} + +type fixture struct { + *keyValueService + server *rpctest.TestServer +} + +func newFixture(t *testing.T, keys *accountdata.AccountKeys, spacePayload spacestorage.SpaceStorageCreatePayload) *fixture { + storePath := filepath.Join(t.TempDir(), "store.db") + anyStore, err := anystore.Open(ctx, storePath, nil) + require.NoError(t, err) + storage, err := spacestorage.Create(ctx, anyStore, spacePayload) + require.NoError(t, err) + aclStorage, err := storage.AclStorage() + require.NoError(t, err) + aclList, err := list.BuildAclListWithIdentity(keys, aclStorage, list.NoOpAcceptorVerifier{}) + require.NoError(t, err) + storageId := "kv.storage" + rpcHandler := rpctest.NewTestServer() + defaultStorage, err := keyvaluestorage.New(ctx, + storageId, + anyStore, + storage.HeadStorage(), + keys, + noOpSyncClient{}, + aclList, + keyvaluestorage.NoOpIndexer{}) + require.NoError(t, err) + ctx, cancel := context.WithCancel(ctx) + service := &keyValueService{ + spaceId: storage.Id(), + storageId: storageId, + limiter: newConcurrentLimiter(), + ctx: ctx, + cancel: cancel, + clientFactory: spacesyncproto.ClientFactoryFunc(spacesyncproto.NewDRPCSpaceSyncClient), + defaultStore: defaultStorage, + } + require.NoError(t, spacesyncproto.DRPCRegisterSpaceSync(rpcHandler, &testServer{service: service})) + return &fixture{ + keyValueService: service, + server: rpcHandler, + } +} + +func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spacestorage.SpaceStorageCreatePayload { + masterKey, _, err := crypto.GenerateRandomEd25519KeyPair() + require.NoError(t, err) + metaKey, _, err := crypto.GenerateRandomEd25519KeyPair() + require.NoError(t, err) + readKey := crypto.NewAES() + meta := []byte("account") + payload := spacepayloads.SpaceCreatePayload{ + SigningKey: keys.SignKey, + SpaceType: "space", + ReplicationKey: 10, + SpacePayload: nil, + MasterKey: masterKey, + ReadKey: readKey, + MetadataKey: metaKey, + Metadata: meta, + } + createSpace, err := spacepayloads.StoragePayloadForSpaceCreate(payload) + require.NoError(t, err) + return createSpace +} + +type testServer struct { + spacesyncproto.DRPCSpaceSyncUnimplementedServer + service *keyValueService +} + +func (t *testServer) StoreDiff(ctx context.Context, req *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { + return t.service.HandleStoreDiffRequest(ctx, req) +} + +func (t *testServer) StoreElements(stream spacesyncproto.DRPCSpaceSync_StoreElementsStream) error { + return t.service.HandleStoreElementsRequest(ctx, stream) +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 2fe134c1..b3f22efc 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -52,6 +52,7 @@ type Storage interface { Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) + Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error InnerStorage() innerstorage.KeyValueStorage } @@ -268,6 +269,37 @@ func (s *storage) readKeysFromAclState(state *list.AclState) (err error) { return err } +func (s *storage) Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) (err error) { + var ( + curKey = "" + values []innerstorage.KeyValue + ) + err = s.inner.IterateValues(ctx, func(kv innerstorage.KeyValue) (bool, error) { + if kv.Key != curKey { + if curKey != "" { + iter, err := f(curKey, values) + if err != nil { + return false, err + } + if !iter { + return false, nil + } + } + curKey = kv.Key + values = values[:0] + } + values = append(values, kv) + return true, nil + }) + if err != nil { + return err + } + if len(values) > 0 { + _, err = f(curKey, values) + } + return err +} + func (s *storage) decrypt(kv innerstorage.KeyValue) (value []byte, err error) { if kv.ReadKeyId == "" { return nil, fmt.Errorf("no read key id") diff --git a/commonspace/space.go b/commonspace/space.go index 9c840d27..8ea543bf 100644 --- a/commonspace/space.go +++ b/commonspace/space.go @@ -29,35 +29,8 @@ import ( "github.com/anyproto/any-sync/commonspace/syncstatus" "github.com/anyproto/any-sync/net/peer" "github.com/anyproto/any-sync/net/streampool" - "github.com/anyproto/any-sync/util/crypto" ) -type SpaceCreatePayload struct { - // SigningKey is the signing key of the owner - SigningKey crypto.PrivKey - // SpaceType is an arbitrary string - SpaceType string - // ReplicationKey is a key which is to be used to determine the node where the space should be held - ReplicationKey uint64 - // SpacePayload is an arbitrary payload related to space type - SpacePayload []byte - // MasterKey is the master key of the owner - MasterKey crypto.PrivKey - // ReadKey is the first read key of space - ReadKey crypto.SymKey - // MetadataKey is the first metadata key of space - MetadataKey crypto.PrivKey - // Metadata is the metadata of the owner - Metadata []byte -} - -type SpaceDerivePayload struct { - SigningKey crypto.PrivKey - MasterKey crypto.PrivKey - SpaceType string - SpacePayload []byte -} - type SpaceDescription struct { SpaceHeader *spacesyncproto.RawSpaceHeaderWithId AclId string diff --git a/commonspace/payloads.go b/commonspace/spacepayloads/payloads.go similarity index 89% rename from commonspace/payloads.go rename to commonspace/spacepayloads/payloads.go index 269a46cd..ecb10a0d 100644 --- a/commonspace/payloads.go +++ b/commonspace/spacepayloads/payloads.go @@ -1,9 +1,9 @@ -package commonspace +package spacepayloads import ( + "crypto/rand" "errors" "hash/fnv" - "math/rand" "strconv" "strings" "time" @@ -21,6 +21,32 @@ import ( "github.com/anyproto/any-sync/util/crypto" ) +type SpaceCreatePayload struct { + // SigningKey is the signing key of the owner + SigningKey crypto.PrivKey + // SpaceType is an arbitrary string + SpaceType string + // ReplicationKey is a key which is to be used to determine the node where the space should be held + ReplicationKey uint64 + // SpacePayload is an arbitrary payload related to space type + SpacePayload []byte + // MasterKey is the master key of the owner + MasterKey crypto.PrivKey + // ReadKey is the first read key of space + ReadKey crypto.SymKey + // MetadataKey is the first metadata key of space + MetadataKey crypto.PrivKey + // Metadata is the metadata of the owner + Metadata []byte +} + +type SpaceDerivePayload struct { + SigningKey crypto.PrivKey + MasterKey crypto.PrivKey + SpaceType string + SpacePayload []byte +} + const ( SpaceReserved = "any-sync.space" ) @@ -113,7 +139,7 @@ func StoragePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload sp return } -func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload spacestorage.SpaceStorageCreatePayload, err error) { +func StoragePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload spacestorage.SpaceStorageCreatePayload, err error) { // marshalling keys identity, err := payload.SigningKey.GetPublic().Marshall() if err != nil { @@ -192,7 +218,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload sp return } -func validateSpaceStorageCreatePayload(payload spacestorage.SpaceStorageCreatePayload) (err error) { +func ValidateSpaceStorageCreatePayload(payload spacestorage.SpaceStorageCreatePayload) (err error) { err = ValidateSpaceHeader(payload.SpaceHeaderWithId, nil) if err != nil { return @@ -328,3 +354,7 @@ func validateCreateSpaceSettingsPayload(rawWithId *treechangeproto.RawTreeChange return } + +func NewSpaceId(id string, repKey uint64) string { + return strings.Join([]string{id, strconv.FormatUint(repKey, 36)}, ".") +} diff --git a/commonspace/payloads_test.go b/commonspace/spacepayloads/payloads_test.go similarity index 98% rename from commonspace/payloads_test.go rename to commonspace/spacepayloads/payloads_test.go index fbfe0f10..bd7ec235 100644 --- a/commonspace/payloads_test.go +++ b/commonspace/spacepayloads/payloads_test.go @@ -1,4 +1,4 @@ -package commonspace +package spacepayloads import ( "fmt" @@ -7,6 +7,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/anyproto/any-sync/commonspace/object/accountdata" "github.com/anyproto/any-sync/commonspace/object/acl/aclrecordproto" "github.com/anyproto/any-sync/commonspace/object/tree/objecttree" @@ -16,8 +19,6 @@ import ( "github.com/anyproto/any-sync/consensus/consensusproto" "github.com/anyproto/any-sync/util/cidutil" "github.com/anyproto/any-sync/util/crypto" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestSuccessHeaderPayloadForSpaceCreate(t *testing.T) { @@ -438,7 +439,7 @@ func TestSuccessSameIds(t *testing.T) { SpaceHeaderWithId: rawHeaderWithId, SpaceSettingsWithId: rawSettingsPayload, } - err = validateSpaceStorageCreatePayload(spacePayload) + err = ValidateSpaceStorageCreatePayload(spacePayload) require.NoError(t, err) } @@ -455,7 +456,7 @@ func TestFailWithAclWrongSpaceId(t *testing.T) { SpaceHeaderWithId: rawHeaderWithId, SpaceSettingsWithId: rawSettingsPayload, } - err = validateSpaceStorageCreatePayload(spacePayload) + err = ValidateSpaceStorageCreatePayload(spacePayload) assert.EqualErrorf(t, err, spacestorage.ErrIncorrectSpaceHeader.Error(), "Error should be: %v, got: %v", spacestorage.ErrIncorrectSpaceHeader, err) } @@ -472,7 +473,7 @@ func TestFailWithSettingsWrongSpaceId(t *testing.T) { SpaceHeaderWithId: rawHeaderWithId, SpaceSettingsWithId: rawSettingsPayload, } - err = validateSpaceStorageCreatePayload(spacePayload) + err = ValidateSpaceStorageCreatePayload(spacePayload) assert.EqualErrorf(t, err, spacestorage.ErrIncorrectSpaceHeader.Error(), "Error should be: %v, got: %v", spacestorage.ErrIncorrectSpaceHeader, err) } @@ -489,7 +490,7 @@ func TestFailWithWrongAclHeadIdInSettingsPayload(t *testing.T) { SpaceHeaderWithId: rawHeaderWithId, SpaceSettingsWithId: rawSettingsPayload, } - err = validateSpaceStorageCreatePayload(spacePayload) + err = ValidateSpaceStorageCreatePayload(spacePayload) assert.EqualErrorf(t, err, spacestorage.ErrIncorrectSpaceHeader.Error(), "Error should be: %v, got: %v", spacestorage.ErrIncorrectSpaceHeader, err) } diff --git a/commonspace/spaceservice.go b/commonspace/spaceservice.go index 1f0c37b7..09127211 100644 --- a/commonspace/spaceservice.go +++ b/commonspace/spaceservice.go @@ -16,6 +16,7 @@ import ( "github.com/anyproto/any-sync/commonspace/object/keyvalue" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" "github.com/anyproto/any-sync/commonspace/object/treesyncer" + "github.com/anyproto/any-sync/commonspace/spacepayloads" "github.com/anyproto/any-sync/commonspace/sync" "github.com/anyproto/any-sync/commonspace/sync/objectsync" "github.com/anyproto/any-sync/net" @@ -60,9 +61,9 @@ type ctxKey int const AddSpaceCtxKey ctxKey = 0 type SpaceService interface { - DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (string, error) - DeriveId(ctx context.Context, payload SpaceDerivePayload) (string, error) - CreateSpace(ctx context.Context, payload SpaceCreatePayload) (string, error) + DeriveSpace(ctx context.Context, payload spacepayloads.SpaceDerivePayload) (string, error) + DeriveId(ctx context.Context, payload spacepayloads.SpaceDerivePayload) (string, error) + CreateSpace(ctx context.Context, payload spacepayloads.SpaceCreatePayload) (string, error) NewSpace(ctx context.Context, id string, deps Deps) (sp Space, err error) app.Component } @@ -104,8 +105,8 @@ func (s *spaceService) Name() (name string) { return CName } -func (s *spaceService) CreateSpace(ctx context.Context, payload SpaceCreatePayload) (id string, err error) { - storageCreate, err := StoragePayloadForSpaceCreate(payload) +func (s *spaceService) CreateSpace(ctx context.Context, payload spacepayloads.SpaceCreatePayload) (id string, err error) { + storageCreate, err := spacepayloads.StoragePayloadForSpaceCreate(payload) if err != nil { return } @@ -120,8 +121,8 @@ func (s *spaceService) CreateSpace(ctx context.Context, payload SpaceCreatePaylo return store.Id(), store.Close(ctx) } -func (s *spaceService) DeriveId(ctx context.Context, payload SpaceDerivePayload) (id string, err error) { - storageCreate, err := storagePayloadForSpaceDerive(payload) +func (s *spaceService) DeriveId(ctx context.Context, payload spacepayloads.SpaceDerivePayload) (id string, err error) { + storageCreate, err := spacepayloads.StoragePayloadForSpaceDerive(payload) if err != nil { return } @@ -129,8 +130,8 @@ func (s *spaceService) DeriveId(ctx context.Context, payload SpaceDerivePayload) return } -func (s *spaceService) DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (id string, err error) { - storageCreate, err := storagePayloadForSpaceDerive(payload) +func (s *spaceService) DeriveSpace(ctx context.Context, payload spacepayloads.SpaceDerivePayload) (id string, err error) { + storageCreate, err := spacepayloads.StoragePayloadForSpaceDerive(payload) if err != nil { return } @@ -313,7 +314,7 @@ func (s *spaceService) spacePullWithPeer(ctx context.Context, p peer.Peer, id st } func (s *spaceService) createSpaceStorage(ctx context.Context, payload spacestorage.SpaceStorageCreatePayload) (spacestorage.SpaceStorage, error) { - err := validateSpaceStorageCreatePayload(payload) + err := spacepayloads.ValidateSpaceStorageCreatePayload(payload) if err != nil { return nil, err } diff --git a/commonspace/spacestorage_test.go b/commonspace/spacestorage_test.go index 51059d51..a7cc038f 100644 --- a/commonspace/spacestorage_test.go +++ b/commonspace/spacestorage_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/anyproto/any-sync/commonspace/object/accountdata" + "github.com/anyproto/any-sync/commonspace/spacepayloads" "github.com/anyproto/any-sync/commonspace/spacestorage" "github.com/anyproto/any-sync/util/crypto" ) @@ -22,7 +23,7 @@ func newStorageCreatePayload(t *testing.T) spacestorage.SpaceStorageCreatePayloa require.NoError(t, err) readKey := crypto.NewAES() meta := []byte("account") - payload := SpaceCreatePayload{ + payload := spacepayloads.SpaceCreatePayload{ SigningKey: keys.SignKey, SpaceType: "space", ReplicationKey: 10, @@ -32,7 +33,7 @@ func newStorageCreatePayload(t *testing.T) spacestorage.SpaceStorageCreatePayloa MetadataKey: metaKey, Metadata: meta, } - createSpace, err := StoragePayloadForSpaceCreate(payload) + createSpace, err := spacepayloads.StoragePayloadForSpaceCreate(payload) require.NoError(t, err) return createSpace } diff --git a/commonspace/spaceutils_test.go b/commonspace/spaceutils_test.go index 1d0a4f4c..17f0b474 100644 --- a/commonspace/spaceutils_test.go +++ b/commonspace/spaceutils_test.go @@ -26,6 +26,7 @@ import ( "github.com/anyproto/any-sync/commonspace/object/treesyncer" "github.com/anyproto/any-sync/commonspace/objecttreebuilder" "github.com/anyproto/any-sync/commonspace/peermanager" + "github.com/anyproto/any-sync/commonspace/spacepayloads" "github.com/anyproto/any-sync/commonspace/spacestorage" "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" @@ -751,7 +752,7 @@ func newMultiPeerFixture(t *testing.T, peerNum int) *multiPeerFixture { require.NoError(t, err) readKey := crypto.NewAES() meta := []byte("account") - payload := SpaceCreatePayload{ + payload := spacepayloads.SpaceCreatePayload{ SigningKey: keys.SignKey, SpaceType: "space", ReplicationKey: 10, @@ -761,7 +762,7 @@ func newMultiPeerFixture(t *testing.T, peerNum int) *multiPeerFixture { MetadataKey: metaKey, Metadata: meta, } - createSpace, err := StoragePayloadForSpaceCreate(payload) + createSpace, err := spacepayloads.StoragePayloadForSpaceCreate(payload) require.NoError(t, err) executor := list.NewExternalKeysAclExecutor(createSpace.SpaceHeaderWithId.Id, keys, meta, createSpace.AclWithId) cmds := []string{ From f6558bd9a23767289e505accb7d726683c582451 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 01:00:37 +0200 Subject: [PATCH 28/62] WIP key value test --- commonspace/object/keyvalue/keyvalue_test.go | 11 ++++++++++- .../object/keyvalue/keyvaluestorage/storage.go | 5 +++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index 599128e9..b0fb1e62 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -22,7 +22,11 @@ import ( func TestKeyValueService(t *testing.T) { t.Run("basic", func(t *testing.T) { - fxClient, _, serverPeer := prepareFixtures(t) + fxClient, fxServer, serverPeer := prepareFixtures(t) + fxClient.add(t, "key1", []byte("value1")) + fxClient.add(t, "key2", []byte("value2")) + fxServer.add(t, "key3", []byte("value3")) + fxServer.add(t, "key4", []byte("value4")) err := fxClient.SyncWithPeer(serverPeer) require.NoError(t, err) fxClient.limiter.Close() @@ -97,6 +101,11 @@ func newFixture(t *testing.T, keys *accountdata.AccountKeys, spacePayload spaces } } +func (fx *fixture) add(t *testing.T, key string, value []byte) { + err := fx.defaultStore.Set(ctx, key, value) + require.NoError(t, err) +} + func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spacestorage.SpaceStorageCreatePayload { masterKey, _, err := crypto.GenerateRandomEd25519KeyPair() require.NoError(t, err) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index b3f22efc..9251d5e1 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -51,7 +51,7 @@ type Storage interface { Id() string Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error - GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) + GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, decryptor Decryptor, err error) Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error InnerStorage() innerstorage.KeyValueStorage } @@ -226,7 +226,8 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK return nil } -func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, err error) { +func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, decryptor Decryptor, err error) { + decryptor = s.decrypt err = s.inner.IteratePrefix(ctx, key, func(kv innerstorage.KeyValue) error { values = append(values, kv) return nil From b4bf8480d8d44969814d707a9b36e3048056afaa Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 09:48:18 +0200 Subject: [PATCH 29/62] Fix test --- commonspace/object/keyvalue/keyvalue.go | 4 ++-- commonspace/object/keyvalue/keyvalue_test.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index cde400b9..bed7d2e3 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -80,7 +80,7 @@ func (k *keyValueService) syncWithPeer(ctx context.Context, p peer.Peer) (err er return err } defer stream.CloseSend() - for _, id := range append(newIds, changedIds...) { + for _, id := range append(removedIds, changedIds...) { kv, err := innerStorage.GetKeyPeerId(ctx, id) if err != nil { return err @@ -90,7 +90,7 @@ func (k *keyValueService) syncWithPeer(ctx context.Context, p peer.Peer) (err er return err } } - for _, id := range append(theirChangedIds, removedIds...) { + for _, id := range append(theirChangedIds, newIds...) { kv := &spacesyncproto.StoreKeyValue{ KeyPeerId: id, } diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index b0fb1e62..e6ea2e0d 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -1,6 +1,7 @@ package keyvalue import ( + "bytes" "context" "path/filepath" "testing" @@ -30,6 +31,10 @@ func TestKeyValueService(t *testing.T) { err := fxClient.SyncWithPeer(serverPeer) require.NoError(t, err) fxClient.limiter.Close() + fxClient.check(t, "key3", []byte("value3")) + fxClient.check(t, "key4", []byte("value4")) + fxServer.check(t, "key1", []byte("value1")) + fxServer.check(t, "key2", []byte("value2")) }) } @@ -106,6 +111,19 @@ func (fx *fixture) add(t *testing.T, key string, value []byte) { require.NoError(t, err) } +func (fx *fixture) check(t *testing.T, key string, value []byte) bool { + kv, decryptor, err := fx.defaultStore.GetAll(ctx, key) + require.NoError(t, err) + for _, v := range kv { + decryptedValue, err := decryptor(v) + require.NoError(t, err) + if bytes.Equal(value, decryptedValue) { + return true + } + } + return false +} + func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spacestorage.SpaceStorageCreatePayload { masterKey, _, err := crypto.GenerateRandomEd25519KeyPair() require.NoError(t, err) From 5e1f889eb18463d42b7d3c617e93fce482f52590 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 10:12:35 +0200 Subject: [PATCH 30/62] Same keys different values --- commonspace/object/keyvalue/keyvalue_test.go | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index e6ea2e0d..7deda0a5 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -22,7 +22,7 @@ import ( ) func TestKeyValueService(t *testing.T) { - t.Run("basic", func(t *testing.T) { + t.Run("different keys", func(t *testing.T) { fxClient, fxServer, serverPeer := prepareFixtures(t) fxClient.add(t, "key1", []byte("value1")) fxClient.add(t, "key2", []byte("value2")) @@ -36,6 +36,27 @@ func TestKeyValueService(t *testing.T) { fxServer.check(t, "key1", []byte("value1")) fxServer.check(t, "key2", []byte("value2")) }) + t.Run("change same keys, different values", func(t *testing.T) { + fxClient, fxServer, serverPeer := prepareFixtures(t) + fxClient.add(t, "key1", []byte("value1")) + fxServer.add(t, "key1", []byte("value2")) + err := fxClient.SyncWithPeer(serverPeer) + require.NoError(t, err) + fxClient.limiter.Close() + fxClient.check(t, "key1", []byte("value1")) + fxClient.check(t, "key1", []byte("value2")) + fxServer.check(t, "key1", []byte("value1")) + fxServer.check(t, "key1", []byte("value2")) + fxClient.add(t, "key1", []byte("value1-2")) + fxServer.add(t, "key1", []byte("value2-2")) + err = fxClient.SyncWithPeer(serverPeer) + require.NoError(t, err) + fxClient.limiter.Close() + fxClient.check(t, "key1", []byte("value1-2")) + fxClient.check(t, "key1", []byte("value2-2")) + fxServer.check(t, "key1", []byte("value1-2")) + fxServer.check(t, "key1", []byte("value2-2")) + }) } func prepareFixtures(t *testing.T) (fxClient *fixture, fxServer *fixture, serverPeer peer.Peer) { From 20b48edf1707a60c75aa6546af18d35061120729 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 11:30:23 +0200 Subject: [PATCH 31/62] Send spaceId on elements sync --- commonspace/object/keyvalue/keyvalue.go | 4 + commonspace/object/keyvalue/keyvalue_test.go | 6 +- .../innerstorage/keyvaluestorage.go | 3 - .../spacesyncproto/protos/spacesync.proto | 1 + commonspace/spacesyncproto/spacesync.pb.go | 249 +++++++++++------- 5 files changed, 160 insertions(+), 103 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index bed7d2e3..e94d4196 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -80,6 +80,10 @@ func (k *keyValueService) syncWithPeer(ctx context.Context, p peer.Peer) (err er return err } defer stream.CloseSend() + err = stream.Send(&spacesyncproto.StoreKeyValue{SpaceId: k.spaceId}) + if err != nil { + return err + } for _, id := range append(removedIds, changedIds...) { kv, err := innerStorage.GetKeyPeerId(ctx, id) if err != nil { diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index 7deda0a5..542c9b3f 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -120,7 +120,7 @@ func newFixture(t *testing.T, keys *accountdata.AccountKeys, spacePayload spaces clientFactory: spacesyncproto.ClientFactoryFunc(spacesyncproto.NewDRPCSpaceSyncClient), defaultStore: defaultStorage, } - require.NoError(t, spacesyncproto.DRPCRegisterSpaceSync(rpcHandler, &testServer{service: service})) + require.NoError(t, spacesyncproto.DRPCRegisterSpaceSync(rpcHandler, &testServer{service: service, t: t})) return &fixture{ keyValueService: service, server: rpcHandler, @@ -170,6 +170,7 @@ func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spaces type testServer struct { spacesyncproto.DRPCSpaceSyncUnimplementedServer service *keyValueService + t *testing.T } func (t *testServer) StoreDiff(ctx context.Context, req *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { @@ -177,5 +178,8 @@ func (t *testServer) StoreDiff(ctx context.Context, req *spacesyncproto.StoreDif } func (t *testServer) StoreElements(stream spacesyncproto.DRPCSpaceSync_StoreElementsStream) error { + msg, err := stream.Recv() + require.NoError(t.t, err) + require.NotEmpty(t.t, msg.SpaceId) return t.service.HandleStoreElementsRequest(ctx, stream) } diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index ac941395..9af51f63 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -89,9 +89,6 @@ func (s *storage) Diff() ldiff.CompareDiff { func (s *storage) GetKeyPeerId(ctx context.Context, keyPeerId string) (value KeyValue, err error) { doc, err := s.collection.FindId(ctx, keyPeerId) if err != nil { - if errors.Is(err, anystore.ErrDocNotFound) { - return KeyValue{}, nil - } return } return s.keyValueFromDoc(doc), nil diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index a563f013..692be076 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -215,6 +215,7 @@ message StoreKeyValue { bytes value = 2; bytes identitySignature = 3; bytes peerSignature = 4; + string spaceId = 5; } message StoreKeyValues { diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index b0ed2a85..03599e85 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1837,6 +1837,7 @@ type StoreKeyValue struct { Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` IdentitySignature []byte `protobuf:"bytes,3,opt,name=identitySignature,proto3" json:"identitySignature,omitempty"` PeerSignature []byte `protobuf:"bytes,4,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"` + SpaceId string `protobuf:"bytes,5,opt,name=spaceId,proto3" json:"spaceId,omitempty"` } func (m *StoreKeyValue) Reset() { *m = StoreKeyValue{} } @@ -1908,6 +1909,13 @@ func (m *StoreKeyValue) GetPeerSignature() []byte { return nil } +func (m *StoreKeyValue) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + type StoreKeyValues struct { KeyValues []*StoreKeyValue `protobuf:"bytes,1,rep,name=keyValues,proto3" json:"keyValues,omitempty"` } @@ -2154,105 +2162,105 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1556 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x4b, 0x6f, 0x1b, 0xc5, - 0x3f, 0xbb, 0x4e, 0x1c, 0xfb, 0x17, 0xc7, 0xdd, 0x4c, 0x92, 0xc6, 0x7f, 0xb7, 0x72, 0xad, 0xd1, - 0x5f, 0x25, 0x8a, 0xa0, 0x6d, 0x52, 0xa8, 0xd4, 0x02, 0x87, 0x34, 0x49, 0x1b, 0x53, 0xd2, 0x44, - 0xe3, 0x3e, 0x24, 0x24, 0x90, 0x36, 0xbb, 0x93, 0x64, 0xe9, 0x7a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0xab, 0x46, 0x40, 0x87, 0x9a, 0x48, 0x0c, 0x46, 0x4c, - 0xc1, 0xe9, 0x0a, 0x9e, 0xa3, 0x01, 0x3b, 0xcb, 0xee, 0x77, 0x33, 0x77, 0x40, 0x84, 0xb4, 0xb0, - 0xb5, 0x66, 0xe8, 0x49, 0xb9, 0x53, 0x72, 0xee, 0x59, 0x0b, 0x60, 0x27, 0xa1, 0x3e, 0x8d, 0x78, - 0xe0, 0x86, 0x32, 0xd8, 0x1a, 0x31, 0x30, 0x78, 0x19, 0x96, 0x0c, 0x33, 0xe9, 0xb5, 0x61, 0xac, - 0x6d, 0x87, 0x61, 0x66, 0x7b, 0xa4, 0x26, 0xf1, 0x3d, 0x2d, 0x28, 0x78, 0xd4, 0x7d, 0xff, 0x7b, - 0x07, 0xf1, 0xb7, 0x36, 0xd4, 0x4c, 0x0a, 0xda, 0x86, 0x05, 0x29, 0x23, 0xca, 0x83, 0x26, 0x4a, - 0xcf, 0x15, 0x43, 0x0f, 0x71, 0x5f, 0x74, 0x73, 0x86, 0xa7, 0x01, 0x3f, 0xeb, 0xf8, 0xc4, 0x94, - 0x11, 0x41, 0xbb, 0x5e, 0xa8, 0x14, 0x66, 0x41, 0xe7, 0x18, 0x84, 0xa1, 0x96, 0x43, 0xfa, 0x9e, - 0x0b, 0x38, 0xb4, 0x05, 0x2b, 0x52, 0x65, 0x97, 0x72, 0x1e, 0x44, 0xa7, 0xec, 0xa8, 0x70, 0xf3, - 0x13, 0x69, 0xe8, 0x16, 0x5c, 0x9c, 0x84, 0xd7, 0x45, 0x31, 0x85, 0x8a, 0x7f, 0xb3, 0x60, 0xc1, - 0x08, 0x49, 0x94, 0x53, 0x20, 0x2f, 0x88, 0x0f, 0xd5, 0x10, 0xd2, 0xb0, 0x28, 0x5e, 0x1e, 0xf4, - 0x28, 0xe3, 0x6e, 0xaf, 0x2f, 0x43, 0x2b, 0x91, 0x1c, 0x21, 0xa8, 0xd2, 0x86, 0x6e, 0xdb, 0x2a,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a2, 0x54, 0xf5, - 0x80, 0x0e, 0x9f, 0x88, 0xf6, 0x13, 0x93, 0xe4, 0x19, 0x1d, 0x16, 0x7a, 0x29, 0x47, 0x88, 0x47, - 0x9c, 0xec, 0x52, 0x95, 0xf0, 0x14, 0x40, 0xef, 0xc3, 0x52, 0x36, 0x9b, 0xbb, 0x7a, 0x76, 0x95, - 0x24, 0xc7, 0x38, 0x41, 0xb4, 0x54, 0x9f, 0xd2, 0x24, 0xe7, 0x4c, 0xd7, 0x49, 0x11, 0x89, 0xf7, - 0xa1, 0x5e, 0x70, 0x8c, 0xa1, 0x5b, 0xd2, 0xb3, 0x14, 0x50, 0x21, 0x9a, 0xa9, 0x2a, 0x70, 0x93, - 0x9c, 0x15, 0xff, 0x62, 0xc4, 0xd8, 0x89, 0x22, 0x9a, 0x88, 0xd9, 0x2e, 0x8c, 0x65, 0x8f, 0x5b, - 0x71, 0x2e, 0xec, 0x1b, 0x7b, 0x64, 0xdf, 0xe8, 0xa8, 0x4b, 0x66, 0xd4, 0x57, 0xa1, 0xae, 0x97, - 0xce, 0x41, 0x10, 0x86, 0x81, 0x0c, 0xa4, 0x44, 0x46, 0xb0, 0x22, 0xa3, 0xaa, 0x96, 0xf4, 0x12, - 0xcc, 0x11, 0xc8, 0x81, 0xd2, 0x33, 0x3a, 0x94, 0x4b, 0xa4, 0x4a, 0xc4, 0x11, 0x3f, 0x48, 0xdd, - 0x75, 0x4f, 0xb3, 0x95, 0x30, 0xbd, 0x74, 0xc4, 0x3a, 0x49, 0x59, 0x1f, 0xba, 0x3d, 0xaa, 0x2a, - 0xd7, 0x44, 0x6d, 0xfc, 0x65, 0x41, 0x65, 0x2f, 0x49, 0x76, 0x62, 0x9f, 0x32, 0x54, 0x07, 0x78, - 0x1c, 0xd1, 0xf3, 0x3e, 0xf5, 0x38, 0xf5, 0x9d, 0x19, 0xe4, 0xa8, 0x67, 0xc7, 0x41, 0xc0, 0x58, - 0x10, 0x9d, 0x3a, 0x16, 0xba, 0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0x5b, 0x33, 0x2f, 0x5f, 0xb7, 0x66, 0xfe, 0x78, 0xdd, 0x9a, 0xf9, 0xa2, 0x39, 0xfd, 0x9f, - 0x25, 0xc7, 0x65, 0xf9, 0x73, 0xf3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0xfa, 0xd5, 0x33, - 0x51, 0x11, 0x00, 0x00, + // 1562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0xcd, 0x6f, 0x1b, 0xc5, + 0x37, 0xbb, 0x4e, 0x1c, 0xfb, 0xc5, 0x71, 0x37, 0x93, 0xa4, 0xf1, 0xcf, 0xad, 0x5c, 0x6b, 0xf4, + 0x53, 0x89, 0x22, 0x68, 0x9b, 0x14, 0x2a, 0xb5, 0xc0, 0x21, 0x4d, 0xd2, 0xc6, 0x94, 0x34, 0xd1, + 0xb8, 0x1f, 0x12, 0x12, 0x48, 0x9b, 0xdd, 0x49, 0xb2, 0x74, 0xbd, 0x6b, 0x76, 0xc6, 0x6d, 0x7c, + 0xe4, 0xc4, 0x09, 0xc4, 0x99, 0xff, 0x81, 0x03, 0xff, 0x05, 0xc7, 0xc2, 0x89, 0x23, 0x6a, 0xef, + 0xfc, 0x0d, 0x68, 0x66, 0x67, 0x67, 0x67, 0xfd, 0x51, 0x8a, 0x2a, 0x2e, 0xf1, 0xbc, 0xcf, 0x79, + 0xef, 0xcd, 0xfb, 0xda, 0xc0, 0xa6, 0x17, 0xf7, 0x7a, 0x71, 0xc4, 0xfa, 0xae, 0x47, 0xaf, 0xcb, + 0xbf, 0x6c, 0x18, 0x79, 0xfd, 0x24, 0xe6, 0xf1, 0x75, 0xf9, 0x97, 0xe5, 0xd8, 0x6b, 0x12, 0x81, + 0xaa, 0x1a, 0x81, 0x29, 0x2c, 0xee, 0x53, 0xd7, 0xef, 0x0e, 0x23, 0x8f, 0xb8, 0xd1, 0x29, 0x45,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 0x9a, 0xb6, 0x25, 0x27, 0x51, 0x12, 0xb8, + 0x03, 0xcb, 0xdb, 0x5e, 0xb8, 0xed, 0xfb, 0x84, 0x7a, 0x71, 0xe2, 0xff, 0xf3, 0x08, 0x36, 0xa6, + 0x87, 0x5d, 0x98, 0x1e, 0xf8, 0x73, 0x58, 0x29, 0xaa, 0x52, 0xdd, 0xb4, 0x09, 0x95, 0x44, 0x62, + 0xb4, 0x32, 0x0d, 0xbf, 0x41, 0xdb, 0x67, 0x52, 0xdb, 0x7d, 0xca, 0x53, 0x6d, 0xec, 0xad, 0x2c, + 0x73, 0xbd, 0x70, 0x3f, 0xdf, 0x30, 0x32, 0x10, 0x6f, 0xc2, 0xea, 0x88, 0x2e, 0x65, 0x9a, 0x1c, + 0x92, 0x12, 0x25, 0x83, 0x5a, 0x23, 0x19, 0x88, 0xbf, 0x02, 0xa7, 0xcb, 0xe3, 0x84, 0x8a, 0x39, + 0xfd, 0x1f, 0xec, 0x25, 0x78, 0x1f, 0x96, 0x0c, 0xfd, 0xef, 0xb0, 0x67, 0xe0, 0x5f, 0x2c, 0x58, + 0x94, 0xaa, 0x1e, 0xd0, 0xe1, 0x13, 0x51, 0x7e, 0xa2, 0x93, 0x3c, 0xa3, 0xc3, 0x42, 0x2d, 0xe5, + 0x08, 0xb1, 0xc4, 0xc9, 0x2a, 0x55, 0x01, 0x4f, 0x01, 0xf4, 0x3e, 0x2c, 0x65, 0xbd, 0xb9, 0xab, + 0x7b, 0x57, 0x49, 0x72, 0x8c, 0x13, 0x44, 0x49, 0xf5, 0x29, 0x4d, 0x72, 0xce, 0x74, 0x9c, 0x14, + 0x91, 0x66, 0xbc, 0xe6, 0x0a, 0xf1, 0xc2, 0xfb, 0x50, 0x2f, 0x98, 0xcc, 0xd0, 0x2d, 0x69, 0x73, + 0x0a, 0x28, 0xe7, 0xcd, 0x20, 0x16, 0xb8, 0x49, 0xce, 0x8a, 0x7f, 0x36, 0xbc, 0xef, 0x44, 0x11, + 0x4d, 0x44, 0xd7, 0x17, 0x66, 0x64, 0x6b, 0xaf, 0x38, 0x17, 0x26, 0x91, 0x3d, 0x32, 0x89, 0x74, + 0x3c, 0x4a, 0x66, 0x3c, 0xae, 0x42, 0x5d, 0x8f, 0xa3, 0x83, 0x20, 0x0c, 0x03, 0xe9, 0x62, 0x89, + 0x8c, 0x60, 0x45, 0xac, 0x55, 0x96, 0x69, 0x2f, 0x73, 0x04, 0x72, 0xa0, 0xf4, 0x8c, 0x0e, 0xe5, + 0x78, 0xa9, 0x12, 0x71, 0xc4, 0x0f, 0x52, 0x73, 0xdd, 0xd3, 0x6c, 0x58, 0x4c, 0x4f, 0x2a, 0x31, + 0x68, 0x52, 0xd6, 0x87, 0x6e, 0x8f, 0xaa, 0x9c, 0x36, 0x51, 0x1b, 0x7f, 0x59, 0x50, 0xd9, 0x4b, + 0x92, 0x9d, 0xd8, 0xa7, 0x0c, 0xd5, 0x01, 0x1e, 0x47, 0xf4, 0xbc, 0x4f, 0x3d, 0x4e, 0x7d, 0x67, + 0x06, 0x39, 0x6a, 0x21, 0x39, 0x08, 0x18, 0x0b, 0xa2, 0x53, 0xc7, 0x42, 0x17, 0x54, 0xdb, 0xdd, + 0x3b, 0x0f, 0x18, 0x67, 0x8e, 0x8d, 0x96, 0xe1, 0x82, 0x44, 0x3c, 0x8c, 0x79, 0x27, 0xda, 0x71, + 0xbd, 0x33, 0xea, 0x94, 0x10, 0x82, 0xba, 0x44, 0x76, 0x58, 0xda, 0x9e, 0x7d, 0x67, 0x16, 0x35, + 0x60, 0x45, 0x66, 0x0f, 0x7b, 0x18, 0x73, 0x95, 0xad, 0xc1, 0x71, 0x48, 0x9d, 0x39, 0xb4, 0x02, + 0x0e, 0xa1, 0x1e, 0x0d, 0xfa, 0xbc, 0xc3, 0x3a, 0xd1, 0x73, 0x37, 0x0c, 0x7c, 0xa7, 0x2c, 0x74, + 0x28, 0x40, 0xcd, 0x51, 0x67, 0x5e, 0x70, 0xee, 0x0e, 0xd2,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 0x17, 0x72, 0x43, 0x4f, 0x18, 0x4e, 0xd2, 0xa3, 0xd7, 0xf4, 0x49, 0x7a, 0x8c, 0xfd, 0x9c, 0x80, + 0x93, 0x7f, 0x28, 0x75, 0x79, 0x42, 0xdd, 0x1e, 0xba, 0x3c, 0xb6, 0xe1, 0x18, 0x5f, 0x51, 0xcd, + 0x37, 0x52, 0xa5, 0x8f, 0xfb, 0xd9, 0xb3, 0xcb, 0xb7, 0x7b, 0x07, 0x6d, 0xe8, 0x29, 0xac, 0xe5, + 0x48, 0xe5, 0xd0, 0xbb, 0x1b, 0x79, 0xc3, 0x42, 0x87, 0x50, 0x33, 0x07, 0x2c, 0x6a, 0x19, 0xfc, + 0x13, 0x86, 0x78, 0xf3, 0xca, 0x54, 0xba, 0x8e, 0xe3, 0x62, 0x61, 0x2e, 0xa2, 0x11, 0x89, 0xb1, + 0xe9, 0xdb, 0x6c, 0x4f, 0x67, 0x48, 0x75, 0xde, 0xfd, 0xf0, 0xd7, 0x57, 0x2d, 0xeb, 0xe5, 0xab, + 0x96, 0xf5, 0xe7, 0xab, 0x96, 0xf5, 0xe3, 0xeb, 0xd6, 0xcc, 0xcb, 0xd7, 0xad, 0x99, 0x3f, 0x5e, + 0xb7, 0x66, 0xbe, 0x68, 0x4e, 0xff, 0x37, 0xca, 0x71, 0x59, 0xfe, 0xdc, 0xfc, 0x3b, 0x00, 0x00, + 0xff, 0xff, 0x49, 0xe0, 0x66, 0x0a, 0x6b, 0x11, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -3374,6 +3382,13 @@ func (m *StoreKeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x2a + } if len(m.PeerSignature) > 0 { i -= len(m.PeerSignature) copy(dAtA[i:], m.PeerSignature) @@ -4071,6 +4086,10 @@ func (m *StoreKeyValue) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } return n } @@ -7413,6 +7432,38 @@ func (m *StoreKeyValue) Unmarshal(dAtA []byte) error { m.PeerSignature = []byte{} } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) From 1f3c2b98cfa1f54beef8afd5369a9c65bf607a7b Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 11:50:17 +0200 Subject: [PATCH 32/62] Test with randomness --- commonspace/object/keyvalue/keyvalue_test.go | 67 +++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index 542c9b3f..7cf81e4c 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -3,8 +3,13 @@ package keyvalue import ( "bytes" "context" + "fmt" + "math/rand" "path/filepath" + "strconv" + "strings" "testing" + "time" anystore "github.com/anyproto/any-store" "github.com/stretchr/testify/require" @@ -36,6 +41,7 @@ func TestKeyValueService(t *testing.T) { fxServer.check(t, "key1", []byte("value1")) fxServer.check(t, "key2", []byte("value2")) }) + t.Run("change same keys, different values", func(t *testing.T) { fxClient, fxServer, serverPeer := prepareFixtures(t) fxClient.add(t, "key1", []byte("value1")) @@ -57,6 +63,65 @@ func TestKeyValueService(t *testing.T) { fxServer.check(t, "key1", []byte("value1-2")) fxServer.check(t, "key1", []byte("value2-2")) }) + + t.Run("random keys and values", func(t *testing.T) { + rand.Seed(time.Now().UnixNano()) + diffEntries := 100 + ovelappingEntries := 10 + fxClient, fxServer, serverPeer := prepareFixtures(t) + numClientEntries := 5 + rand.Intn(diffEntries) + numServerEntries := 5 + rand.Intn(diffEntries) + allKeys := make(map[string]bool) + for i := 0; i < numClientEntries; i++ { + key := fmt.Sprintf("client-key-%d", i) + value := []byte(fmt.Sprintf("client-value-%d", i)) + fxClient.add(t, key, value) + allKeys[key] = true + } + for i := 0; i < numServerEntries; i++ { + key := fmt.Sprintf("server-key-%d", i) + value := []byte(fmt.Sprintf("server-value-%d", i)) + fxServer.add(t, key, value) + allKeys[key] = true + } + numOverlappingKeys := 3 + rand.Intn(ovelappingEntries) + for i := 0; i < numOverlappingKeys; i++ { + key := fmt.Sprintf("overlap-key-%d", i) + clientValue := []byte(fmt.Sprintf("client-overlap-value-%d", i)) + serverValue := []byte(fmt.Sprintf("server-overlap-value-%d", i)) + fxClient.add(t, key, clientValue) + fxServer.add(t, key, serverValue) + allKeys[key] = true + } + err := fxClient.SyncWithPeer(serverPeer) + require.NoError(t, err) + fxClient.limiter.Close() + + for key := range allKeys { + if strings.HasPrefix(key, "client-key-") { + i, _ := strconv.Atoi(strings.TrimPrefix(key, "client-key-")) + value := []byte(fmt.Sprintf("client-value-%d", i)) + fxClient.check(t, key, value) + fxServer.check(t, key, value) + } + if strings.HasPrefix(key, "server-key-") { + i, _ := strconv.Atoi(strings.TrimPrefix(key, "server-key-")) + value := []byte(fmt.Sprintf("server-value-%d", i)) + fxClient.check(t, key, value) + fxServer.check(t, key, value) + } + } + for i := 0; i < numOverlappingKeys; i++ { + key := fmt.Sprintf("overlap-key-%d", i) + clientValue := []byte(fmt.Sprintf("client-overlap-value-%d", i)) + serverValue := []byte(fmt.Sprintf("server-overlap-value-%d", i)) + + fxClient.check(t, key, clientValue) + fxClient.check(t, key, serverValue) + fxServer.check(t, key, clientValue) + fxServer.check(t, key, serverValue) + } + }) } func prepareFixtures(t *testing.T) (fxClient *fixture, fxServer *fixture, serverPeer peer.Peer) { @@ -170,7 +235,7 @@ func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spaces type testServer struct { spacesyncproto.DRPCSpaceSyncUnimplementedServer service *keyValueService - t *testing.T + t *testing.T } func (t *testServer) StoreDiff(ctx context.Context, req *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { From 3fde9b9ef8edf28dcf1277660c8a8f03ed5ec87b Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 12:14:04 +0200 Subject: [PATCH 33/62] Read keys on storage start --- commonspace/object/keyvalue/keyvaluestorage/storage.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 9251d5e1..1beb9f6c 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -82,7 +82,7 @@ func New( if err != nil { return nil, err } - return &storage{ + s := &storage{ inner: inner, keys: keys, storageId: storageId, @@ -90,7 +90,11 @@ func New( indexer: indexer, syncClient: syncClient, readKeys: make(map[string]crypto.SymKey), - }, nil + } + s.aclList.RLock() + defer s.aclList.RUnlock() + err = s.readKeysFromAclState(s.aclList.AclState()) + return s, err } func (s *storage) Id() string { From 5598491c0b8d43663cfd0d702ec1d72628061ce0 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 12:22:56 +0200 Subject: [PATCH 34/62] Update prepare --- commonspace/object/keyvalue/keyvalue.go | 2 +- commonspace/object/keyvalue/keyvaluestorage/storage.go | 8 ++++++-- commonspace/spaceservice.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index e94d4196..2cd3a0f2 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -216,7 +216,7 @@ func (k *keyValueService) Name() (name string) { } func (k *keyValueService) Run(ctx context.Context) (err error) { - return nil + return k.defaultStore.Prepare() } func (k *keyValueService) Close(ctx context.Context) (err error) { diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 1beb9f6c..470ef57e 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -49,6 +49,7 @@ func (n NoOpIndexer) Index(decryptor Decryptor, keyValue ...innerstorage.KeyValu type Storage interface { Id() string + Prepare() error Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, decryptor Decryptor, err error) @@ -91,10 +92,13 @@ func New( syncClient: syncClient, readKeys: make(map[string]crypto.SymKey), } + return s, nil +} + +func (s *storage) Prepare() error { s.aclList.RLock() defer s.aclList.RUnlock() - err = s.readKeysFromAclState(s.aclList.AclState()) - return s, err + return s.readKeysFromAclState(s.aclList.AclState()) } func (s *storage) Id() string { diff --git a/commonspace/spaceservice.go b/commonspace/spaceservice.go index 09127211..630e15c2 100644 --- a/commonspace/spaceservice.go +++ b/commonspace/spaceservice.go @@ -193,10 +193,10 @@ func (s *spaceService) NewSpace(ctx context.Context, id string, deps Deps) (Spac Register(peerManager). Register(st). Register(keyValueIndexer). - Register(keyvalue.New()). Register(objectsync.New()). Register(sync.NewSyncService()). Register(syncacl.New()). + Register(keyvalue.New()). Register(deletionstate.New()). Register(deletionmanager.New()). Register(settings.New()). From 6afb38419ba03aef5f7752830e63fdaa0d0c8544 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 14:09:58 +0200 Subject: [PATCH 35/62] Update kv --- .../object/keyvalue/keyvaluestorage/storage.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 470ef57e..18840d8f 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -64,6 +64,7 @@ type storage struct { syncClient syncstorage.SyncClient indexer Indexer storageId string + byteRepr []byte readKeys map[string]crypto.SymKey currentReadKey crypto.SymKey mx sync.Mutex @@ -90,6 +91,7 @@ func New( aclList: aclList, indexer: indexer, syncClient: syncClient, + byteRepr: make([]byte, 8), readKeys: make(map[string]crypto.SymKey), } return s, nil @@ -209,6 +211,14 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK return err } for i := range keyValues { + el, err := s.inner.Diff().Element(keyValues[i].KeyPeerId) + if err == nil { + binary.BigEndian.PutUint64(s.byteRepr, uint64(keyValues[i].TimestampMilli)) + if el.Head >= string(s.byteRepr) { + keyValues[i].KeyPeerId = "" + continue + } + } keyValues[i].ReadKeyId, err = state.ReadKeyForAclId(keyValues[i].AclId) if err != nil { keyValues[i].KeyPeerId = "" @@ -219,6 +229,9 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK keyValues = slice.DiscardFromSlice(keyValues, func(value innerstorage.KeyValue) bool { return value.KeyPeerId == "" }) + if len(keyValues) == 0 { + return nil + } err = s.inner.Set(ctx, keyValues...) if err != nil { return err From 969c76ce86e503d8ca93f40637ec40914b6f6a27 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 9 Apr 2025 14:10:11 +0200 Subject: [PATCH 36/62] Add encoding --- commonspace/object/keyvalue/keyvaluestorage/storage.go | 1 + 1 file changed, 1 insertion(+) diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 18840d8f..0479cb69 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -2,6 +2,7 @@ package keyvaluestorage import ( "context" + "encoding/binary" "fmt" "sync" "time" From e4e9ca4358b3d3fdb5d5f96d1b78ce40ca770e4a Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 9 Apr 2025 14:35:18 +0200 Subject: [PATCH 37/62] GO-4093: Extend KeyValueService interface --- commonspace/object/keyvalue/kvinterfaces/interfaces.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commonspace/object/keyvalue/kvinterfaces/interfaces.go b/commonspace/object/keyvalue/kvinterfaces/interfaces.go index 56090024..6bc34e13 100644 --- a/commonspace/object/keyvalue/kvinterfaces/interfaces.go +++ b/commonspace/object/keyvalue/kvinterfaces/interfaces.go @@ -7,6 +7,7 @@ import ( "github.com/anyproto/any-sync/app" "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" + "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/net/peer" ) @@ -17,4 +18,6 @@ type KeyValueService interface { DefaultStore() keyvaluestorage.Storage HandleMessage(ctx context.Context, msg drpc.Message) (err error) SyncWithPeer(p peer.Peer) (err error) + HandleStoreDiffRequest(ctx context.Context, req *spacesyncproto.StoreDiffRequest) (resp *spacesyncproto.StoreDiffResponse, err error) + HandleStoreElementsRequest(ctx context.Context, stream spacesyncproto.DRPCSpaceSync_StoreElementsStream) (err error) } From 7dee825636fb9343977d33aff46fde7cebdf23f8 Mon Sep 17 00:00:00 2001 From: Sergey Date: Wed, 9 Apr 2025 15:25:49 +0200 Subject: [PATCH 38/62] GO-4093: Fix typo --- .../keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index 9af51f63..033390de 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -134,7 +134,7 @@ func (s *storage) IteratePrefix(ctx context.Context, prefix string, iterFunc fun return } if !strings.Contains(doc.Value().GetString("id"), prefix) { - break + continue } err := iterFunc(s.keyValueFromDoc(doc)) if err != nil { From 9877163c49cebe2025d8ccd2fcfac6a78d0e0a94 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 10 Apr 2025 15:14:32 +0200 Subject: [PATCH 39/62] Update logic --- commonspace/object/keyvalue/keyvalue.go | 22 +- .../keyvalue/keyvaluestorage/storage.go | 13 +- .../spacesyncproto/protos/spacesync.proto | 6 + commonspace/spacesyncproto/spacesync.pb.go | 457 +++++++++++++----- 4 files changed, 378 insertions(+), 120 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue.go b/commonspace/object/keyvalue/keyvalue.go index 2cd3a0f2..eab795de 100644 --- a/commonspace/object/keyvalue/keyvalue.go +++ b/commonspace/object/keyvalue/keyvalue.go @@ -23,6 +23,7 @@ import ( "github.com/anyproto/any-sync/commonspace/sync/objectsync/objectmessages" "github.com/anyproto/any-sync/net/peer" "github.com/anyproto/any-sync/net/rpc/rpcerr" + "github.com/anyproto/any-sync/util/cidutil" ) var ErrUnexpectedMessageType = errors.New("unexpected message type") @@ -193,7 +194,10 @@ func (k *keyValueService) Init(a *app.App) (err error) { aclList := a.MustComponent(syncacl.CName).(list.AclList) spaceStorage := a.MustComponent(spacestorage.CName).(spacestorage.SpaceStorage) syncService := a.MustComponent(sync.CName).(sync.SyncService) - k.storageId = storageIdFromSpace(k.spaceId) + k.storageId, err = storageIdFromSpace(k.spaceId) + if err != nil { + return err + } indexer := a.Component(keyvaluestorage.IndexerCName).(keyvaluestorage.Indexer) if indexer == nil { indexer = keyvaluestorage.NoOpIndexer{} @@ -225,6 +229,18 @@ func (k *keyValueService) Close(ctx context.Context) (err error) { return nil } -func storageIdFromSpace(spaceId string) (storageId string) { - return spaceId + ".keyvalue" +func storageIdFromSpace(spaceId string) (storageId string, err error) { + header := &spacesyncproto.StorageHeader{ + SpaceId: spaceId, + StorageName: "default", + } + data, err := proto.Marshal(header) + if err != nil { + return "", err + } + cid, err := cidutil.NewCidFromBytes(data) + if err != nil { + return "", err + } + return cid, nil } diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 0479cb69..ff2b2f54 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -53,7 +53,7 @@ type Storage interface { Prepare() error Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error - GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, decryptor Decryptor, err error) + GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error InnerStorage() innerstorage.KeyValueStorage } @@ -248,13 +248,18 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK return nil } -func (s *storage) GetAll(ctx context.Context, key string) (values []innerstorage.KeyValue, decryptor Decryptor, err error) { - decryptor = s.decrypt +func (s *storage) GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) (err error) { + var values []innerstorage.KeyValue err = s.inner.IteratePrefix(ctx, key, func(kv innerstorage.KeyValue) error { values = append(values, kv) return nil }) - return + if err != nil { + return err + } + s.mx.Lock() + defer s.mx.Unlock() + return get(s.decrypt, values) } func (s *storage) InnerStorage() innerstorage.KeyValueStorage { diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index 692be076..87a317d5 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -149,6 +149,12 @@ message ObjectDelete { string id = 1; } +// StoreHeader is a header for a store +message StoreHeader { + string spaceId = 1; + string storageName = 2; +} + // SpaceDelete is a message containing deleter peer id message SpaceDelete { string deleterPeerId = 1; diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 03599e85..442f1acf 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -1248,6 +1248,67 @@ func (m *ObjectDelete) GetId() string { return "" } +// StoreHeader is a header for a store +type StoreHeader struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + StorageName string `protobuf:"bytes,2,opt,name=storageName,proto3" json:"storageName,omitempty"` +} + +func (m *StoreHeader) Reset() { *m = StoreHeader{} } +func (m *StoreHeader) String() string { return proto.CompactTextString(m) } +func (*StoreHeader) ProtoMessage() {} +func (*StoreHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_80e49f1f4ac27799, []int{16} +} +func (m *StoreHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreHeader.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreHeader) XXX_MarshalAppend(b []byte, newLen int) ([]byte, error) { + b = b[:newLen] + _, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b, nil +} +func (m *StoreHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreHeader.Merge(m, src) +} +func (m *StoreHeader) XXX_Size() int { + return m.Size() +} +func (m *StoreHeader) XXX_DiscardUnknown() { + xxx_messageInfo_StoreHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreHeader proto.InternalMessageInfo + +func (m *StoreHeader) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *StoreHeader) GetStorageName() string { + if m != nil { + return m.StorageName + } + return "" +} + // SpaceDelete is a message containing deleter peer id type SpaceDelete struct { DeleterPeerId string `protobuf:"bytes,1,opt,name=deleterPeerId,proto3" json:"deleterPeerId,omitempty"` @@ -1257,7 +1318,7 @@ func (m *SpaceDelete) Reset() { *m = SpaceDelete{} } func (m *SpaceDelete) String() string { return proto.CompactTextString(m) } func (*SpaceDelete) ProtoMessage() {} func (*SpaceDelete) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{16} + return fileDescriptor_80e49f1f4ac27799, []int{17} } func (m *SpaceDelete) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1311,7 +1372,7 @@ func (m *SpaceSettingsSnapshot) Reset() { *m = SpaceSettingsSnapshot{} } func (m *SpaceSettingsSnapshot) String() string { return proto.CompactTextString(m) } func (*SpaceSettingsSnapshot) ProtoMessage() {} func (*SpaceSettingsSnapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{17} + return fileDescriptor_80e49f1f4ac27799, []int{18} } func (m *SpaceSettingsSnapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1372,7 +1433,7 @@ func (m *SettingsData) Reset() { *m = SettingsData{} } func (m *SettingsData) String() string { return proto.CompactTextString(m) } func (*SettingsData) ProtoMessage() {} func (*SettingsData) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{18} + return fileDescriptor_80e49f1f4ac27799, []int{19} } func (m *SettingsData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1432,7 +1493,7 @@ func (m *SpaceSubscription) Reset() { *m = SpaceSubscription{} } func (m *SpaceSubscription) String() string { return proto.CompactTextString(m) } func (*SpaceSubscription) ProtoMessage() {} func (*SpaceSubscription) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{19} + return fileDescriptor_80e49f1f4ac27799, []int{20} } func (m *SpaceSubscription) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1493,7 +1554,7 @@ func (m *AclAddRecordRequest) Reset() { *m = AclAddRecordRequest{} } func (m *AclAddRecordRequest) String() string { return proto.CompactTextString(m) } func (*AclAddRecordRequest) ProtoMessage() {} func (*AclAddRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{20} + return fileDescriptor_80e49f1f4ac27799, []int{21} } func (m *AclAddRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1554,7 +1615,7 @@ func (m *AclAddRecordResponse) Reset() { *m = AclAddRecordResponse{} } func (m *AclAddRecordResponse) String() string { return proto.CompactTextString(m) } func (*AclAddRecordResponse) ProtoMessage() {} func (*AclAddRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{21} + return fileDescriptor_80e49f1f4ac27799, []int{22} } func (m *AclAddRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1616,7 +1677,7 @@ func (m *AclGetRecordsRequest) Reset() { *m = AclGetRecordsRequest{} } func (m *AclGetRecordsRequest) String() string { return proto.CompactTextString(m) } func (*AclGetRecordsRequest) ProtoMessage() {} func (*AclGetRecordsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{22} + return fileDescriptor_80e49f1f4ac27799, []int{23} } func (m *AclGetRecordsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1676,7 +1737,7 @@ func (m *AclGetRecordsResponse) Reset() { *m = AclGetRecordsResponse{} } func (m *AclGetRecordsResponse) String() string { return proto.CompactTextString(m) } func (*AclGetRecordsResponse) ProtoMessage() {} func (*AclGetRecordsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{23} + return fileDescriptor_80e49f1f4ac27799, []int{24} } func (m *AclGetRecordsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1729,7 +1790,7 @@ func (m *StoreDiffRequest) Reset() { *m = StoreDiffRequest{} } func (m *StoreDiffRequest) String() string { return proto.CompactTextString(m) } func (*StoreDiffRequest) ProtoMessage() {} func (*StoreDiffRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{24} + return fileDescriptor_80e49f1f4ac27799, []int{25} } func (m *StoreDiffRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1788,7 +1849,7 @@ func (m *StoreDiffResponse) Reset() { *m = StoreDiffResponse{} } func (m *StoreDiffResponse) String() string { return proto.CompactTextString(m) } func (*StoreDiffResponse) ProtoMessage() {} func (*StoreDiffResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{25} + return fileDescriptor_80e49f1f4ac27799, []int{26} } func (m *StoreDiffResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1844,7 +1905,7 @@ func (m *StoreKeyValue) Reset() { *m = StoreKeyValue{} } func (m *StoreKeyValue) String() string { return proto.CompactTextString(m) } func (*StoreKeyValue) ProtoMessage() {} func (*StoreKeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{26} + return fileDescriptor_80e49f1f4ac27799, []int{27} } func (m *StoreKeyValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1924,7 +1985,7 @@ func (m *StoreKeyValues) Reset() { *m = StoreKeyValues{} } func (m *StoreKeyValues) String() string { return proto.CompactTextString(m) } func (*StoreKeyValues) ProtoMessage() {} func (*StoreKeyValues) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{27} + return fileDescriptor_80e49f1f4ac27799, []int{28} } func (m *StoreKeyValues) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1981,7 +2042,7 @@ func (m *StoreKeyInner) Reset() { *m = StoreKeyInner{} } func (m *StoreKeyInner) String() string { return proto.CompactTextString(m) } func (*StoreKeyInner) ProtoMessage() {} func (*StoreKeyInner) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{28} + return fileDescriptor_80e49f1f4ac27799, []int{29} } func (m *StoreKeyInner) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2069,7 +2130,7 @@ func (m *StorageHeader) Reset() { *m = StorageHeader{} } func (m *StorageHeader) String() string { return proto.CompactTextString(m) } func (*StorageHeader) ProtoMessage() {} func (*StorageHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_80e49f1f4ac27799, []int{29} + return fileDescriptor_80e49f1f4ac27799, []int{30} } func (m *StorageHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2141,6 +2202,7 @@ func init() { proto.RegisterType((*RawSpaceHeaderWithId)(nil), "spacesync.RawSpaceHeaderWithId") proto.RegisterType((*SpaceSettingsContent)(nil), "spacesync.SpaceSettingsContent") proto.RegisterType((*ObjectDelete)(nil), "spacesync.ObjectDelete") + proto.RegisterType((*StoreHeader)(nil), "spacesync.StoreHeader") proto.RegisterType((*SpaceDelete)(nil), "spacesync.SpaceDelete") proto.RegisterType((*SpaceSettingsSnapshot)(nil), "spacesync.SpaceSettingsSnapshot") proto.RegisterType((*SettingsData)(nil), "spacesync.SettingsData") @@ -2162,105 +2224,106 @@ func init() { } var fileDescriptor_80e49f1f4ac27799 = []byte{ - // 1562 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0xcd, 0x6f, 0x1b, 0xc5, - 0x37, 0xbb, 0x4e, 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3f, 0xdf, 0x30, 0x32, 0x10, 0x6f, 0xc2, 0xea, 0x88, 0x2e, 0x65, 0x9a, 0x1c, - 0x92, 0x12, 0x25, 0x83, 0x5a, 0x23, 0x19, 0x88, 0xbf, 0x02, 0xa7, 0xcb, 0xe3, 0x84, 0x8a, 0x39, - 0xfd, 0x1f, 0xec, 0x25, 0x78, 0x1f, 0x96, 0x0c, 0xfd, 0xef, 0xb0, 0x67, 0xe0, 0x5f, 0x2c, 0x58, - 0x94, 0xaa, 0x1e, 0xd0, 0xe1, 0x13, 0x51, 0x7e, 0xa2, 0x93, 0x3c, 0xa3, 0xc3, 0x42, 0x2d, 0xe5, - 0x08, 0xb1, 0xc4, 0xc9, 0x2a, 0x55, 0x01, 0x4f, 0x01, 0xf4, 0x3e, 0x2c, 0x65, 0xbd, 0xb9, 0xab, - 0x7b, 0x57, 0x49, 0x72, 0x8c, 0x13, 0x44, 0x49, 0xf5, 0x29, 0x4d, 0x72, 0xce, 0x74, 0x9c, 0x14, - 0x91, 0x66, 0xbc, 0xe6, 0x0a, 0xf1, 0xc2, 0xfb, 0x50, 0x2f, 0x98, 0xcc, 0xd0, 0x2d, 0x69, 0x73, - 0x0a, 0x28, 0xe7, 0xcd, 0x20, 0x16, 0xb8, 0x49, 0xce, 0x8a, 0x7f, 0x36, 0xbc, 0xef, 0x44, 0x11, - 0x4d, 0x44, 0xd7, 0x17, 0x66, 0x64, 0x6b, 0xaf, 0x38, 0x17, 0x26, 0x91, 0x3d, 0x32, 0x89, 0x74, - 0x3c, 0x4a, 0x66, 0x3c, 0xae, 0x42, 0x5d, 0x8f, 0xa3, 0x83, 0x20, 0x0c, 0x03, 0xe9, 0x62, 0x89, - 0x8c, 0x60, 0x45, 0xac, 0x55, 0x96, 0x69, 0x2f, 0x73, 0x04, 0x72, 0xa0, 0xf4, 0x8c, 0x0e, 0xe5, - 0x78, 0xa9, 0x12, 0x71, 0xc4, 0x0f, 0x52, 0x73, 0xdd, 0xd3, 0x6c, 0x58,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x50, 0x33, 0x07, 0x2c, 0x6a, 0x19, 0xfc, - 0x13, 0x86, 0x78, 0xf3, 0xca, 0x54, 0xba, 0x8e, 0xe3, 0x62, 0x61, 0x2e, 0xa2, 0x11, 0x89, 0xb1, - 0xe9, 0xdb, 0x6c, 0x4f, 0x67, 0x48, 0x75, 0xde, 0xfd, 0xf0, 0xd7, 0x57, 0x2d, 0xeb, 0xe5, 0xab, - 0x96, 0xf5, 0xe7, 0xab, 0x96, 0xf5, 0xe3, 0xeb, 0xd6, 0xcc, 0xcb, 0xd7, 0xad, 0x99, 0x3f, 0x5e, - 0xb7, 0x66, 0xbe, 0x68, 0x4e, 0xff, 0x37, 0xca, 0x71, 0x59, 0xfe, 0xdc, 0xfc, 0x3b, 0x00, 0x00, - 0xff, 0xff, 0x49, 0xe0, 0x66, 0x0a, 0x6b, 0x11, 0x00, 0x00, + // 1572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x4d, 0x6f, 0x1b, 0x45, + 0x3b, 0xbb, 0x4e, 0x1c, 0xfb, 0x89, 0xe3, 0x6e, 0x26, 0x49, 0xe3, 0xd7, 0xad, 0x5c, 0x6b, 0xf4, + 0xaa, 0x6f, 0x14, 0xbd, 0xb4, 0x4d, 0x0a, 0x95, 0x5a, 0xe0, 0x90, 0x26, 0x69, 0x63, 0x4a, 0x9a, + 0x68, 0xdc, 0x0f, 0x09, 0x09, 0xa4, 0xcd, 0xee, 0x24, 0x59, 0xba, 0xde, 0x35, 0x3b, 0xe3, 0x36, + 0x3e, 0x72, 0xe2, 0x04, 0xe2, 0xcc, 0x7f, 0xe0, 0xc0, 0xbf, 0xe0, 0x58, 0x38, 0x71, 0x44, 0xed, + 0x9d, 0xdf, 0x80, 0x66, 0x76, 0x76, 0x76, 0xd6, 0x1f, 0xa5, 0xa8, 0x70, 0x89, 0xe7, 0x79, 0xe6, + 0xf9, 0xfe, 0x9c, 0x0d, 0x6c, 0x7a, 0x71, 0xaf, 0x17, 0x47, 0xac, 0xef, 0x7a, 0xf4, 0xba, 0xfc, + 0xcb, 0x86, 0x91, 0xd7, 0x4f, 0x62, 0x1e, 0x5f, 0x97, 0x7f, 0x59, 0x8e, 0xbd, 0x26, 0x11, 0xa8, + 0xaa, 0x11, 0x98, 0xc2, 0xe2, 0x3e, 0x75, 0xfd, 0xee, 0x30, 0xf2, 0x88, 0x1b, 0x9d, 0x52, 0x84, + 0x60, 0xf6, 0x24, 0x89, 0x7b, 0x0d, 0xab, 0x6d, 0xad, 0xcf, 0x12, 0x79, 0x46, 0x75, 0xb0, 0x79, + 0xdc, 0xb0, 0x25, 0xc6, 0xe6, 0x31, 0x5a, 0x81, 0xb9, 0x30, 0xe8, 0x05, 0xbc, 0x51, 0x6a, 0x5b, + 0xeb, 0x8b, 0x24, 0x05, 0x50, 0x13, 0x2a, 0x34, 0xa4, 0x3d, 0x1a, 0x71, 0xd6, 0x98, 0x6d, 0x5b, + 0xeb, 0x15, 0xa2, 0x61, 0x7c, 0x0e, 0x75, 0xad, 0x86, 0xb2, 0x41, 0xc8, 0x85, 0x9e, 0x33, 0x97, + 0x9d, 0x49, 0x3d, 0x35, 0x22, 0xcf, 0xe8, 0x23, 0x43, 0x82, 0xdd, 0x2e, 0xad, 0x2f, 0x6c, 0xb5, + 0xaf, 0xe5, 0xb6, 0x17, 0x05, 0xec, 0xa5, 0x84, 0xb9, 0x0e, 0x61, 0x95, 0x17, 0x0f, 0x22, 0x6d, + 0x95, 0x04, 0xf0, 0x87, 0xb0, 0x3a, 0x91, 0x51, 0x38, 0x15, 0xf8, 0x52, 0x7d, 0x95, 0xd8, 0x81, + 0x2f, 0x0d, 0xa2, 0xae, 0x2f, 0xdd, 0xac, 0x12, 0x79, 0xc6, 0xdf, 0x59, 0x70, 0x21, 0xe7, 0xfe, + 0x6a, 0x40, 0x19, 0x47, 0x0d, 0x98, 0x97, 0x36, 0x75, 0x32, 0xe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0xc0, 0x0d, 0xa5, 0xb3, 0x35, 0x62, 0x60, 0xf0, 0x32, 0x2c, 0x19, 0x6a, 0xd2, 0xb4, 0x61, + 0xac, 0x75, 0x87, 0x61, 0xa6, 0x7b, 0xa4, 0x26, 0xf1, 0x3d, 0xcd, 0x28, 0x68, 0x54, 0xbe, 0xff, + 0xbe, 0x81, 0xf8, 0x6b, 0x1b, 0x6a, 0xe6, 0x0d, 0xda, 0x86, 0x05, 0xc9, 0x23, 0xca, 0x83, 0x26, + 0x4a, 0xce, 0x15, 0x43, 0x0e, 0x71, 0x5f, 0x74, 0x73, 0x82, 0xa7, 0x01, 0x3f, 0xeb, 0xf8, 0xc4, + 0xe4, 0x11, 0x4e, 0xbb, 0x5e, 0xa8, 0x04, 0x66, 0x4e, 0xe7, 0x18, 0x84, 0xa1, 0x96, 0x43, 0x3a, + 0xcf, 0x05, 0x1c, 0xda, 0x82, 0x15, 0x29, 0xb2, 0x4b, 0x39, 0x0f, 0xa2, 0x53, 0x76, 0x54, 0xc8, + 0xfc, 0xc4, 0x3b, 0x74, 0x0b, 0x2e, 0x4e, 0xc2, 0xeb, 0xa2, 0x98, 0x72, 0x8b, 0x7f, 0xb1, 0x60, + 0xc1, 0x70, 0x49, 0x94, 0x53, 0x20, 0x13, 0xc4, 0x87, 0x6a, 0x08, 0x69, 0x58, 0x14, 0x2f, 0x0f, + 0x7a, 0x94, 0x71, 0xb7, 0xd7, 0x97, 0xae, 0x95, 0x48, 0x8e, 0x10, 0xb7, 0x52, 0x87, 0x6e, 0xdb, + 0x2a, 0xc9, 0x11, 0xe8, 0x2a, 0xd4, 0x45, 0x2d, 0x07, 0x9e, 0xcb, 0x83, 0x38, 0x7a, 0x40, 0x87, + 0xd2, 0x9b, 0x59, 0x32, 0x82, 0x15, 0xf3, 0x86, 0x51, 0x9a, 0x5a, 0x5d, 0x23, 0xf2, 0x8c, 0xae, + 0x01, 0x32, 0x42, 0x9c, 0x45, 0xa3, 0x2c, 0x29, 0x26, 0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 0x00, 0x00, 0xff, 0xff, 0xf9, 0xe8, 0x68, 0xd7, + 0xb6, 0x11, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -2983,6 +3046,43 @@ func (m *ObjectDelete) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StoreHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StorageName) > 0 { + i -= len(m.StorageName) + copy(dAtA[i:], m.StorageName) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.StorageName))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *SpaceDelete) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3895,6 +3995,23 @@ func (m *ObjectDelete) Size() (n int) { return n } +func (m *StoreHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.StorageName) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func (m *SpaceDelete) Size() (n int) { if m == nil { return 0 @@ -6224,6 +6341,120 @@ func (m *ObjectDelete) Unmarshal(dAtA []byte) error { } return nil } +func (m *StoreHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *SpaceDelete) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 5d2e7ce5fed723db48df071e16f2c059776285ee Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 11 Apr 2025 21:17:28 +0200 Subject: [PATCH 40/62] Fix check --- commonspace/object/keyvalue/keyvalue_test.go | 23 +++++++++++-------- .../keyvalue/keyvaluestorage/storage.go | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index 7cf81e4c..9ff1c59a 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -197,17 +197,20 @@ func (fx *fixture) add(t *testing.T, key string, value []byte) { require.NoError(t, err) } -func (fx *fixture) check(t *testing.T, key string, value []byte) bool { - kv, decryptor, err := fx.defaultStore.GetAll(ctx, key) - require.NoError(t, err) - for _, v := range kv { - decryptedValue, err := decryptor(v) - require.NoError(t, err) - if bytes.Equal(value, decryptedValue) { - return true +func (fx *fixture) check(t *testing.T, key string, value []byte) (isFound bool) { + err := fx.defaultStore.GetAll(ctx, key, func(decryptor keyvaluestorage.Decryptor, values []innerstorage.KeyValue) error { + for _, v := range values { + decryptedValue, err := decryptor(v) + require.NoError(t, err) + if bytes.Equal(value, decryptedValue) { + isFound = true + break + } } - } - return false + return nil + }) + require.NoError(t, err) + return } func newStorageCreatePayload(t *testing.T, keys *accountdata.AccountKeys) spacestorage.SpaceStorageCreatePayload { diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index ff2b2f54..ebf62f35 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -53,7 +53,7 @@ type Storage interface { Prepare() error Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error - GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) + GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) error Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error InnerStorage() innerstorage.KeyValueStorage } From 21b0b9e835b4c1a141d2630bacffb906e0e37784 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 11 Apr 2025 22:31:55 +0200 Subject: [PATCH 41/62] WIP fix tests and key value --- commonspace/object/keyvalue/keyvalue_test.go | 118 ++++++++++++++++++ .../keyvaluestorage/innerstorage/element.go | 2 +- .../innerstorage/keyvaluestorage.go | 4 +- .../keyvalue/keyvaluestorage/storage.go | 24 ++-- .../spacesyncproto/protos/spacesync.proto | 2 +- commonspace/spacesyncproto/spacesync.pb.go | 26 ++-- commonspace/sync/sync_test.go | 8 -- 7 files changed, 152 insertions(+), 32 deletions(-) diff --git a/commonspace/object/keyvalue/keyvalue_test.go b/commonspace/object/keyvalue/keyvalue_test.go index 9ff1c59a..301d9d0d 100644 --- a/commonspace/object/keyvalue/keyvalue_test.go +++ b/commonspace/object/keyvalue/keyvalue_test.go @@ -6,6 +6,7 @@ import ( "fmt" "math/rand" "path/filepath" + "sort" "strconv" "strings" "testing" @@ -121,6 +122,111 @@ func TestKeyValueService(t *testing.T) { fxServer.check(t, key, clientValue) fxServer.check(t, key, serverValue) } + foundClientKeys := make(map[string]bool) + foundServerKeys := make(map[string]bool) + err = fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + foundClientKeys[key] = true + return true, nil + }) + require.NoError(t, err) + err = fxServer.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + foundServerKeys[key] = true + return true, nil + }) + require.NoError(t, err) + require.True(t, mapEqual(allKeys, foundServerKeys), "expected all client keys to be found") + require.True(t, mapEqual(foundClientKeys, foundServerKeys), "expected all client keys to be found") + }) +} + +func TestKeyValueServiceIterate(t *testing.T) { + t.Run("empty storage", func(t *testing.T) { + fxClient, _, _ := prepareFixtures(t) + var keys []string + err := fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + keys = append(keys, key) + return true, nil + }) + require.NoError(t, err) + require.Empty(t, keys, "expected no keys in empty storage") + }) + + t.Run("single key later value", func(t *testing.T) { + fxClient, _, _ := prepareFixtures(t) + err := fxClient.defaultStore.Set(context.Background(), "test-key", []byte("value1")) + require.NoError(t, err) + err = fxClient.defaultStore.Set(context.Background(), "test-key", []byte("value2")) + require.NoError(t, err) + var keys []string + valueCount := 0 + err = fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + keys = append(keys, key) + valueCount = len(values) + + for _, kv := range values { + val, err := decryptor(kv) + require.NoError(t, err) + require.Equal(t, "value2", string(val)) + } + return true, nil + }) + require.NoError(t, err) + require.Equal(t, 1, len(keys), "expected one key") + require.Equal(t, "test-key", keys[0], "expected key to be 'test-key'") + require.Equal(t, 1, valueCount, "expected one value for key") + }) + + t.Run("multiple keys", func(t *testing.T) { + fxClient, _, _ := prepareFixtures(t) + testKeys := []string{"key1", "key2", "key3"} + for _, key := range testKeys { + err := fxClient.defaultStore.Set(context.Background(), key, []byte("value-"+key)) + require.NoError(t, err) + } + var foundKeys []string + err := fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + foundKeys = append(foundKeys, key) + require.Equal(t, 1, len(values), "Expected one value for key: "+key) + val, err := decryptor(values[0]) + require.NoError(t, err) + require.Equal(t, "value-"+key, string(val), "Value doesn't match for key: "+key) + + return true, nil + }) + require.NoError(t, err) + sort.Strings(foundKeys) + sort.Strings(testKeys) + require.Equal(t, testKeys, foundKeys, "Expected all keys to be found") + }) + + t.Run("early termination", func(t *testing.T) { + fxClient, _, _ := prepareFixtures(t) + testKeys := []string{"key1", "key2", "key3", "key4", "key5"} + for _, key := range testKeys { + err := fxClient.defaultStore.Set(context.Background(), key, []byte("value-"+key)) + require.NoError(t, err) + } + + var foundKeys []string + err := fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + foundKeys = append(foundKeys, key) + return len(foundKeys) < 2, nil + }) + require.NoError(t, err) + require.Equal(t, 2, len(foundKeys), "expected to find exactly 2 keys before stopping") + }) + + t.Run("error during iteration", func(t *testing.T) { + fxClient, _, _ := prepareFixtures(t) + + err := fxClient.defaultStore.Set(context.Background(), "test-key", []byte("test-value")) + require.NoError(t, err) + + expectedErr := context.Canceled + err = fxClient.defaultStore.Iterate(context.Background(), func(decryptor keyvaluestorage.Decryptor, key string, values []innerstorage.KeyValue) (bool, error) { + return false, expectedErr + }) + require.Equal(t, expectedErr, err, "expected error to be propagated") }) } @@ -141,6 +247,18 @@ func prepareFixtures(t *testing.T) (fxClient *fixture, fxServer *fixture, server return } +func mapEqual[K comparable, V comparable](map1, map2 map[K]V) bool { + if len(map1) != len(map2) { + return false + } + for key, val1 := range map1 { + if val2, ok := map2[key]; !ok || val1 != val2 { + return false + } + } + return true +} + var ctx = context.Background() type noOpSyncClient struct{} diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go index 4c9aa8e7..e4e48000 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/element.go @@ -37,7 +37,7 @@ func KeyValueFromProto(proto *spacesyncproto.StoreKeyValue, verify bool) (kv Key if err = innerValue.Unmarshal(proto.Value); err != nil { return kv, err } - kv.TimestampMilli = int(innerValue.TimestampMilli) + kv.TimestampMilli = int(innerValue.TimestampMicro) identity, err := crypto.UnmarshalEd25519PublicKeyProto(innerValue.Identity) if err != nil { return kv, err diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index 033390de..363c3032 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -121,7 +121,7 @@ func (s *storage) IterateValues(ctx context.Context, iterFunc func(kv KeyValue) func (s *storage) IteratePrefix(ctx context.Context, prefix string, iterFunc func(kv KeyValue) error) (err error) { filter := query.Key{Path: []string{"id"}, Filter: query.NewComp(query.CompOpGte, prefix)} qry := s.collection.Find(filter).Sort("id") - iter, err := s.collection.Find(qry).Iter(ctx) + iter, err := qry.Iter(ctx) if err != nil { return } @@ -134,7 +134,7 @@ func (s *storage) IteratePrefix(ctx context.Context, prefix string, iterFunc fun return } if !strings.Contains(doc.Value().GetString("id"), prefix) { - continue + break } err := iterFunc(s.keyValueFromDoc(doc)) if err != nil { diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index ebf62f35..7d03075c 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -54,7 +54,7 @@ type Storage interface { Set(ctx context.Context, key string, value []byte) error SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreKeyValue) error GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) error - Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) error + Iterate(ctx context.Context, f func(decryptor Decryptor, key string, values []innerstorage.KeyValue) (bool, error)) error InnerStorage() innerstorage.KeyValueStorage } @@ -139,12 +139,12 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { if err != nil { return err } - timestampMilli := time.Now().UnixMilli() + timestampMicro := time.Now().UnixMicro() inner := spacesyncproto.StoreKeyInner{ Peer: protoPeerKey, Identity: protoIdentityKey, Value: value, - TimestampMilli: timestampMilli, + TimestampMicro: timestampMicro, AclHeadId: headId, Key: key, } @@ -164,7 +164,7 @@ func (s *storage) Set(ctx context.Context, key string, value []byte) error { keyValue := innerstorage.KeyValue{ KeyPeerId: keyPeerId, Key: key, - TimestampMilli: int(timestampMilli), + TimestampMilli: int(timestampMicro), Identity: identityKey.GetPublic().Account(), PeerId: peerIdKey.GetPublic().PeerId(), AclId: headId, @@ -251,6 +251,9 @@ func (s *storage) SetRaw(ctx context.Context, keyValue ...*spacesyncproto.StoreK func (s *storage) GetAll(ctx context.Context, key string, get func(decryptor Decryptor, values []innerstorage.KeyValue) error) (err error) { var values []innerstorage.KeyValue err = s.inner.IteratePrefix(ctx, key, func(kv innerstorage.KeyValue) error { + bytes := make([]byte, len(kv.Value.Value)) + copy(bytes, kv.Value.Value) + kv.Value.Value = bytes values = append(values, kv) return nil }) @@ -297,25 +300,32 @@ func (s *storage) readKeysFromAclState(state *list.AclState) (err error) { return err } -func (s *storage) Iterate(ctx context.Context, f func(key string, values []innerstorage.KeyValue) (bool, error)) (err error) { +func (s *storage) Iterate(ctx context.Context, f func(decryptor Decryptor, key string, values []innerstorage.KeyValue) (bool, error)) (err error) { + s.mx.Lock() + defer s.mx.Unlock() var ( curKey = "" + // TODO: reuse buffer values []innerstorage.KeyValue ) err = s.inner.IterateValues(ctx, func(kv innerstorage.KeyValue) (bool, error) { if kv.Key != curKey { if curKey != "" { - iter, err := f(curKey, values) + iter, err := f(s.decrypt, curKey, values) if err != nil { return false, err } if !iter { + values = nil return false, nil } } curKey = kv.Key values = values[:0] } + bytes := make([]byte, len(kv.Value.Value)) + copy(bytes, kv.Value.Value) + kv.Value.Value = bytes values = append(values, kv) return true, nil }) @@ -323,7 +333,7 @@ func (s *storage) Iterate(ctx context.Context, f func(key string, values []inner return err } if len(values) > 0 { - _, err = f(curKey, values) + _, err = f(s.decrypt, curKey, values) } return err } diff --git a/commonspace/spacesyncproto/protos/spacesync.proto b/commonspace/spacesyncproto/protos/spacesync.proto index 87a317d5..b14f76d6 100644 --- a/commonspace/spacesyncproto/protos/spacesync.proto +++ b/commonspace/spacesyncproto/protos/spacesync.proto @@ -232,7 +232,7 @@ message StoreKeyInner { bytes peer = 1; bytes identity = 2; bytes value = 3; - int64 timestampMilli = 4; + int64 timestampMicro = 4; string aclHeadId = 5; string key = 6; } diff --git a/commonspace/spacesyncproto/spacesync.pb.go b/commonspace/spacesyncproto/spacesync.pb.go index 442f1acf..3e4cfb5e 100644 --- a/commonspace/spacesyncproto/spacesync.pb.go +++ b/commonspace/spacesyncproto/spacesync.pb.go @@ -2033,7 +2033,7 @@ type StoreKeyInner struct { Peer []byte `protobuf:"bytes,1,opt,name=peer,proto3" json:"peer,omitempty"` Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - TimestampMilli int64 `protobuf:"varint,4,opt,name=timestampMilli,proto3" json:"timestampMilli,omitempty"` + TimestampMicro int64 `protobuf:"varint,4,opt,name=timestampMicro,proto3" json:"timestampMicro,omitempty"` AclHeadId string `protobuf:"bytes,5,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` } @@ -2100,9 +2100,9 @@ func (m *StoreKeyInner) GetValue() []byte { return nil } -func (m *StoreKeyInner) GetTimestampMilli() int64 { +func (m *StoreKeyInner) GetTimestampMicro() int64 { if m != nil { - return m.TimestampMilli + return m.TimestampMicro } return 0 } @@ -2293,8 +2293,8 @@ var fileDescriptor_80e49f1f4ac27799 = []byte{ 0x4e, 0x99, 0x6e, 0xa6, 0x22, 0xd2, 0x8c, 0xd7, 0x5c, 0x21, 0x5e, 0x78, 0x1f, 0xea, 0x05, 0x93, 0x19, 0xba, 0x25, 0x6d, 0x4e, 0x01, 0xe5, 0xbc, 0x19, 0xc4, 0x02, 0x35, 0xc9, 0x49, 0xf1, 0x8f, 0x86, 0xf7, 0x9d, 0x28, 0xa2, 0x89, 0x58, 0x20, 0xc2, 0x8c, 0xec, 0x05, 0x2d, 0xce, 0x85, 0xa5, - 0x66, 0x8f, 0x2c, 0x35, 0x1d, 0x8f, 0x92, 0x19, 0x8f, 0xab, 0x50, 0xd7, 0x9b, 0xed, 0x20, 0x08, - 0xc3, 0x40, 0xba, 0x58, 0x22, 0x23, 0x58, 0x11, 0x6b, 0x55, 0x65, 0xda, 0xcb, 0x1c, 0x81, 0x1c, + 0x66, 0x8f, 0x2c, 0x35, 0x1d, 0x8f, 0x92, 0x19, 0x8f, 0xab, 0x50, 0xd7, 0x9b, 0xed, 0x20, 0xf0, + 0x92, 0x58, 0xba, 0x58, 0x22, 0x23, 0x58, 0x11, 0x6b, 0x55, 0x65, 0xda, 0xcb, 0x1c, 0x81, 0x1c, 0x28, 0x3d, 0xa3, 0x43, 0xb9, 0xa9, 0xaa, 0x44, 0x1c, 0xf1, 0x83, 0xd4, 0x5c, 0xf7, 0xf4, 0x1f, 0x98, 0xa3, 0x1b, 0x7f, 0x58, 0x50, 0xd9, 0x4b, 0x92, 0x9d, 0xd8, 0xa7, 0x0c, 0xd5, 0x01, 0x1e, 0x47, 0xf4, 0xbc, 0x4f, 0x3d, 0x4e, 0x7d, 0x67, 0x06, 0x39, 0xea, 0x6d, 0x73, 0x10, 0x30, 0x16, @@ -2322,7 +2322,7 @@ var fileDescriptor_80e49f1f4ac27799 = []byte{ 0xd7, 0x71, 0x5c, 0x2c, 0xec, 0x45, 0x34, 0xc2, 0x31, 0xb6, 0x7d, 0x9b, 0xed, 0xe9, 0x04, 0xa9, 0xcc, 0xbb, 0xef, 0xff, 0xfc, 0xaa, 0x65, 0xbd, 0x7c, 0xd5, 0xb2, 0x7e, 0x7f, 0xd5, 0xb2, 0xbe, 0x7f, 0xdd, 0x9a, 0x79, 0xf9, 0xba, 0x35, 0xf3, 0xdb, 0xeb, 0xd6, 0xcc, 0x67, 0xcd, 0xe9, 0xff, - 0x91, 0x39, 0x2e, 0xcb, 0x9f, 0x9b, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xe8, 0x68, 0xd7, + 0x91, 0x39, 0x2e, 0xcb, 0x9f, 0x9b, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x8f, 0x50, 0x36, 0xb6, 0x11, 0x00, 0x00, } @@ -3591,8 +3591,8 @@ func (m *StoreKeyInner) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.TimestampMilli != 0 { - i = encodeVarintSpacesync(dAtA, i, uint64(m.TimestampMilli)) + if m.TimestampMicro != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.TimestampMicro)) i-- dAtA[i] = 0x20 } @@ -4243,8 +4243,8 @@ func (m *StoreKeyInner) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } - if m.TimestampMilli != 0 { - n += 1 + sovSpacesync(uint64(m.TimestampMilli)) + if m.TimestampMicro != 0 { + n += 1 + sovSpacesync(uint64(m.TimestampMicro)) } l = len(m.AclHeadId) if l > 0 { @@ -7933,9 +7933,9 @@ func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimestampMilli", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TimestampMicro", wireType) } - m.TimestampMilli = 0 + m.TimestampMicro = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSpacesync @@ -7945,7 +7945,7 @@ func (m *StoreKeyInner) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TimestampMilli |= int64(b&0x7F) << shift + m.TimestampMicro |= int64(b&0x7F) << shift if b < 0x80 { break } diff --git a/commonspace/sync/sync_test.go b/commonspace/sync/sync_test.go index 7a2fbe0b..0a4d93c0 100644 --- a/commonspace/sync/sync_test.go +++ b/commonspace/sync/sync_test.go @@ -115,14 +115,6 @@ func TestSyncService(t *testing.T) { } require.Equal(t, headUpdate, f.syncHandler.headUpdate) }) - t.Run("handle key value message no op", func(t *testing.T) { - f := newFixture(t) - headUpdate := &testMessage{objectId: "objectId", objectType: spacesyncproto.ObjectType_KeyValue} - err := f.HandleMessage(ctx, headUpdate) - require.NoError(t, err) - f.Close(t) - require.Nil(t, f.syncHandler.headUpdate) - }) t.Run("handle message", func(t *testing.T) { f := newFixture(t) f.syncHandler.toReceiveData = map[string][]*testResponse{ From 47b75137c84654752890bd127b56f29f6bda371e Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 11 Apr 2025 23:04:16 +0200 Subject: [PATCH 42/62] Gen storage and fix tests --- commonspace/headsync/headsync_test.go | 14 ++ .../mock_commonspace/mock_commonspace.go | 15 ++ .../mock_keyvaluestorage.go | 144 +++++++++++++++ .../keyvalue/keyvaluestorage/storage.go | 1 + .../keyvalue/kvinterfaces/interfaces.go | 1 + .../mock_kvinterfaces/mock_kvinterfaces.go | 171 ++++++++++++++++++ .../mock_spacesyncproto.go | 30 +++ .../sync/objectsync/objectsync_test.go | 6 + 8 files changed, 382 insertions(+) create mode 100644 commonspace/object/keyvalue/keyvaluestorage/mock_keyvaluestorage/mock_keyvaluestorage.go create mode 100644 commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces/mock_kvinterfaces.go diff --git a/commonspace/headsync/headsync_test.go b/commonspace/headsync/headsync_test.go index 597b85e4..a0d88636 100644 --- a/commonspace/headsync/headsync_test.go +++ b/commonspace/headsync/headsync_test.go @@ -22,6 +22,9 @@ import ( "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" "github.com/anyproto/any-sync/commonspace/object/acl/syncacl/mock_syncacl" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/mock_keyvaluestorage" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/treemanager" "github.com/anyproto/any-sync/commonspace/object/treemanager/mock_treemanager" "github.com/anyproto/any-sync/commonspace/object/treesyncer" @@ -34,6 +37,7 @@ import ( "github.com/anyproto/any-sync/commonspace/spacesyncproto/mock_spacesyncproto" "github.com/anyproto/any-sync/nodeconf" "github.com/anyproto/any-sync/nodeconf/mock_nodeconf" + "github.com/anyproto/any-sync/testutil/anymock" ) type mockConfig struct { @@ -57,6 +61,8 @@ type headSyncFixture struct { app *app.App configurationMock *mock_nodeconf.MockService + kvMock *mock_kvinterfaces.MockKeyValueService + defStoreMock *mock_keyvaluestorage.MockStorage storageMock *mock_spacestorage.MockSpaceStorage peerManagerMock *mock_peermanager.MockPeerManager credentialProviderMock *mock_credentialprovider.MockCredentialProvider @@ -96,6 +102,11 @@ func newHeadSyncFixture(t *testing.T) *headSyncFixture { treeSyncerMock := mock_treesyncer.NewMockTreeSyncer(ctrl) headStorage := mock_headstorage.NewMockHeadStorage(ctrl) stateStorage := mock_statestorage.NewMockStateStorage(ctrl) + kvMock := mock_kvinterfaces.NewMockKeyValueService(ctrl) + anymock.ExpectComp(kvMock.EXPECT(), kvinterfaces.CName) + defStore := mock_keyvaluestorage.NewMockStorage(ctrl) + kvMock.EXPECT().DefaultStore().Return(defStore).AnyTimes() + defStore.EXPECT().Id().Return("store").AnyTimes() storageMock.EXPECT().HeadStorage().AnyTimes().Return(headStorage) storageMock.EXPECT().StateStorage().AnyTimes().Return(stateStorage) treeSyncerMock.EXPECT().Name().AnyTimes().Return(treesyncer.CName) @@ -108,6 +119,7 @@ func newHeadSyncFixture(t *testing.T) *headSyncFixture { a := &app.App{} a.Register(spaceState). Register(aclMock). + Register(kvMock). Register(mockConfig{}). Register(configurationMock). Register(storageMock). @@ -121,6 +133,8 @@ func newHeadSyncFixture(t *testing.T) *headSyncFixture { spaceState: spaceState, ctrl: ctrl, app: a, + kvMock: kvMock, + defStoreMock: defStore, configurationMock: configurationMock, storageMock: storageMock, diffContainerMock: diffContainerMock, diff --git a/commonspace/mock_commonspace/mock_commonspace.go b/commonspace/mock_commonspace/mock_commonspace.go index 4d414ddf..652ccdc0 100644 --- a/commonspace/mock_commonspace/mock_commonspace.go +++ b/commonspace/mock_commonspace/mock_commonspace.go @@ -17,6 +17,7 @@ import ( aclclient "github.com/anyproto/any-sync/commonspace/acl/aclclient" headsync "github.com/anyproto/any-sync/commonspace/headsync" syncacl "github.com/anyproto/any-sync/commonspace/object/acl/syncacl" + kvinterfaces "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" treesyncer "github.com/anyproto/any-sync/commonspace/object/treesyncer" objecttreebuilder "github.com/anyproto/any-sync/commonspace/objecttreebuilder" spacestorage "github.com/anyproto/any-sync/commonspace/spacestorage" @@ -222,6 +223,20 @@ func (mr *MockSpaceMockRecorder) Init(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockSpace)(nil).Init), arg0) } +// KeyValue mocks base method. +func (m *MockSpace) KeyValue() kvinterfaces.KeyValueService { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "KeyValue") + ret0, _ := ret[0].(kvinterfaces.KeyValueService) + return ret0 +} + +// KeyValue indicates an expected call of KeyValue. +func (mr *MockSpaceMockRecorder) KeyValue() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "KeyValue", reflect.TypeOf((*MockSpace)(nil).KeyValue)) +} + // Storage mocks base method. func (m *MockSpace) Storage() spacestorage.SpaceStorage { m.ctrl.T.Helper() diff --git a/commonspace/object/keyvalue/keyvaluestorage/mock_keyvaluestorage/mock_keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/mock_keyvaluestorage/mock_keyvaluestorage.go new file mode 100644 index 00000000..548d61f1 --- /dev/null +++ b/commonspace/object/keyvalue/keyvaluestorage/mock_keyvaluestorage/mock_keyvaluestorage.go @@ -0,0 +1,144 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage (interfaces: Storage) +// +// Generated by this command: +// +// mockgen -destination mock_keyvaluestorage/mock_keyvaluestorage.go github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage Storage +// +// Package mock_keyvaluestorage is a generated GoMock package. +package mock_keyvaluestorage + +import ( + context "context" + reflect "reflect" + + innerstorage "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage/innerstorage" + spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto" + gomock "go.uber.org/mock/gomock" +) + +// MockStorage is a mock of Storage interface. +type MockStorage struct { + ctrl *gomock.Controller + recorder *MockStorageMockRecorder +} + +// MockStorageMockRecorder is the mock recorder for MockStorage. +type MockStorageMockRecorder struct { + mock *MockStorage +} + +// NewMockStorage creates a new mock instance. +func NewMockStorage(ctrl *gomock.Controller) *MockStorage { + mock := &MockStorage{ctrl: ctrl} + mock.recorder = &MockStorageMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStorage) EXPECT() *MockStorageMockRecorder { + return m.recorder +} + +// GetAll mocks base method. +func (m *MockStorage) GetAll(arg0 context.Context, arg1 string, arg2 func(func(innerstorage.KeyValue) ([]byte, error), []innerstorage.KeyValue) error) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAll", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// GetAll indicates an expected call of GetAll. +func (mr *MockStorageMockRecorder) GetAll(arg0, arg1, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAll", reflect.TypeOf((*MockStorage)(nil).GetAll), arg0, arg1, arg2) +} + +// Id mocks base method. +func (m *MockStorage) Id() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Id") + ret0, _ := ret[0].(string) + return ret0 +} + +// Id indicates an expected call of Id. +func (mr *MockStorageMockRecorder) Id() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Id", reflect.TypeOf((*MockStorage)(nil).Id)) +} + +// InnerStorage mocks base method. +func (m *MockStorage) InnerStorage() innerstorage.KeyValueStorage { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InnerStorage") + ret0, _ := ret[0].(innerstorage.KeyValueStorage) + return ret0 +} + +// InnerStorage indicates an expected call of InnerStorage. +func (mr *MockStorageMockRecorder) InnerStorage() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InnerStorage", reflect.TypeOf((*MockStorage)(nil).InnerStorage)) +} + +// Iterate mocks base method. +func (m *MockStorage) Iterate(arg0 context.Context, arg1 func(func(innerstorage.KeyValue) ([]byte, error), string, []innerstorage.KeyValue) (bool, error)) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Iterate", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Iterate indicates an expected call of Iterate. +func (mr *MockStorageMockRecorder) Iterate(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Iterate", reflect.TypeOf((*MockStorage)(nil).Iterate), arg0, arg1) +} + +// Prepare mocks base method. +func (m *MockStorage) Prepare() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Prepare") + ret0, _ := ret[0].(error) + return ret0 +} + +// Prepare indicates an expected call of Prepare. +func (mr *MockStorageMockRecorder) Prepare() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Prepare", reflect.TypeOf((*MockStorage)(nil).Prepare)) +} + +// Set mocks base method. +func (m *MockStorage) Set(arg0 context.Context, arg1 string, arg2 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Set", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// Set indicates an expected call of Set. +func (mr *MockStorageMockRecorder) Set(arg0, arg1, arg2 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockStorage)(nil).Set), arg0, arg1, arg2) +} + +// SetRaw mocks base method. +func (m *MockStorage) SetRaw(arg0 context.Context, arg1 ...*spacesyncproto.StoreKeyValue) error { + m.ctrl.T.Helper() + varargs := []any{arg0} + for _, a := range arg1 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetRaw", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRaw indicates an expected call of SetRaw. +func (mr *MockStorageMockRecorder) SetRaw(arg0 any, arg1 ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{arg0}, arg1...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRaw", reflect.TypeOf((*MockStorage)(nil).SetRaw), varargs...) +} diff --git a/commonspace/object/keyvalue/keyvaluestorage/storage.go b/commonspace/object/keyvalue/keyvaluestorage/storage.go index 7d03075c..9f8caf13 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/storage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/storage.go @@ -1,3 +1,4 @@ +//go:generate mockgen -destination mock_keyvaluestorage/mock_keyvaluestorage.go github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage Storage package keyvaluestorage import ( diff --git a/commonspace/object/keyvalue/kvinterfaces/interfaces.go b/commonspace/object/keyvalue/kvinterfaces/interfaces.go index 6bc34e13..ce0ea4b3 100644 --- a/commonspace/object/keyvalue/kvinterfaces/interfaces.go +++ b/commonspace/object/keyvalue/kvinterfaces/interfaces.go @@ -1,3 +1,4 @@ +//go:generate mockgen -destination mock_kvinterfaces/mock_kvinterfaces.go github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces KeyValueService package kvinterfaces import ( diff --git a/commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces/mock_kvinterfaces.go b/commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces/mock_kvinterfaces.go new file mode 100644 index 00000000..93026984 --- /dev/null +++ b/commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces/mock_kvinterfaces.go @@ -0,0 +1,171 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces (interfaces: KeyValueService) +// +// Generated by this command: +// +// mockgen -destination mock_kvinterfaces/mock_kvinterfaces.go github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces KeyValueService +// +// Package mock_kvinterfaces is a generated GoMock package. +package mock_kvinterfaces + +import ( + context "context" + reflect "reflect" + + app "github.com/anyproto/any-sync/app" + keyvaluestorage "github.com/anyproto/any-sync/commonspace/object/keyvalue/keyvaluestorage" + spacesyncproto "github.com/anyproto/any-sync/commonspace/spacesyncproto" + peer "github.com/anyproto/any-sync/net/peer" + gomock "go.uber.org/mock/gomock" + drpc "storj.io/drpc" +) + +// MockKeyValueService is a mock of KeyValueService interface. +type MockKeyValueService struct { + ctrl *gomock.Controller + recorder *MockKeyValueServiceMockRecorder +} + +// MockKeyValueServiceMockRecorder is the mock recorder for MockKeyValueService. +type MockKeyValueServiceMockRecorder struct { + mock *MockKeyValueService +} + +// NewMockKeyValueService creates a new mock instance. +func NewMockKeyValueService(ctrl *gomock.Controller) *MockKeyValueService { + mock := &MockKeyValueService{ctrl: ctrl} + mock.recorder = &MockKeyValueServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockKeyValueService) EXPECT() *MockKeyValueServiceMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockKeyValueService) Close(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockKeyValueServiceMockRecorder) Close(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockKeyValueService)(nil).Close), arg0) +} + +// DefaultStore mocks base method. +func (m *MockKeyValueService) DefaultStore() keyvaluestorage.Storage { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DefaultStore") + ret0, _ := ret[0].(keyvaluestorage.Storage) + return ret0 +} + +// DefaultStore indicates an expected call of DefaultStore. +func (mr *MockKeyValueServiceMockRecorder) DefaultStore() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultStore", reflect.TypeOf((*MockKeyValueService)(nil).DefaultStore)) +} + +// HandleMessage mocks base method. +func (m *MockKeyValueService) HandleMessage(arg0 context.Context, arg1 drpc.Message) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HandleMessage", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// HandleMessage indicates an expected call of HandleMessage. +func (mr *MockKeyValueServiceMockRecorder) HandleMessage(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleMessage", reflect.TypeOf((*MockKeyValueService)(nil).HandleMessage), arg0, arg1) +} + +// HandleStoreDiffRequest mocks base method. +func (m *MockKeyValueService) HandleStoreDiffRequest(arg0 context.Context, arg1 *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HandleStoreDiffRequest", arg0, arg1) + ret0, _ := ret[0].(*spacesyncproto.StoreDiffResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HandleStoreDiffRequest indicates an expected call of HandleStoreDiffRequest. +func (mr *MockKeyValueServiceMockRecorder) HandleStoreDiffRequest(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleStoreDiffRequest", reflect.TypeOf((*MockKeyValueService)(nil).HandleStoreDiffRequest), arg0, arg1) +} + +// HandleStoreElementsRequest mocks base method. +func (m *MockKeyValueService) HandleStoreElementsRequest(arg0 context.Context, arg1 spacesyncproto.DRPCSpaceSync_StoreElementsStream) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HandleStoreElementsRequest", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// HandleStoreElementsRequest indicates an expected call of HandleStoreElementsRequest. +func (mr *MockKeyValueServiceMockRecorder) HandleStoreElementsRequest(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleStoreElementsRequest", reflect.TypeOf((*MockKeyValueService)(nil).HandleStoreElementsRequest), arg0, arg1) +} + +// Init mocks base method. +func (m *MockKeyValueService) Init(arg0 *app.App) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Init", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Init indicates an expected call of Init. +func (mr *MockKeyValueServiceMockRecorder) Init(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockKeyValueService)(nil).Init), arg0) +} + +// Name mocks base method. +func (m *MockKeyValueService) Name() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Name") + ret0, _ := ret[0].(string) + return ret0 +} + +// Name indicates an expected call of Name. +func (mr *MockKeyValueServiceMockRecorder) Name() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockKeyValueService)(nil).Name)) +} + +// Run mocks base method. +func (m *MockKeyValueService) Run(arg0 context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Run", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Run indicates an expected call of Run. +func (mr *MockKeyValueServiceMockRecorder) Run(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockKeyValueService)(nil).Run), arg0) +} + +// SyncWithPeer mocks base method. +func (m *MockKeyValueService) SyncWithPeer(arg0 peer.Peer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SyncWithPeer", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SyncWithPeer indicates an expected call of SyncWithPeer. +func (mr *MockKeyValueServiceMockRecorder) SyncWithPeer(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncWithPeer", reflect.TypeOf((*MockKeyValueService)(nil).SyncWithPeer), arg0) +} diff --git a/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go b/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go index edd75aff..082e823e 100644 --- a/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go +++ b/commonspace/spacesyncproto/mock_spacesyncproto/mock_spacesyncproto.go @@ -173,3 +173,33 @@ func (mr *MockDRPCSpaceSyncClientMockRecorder) SpacePush(arg0, arg1 any) *gomock mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpacePush", reflect.TypeOf((*MockDRPCSpaceSyncClient)(nil).SpacePush), arg0, arg1) } + +// StoreDiff mocks base method. +func (m *MockDRPCSpaceSyncClient) StoreDiff(arg0 context.Context, arg1 *spacesyncproto.StoreDiffRequest) (*spacesyncproto.StoreDiffResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreDiff", arg0, arg1) + ret0, _ := ret[0].(*spacesyncproto.StoreDiffResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StoreDiff indicates an expected call of StoreDiff. +func (mr *MockDRPCSpaceSyncClientMockRecorder) StoreDiff(arg0, arg1 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreDiff", reflect.TypeOf((*MockDRPCSpaceSyncClient)(nil).StoreDiff), arg0, arg1) +} + +// StoreElements mocks base method. +func (m *MockDRPCSpaceSyncClient) StoreElements(arg0 context.Context) (spacesyncproto.DRPCSpaceSync_StoreElementsClient, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StoreElements", arg0) + ret0, _ := ret[0].(spacesyncproto.DRPCSpaceSync_StoreElementsClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StoreElements indicates an expected call of StoreElements. +func (mr *MockDRPCSpaceSyncClientMockRecorder) StoreElements(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreElements", reflect.TypeOf((*MockDRPCSpaceSyncClient)(nil).StoreElements), arg0) +} diff --git a/commonspace/sync/objectsync/objectsync_test.go b/commonspace/sync/objectsync/objectsync_test.go index eb104d5d..f3a61e38 100644 --- a/commonspace/sync/objectsync/objectsync_test.go +++ b/commonspace/sync/objectsync/objectsync_test.go @@ -10,6 +10,8 @@ import ( "go.uber.org/mock/gomock" "github.com/anyproto/any-sync/app" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces" + "github.com/anyproto/any-sync/commonspace/object/keyvalue/kvinterfaces/mock_kvinterfaces" "github.com/anyproto/any-sync/commonspace/object/tree/synctree" "github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto" "github.com/anyproto/any-sync/commonspace/object/treemanager" @@ -159,6 +161,7 @@ func TestObjectSync_ApplyRequest(t *testing.T) { type fixture struct { *objectSync objectManager *mock_objectmanager.MockObjectManager + keyValue *mock_kvinterfaces.MockKeyValueService pool *mock_pool.MockService a *app.App ctrl *gomock.Controller @@ -171,13 +174,16 @@ func newFixture(t *testing.T) *fixture { fx.ctrl = gomock.NewController(t) fx.objectManager = mock_objectmanager.NewMockObjectManager(fx.ctrl) fx.pool = mock_pool.NewMockService(fx.ctrl) + fx.keyValue = mock_kvinterfaces.NewMockKeyValueService(fx.ctrl) anymock.ExpectComp(fx.objectManager.EXPECT(), treemanager.CName) anymock.ExpectComp(fx.pool.EXPECT(), pool.CName) + anymock.ExpectComp(fx.keyValue.EXPECT(), kvinterfaces.CName) fx.objectSync = &objectSync{} spaceState := &spacestate.SpaceState{SpaceId: "spaceId"} fx.a.Register(fx.objectManager). Register(spaceState). Register(fx.pool). + Register(fx.keyValue). Register(syncstatus.NewNoOpSyncStatus()). Register(fx.objectSync) require.NoError(t, fx.a.Start(context.Background())) From 40f464aba8e8e1b10495b84278df9f7ac26fab51 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 11 Apr 2025 23:27:42 +0200 Subject: [PATCH 43/62] Fix tests --- commonspace/headsync/headsync_test.go | 38 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/commonspace/headsync/headsync_test.go b/commonspace/headsync/headsync_test.go index a0d88636..3ec4ee72 100644 --- a/commonspace/headsync/headsync_test.go +++ b/commonspace/headsync/headsync_test.go @@ -178,14 +178,16 @@ func TestHeadSync(t *testing.T) { headEntries := []headstorage.HeadsEntry{ { - Id: "id1", - Heads: []string{"h1", "h2"}, - IsDerived: false, + Id: "id1", + Heads: []string{"h1", "h2"}, + CommonSnapshot: "id1", + IsDerived: false, }, { - Id: "id2", - Heads: []string{"h3", "h4"}, - IsDerived: false, + Id: "id2", + Heads: []string{"h3", "h4"}, + CommonSnapshot: "id2", + IsDerived: false, }, } fx.headStorage.EXPECT().IterateEntries(gomock.Any(), gomock.Any(), gomock.Any()). @@ -210,8 +212,9 @@ func TestHeadSync(t *testing.T) { Id: "aclId", Head: "headId", }) - fx.diffContainerMock.EXPECT().NewDiff().Return(fx.diffMock) - fx.diffContainerMock.EXPECT().OldDiff().Return(fx.diffMock) + fx.diffMock.EXPECT().Set([]ldiff.Element{}) + fx.diffContainerMock.EXPECT().NewDiff().AnyTimes().Return(fx.diffMock) + fx.diffContainerMock.EXPECT().OldDiff().AnyTimes().Return(fx.diffMock) fx.diffMock.EXPECT().Hash().AnyTimes().Return("hash") fx.stateStorage.EXPECT().SetHash(gomock.Any(), "hash", "hash").Return(nil) fx.diffSyncerMock.EXPECT().Sync(gomock.Any()).Return(nil) @@ -229,14 +232,16 @@ func TestHeadSync(t *testing.T) { headEntries := []headstorage.HeadsEntry{ { - Id: "id1", - Heads: []string{"id1"}, - IsDerived: true, + Id: "id1", + Heads: []string{"id1"}, + CommonSnapshot: "id1", + IsDerived: true, }, { - Id: "id2", - Heads: []string{"h3", "h4"}, - IsDerived: false, + Id: "id2", + Heads: []string{"h3", "h4"}, + CommonSnapshot: "id2", + IsDerived: false, }, } fx.headStorage.EXPECT().IterateEntries(gomock.Any(), gomock.Any(), gomock.Any()). @@ -258,8 +263,9 @@ func TestHeadSync(t *testing.T) { Id: "aclId", Head: "headId", }) - fx.diffContainerMock.EXPECT().NewDiff().Return(fx.diffMock) - fx.diffContainerMock.EXPECT().OldDiff().Return(fx.diffMock) + fx.diffMock.EXPECT().Set([]ldiff.Element{}) + fx.diffContainerMock.EXPECT().NewDiff().AnyTimes().Return(fx.diffMock) + fx.diffContainerMock.EXPECT().OldDiff().AnyTimes().Return(fx.diffMock) fx.diffMock.EXPECT().Hash().AnyTimes().Return("hash") fx.stateStorage.EXPECT().SetHash(gomock.Any(), "hash", "hash").Return(nil) fx.diffSyncerMock.EXPECT().Sync(gomock.Any()).Return(nil) From f108cbc8c6e1e2f71653abc783e3abcedd747e6b Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 14 Apr 2025 21:12:51 +0200 Subject: [PATCH 44/62] Add store changed test --- commonspace/headsync/diffsyncer_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/commonspace/headsync/diffsyncer_test.go b/commonspace/headsync/diffsyncer_test.go index 6968b4f8..e9915670 100644 --- a/commonspace/headsync/diffsyncer_test.go +++ b/commonspace/headsync/diffsyncer_test.go @@ -118,6 +118,31 @@ func TestDiffSyncer(t *testing.T) { require.NoError(t, fx.diffSyncer.Sync(ctx)) }) + t.Run("diff syncer sync, store changed", func(t *testing.T) { + fx := newHeadSyncFixture(t) + fx.initDiffSyncer(t) + defer fx.stop() + mPeer := rpctest.MockPeer{} + remDiff := NewRemoteDiff(fx.spaceState.SpaceId, fx.clientMock) + fx.treeSyncerMock.EXPECT().ShouldSync(gomock.Any()).Return(true) + fx.aclMock.EXPECT().Id().AnyTimes().Return("aclId") + fx.peerManagerMock.EXPECT(). + GetResponsiblePeers(gomock.Any()). + Return([]peer.Peer{mPeer}, nil) + fx.diffContainerMock.EXPECT().DiffTypeCheck(gomock.Any(), gomock.Any()).Return(true, fx.diffMock, nil) + fx.diffMock.EXPECT(). + Diff(gomock.Any(), gomock.Eq(remDiff)). + Return([]string{"new"}, []string{"changed"}, nil, nil) + fx.deletionStateMock.EXPECT().Filter([]string{"new"}).Return([]string{"new"}).Times(1) + fx.deletionStateMock.EXPECT().Filter([]string{"changed"}).Return([]string{"changed", "store"}).Times(1) + fx.deletionStateMock.EXPECT().Filter(nil).Return(nil).Times(1) + fx.treeSyncerMock.EXPECT().SyncAll(gomock.Any(), mPeer, []string{"changed"}, []string{"new"}).Return(nil) + fx.kvMock.EXPECT().SyncWithPeer(mPeer).Return(nil) + fx.peerManagerMock.EXPECT().KeepAlive(gomock.Any()) + + require.NoError(t, fx.diffSyncer.Sync(ctx)) + }) + t.Run("diff syncer sync conf error", func(t *testing.T) { fx := newHeadSyncFixture(t) fx.initDiffSyncer(t) From 76256022c1613311a16c64e8c874814cf5db593c Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Tue, 15 Apr 2025 13:09:56 +0200 Subject: [PATCH 45/62] Fix diff set store --- .../keyvaluestorage/innerstorage/keyvaluestorage.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go index 363c3032..5dcd6990 100644 --- a/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go +++ b/commonspace/object/keyvalue/keyvaluestorage/innerstorage/keyvaluestorage.go @@ -32,6 +32,7 @@ type storage struct { headStorage headstorage.HeadStorage collection anystore.Collection store anystore.DB + storageName string } func New(ctx context.Context, storageName string, headStorage headstorage.HeadStorage, store anystore.DB) (kv KeyValueStorage, err error) { @@ -51,6 +52,7 @@ func New(ctx context.Context, storageName string, headStorage headstorage.HeadSt } }() storage := &storage{ + storageName: storageName, headStorage: headStorage, collection: collection, store: store, @@ -201,6 +203,10 @@ func (s *storage) Set(ctx context.Context, values ...KeyValue) (err error) { return } s.diff.Set(elements...) + err = s.headStorage.UpdateEntryTx(ctx, headstorage.HeadsUpdate{ + Id: s.storageName, + Heads: []string{s.diff.Hash()}, + }) return } From bd68dda8c30ad7fa6b597a63b760c886b2b426b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 16:30:29 +0000 Subject: [PATCH 46/62] build(deps): bump github.com/quic-go/quic-go from 0.50.1 to 0.51.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.50.1 to 0.51.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.50.1...v0.51.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-version: 0.51.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5df18009..4057c03d 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/multiformats/go-multibase v0.2.0 github.com/multiformats/go-multihash v0.2.3 github.com/prometheus/client_golang v1.21.1 - github.com/quic-go/quic-go v0.50.1 + github.com/quic-go/quic-go v0.51.0 github.com/stretchr/testify v1.10.0 github.com/tyler-smith/go-bip39 v1.1.0 github.com/zeebo/blake3 v0.2.4 diff --git a/go.sum b/go.sum index 17d68734..4caa4d70 100644 --- a/go.sum +++ b/go.sum @@ -293,8 +293,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.50.1 h1:unsgjFIUqW8a2oopkY7YNONpV1gYND6Nt9hnt1PN94Q= -github.com/quic-go/quic-go v0.50.1/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E= +github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= +github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 h1:4WFk6u3sOT6pLa1kQ50ZVdm8BQFgJNA117cepZxtLIg= github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66/go.mod h1:Vp72IJajgeOL6ddqrAhmp7IM9zbTcgkQxD/YdxrVwMw= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= From 68af5f13209817ea56ae5db37cc45f54417fdce7 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Tue, 22 Apr 2025 15:50:17 +0200 Subject: [PATCH 47/62] Fix rollbacks after commit --- .../headsync/statestorage/statestorage.go | 6 +--- commonspace/object/acl/list/storage.go | 23 ++++++------ commonspace/object/tree/objecttree/storage.go | 36 +++++++++---------- commonspace/spacestorage/spacestorage.go | 6 ++-- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/commonspace/headsync/statestorage/statestorage.go b/commonspace/headsync/statestorage/statestorage.go index 9d62376d..cb8ab283 100644 --- a/commonspace/headsync/statestorage/statestorage.go +++ b/commonspace/headsync/statestorage/statestorage.go @@ -108,12 +108,8 @@ func Create(ctx context.Context, state State, store anystore.DB) (st StateStorag return nil, err } storage, err := CreateTx(tx.Context(), state, store) - defer func() { - if err != nil { - tx.Rollback() - } - }() if err != nil { + tx.Rollback() return nil, err } return storage, tx.Commit() diff --git a/commonspace/object/acl/list/storage.go b/commonspace/object/acl/list/storage.go index a54eedf3..9168bbe4 100644 --- a/commonspace/object/acl/list/storage.go +++ b/commonspace/object/acl/list/storage.go @@ -66,12 +66,8 @@ func CreateStorage(ctx context.Context, root *consensusproto.RawRecordWithId, he return nil, err } storage, err := CreateStorageTx(tx.Context(), root, headStorage, store) - defer func() { - if err != nil { - tx.Rollback() - } - }() if err != nil { + tx.Rollback() return nil, err } return storage, tx.Commit() @@ -210,6 +206,13 @@ func (s *storage) AddAll(ctx context.Context, records []StorageRecord) error { if err != nil { return fmt.Errorf("failed to create write tx: %w", err) } + defer func() { + if err != nil { + _ = tx.Rollback() + } else { + err = tx.Commit() + } + }() vals := make([]*anyenc.Value, 0, len(records)) for _, ch := range records { newVal := newStorageRecordValue(ch, arena) @@ -217,20 +220,14 @@ func (s *storage) AddAll(ctx context.Context, records []StorageRecord) error { } err = s.recordsColl.Insert(tx.Context(), vals...) if err != nil { - tx.Rollback() - return nil + return err } head := records[len(records)-1].Id update := headstorage.HeadsUpdate{ Id: s.id, Heads: []string{head}, } - err = s.headStorage.UpdateEntryTx(tx.Context(), update) - if err != nil { - tx.Rollback() - return err - } - return tx.Commit() + return s.headStorage.UpdateEntryTx(tx.Context(), update) } func (s *storage) Id() string { diff --git a/commonspace/object/tree/objecttree/storage.go b/commonspace/object/tree/objecttree/storage.go index 02edf830..2a88ad04 100644 --- a/commonspace/object/tree/objecttree/storage.go +++ b/commonspace/object/tree/objecttree/storage.go @@ -82,12 +82,8 @@ func CreateStorage(ctx context.Context, root *treechangeproto.RawTreeChangeWithI return nil, err } storage, err := CreateStorageTx(tx.Context(), root, headStorage, store) - defer func() { - if err != nil { - tx.Rollback() - } - }() if err != nil { + tx.Rollback() return nil, err } return storage, tx.Commit() @@ -225,13 +221,19 @@ func (s *storage) AddAll(ctx context.Context, changes []StorageChange, heads []s if err != nil { return fmt.Errorf("failed to create write tx: %w", err) } + defer func() { + if err != nil { + tx.Rollback() + } else { + err = tx.Commit() + } + }() for _, ch := range changes { ch.TreeId = s.id newVal := newStorageChangeValue(ch, arena) err = s.changesColl.Insert(tx.Context(), newVal) arena.Reset() if err != nil { - tx.Rollback() return err } } @@ -240,12 +242,7 @@ func (s *storage) AddAll(ctx context.Context, changes []StorageChange, heads []s Heads: heads, CommonSnapshot: &commonSnapshot, } - err = s.headStorage.UpdateEntryTx(tx.Context(), update) - if err != nil { - tx.Rollback() - return err - } - return tx.Commit() + return s.headStorage.UpdateEntryTx(tx.Context(), update) } func (s *storage) AddAllNoError(ctx context.Context, changes []StorageChange, heads []string, commonSnapshot string) error { @@ -255,13 +252,19 @@ func (s *storage) AddAllNoError(ctx context.Context, changes []StorageChange, he if err != nil { return fmt.Errorf("failed to create write tx: %w", err) } + defer func() { + if err != nil { + tx.Rollback() + } else { + err = tx.Commit() + } + }() for _, ch := range changes { ch.TreeId = s.id newVal := newStorageChangeValue(ch, arena) err = s.changesColl.Insert(tx.Context(), newVal) arena.Reset() if err != nil && !errors.Is(err, anystore.ErrDocExists) { - tx.Rollback() return err } } @@ -270,12 +273,7 @@ func (s *storage) AddAllNoError(ctx context.Context, changes []StorageChange, he Heads: heads, CommonSnapshot: &commonSnapshot, } - err = s.headStorage.UpdateEntryTx(tx.Context(), update) - if err != nil { - tx.Rollback() - return err - } - return tx.Commit() + return s.headStorage.UpdateEntryTx(tx.Context(), update) } func (s *storage) Delete(ctx context.Context) error { diff --git a/commonspace/spacestorage/spacestorage.go b/commonspace/spacestorage/spacestorage.go index fac0f398..2c3a5a7a 100644 --- a/commonspace/spacestorage/spacestorage.go +++ b/commonspace/spacestorage/spacestorage.go @@ -66,7 +66,9 @@ func Create(ctx context.Context, store anystore.DB, payload SpaceStorageCreatePa } defer func() { if err != nil { - tx.Rollback() + _ = tx.Rollback() + } else { + err = tx.Commit() } }() changesColl, err := store.Collection(tx.Context(), objecttree.CollName) @@ -110,7 +112,7 @@ func Create(ctx context.Context, store anystore.DB, payload SpaceStorageCreatePa headStorage: headStorage, stateStorage: stateStorage, aclStorage: aclStorage, - }, tx.Commit() + }, nil } func New(ctx context.Context, spaceId string, store anystore.DB) (SpaceStorage, error) { From d2498a1c5657aca303d015b659a89d1a4ff8e15c Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Tue, 22 Apr 2025 16:13:18 +0200 Subject: [PATCH 48/62] Fix tests --- commonspace/spaceutils_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/commonspace/spaceutils_test.go b/commonspace/spaceutils_test.go index 17f0b474..2d5e97d5 100644 --- a/commonspace/spaceutils_test.go +++ b/commonspace/spaceutils_test.go @@ -2,12 +2,14 @@ package commonspace import ( "context" + "errors" "fmt" "math/rand" "sync" "testing" "time" + anystore "github.com/anyproto/any-store" "github.com/anyproto/go-chash" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -803,6 +805,9 @@ func newMultiPeerFixture(t *testing.T, peerNum int) *multiPeerFixture { err := listStorage.AddAll(ctx, []list.StorageRecord{ {RawRecord: rec.Payload, Id: rec.Id, PrevId: prevRec, Order: i + 1, ChangeSize: len(rec.Payload)}, }) + if errors.Is(err, anystore.ErrDocExists) { + continue + } require.NoError(t, err) } } From 7202d8f0b816b8fc5f4c3dfb263b5c0e49446fff Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 23 Apr 2025 18:11:35 +0200 Subject: [PATCH 49/62] Add legacy hash key to state storage --- commonspace/headsync/statestorage/statestorage.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commonspace/headsync/statestorage/statestorage.go b/commonspace/headsync/statestorage/statestorage.go index cb8ab283..b2de213e 100644 --- a/commonspace/headsync/statestorage/statestorage.go +++ b/commonspace/headsync/statestorage/statestorage.go @@ -11,6 +11,7 @@ import ( type State struct { OldHash string NewHash string + LegacyHash string AclId string SettingsId string SpaceId string @@ -33,6 +34,7 @@ const ( idKey = "id" oldHashKey = "oh" newHashKey = "nh" + legacyHashKey = "h" headerKey = "e" aclIdKey = "a" settingsIdKey = "s" @@ -151,6 +153,7 @@ func (s *stateStorage) stateFromDoc(doc anystore.Doc) State { AclId: doc.Value().GetString(aclIdKey), OldHash: doc.Value().GetString(newHashKey), NewHash: doc.Value().GetString(oldHashKey), + LegacyHash: doc.Value().GetString(legacyHashKey), SpaceHeader: doc.Value().GetBytes(headerKey), } } From 02ee0d327bffb20d82b3ba70ce8a1f7359f9e992 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Thu, 24 Apr 2025 16:46:00 +0200 Subject: [PATCH 50/62] Change method --- commonspace/object/acl/list/aclstate.go | 13 ++----- commonspace/object/acl/list/aclstate_test.go | 38 +++----------------- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/commonspace/object/acl/list/aclstate.go b/commonspace/object/acl/list/aclstate.go index 0aded280..d67daf93 100644 --- a/commonspace/object/acl/list/aclstate.go +++ b/commonspace/object/acl/list/aclstate.go @@ -152,17 +152,8 @@ func (st *AclState) CurrentMetadataKey() (crypto.PubKey, error) { } func (st *AclState) FirstMetadataKey() (crypto.PrivKey, error) { - if len(st.readKeyChanges) == 0 { - return nil, ErrNoMetadataKey - } - for _, change := range st.readKeyChanges { - key, exists := st.keys[change] - if !exists { - continue - } - if key.MetadataPrivKey != nil { - return key.MetadataPrivKey, nil - } + if firstKey, ok := st.keys[st.id]; ok && firstKey.MetadataPrivKey != nil { + return firstKey.MetadataPrivKey, nil } return nil, ErrNoMetadataKey } diff --git a/commonspace/object/acl/list/aclstate_test.go b/commonspace/object/acl/list/aclstate_test.go index 5c90b997..2cc178f8 100644 --- a/commonspace/object/acl/list/aclstate_test.go +++ b/commonspace/object/acl/list/aclstate_test.go @@ -2,9 +2,10 @@ package list import ( "crypto/rand" - "github.com/anyproto/any-sync/util/crypto" "testing" + "github.com/anyproto/any-sync/util/crypto" + "github.com/stretchr/testify/require" ) @@ -73,14 +74,12 @@ func TestAclStateIsEmpty(t *testing.T) { func TestAclState_FirstMetadataKey(t *testing.T) { t.Run("returns first metadata key successfully", func(t *testing.T) { - // given privKey, _, err := crypto.GenerateEd25519Key(rand.Reader) require.NoError(t, err) pubKey := privKey.GetPublic() readKey := crypto.NewAES() - state := &AclState{ - readKeyChanges: []string{"recordId"}, + id: "recordId", keys: map[string]AclKeys{ "recordId": { ReadKey: readKey, @@ -89,53 +88,26 @@ func TestAclState_FirstMetadataKey(t *testing.T) { }, }, } - - // when key, err := state.FirstMetadataKey() - - // then require.NoError(t, err) require.Equal(t, privKey, key) }) t.Run("first metadata is nil", func(t *testing.T) { - // given state := &AclState{ - readKeyChanges: []string{"recordId"}, + id: "recordId", keys: map[string]AclKeys{ "recordId": { ReadKey: crypto.NewAES(), }, }, } - - // when key, err := state.FirstMetadataKey() - - // then require.ErrorIs(t, err, ErrNoMetadataKey) require.Nil(t, key) }) t.Run("returns error when no read key changes", func(t *testing.T) { - // given - state := &AclState{readKeyChanges: []string{}} - - // when + state := &AclState{} _, err := state.FirstMetadataKey() - - // then - require.ErrorIs(t, err, ErrNoMetadataKey) - }) - - t.Run("returns error when first read key change is missing", func(t *testing.T) { - // given - state := &AclState{ - readKeyChanges: []string{"missingRecord"}, - keys: make(map[string]AclKeys)} - - // when - _, err := state.FirstMetadataKey() - - // then require.ErrorIs(t, err, ErrNoMetadataKey) }) } From 25bd9ca4a48c7604597c535cfc2bde536792d6df Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 25 Apr 2025 14:15:21 +0200 Subject: [PATCH 51/62] Fix misplaced hashes --- commonspace/headsync/statestorage/statestorage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commonspace/headsync/statestorage/statestorage.go b/commonspace/headsync/statestorage/statestorage.go index b2de213e..65cba616 100644 --- a/commonspace/headsync/statestorage/statestorage.go +++ b/commonspace/headsync/statestorage/statestorage.go @@ -151,8 +151,8 @@ func (s *stateStorage) stateFromDoc(doc anystore.Doc) State { SpaceId: doc.Value().GetString(idKey), SettingsId: doc.Value().GetString(settingsIdKey), AclId: doc.Value().GetString(aclIdKey), - OldHash: doc.Value().GetString(newHashKey), - NewHash: doc.Value().GetString(oldHashKey), + OldHash: doc.Value().GetString(oldHashKey), + NewHash: doc.Value().GetString(newHashKey), LegacyHash: doc.Value().GetString(legacyHashKey), SpaceHeader: doc.Value().GetBytes(headerKey), } From 4a98522b4fa0a3b63a2155314f149c161cd9cf13 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Fri, 25 Apr 2025 16:57:31 +0200 Subject: [PATCH 52/62] Remove legacy hash --- commonspace/headsync/statestorage/statestorage.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/commonspace/headsync/statestorage/statestorage.go b/commonspace/headsync/statestorage/statestorage.go index 65cba616..23eda96b 100644 --- a/commonspace/headsync/statestorage/statestorage.go +++ b/commonspace/headsync/statestorage/statestorage.go @@ -11,7 +11,6 @@ import ( type State struct { OldHash string NewHash string - LegacyHash string AclId string SettingsId string SpaceId string @@ -147,13 +146,21 @@ func (s *stateStorage) SettingsId() string { } func (s *stateStorage) stateFromDoc(doc anystore.Doc) State { + var ( + oldHash = doc.Value().GetString(oldHashKey) + newHash = doc.Value().GetString(newHashKey) + ) + // legacy hash is used for backward compatibility, which was due to a mistake in key names + if oldHash == "" || newHash == "" { + oldHash = doc.Value().GetString(legacyHashKey) + newHash = oldHash + } return State{ SpaceId: doc.Value().GetString(idKey), SettingsId: doc.Value().GetString(settingsIdKey), AclId: doc.Value().GetString(aclIdKey), - OldHash: doc.Value().GetString(oldHashKey), - NewHash: doc.Value().GetString(newHashKey), - LegacyHash: doc.Value().GetString(legacyHashKey), + OldHash: oldHash, + NewHash: newHash, SpaceHeader: doc.Value().GetBytes(headerKey), } } From 81497e20716e04fcaf217fa0891af443f3f86042 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 5 May 2025 13:22:33 +0200 Subject: [PATCH 53/62] Simplify space migrator and fix not removing on error --- .../spacestorage/migration/spacemigrator.go | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/commonspace/spacestorage/migration/spacemigrator.go b/commonspace/spacestorage/migration/spacemigrator.go index 57885ff5..63808b62 100644 --- a/commonspace/spacestorage/migration/spacemigrator.go +++ b/commonspace/spacestorage/migration/spacemigrator.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "os" - "path/filepath" "time" anystore "github.com/anyproto/any-store" @@ -30,7 +28,6 @@ var ErrAlreadyMigrated = errors.New("already migrated") type SpaceMigrator interface { MigrateId(ctx context.Context, id string, progress Progress) error - CheckMigrated(ctx context.Context, id string) (bool, error) } type Progress interface { @@ -47,11 +44,7 @@ type spaceMigrator struct { removeFunc RemoveFunc } -func NewSpaceMigrator(oldProvider oldstorage.SpaceStorageProvider, newProvider spacestorage.SpaceStorageProvider, numParallel int, rootPath string) SpaceMigrator { - return NewSpaceMigratorWithRemoveFunc(oldProvider, newProvider, numParallel, rootPath, nil) -} - -func NewSpaceMigratorWithRemoveFunc(oldProvider oldstorage.SpaceStorageProvider, newProvider spacestorage.SpaceStorageProvider, numParallel int, rootPath string, removeFunc RemoveFunc) SpaceMigrator { +func NewSpaceMigrator(oldProvider oldstorage.SpaceStorageProvider, newProvider spacestorage.SpaceStorageProvider, numParallel int, rootPath string, removeFunc RemoveFunc) SpaceMigrator { return &spaceMigrator{ oldProvider: oldProvider, newProvider: newProvider, @@ -61,32 +54,16 @@ func NewSpaceMigratorWithRemoveFunc(oldProvider oldstorage.SpaceStorageProvider, } } -func (s *spaceMigrator) CheckMigrated(ctx context.Context, id string) (bool, error) { - migrated, storage := s.checkMigrated(ctx, id) - if storage != nil { - return migrated, storage.Close(ctx) - } - return false, nil -} - func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progress) error { migrated, storage := s.checkMigrated(ctx, id) if migrated { storage.Close(ctx) return ErrAlreadyMigrated } - if storage != nil { - if s.removeFunc != nil { - err := s.removeFunc(storage, s.rootPath) - if err != nil { - return fmt.Errorf("migration: failed to remove new storage: %w", err) - } - } else { - err := storage.Close(ctx) - if err != nil { - return fmt.Errorf("migration: failed to close old storage: %w", err) - } - os.RemoveAll(filepath.Join(s.rootPath, id)) + if !migrated { + err := s.removeFunc(storage, s.rootPath) + if err != nil { + return fmt.Errorf("migration: failed to remove new storage: %w", err) } } oldStorage, err := s.oldProvider.WaitSpaceStorage(ctx, id) From 9107daa3c6487a3ca855868ff2b804393f95225c Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Mon, 5 May 2025 13:47:19 +0200 Subject: [PATCH 54/62] Add id to remove func --- commonspace/spacestorage/migration/spacemigrator.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/commonspace/spacestorage/migration/spacemigrator.go b/commonspace/spacestorage/migration/spacemigrator.go index 63808b62..e2adf5cf 100644 --- a/commonspace/spacestorage/migration/spacemigrator.go +++ b/commonspace/spacestorage/migration/spacemigrator.go @@ -34,7 +34,7 @@ type Progress interface { AddDone(done int64) } -type RemoveFunc func(newStorage spacestorage.SpaceStorage, rootPath string) error +type RemoveFunc func(newStorage spacestorage.SpaceStorage, id, rootPath string) error type spaceMigrator struct { oldProvider oldstorage.SpaceStorageProvider @@ -60,11 +60,9 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr storage.Close(ctx) return ErrAlreadyMigrated } - if !migrated { - err := s.removeFunc(storage, s.rootPath) - if err != nil { - return fmt.Errorf("migration: failed to remove new storage: %w", err) - } + err := s.removeFunc(storage, id, s.rootPath) + if err != nil { + return fmt.Errorf("migration: failed to remove new storage: %w", err) } oldStorage, err := s.oldProvider.WaitSpaceStorage(ctx, id) if err != nil { From d878d00052788d181948d62ac77b6966ecb970d1 Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Wed, 16 Apr 2025 23:42:49 +0200 Subject: [PATCH 55/62] Ignore errors on migration --- commonspace/spacestorage/migration/spacemigrator.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/commonspace/spacestorage/migration/spacemigrator.go b/commonspace/spacestorage/migration/spacemigrator.go index e2adf5cf..0eb9c221 100644 --- a/commonspace/spacestorage/migration/spacemigrator.go +++ b/commonspace/spacestorage/migration/spacemigrator.go @@ -121,7 +121,6 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr treeMigrators = append(treeMigrators, objecttree.NewTreeMigrator(crypto.NewKeyStorage(), aclList)) ch <- treeMigrators[i] } - var allErrors []error slices.Sort(storedIds) storedIds = slice.DiscardDuplicatesSorted(storedIds) for _, id := range storedIds { @@ -138,7 +137,6 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr } err = tm.MigrateTreeStorage(ctx, treeStorage, newStorage.HeadStorage(), newStorage.AnyStore()) if err != nil { - allErrors = append(allErrors, fmt.Errorf("migration: failed to migrate tree storage: %w", err)) return } }) @@ -151,9 +149,6 @@ func (s *spaceMigrator) MigrateId(ctx context.Context, id string, progress Progr if err != nil { return fmt.Errorf("migration: failed to wait for executor: %w", err) } - if len(allErrors) > 0 { - return fmt.Errorf("migration failed: %w", errors.Join(allErrors...)) - } if err := s.migrateHash(ctx, oldStorage, newStorage); err != nil { log.Warn("migration: failed to migrate hash", zap.Error(err)) } From f80934c42c4236b11b58cbfcb274184166862eed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 15:40:12 +0000 Subject: [PATCH 56/62] build(deps): bump golang.org/x/sys from 0.31.0 to 0.33.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.33.0. - [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5df18009..c8ab2a59 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( golang.org/x/crypto v0.36.0 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 golang.org/x/net v0.37.0 - golang.org/x/sys v0.31.0 + golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 golang.org/x/tools v0.31.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 17d68734..ebf83c11 100644 --- a/go.sum +++ b/go.sum @@ -416,8 +416,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w 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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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= From 89f984937578f2a7daf931e78b1bd0688c18d45e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:18:13 +0000 Subject: [PATCH 57/62] build(deps): bump golang.org/x/crypto from 0.36.0 to 0.37.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.37.0. - [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.37.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index c8ab2a59..4808f4f0 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( go.uber.org/atomic v1.11.0 go.uber.org/mock v0.5.0 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.36.0 + golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 golang.org/x/net v0.37.0 golang.org/x/sys v0.33.0 @@ -109,8 +109,8 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/image v0.21.0 // indirect golang.org/x/mod v0.24.0 // indirect - golang.org/x/sync v0.12.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/sync v0.14.0 // indirect + golang.org/x/text v0.25.0 // indirect google.golang.org/protobuf v1.36.5 // indirect lukechampine.com/blake3 v1.4.0 // indirect modernc.org/libc v1.61.13 // indirect diff --git a/go.sum b/go.sum index ebf83c11..5138f771 100644 --- a/go.sum +++ b/go.sum @@ -377,8 +377,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -404,8 +404,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ 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/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/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= @@ -421,8 +421,8 @@ golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From f3ca6ed73640a272406c94db810ea967710e19da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:25:12 +0000 Subject: [PATCH 58/62] build(deps): bump golang.org/x/net from 0.37.0 to 0.39.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.37.0 to 0.39.0. - [Commits](https://github.com/golang/net/compare/v0.37.0...v0.39.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.39.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4808f4f0..a118c259 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( go.uber.org/zap v1.27.0 golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 - golang.org/x/net v0.37.0 + golang.org/x/net v0.40.0 golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 golang.org/x/tools v0.31.0 diff --git a/go.sum b/go.sum index 5138f771..3d7dc5b5 100644 --- a/go.sum +++ b/go.sum @@ -397,8 +397,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL 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.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/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= From ec85d9e04acb4fcb1b3ec07dbb22c4865292ca22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:25:19 +0000 Subject: [PATCH 59/62] build(deps): bump go.uber.org/mock from 0.5.0 to 0.5.2 Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.5.0 to 0.5.2. - [Release notes](https://github.com/uber/mock/releases) - [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md) - [Commits](https://github.com/uber/mock/compare/v0.5.0...v0.5.2) --- updated-dependencies: - dependency-name: go.uber.org/mock dependency-version: 0.5.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4808f4f0..87919078 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/tyler-smith/go-bip39 v1.1.0 github.com/zeebo/blake3 v0.2.4 go.uber.org/atomic v1.11.0 - go.uber.org/mock v0.5.0 + go.uber.org/mock v0.5.2 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.38.0 golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 diff --git a/go.sum b/go.sum index 5138f771..ffc7aab8 100644 --- a/go.sum +++ b/go.sum @@ -363,8 +363,8 @@ go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= -go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= +go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= +go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= From 0a781c7a9c5e97d5a7eda48c60fc08f3e48929b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:29:36 +0000 Subject: [PATCH 60/62] build(deps): bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.21.1 to 1.22.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.21.1...v1.22.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-version: 1.22.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 +-- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e9adba98..f39e5ba8 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/mr-tron/base58 v1.2.0 github.com/multiformats/go-multibase v0.2.0 github.com/multiformats/go-multihash v0.2.3 - github.com/prometheus/client_golang v1.21.1 + github.com/prometheus/client_golang v1.22.0 github.com/quic-go/quic-go v0.51.0 github.com/stretchr/testify v1.10.0 github.com/tyler-smith/go-bip39 v1.1.0 @@ -77,7 +77,6 @@ require ( github.com/ipld/go-codec-dagpb v1.6.0 // indirect github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect - github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/go.sum b/go.sum index 73459efd..09e34f1e 100644 --- a/go.sum +++ b/go.sum @@ -96,8 +96,8 @@ github.com/goccy/go-graphviz v0.2.9/go.mod h1:hssjl/qbvUXGmloY81BwXt2nqoApKo7DFg github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -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/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/pprof v0.0.0-20250208200701-d0013a598941 h1:43XjGa6toxLpeksjcxs1jIoIyr+vUfOqY2c6HB4bpoc= @@ -283,8 +283,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= -github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk= -github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= +github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= +github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= From be929ca4fb27f3a0e77c38217ac2d262c67e92d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 10:29:38 +0000 Subject: [PATCH 61/62] build(deps): bump golang.org/x/tools from 0.31.0 to 0.32.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.31.0 to 0.32.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-version: 0.32.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e9adba98..1ca9dde3 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( golang.org/x/net v0.40.0 golang.org/x/sys v0.33.0 golang.org/x/time v0.11.0 - golang.org/x/tools v0.31.0 + golang.org/x/tools v0.33.0 gopkg.in/yaml.v3 v3.0.1 storj.io/drpc v0.0.34 ) diff --git a/go.sum b/go.sum index 73459efd..9d78e8ae 100644 --- a/go.sum +++ b/go.sum @@ -432,8 +432,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn 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/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= 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= From b8ab7ad5bf5a15f22f0a8b1a8fcc88050b2f5184 Mon Sep 17 00:00:00 2001 From: Anthony Akentiev Date: Tue, 6 May 2025 11:55:14 +0100 Subject: [PATCH 62/62] payments: new tier field --- .../mock/mock_paymentserviceclient.go | 82 +++++------ .../paymentservice_tiers.pb.go | 135 ++++++++++++------ .../protos/paymentservice_tiers.proto | 3 + 3 files changed, 140 insertions(+), 80 deletions(-) diff --git a/paymentservice/paymentserviceclient/mock/mock_paymentserviceclient.go b/paymentservice/paymentserviceclient/mock/mock_paymentserviceclient.go index 2716f81b..080941a6 100644 --- a/paymentservice/paymentserviceclient/mock/mock_paymentserviceclient.go +++ b/paymentservice/paymentserviceclient/mock/mock_paymentserviceclient.go @@ -5,6 +5,7 @@ // // mockgen -destination=mock/mock_paymentserviceclient.go -package=mock_paymentserviceclient github.com/anyproto/any-sync/paymentservice/paymentserviceclient AnyPpClientService // + // Package mock_paymentserviceclient is a generated GoMock package. package mock_paymentserviceclient @@ -21,6 +22,7 @@ import ( type MockAnyPpClientService struct { ctrl *gomock.Controller recorder *MockAnyPpClientServiceMockRecorder + isgomock struct{} } // MockAnyPpClientServiceMockRecorder is the mock recorder for MockAnyPpClientService. @@ -41,122 +43,122 @@ func (m *MockAnyPpClientService) EXPECT() *MockAnyPpClientServiceMockRecorder { } // BuySubscription mocks base method. -func (m *MockAnyPpClientService) BuySubscription(arg0 context.Context, arg1 *paymentserviceproto.BuySubscriptionRequestSigned) (*paymentserviceproto.BuySubscriptionResponse, error) { +func (m *MockAnyPpClientService) BuySubscription(ctx context.Context, in *paymentserviceproto.BuySubscriptionRequestSigned) (*paymentserviceproto.BuySubscriptionResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BuySubscription", arg0, arg1) + ret := m.ctrl.Call(m, "BuySubscription", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.BuySubscriptionResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // BuySubscription indicates an expected call of BuySubscription. -func (mr *MockAnyPpClientServiceMockRecorder) BuySubscription(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) BuySubscription(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuySubscription", reflect.TypeOf((*MockAnyPpClientService)(nil).BuySubscription), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuySubscription", reflect.TypeOf((*MockAnyPpClientService)(nil).BuySubscription), ctx, in) } // FinalizeSubscription mocks base method. -func (m *MockAnyPpClientService) FinalizeSubscription(arg0 context.Context, arg1 *paymentserviceproto.FinalizeSubscriptionRequestSigned) (*paymentserviceproto.FinalizeSubscriptionResponse, error) { +func (m *MockAnyPpClientService) FinalizeSubscription(ctx context.Context, in *paymentserviceproto.FinalizeSubscriptionRequestSigned) (*paymentserviceproto.FinalizeSubscriptionResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FinalizeSubscription", arg0, arg1) + ret := m.ctrl.Call(m, "FinalizeSubscription", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.FinalizeSubscriptionResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // FinalizeSubscription indicates an expected call of FinalizeSubscription. -func (mr *MockAnyPpClientServiceMockRecorder) FinalizeSubscription(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) FinalizeSubscription(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeSubscription", reflect.TypeOf((*MockAnyPpClientService)(nil).FinalizeSubscription), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FinalizeSubscription", reflect.TypeOf((*MockAnyPpClientService)(nil).FinalizeSubscription), ctx, in) } // GetAllTiers mocks base method. -func (m *MockAnyPpClientService) GetAllTiers(arg0 context.Context, arg1 *paymentserviceproto.GetTiersRequestSigned) (*paymentserviceproto.GetTiersResponse, error) { +func (m *MockAnyPpClientService) GetAllTiers(ctx context.Context, in *paymentserviceproto.GetTiersRequestSigned) (*paymentserviceproto.GetTiersResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllTiers", arg0, arg1) + ret := m.ctrl.Call(m, "GetAllTiers", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.GetTiersResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetAllTiers indicates an expected call of GetAllTiers. -func (mr *MockAnyPpClientServiceMockRecorder) GetAllTiers(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) GetAllTiers(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllTiers", reflect.TypeOf((*MockAnyPpClientService)(nil).GetAllTiers), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllTiers", reflect.TypeOf((*MockAnyPpClientService)(nil).GetAllTiers), ctx, in) } // GetSubscriptionPortalLink mocks base method. -func (m *MockAnyPpClientService) GetSubscriptionPortalLink(arg0 context.Context, arg1 *paymentserviceproto.GetSubscriptionPortalLinkRequestSigned) (*paymentserviceproto.GetSubscriptionPortalLinkResponse, error) { +func (m *MockAnyPpClientService) GetSubscriptionPortalLink(ctx context.Context, in *paymentserviceproto.GetSubscriptionPortalLinkRequestSigned) (*paymentserviceproto.GetSubscriptionPortalLinkResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSubscriptionPortalLink", arg0, arg1) + ret := m.ctrl.Call(m, "GetSubscriptionPortalLink", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.GetSubscriptionPortalLinkResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetSubscriptionPortalLink indicates an expected call of GetSubscriptionPortalLink. -func (mr *MockAnyPpClientServiceMockRecorder) GetSubscriptionPortalLink(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) GetSubscriptionPortalLink(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionPortalLink", reflect.TypeOf((*MockAnyPpClientService)(nil).GetSubscriptionPortalLink), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionPortalLink", reflect.TypeOf((*MockAnyPpClientService)(nil).GetSubscriptionPortalLink), ctx, in) } // GetSubscriptionStatus mocks base method. -func (m *MockAnyPpClientService) GetSubscriptionStatus(arg0 context.Context, arg1 *paymentserviceproto.GetSubscriptionRequestSigned) (*paymentserviceproto.GetSubscriptionResponse, error) { +func (m *MockAnyPpClientService) GetSubscriptionStatus(ctx context.Context, in *paymentserviceproto.GetSubscriptionRequestSigned) (*paymentserviceproto.GetSubscriptionResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSubscriptionStatus", arg0, arg1) + ret := m.ctrl.Call(m, "GetSubscriptionStatus", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.GetSubscriptionResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetSubscriptionStatus indicates an expected call of GetSubscriptionStatus. -func (mr *MockAnyPpClientServiceMockRecorder) GetSubscriptionStatus(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) GetSubscriptionStatus(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionStatus", reflect.TypeOf((*MockAnyPpClientService)(nil).GetSubscriptionStatus), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionStatus", reflect.TypeOf((*MockAnyPpClientService)(nil).GetSubscriptionStatus), ctx, in) } // GetVerificationEmail mocks base method. -func (m *MockAnyPpClientService) GetVerificationEmail(arg0 context.Context, arg1 *paymentserviceproto.GetVerificationEmailRequestSigned) (*paymentserviceproto.GetVerificationEmailResponse, error) { +func (m *MockAnyPpClientService) GetVerificationEmail(ctx context.Context, in *paymentserviceproto.GetVerificationEmailRequestSigned) (*paymentserviceproto.GetVerificationEmailResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVerificationEmail", arg0, arg1) + ret := m.ctrl.Call(m, "GetVerificationEmail", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.GetVerificationEmailResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // GetVerificationEmail indicates an expected call of GetVerificationEmail. -func (mr *MockAnyPpClientServiceMockRecorder) GetVerificationEmail(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) GetVerificationEmail(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVerificationEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).GetVerificationEmail), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVerificationEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).GetVerificationEmail), ctx, in) } // Init mocks base method. -func (m *MockAnyPpClientService) Init(arg0 *app.App) error { +func (m *MockAnyPpClientService) Init(a *app.App) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Init", arg0) + ret := m.ctrl.Call(m, "Init", a) ret0, _ := ret[0].(error) return ret0 } // Init indicates an expected call of Init. -func (mr *MockAnyPpClientServiceMockRecorder) Init(arg0 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) Init(a any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockAnyPpClientService)(nil).Init), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockAnyPpClientService)(nil).Init), a) } // IsNameValid mocks base method. -func (m *MockAnyPpClientService) IsNameValid(arg0 context.Context, arg1 *paymentserviceproto.IsNameValidRequest) (*paymentserviceproto.IsNameValidResponse, error) { +func (m *MockAnyPpClientService) IsNameValid(ctx context.Context, in *paymentserviceproto.IsNameValidRequest) (*paymentserviceproto.IsNameValidResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsNameValid", arg0, arg1) + ret := m.ctrl.Call(m, "IsNameValid", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.IsNameValidResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // IsNameValid indicates an expected call of IsNameValid. -func (mr *MockAnyPpClientServiceMockRecorder) IsNameValid(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) IsNameValid(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNameValid", reflect.TypeOf((*MockAnyPpClientService)(nil).IsNameValid), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNameValid", reflect.TypeOf((*MockAnyPpClientService)(nil).IsNameValid), ctx, in) } // Name mocks base method. @@ -174,31 +176,31 @@ func (mr *MockAnyPpClientServiceMockRecorder) Name() *gomock.Call { } // VerifyAppStoreReceipt mocks base method. -func (m *MockAnyPpClientService) VerifyAppStoreReceipt(arg0 context.Context, arg1 *paymentserviceproto.VerifyAppStoreReceiptRequestSigned) (*paymentserviceproto.VerifyAppStoreReceiptResponse, error) { +func (m *MockAnyPpClientService) VerifyAppStoreReceipt(ctx context.Context, in *paymentserviceproto.VerifyAppStoreReceiptRequestSigned) (*paymentserviceproto.VerifyAppStoreReceiptResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyAppStoreReceipt", arg0, arg1) + ret := m.ctrl.Call(m, "VerifyAppStoreReceipt", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.VerifyAppStoreReceiptResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // VerifyAppStoreReceipt indicates an expected call of VerifyAppStoreReceipt. -func (mr *MockAnyPpClientServiceMockRecorder) VerifyAppStoreReceipt(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) VerifyAppStoreReceipt(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyAppStoreReceipt", reflect.TypeOf((*MockAnyPpClientService)(nil).VerifyAppStoreReceipt), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyAppStoreReceipt", reflect.TypeOf((*MockAnyPpClientService)(nil).VerifyAppStoreReceipt), ctx, in) } // VerifyEmail mocks base method. -func (m *MockAnyPpClientService) VerifyEmail(arg0 context.Context, arg1 *paymentserviceproto.VerifyEmailRequestSigned) (*paymentserviceproto.VerifyEmailResponse, error) { +func (m *MockAnyPpClientService) VerifyEmail(ctx context.Context, in *paymentserviceproto.VerifyEmailRequestSigned) (*paymentserviceproto.VerifyEmailResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyEmail", arg0, arg1) + ret := m.ctrl.Call(m, "VerifyEmail", ctx, in) ret0, _ := ret[0].(*paymentserviceproto.VerifyEmailResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // VerifyEmail indicates an expected call of VerifyEmail. -func (mr *MockAnyPpClientServiceMockRecorder) VerifyEmail(arg0, arg1 any) *gomock.Call { +func (mr *MockAnyPpClientServiceMockRecorder) VerifyEmail(ctx, in any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).VerifyEmail), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).VerifyEmail), ctx, in) } diff --git a/paymentservice/paymentserviceproto/paymentservice_tiers.pb.go b/paymentservice/paymentserviceproto/paymentservice_tiers.pb.go index 7f6246ae..0f5792d0 100644 --- a/paymentservice/paymentserviceproto/paymentservice_tiers.pb.go +++ b/paymentservice/paymentserviceproto/paymentservice_tiers.pb.go @@ -275,6 +275,8 @@ type TierData struct { // Android platform-specific data: AndroidProductId string `protobuf:"bytes,18,opt,name=androidProductId,proto3" json:"androidProductId,omitempty"` AndroidManageUrl string `protobuf:"bytes,19,opt,name=androidManageUrl,proto3" json:"androidManageUrl,omitempty"` + // something like "limited offer", etc + Offer string `protobuf:"bytes,20,opt,name=offer,proto3" json:"offer,omitempty"` } func (m *TierData) Reset() { *m = TierData{} } @@ -451,6 +453,13 @@ func (m *TierData) GetAndroidManageUrl() string { return "" } +func (m *TierData) GetOffer() string { + if m != nil { + return m.Offer + } + return "" +} + type GetTiersResponse struct { // list of all available tiers Tiers []*TierData `protobuf:"bytes,1,rep,name=tiers,proto3" json:"tiers,omitempty"` @@ -518,46 +527,47 @@ func init() { } var fileDescriptor_597ac3048c641f44 = []byte{ - // 618 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x94, 0xc1, 0x4f, 0x13, 0x4f, - 0x14, 0xc7, 0xbb, 0x85, 0x42, 0xfb, 0x5a, 0xda, 0x65, 0xfa, 0xe3, 0xe7, 0xc4, 0x98, 0xda, 0x6c, - 0x3c, 0x34, 0x90, 0x14, 0x03, 0x1e, 0xbd, 0x20, 0x44, 0x6d, 0x22, 0x4a, 0x16, 0xd0, 0xe8, 0xc5, - 0x8c,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xbe, 0x04, 0xff, 0xfe, 0xd3, 0xfa, 0xb6, 0xe2, 0xbe, 0x76, 0xff, 0x06, 0x00, 0x00, - 0xff, 0xff, 0xca, 0xfa, 0xda, 0x87, 0xe1, 0x04, 0x00, 0x00, + // 627 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x5f, 0x4f, 0x1a, 0x4b, + 0x14, 0x67, 0x51, 0x14, 0x0e, 0x08, 0xeb, 0xa0, 0xf7, 0x4e, 0x6e, 0x6e, 0xb8, 0x84, 0xdc, 0x07, + 0xa2, 0x09, 0x36, 0xda, 0xc7, 0xbe, 0x58, 0x4d, 0x5b, 0x92, 0xda, 0x9a, 0x55, 0xdb, 0xb4, 0x2f, + 0xcd, 0x74, 0xe7, 0x88, 0x13, 0x97, 0x99, 0xed, 0xcc, 0xa0, 0xe1, 0x5b, 0xf8, 0xb1, 0xfa, 0xe8, + 0x5b, 0xfb, 0xd8, 0xe8, 0x17, 0x69, 0x76, 0x40, 0x66, 0x41, 0x93, 0xbe, 0x00, 0xbf, 0x3f, 0xe7, + 0x97, 0x73, 0xce, 0x9e, 0x05, 0x0e, 0x53, 0x36, 0x1e, 0xa2, 0xb4, 0x06, 0xf5, 0x95, 0x88, 0x71, + 0x67, 0x1e, 0xa6, 0x5a, 0x59, 0xb5, 0xe3, 0x3e, 0xcd, 0x82, 0xf4, 0xc5, 0x0a, 0xd4, 0xa6, 0xe7, + 0xb4, 0xce, 0x36, 0xac, 0xbe, 0x42, 0x66, 0x47, 0x1a, 0x49, 0x1b, 0xaa, 0x1c, 0x4d, 0xac, 0x45, + 0x6a, 0x85, 0x92, 0x34, 0x68, 0x07, 0xdd, 0x4a, 0x94, 0xa7, 0x3a, 0x7d, 0x68, 0xbc, 0x46, 0x7b, + 0x9a, 0x95, 0x47, 0xf8, 0x6d, 0x84, 0xc6, 0x92, 0x16, 0x80, 0xba, 0x96, 0xa8, 0xf7, 0xe5, 0xb8, + 0xcf, 0xa7, 0x35, 0x39, 0x86, 0xfc, 0x05, 0x2b, 0x89, 0x8a, 0x59, 0x82, 0xb4, 0xe8, 0xb4, 0x29, + 0xea, 0xbc, 0x87, 0xcd, 0x85, 0xa8, 0x13, 0x31, 0x90, 0xc8, 0x09, 0x85, 0xd5, 0x94, 0x8d, 0x13, + 0xc5, 0x26, 0x69, 0xb5, 0xe8, 0x01, 0x92, 0x7f, 0xa1, 0x62, 0xc4, 0x40, 0xba, 0x66, 0x5d, 0x5a, + 0x2d, 0xf2, 0x44, 0xe7, 0x47, 0x09, 0xca, 0x59, 0xdc, 0x21, 0xb3, 0x8c, 0xd4, 0xa1, 0x28, 0x26, + 0xf5, 0x6b, 0x51, 0x51, 0x70, 0x42, 0x60, 0x59, 0xb2, 0xe1, 0x43, 0x0f, 0xee, 0xf7, 0xe2, 0xb8, + 0x4b, 0x8f, 0xc6, 0x25, 0xff, 0x40, 0x59, 0x98, 0xfd, 0xd8, 0x8a, 0x2b, 0xa4, 0xcb, 0xed, 0xa0, + 0x5b, 0x8e, 0x66, 0x38, 0x9b, 0x4b, 0x98, 0x53, 0x34, 0x96, 0x96, 0x9c, 0x32, 0x45, 0xa4, 0x03, + 0x35, 0x61, 0xde, 0x08, 0xce, 0x51, 0x66, 0xdd, 0xd0, 0x15, 0xa7, 0xce, 0x71, 0x64, 0x1b, 0x20, + 0x45, 0x2d, 0x14, 0x3f, 0x1d, 0xa7, 0x48, 0x57, 0xdb, 0x41, 0xb7, 0xbe, 0x5b, 0xed, 0x1d, 0xcf, + 0xa8, 0x28, 0x27, 0x67, 0x6d, 0x4e, 0xd0, 0x07, 0x96, 0x8c, 0x90, 0x96, 0xdd, 0x4c, 0x79, 0x8a, + 0x3c, 0x83, 0x66, 0xaa, 0x45, 0x8c, 0x27, 0x56, 0x8b, 0x14, 0xcf, 0x0c, 0x3f, 0xc8, 0x9e, 0x35, + 0xad, 0x38, 0xe7, 0x53, 0x12,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0xeb, 0x1e, 0x9d, 0xc9, 0x4b, 0xa9, + 0xae, 0x65, 0x58, 0x20, 0x7f, 0x43, 0x33, 0x4f, 0x27, 0x62, 0x28, 0x2c, 0xf2, 0x30, 0x20, 0x04, + 0xea, 0x5e, 0x38, 0x64, 0x63, 0x13, 0x16, 0x49, 0x13, 0x1a, 0x9e, 0xfb, 0x88, 0x78, 0x69, 0xc2, + 0x25, 0xb2, 0x01, 0xa1, 0x27, 0x8f, 0x94, 0xb4, 0x17, 0x26, 0x5c, 0x9e, 0xb7, 0x7e, 0x42, 0xa6, + 0x4d, 0x58, 0x7a, 0xf9, 0xe2, 0xfb, 0x5d, 0x2b, 0xb8, 0xbd, 0x6b, 0x05, 0xbf, 0xee, 0x5a, 0xc1, + 0xcd, 0x7d, 0xab, 0x70, 0x7b, 0xdf, 0x2a, 0xfc, 0xbc, 0x6f, 0x15, 0x3e, 0x77, 0xfe, 0xfc, 0x57, + 0xf6, 0x75, 0xc5, 0x7d, 0xed, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc5, 0xbe, 0x42, 0x45, 0xf7, + 0x04, 0x00, 0x00, } func (m *Feature) Marshal() (dAtA []byte, err error) { @@ -684,6 +694,15 @@ func (m *TierData) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Offer) > 0 { + i -= len(m.Offer) + copy(dAtA[i:], m.Offer) + i = encodeVarintPaymentserviceTiers(dAtA, i, uint64(len(m.Offer))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa2 + } if len(m.AndroidManageUrl) > 0 { i -= len(m.AndroidManageUrl) copy(dAtA[i:], m.AndroidManageUrl) @@ -1002,6 +1021,10 @@ func (m *TierData) Size() (n int) { if l > 0 { n += 2 + l + sovPaymentserviceTiers(uint64(l)) } + l = len(m.Offer) + if l > 0 { + n += 2 + l + sovPaymentserviceTiers(uint64(l)) + } return n } @@ -1865,6 +1888,38 @@ func (m *TierData) Unmarshal(dAtA []byte) error { } m.AndroidManageUrl = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 20: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Offer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPaymentserviceTiers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPaymentserviceTiers + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPaymentserviceTiers + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Offer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPaymentserviceTiers(dAtA[iNdEx:]) diff --git a/paymentservice/paymentserviceproto/protos/paymentservice_tiers.proto b/paymentservice/paymentserviceproto/protos/paymentservice_tiers.proto index 4369e2fb..f4a6f6b4 100644 --- a/paymentservice/paymentserviceproto/protos/paymentservice_tiers.proto +++ b/paymentservice/paymentserviceproto/protos/paymentservice_tiers.proto @@ -73,6 +73,9 @@ message TierData { // Android platform-specific data: string androidProductId = 18; string androidManageUrl = 19; + + // something like "limited offer", etc + string offer = 20; } message GetTiersResponse {