Skip to content

Commit b58300b

Browse files
authored
StateKeyRegistry (aptos-labs#12864)
1 parent 5a963fa commit b58300b

File tree

15 files changed

+673
-130
lines changed

15 files changed

+673
-130
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ aptos-cargo-cli = { path = "devtools/aptos-cargo-cli" }
450450
# External crate dependencies.
451451
# Please do not add any test features here: they should be declared by the individual crate.
452452
aes-gcm = "0.10.3"
453+
ahash = "0.8.11"
453454
atty = "0.2.14"
454455
nalgebra = "0.32"
455456
float-cmp = "0.9.0"
@@ -562,6 +563,7 @@ futures = "0.3.29"
562563
futures-channel = "0.3.29"
563564
futures-core = "0.3.29"
564565
futures-util = "0.3.29"
566+
fxhash = "0.2.1"
565567
getrandom = "0.2.2"
566568
gcp-bigquery-client = "0.13.0"
567569
get_if_addrs = "0.5.3"

api/types/src/wrappers.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,7 @@ pub struct StateKeyWrapper(pub StateKey);
119119

120120
impl fmt::Display for StateKeyWrapper {
121121
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
122-
let hex_string = hex::encode(
123-
self.0
124-
.encode()
125-
.context("Failed to encode StateKey")
126-
.map_err(|_| fmt::Error)?,
127-
);
122+
let hex_string = hex::encode(self.0.encoded());
128123
write!(f, "{}", hex_string)
129124
}
130125
}

aptos-move/aptos-vm-types/src/storage/io_pricing.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ impl IoPricingV1 {
6161
let mut cost = self.write_data_per_op * NumArgs::new(1);
6262

6363
if self.write_data_per_byte_in_key > 0.into() {
64-
cost += self.write_data_per_byte_in_key
65-
* NumBytes::new(
66-
key.encode()
67-
.expect("Should be able to serialize state key")
68-
.len() as u64,
69-
);
64+
cost += self.write_data_per_byte_in_key * NumBytes::new(key.encoded().len() as u64);
7065
}
7166

7267
match op_size {
@@ -135,11 +130,7 @@ impl IoPricingV2 {
135130
.checked_sub(self.free_write_bytes_quota)
136131
.unwrap_or(NumBytes::zero())
137132
} else {
138-
let key_size = NumBytes::new(
139-
key.encode()
140-
.expect("Should be able to serialize state key")
141-
.len() as u64,
142-
);
133+
let key_size = NumBytes::new(key.encoded().len() as u64);
143134
key_size + value_size
144135
}
145136
}

aptos-move/e2e-move-tests/src/tests/access_path_test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ use move_binary_format::{
1818
};
1919
use move_core_types::{identifier::Identifier, vm_status::StatusCode};
2020

21-
/// FIXME(aldenhu): fix or remove
22-
#[ignore]
2321
#[test]
2422
fn access_path_panic() {
2523
// github.com/aptos-labs/aptos-core/security/advisories/GHSA-rpw2-84hq-48jj

storage/aptosdb/src/schema/stale_state_value_index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl KeyCodec<StaleStateValueIndexSchema> for StaleStateValueIndex {
4343
let mut encoded = vec![];
4444
encoded.write_u64::<BigEndian>(self.stale_since_version)?;
4545
encoded.write_u64::<BigEndian>(self.version)?;
46-
encoded.write_all(&self.state_key.encode()?)?;
46+
encoded.write_all(self.state_key.encoded())?;
4747

4848
Ok(encoded)
4949
}

storage/aptosdb/src/schema/state_value/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define_schema!(
4242
impl KeyCodec<StateValueSchema> for Key {
4343
fn encode_key(&self) -> Result<Vec<u8>> {
4444
let mut encoded = vec![];
45-
encoded.write_all(&self.0.encode()?)?;
45+
encoded.write_all(self.0.encoded())?;
4646
encoded.write_u64::<BigEndian>(!self.1)?;
4747
Ok(encoded)
4848
}

storage/aptosdb/src/schema/state_value_index/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define_schema!(StateValueIndexSchema, Key, (), STATE_VALUE_INDEX_CF_NAME);
3030
impl KeyCodec<StateValueIndexSchema> for Key {
3131
fn encode_key(&self) -> Result<Vec<u8>> {
3232
let mut encoded = vec![];
33-
encoded.write_all(&self.0.encode()?)?;
33+
encoded.write_all(self.0.encoded())?;
3434
encoded.write_u64::<BigEndian>(!self.1)?;
3535
Ok(encoded)
3636
}

testsuite/generate-format/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ aptos-consensus-types = { workspace = true }
2020
aptos-crypto = { workspace = true }
2121
aptos-crypto-derive = { workspace = true }
2222
aptos-network = { workspace = true }
23-
aptos-types = { workspace = true }
23+
aptos-types = { workspace = true, features = ["fuzzing"] }
2424
bcs = { workspace = true }
2525
clap = { workspace = true }
2626
move-core-types = { workspace = true, features = ["fuzzing"] }

types/Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ aptos-crypto = { workspace = true }
1919
aptos-crypto-derive = { workspace = true }
2020
aptos-dkg = { workspace = true }
2121
aptos-experimental-runtimes = { workspace = true }
22+
aptos-infallible = { workspace = true }
2223
ark-bn254 = { workspace = true }
2324
ark-ff = { workspace = true }
2425
ark-groth16 = { workspace = true }
@@ -27,9 +28,9 @@ arr_macro = { workspace = true }
2728
base64 = { workspace = true }
2829
bcs = { workspace = true }
2930
bytes = { workspace = true }
30-
criterion = { workspace = true }
31-
derivative = { workspace = true }
3231
fixed = { workspace = true }
32+
fxhash = { workspace = true }
33+
hashbrown = { workspace = true }
3334
hex = { workspace = true }
3435
itertools = { workspace = true }
3536
jsonwebtoken = { workspace = true }
@@ -60,11 +61,15 @@ strum_macros = { workspace = true }
6061
thiserror = { workspace = true }
6162

6263
[dev-dependencies]
64+
ahash = { workspace = true }
6365
aptos-crypto = { workspace = true, features = ["fuzzing", "testing"] }
66+
aptos-proptest-helpers = { workspace = true }
6467
async-trait = { workspace = true }
6568
ciborium = { workspace = true }
6669
claims = { workspace = true }
6770
coset = { workspace = true }
71+
criterion = { workspace = true }
72+
derivative = { workspace = true }
6873
move-core-types = { workspace = true, features = ["fuzzing"] }
6974
p256 = { workspace = true }
7075
passkey-authenticator = { workspace = true }
@@ -84,3 +89,7 @@ fuzzing = ["proptest", "proptest-derive", "aptos-crypto/fuzzing", "move-core-typ
8489
[[bench]]
8590
name = "keyless"
8691
harness = false
92+
93+
[[bench]]
94+
name = "state_key"
95+
harness = false

0 commit comments

Comments
 (0)