Skip to content

Commit cebe0ae

Browse files
authored
Merge pull request #2 from scrtlabs/revert-implicit-hash
Revert implicit hash
2 parents 9067bdc + 945e948 commit cebe0ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1044
-792
lines changed

light-client-detector/src/evidence.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub fn make_evidence(
5353
fn conflicting_header_is_invalid(conflicted: &Header, trusted: &Header) -> bool {
5454
trusted.validators_hash != conflicted.validators_hash
5555
|| trusted.next_validators_hash != conflicted.next_validators_hash
56-
|| trusted.implicit_hash != conflicted.implicit_hash
5756
|| trusted.consensus_hash != conflicted.consensus_hash
5857
|| trusted.app_hash != conflicted.app_hash
5958
|| trusted.last_results_hash != conflicted.last_results_hash

light-client-js/tests/web.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const UNTRUSTED_BLOCK: &str = r#"{
2626
"data_hash": null,
2727
"validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068",
2828
"next_validators_hash": "C8CFFADA9808F685C4111693E1ADFDDBBEE9B9493493BEF805419F143C5B0D0A",
29-
"implicit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
3029
"consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068",
3130
"app_hash": "",
3231
"last_results_hash": null,
@@ -99,7 +98,6 @@ const TRUSTED_BLOCK: &str = r#"{
9998
"data_hash": null,
10099
"validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068",
101100
"next_validators_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068",
102-
"implicit_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
103101
"consensus_hash": "75E6DD63C2DC2B58FE0ED82792EAB369C4308C7EC16B69446382CC4B41D46068",
104102
"app_hash": "",
105103
"last_results_hash": null,

light-client-verifier/src/errors.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,6 @@ define_error! {
9393
e.header_next_validators_hash, e.next_validators_hash)
9494
},
9595

96-
InvalidImplicitHash
97-
{
98-
header_implicit_hash: Option<Hash>,
99-
implicit_hash: Option<Hash>,
100-
}
101-
| e | {
102-
format_args!("invalid implicit hash: header_implicit_hash={:?} implicit_hash={:?}",
103-
e.header_implicit_hash, e.implicit_hash)
104-
},
105-
10696
InvalidValidatorSet
10797
{
10898
header_validators_hash: Hash,

light-client-verifier/src/predicates.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ pub trait VerificationPredicates: Send + Sync {
6969
}
7070
}
7171

72-
fn implicit_hash_match(
73-
&self,
74-
implicit_hash: Option<Hash>,
75-
header_implicit_hash: Option<Hash>,
76-
) -> Result<(), VerificationError> {
77-
if header_implicit_hash == implicit_hash {
78-
Ok(())
79-
} else {
80-
Err(VerificationError::invalid_implicit_hash(
81-
header_implicit_hash,
82-
implicit_hash,
83-
))
84-
}
85-
}
86-
8772
/// Check that the hash of the header in the commit matches the actual one.
8873
fn header_matches_commit(
8974
&self,

light-client-verifier/src/types.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,13 @@ pub struct TrustedBlockState<'a> {
8484
pub height: Height,
8585
pub next_validators: &'a ValidatorSet,
8686
pub next_validators_hash: Hash,
87-
pub implicit_hash: Option<Hash>,
8887
}
8988

9089
/// Untrusted block parameters needed for light client verification.
9190
pub struct UntrustedBlockState<'a> {
9291
pub signed_header: &'a SignedHeader,
9392
pub validators: &'a ValidatorSet,
9493
pub next_validators: Option<&'a ValidatorSet>,
95-
pub implicit_hash: Option<Hash>,
9694
}
9795

9896
impl<'a> UntrustedBlockState<'a> {
@@ -160,7 +158,6 @@ impl LightBlock {
160158
height: self.signed_header.header.height,
161159
next_validators: &self.next_validators,
162160
next_validators_hash: self.signed_header.header.next_validators_hash,
163-
implicit_hash: self.signed_header.header.implicit_hash,
164161
}
165162
}
166163

@@ -171,7 +168,6 @@ impl LightBlock {
171168
signed_header: &self.signed_header,
172169
validators: &self.validators,
173170
next_validators: Some(&self.next_validators),
174-
implicit_hash: self.signed_header.header.implicit_hash,
175171
}
176172
}
177173
}

light-client-verifier/src/verifier.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,6 @@ where
147147
Verdict::Success
148148
}
149149

150-
pub fn verify_implicit(&self, untrusted: &UntrustedBlockState<'_>) -> Verdict {
151-
verdict!(self.predicates.implicit_hash_match(
152-
untrusted.implicit_hash,
153-
untrusted.signed_header.header.implicit_hash,
154-
));
155-
156-
Verdict::Success
157-
}
158-
159150
/// Validate an `UntrustedBlockState` coming from a client update,
160151
/// based on the given `TrustedBlockState`, `Options` and current time.
161152
pub fn validate_against_trusted(
@@ -309,7 +300,6 @@ where
309300
now: Time,
310301
) -> Verdict {
311302
ensure_verdict_success!(self.verify_validator_sets(&untrusted));
312-
ensure_verdict_success!(self.verify_implicit(&untrusted));
313303
ensure_verdict_success!(self.validate_against_trusted(&untrusted, &trusted, options, now));
314304
ensure_verdict_success!(self.check_header_is_from_past(&untrusted, options, now));
315305
ensure_verdict_success!(self.verify_commit_against_trusted(&untrusted, &trusted, options));
@@ -328,7 +318,6 @@ where
328318
now: Time,
329319
) -> Verdict {
330320
ensure_verdict_success!(self.verify_validator_sets(&untrusted));
331-
ensure_verdict_success!(self.verify_implicit(&untrusted));
332321
ensure_verdict_success!(self.validate_against_trusted(&untrusted, &trusted, options, now));
333322
ensure_verdict_success!(self.verify_commit_against_trusted(&untrusted, &trusted, options));
334323
Verdict::Success

light-client/src/builder/light_client.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,7 @@ where
201201
light_block.signed_header.header.next_validators_hash,
202202
)
203203
.map_err(Error::invalid_light_block)?;
204-
// self.predicates
205-
// .implicit_hash_match(
206-
// &light_block,
207-
// light_block.signed_header.header.implicit_hash,
208-
// )
209-
// .map_err(Error::invalid_light_block)?;
204+
210205
Ok(())
211206
}
212207
}

0 commit comments

Comments
 (0)