Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
152675fb
Unverified
Commit
152675fb
authored
1 year ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
fix distance_oracle NEED VALID METADATA TO FINISH
parent
c14015ab
No related branches found
No related tags found
No related merge requests found
Pipeline
#35466
failed
1 year ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1078
-79
1078 additions, 79 deletions
Cargo.lock
distance-oracle/Cargo.toml
+12
-11
12 additions, 11 deletions
distance-oracle/Cargo.toml
distance-oracle/src/api.rs
+13
-9
13 additions, 9 deletions
distance-oracle/src/api.rs
distance-oracle/src/lib.rs
+2
-3
2 additions, 3 deletions
distance-oracle/src/lib.rs
with
1105 additions
and
102 deletions
Cargo.lock
+
1078
−
79
View file @
152675fb
This diff is collapsed.
Click to expand it.
distance-oracle/Cargo.toml
+
12
−
11
View file @
152675fb
...
...
@@ -9,21 +9,22 @@ edition = "2021"
[dependencies]
sp-distance
=
{
path
=
"../primitives/distance"
}
codec
=
{
package
=
"parity-scale-codec"
,
version
=
"3.6.
5
"
}
codec
=
{
package
=
"parity-scale-codec"
,
version
=
"3.6.
9
"
}
fnv
=
"1.0.7"
log
=
"0.4.17"
num-traits
=
"0.2.15"
rayon
=
"1.7.0"
simple_logger
=
"4.2.0"
log
=
"0.4.20"
num-traits
=
"0.2.17"
rayon
=
"1.8.1"
simple_logger
=
"4.3.3"
sp-core
=
{
git
=
"https://github.com/bgallois/duniter-polkadot-sdk.git"
,
branch
=
"duniter-v1.6.0"
}
sp-runtime
=
{
git
=
"https://github.com/bgallois/duniter-polkadot-sdk.git"
,
branch
=
"duniter-v1.6.0"
}
subxt
=
{
git
=
'https://github.com/
duniter
/subxt.git'
,
branch
=
'duniter-substrate-v0.9.42
'
,
default-features
=
false
,
features
=
[
"substrate-compat"
,
"
jsonrpsee-ws
"
]
}
time
=
"
<
=
0.3
.
23
"# required for MSRV
time-macros = "
=
0.2
.
1
0
"
subxt
=
{
git
=
'https://github.com/
paritytech
/subxt.git'
,
tag
=
'v0.33.0
'
,
default-features
=
false
,
features
=
[
"substrate-compat"
,
"
native
"
]
}
time
=
"0.3.
31"
time-macros
=
"0.2.1
6
"
# standalone only
clap
=
{
version
=
"4.
0
"
,
features
=
[
"derive"
],
optional
=
true
}
tokio
=
{
version
=
"1.
1
5.
0
"
,
features
=
[
clap
=
{
version
=
"4.
4.18
"
,
features
=
[
"derive"
],
optional
=
true
}
tokio
=
{
version
=
"1.
3
5.
1
"
,
features
=
[
"rt-multi-thread"
,
"macros"
,
],
optional
=
true
}
...
...
@@ -31,7 +32,7 @@ tokio = { version = "1.15.0", features = [
[dev-dependencies]
bincode
=
"1.3.3"
dubp-wot
=
"0.11.1"
flate2
=
{
version
=
"1.0"
,
features
=
[
flate2
=
{
version
=
"1.0
.28
"
,
features
=
[
"zlib-ng-compat"
,
],
default-features
=
false
}
...
...
This diff is collapsed.
Click to expand it.
distance-oracle/src/api.rs
+
13
−
9
View file @
152675fb
...
...
@@ -18,7 +18,7 @@ use crate::runtime;
use
log
::
debug
;
use
sp_core
::
H256
;
use
subxt
::
storage
::
Storage
Key
;
use
subxt
::
storage
::
Storage
;
pub
type
Client
=
subxt
::
OnlineClient
<
crate
::
RuntimeConfig
>
;
pub
type
AccountId
=
subxt
::
utils
::
AccountId32
;
...
...
@@ -31,7 +31,12 @@ pub async fn client(rpc_url: String) -> Client {
}
pub
async
fn
parent_hash
(
client
:
&
Client
)
->
H256
{
client
.rpc
()
.block_hash
(
None
)
.await
.unwrap
()
.unwrap
()
client
.blocks
()
.at_latest
()
.await
.expect
(
"Cannot fetch latest block hash"
)
.hash
()
}
pub
async
fn
current_session
(
client
:
&
Client
,
parent_hash
:
H256
)
->
u32
{
...
...
@@ -93,18 +98,17 @@ pub async fn member_iter(client: &Client, evaluation_block: H256) -> MemberIter
client
.storage
()
.at
(
evaluation_block
)
.iter
(
runtime
::
storage
()
.membership
()
.membership
(
0
)
,
100
)
.iter
(
runtime
::
storage
()
.membership
()
.membership
(
0
))
.await
.expect
(
"Cannot fetch memberships"
),
)
}
pub
struct
MemberIter
(
subxt
::
storage
::
KeyIter
<
crate
::
RuntimeConfig
,
Client
,
subxt
::
backend
::
StreamOfResults
<
(
Vec
<
u8
>
,
runtime
::
runtime_types
::
sp_membership
::
MembershipData
<
u32
>
,
>
,
)
>
,
);
impl
MemberIter
{
...
...
@@ -128,7 +132,7 @@ pub async fn cert_iter(client: &Client, evaluation_block: H256) -> CertIter {
)
}
pub
struct
CertIter
(
subxt
::
storage
::
KeyIter
<
crate
::
RuntimeConfig
,
Client
,
Vec
<
(
IdtyIndex
,
u32
)
>>
);
pub
struct
CertIter
(
subxt
::
backend
::
StreamOfResults
<
(
Vec
<
u8
>
,
Vec
<
(
IdtyIndex
,
u32
)
>
)
>
);
impl
CertIter
{
pub
async
fn
next
(
...
...
@@ -142,6 +146,6 @@ impl CertIter {
}
}
fn
idty_id_from_storage_key
(
storage_key
:
&
Storage
Key
)
->
IdtyIndex
{
fn
idty_id_from_storage_key
<
T
:
subxt
::
Config
>
(
storage_key
:
&
Storage
<
T
,
Client
>
)
->
IdtyIndex
{
u32
::
from_le_bytes
(
storage_key
.as_ref
()[
40
..
44
]
.try_into
()
.unwrap
())
}
This diff is collapsed.
Click to expand it.
distance-oracle/src/lib.rs
+
2
−
3
View file @
152675fb
...
...
@@ -40,8 +40,6 @@ pub mod runtime {}
pub
enum
RuntimeConfig
{}
impl
subxt
::
config
::
Config
for
RuntimeConfig
{
type
Index
=
u32
;
// type BlockNumber = u32;
type
Hash
=
sp_core
::
H256
;
type
Hasher
=
subxt
::
config
::
substrate
::
BlakeTwo256
;
type
AccountId
=
AccountId
;
...
...
@@ -49,7 +47,8 @@ impl subxt::config::Config for RuntimeConfig {
type
Header
=
subxt
::
config
::
substrate
::
SubstrateHeader
<
u32
,
subxt
::
config
::
substrate
::
BlakeTwo256
>
;
type
Signature
=
subxt
::
ext
::
sp_runtime
::
MultiSignature
;
type
ExtrinsicParams
=
subxt
::
config
::
extrinsic_params
::
BaseExtrinsicParams
<
Self
,
Tip
>
;
type
ExtrinsicParams
=
subxt
::
config
::
substrate
::
SubstrateExtrinsicParams
<
Self
>
;
type
AssetId
=
();
}
#[derive(Copy,
Clone,
Debug,
Default,
Encode)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment