Skip to content

Commit

Permalink
Merge pull request #50 from sporeprotocol/bug/v1-v2-compatibility
Browse files Browse the repository at this point in the history
bug: fix compatibility within v1 and v2
  • Loading branch information
ashuralyk authored Jan 20, 2024
2 parents aa7ae61 + ff2f359 commit b97831a
Show file tree
Hide file tree
Showing 25 changed files with 1,479 additions and 3,229 deletions.
2 changes: 1 addition & 1 deletion contracts/cluster/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use ckb_std::{
// https://docs.rs/ckb-std/
use ckb_std::high_level::{load_script, QueryIter};
use spore_errors::error::Error;
use spore_types::generated::spore_types::ClusterData;
use spore_types::generated::spore::ClusterDataV2 as ClusterData;
use spore_utils::{
check_spore_address, extract_spore_action, find_position_by_type, find_position_by_type_args,
load_self_id, verify_type_id,
Expand Down
10 changes: 5 additions & 5 deletions contracts/spore/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use ckb_std::{

use spore_errors::error::Error;
use spore_types::generated::action;
use spore_types::generated::spore_types::{ClusterData, SporeData};
use spore_types::generated::spore::SporeData;
use spore_utils::{
calc_capacity_sum, check_spore_address, extract_spore_action, find_position_by_lock_hash,
find_position_by_type, find_position_by_type_args, load_self_id, verify_type_id, MIME,
calc_capacity_sum, check_spore_address, compatible_load_cluster_data, extract_spore_action,
find_position_by_lock_hash, find_position_by_type, find_position_by_type_args, load_self_id,
verify_type_id, MIME,
};

use crate::hash::{CLUSTER_AGENT_CODE_HASHES, CLUSTER_CODE_HASHES};
Expand Down Expand Up @@ -106,8 +107,7 @@ fn process_creation(index: usize) -> Result<(), Error> {

// the cluster contract guarantees the cluster data will always be correct once created
let raw_cluster_data = load_cell_data(cell_dep_index, CellDep)?;
let cluster_data = ClusterData::from_compatible_slice(&raw_cluster_data)
.map_err(|_| Error::InvalidClusterData)?;
let cluster_data = compatible_load_cluster_data(&raw_cluster_data)?;

// check in Mutant mode
if let Some(mutant_id) = cluster_data.mutant_id().to_opt() {
Expand Down
13 changes: 13 additions & 0 deletions deployment/migration/cluster/2024-01-19-aa7ae614.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster",
"tx_hash": "0xfbceb70b2e683ef3a97865bb88e082e3e5366ee195a9c826e3c07d1026792fcd",
"index": 0,
"occupied_capacity": 4697400000000,
"data_hash": "0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075",
"type_id": "0x95cb51b763d4a73ac695f05fefdf3bcbe189cc6e0e71497360d2df45915c53c5"
}
],
"dep_group_recipes": []
}
13 changes: 13 additions & 0 deletions deployment/migration/cluster_agent/2024-01-19-aa7ae614.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster_agent",
"tx_hash": "0x53fdb9366637434ff685d0aca5e2a68a859b6fcaa4b608a7ecca0713fed0f5b7",
"index": 0,
"occupied_capacity": 5308600000000,
"data_hash": "0xc986099b41d79ca1b2a56ce5874bcda8175440a17298ea5e2bbc3897736b8c21",
"type_id": "0x313310e2bb617367c0b47f5d49fc0be7a7e9dbdd7cacc5b8492a99f686898972"
}
],
"dep_group_recipes": []
}
13 changes: 13 additions & 0 deletions deployment/migration/cluster_proxy/2024-01-19-aa7ae614.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster_proxy",
"tx_hash": "0x0231ea581bbc38965e10a2659da326ae840c038a9d0d6849f458b51d94870104",
"index": 0,
"occupied_capacity": 4635000000000,
"data_hash": "0xbe8b9ce3d05a32c4bb26fe71cd5fc1407ce91e3a8b9e8719be2ab072cef1454b",
"type_id": "0xa746a91d3aaf46765c848d482be7e33a423c2229da98b0ad668fe14888a21142"
}
],
"dep_group_recipes": []
}
13 changes: 13 additions & 0 deletions deployment/migration/spore/2024-01-19-aa7ae614.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "spore",
"tx_hash": "0x06995b9fc19461a2bf9933e57b69af47a20bf0a5bc6c0ffcb85567a2c733f0a1",
"index": 0,
"occupied_capacity": 7691000000000,
"data_hash": "0x5e063b4c0e7abeaa6a428df3b693521a3050934cf3b0ae97a800d1bc31449398",
"type_id": "0x28889a10fd23b6da93c9a96b1585ad23f46e142cce4700937ac86fd811328c8a"
}
],
"dep_group_recipes": []
}
13 changes: 13 additions & 0 deletions deployment/migration/spore_extension_lua/2024-01-19-aa7ae614.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "spore_extension_lua",
"tx_hash": "0x3faf49cbd18fc99566079b534c3c05b2b29703d936e9c0b04234bcc686e076b1",
"index": 0,
"occupied_capacity": 3155000000000,
"data_hash": "0x94a9b875911ace20f1f0d063a26495d14e4b04e32fd218261bb747f34e71ae47",
"type_id": "0x83c394f0e439bfdd5711578b1669ec73140b5aefd8c6af1d623d6d299a5218de"
}
],
"dep_group_recipes": []
}
11 changes: 0 additions & 11 deletions lib/types/schemas/spore.mol → lib/types/schemas/spore_v1.mol
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
array U8 [byte; 1];
array U128 [byte; 16];
array USize [byte; 4];
array Bytes32 [byte; 32];

vector Bytes <byte>;
vector BytesVec <Bytes>;

array Bool [byte; 1];
option BoolOpt (Bool);
option BytesOpt (Bytes);

table SporeData {
Expand All @@ -19,6 +10,4 @@ table SporeData {
table ClusterData {
name: Bytes,
description: Bytes,
mutant_id: BytesOpt,
}

7 changes: 7 additions & 0 deletions lib/types/schemas/spore_v2.mol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import spore_v1;

table ClusterDataV2 {
name: Bytes,
description: Bytes,
mutant_id: BytesOpt,
}
9 changes: 8 additions & 1 deletion lib/types/src/generated/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
mod spore_v1;
mod spore_v2;

pub mod spore {
pub use super::spore_v1::*;
pub use super::spore_v2::*;
}

pub mod action;
pub mod spore_types;
Loading

0 comments on commit b97831a

Please sign in to comment.