From 4e56f1c68f9e8478c9fadd1e8b7138376c98c12d Mon Sep 17 00:00:00 2001 From: Age Manning Date: Mon, 17 Jun 2024 09:59:20 +1000 Subject: [PATCH 1/3] Revert to raw encoding for non-list entries (#80) --- src/lib.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b69a4b1..3c7e369 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1041,12 +1041,19 @@ impl Decodable for Enr { _ => { let other_header = Header::decode(payload)?; let value = &payload[..other_header.payload_length]; - // Preserve the valid encoding payload.advance(other_header.payload_length); - let mut out = Vec::::new(); - other_header.encode(&mut out); - out.extend_from_slice(value); - out + + // Encode the header for list values, for non-list objects, we remove the + // header for compatibility with commonly used key entries (i.e it's the + // current convention). + if other_header.list { + let mut out = Vec::::new(); + other_header.encode(&mut out); + out.extend_from_slice(value); + out + } else { + alloy_rlp::encode(value) + } } }; content.insert(key.to_vec(), Bytes::from(value)); @@ -1961,4 +1968,17 @@ mod tests { record.set_seq(30, &key).unwrap(); assert_eq!(record.seq(), 30); } + + /// Tests a common ENR which uses RLP encoded values without the header + #[test] + fn test_common_rlp_convention() { + const COMMON_VALID_ENR: &str = concat!( + "-LW4QCAyOCtqvQjd8AgpqbaCgfjy8oN8cBBRT5jtzarkGJQWZx1eN70EM0QafVCugLa-Bv493DPNzflagqfTOsWSF78Ih2F0d", + "G5ldHOIAGAAAAAAAACEZXRoMpBqlaGpBAAAAP__________gmlkgnY0hHF1aWOCIymJc2VjcDI1NmsxoQPg_HgqXzwRIK39Oy", + "lGdC30YUFwsfXvATnGUvEZ6MtBQIhzeW5jbmV0cwCDdGNwgiMo" + ); + + // Expect this to be able to be decoded + let _decoded: DefaultEnr = COMMON_VALID_ENR.parse().unwrap(); + } } From 855a4f94d1fd2cc1eb36c089a68d25da0a38e1d1 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Sun, 16 Jun 2024 20:04:47 -0400 Subject: [PATCH 2/3] chore: bump secp256k1 to 0.29 (#79) --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ca9bf1d..bd297db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,13 +23,13 @@ sha3 = "0.10" k256 = { version = "0.13", features = ["ecdsa"], optional = true } serde = { version = "1.0", features = ["derive"], optional = true } ed25519-dalek = { version = "2.1.1", optional = true, features = ["rand_core"] } -secp256k1 = { version = "0.28", optional = true, default-features = false, features = [ +secp256k1 = { version = "0.29", optional = true, default-features = false, features = [ "global-context", ] } [dev-dependencies] alloy-rlp = { version = "0.3.4", features = ["derive"] } -secp256k1 = { version = "0.28", features = ["rand-std"] } +secp256k1 = { version = "0.29", features = ["rand-std"] } serde_json = "1.0" [features] From 497349ded9793b4248084ee5caf83b6c8ab26fe8 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Sun, 16 Jun 2024 20:07:08 -0400 Subject: [PATCH 3/3] chore: add .DS_Store and others to gitignore (#78) --- .gitignore | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fa8d85a..b6012ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,25 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# This project does not check in Cargo.lock Cargo.lock -target + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by Intellij-based IDEs. +.idea + +# Generated by MacOS +.DS_Store + +# VSCode +.vscode + +# Rust bug report +rustc-ice-*