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

Commit

Permalink
GSRPC Update (#479)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
mikiquantum authored Jul 15, 2020
1 parent 416cf69 commit 07c1cd0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions chains/substrate/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func (c *Connection) SubmitTx(method utils.Method, args ...interface{}) error {
BlockHash: c.genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: c.genesisHash,
Nonce: types.UCompact(c.nonce),
Nonce: types.NewUCompactFromUInt(uint64(c.nonce)),
SpecVersion: rv.SpecVersion,
Tip: 0,
Tip: types.NewUCompactFromUInt(0),
}

err = ext.Sign(*c.key, o)
Expand Down
2 changes: 1 addition & 1 deletion chains/substrate/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestConnect_SubmitTx(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = conn.SubmitTx("Balances.transfer", bob.AsAccountID, types.UCompact(10))
err = conn.SubmitTx("Balances.transfer", bob.AsAccountID, types.NewUCompactFromUInt(10))
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ChainSafe/ChainBridge
go 1.13

require (
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e
github.com/ChainSafe/log15 v1.0.0
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible
github.com/ethereum/go-ethereum v1.9.13
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/stretchr/testify v1.4.0
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793 h1:sf/lEDGAjCqgC2BCGTUziaH4wltHh7rgcz/taIpk5Fc=
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200527185312-f0db52b1c793/go.mod h1:RSXnXog37jdV0A3j9uaZVjOxZ5Lrj5miNhjiMtQXZkM=
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e h1:c7NSjEfp13ua566bC2KSNmyx0Cvj1cciO2klsFIQv2I=
github.com/ChainSafe/chainbridge-substrate-events v0.0.0-20200715141113-87198532025e/go.mod h1:H5fNH57wn/j1oLifOnWEqYbfJZcOWzr7jZjKKrUckSQ=
github.com/ChainSafe/log15 v1.0.0 h1:vRDVtWtVwIH5uSCBvgTTZh6FA58UBJ6+QiiypaZfBf8=
github.com/ChainSafe/log15 v1.0.0/go.mod h1:5v1+ALHtdW0NfAeeoYyKmzCAMcAeqkdhIg4uxXWIgOg=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand Down Expand Up @@ -42,9 +42,8 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/centrifuge/go-substrate-rpc-client v1.1.0/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6 h1:wA8hkwP5xlNCWUxoTqLeP6gxl8olY8aedBUkfHMi2Tg=
github.com/centrifuge/go-substrate-rpc-client v1.1.1-0.20200428140716-e238735648d6/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible h1:d8hQYVrpemZ6ZN38kL1XdQtezXTwrgiVXgQg+M3Lay0=
github.com/centrifuge/go-substrate-rpc-client v2.0.0-alpha.3+incompatible/go.mod h1:GBMLH8MQs5g4FcrytcMm9uRgBnTL1LIkNTue6lUPhZU=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
Expand Down
12 changes: 7 additions & 5 deletions shared/substrate/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

import (
"fmt"
"math/big"
"sync"

"github.com/ChainSafe/log15"
Expand Down Expand Up @@ -40,9 +41,9 @@ func SubmitTx(client *Client, method Method, args ...interface{}) error {
BlockHash: client.Genesis,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: client.Genesis,
Nonce: types.UCompact(acct.Nonce),
Nonce: types.NewUCompactFromUInt(uint64(acct.Nonce)),
SpecVersion: rv.SpecVersion,
Tip: 0,
Tip: types.NewUCompactFromUInt(0),
}
err = ext.Sign(*client.Key, o)
if err != nil {
Expand Down Expand Up @@ -98,9 +99,9 @@ func BatchSubmit(client *Client, calls []types.Call) error {
BlockHash: client.Genesis,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: client.Genesis,
Nonce: types.UCompact(acct.Nonce),
Nonce: types.NewUCompactFromUInt(uint64(acct.Nonce)),
SpecVersion: rv.SpecVersion,
Tip: 0,
Tip: types.NewUCompactFromUInt(0),
}

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

o.Nonce = o.Nonce + 1
bigNonce := big.Int(o.Nonce)
o.Nonce = types.NewUCompactFromUInt(bigNonce.Uint64() + 1)
}

wg.Wait()
Expand Down

0 comments on commit 07c1cd0

Please sign in to comment.