Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions core/res/blake_pow.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
18 changes: 9 additions & 9 deletions core/res/cuckoo.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
18 changes: 9 additions & 9 deletions core/res/null.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
18 changes: 9 additions & 9 deletions core/res/solo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
18 changes: 9 additions & 9 deletions core/res/solo_authority.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
18 changes: 9 additions & 9 deletions core/res/tendermint.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"extraData": "0x"
},
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "100", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "100" },
"0000000000000000000000000000000000000006": { "balance": "100" },
"0000000000000000000000000000000000000007": { "balance": "100" },
"0000000000000000000000000000000000000008": { "balance": "100" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "100" },
"0000000000000000000000000000000000000001": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000002": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000003": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000004": { "balance": "1000000", "nonce": "0" },
"0000000000000000000000000000000000000005": { "balance": "1000000" },
"0000000000000000000000000000000000000006": { "balance": "1000000" },
"0000000000000000000000000000000000000007": { "balance": "1000000" },
"0000000000000000000000000000000000000008": { "balance": "1000000" },
"a6594b7196808d161b6fb137e781abbc251385d9": { "balance": "1000000" },
"9cce34f7ab185c7aba1b7c8140d620b4bda941d6": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "0" }
},
"shards": {
Expand Down
8 changes: 4 additions & 4 deletions core/src/consensus/null_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ impl<M: WithBalances> ConsensusEngine<M> for NullEngine<M> {
&self.machine
}

fn verify_local_seal(&self, _header: &M::Header) -> Result<(), M::Error> {
Ok(())
}

fn on_close_block(&self, block: &mut M::LiveBlock) -> Result<(), M::Error> {
let author = *LiveBlock::header(&*block).author();
self.machine.add_balance(block, &author, &self.params.block_reward)
}

fn verify_local_seal(&self, _header: &M::Header) -> Result<(), M::Error> {
Ok(())
}
}
9 changes: 9 additions & 0 deletions core/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,12 @@ impl ::machine::Header for Header {
Header::number(self)
}
}

impl ::machine::ScoredHeader for Header {
fn score(&self) -> &U256 {
self.score()
}
fn set_score(&mut self, score: U256) {
self.set_score(score)
}
}
9 changes: 9 additions & 0 deletions core/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ pub trait Header {
fn number(&self) -> u64;
}

/// A header with an associated score (difficulty in PoW terms)
pub trait ScoredHeader: Header {
/// Get the score of this header.
fn score(&self) -> &U256;

/// Set the score of this header.
fn set_score(&mut self, score: U256);
}

/// A "live" block is one which is in the process of the transition.
/// The state of this block can be mutated by arbitrary rules of the
/// state transition function.
Expand Down
17 changes: 14 additions & 3 deletions core/src/parcel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub fn parcel_error_message(error: &ParcelError) -> String {
match error {
AlreadyImported => "Already imported".into(),
Old => "No longer valid".into(),
TooCheapToReplace => "Gas price too low to replace".into(),
InvalidNetworkId => "Parcel of this network ID is not allowed on this chain.".into(),
TooCheapToReplace => "Fee too low to replace".into(),
InvalidNetworkId => "This network ID is not allowed on this chain".into(),
MetadataTooBig => "Metadata size is too big.".into(),
LimitReached => "Parcel limit reached".into(),
InsufficientFee {
Expand Down Expand Up @@ -375,14 +375,25 @@ impl UnverifiedParcel {
for t in transactions {
match &t {
Transaction::AssetMint {
network_id,
metadata,
..
} => {
if metadata.len() > params.max_metadata_size {
return Err(ParcelError::MetadataTooBig)
}
if network_id != &self.network_id {
return Err(ParcelError::InvalidNetworkId)
}
}
Transaction::AssetTransfer {
network_id,
..
} => {
if network_id != &self.network_id {
return Err(ParcelError::InvalidNetworkId)
}
}
_ => {}
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use super::parcel::{AssetTransferInput, AssetTransferOutput};
pub enum Transaction {
#[serde(rename_all = "camelCase")]
AssetMint {
network_id: u64,
metadata: String,
lock_script_hash: H256,
parameters: Vec<Bytes>,
Expand Down Expand Up @@ -101,16 +102,17 @@ impl Decodable for Transaction {
fn decode(d: &UntrustedRlp) -> Result<Self, DecoderError> {
match d.val_at(0)? {
ASSET_MINT_ID => {
if d.item_count()? != 7 {
if d.item_count()? != 8 {
return Err(DecoderError::RlpIncorrectListLen)
}
Ok(Transaction::AssetMint {
metadata: d.val_at(1)?,
lock_script_hash: d.val_at(2)?,
parameters: d.val_at(3)?,
amount: d.val_at(4)?,
registrar: d.val_at(5)?,
nonce: d.val_at(6)?,
network_id: d.val_at(1)?,
metadata: d.val_at(2)?,
lock_script_hash: d.val_at(3)?,
parameters: d.val_at(4)?,
amount: d.val_at(5)?,
registrar: d.val_at(6)?,
nonce: d.val_at(7)?,
})
}
ASSET_TRANSFER_ID => {
Expand All @@ -134,14 +136,16 @@ impl Encodable for Transaction {
fn rlp_append(&self, s: &mut RlpStream) {
match self {
Transaction::AssetMint {
network_id,
metadata,
lock_script_hash,
parameters,
amount,
registrar,
nonce,
} => s.begin_list(7)
} => s.begin_list(8)
.append(&ASSET_MINT_ID)
.append(network_id)
.append(metadata)
.append(lock_script_hash)
.append(parameters)
Expand Down
2 changes: 1 addition & 1 deletion docs/basic-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The way each node is connected does not matter, as long as each node is connecte
the node with a secret key of 1, use this command:
::

codechain --db-path db/db0 --port 3485 --jsonrpc-port 8080 --secret-key 0000000000000000000000000000000000000000000000000000000000000001 -c tendermint --bootstrap-addresses 127.0.0.1:8080
codechain --db-path db/db1 --port 3486 --jsonrpc-port 8081 --secret-key 0000000000000000000000000000000000000000000000000000000000000002 -c tendermint --bootstrap-addresses 127.0.0.1:3485

Checking if CodeChain is Configured Properly
============================================
Expand Down
Loading