-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Update bridge pallet to work with the (almost) lastest master #4672
Update bridge pallet to work with the (almost) lastest master #4672
Conversation
Main change was updating the usage of InMemoryBackend
It looks like @HCastano signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
frame/bridge/src/lib.rs
Outdated
)?; | ||
); | ||
|
||
// TODO: Remove once I can impl From<StorageError> for DispatchError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I would've like to have implemented this, but with the way decl_error!
is written at the moment I'm not able to do this. If anybody has any better ideas than the map_storage_err
function I'm using at the moment I'm all ears.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be just
let checker = checker.map_err(Self::map_storage_err)?;
I don't think that it's so bad that it requires a TODO
line in the code. Feel free to create an issue for this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
frame/bridge/src/lib.rs
Outdated
)?; | ||
); | ||
|
||
// TODO: Remove once I can impl From<StorageError> for DispatchError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be just
let checker = checker.map_err(Self::map_storage_err)?;
I don't think that it's so bad that it requires a TODO
line in the code. Feel free to create an issue for this though.
frame/bridge/src/lib.rs
Outdated
.ok_or(Error::StorageValueUnavailable)?; | ||
|
||
// TODO: Remove once I can impl From<StorageError> for DispatchError | ||
let actual_validator_set = match checker.read_value(b":grandpa_authorities") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
let actual_validator_set = checker.read_value(MOVED_TO_CONSTANT).map_err(Self::map_storage_err)?
let actual_validator_set = actual_validator_set.ok_or(Error::<T>::StorageValueUnavailable))?;
frame/bridge/src/lib.rs
Outdated
} | ||
|
||
Err(Error::InvalidAncestryProof) | ||
// TODO: Remove once I can impl From<StorageError> for DispatchError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO the function is fine.
// TODO: Remove once I can impl From<StorageError> for DispatchError |
frame/bridge/src/lib.rs
Outdated
match e { | ||
StorageError::StorageRootMismatch => Error::<T>::StorageRootMismatch.into(), | ||
StorageError::StorageValueUnavailable => Error::<T>::StorageValueUnavailable.into(), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
}.into() |
You could put into
here to avoid duplication, but it's a minor thing.
frame/bridge/src/lib.rs
Outdated
let backend = <InMemory<Blake2Hasher>>::from(vec![ | ||
(None, b":grandpa_authorities".to_vec(), Some(encoded_set)), | ||
let backend = <InMemoryBackend<Blake2Hasher>>::from(vec![ | ||
(None, vec![(b":grandpa_authorities".to_vec(), Some(encoded_set))]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string should come from the same constant.
frame/bridge/src/lib.rs
Outdated
]); | ||
let root = backend.storage_root(std::iter::empty()).0; | ||
|
||
// Generates a storage read proof | ||
let proof = prove_read(backend, &[&b":grandpa_authorities"[..]]).unwrap(); | ||
let proof: StorageProof = prove_read(backend, &[&b":grandpa_authorities"[..]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
I've rebased the
hc-jp-bridge-module
branch ontomaster
from last week-ish, and now in this PR I've make some changes to make the pallet compile. The two main things are using the newdecl_error!
changes introduced by Basti, and updating dependencies to use their 2.0.0 versions.