fix: update chainstate import code to no longer use name block heights

This commit is contained in:
Matthew Little
2021-01-08 00:20:36 +01:00
parent c1dddadfdb
commit 220e873e14
7 changed files with 55362 additions and 69365 deletions

View File

@@ -636,8 +636,6 @@ pub struct ChainstateAccountLockup {
pub struct ChainstateBNSNamespace {
pub namespace_id: String,
pub importer: String,
pub revealed_at: u64,
pub launched_at: u64,
pub buckets: String,
pub base: u64,
pub coeff: u64,
@@ -650,8 +648,6 @@ pub struct ChainstateBNSNamespace {
pub struct ChainstateBNSName {
pub fully_qualified_name: String,
pub owner: String,
pub registered_at: u64,
pub expired_at: u64,
pub zonefile_hash: String,
}
@@ -1040,8 +1036,8 @@ impl StacksChainState {
Value::Principal(address)
};
let revealed_at = Value::UInt(entry.revealed_at.into());
let launched_at = Value::UInt(entry.launched_at.into());
let revealed_at = Value::UInt(0);
let launched_at = Value::UInt(0);
let lifetime = Value::UInt(entry.lifetime.into());
let price_function = {
let base = Value::UInt(entry.base.into());
@@ -1151,7 +1147,7 @@ impl StacksChainState {
&expected_asset_type,
)?;
let registered_at = Value::UInt(entry.registered_at.into());
let registered_at = Value::UInt(0);
let name_props = Value::Tuple(
TupleData::from_data(vec![
(
@@ -2060,8 +2056,6 @@ pub mod test {
ChainstateBNSNamespace {
namespace_id: item.namespace_id,
importer: item.importer,
revealed_at: item.reveal_block as u64,
launched_at: item.ready_block as u64,
buckets: item.buckets,
base: item.base as u64,
coeff: item.coeff as u64,
@@ -2078,8 +2072,6 @@ pub mod test {
.map(|item| ChainstateBNSName {
fully_qualified_name: item.fully_qualified_name,
owner: item.owner,
registered_at: item.registered_at as u64,
expired_at: item.expire_block as u64,
zonefile_hash: item.zonefile_hash,
}),
)
@@ -2116,7 +2108,7 @@ pub mod test {
// Just update the expected value
assert_eq!(
genesis_root_hash.to_string(),
"146bb2f3c11d543c126067a4fb39091c0596b3257a3c0b6ef4b9861546ae56e9",
"54e300e1f626c3a952968204b63a272d308ba498824e72013a7788fcf4b316e4"
);
}
@@ -2150,12 +2142,10 @@ pub mod test {
}))
})),
get_bulk_initial_namespaces: Some(Box::new(|| {
Box::new(GenesisData::new(true).read_namespaces().map(|item| {
Box::new(GenesisData::new(false).read_namespaces().map(|item| {
ChainstateBNSNamespace {
namespace_id: item.namespace_id,
importer: item.importer,
revealed_at: item.reveal_block as u64,
launched_at: item.ready_block as u64,
buckets: item.buckets,
base: item.base as u64,
coeff: item.coeff as u64,
@@ -2167,13 +2157,11 @@ pub mod test {
})),
get_bulk_initial_names: Some(Box::new(|| {
Box::new(
GenesisData::new(true)
GenesisData::new(false)
.read_names()
.map(|item| ChainstateBNSName {
fully_qualified_name: item.fully_qualified_name,
owner: item.owner,
registered_at: item.registered_at as u64,
expired_at: item.expire_block as u64,
zonefile_hash: item.zonefile_hash,
}),
)
@@ -2210,7 +2198,7 @@ pub mod test {
// Just update the expected value
assert_eq!(
format!("{}", genesis_root_hash),
"30f4472782b844e508bfebd8912f271270c1fd04393cd18e884f42dbb1a133f1"
"a2fcaeb9fcc41d54e91062d9a69d76c301155fabf87e7139bdb1ca9b6e3d9705"
);
}
}

View File

@@ -1,25 +1,25 @@
-----BEGIN NAMESPACES-----
namespace_id,address,reveal_block,ready_block,buckets,base,coeff,nonalpha_discount,no_vowel_discount,lifetime
blockstack,SP355AMV5R2A5C7VQCF4YPPAS05W93HTB68574W7S,524363,524393,7;6;5;4;3;2;1;1;1;1;1;1;1;1;1;1,4,250,4,4,0
graphite,SP3X2W6GTGVVG9RW78F1MT7M9AQFS2HWV2JETXPG2,522128,524057,6;5;4;3;2;1;0;0;0;0;0;0;0;0;0;0,4,250,4,4,52595
helloworld,SP3TJ4WRTXW0YFWF1TWKWCG7E6Z6MZDTWAVB6SW5V,490390,497855,15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0,2,4,2,5,0
id,SP364R1Y0XYC8PYXEK0PE3V752RAJB2GNWF28WP90,373608,384057,6;5;4;3;2;1;0;0;0;0;0;0;0;0;0;0,4,250,4,4,52595
podcast,SPHYHD2ZJ11HWRDKVZ160QX7FD7PCVNT2N9CT2H6,498126,506980,1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1,40,250,1,1,0
namespace_id,address,buckets,base,coeff,nonalpha_discount,no_vowel_discount,lifetime
blockstack,SP355AMV5R2A5C7VQCF4YPPAS05W93HTB68574W7S,7;6;5;4;3;2;1;1;1;1;1;1;1;1;1;1,4,250,4,4,0
graphite,SP3X2W6GTGVVG9RW78F1MT7M9AQFS2HWV2JETXPG2,6;5;4;3;2;1;0;0;0;0;0;0;0;0;0;0,4,250,4,4,52595
helloworld,SP3TJ4WRTXW0YFWF1TWKWCG7E6Z6MZDTWAVB6SW5V,15;14;13;12;11;10;9;8;7;6;5;4;3;2;1;0,2,4,2,5,0
id,SP364R1Y0XYC8PYXEK0PE3V752RAJB2GNWF28WP90,6;5;4;3;2;1;0;0;0;0;0;0;0;0;0;0,4,250,4,4,52595
podcast,SPHYHD2ZJ11HWRDKVZ160QX7FD7PCVNT2N9CT2H6,1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1,40,250,1,1,0
-----END NAMESPACES-----
-----BEGIN NAMES-----
name,address,registered_at,expire_block,zonefile_hash
0.id,SP1HPCXTGV31W5659M3WTBEFP5AN55HV4B1Q9T31F,605279,710469,c5f5b4197c94d4561f6332160f624d728b0da8bf
1.id,SP1FRDVA4JAZ4TC93XZC850QAY6R4MTHN10XZJ035,603148,708338,8961c32ad98df87af12b186c3d0be6ca22105936
10.id,SP12TFSBQFZWVVEAWJTVRW3K8V00R0S4895ABXRBR,604777,709967,8ae7173b9a2f96521ba077bbcbe9b56b1cf2449f
10x.id,SP3N5TVVEHGA8B6G3JXWBP476161E32654D9P9A3Y,600560,705750,3d0576cd134fa1ff8d54d8e2ef5da97f5cae36f2
111111111.id,SP15XBGYRVMKF1TWPXE6A3M0T2A87VYSVF9VFSZ1A,649364,754554,01a8c60c852b75f9c6417491ac89275fb9de774c
123.id,SP2PEZ0W4PFGYV6ZZ2DWDVNAVVTQPJ9KX8EK4VRVT,605026,710216,ae34427289a8865028eb2d475dafb085060d5625
zinai.id,SP19QQ0RZ2F3CKJ2G2FT4EA905MKV89FY9K5XB5M3,621850,727040,c7b0bbeb92c2575a3e4a82632d8ec4b7fc86cc19
zlh.id,SP1E311NW655FXQMQQKEKQKZZJFAA58AVP3GBTAZT,600958,706148,da6a954fdf90c890966cde5ae808ca6c96082428
zone117x.id,SP3R9402R2XB0WMG0BTEMZ5Q67QFJ7Y8YVJRQCJZN,606679,711869,578ed433dabeb24952c892d5f3fc0cd7b9844bb8
zumminer_crux.id,SP3DGYX27MM12SSPVGK2NMTR4836DT9VWYJV844BK,600528,705718,fa602059cb01dbe8d1885d8fc2a7c6b265c57e64
zumminer_dev_crux.id,SPSSW2FFJQ2AMR5KZASBY8XH3F5WXHJV0M22GJ9G,601529,706719,f9569aa25b6325b0f2e3a5f9edb552cd98260f9b
zumrai.id,SP29EJ0SVM2TRZ3XGVTZPVTKF4SV1VMD8C0GA5SK5,618792,723982,853cd126478237bc7392e65091f7ffa5a1556a33
name,address,zonefile_hash
0.id,SP1HPCXTGV31W5659M3WTBEFP5AN55HV4B1Q9T31F,c5f5b4197c94d4561f6332160f624d728b0da8bf
1.id,SP1FRDVA4JAZ4TC93XZC850QAY6R4MTHN10XZJ035,8961c32ad98df87af12b186c3d0be6ca22105936
10.id,SP12TFSBQFZWVVEAWJTVRW3K8V00R0S4895ABXRBR,8ae7173b9a2f96521ba077bbcbe9b56b1cf2449f
10x.id,SP3N5TVVEHGA8B6G3JXWBP476161E32654D9P9A3Y,3d0576cd134fa1ff8d54d8e2ef5da97f5cae36f2
111111111.id,SP15XBGYRVMKF1TWPXE6A3M0T2A87VYSVF9VFSZ1A,01a8c60c852b75f9c6417491ac89275fb9de774c
123.id,SP2PEZ0W4PFGYV6ZZ2DWDVNAVVTQPJ9KX8EK4VRVT,ae34427289a8865028eb2d475dafb085060d5625
zinai.id,SP19QQ0RZ2F3CKJ2G2FT4EA905MKV89FY9K5XB5M3,c7b0bbeb92c2575a3e4a82632d8ec4b7fc86cc19
zlh.id,SP1E311NW655FXQMQQKEKQKZZJFAA58AVP3GBTAZT,da6a954fdf90c890966cde5ae808ca6c96082428
zone117x.id,SP3R9402R2XB0WMG0BTEMZ5Q67QFJ7Y8YVJRQCJZN,578ed433dabeb24952c892d5f3fc0cd7b9844bb8
zumminer_crux.id,SP3DGYX27MM12SSPVGK2NMTR4836DT9VWYJV844BK,fa602059cb01dbe8d1885d8fc2a7c6b265c57e64
zumminer_dev_crux.id,SPSSW2FFJQ2AMR5KZASBY8XH3F5WXHJV0M22GJ9G,f9569aa25b6325b0f2e3a5f9edb552cd98260f9b
zumrai.id,SP29EJ0SVM2TRZ3XGVTZPVTKF4SV1VMD8C0GA5SK5,853cd126478237bc7392e65091f7ffa5a1556a33
-----END NAMES-----
-----BEGIN STX BALANCES-----
address,balance

View File

@@ -1 +1 @@
f3720f00692f4fcbcfe8374238fb2bfaf538a0f2d607dc5aa440a13d6a2aa4ed
014402b47d53b0716402c172fa746adf308b03a826ebea91944a5eb6a304a823

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
5ee9c678f9f07ae04fdb6913993f2c60347a7f8c8ec959feb42604bc350df016
1d587f628d370651ade417d6f92148210e1f1c367a8afd35c4af87781d61a2d9

View File

@@ -22,8 +22,6 @@ pub struct GenesisAccountLockup {
pub struct GenesisNamespace {
pub namespace_id: String,
pub importer: String,
pub reveal_block: i64,
pub ready_block: i64,
pub buckets: String,
pub base: i64,
pub coeff: i64,
@@ -35,8 +33,6 @@ pub struct GenesisNamespace {
pub struct GenesisName {
pub fully_qualified_name: String,
pub owner: String,
pub registered_at: i64,
pub expire_block: i64,
pub zonefile_hash: String,
}
@@ -115,14 +111,12 @@ fn read_namespaces(deflate_bytes: &'static [u8]) -> Box<dyn Iterator<Item = Gene
let namespaces = iter_deflated_csv(deflate_bytes).map(|cols| GenesisNamespace {
namespace_id: cols[0].to_string(),
importer: cols[1].to_string(),
reveal_block: cols[2].parse::<i64>().unwrap(),
ready_block: cols[3].parse::<i64>().unwrap(),
buckets: cols[4].to_string(),
base: cols[5].parse::<i64>().unwrap(),
coeff: cols[6].parse::<i64>().unwrap(),
nonalpha_discount: cols[7].parse::<i64>().unwrap(),
no_vowel_discount: cols[8].parse::<i64>().unwrap(),
lifetime: cols[9].parse::<i64>().unwrap(),
buckets: cols[2].to_string(),
base: cols[3].parse::<i64>().unwrap(),
coeff: cols[4].parse::<i64>().unwrap(),
nonalpha_discount: cols[5].parse::<i64>().unwrap(),
no_vowel_discount: cols[6].parse::<i64>().unwrap(),
lifetime: cols[7].parse::<i64>().unwrap(),
});
return Box::new(namespaces);
}
@@ -131,9 +125,7 @@ fn read_names(deflate_bytes: &'static [u8]) -> Box<dyn Iterator<Item = GenesisNa
let names = iter_deflated_csv(deflate_bytes).map(|cols| GenesisName {
fully_qualified_name: cols[0].to_string(),
owner: cols[1].to_string(),
registered_at: cols[2].parse::<i64>().unwrap(),
expire_block: cols[3].parse::<i64>().unwrap(),
zonefile_hash: cols[4].to_string(),
zonefile_hash: cols[2].to_string(),
});
return Box::new(names);
}
@@ -167,20 +159,20 @@ mod tests {
#[test]
fn test_namespaces_read() {
for namespace in GenesisData::new(false).read_namespaces() {
assert!(namespace.ready_block > 0);
assert!(namespace.base > 0);
}
for namespace in GenesisData::new(true).read_namespaces() {
assert!(namespace.ready_block > 0);
assert!(namespace.base > 0);
}
}
#[test]
fn test_names_read() {
for name in GenesisData::new(false).read_names() {
assert!(name.registered_at > 0);
assert!(name.owner.len() > 0);
}
for name in GenesisData::new(true).read_names() {
assert!(name.registered_at > 0);
assert!(name.owner.len() > 0);
}
}
}

View File

@@ -121,8 +121,6 @@ pub fn get_namespaces(
.map(|item| ChainstateBNSNamespace {
namespace_id: item.namespace_id,
importer: item.importer,
revealed_at: item.reveal_block as u64,
launched_at: item.ready_block as u64,
buckets: item.buckets,
base: item.base as u64,
coeff: item.coeff as u64,
@@ -140,8 +138,6 @@ pub fn get_names(use_test_chainstate_data: bool) -> Box<dyn Iterator<Item = Chai
.map(|item| ChainstateBNSName {
fully_qualified_name: item.fully_qualified_name,
owner: item.owner,
registered_at: item.registered_at as u64,
expired_at: item.expire_block as u64,
zonefile_hash: item.zonefile_hash,
}),
)