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
update
  • Loading branch information
vgeddes committed Jun 22, 2021
commit 0739e8f8eea630949042534891e15b1cffde9dec
13 changes: 1 addition & 12 deletions parachain/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,5 @@
}
]
}
],
"simpleParachains": [
{
"bin": "/tmp/polkadot/target/release/adder-collator",
"id": 201,
"port": 9977,
"name": "alice"
}
],
"hrmpChannels": [],
"types": {
}
]
}
7 changes: 6 additions & 1 deletion relayer/chain/ethereum/header_cache_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ func (s *HeaderCacheState) GetReceiptTrie(ctx context.Context, hash gethCommon.H
if err != nil {
return nil, err
}
receiptTrie = MakeTrie(receipts)

receiptTrie, err = MakeTrie(receipts)
if err != nil {
return nil, err
}

if receiptTrie.Hash() != block.ReceiptHash() {
return nil, fmt.Errorf("Receipt trie does not match block receipt hash")
}
Expand Down
6 changes: 5 additions & 1 deletion relayer/chain/ethereum/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func TestMessage_Proof(t *testing.T) {
}

// Construct Merkle Patricia Trie for receipts
receiptTrie := ethereum.MakeTrie(receipts)
receiptTrie, err := ethereum.MakeTrie(receipts)
if err != nil {
panic(err)
}

fmt.Println("Hash", receiptTrie.Hash())

if receiptTrie.Hash() != block.ReceiptHash() {
Expand Down
16 changes: 9 additions & 7 deletions relayer/chain/ethereum/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import (
"github.com/ethereum/go-ethereum/trie"
)

func MakeTrie(items types.Receipts) *trie.Trie {
func MakeTrie(items types.Receipts) (*trie.Trie, error) {
keyBuf := new(bytes.Buffer)
valueBuf := new(bytes.Buffer)
trie := new(trie.Trie)

for i := 0; i < items.Len(); i++ {
keyBuf.Reset()
valueBuf.Reset()

rlp.Encode(keyBuf, uint(i))
items.EncodeIndex(i, valueBuf)
trie.Update(keyBuf.Bytes(), valueBuf.Bytes())

value, err := rlp.EncodeToBytes(items[i])
if err != nil {
return nil, err
}

trie.Update(keyBuf.Bytes(), value)
}
return trie
return trie, nil
}
6 changes: 5 additions & 1 deletion relayer/cmd/fetch_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ func getEthContractEventsAndTrie(
if err != nil {
return nil, nil, err
}
trie := ethereum.MakeTrie(receipts)

trie, err := ethereum.MakeTrie(receipts)
if err != nil {
return nil, nil, err
}

allEvents := make([]*gethTypes.Log, 0)

Expand Down
58 changes: 38 additions & 20 deletions test/config/launchConfigOverridesDup.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,48 @@
"parachains": [
{
"id": "200",
"wsPort": 11144,
"port": 31200,
"flags": [
"--execution=native",
"-lruntime=debug,import_header=trace,bridge=trace",
"--rpc-cors=all",
"--offchain-worker=Always",
"--enable-offchain-indexing=true",
"--",
"--execution=wasm"
"nodes": [
{
"wsPort": 11144,
"port": 31200,
"name": "alice",
"flags": [
"-lruntime=debug",
"--rpc-port=8081",
"--rpc-cors=all",
"--ws-external",
"--rpc-external",
"--rpc-methods=Unsafe",
"--offchain-worker=Always",
"--enable-offchain-indexing=true",
"--execution=native",
"--",
"--execution=wasm"
]
}
]
},
{
"id": "201",
"wsPort": 11145,
"port": 31201,
"flags": [
"--execution=native",
"-lruntime=debug,import_header=trace,bridge=trace",
"--rpc-cors=all",
"--offchain-worker=Always",
"--enable-offchain-indexing=true",
"--",
"--execution=wasm"
"nodes": [
{
"wsPort": 11155,
"port": 31201,
"name": "alice",
"flags": [
"-lruntime=debug",
"--rpc-port=8082",
"--rpc-cors=all",
"--ws-external",
"--rpc-external",
"--rpc-methods=Unsafe",
"--offchain-worker=Always",
"--enable-offchain-indexing=true",
"--execution=native",
"--",
"--execution=wasm"
]
}
]
}
]
Expand Down