From db036325a4992206d97b627368d344290e70d66d Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 25 Jan 2024 15:14:08 +0100 Subject: [PATCH] Update any-sync --- etc/configs/any-sync-node1.yml | 73 ++++++++++++++++++++++++++++++++++ etc/configs/any-sync-node2.yml | 73 ++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 8 +++- nodespace/rpchandler.go | 9 +++-- nodespace/space.go | 9 ++++- 6 files changed, 165 insertions(+), 9 deletions(-) create mode 100755 etc/configs/any-sync-node1.yml create mode 100755 etc/configs/any-sync-node2.yml diff --git a/etc/configs/any-sync-node1.yml b/etc/configs/any-sync-node1.yml new file mode 100755 index 0000000..6975ba4 --- /dev/null +++ b/etc/configs/any-sync-node1.yml @@ -0,0 +1,73 @@ +account: + peerId: 12D3KooWKnXTtbveMDUFfeSqR5dt9a4JW66tZQXG7C7PdDh3vqGu + peerKey: /Ou28/uU/z3BbGmkHMV5ev0mwl6lJI/NNniFlMm2gOeUHDfed/zbwYZLbPt1B0sujNx0DGKUgUTUXy/SE7biwg== + signingKey: /Ou28/uU/z3BbGmkHMV5ev0mwl6lJI/NNniFlMm2gOeUHDfed/zbwYZLbPt1B0sujNx0DGKUgUTUXy/SE7biwg== +apiServer: + listenAddr: 127.0.0.1:8180 +drpc: + stream: + timeoutMilliseconds: 1000 + maxMsgSizeMb: 256 +yamux: + listenAddrs: + - 127.0.0.1:4430 + writeTimeoutSec: 10 + dialTimeoutSec: 10 +quic: + listenAddrs: + - 127.0.0.1:5430 + writeTimeoutSec: 10 + dialTimeoutSec: 10 +network: + id: 64384a038e697b7fce2f447e + networkId: N4N1wDHFpFpovXBqdbq2TDXE9tXdXbtV1eTJFpKJW4YeaJqR + nodes: + - peerId: 12D3KooWKLCajM89S8unbt3tgGbRLgmiWnFZT3adn9A5pQciBSLa + addresses: + - "127.0.0.1:4830" + types: + - coordinator + - peerId: 12D3KooWKnXTtbveMDUFfeSqR5dt9a4JW66tZQXG7C7PdDh3vqGu + addresses: + - 127.0.0.1:4430 + types: + - tree + - peerId: 12D3KooWKgVN2kW8xw5Uvm2sLUnkeUNQYAvcWvF58maTzev7FjPi + addresses: + - 127.0.0.1:4431 + types: + - tree + - peerId: 12D3KooWCUPYuMnQhu9yREJgQyjcz8zWY83rZGmDLwb9YR6QkbZX + addresses: + - 127.0.0.1:4432 + types: + - tree + - peerId: 12D3KooWQxiZ5a7vcy4DTJa8Gy1eVUmwb5ojN4SrJC9Rjxzigw6C + addresses: + - 127.0.0.1:4730 + types: + - file + - peerId: 12D3KooWNT4hbNKXeFuDtdQ13ZbhQ1oJJ2AVWgAQVRrCj6Zb5wxk + addresses: + - 127.0.0.1:4530 + types: + - consensus + creationTime: 2023-04-13T20:29:23.453806629+02:00 +networkStorePath: . +networkUpdateIntervalSec: 600 +space: + gcTTL: 60 + syncPeriod: 20 +storage: + path: db/node1 +metric: + addr: ":7001" +nodeSync: + hotSync: + simultaneousRequests: 400 + syncOnStart: true + periodicSyncHours: 2 +log: + production: false + defaultLevel: "" + namedLevels: { } diff --git a/etc/configs/any-sync-node2.yml b/etc/configs/any-sync-node2.yml new file mode 100755 index 0000000..6f27f9b --- /dev/null +++ b/etc/configs/any-sync-node2.yml @@ -0,0 +1,73 @@ +account: + peerId: 12D3KooWKgVN2kW8xw5Uvm2sLUnkeUNQYAvcWvF58maTzev7FjPi + peerKey: ckI1ThxMQmAWH48so5jT614HNg4VppB/3jTfh1cdrzSSkFuVPiGzSDJcsgFLsRGW2WT0a8ymqtc4hog5Z4mdfQ== + signingKey: ckI1ThxMQmAWH48so5jT614HNg4VppB/3jTfh1cdrzSSkFuVPiGzSDJcsgFLsRGW2WT0a8ymqtc4hog5Z4mdfQ== +apiServer: + listenAddr: 127.0.0.1:8181 +drpc: + stream: + timeoutMilliseconds: 1000 + maxMsgSizeMb: 256 +yamux: + listenAddrs: + - 127.0.0.1:4431 + writeTimeoutSec: 10 + dialTimeoutSec: 10 +quic: + listenAddrs: + - 127.0.0.1:5431 + writeTimeoutSec: 10 + dialTimeoutSec: 10 +network: + id: 64384a038e697b7fce2f447e + networkId: N4N1wDHFpFpovXBqdbq2TDXE9tXdXbtV1eTJFpKJW4YeaJqR + nodes: + - peerId: 12D3KooWKLCajM89S8unbt3tgGbRLgmiWnFZT3adn9A5pQciBSLa + addresses: + - "127.0.0.1:4830" + types: + - coordinator + - peerId: 12D3KooWKnXTtbveMDUFfeSqR5dt9a4JW66tZQXG7C7PdDh3vqGu + addresses: + - 127.0.0.1:4430 + types: + - tree + - peerId: 12D3KooWKgVN2kW8xw5Uvm2sLUnkeUNQYAvcWvF58maTzev7FjPi + addresses: + - 127.0.0.1:4431 + types: + - tree + - peerId: 12D3KooWCUPYuMnQhu9yREJgQyjcz8zWY83rZGmDLwb9YR6QkbZX + addresses: + - 127.0.0.1:4432 + types: + - tree + - peerId: 12D3KooWQxiZ5a7vcy4DTJa8Gy1eVUmwb5ojN4SrJC9Rjxzigw6C + addresses: + - 127.0.0.1:4730 + types: + - file + - peerId: 12D3KooWNT4hbNKXeFuDtdQ13ZbhQ1oJJ2AVWgAQVRrCj6Zb5wxk + addresses: + - 127.0.0.1:4530 + types: + - consensus + creationTime: 2023-04-13T20:29:23.453806629+02:00 +networkStorePath: . +networkUpdateIntervalSec: 600 +space: + gcTTL: 60 + syncPeriod: 20 +storage: + path: db/node2 +metric: + addr: ":7002" +nodeSync: + hotSync: + simultaneousRequests: 400 + syncOnStart: true + periodicSyncHours: 2 +log: + production: false + defaultLevel: "" + namedLevels: { } diff --git a/go.mod b/go.mod index 7bb91b9..501cbec 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/ahmetb/govvv v0.3.0 github.com/akrylysov/pogreb v0.10.2-0.20231113223812-90db0cc40ff5 - github.com/anyproto/any-sync v0.3.18 + github.com/anyproto/any-sync v0.3.19-0.20240125134459-30920610e6c2 github.com/anyproto/go-chash v0.1.0 github.com/gogo/protobuf v1.3.2 github.com/prometheus/client_golang v1.17.0 diff --git a/go.sum b/go.sum index 3b76c11..81e436e 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,12 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/anyproto/any-sync v0.3.18 h1:hHhGcFChzPaahviqA9P6JpcXgE4DhR/YuGsezW+4ve0= -github.com/anyproto/any-sync v0.3.18/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E= +github.com/anyproto/any-sync v0.3.19-0.20240125122747-85d1cf16566a h1:0cZBO1x/fqGArQDuvNZtJgjYPeYPFWvrP84/gjmczGU= +github.com/anyproto/any-sync v0.3.19-0.20240125122747-85d1cf16566a/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E= +github.com/anyproto/any-sync v0.3.19-0.20240125133140-9a4c0403e539 h1:5hy61OQXMHUyYlOpt1pNYy/x+6fmKbSPaNAY3+CMDrY= +github.com/anyproto/any-sync v0.3.19-0.20240125133140-9a4c0403e539/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E= +github.com/anyproto/any-sync v0.3.19-0.20240125134459-30920610e6c2 h1:420qrdufvSNgvVvrD7+LBoucjHopIgFLlAhS1UnA0Ps= +github.com/anyproto/any-sync v0.3.19-0.20240125134459-30920610e6c2/go.mod h1:exw/7+W3jfkuaVWsStQD8s8aLFT9L2NBiW/DVwTNi/E= 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= diff --git a/nodespace/rpchandler.go b/nodespace/rpchandler.go index 34a22b1..05a848b 100644 --- a/nodespace/rpchandler.go +++ b/nodespace/rpchandler.go @@ -3,10 +3,12 @@ package nodespace import ( "context" "encoding/hex" + "errors" "math" "time" "github.com/anyproto/any-sync/commonspace" + "github.com/anyproto/any-sync/commonspace/object/acl/list" "github.com/anyproto/any-sync/commonspace/spacesyncproto" "github.com/anyproto/any-sync/consensus/consensusproto" "github.com/anyproto/any-sync/metric" @@ -46,14 +48,13 @@ func (r *rpcHandler) AclAddRecord(ctx context.Context, request *spacesyncproto.A acl.Lock() defer acl.Unlock() err = acl.AddRawRecord(rawRecordWithId) - if err != nil { + if err != nil && !errors.Is(err, list.ErrRecordAlreadyExists) { return } - resp = &spacesyncproto.AclAddRecordResponse{ + return &spacesyncproto.AclAddRecordResponse{ RecordId: rawRecordWithId.Id, Payload: rawRecordWithId.Payload, - } - return + }, nil } func (r *rpcHandler) AclGetRecords(ctx context.Context, request *spacesyncproto.AclGetRecordsRequest) (resp *spacesyncproto.AclGetRecordsResponse, err error) { diff --git a/nodespace/space.go b/nodespace/space.go index 0b24d21..629532e 100644 --- a/nodespace/space.go +++ b/nodespace/space.go @@ -2,7 +2,8 @@ package nodespace import ( "context" - "github.com/anyproto/any-sync-node/nodestorage" + "time" + "github.com/anyproto/any-sync/app/logger" "github.com/anyproto/any-sync/commonspace" "github.com/anyproto/any-sync/consensus/consensusclient" @@ -10,7 +11,8 @@ import ( "github.com/anyproto/any-sync/consensus/consensusproto/consensuserr" "github.com/anyproto/any-sync/net/rpc/rpcerr" "go.uber.org/zap" - "time" + + "github.com/anyproto/any-sync-node/nodestorage" ) type NodeSpace interface { @@ -37,6 +39,9 @@ func (s *nodeSpace) AddConsensusRecords(recs []*consensusproto.RawRecordWithId) log := s.log.With(zap.Int("len(records)", len(recs)), zap.String("firstId", recs[0].Id)) s.Acl().Lock() defer s.Acl().Unlock() + for i := 0; i < len(recs)/2; i++ { + recs[i], recs[len(recs)-i-1] = recs[len(recs)-i-1], recs[i] + } err := s.Acl().AddRawRecords(recs) if err != nil { log.Warn("failed to add consensus records", zap.Error(err))