Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions light-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,7 @@ mod test {
additional_header_item_count: 0,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
}];
(client_state, cons_state)
}));
Expand All @@ -1382,6 +1383,7 @@ mod test {
additional_header_item_count: 0,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
}];
(client_state, cons_state)
}));
Expand All @@ -1396,6 +1398,7 @@ mod test {
additional_header_item_count: 0,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
}];
(client_state, cons_state)
}))
Expand Down
1 change: 1 addition & 0 deletions light-client/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ mod test {
additional_header_item_count: 1, // requestsHash
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
}
}

Expand Down
4 changes: 4 additions & 0 deletions light-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub enum Error {
MissingSignerInValidator(BlockNumber, Address),
UnexpectedGasDiff(BlockNumber, u64, u64),
UnexpectedGasUsed(BlockNumber, u64, u64),
UnexpectedGasLimitDivider(BlockNumber),
UnexpectedHeaderRelation(BlockNumber, BlockNumber, Hash, Vec<u8>, u64, u64),
ProofRLPError(rlp::DecoderError),
InvalidProofFormatError(Vec<u8>),
Expand Down Expand Up @@ -506,6 +507,9 @@ impl core::fmt::Display for Error {
Error::UnexpectedEpochInfo(e1, e2) => {
write!(f, "UnexpectedEpochInfo : {} {}", e1, e2)
}
Error::UnexpectedGasLimitDivider(e1) => {
write!(f, "UnexpectedGasLimitDivider : {}", e1)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions light-client/src/fixture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub fn fork_spec_after_pascal() -> ForkSpec {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 64,
gas_limit_bound_divider: 256,
}
}

Expand All @@ -84,6 +85,7 @@ pub fn fork_spec_after_lorentz() -> ForkSpec {
additional_header_item_count: 1,
epoch_length: 500,
max_turn_length: 64,
gas_limit_bound_divider: 1024,
}
}

Expand All @@ -93,5 +95,6 @@ pub fn fork_spec_after_maxwell() -> ForkSpec {
additional_header_item_count: 1,
epoch_length: 1000,
max_turn_length: 64,
gas_limit_bound_divider: 1024,
}
}
33 changes: 33 additions & 0 deletions light-client/src/fork_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct ForkSpec {
pub epoch_length: u64,
/// Max turn length
pub max_turn_length: u64,
/// Gas Limit bound diriver
pub gas_limit_bound_divider: u64,
}

impl ForkSpec {
Expand Down Expand Up @@ -182,6 +184,7 @@ impl TryFrom<RawForkSpec> for ForkSpec {
additional_header_item_count: value.additional_header_item_count,
epoch_length: value.epoch_length,
max_turn_length: value.max_turn_length,
gas_limit_bound_divider: value.gas_limit_bound_divider,
})
}
}
Expand All @@ -198,6 +201,7 @@ impl From<ForkSpec> for RawForkSpec {
additional_header_item_count: value.additional_header_item_count,
epoch_length: value.epoch_length,
max_turn_length: value.max_turn_length,
gas_limit_bound_divider: value.gas_limit_bound_divider,
}
}
}
Expand Down Expand Up @@ -290,12 +294,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(20),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = find_target_fork_spec(specs, 10, 0).unwrap();
Expand All @@ -316,12 +322,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(20),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = find_target_fork_spec(specs, 0, 10).unwrap();
Expand All @@ -342,12 +350,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(10),
additional_header_item_count: 20,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
// After value is primary
Expand All @@ -369,12 +379,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(20),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = find_target_fork_spec(specs, 9, 0).unwrap_err();
Expand All @@ -395,12 +407,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(20),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = find_target_fork_spec(specs, 0, 9).unwrap_err();
Expand All @@ -421,12 +435,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(10),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = find_target_fork_spec(specs, 9, 9).unwrap_err();
Expand All @@ -447,12 +463,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(11),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
verify_sorted_asc(specs).unwrap();
Expand All @@ -466,12 +484,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(11),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
verify_sorted_asc(specs).unwrap();
Expand All @@ -485,12 +505,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(10),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = verify_sorted_asc(specs).unwrap_err();
Expand All @@ -508,12 +530,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(10),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = verify_sorted_asc(specs).unwrap_err();
Expand All @@ -534,12 +558,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(10),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = verify_sorted_asc(specs).unwrap_err();
Expand All @@ -557,12 +583,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Time(10),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = verify_sorted_asc(specs).unwrap_err();
Expand All @@ -582,6 +610,7 @@ mod test {
additional_header_item_count: 1,
epoch_length: 500,
max_turn_length: 64,
gas_limit_bound_divider: 256,
};
match current
.boundary_epochs(&fork_spec_after_pascal())
Expand Down Expand Up @@ -705,12 +734,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(20),
additional_header_item_count: 2,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = get_boundary_epochs(&fork_spec_after_pascal(), specs).unwrap_err();
Expand All @@ -730,12 +761,14 @@ mod test {
additional_header_item_count: 1,
epoch_length: 200,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
ForkSpec {
height_or_timestamp: HeightOrTimestamp::Height(20),
additional_header_item_count: 2,
epoch_length: 500,
max_turn_length: 9,
gas_limit_bound_divider: 256,
},
];
let v = get_boundary_epochs(&specs[1], specs).unwrap();
Expand Down
Loading
Loading