diff --git a/deployment/frozen/mainnet.toml b/deployment/frozen/mainnet.toml index f1879e1..787fcd4 100644 --- a/deployment/frozen/mainnet.toml +++ b/deployment/frozen/mainnet.toml @@ -1,14 +1 @@ -[cluster] -code_hash_list = [] - -[spore] -code_hash_list = [] - -[cluster_proxy] -code_hash_list = [] - -[cluster_agent] -code_hash_list = [] - -[mutant] -code_hash_list = [] +[[code_hash_list]] diff --git a/deployment/frozen/testnet.toml b/deployment/frozen/testnet.toml index 35854d7..2251e1b 100644 --- a/deployment/frozen/testnet.toml +++ b/deployment/frozen/testnet.toml @@ -1,20 +1,5 @@ -[cluster] -code_hash_list = [ - # version v1 (commit: 457e32d23b5f401cad837e52a568281784943e18) - "598d793defef36e2eeba54a9b45130e4ca92822e1d193671f490950c3b856080", -] - -[spore] -code_hash_list = [ - # version v1 (commit: 457e32d23b5f401cad837e52a568281784943e18) - "bbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494", -] - -[cluster_proxy] -code_hash_list = [] - -[cluster_agent] -code_hash_list = [] - -[mutant] -code_hash_list = [] +# version v1 +[[code_hash_list]] +commit_hash = "457e32d23b5f401cad837e52a568281784943e18" +cluster = "598d793defef36e2eeba54a9b45130e4ca92822e1d193671f490950c3b856080" +spore = "bbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494" diff --git a/deployment/migration/cluster/2024-01-05-115055.json b/deployment/migration/cluster/2024-01-05-115055.json deleted file mode 100644 index 84b93d5..0000000 --- a/deployment/migration/cluster/2024-01-05-115055.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "cell_recipes": [ - { - "name": "cluster", - "tx_hash": "0xb463cc2a0e4eb12f188140bb11b07ea4682ed1d6f20b7d1e5ab2868e4105df0d", - "index": 0, - "occupied_capacity": 3703000000000, - "data_hash": "0xa5b26d4d9336066cedbbf359430864bfaa687113d7207bcf797363b9d2fa65af", - "type_id": "0xd70ad85c0b3c377b3f9d73f53e110de6c853139340e12aa667bba9db749ae876" - } - ], - "dep_group_recipes": [] -} \ No newline at end of file diff --git a/deployment/migration/cluster/2024-01-11-143056.json b/deployment/migration/cluster/2024-01-11-143056.json new file mode 100644 index 0000000..d023847 --- /dev/null +++ b/deployment/migration/cluster/2024-01-11-143056.json @@ -0,0 +1,13 @@ +{ + "cell_recipes": [ + { + "name": "cluster", + "tx_hash": "0x5382cd28be1da97b2e7f2824b68e3e5613441b489031eab7d1346fe4a0b9a0cf", + "index": 0, + "occupied_capacity": 3703800000000, + "data_hash": "0x3df619d2d3b80b561394c57df504f3f13e1a1e3a0ea6f3f61ad2cc1da5af9911", + "type_id": "0xd70ad85c0b3c377b3f9d73f53e110de6c853139340e12aa667bba9db749ae876" + } + ], + "dep_group_recipes": [] +} \ No newline at end of file diff --git a/deployment/migration/cluster_agent/2024-01-05-115132.json b/deployment/migration/cluster_agent/2024-01-05-115132.json deleted file mode 100644 index ca0c0d0..0000000 --- a/deployment/migration/cluster_agent/2024-01-05-115132.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "cell_recipes": [ - { - "name": "cluster_agent", - "tx_hash": "0xb6e52b4e96e5e88679657d3b930d1b4b7bf95437cd442ea73d942ee0214320cf", - "index": 0, - "occupied_capacity": 4902200000000, - "data_hash": "0xc3c7f206759b33b5cfcde1ee84f9030059dadb08072a4edd96b39ffd4f16a9f1", - "type_id": "0xbfe31502db747a6a90e20d88c7a3819e339f78200691b11057323fbdf85754fe" - } - ], - "dep_group_recipes": [] -} \ No newline at end of file diff --git a/deployment/migration/cluster_agent/2024-01-11-143147.json b/deployment/migration/cluster_agent/2024-01-11-143147.json new file mode 100644 index 0000000..ddcd48f --- /dev/null +++ b/deployment/migration/cluster_agent/2024-01-11-143147.json @@ -0,0 +1,13 @@ +{ + "cell_recipes": [ + { + "name": "cluster_agent", + "tx_hash": "0xca7792c1b373afa1a0ff859e202a4ce4dee080c04bc896143fddae2016f69205", + "index": 0, + "occupied_capacity": 5034200000000, + "data_hash": "0x8b9c430c56be8194c4a7796ea88f54e8669f7832e5b6cd6aed5d69b91b9d0c85", + "type_id": "0xbfe31502db747a6a90e20d88c7a3819e339f78200691b11057323fbdf85754fe" + } + ], + "dep_group_recipes": [] +} \ No newline at end of file diff --git a/deployment/migration/cluster_proxy/2024-01-05-115210.json b/deployment/migration/cluster_proxy/2024-01-05-115210.json deleted file mode 100644 index e943cfa..0000000 --- a/deployment/migration/cluster_proxy/2024-01-05-115210.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "cell_recipes": [ - { - "name": "cluster_proxy", - "tx_hash": "0xa66de1ec29e765df9d2eb96e103b0664c52f358ed1f01491f791c6d4dec5d932", - "index": 0, - "occupied_capacity": 3340600000000, - "data_hash": "0xf8d0ec631924ea37e9fce95c97c52a5b37ceb344c32c8a03a494876daa00d574", - "type_id": "0x969aefb1207e9694919686bbc1605c7d66322a2974bdc81b96e6b645bfc4a1d3" - } - ], - "dep_group_recipes": [] -} \ No newline at end of file diff --git a/deployment/migration/cluster_proxy/2024-01-11-143206.json b/deployment/migration/cluster_proxy/2024-01-11-143206.json new file mode 100644 index 0000000..d7cfd7b --- /dev/null +++ b/deployment/migration/cluster_proxy/2024-01-11-143206.json @@ -0,0 +1,13 @@ +{ + "cell_recipes": [ + { + "name": "cluster_proxy", + "tx_hash": "0x67b99c9846262cfd459cbbada20d59c16c88d12d80f3841d19e0d5d612830de8", + "index": 0, + "occupied_capacity": 3311000000000, + "data_hash": "0xe91ea54245f007c9e0a8cea49e4ae40b4ebdbfa9fa4d52bc942c6772c0094767", + "type_id": "0x969aefb1207e9694919686bbc1605c7d66322a2974bdc81b96e6b645bfc4a1d3" + } + ], + "dep_group_recipes": [] +} \ No newline at end of file diff --git a/deployment/migration/spore/2024-01-05-115020.json b/deployment/migration/spore/2024-01-05-115020.json deleted file mode 100644 index 2c99730..0000000 --- a/deployment/migration/spore/2024-01-05-115020.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "cell_recipes": [ - { - "name": "spore", - "tx_hash": "0xa3d9bea0e4e26088a3d8929138ae08209dbbb547d843bc76ec9fb5b5153b14d3", - "index": 0, - "occupied_capacity": 7764600000000, - "data_hash": "0x477cf211cc3904e059fa2a870b29090684099b14cdca9badfd95956a7800c417", - "type_id": "0x657323d5a9672e35deb3d46500c140b511208f111fc233eeee74545634e2ebee" - } - ], - "dep_group_recipes": [] -} \ No newline at end of file diff --git a/deployment/migration/spore/2024-01-11-142958.json b/deployment/migration/spore/2024-01-11-142958.json new file mode 100644 index 0000000..fbf7149 --- /dev/null +++ b/deployment/migration/spore/2024-01-11-142958.json @@ -0,0 +1,13 @@ +{ + "cell_recipes": [ + { + "name": "spore", + "tx_hash": "0x024b39f1e840548a5f4c915ced950a79dbd0c78954290e472c995eb83f72b7cf", + "index": 0, + "occupied_capacity": 7907000000000, + "data_hash": "0x86973384d661ac5aabd581de082b04726d74705fa0f97602faf10089be0a0f85", + "type_id": "0x657323d5a9672e35deb3d46500c140b511208f111fc233eeee74545634e2ebee" + } + ], + "dep_group_recipes": [] +} \ No newline at end of file diff --git a/deployment/migration/spore_extension_lua/2024-01-05-115243.json b/deployment/migration/spore_extension_lua/2024-01-05-115243.json deleted file mode 100644 index fbb2f3d..0000000 --- a/deployment/migration/spore_extension_lua/2024-01-05-115243.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "cell_recipes": [ - { - "name": "spore_extension_lua", - "tx_hash": "0x3b52500e30c892fbcf6be35fd94cb0530822d68d9c389ad0de59c7d86a409561", - "index": 0, - "occupied_capacity": 4183000000000, - "data_hash": "0x1fe5301fcaa6e2078a09b76d11b5ecea5920c5b0f3ed8ef8c7eb893356bd84bd", - "type_id": "0x43befa1e7081db9b2741ce98d20707f46474d19b49b2b765f832696cacc39341" - } - ], - "dep_group_recipes": [] -} \ No newline at end of file diff --git a/deployment/migration/spore_extension_lua/2024-01-11-143252.json b/deployment/migration/spore_extension_lua/2024-01-11-143252.json new file mode 100644 index 0000000..7bee4ae --- /dev/null +++ b/deployment/migration/spore_extension_lua/2024-01-11-143252.json @@ -0,0 +1,13 @@ +{ + "cell_recipes": [ + { + "name": "spore_extension_lua", + "tx_hash": "0xe6f6624bf28207aaf9c8e812723da28c27af54f6f262c8a314662dd11079e9f9", + "index": 0, + "occupied_capacity": 4181400000000, + "data_hash": "0x6e9a921ae3bfbf132b1380fd35e151806b7b0413291094bdd4bd33ca7baef415", + "type_id": "0x43befa1e7081db9b2741ce98d20707f46474d19b49b2b765f832696cacc39341" + } + ], + "dep_group_recipes": [] +} \ No newline at end of file diff --git a/lib/build/src/lib.rs b/lib/build/src/lib.rs index c4259b6..19f30c5 100644 --- a/lib/build/src/lib.rs +++ b/lib/build/src/lib.rs @@ -3,17 +3,24 @@ use std::env; use std::fs; #[derive(serde::Deserialize)] -struct CodeHashList { - code_hash_list: Vec, +pub struct FrozenVersions { + code_hash_list: Vec, } #[derive(serde::Deserialize)] pub struct PublishedCodeHash { - spore: CodeHashList, - cluster: CodeHashList, - cluster_proxy: CodeHashList, - cluster_agent: CodeHashList, - mutant: CodeHashList, + #[serde(rename(deserialize = "commit_hash"))] + _commit_hash: String, + #[serde(default)] + spore: String, + #[serde(default)] + cluster: String, + #[serde(default)] + cluster_proxy: String, + #[serde(default)] + cluster_agent: String, + #[serde(default)] + mutant: String, } fn hex_to_byte32(hex: &str) -> [u8; 32] { @@ -23,49 +30,74 @@ fn hex_to_byte32(hex: &str) -> [u8; 32] { byte32 } -impl PublishedCodeHash { +impl FrozenVersions { pub fn spore_code_hashes(&self) -> Vec<[u8; 32]> { - self.spore - .code_hash_list + self.code_hash_list .iter() - .map(|v| hex_to_byte32(v)) + .filter_map(|v| { + if !v.spore.is_empty() { + Some(hex_to_byte32(&v.spore)) + } else { + None + } + }) .collect() } pub fn cluster_code_hashes(&self) -> Vec<[u8; 32]> { - self.cluster - .code_hash_list + self.code_hash_list .iter() - .map(|v| hex_to_byte32(v)) + .filter_map(|v| { + if !v.cluster.is_empty() { + Some(hex_to_byte32(&v.cluster)) + } else { + None + } + }) .collect() } pub fn cluster_proxy_code_hashes(&self) -> Vec<[u8; 32]> { - self.cluster_proxy - .code_hash_list + self.code_hash_list .iter() - .map(|v| hex_to_byte32(v)) + .filter_map(|v| { + if !v.cluster_proxy.is_empty() { + Some(hex_to_byte32(&v.cluster_proxy)) + } else { + None + } + }) .collect() } pub fn cluster_agent_code_hashes(&self) -> Vec<[u8; 32]> { - self.cluster_agent - .code_hash_list + self.code_hash_list .iter() - .map(|v| hex_to_byte32(v)) + .filter_map(|v| { + if !v.cluster_agent.is_empty() { + Some(hex_to_byte32(&v.cluster_agent)) + } else { + None + } + }) .collect() } pub fn mutant_code_hashes(&self) -> Vec<[u8; 32]> { - self.mutant - .code_hash_list + self.code_hash_list .iter() - .map(|v| hex_to_byte32(v)) + .filter_map(|v| { + if !v.mutant.is_empty() { + Some(hex_to_byte32(&v.mutant)) + } else { + None + } + }) .collect() } } -pub fn load_frozen_toml() -> PublishedCodeHash { +pub fn load_frozen_toml() -> FrozenVersions { let net_type = if env::var("CARGO_FEATURE_RELEASE_EXPORT").is_ok() { "mainnet" } else {