mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Use yaml_serde in place of deprecated serde_yaml (#9040)
`serde_yaml` is now deprecated. The API-compatible `yaml_serde` should be used instead. Replace `serde_yaml` with `yaml_serde`. This is purely mechanical as the API is 1-to-1. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -14,6 +14,6 @@ ethereum_ssz_derive = { workspace = true }
|
||||
fixed_bytes = { workspace = true }
|
||||
safe_arith = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
superstruct = { workspace = true }
|
||||
types = { workspace = true }
|
||||
yaml_serde = { workspace = true }
|
||||
|
||||
@@ -22,5 +22,5 @@ fn main() {
|
||||
|
||||
fn write_test_def_to_yaml(filename: &str, def: ForkChoiceTestDefinition) {
|
||||
let file = File::create(filename).expect("Should be able to open file");
|
||||
serde_yaml::to_writer(file, &def).expect("Should be able to write YAML to file");
|
||||
yaml_serde::to_writer(file, &def).expect("Should be able to write YAML to file");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ rusqlite = { workspace = true, optional = true }
|
||||
safe_arith = { workspace = true }
|
||||
serde = { workspace = true, features = ["rc"] }
|
||||
serde_json = { workspace = true }
|
||||
serde_yaml = { workspace = true }
|
||||
smallvec = { workspace = true }
|
||||
ssz_types = { workspace = true }
|
||||
superstruct = { workspace = true }
|
||||
@@ -64,6 +63,7 @@ tracing = { workspace = true }
|
||||
tree_hash = { workspace = true }
|
||||
tree_hash_derive = { workspace = true }
|
||||
typenum = { workspace = true }
|
||||
yaml_serde = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
beacon_chain = { workspace = true }
|
||||
|
||||
@@ -2531,7 +2531,7 @@ impl Config {
|
||||
pub fn from_file(filename: &Path) -> Result<Self, String> {
|
||||
let f = File::open(filename)
|
||||
.map_err(|e| format!("Error opening spec at {}: {:?}", filename.display(), e))?;
|
||||
serde_yaml::from_reader(f)
|
||||
yaml_serde::from_reader(f)
|
||||
.map_err(|e| format!("Error parsing spec at {}: {:?}", filename.display(), e))
|
||||
}
|
||||
|
||||
@@ -2869,7 +2869,7 @@ mod yaml_tests {
|
||||
|
||||
let yamlconfig = Config::from_chain_spec::<MinimalEthSpec>(&minimal_spec);
|
||||
// write fresh minimal config to file
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
@@ -2877,7 +2877,7 @@ mod yaml_tests {
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
// deserialize minimal config from file
|
||||
let from: Config = serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
let from: Config = yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(from, yamlconfig);
|
||||
}
|
||||
|
||||
@@ -2891,14 +2891,14 @@ mod yaml_tests {
|
||||
.expect("error opening file");
|
||||
let mainnet_spec = ChainSpec::mainnet();
|
||||
let yamlconfig = Config::from_chain_spec::<MainnetEthSpec>(&mainnet_spec);
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
.write(false)
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
let from: Config = serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
let from: Config = yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(from, yamlconfig);
|
||||
}
|
||||
|
||||
@@ -2960,7 +2960,7 @@ mod yaml_tests {
|
||||
MAX_BLOBS_PER_BLOCK: 20
|
||||
"#;
|
||||
let config: Config =
|
||||
serde_yaml::from_str(spec_contents).expect("error while deserializing");
|
||||
yaml_serde::from_str(spec_contents).expect("error while deserializing");
|
||||
let spec =
|
||||
ChainSpec::from_config::<MainnetEthSpec>(&config).expect("error while creating spec");
|
||||
|
||||
@@ -3042,11 +3042,11 @@ mod yaml_tests {
|
||||
assert_eq!(spec.max_blobs_per_block_within_fork(ForkName::Fulu), 20);
|
||||
|
||||
// Check that serialization is in ascending order
|
||||
let yaml = serde_yaml::to_string(&spec.blob_schedule).expect("should serialize");
|
||||
let yaml = yaml_serde::to_string(&spec.blob_schedule).expect("should serialize");
|
||||
|
||||
// Deserialize back to Vec<BlobParameters> to check order
|
||||
let deserialized: Vec<BlobParameters> =
|
||||
serde_yaml::from_str(&yaml).expect("should deserialize");
|
||||
yaml_serde::from_str(&yaml).expect("should deserialize");
|
||||
|
||||
// Should be in ascending order by epoch
|
||||
assert!(
|
||||
@@ -3113,7 +3113,7 @@ mod yaml_tests {
|
||||
MAX_BLOBS_PER_BLOCK: 300
|
||||
"#;
|
||||
let config: Config =
|
||||
serde_yaml::from_str(spec_contents).expect("error while deserializing");
|
||||
yaml_serde::from_str(spec_contents).expect("error while deserializing");
|
||||
let spec =
|
||||
ChainSpec::from_config::<MainnetEthSpec>(&config).expect("error while creating spec");
|
||||
|
||||
@@ -3203,7 +3203,7 @@ mod yaml_tests {
|
||||
SAMPLES_PER_SLOT: 8
|
||||
"#;
|
||||
|
||||
let chain_spec: Config = serde_yaml::from_str(spec).unwrap();
|
||||
let chain_spec: Config = yaml_serde::from_str(spec).unwrap();
|
||||
|
||||
// Asserts that `chain_spec.$name` and `default_$name()` are equal.
|
||||
macro_rules! check_default {
|
||||
|
||||
@@ -174,7 +174,7 @@ mod test {
|
||||
yamlconfig.extra_fields_mut().insert(k3.into(), v3.into());
|
||||
yamlconfig.extra_fields_mut().insert(k4.into(), v4);
|
||||
|
||||
serde_yaml::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
yaml_serde::to_writer(writer, &yamlconfig).expect("failed to write or serialize");
|
||||
|
||||
let reader = File::options()
|
||||
.read(true)
|
||||
@@ -182,7 +182,7 @@ mod test {
|
||||
.open(tmp_file.as_ref())
|
||||
.expect("error while opening the file");
|
||||
let from: ConfigAndPresetGloas =
|
||||
serde_yaml::from_reader(reader).expect("error while deserializing");
|
||||
yaml_serde::from_reader(reader).expect("error while deserializing");
|
||||
assert_eq!(ConfigAndPreset::Gloas(from), yamlconfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ mod test {
|
||||
fn preset_from_file<T: DeserializeOwned>(preset_name: &str, filename: &str) -> T {
|
||||
let f = File::open(presets_base_path().join(preset_name).join(filename))
|
||||
.expect("preset file exists");
|
||||
serde_yaml::from_reader(f).unwrap()
|
||||
yaml_serde::from_reader(f).unwrap()
|
||||
}
|
||||
|
||||
fn preset_test<E: EthSpec>() {
|
||||
|
||||
Reference in New Issue
Block a user