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

feat(lib/runtime): Implement trie_blake2_256_verify_proof host function #1920

Merged
merged 69 commits into from
Nov 9, 2021
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7dd7c4b
feat: add verify_proof function
EclesioMeloJunior Oct 8, 2021
e6a3415
chore: adding helpers
EclesioMeloJunior Oct 8, 2021
cff7280
chore: build the tree from proof slice
EclesioMeloJunior Oct 11, 2021
2d816a4
chore: remove Nibbles custom type
EclesioMeloJunior Oct 11, 2021
6a4552a
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 11, 2021
e6a02d8
chore: fix lint warns
EclesioMeloJunior Oct 11, 2021
71cb795
Merge branch 'eclesio/verify-proof' of github.com:ChainSafe/gossamer …
EclesioMeloJunior Oct 11, 2021
e92276b
chore: add benchmark tests
EclesioMeloJunior Oct 11, 2021
493dddb
chore: fix deepsource warns
EclesioMeloJunior Oct 12, 2021
c129de5
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 13, 2021
4de95ec
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 13, 2021
9455e13
chore: redefine LoadFromProof function
EclesioMeloJunior Oct 13, 2021
e8d4912
chore: remove logs
EclesioMeloJunior Oct 13, 2021
10dd296
chore: address comments
EclesioMeloJunior Oct 14, 2021
34b8dd0
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 15, 2021
35abff5
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 15, 2021
e3debb7
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 18, 2021
8e4a1c1
chore: fix the condition to load the proof
EclesioMeloJunior Oct 18, 2021
76893e2
chore: address comments
EclesioMeloJunior Oct 18, 2021
7ee1756
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 19, 2021
c07ab85
chore: create test cases
EclesioMeloJunior Oct 19, 2021
7f24a65
chore: improve find function
EclesioMeloJunior Oct 19, 2021
5a6d3f8
chore: use map to avoid duplicate keys
EclesioMeloJunior Oct 19, 2021
8bd6a33
chore: add test cases to duplicate values and nil values
EclesioMeloJunior Oct 19, 2021
f4081ba
chore: fix unused param lint error
EclesioMeloJunior Oct 19, 2021
d8a5e41
chore: use the shortest form
EclesioMeloJunior Oct 19, 2021
6465be8
chore: use set just for find dupl keys
EclesioMeloJunior Oct 19, 2021
6204ba4
Merge branch 'development' into eclesio/verify-proof
EclesioMeloJunior Oct 19, 2021
c0a88a9
chore: fixing test cases
EclesioMeloJunior Oct 19, 2021
8836808
Merge branch 'eclesio/verify-proof' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 19, 2021
0193014
wip: waiting w3f response about host fun
EclesioMeloJunior Oct 19, 2021
8406e94
chore: trie without rtm prefix
EclesioMeloJunior Oct 20, 2021
7fe1e94
feat: add ext_trie_blake2_256_verify_proof_version_1 host function
EclesioMeloJunior Oct 22, 2021
ee4a4a4
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 22, 2021
3c92e65
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 22, 2021
b23be22
chore: remove uneeded condition
EclesioMeloJunior Oct 22, 2021
cf034a0
Merge branch 'eclesio/runtime-verify-proof' of github.com:ChainSafe/g…
EclesioMeloJunior Oct 22, 2021
81ce63d
chore: put back test main
EclesioMeloJunior Oct 22, 2021
a426769
chore: fix tests
EclesioMeloJunior Oct 22, 2021
5c28b75
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 25, 2021
fd00ea1
chore: group param to one type
EclesioMeloJunior Oct 25, 2021
5a31f8e
chore: improve verify proof condition and simplify errors comments
EclesioMeloJunior Oct 25, 2021
d006213
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 25, 2021
05c28d0
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 25, 2021
020b04c
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 26, 2021
ec95003
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 27, 2021
df5c7db
Merge branch 'development' into eclesio/runtime-verify-proof
noot Oct 27, 2021
d16881e
Merge branch 'development' into eclesio/runtime-verify-proof
noot Oct 27, 2021
c4eb31f
Merge branch 'development' into eclesio/runtime-verify-proof
noot Oct 27, 2021
de632e8
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 28, 2021
b879c61
Merge branch 'development' into eclesio/runtime-verify-proof
noot Oct 28, 2021
be909f2
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 29, 2021
c988651
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 29, 2021
321dcb6
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Oct 29, 2021
2960125
chore: remove tmp dir after test finish
EclesioMeloJunior Nov 1, 2021
3cb4bf4
chore: update tests
EclesioMeloJunior Nov 1, 2021
371ce96
chore: use map on tests
EclesioMeloJunior Nov 1, 2021
76e8c44
chore: fix lint warns
EclesioMeloJunior Nov 1, 2021
a49d819
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Nov 1, 2021
53ed87b
chore: update the polkadot-runtime commit
EclesioMeloJunior Nov 1, 2021
3cbe155
Merge branch 'eclesio/runtime-verify-proof' of github.com:ChainSafe/g…
EclesioMeloJunior Nov 1, 2021
b2c1d13
chore: remove comment, add parallel to tests
EclesioMeloJunior Nov 3, 2021
8f29223
chore: fix deepsource warns
EclesioMeloJunior Nov 5, 2021
92828de
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Nov 5, 2021
54f98cb
chore: create a client rather than the default client
EclesioMeloJunior Nov 5, 2021
b46a01a
chore: update verify-proof trie root param to u32
EclesioMeloJunior Nov 8, 2021
c684da5
chore: change host api commit
EclesioMeloJunior Nov 8, 2021
245cb35
Merge branch 'development' into eclesio/runtime-verify-proof
EclesioMeloJunior Nov 9, 2021
2ada338
using ioutil.ReadAll
EclesioMeloJunior Nov 9, 2021
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
15 changes: 14 additions & 1 deletion lib/runtime/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package runtime

import (
"context"
"io"
"io/ioutil"
"net/http"
"os"
"path"
"testing"
"time"

"github.com/ChainSafe/chaindb"
"github.com/ChainSafe/gossamer/lib/common"
Expand Down Expand Up @@ -85,7 +87,18 @@ func GetRuntimeBlob(testRuntimeFilePath, testRuntimeURL string) error {
return nil
}

resp, err := http.Get(testRuntimeURL)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

req, err := http.NewRequestWithContext(ctx, http.MethodGet, testRuntimeURL, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit nit I'm going to sound annoying, but you could actually use context.WithTimeout(context.Background(), someTimeout) and the default http client 😄 But the current implementation is good too 👍!

if err != nil {
return err
}

const runtimeReqTimout = time.Second * 30

httpcli := http.Client{Timeout: runtimeReqTimout}
resp, err := httpcli.Do(req)
if err != nil {
return err
}
Expand Down