Skip to content

Commit 2f0cbbd

Browse files
authored
spec: support data field in IssuedCell (#5079)
<!-- Thank you for contributing to nervosnetwork/ckb! If you haven't already, please read [CONTRIBUTING](https://github.com/nervosnetwork/ckb/blob/develop/CONTRIBUTING.md) document. If you're unsure about anything, just ask; somebody should be along to answer within a day or two. **Important**: We use Squash Merge to merge PRs, so the PR title will become the commit message. Please ensure your PR title follows the [Conventional Commit Messages](https://www.conventionalcommits.org/) format. The most important prefixes you should use: - `fix:`: represents bug fixes, and results in a SemVer patch bump. - `feat:`: represents a new feature, and results in a SemVer minor bump. - `<prefix>!:` (e.g. `feat!:`): represents a breaking change (indicated by the !) and results in a SemVer major bump. Other conventional prefixes are also acceptable (e.g., `docs:`, `refactor:`, `test:`, `chore:`, etc.). --> ### What problem does this PR solve? Table `IssuedCell` in spec cannot specify output data of a cell ### What is changed and how it works? This PR adds a field named `data` and can be ignored (to keep compatibility with previous spec), used to specify data of cells ### Related changes - PR to update `owner/repo`: - Need to cherry-pick to the release branch ### Check List <!--REMOVE the items that are not applicable--> Tests <!-- At least one of them must be included. --> - Unit test - Integration test - Manual test (add detailed scripts or steps below) - No code Side effects - Performance regression - Breaking backward compatibility
1 parent 12ccab7 commit 2f0cbbd

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

benches/benches/benchmarks/resolve.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ pub fn setup_chain(txs_size: usize) -> (Shared, ChainController) {
7676
.map(|_| IssuedCell {
7777
capacity: capacity_bytes!(100_000),
7878
lock: secp_script.clone().into(),
79+
data: None,
80+
type_: None,
7981
})
8082
.collect();
8183

spec/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::versionbits::{ActiveMode, Deployment, DeploymentPos};
1919
use ckb_constant::hardfork::{mainnet, testnet};
2020
use ckb_crypto::secp::Privkey;
2121
use ckb_hash::{blake2b_256, new_blake2b};
22-
use ckb_jsonrpc_types::Script;
22+
use ckb_jsonrpc_types::{JsonBytes, Script};
2323
use ckb_pow::{Pow, PowEngine};
2424
use ckb_resource::{
2525
CODE_HASH_DAO, CODE_HASH_SECP256K1_BLAKE160_MULTISIG_ALL,
@@ -400,6 +400,11 @@ pub struct GenesisCell {
400400
pub struct IssuedCell {
401401
/// The cell capacity
402402
pub capacity: Capacity,
403+
/// The cell data, can be ignored in spec
404+
pub data: Option<JsonBytes>,
405+
/// The cell type script
406+
#[serde(rename = "type")]
407+
pub type_: Option<Script>,
403408
/// The cell lock
404409
pub lock: Script,
405410
}
@@ -826,7 +831,12 @@ impl ChainSpec {
826831
.iter()
827832
.map(IssuedCell::build_output),
828833
);
829-
outputs_data.extend(self.genesis.issued_cells.iter().map(|_| Bytes::new()));
834+
outputs_data.extend(
835+
self.genesis
836+
.issued_cells
837+
.iter()
838+
.map(|x| x.data.clone().unwrap_or_default().into_bytes()),
839+
);
830840

831841
let script: packed::Script = self.genesis.bootstrap_lock.clone().into();
832842

@@ -953,6 +963,7 @@ impl IssuedCell {
953963
packed::CellOutput::new_builder()
954964
.lock(self.lock.clone())
955965
.capacity(self.capacity)
966+
.type_(self.type_.clone().map(|x| x.into()))
956967
.build()
957968
}
958969
}

test/src/specs/dao/satoshi_dao_occupied.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,7 @@ fn issue_satoshi_cell() -> IssuedCell {
154154
IssuedCell {
155155
capacity: SATOSHI_CELL_CAPACITY,
156156
lock: lock.into(),
157+
data: None,
158+
type_: None,
157159
}
158160
}

0 commit comments

Comments
 (0)