From bae9f4d8bcae1902df4c3da929cafee52f22b14e Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 3 Oct 2023 17:53:47 +0200 Subject: [PATCH 1/4] Dependency upgrades --- .github/workflows/go.yml | 12 +++++++++-- go.mod | 14 ++++++------- go.sum | 43 ++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 12310434..9aca883f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: 1.20 - name: Install depedencies run: go install honnef.co/go/tools/cmd/staticcheck@latest @@ -21,6 +21,14 @@ jobs: - name: Build run: go build -v ./... + + + + + + + + - name: Test run: go test -timeout 20m -v -run "TestCRDT" -race -coverprofile=coverage.txt -covermode=atomic @@ -40,7 +48,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.19 + go-version: 1.20 - name: Test run: go test -timeout 30m -v -run "TestDatastoreSuite" . diff --git a/go.mod b/go.mod index 73b428de..d89e57c5 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,16 @@ module github.com/ipfs/go-ds-crdt -go 1.19 +go 1.20 require ( github.com/dgraph-io/badger v1.6.2 github.com/golang/protobuf v1.5.3 github.com/ipfs/bbloom v0.0.4 - github.com/ipfs/boxo v0.11.0 + github.com/ipfs/boxo v0.13.1 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-datastore v0.6.0 github.com/ipfs/go-ds-badger v0.3.0 - github.com/ipfs/go-ipld-format v0.5.0 + github.com/ipfs/go-ipld-format v0.6.0 github.com/ipfs/go-log/v2 v2.5.1 github.com/jbenet/goprocess v0.1.4 github.com/libp2p/go-libp2p-pubsub v0.9.3 @@ -40,14 +40,14 @@ require ( github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.29.2 // indirect + github.com/libp2p/go-libp2p v0.30.0 // indirect github.com/libp2p/go-msgio v0.3.0 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect - github.com/multiformats/go-multiaddr v0.10.1 // indirect + github.com/multiformats/go-multiaddr v0.11.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-multistream v0.4.1 // indirect @@ -59,8 +59,8 @@ require ( go.opentelemetry.io/otel/trace v1.16.0 // indirect go.uber.org/zap v1.25.0 // indirect golang.org/x/crypto v0.12.0 // indirect - golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect - golang.org/x/net v0.12.0 // indirect + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect + golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index e791c51c..2524e298 100644 --- a/go.sum +++ b/go.sum @@ -57,7 +57,7 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= -github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 h1:n6vlPhxsA+BW/XsS5+uqi7GyzaLa5MH7qlSLBZtRdiA= +github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -71,8 +71,8 @@ github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.11.0 h1:urMxhZ3xoF4HssJVD3+0ssGT9pptEfHfbL8DYdoWFlg= -github.com/ipfs/boxo v0.11.0/go.mod h1:8IfDmp+FzFGcF4zjAgHMVPpwYw4AjN9ePEzDfkaYJ1w= +github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= +github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo= github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= @@ -90,8 +90,8 @@ github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1I github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE= github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0= github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn17xAKWBvs= -github.com/ipfs/go-ipld-format v0.5.0 h1:WyEle9K96MSrvr47zZHKKcDxJ/vlpET6PSiQsAFO+Ds= -github.com/ipfs/go-ipld-format v0.5.0/go.mod h1:ImdZqJQaEouMjCvqCe0ORUS+uoBmf7Hf+EO/jh+nk3M= +github.com/ipfs/go-ipld-format v0.6.0 h1:VEJlA2kQ3LqFSIm5Vu6eIlSxD/Ze90xtc4Meten1F5U= +github.com/ipfs/go-ipld-format v0.6.0/go.mod h1:g4QVMTn3marU3qXchwjpKPKgJv+zF+OlaKMyhJ4LHPg= github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk= github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM= github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw= @@ -127,8 +127,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-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= -github.com/libp2p/go-libp2p v0.29.2 h1:uPw/c8hOxoLP/KhFnzlc5Ejqf+OmAL1dwIsqE31WBtY= -github.com/libp2p/go-libp2p v0.29.2/go.mod h1:OU7nSq0aEZMsV2wY8nXn1+XNNt9q2UiR8LjW3Kmp2UE= +github.com/libp2p/go-libp2p v0.30.0 h1:9EZwFtJPFBcs/yJTnP90TpN1hgrT/EsFfM+OZuwV87U= +github.com/libp2p/go-libp2p v0.30.0/go.mod h1:nr2g5V7lfftwgiJ78/HrID+pwvayLyqKCEirT2Y3Byg= github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= github.com/libp2p/go-libp2p-pubsub v0.9.3 h1:ihcz9oIBMaCK9kcx+yHWm3mLAFBMAUsM4ux42aikDxo= github.com/libp2p/go-libp2p-pubsub v0.9.3/go.mod h1:RYA7aM9jIic5VV47WXu4GkcRxRhrdElWf8xtyli+Dzc= @@ -138,7 +138,7 @@ github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0 github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= -github.com/libp2p/go-reuseport v0.3.0 h1:iiZslO5byUYZEg9iCwJGf5h+sf1Agmqx2V2FDjPyvUw= +github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= @@ -159,8 +159,8 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.10.1 h1:HghtFrWyZEPrpTvgAMFJi6gFdgHfs2cb0pyfDsk+lqU= -github.com/multiformats/go-multiaddr v0.10.1/go.mod h1:jLEZsA61rwWNZQTHHnqq2HNa+4os/Hz54eqiRnsRqYQ= +github.com/multiformats/go-multiaddr v0.11.0 h1:XqGyJ8ufbCE0HmTDwx2kPdsrQ36AGPZNZX6s6xfJH10= +github.com/multiformats/go-multiaddr v0.11.0/go.mod h1:gWUm0QLR4thQ6+ZF6SXUw8YjtwQSPapICM+NmCkxHSM= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= @@ -175,7 +175,7 @@ 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/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= +github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -184,14 +184,13 @@ 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.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qtls-go1-19 v0.3.3 h1:wznEHvJwd+2X3PqftRha0SUKmGsnb6dfArMhy9PeJVE= -github.com/quic-go/qtls-go1-20 v0.2.3 h1:m575dovXn1y2ATOb1XrRFcrv0F+EQmlowTkoraNkDPI= -github.com/quic-go/quic-go v0.36.4 h1:CXn/ZLN5Vntlk53fjR+kUMC8Jt7flfQe+I5Ty5A+k0o= +github.com/quic-go/qtls-go1-20 v0.3.2 h1:rRgN3WfnKbyik4dBV8A6girlJVxGand/d+jVKbQq5GI= +github.com/quic-go/quic-go v0.38.0 h1:T45lASr5q/TrVwt+jrVccmqHhPL2XuSyoCLVCpfOSLc= github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -253,8 +252,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= -golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -267,8 +266,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.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -301,7 +300,7 @@ 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.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= +golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E= 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 a36a5d8db92942d791a921a52c2ef5dc0c95eb77 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 3 Oct 2023 17:59:45 +0200 Subject: [PATCH 2/4] Set go version to 1.20 properly --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9aca883f..05a9070d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,7 +13,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.20 + go-version: "1.20" - name: Install depedencies run: go install honnef.co/go/tools/cmd/staticcheck@latest @@ -48,7 +48,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.20 + go-version: "1.20" - name: Test run: go test -timeout 30m -v -run "TestDatastoreSuite" . From 1ca4a086842b10d40f60a8aed30ea83ac1409acd Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 3 Oct 2023 18:05:33 +0200 Subject: [PATCH 3/4] Avoid using deprecated global rand functions --- crdt.go | 6 ++---- crdt_test.go | 10 ++++------ heads_test.go | 7 +++---- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/crdt.go b/crdt.go index 22233558..91ba3c00 100644 --- a/crdt.go +++ b/crdt.go @@ -55,9 +55,7 @@ var ( ErrNoMoreBroadcast = errors.New("receiving blocks aborted since no new blocks will be broadcasted") ) -func init() { - rand.Seed(time.Now().UnixNano()) -} +var randGen = rand.New(rand.NewSource(time.Now().UnixNano())) // A Broadcaster provides a way to send (notify) an opaque payload to // all replicas and to retrieve payloads broadcasted. @@ -467,7 +465,7 @@ func randomizeInterval(d time.Duration) time.Duration { // 30% of the configured interval leeway := (d * 30 / 100) // A random number between -leeway|+leeway - randomInterval := time.Duration(rand.Int63n(int64(leeway*2))) - leeway + randomInterval := time.Duration(randGen.Int63n(int64(leeway*2))) - leeway return d + randomInterval } diff --git a/crdt_test.go b/crdt_test.go index 90d2f4f6..5ba3e810 100644 --- a/crdt_test.go +++ b/crdt_test.go @@ -3,7 +3,6 @@ package crdt import ( "context" "fmt" - "math/rand" "os" "sync" "sync/atomic" @@ -36,7 +35,6 @@ const ( var store int = mapStore func init() { - rand.Seed(time.Now().UnixNano()) dstest.ElemCount = 10 } @@ -122,7 +120,7 @@ func newBroadcasters(t testing.TB, n int) ([]*mockBroadcaster, context.CancelFun func (mb *mockBroadcaster) Broadcast(data []byte) error { var wg sync.WaitGroup for i, ch := range mb.chans { - n := rand.Intn(100) + n := randGen.Intn(100) if n < mb.dropProb { continue } @@ -130,7 +128,7 @@ func (mb *mockBroadcaster) Broadcast(data []byte) error { go func() { defer wg.Done() // randomize when we send a little bit - if rand.Intn(100) < 30 { + if randGen.Intn(100) < 30 { // Sleep for a very small time that will // effectively be pretty random time.Sleep(time.Nanosecond) @@ -316,7 +314,7 @@ func TestCRDTReplication(t *testing.T) { for i := 0; i < nItems; i++ { k := ds.RandomKey() v := []byte(fmt.Sprintf("%d", i)) - n := rand.Intn(len(replicas)) + n := randGen.Intn(len(replicas)) err := replicas[n].Put(ctx, k, v) if err != nil { t.Fatal(err) @@ -357,7 +355,7 @@ func TestCRDTReplication(t *testing.T) { // give a new value for each item for _, r := range rest { - n := rand.Intn(len(replicas)) + n := randGen.Intn(len(replicas)) err := replicas[n].Put(ctx, ds.NewKey(r.Key), []byte("hola")) if err != nil { t.Error(err) diff --git a/heads_test.go b/heads_test.go index 8de50eda..0cb8b316 100644 --- a/heads_test.go +++ b/heads_test.go @@ -3,7 +3,6 @@ package crdt import ( "bytes" "context" - "math/rand" "reflect" "sort" "testing" @@ -33,7 +32,7 @@ func newTestHeads(t *testing.T) *heads { func newCID(t *testing.T) cid.Cid { t.Helper() var buf [32]byte - _, _ = rand.Read(buf[:]) + _, _ = randGen.Read(buf[:]) mh, err := multihash.Sum(buf[:], multihash.SHA2_256, -1) if err != nil { @@ -57,7 +56,7 @@ func TestHeadsBasic(t *testing.T) { cidHeights := make(map[cid.Cid]uint64) numHeads := 5 for i := 0; i < numHeads; i++ { - c, height := newCID(t), uint64(rand.Int()) + c, height := newCID(t), uint64(randGen.Int()) cidHeights[c] = height err := heads.Add(ctx, c, height) if err != nil { @@ -68,7 +67,7 @@ func TestHeadsBasic(t *testing.T) { assertHeads(t, heads, cidHeights) for c := range cidHeights { - newC, newHeight := newCID(t), uint64(rand.Int()) + newC, newHeight := newCID(t), uint64(randGen.Int()) err := heads.Replace(ctx, c, newC, newHeight) if err != nil { t.Fatal(err) From 356a5e67dcec5b7ac4683e0cc1e56d08a62dc6cd Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 3 Oct 2023 18:26:25 +0200 Subject: [PATCH 4/4] fix rand usage --- crdt.go | 3 +-- crdt_test.go | 14 ++++++++++---- heads_test.go | 10 +++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crdt.go b/crdt.go index 91ba3c00..695f288a 100644 --- a/crdt.go +++ b/crdt.go @@ -55,8 +55,6 @@ var ( ErrNoMoreBroadcast = errors.New("receiving blocks aborted since no new blocks will be broadcasted") ) -var randGen = rand.New(rand.NewSource(time.Now().UnixNano())) - // A Broadcaster provides a way to send (notify) an opaque payload to // all replicas and to retrieve payloads broadcasted. type Broadcaster interface { @@ -465,6 +463,7 @@ func randomizeInterval(d time.Duration) time.Duration { // 30% of the configured interval leeway := (d * 30 / 100) // A random number between -leeway|+leeway + randGen := rand.New(rand.NewSource(time.Now().UnixNano())) randomInterval := time.Duration(randGen.Int63n(int64(leeway*2))) - leeway return d + randomInterval } diff --git a/crdt_test.go b/crdt_test.go index 5ba3e810..9fc2305b 100644 --- a/crdt_test.go +++ b/crdt_test.go @@ -3,6 +3,7 @@ package crdt import ( "context" "fmt" + "math/rand" "os" "sync" "sync/atomic" @@ -119,16 +120,20 @@ func newBroadcasters(t testing.TB, n int) ([]*mockBroadcaster, context.CancelFun func (mb *mockBroadcaster) Broadcast(data []byte) error { var wg sync.WaitGroup + + randg := rand.New(rand.NewSource(time.Now().UnixNano())) + for i, ch := range mb.chans { - n := randGen.Intn(100) + n := randg.Intn(100) if n < mb.dropProb { continue } wg.Add(1) - go func() { + go func(i int) { defer wg.Done() + randg := rand.New(rand.NewSource(int64(i))) // randomize when we send a little bit - if randGen.Intn(100) < 30 { + if randg.Intn(100) < 30 { // Sleep for a very small time that will // effectively be pretty random time.Sleep(time.Nanosecond) @@ -142,7 +147,7 @@ func (mb *mockBroadcaster) Broadcast(data []byte) error { case <-timer.C: mb.t.Errorf("broadcasting to %d timed out", i) } - }() + }(i) wg.Wait() } return nil @@ -306,6 +311,7 @@ func TestCRDT(t *testing.T) { func TestCRDTReplication(t *testing.T) { ctx := context.Background() nItems := 50 + randGen := rand.New(rand.NewSource(time.Now().UnixNano())) replicas, closeReplicas := makeReplicas(t, nil) defer closeReplicas() diff --git a/heads_test.go b/heads_test.go index 0cb8b316..d38a0168 100644 --- a/heads_test.go +++ b/heads_test.go @@ -3,9 +3,11 @@ package crdt import ( "bytes" "context" + "math/rand" "reflect" "sort" "testing" + "time" "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" @@ -15,6 +17,8 @@ import ( var headsTestNS = ds.NewKey("headstest") +var randg = rand.New(rand.NewSource(time.Now().UnixNano())) + // TODO we should also test with a non-batching store func newTestHeads(t *testing.T) *heads { t.Helper() @@ -32,7 +36,7 @@ func newTestHeads(t *testing.T) *heads { func newCID(t *testing.T) cid.Cid { t.Helper() var buf [32]byte - _, _ = randGen.Read(buf[:]) + _, _ = randg.Read(buf[:]) mh, err := multihash.Sum(buf[:], multihash.SHA2_256, -1) if err != nil { @@ -56,7 +60,7 @@ func TestHeadsBasic(t *testing.T) { cidHeights := make(map[cid.Cid]uint64) numHeads := 5 for i := 0; i < numHeads; i++ { - c, height := newCID(t), uint64(randGen.Int()) + c, height := newCID(t), uint64(randg.Int()) cidHeights[c] = height err := heads.Add(ctx, c, height) if err != nil { @@ -67,7 +71,7 @@ func TestHeadsBasic(t *testing.T) { assertHeads(t, heads, cidHeights) for c := range cidHeights { - newC, newHeight := newCID(t), uint64(randGen.Int()) + newC, newHeight := newCID(t), uint64(randg.Int()) err := heads.Replace(ctx, c, newC, newHeight) if err != nil { t.Fatal(err)