Skip to content

Remove PoW consensus #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 24, 2019
Merged
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
42 changes: 0 additions & 42 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ codechain-sync = { path = "sync" }
codechain-timer = { path = "util/timer" }
codechain-types = { path = "types" }
codechain-vm = { path = "vm" }
codechain-stratum = { path = "stratum" }
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
fdlimit = "0.1"
finally-block = "0.1"
Expand Down
2 changes: 0 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ codechain-network = { path = "../network" }
codechain-state = { path = "../state" }
codechain-timer = { path = "../util/timer" }
codechain-types = { path = "../types" }
codechain-stratum = { path = "../stratum" }
codechain-vm = { path = "../vm" }
crossbeam-channel = "0.3"
cuckoo = { git = "https://github.com/CodeChain-io/rust-cuckoo.git", rev = "280cab9c" }
hyper = { git = "https://github.com/paritytech/hyper", default-features = false }
kvdb = "0.1"
kvdb-rocksdb = "0.1"
Expand Down
66 changes: 0 additions & 66 deletions core/res/blake_pow.json

This file was deleted.

69 changes: 0 additions & 69 deletions core/res/cuckoo.json

This file was deleted.

61 changes: 0 additions & 61 deletions core/res/husky.json

This file was deleted.

14 changes: 3 additions & 11 deletions core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,11 @@ impl LockedBlock {
/// Provide a valid seal in order to turn this into a `SealedBlock`.
/// This does check the validity of `seal` with the engine.
/// Returns the `ClosedBlock` back again if the seal is no good.
pub fn try_seal(
mut self,
engine: &dyn CodeChainEngine,
seal: Vec<Bytes>,
) -> Result<SealedBlock, (Error, LockedBlock)> {
pub fn seal_block(mut self, seal: Vec<Bytes>) -> SealedBlock {
self.block.header.set_seal(seal);

// TODO: passing state context to avoid engines owning it?
match engine.verify_local_seal(&self.block.header) {
Err(e) => Err((e, self)),
_ => Ok(SealedBlock {
block: self.block,
}),
SealedBlock {
block: self.block,
}
}

Expand Down
34 changes: 0 additions & 34 deletions core/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,13 @@ impl Client {
}
}

/// When RESEAL_MAX_TIMER invoked, a block is created although the block is empty.
const RESEAL_MAX_TIMER_TOKEN: TimerToken = 0;
/// The minimum time between blocks, the miner creates a block when RESEAL_MIN_TIMER is invoked.
/// Do not create a block before RESEAL_MIN_TIMER event.
const RESEAL_MIN_TIMER_TOKEN: TimerToken = 1;

impl TimeoutHandler for Client {
fn on_timeout(&self, token: TimerToken) {
match token {
RESEAL_MAX_TIMER_TOKEN => {
// Working in PoW only
if self.engine().seals_internally().is_none() && !self.importer.miner.prepare_work_sealing(self) {
self.update_sealing(BlockId::Latest, true);
}
}
RESEAL_MIN_TIMER_TOKEN => {
// Checking self.ready_transactions() for efficiency
if !self.engine().engine_type().ignore_reseal_min_period() && !self.is_pending_queue_empty() {
Expand Down Expand Up @@ -552,18 +544,6 @@ impl EngineClient for Client {
}
}

/// Submit a seal for a block in the mining queue.
fn submit_seal(&self, block_hash: BlockHash, seal: Vec<Bytes>) {
if self.importer.miner.submit_seal(self, block_hash, seal).is_err() {
cwarn!(CLIENT, "Wrong internal seal submission!")
}
}

/// Convert PoW difficulty to target.
fn score_to_target(&self, score: &U256) -> U256 {
self.engine.score_to_target(score)
}

/// Update the best block as the given block hash.
///
/// Used in Tendermint, when going to the commit step.
Expand Down Expand Up @@ -690,20 +670,6 @@ impl ImportBlock for Client {
Err(err) => unreachable!("Reseal min timer should not fail but failed with {:?}", err),
}
}

fn set_max_timer(&self) {
self.reseal_timer.cancel(RESEAL_MAX_TIMER_TOKEN).expect("Reseal max timer clear succeeds");
match self
.reseal_timer
.schedule_once(self.importer.miner.get_options().reseal_max_period, RESEAL_MAX_TIMER_TOKEN)
{
Ok(_) => {}
Err(TimerScheduleError::TokenAlreadyScheduled) => {
// Since set_max_timer could be called in multi thread, ignore the TokenAlreadyScheduled error
}
Err(err) => unreachable!("Reseal max timer should not fail but failed with {:?}", err),
}
}
}


Expand Down
Loading