Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -1372,6 +1372,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 @@ -1385,6 +1386,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 @@ -1399,6 +1401,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 @@ -509,6 +510,9 @@ impl core::fmt::Display for Error {
Error::UnexpectedEpochInfo(e1, e2) => {
write!(f, "UnexpectedEpochInfo : {} {}", e1, e2)
}
Error::UnexpectedGasLimitDivider(e1) => {
write!(f, "UnexpectedGasLimitDivider : {}", e1)
}
Error::UnexpectedEpochLength(e1, e2) => {
write!(f, "UnexpectedEpochLength : {} {}", e1, e2)
}
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,
}
}
35 changes: 35 additions & 0 deletions light-client/src/fork_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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 @@ -201,6 +203,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 @@ -217,6 +220,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 @@ -308,12 +312,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 @@ -334,12 +340,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 @@ -360,12 +368,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 @@ -387,12 +397,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 @@ -413,12 +425,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 @@ -439,12 +453,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 @@ -465,12 +481,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 @@ -484,12 +502,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 @@ -503,12 +523,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 @@ -526,12 +548,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 @@ -552,12 +576,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 @@ -575,12 +601,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 @@ -600,6 +628,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 All @@ -619,6 +648,7 @@ mod test {
additional_header_item_count: 1,
epoch_length: 0,
max_turn_length: 64,
gas_limit_bound_divider: 256,
};
match current
.boundary_epochs(&fork_spec_after_pascal())
Expand All @@ -639,6 +669,7 @@ mod test {
additional_header_item_count: 1,
epoch_length: 0,
max_turn_length: 64,
gas_limit_bound_divider: 256,
};
match fork_spec_after_pascal()
.boundary_epochs(&previous)
Expand Down Expand Up @@ -763,12 +794,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 @@ -788,12 +821,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