mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
Merge commit '392447f5c8f986ded2559a78457f4cd87942f393' into update-bridges-subtree-r/w
This commit is contained in:
@@ -7,9 +7,9 @@ edition = "2018"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0" }
|
||||
ethereum-types = "0.11.0"
|
||||
finality-grandpa = "0.14.4"
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0" }
|
||||
ethereum-types = "0.12.0"
|
||||
finality-grandpa = "0.14.0"
|
||||
hex = "0.4"
|
||||
log = "0.4.14"
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ pub enum Error {
|
||||
BlockNumberDecode,
|
||||
/// Failed to decode Substrate header.
|
||||
HeaderDecode(codec::Error),
|
||||
/// Failed to decode best voters set.
|
||||
/// Failed to decode the best voters set.
|
||||
BestSetDecode(codec::Error),
|
||||
/// Best voters set is invalid.
|
||||
/// The best voters set is invalid.
|
||||
InvalidBestSet,
|
||||
/// Failed to decode finality proof.
|
||||
FinalityProofDecode(codec::Error),
|
||||
@@ -135,7 +135,9 @@ pub fn verify_substrate_finality_proof(
|
||||
) -> Result<(), Error> {
|
||||
let best_set = AuthorityList::decode(&mut &*raw_best_set)
|
||||
.map_err(Error::BestSetDecode)
|
||||
.and_then(|authorities| VoterSet::new(authorities.into_iter()).ok_or(Error::InvalidBestSet));
|
||||
.and_then(|authorities| {
|
||||
VoterSet::new(authorities.into_iter()).ok_or(Error::InvalidBestSet)
|
||||
});
|
||||
|
||||
log::debug!(
|
||||
target: "bridge-builtin",
|
||||
@@ -150,15 +152,16 @@ pub fn verify_substrate_finality_proof(
|
||||
|
||||
let best_set = best_set?;
|
||||
|
||||
let verify_result = sc_finality_grandpa::GrandpaJustification::<Block>::decode_and_verify_finalizes(
|
||||
raw_finality_proof,
|
||||
(finality_target_hash, finality_target_number),
|
||||
best_set_id,
|
||||
&best_set,
|
||||
)
|
||||
.map_err(Box::new)
|
||||
.map_err(Error::JustificationVerify)
|
||||
.map(|_| ());
|
||||
let verify_result =
|
||||
sc_finality_grandpa::GrandpaJustification::<Block>::decode_and_verify_finalizes(
|
||||
raw_finality_proof,
|
||||
(finality_target_hash, finality_target_number),
|
||||
best_set_id,
|
||||
&best_set,
|
||||
)
|
||||
.map_err(Box::new)
|
||||
.map_err(Error::JustificationVerify)
|
||||
.map(|_| ());
|
||||
|
||||
log::debug!(
|
||||
target: "bridge-builtin",
|
||||
@@ -202,10 +205,7 @@ mod tests {
|
||||
#[test]
|
||||
fn from_substrate_block_number_succeeds() {
|
||||
assert_eq!(from_substrate_block_number(0).unwrap(), U256::zero());
|
||||
assert_eq!(
|
||||
from_substrate_block_number(std::u32::MAX).unwrap(),
|
||||
U256::from(std::u32::MAX)
|
||||
);
|
||||
assert_eq!(from_substrate_block_number(std::u32::MAX).unwrap(), U256::from(std::u32::MAX));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -285,10 +285,7 @@ mod tests {
|
||||
.parse()
|
||||
.unwrap(),
|
||||
number: 8,
|
||||
signal: Some(ValidatorsSetSignal {
|
||||
delay: 8,
|
||||
validators: authorities.encode(),
|
||||
}),
|
||||
signal: Some(ValidatorsSetSignal { delay: 8, validators: authorities.encode() }),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -296,13 +293,14 @@ mod tests {
|
||||
/// Number of the example block with justification.
|
||||
const EXAMPLE_JUSTIFIED_BLOCK_NUMBER: u32 = 8;
|
||||
/// Hash of the example block with justification.
|
||||
const EXAMPLE_JUSTIFIED_BLOCK_HASH: &str = "a2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f343775";
|
||||
/// Id of authorities set that have generated example justification. Could be computed by tracking
|
||||
/// every set change in canonized headers.
|
||||
const EXAMPLE_JUSTIFIED_BLOCK_HASH: &str =
|
||||
"a2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f343775";
|
||||
/// Id of authorities set that have generated example justification. Could be computed by
|
||||
/// tracking every set change in canonized headers.
|
||||
const EXAMPLE_AUTHORITIES_SET_ID: u64 = 0;
|
||||
/// Encoded authorities set that has generated example justification. Could be fetched from `ScheduledChange`
|
||||
/// digest of the block that has scheduled this set OR by calling `GrandpaApi::grandpa_authorities()` at
|
||||
/// appropriate block.
|
||||
/// Encoded authorities set that has generated example justification. Could be fetched from
|
||||
/// `ScheduledChange` digest of the block that has scheduled this set OR by calling
|
||||
/// `GrandpaApi::grandpa_authorities()` at appropriate block.
|
||||
const EXAMPLE_AUTHORITIES_SET: &str = "1488dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee0100000000000000d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae690100000000000000439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234f01000000000000005e639b43e0052c47447dac87d6fd2b6ec50bdd4d0f614e4299c665249bbd09d901000000000000001dfe3e22cc0d45c70779c1095f7489a8ef3cf52d62fbd8c2fa38c9f1723502b50100000000000000";
|
||||
/// Example justification. Could be fetched by calling 'chain_getBlock' RPC.
|
||||
const EXAMPLE_JUSTIFICATION: &str = "2600000000000000a2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f3437750800000010a2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f34377508000000d66b4ceb57ef8bcbc955071b597c8c5d2adcfdbb009c73f8438d342670fdeca9ac60686cbd58105b10f51d0a64a8e73b2e5829b2eab3248a008c472852130b00439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234fa2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f34377508000000f5730c14d3cd22b7661e2f5fcb3139dd5fef37f946314a441d01b40ce1200ef70d810525f23fd278b588cd67473c200bda83c338c407b479386aa83798e5970b5e639b43e0052c47447dac87d6fd2b6ec50bdd4d0f614e4299c665249bbd09d9a2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f34377508000000c78d6ec463f476461a695b4791d30e7626d16fdf72d7c252c2cad387495a97e8c2827ed4d5af853d6e05d31cb6fb7438c9481a7e9c6990d60a9bfaf6a6e1930988dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eea2f45892db86b2ad133ce57d81b7e4375bb7035ce9883e6b68c358164f3437750800000052b4fc52d430286b3e2d650aa6e01b6ff4fae8b968893a62be789209eb97ee6e23780d3f5af7042d85bb48f1b202890b22724dfebce138826f66a5e00324320fd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae6900";
|
||||
|
||||
Reference in New Issue
Block a user