Skip to content

Commit 2b94d32

Browse files
authored
Merge pull request #60 from anyproto/GO-5411-drpc-encoding
GO-5411 drpc encoding
2 parents a1975ae + 481da10 commit 2b94d32

File tree

6 files changed

+91
-145
lines changed

6 files changed

+91
-145
lines changed

cmd/consensusnode.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"github.com/anyproto/any-sync-consensusnode/account"
8-
"github.com/anyproto/any-sync-consensusnode/config"
9-
"github.com/anyproto/any-sync-consensusnode/consensusrpc"
10-
"github.com/anyproto/any-sync-consensusnode/db"
11-
"github.com/anyproto/any-sync-consensusnode/stream"
7+
"net/http"
8+
_ "net/http/pprof"
9+
"os"
10+
"os/signal"
11+
"syscall"
12+
"time"
13+
1214
"github.com/anyproto/any-sync/app"
1315
"github.com/anyproto/any-sync/app/logger"
1416
"github.com/anyproto/any-sync/coordinator/coordinatorclient"
@@ -23,20 +25,20 @@ import (
2325
"github.com/anyproto/any-sync/nodeconf"
2426
"github.com/anyproto/any-sync/nodeconf/nodeconfstore"
2527
"go.uber.org/zap"
28+
29+
"github.com/anyproto/any-sync-consensusnode/account"
30+
"github.com/anyproto/any-sync-consensusnode/config"
31+
"github.com/anyproto/any-sync-consensusnode/consensusrpc"
32+
"github.com/anyproto/any-sync-consensusnode/db"
33+
"github.com/anyproto/any-sync-consensusnode/stream"
2634
// import this to keep govvv in go.mod on mod tidy
2735
_ "github.com/ahmetb/govvv/integration-test/app-different-package/mypkg"
28-
"net/http"
29-
_ "net/http/pprof"
30-
"os"
31-
"os/signal"
32-
"syscall"
33-
"time"
3436
)
3537

3638
var log = logger.NewNamed("main")
3739

3840
var (
39-
flagConfigFile = flag.String("c", "etc/consensus-config.yml", "path to config file")
41+
flagConfigFile = flag.String("c", "etc/any-sync-consensusnode.yml", "path to config file")
4042
flagVersion = flag.Bool("v", false, "show version and exit")
4143
flagHelp = flag.Bool("h", false, "show help and exit")
4244
)

consensusrpc/consensusrpc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (c *consensusRpc) RecordAdd(ctx context.Context, req *consensusproto.Record
126126

127127
// unmarshal payload as a consensus record
128128
rec := &consensusproto.Record{}
129-
if e := rec.Unmarshal(req.Record.Payload); e != nil {
129+
if e := rec.UnmarshalVT(req.Record.Payload); e != nil {
130130
err = consensuserr.ErrInvalidPayload
131131
return
132132
}
@@ -143,7 +143,7 @@ func (c *consensusRpc) RecordAdd(ctx context.Context, req *consensusproto.Record
143143
return
144144
}
145145
// marshal with identity and sign
146-
payload, err := req.Record.Marshal()
146+
payload, err := req.Record.MarshalVT()
147147
if err != nil {
148148
log.Warn("can't marshal payload", zap.Error(err))
149149
err = consensuserr.ErrUnexpected

consensusrpc/consensusrpc_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func testRecord(prevId string) (rId *consensusproto.RawRecordWithId, rawRec *con
3838
Timestamp: time.Now().Unix(),
3939
}
4040

41-
recPayload, _ := rec.Marshal()
41+
recPayload, _ := rec.MarshalVT()
4242
rawRec = &consensusproto.RawRecord{
4343
Payload: recPayload,
4444
}
45-
payload, _ := rawRec.Marshal()
45+
payload, _ := rawRec.MarshalVT()
4646
id, _ := cidutil.NewCidFromBytes(payload)
4747
return &consensusproto.RawRecordWithId{
4848
Payload: payload,
@@ -126,7 +126,7 @@ func TestConsensusRpc_RecordAdd(t *testing.T) {
126126
assert.NotEmpty(t, resp.Payload)
127127

128128
var result = &consensusproto.RawRecord{}
129-
require.NoError(t, result.Unmarshal(resp.Payload))
129+
require.NoError(t, result.UnmarshalVT(resp.Payload))
130130
assert.NotEmpty(t, result.AcceptorTimestamp)
131131
})
132132
t.Run("invalid peer", func(t *testing.T) {

etc/any-sync-consensusnode.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ drpc:
1212
stream:
1313
timeoutMilliseconds: 1000
1414
maxMsgSizeMb: 256
15+
snappy: true
1516
yamux:
1617
listenAddrs:
1718
- 127.0.0.1:4530

go.mod

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/anyproto/any-sync-consensusnode
22

3-
go 1.23.0
3+
go 1.23.8
44

5-
toolchain go1.23.6
5+
toolchain go1.24.0
66

77
require (
88
github.com/ahmetb/govvv v0.3.0
9-
github.com/anyproto/any-sync v0.8.3
9+
github.com/anyproto/any-sync v0.9.0
1010
github.com/cheggaaa/mb/v3 v3.0.2
1111
github.com/stretchr/testify v1.10.0
1212
go.mongodb.org/mongo-driver v1.17.4
@@ -21,7 +21,6 @@ require (
2121
github.com/anyproto/go-chash v0.1.0 // indirect
2222
github.com/anyproto/go-slip10 v1.0.0 // indirect
2323
github.com/anyproto/go-slip21 v1.0.0 // indirect
24-
github.com/anyproto/protobuf v1.3.3-0.20240814124528-72b8c7e0e0f5 // indirect
2524
github.com/beorn7/perks v1.0.1 // indirect
2625
github.com/btcsuite/btcd v0.22.1 // indirect
2726
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
@@ -31,38 +30,36 @@ require (
3130
github.com/davecgh/go-spew v1.1.1 // indirect
3231
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
3332
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
34-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
3533
github.com/gobwas/glob v0.2.3 // indirect
3634
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
37-
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
3835
github.com/hashicorp/yamux v0.1.2 // indirect
3936
github.com/ipfs/go-cid v0.5.0 // indirect
40-
github.com/ipfs/go-log/v2 v2.5.1 // indirect
37+
github.com/ipfs/go-log/v2 v2.6.0 // indirect
4138
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
4239
github.com/klauspost/compress v1.18.0 // indirect
4340
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
4441
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
45-
github.com/libp2p/go-libp2p v0.41.1 // indirect
42+
github.com/libp2p/go-libp2p v0.42.0 // indirect
4643
github.com/mattn/go-isatty v0.0.20 // indirect
4744
github.com/minio/sha256-simd v1.0.1 // indirect
4845
github.com/montanaflynn/stats v0.7.1 // indirect
4946
github.com/mr-tron/base58 v1.2.0 // indirect
5047
github.com/multiformats/go-base32 v0.1.0 // indirect
5148
github.com/multiformats/go-base36 v0.2.0 // indirect
52-
github.com/multiformats/go-multiaddr v0.15.0 // indirect
49+
github.com/multiformats/go-multiaddr v0.16.0 // indirect
5350
github.com/multiformats/go-multibase v0.2.0 // indirect
54-
github.com/multiformats/go-multicodec v0.9.0 // indirect
51+
github.com/multiformats/go-multicodec v0.9.1 // indirect
5552
github.com/multiformats/go-multihash v0.2.3 // indirect
56-
github.com/multiformats/go-multistream v0.6.0 // indirect
53+
github.com/multiformats/go-multistream v0.6.1 // indirect
5754
github.com/multiformats/go-varint v0.0.7 // indirect
5855
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
59-
github.com/onsi/ginkgo/v2 v2.22.2 // indirect
56+
github.com/planetscale/vtprotobuf v0.6.0 // indirect
6057
github.com/pmezard/go-difflib v1.0.0 // indirect
6158
github.com/prometheus/client_golang v1.22.0 // indirect
62-
github.com/prometheus/client_model v0.6.1 // indirect
63-
github.com/prometheus/common v0.62.0 // indirect
64-
github.com/prometheus/procfs v0.15.1 // indirect
65-
github.com/quic-go/quic-go v0.51.0 // indirect
59+
github.com/prometheus/client_model v0.6.2 // indirect
60+
github.com/prometheus/common v0.64.0 // indirect
61+
github.com/prometheus/procfs v0.16.1 // indirect
62+
github.com/quic-go/quic-go v0.53.0 // indirect
6663
github.com/spaolacci/murmur3 v1.1.0 // indirect
6764
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
6865
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
@@ -72,15 +69,16 @@ require (
7269
github.com/zeebo/errs v1.3.0 // indirect
7370
go.uber.org/atomic v1.11.0 // indirect
7471
go.uber.org/multierr v1.11.0 // indirect
75-
golang.org/x/crypto v0.38.0 // indirect
76-
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
77-
golang.org/x/mod v0.24.0 // indirect
78-
golang.org/x/net v0.40.0 // indirect
79-
golang.org/x/sync v0.14.0 // indirect
80-
golang.org/x/sys v0.33.0 // indirect
81-
golang.org/x/text v0.25.0 // indirect
82-
golang.org/x/time v0.11.0 // indirect
83-
golang.org/x/tools v0.33.0 // indirect
84-
google.golang.org/protobuf v1.36.5 // indirect
85-
lukechampine.com/blake3 v1.4.0 // indirect
72+
golang.org/x/crypto v0.40.0 // indirect
73+
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
74+
golang.org/x/mod v0.26.0 // indirect
75+
golang.org/x/net v0.42.0 // indirect
76+
golang.org/x/sync v0.16.0 // indirect
77+
golang.org/x/sys v0.34.0 // indirect
78+
golang.org/x/text v0.27.0 // indirect
79+
golang.org/x/time v0.12.0 // indirect
80+
golang.org/x/tools v0.35.0 // indirect
81+
google.golang.org/protobuf v1.36.6 // indirect
82+
lukechampine.com/blake3 v1.4.1 // indirect
8683
)
84+

0 commit comments

Comments
 (0)