Skip to content

Commit

Permalink
Update any-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrakhman committed Jan 25, 2024
1 parent bc86b4a commit db03632
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 9 deletions.
73 changes: 73 additions & 0 deletions etc/configs/any-sync-node1.yml
Original file line number Diff line number Diff line change
@@ -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: { }
73 changes: 73 additions & 0 deletions etc/configs/any-sync-node2.yml
Original file line number Diff line number Diff line change
@@ -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: { }
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
9 changes: 5 additions & 4 deletions nodespace/rpchandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions nodespace/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ 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"
"github.com/anyproto/any-sync/consensus/consensusproto"
"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 {
Expand All @@ -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))
Expand Down

0 comments on commit db03632

Please sign in to comment.