Skip to content

Commit

Permalink
Upgrade borsh to v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbrink committed Nov 29, 2023
1 parent 47c887c commit d5bb942
Show file tree
Hide file tree
Showing 9 changed files with 2,012 additions and 1,865 deletions.
2,115 changes: 1,099 additions & 1,016 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ark-bls12-381 = {version = "0.3"}
ark-serialize = {version = "0.3"}
ark-std = "0.3.0"
# branch = "bat/arse-merkle-tree"
arse-merkle-tree = {package = "sparse-merkle-tree", git = "https://github.com/heliaxdev/sparse-merkle-tree", rev = "aed81070ce2c83a41e1c6bada757347f33ef8eb6", default-features = false, features = ["std", "borsh"]}
arse-merkle-tree = {package = "sparse-merkle-tree", git = "https://github.com/heliaxdev/sparse-merkle-tree", rev = "515687fe7884cb365067ac86c66ac3613de176bb", default-features = false, features = ["std", "borsh"]}
assert_cmd = "1.0.7"
assert_matches = "1.5.0"
async-trait = {version = "0.1.51"}
Expand All @@ -53,8 +53,8 @@ bit-set = "0.5.2"
blake2b-rs = "0.2.0"
byte-unit = "4.0.13"
byteorder = "1.4.2"
borsh = {version = "1.0.0-alpha.4", features = ["schema", "derive"]}
borsh-ext = {tag = "v1.0.0-alpha.4", git = "https://github.com/heliaxdev/borsh-ext"}
borsh = {version = "1.2.0", features = ["unstable__schema", "derive"]}
borsh-ext = { git = "https://github.com/heliaxdev/borsh-ext", tag = "v1.2.0" }
chrono = {version = "0.4.22", default-features = false, features = ["clock", "std"]}
circular-queue = "0.2.6"
clap = "4.3.4"
Expand All @@ -80,9 +80,9 @@ fd-lock = "3.0.12"
flate2 = "1.0.22"
fs_extra = "1.2.0"
futures = "0.3"
git2 = "0.13.25"
git2 = "0.18.1"
ics23 = "0.11.0"
index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.8.0", features = ["serialize-borsh", "serialize-serde"]}
index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", features = ["serialize-borsh", "serialize-serde"] }
itertools = "0.10.0"
k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]}
lazy_static = "1.4.0"
Expand All @@ -91,8 +91,8 @@ ledger-transport-hid = "0.10.0"
libc = "0.2.97"
libloading = "0.7.2"
# branch = "murisi/namada-integration"
masp_primitives = { git = "https://github.com/anoma/masp", rev = "77e009626f3f52fe83c81ec6ee38fc2547d38da3" }
masp_proofs = { git = "https://github.com/anoma/masp", rev = "77e009626f3f52fe83c81ec6ee38fc2547d38da3", default-features = false, features = ["local-prover"] }
masp_primitives = { git = "https://github.com/anoma/masp", tag = "v1.0.0" }
masp_proofs = { git = "https://github.com/anoma/masp", tag = "v1.0.0", default-features = false, features = ["local-prover"] }
num256 = "0.3.5"
num_cpus = "1.13.0"
num-derive = "0.3.3"
Expand Down
30 changes: 24 additions & 6 deletions core/src/types/key/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ impl BorshSchema for PublicKey {
) {
// Encoded as `[u8; PUBLIC_KEY_LENGTH]`
let elements = "u8".into();
let length = PUBLIC_KEY_LENGTH as u32;
let definition = borsh::schema::Definition::Array { elements, length };
let length = PUBLIC_KEY_LENGTH as u64;
// let definition = borsh::schema::Definition::Array { elements, length
// };
let definition = borsh::schema::Definition::Sequence {
length_width: 0,
length_range: 0..=length,
elements,
};
definitions.insert(Self::declaration(), definition);
}

Expand Down Expand Up @@ -198,8 +204,14 @@ impl BorshSchema for SecretKey {
) {
// Encoded as `[u8; SECRET_KEY_LENGTH]`
let elements = "u8".into();
let length = SECRET_KEY_LENGTH as u32;
let definition = borsh::schema::Definition::Array { elements, length };
let length = SECRET_KEY_LENGTH as u64;
// let definition = borsh::schema::Definition::Array { elements, length
// };
let definition = borsh::schema::Definition::Sequence {
length_width: 0,
length_range: 0..=length,
elements,
};
definitions.insert(Self::declaration(), definition);
}

Expand Down Expand Up @@ -279,8 +291,14 @@ impl BorshSchema for Signature {
) {
// Encoded as `[u8; SIGNATURE_LENGTH]`
let elements = "u8".into();
let length = SIGNATURE_LENGTH as u32;
let definition = borsh::schema::Definition::Array { elements, length };
let length = SIGNATURE_LENGTH as u64;
// let definition = borsh::schema::Definition::Array { elements, length
// };
let definition = borsh::schema::Definition::Sequence {
length_width: 0,
length_range: 0..=length,
elements,
};
definitions.insert(Self::declaration(), definition);
}

Expand Down
20 changes: 16 additions & 4 deletions core/src/types/key/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ impl BorshSchema for PublicKey {
) {
// Encoded as `[u8; COMPRESSED_PUBLIC_KEY_SIZE]`
let elements = "u8".into();
let length = COMPRESSED_PUBLIC_KEY_SIZE as u32;
let definition = borsh::schema::Definition::Array { elements, length };
let length = COMPRESSED_PUBLIC_KEY_SIZE as u64;
// let definition = borsh::schema::Definition::Array { elements, length
// };
let definition = borsh::schema::Definition::Sequence {
length_width: 0,
length_range: 0..=length,
elements,
};
definitions.insert(Self::declaration(), definition);
}

Expand Down Expand Up @@ -241,8 +247,14 @@ impl BorshSchema for SecretKey {
) {
// Encoded as `[u8; SECRET_KEY_SIZE]`
let elements = "u8".into();
let length = SECRET_KEY_SIZE as u32;
let definition = borsh::schema::Definition::Array { elements, length };
let length = SECRET_KEY_SIZE as u64;
// let definition = borsh::schema::Definition::Array { elements, length
// };
let definition = borsh::schema::Definition::Sequence {
length_width: 0,
length_range: 0..=length,
elements,
};
definitions.insert(Self::declaration(), definition);
}

Expand Down
26 changes: 21 additions & 5 deletions encoding_spec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,29 @@ struct Table {

fn definition_to_table(name: &Declaration, def: schema::Definition) -> Table {
let (desc, rows) = match def {
schema::Definition::Array { length, elements } => {
schema::Definition::Primitive(t) => {
let rows = None;
let desc = format!("Primitive type {}", md_fmt_type(t.to_string()));
(desc, rows)
}
schema::Definition::Sequence {
length_width,
length_range,
elements,
} if length_width == 0 => {
let rows = None;
let desc = format!(
"Fixed-size array with {} elements of {}",
length,
length_range.end(),
md_fmt_type(elements)
);
(desc, rows)
}
schema::Definition::Sequence { elements } => {
schema::Definition::Sequence {
length_width: _,
length_range: _,
elements,
} => {
let rows = None;
let desc =
format!("Dynamic-size array of {}", md_fmt_type(elements));
Expand All @@ -313,10 +326,13 @@ fn definition_to_table(name: &Declaration, def: schema::Definition) -> Table {
);
(desc, rows)
}
schema::Definition::Enum { variants } => {
schema::Definition::Enum {
tag_width: _,
variants,
} => {
let mut rows = madato::types::Table::default();
// build rows for: Variant, Name, Type
for (variant, (name, type_name)) in variants.iter().enumerate() {
for (_, (variant, name, type_name)) in variants.iter().enumerate() {
rows.push(TableRow::from_iter([
("Prefix byte".into(), variant.to_string()),
("Name".into(), name.clone()),
Expand Down
Loading

0 comments on commit d5bb942

Please sign in to comment.