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 polkadot dependencies #417

Merged
merged 27 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Fix conflicts due to geth 1.10.3 upgrade
  • Loading branch information
vgeddes committed Jun 17, 2021
commit 1737aefb9c1da909cafe936536426c2cf07a86ec
15 changes: 8 additions & 7 deletions relayer/chain/ethereum/header_cache_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,15 @@ func (s *HeaderCacheState) GetEthashproofCache(number uint64) (*ethashproof.Data
return cacheState.currentCache, nil
}

func (s *HeaderCacheState) makeTrie(items gethTypes.DerivableList) *gethTrie.Trie {
keybuf := new(bytes.Buffer)
func (s *HeaderCacheState) makeTrie(items gethTypes.Receipts) *gethTrie.Trie {
keyBuf := new(bytes.Buffer)
valueBuf := new(bytes.Buffer)
trie := new(gethTrie.Trie)
for i := 0; i < items.Len(); i++ {
keybuf.Reset()
rlp.Encode(keybuf, uint(i))
trie.Update(keybuf.Bytes(), items.GetRlp(i))

for i, item := range items {
keyBuf.Reset()
rlp.Encode(keyBuf, uint(i))
item.EncodeRLP(valueBuf)
trie.Update(keyBuf.Bytes(), valueBuf.Bytes())
}
return trie
}
Expand Down
14 changes: 8 additions & 6 deletions relayer/cmd/fetch_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ func printEthContractEventForSub(mapping map[common.Address]string, event *gethT
return nil
}

func makeTrie(items gethTypes.DerivableList) *gethTrie.Trie {
keybuf := new(bytes.Buffer)
func makeTrie(items gethTypes.Receipts) *gethTrie.Trie {
keyBuf := new(bytes.Buffer)
valueBuf := new(bytes.Buffer)
trie := new(gethTrie.Trie)
for i := 0; i < items.Len(); i++ {
keybuf.Reset()
rlp.Encode(keybuf, uint(i))
trie.Update(keybuf.Bytes(), items.GetRlp(i))
for i, item := range items {
keyBuf.Reset()
rlp.Encode(keyBuf, uint(i))
item.EncodeRLP(valueBuf)
trie.Update(keyBuf.Bytes(), valueBuf.Bytes())
}
return trie
}
4 changes: 2 additions & 2 deletions relayer/crypto/sr25519/sr25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Keypair struct {
keyringPair *signature.KeyringPair
}

func GenerateKeypair(network string) (*Keypair, error) {
func GenerateKeypair(network uint8) (*Keypair, error) {
data := make([]byte, 32)
_, err := rand.Read(data)
if err != nil {
Expand All @@ -27,7 +27,7 @@ func GenerateKeypair(network string) (*Keypair, error) {
return NewKeypairFromSeed("//"+hexutil.Encode(data), network)
}

func NewKeypairFromSeed(seed, network string) (*Keypair, error) {
func NewKeypairFromSeed(seed string, network uint8) (*Keypair, error) {
kp, err := signature.KeyringPairFromSecret(seed, network)
return &Keypair{&kp}, err
}
Expand Down
6 changes: 3 additions & 3 deletions relayer/crypto/sr25519/sr25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestNewKeypairFromSeed(t *testing.T) {
kp, err := NewKeypairFromSeed("//Alice", "substrate")
kp, err := NewKeypairFromSeed("//Alice", 42)
if err != nil {
t.Fatal(err)
}
Expand All @@ -22,7 +22,7 @@ func TestNewKeypairFromSeed(t *testing.T) {
}

func TestKeypair_AsKeyringPair(t *testing.T) {
kp, err := NewKeypairFromSeed("//Alice", "substrate")
kp, err := NewKeypairFromSeed("//Alice", 42)
if err != nil {
t.Fatal(err)
}
Expand All @@ -38,7 +38,7 @@ func TestKeypair_AsKeyringPair(t *testing.T) {
}

func TestEncodeAndDecodeKeypair(t *testing.T) {
kp, err := NewKeypairFromSeed("//Alice", "substrate")
kp, err := NewKeypairFromSeed("//Alice", 42)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion relayer/workers/ethrelayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (w *Worker) queryFinalizedBlockNumber() (uint64, error) {
}

func (w *Worker) connect(ctx context.Context) error {
kpForPara, err := sr25519.NewKeypairFromSeed(w.paraconfig.PrivateKey, "")
kpForPara, err := sr25519.NewKeypairFromSeed(w.paraconfig.PrivateKey, 42)
if err != nil {
return err
}
Expand Down