Skip to content
This repository was archived by the owner on Jul 13, 2022. It is now read-only.

Commit 07c1cd0

Browse files
authored
GSRPC Update (#479)
Update to latest GSRPC https://github.com/centrifuge/go-substrate-rpc-client/releases/tag/v2.0.0-alpha.3 In particular fixes UCompact type to support Big Numbers up to 536 bit (per substrate SCALE specs)
1 parent 416cf69 commit 07c1cd0

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

chains/substrate/connection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ func (c *Connection) SubmitTx(method utils.Method, args ...interface{}) error {
119119
BlockHash: c.genesisHash,
120120
Era: types.ExtrinsicEra{IsMortalEra: false},
121121
GenesisHash: c.genesisHash,
122-
Nonce: types.UCompact(c.nonce),
122+
Nonce: types.NewUCompactFromUInt(uint64(c.nonce)),
123123
SpecVersion: rv.SpecVersion,
124-
Tip: 0,
124+
Tip: types.NewUCompactFromUInt(0),
125125
}
126126

127127
err = ext.Sign(*c.key, o)

chains/substrate/connection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestConnect_SubmitTx(t *testing.T) {
7474
if err != nil {
7575
t.Fatal(err)
7676
}
77-
err = conn.SubmitTx("Balances.transfer", bob.AsAccountID, types.UCompact(10))
77+
err = conn.SubmitTx("Balances.transfer", bob.AsAccountID, types.NewUCompactFromUInt(10))
7878
if err != nil {
7979
t.Fatal(err)
8080
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module github.com/ChainSafe/ChainBridge
33
go 1.13
44

55
require (
6-
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793
6+
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e
77
github.com/ChainSafe/log15 v1.0.0
88
github.com/btcsuite/btcd v0.20.1-beta // indirect
9-
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6
9+
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible
1010
github.com/ethereum/go-ethereum v1.9.13
1111
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
1212
github.com/stretchr/testify v1.4.0

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN
1212
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
1313
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
1414
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
15-
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793 h1:sf/lEDGAjCqgC2BCGTUziaH4wltHh7rgcz/taIpk5Fc=
16-
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793/go.mod h1:RSXnXog37jdV0A3j9uaZVjOxZ5Lrj5miNhjiMtQXZkM=
15+
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e h1:c7NSjEfp13ua566bC2KSNmyx0Cvj1cciO2klsFIQv2I=
16+
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e/go.mod h1:H5fNH57wn/j1oLifOnWEqYbfJZcOWzr7jZjKKrUckSQ=
1717
github.com/ChainSafe/log15 v1.0.0 h1:vRDVtWtVwIH5uSCBvgTTZh6FA58UBJ6+QiiypaZfBf8=
1818
github.com/ChainSafe/log15 v1.0.0/go.mod h1:5v1+ALHtdW0NfAeeoYyKmzCAMcAeqkdhIg4uxXWIgOg=
1919
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
@@ -42,9 +42,8 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
4242
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
4343
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
4444
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
45-
github.com/centrifuge/go-substrate-rpc-client v1.1.0/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
46-
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6 h1:wA8hkwP5xlNCWUxoTqLeP6gxl8olY8aedBUkfHMi2Tg=
47-
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
45+
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible h1:d8hQYVrpemZ6ZN38kL1XdQtezXTwrgiVXgQg+M3Lay0=
46+
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
4847
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
4948
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
5049
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=

shared/substrate/submit.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package utils
55

66
import (
77
"fmt"
8+
"math/big"
89
"sync"
910

1011
"github.com/ChainSafe/log15"
@@ -40,9 +41,9 @@ func SubmitTx(client *Client, method Method, args ...interface{}) error {
4041
BlockHash: client.Genesis,
4142
Era: types.ExtrinsicEra{IsMortalEra: false},
4243
GenesisHash: client.Genesis,
43-
Nonce: types.UCompact(acct.Nonce),
44+
Nonce: types.NewUCompactFromUInt(uint64(acct.Nonce)),
4445
SpecVersion: rv.SpecVersion,
45-
Tip: 0,
46+
Tip: types.NewUCompactFromUInt(0),
4647
}
4748
err = ext.Sign(*client.Key, o)
4849
if err != nil {
@@ -98,9 +99,9 @@ func BatchSubmit(client *Client, calls []types.Call) error {
9899
BlockHash: client.Genesis,
99100
Era: types.ExtrinsicEra{IsMortalEra: false},
100101
GenesisHash: client.Genesis,
101-
Nonce: types.UCompact(acct.Nonce),
102+
Nonce: types.NewUCompactFromUInt(uint64(acct.Nonce)),
102103
SpecVersion: rv.SpecVersion,
103-
Tip: 0,
104+
Tip: types.NewUCompactFromUInt(0),
104105
}
105106

106107
wg := &sync.WaitGroup{}
@@ -137,7 +138,8 @@ func BatchSubmit(client *Client, calls []types.Call) error {
137138
}
138139
}()
139140

140-
o.Nonce = o.Nonce + 1
141+
bigNonce := big.Int(o.Nonce)
142+
o.Nonce = types.NewUCompactFromUInt(bigNonce.Uint64() + 1)
141143
}
142144

143145
wg.Wait()

0 commit comments

Comments
 (0)