Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for new Perun-Polkadot-Node (Polkadot v1.9) #20

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: 1.21
- name: Checkout
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45
version: v1.56.2

test:
name: Test
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.21

- name: Checkout
uses: actions/checkout@v2
Expand All @@ -40,7 +40,7 @@ jobs:
${{ runner.os }}-go-

- name: Start Substrate node
run: docker run --rm -d --name substrate -p 9944:9944 ghcr.io/perun-network/polkadot-test-node:0.2.0
run: docker run --rm -d --name substrate -p 9944:9944 ghcr.io/perun-network/polkadot-test-node:0.4.0

- name: Wait for Substrate node
# Wait for port 9944 to listen.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cd perun-polkadot-backend
2. Start a local Substrate node with the Perun Pallet installed. See the [polkadot node] repository for more details.

```sh
docker run --rm -p 9944:9944 ghcr.io/perun-network/polkadot-test-node
docker run --rm -p 9944:9944 ghcr.io/perun-network/polkadot-test-node:0.4.0
```

3. Run the tests. This step needs a working [Go distribution](https://golang.org), see [go.mod](go.mod) for the required version.
Expand Down
2 changes: 1 addition & 1 deletion channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package channel
import (
"math/big"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/pkg/errors"
pchannel "perun.network/go-perun/channel"
Expand Down
7 changes: 4 additions & 3 deletions channel/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"math/big"
"time"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"github.com/perun-network/perun-polkadot-backend/pkg/substrate"
"github.com/pkg/errors"
pchannel "perun.network/go-perun/channel"
Expand All @@ -28,12 +29,12 @@ import (

// ScaleEncode encodes any struct according to the SCALE codec.
func ScaleEncode(obj interface{}) ([]byte, error) {
return types.EncodeToBytes(obj)
return codec.Encode(obj)
}

// ScaleDecode decodes any struct according to the SCALE codec.
func ScaleDecode(obj interface{}, data []byte) error {
return types.DecodeFromBytes(data, obj)
return codec.Decode(data, obj)
}

// MakeBalance creates a new Balance.
Expand Down
2 changes: 1 addition & 1 deletion channel/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package channel

import (
"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion channel/pallet/adjudicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pallet
import (
"context"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/pkg/errors"
pchannel "perun.network/go-perun/channel"
"perun.network/go-perun/log"
Expand Down
2 changes: 1 addition & 1 deletion channel/pallet/adjudicator_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"time"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/perun-network/perun-polkadot-backend/channel"
pkg_sr25519 "github.com/perun-network/perun-polkadot-backend/pkg/sr25519"
"github.com/perun-network/perun-polkadot-backend/pkg/substrate"
Expand Down
2 changes: 1 addition & 1 deletion channel/pallet/adjudicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestAdjudicator_Walkthrough(t *testing.T) {
dSetup := chtest.NewDepositSetup(params, state)
adjAlice := pallet.NewAdjudicator(s.Alice.Acc, s.Pallet, s.API, test.PastBlocks)
adjBob := pallet.NewAdjudicator(s.Bob.Acc, s.Pallet, s.API, test.PastBlocks)
ctx, cancel := context.WithTimeout(context.Background(), 100*s.BlockTime)
ctx, cancel := context.WithTimeout(context.Background(), 1000*s.BlockTime)
defer cancel()

// Fund
Expand Down
7 changes: 6 additions & 1 deletion channel/pallet/event_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package pallet

import (
"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"io"

"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"perun.network/go-perun/log"
pkgsync "polycry.pt/poly-go/sync"

Expand Down Expand Up @@ -60,6 +62,9 @@ func NewEventSub(source *substrate.EventSource, meta *types.Metadata, p EventPre
select {
case set := <-source.Events():
if err = sub.decodeEventRecords(set, meta); err != nil {
if err == io.EOF {
continue
}
sub.Log().Errorf("decoding event records: %v", err)
break loop
}
Expand Down
2 changes: 1 addition & 1 deletion channel/pallet/funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"time"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/perun-network/perun-polkadot-backend/channel"
pchannel "perun.network/go-perun/channel"
"perun.network/go-perun/log"
Expand Down
2 changes: 1 addition & 1 deletion channel/pallet/pallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pallet
import (
"errors"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
pchannel "perun.network/go-perun/channel"
"perun.network/go-perun/log"
pwallet "perun.network/go-perun/wallet"
Expand Down
4 changes: 2 additions & 2 deletions channel/pallet/test/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"math/big"
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -131,7 +131,7 @@ func (s *Setup) AssertBalanceChanges(deltas map[types.AccountID]*big.Int, epsilo
for addr, delta := range deltas {
gotDelta := new(big.Int).Sub(before[addr], after[addr])
gotEpsilon := new(big.Int).Sub(delta, gotDelta)
msg := fmt.Sprintf("Addr: 0x%x, gotDelta: %v, wantDelta: %v, gotEps: %v, wantEps: %v", addr, substrate.NewDotFromPlank(gotDelta), substrate.NewDotFromPlank(delta), substrate.NewDotFromPlank(gotEpsilon), substrate.NewDotFromPlank(epsilon))
msg := fmt.Sprintf("Addr: 0x%x, gotDelta: %v, wantDelta: %v, gotEps: %v, wantEps: %v", addr, substrate.NewDotFromPlanck(gotDelta), substrate.NewDotFromPlanck(delta), substrate.NewDotFromPlanck(gotEpsilon), substrate.NewDotFromPlanck(epsilon))
require.True(s.T, gotEpsilon.CmpAbs(epsilon) <= 0, msg)
}
}
16 changes: 14 additions & 2 deletions client/appchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import (
"perun.network/go-perun/channel"
"perun.network/go-perun/client"
clienttest "perun.network/go-perun/client/test"
test "perun.network/go-perun/wallet/test"
"perun.network/go-perun/wire"
pkgtest "polycry.pt/poly-go/test"

"github.com/ChainSafe/go-schnorrkel"
pchannel "github.com/perun-network/perun-polkadot-backend/channel"
ptest "github.com/perun-network/perun-polkadot-backend/channel/pallet/test"
dotwallet "github.com/perun-network/perun-polkadot-backend/wallet/sr25519"
"github.com/stretchr/testify/require"
)

func TestAppChannel(t *testing.T) {
Expand All @@ -42,7 +44,17 @@ func TestAppChannel(t *testing.T) {
clienttest.NewPaula(t, setups[B]),
}

appAddress := test.NewRandomAddress(rng)
byteArray := [32]byte{
176, 115, 108, 113, 171, 155, 245, 248,
27, 234, 80, 36, 30, 145, 56, 217,
213, 25, 176, 99, 145, 198, 217, 248,
220, 159, 39, 241, 120, 209, 175, 8,
}
pk, err := schnorrkel.NewPublicKey(byteArray)
require.NoError(t, err)

appAddress := dotwallet.NewAddressFromPK(pk)
require.NoError(t, err)
app := channel.NewMockApp(appAddress)
channel.RegisterApp(app)

Expand Down
2 changes: 1 addition & 1 deletion client/dispute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"math/big"
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
pclient "perun.network/go-perun/client"
clienttest "perun.network/go-perun/client/test"
"perun.network/go-perun/wire"
Expand Down
2 changes: 1 addition & 1 deletion client/happy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"perun.network/go-perun/wire"
pkgtest "polycry.pt/poly-go/test"

"github.com/centrifuge/go-substrate-rpc-client/v3/types"
"github.com/centrifuge/go-substrate-rpc-client/v4/types"
"github.com/perun-network/perun-polkadot-backend/channel"
"github.com/perun-network/perun-polkadot-backend/channel/pallet/test"
"github.com/perun-network/perun-polkadot-backend/wallet"
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
module github.com/perun-network/perun-polkadot-backend

go 1.17
go 1.21

require (
github.com/ChainSafe/go-schnorrkel v0.0.0-20210318173838-ccb5cd955283
github.com/centrifuge/go-substrate-rpc-client/v3 v3.0.2
github.com/ethereum/go-ethereum v1.10.12
github.com/ChainSafe/go-schnorrkel v1.1.0
github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1
github.com/ethereum/go-ethereum v1.10.20
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.2
github.com/vedhavyas/go-subkey v1.0.2
perun.network/go-perun v0.10.6
polycry.pt/poly-go v0.0.0-20220301085937-fb9d71b45a37
)

require (
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.7.1 // indirect
github.com/decred/base58 v1.0.3 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/base58 v1.0.4 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect
golang.org/x/sys v0.6.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading