Skip to content

Commit

Permalink
[nit] Better protocol config panic error (#16777)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
lxfind authored Mar 23, 2024
1 parent 5e74783 commit 9d1b4a6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/sui-protocol-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,18 @@ impl ProtocolConfig {
/// Get the value ProtocolConfig that are in effect during the given protocol version.
pub fn get_for_version(version: ProtocolVersion, chain: Chain) -> Self {
// ProtocolVersion can be deserialized so we need to check it here as well.
assert!(version.0 >= ProtocolVersion::MIN.0, "{:?}", version);
assert!(version.0 <= ProtocolVersion::MAX_ALLOWED.0, "{:?}", version);
assert!(
version >= ProtocolVersion::MIN,
"Network protocol version is {:?}, but the minimum supported version by the binary is {:?}. Please upgrade the binary.",
version,
ProtocolVersion::MIN.0,
);
assert!(
version <= ProtocolVersion::MAX_ALLOWED,
"Network protocol version is {:?}, but the maximum supported version by the binary is {:?}. Please upgrade the binary.",
version,
ProtocolVersion::MAX_ALLOWED.0,
);

let mut ret = Self::get_for_version_impl(version, chain);
ret.version = version;
Expand Down

0 comments on commit 9d1b4a6

Please sign in to comment.