Skip to content

Commit

Permalink
[enclave/chain_relay] store only hashes of the headers instead of the…
Browse files Browse the repository at this point in the history
… headers themselves
  • Loading branch information
Christian Langenbacher committed Aug 20, 2020
1 parent 42f55ab commit 503b9a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions enclave/chain_relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl LightValidation {

if grandpa_proof.is_none() {
relay.last_finalized_block_header = header.clone();
relay.unjustified_headers.push(header);
relay.unjustified_headers.push(header.hash());
info!(
"Syncing finalized block without grandpa proof. Amount of unjustified headers: {}",
relay.unjustified_headers.len()
Expand All @@ -142,8 +142,8 @@ impl LightValidation {
Self::schedule_validator_set_change(&mut relay, &header);

// a valid grandpa proof proofs finalization of all previous unjustified blocks
relay.headers.append(&mut relay.unjustified_headers);
relay.headers.push(header);
relay.header_hashes.append(&mut relay.unjustified_headers);
relay.header_hashes.push(header.hash());

if validator_set_id > relay.current_validator_set_id {
relay.current_validator_set = validator_set;
Expand Down Expand Up @@ -241,7 +241,7 @@ impl LightValidation {
.tracked_relays
.get(&relay_id)
.ok_or(Error::NoSuchRelayExists)?;
Ok(relay.headers[0].hash())
Ok(relay.header_hashes[0])
}

pub fn latest_header(&self, relay_id: RelayId) -> Result<Header, Error> {
Expand Down
6 changes: 3 additions & 3 deletions enclave/chain_relay/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct RelayState<Block: BlockT> {
pub last_finalized_block_header: Block::Header,
pub current_validator_set: AuthorityList,
pub current_validator_set_id: SetId,
pub headers: Vec<Block::Header>,
pub unjustified_headers: Vec<Block::Header>, // Finalized headers without grandpa proof
pub header_hashes: Vec<Block::Hash>,
pub unjustified_headers: Vec<Block::Hash>, // Finalized headers without grandpa proof
pub verify_tx_inclusion: Vec<OpaqueExtrinsic>, // Transactions sent by the relay
pub scheduled_change: Option<ScheduledChangeAtBlock<Block::Header>>, // Scheduled Authorities change as indicated in the header's digest.
}
Expand All @@ -28,7 +28,7 @@ impl<Block: BlockT> RelayState<Block> {
last_finalized_block_header: block_header.clone(),
current_validator_set: validator_set,
current_validator_set_id: 0,
headers: vec![block_header],
header_hashes: vec![block_header.hash()],
unjustified_headers: Vec::new(),
verify_tx_inclusion: Vec::new(),
scheduled_change: None,
Expand Down

0 comments on commit 503b9a3

Please sign in to comment.