-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-v2.4.3.patch
702 lines (661 loc) · 26.5 KB
/
patch-v2.4.3.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
diff --git a/Cargo.lock b/Cargo.lock
index 07b9fc2c4..49f527b40 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2525,7 +2525,7 @@ dependencies = [
"parity-rpc 1.12.0",
"parity-runtime 0.1.0",
"parity-updater 1.12.0",
- "parity-version 2.4.3",
+ "parity-version 2.4.3-clique",
"parity-whisper 0.1.0",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2676,7 +2676,7 @@ dependencies = [
"parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-runtime 0.1.0",
"parity-updater 1.12.0",
- "parity-version 2.4.3",
+ "parity-version 2.4.3-clique",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2774,7 +2774,7 @@ dependencies = [
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-hash-fetch 1.12.0",
"parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "parity-version 2.4.3",
+ "parity-version 2.4.3-clique",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2784,7 +2784,7 @@ dependencies = [
[[package]]
name = "parity-version"
-version = "2.4.3"
+version = "2.4.3-clique"
dependencies = [
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml
index e6b90a4cd..7ca782ef1 100644
--- a/ethcore/Cargo.toml
+++ b/ethcore/Cargo.toml
@@ -39,7 +39,7 @@ keccak-hasher = { path = "../util/keccak-hasher" }
kvdb = "0.1"
kvdb-memorydb = "0.1"
kvdb-rocksdb = { version = "0.1.3", optional = true }
-lazy_static = "1.0"
+lazy_static = "1.2.0"
len-caching-lock = { path = "../util/len-caching-lock" }
log = "0.4"
lru-cache = "0.1"
diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs
index e5fcb4516..70154c5b6 100644
--- a/ethcore/src/block.rs
+++ b/ethcore/src/block.rs
@@ -46,7 +46,6 @@ use state::State;
use trace::Tracing;
use triehash::ordered_trie_root;
use unexpected::{Mismatch, OutOfBounds};
-use verification::PreverifiedBlock;
use vm::{EnvInfo, LastHashes};
use hash::keccak;
@@ -339,22 +338,6 @@ impl<'x> OpenBlock<'x> {
Ok(())
}
- /// Populate self from a header.
- fn populate_from(&mut self, header: &Header) {
- self.block.header.set_difficulty(*header.difficulty());
- self.block.header.set_gas_limit(*header.gas_limit());
- self.block.header.set_timestamp(header.timestamp());
- self.block.header.set_author(*header.author());
- self.block.header.set_uncles_hash(*header.uncles_hash());
- self.block.header.set_transactions_root(*header.transactions_root());
- // TODO: that's horrible. set only for backwards compatibility
- if header.extra_data().len() > self.engine.maximum_extra_data_size() {
- warn!("Couldn't set extradata. Ignoring.");
- } else {
- self.block.header.set_extra_data(header.extra_data().clone());
- }
- }
-
/// Turn this into a `ClosedBlock`.
pub fn close(self) -> Result<ClosedBlock, Error> {
let unclosed_state = self.block.state.clone();
@@ -453,14 +436,20 @@ impl LockedBlock {
/// Provide a valid seal in order to turn this into a `SealedBlock`.
///
/// NOTE: This does not check the validity of `seal` with the engine.
- pub fn seal(self, engine: &EthEngine, seal: Vec<Bytes>) -> Result<SealedBlock, BlockError> {
+ pub fn seal(self, engine: &EthEngine, seal: Vec<Bytes>) -> Result<SealedBlock, Error> {
let expected_seal_fields = engine.seal_fields(self.header());
- let mut s = self;
if seal.len() != expected_seal_fields {
- return Err(BlockError::InvalidSealArity(
- Mismatch { expected: expected_seal_fields, found: seal.len() }));
+ return Err(Box::new(BlockError::InvalidSealArity(
+ Mismatch { expected: expected_seal_fields, found: seal.len() })).into());
}
+ let mut s = self;
+
s.block.header.set_seal(seal);
+
+ if let Some(new_header) = engine.on_seal_block(&s.block)? {
+ s.block.header = new_header;
+ }
+
s.block.header.compute_hash();
Ok(SealedBlock {
block: s.block
@@ -470,6 +459,7 @@ 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.
+ /// TODO(sunyc): This is currently only used in POW chain call paths, we should really merge it with seal() above.
pub fn try_seal(
self,
engine: &EthEngine,
@@ -515,7 +505,7 @@ impl IsBlock for SealedBlock {
}
/// Enact the block given by block header, transactions and uncles
-fn enact(
+pub fn enact(
header: Header,
transactions: Vec<SignedTransaction>,
uncles: Vec<Header>,
@@ -528,12 +518,12 @@ fn enact(
is_epoch_begin: bool,
ancestry: &mut Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {
- {
- if ::log::max_level() >= ::log::Level::Trace {
- let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?;
- trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n",
- header.number(), s.root(), header.author(), s.balance(&header.author())?);
- }
+ // For trace log
+ let s: Option<State<StateDB>>;
+ if log_enabled!(target: "enact", ::log::Level::Trace) {
+ s = Some(State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?);
+ } else {
+ s = Default::default();
}
let mut b = OpenBlock::new(
@@ -543,14 +533,29 @@ fn enact(
db,
parent,
last_hashes,
- Address::new(),
+ // Engine such as Clique will calculate author from extra_data.
+ // this is only important for executing contracts as the 'executive_author'.
+ engine.executive_author(&header),
(3141562.into(), 31415620.into()),
- vec![],
+ header.extra_data().clone(),
is_epoch_begin,
ancestry,
)?;
- b.populate_from(&header);
+ b.block.header.set_difficulty(*header.difficulty());
+ b.block.header.set_gas_limit(*header.gas_limit());
+ b.block.header.set_timestamp(header.timestamp());
+ b.block.header.set_uncles_hash(*header.uncles_hash());
+ b.block.header.set_transactions_root(*header.transactions_root());
+
+ if log_enabled!(target: "enact", ::log::Level::Trace) && s.is_some() {
+ let env = b.env_info();
+ let root = s.as_ref().unwrap().root();
+ let author_balance = s.as_ref().unwrap().balance(&env.author)?;
+ trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n",
+ b.block.header.number(), root, env.author, author_balance);
+ }
+
b.push_transactions(transactions)?;
for u in uncles {
@@ -560,34 +565,6 @@ fn enact(
b.close_and_lock()
}
-/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
-pub fn enact_verified(
- block: PreverifiedBlock,
- engine: &EthEngine,
- tracing: bool,
- db: StateDB,
- parent: &Header,
- last_hashes: Arc<LastHashes>,
- factories: Factories,
- is_epoch_begin: bool,
- ancestry: &mut Iterator<Item=ExtendedHeader>,
-) -> Result<LockedBlock, Error> {
-
- enact(
- block.header,
- block.transactions,
- block.uncles,
- engine,
- tracing,
- db,
- parent,
- last_hashes,
- factories,
- is_epoch_begin,
- ancestry,
- )
-}
-
#[cfg(test)]
mod tests {
use test_helpers::get_temp_state_db;
@@ -615,8 +592,9 @@ mod tests {
last_hashes: Arc<LastHashes>,
factories: Factories,
) -> Result<LockedBlock, Error> {
- let block = Unverified::from_rlp(block_bytes)?;
- let header = block.header;
+ let mut block = Unverified::from_rlp(block_bytes)?;
+ let mut header = block.header;
+
let transactions: Result<Vec<_>, Error> = block
.transactions
.into_iter()
@@ -625,36 +603,19 @@ mod tests {
.collect();
let transactions = transactions?;
- {
- if ::log::max_level() >= ::log::Level::Trace {
- let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?;
- trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n",
- header.number(), s.root(), header.author(), s.balance(&header.author())?);
- }
- }
-
- let mut b = OpenBlock::new(
+ enact(
+ header,
+ transactions,
+ block.uncles,
engine,
- factories,
tracing,
db,
parent,
last_hashes,
- Address::new(),
- (3141562.into(), 31415620.into()),
- vec![],
+ factories,
false,
&mut Vec::new().into_iter(),
- )?;
-
- b.populate_from(&header);
- b.push_transactions(transactions)?;
-
- for u in block.uncles {
- b.push_uncle(u)?;
- }
-
- b.close_and_lock()
+ )
}
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards
@@ -669,7 +630,7 @@ mod tests {
) -> Result<SealedBlock, Error> {
let header = Unverified::from_rlp(block_bytes.clone())?.header;
Ok(enact_bytes(block_bytes, engine, tracing, db, parent, last_hashes, factories)?
- .seal(engine, header.seal().to_vec())?)
+ .seal(engine, header.seal().to_vec())?)
}
#[test]
diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs
index 0be48a636..db0dbad3d 100644
--- a/ethcore/src/client/client.rs
+++ b/ethcore/src/client/client.rs
@@ -45,7 +45,7 @@ use types::receipt::{Receipt, LocalizedReceipt};
use types::{BlockNumber, header::{Header, ExtendedHeader}};
use vm::{EnvInfo, LastHashes};
-use block::{IsBlock, LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
+use block::{IsBlock, LockedBlock, Drain, ClosedBlock, OpenBlock, enact, SealedBlock};
use client::ancient_import::AncientVerifier;
use client::{
Nonce, Balance, ChainInfo, BlockInfo, TransactionInfo,
@@ -407,8 +407,11 @@ impl Importer {
let db = client.state_db.read().boxed_clone_canon(header.parent_hash());
let is_epoch_begin = chain.epoch_transition(parent.number(), *header.parent_hash()).is_some();
- let enact_result = enact_verified(
- block,
+
+ let enact_result = enact(
+ block.header,
+ block.transactions,
+ block.uncles,
engine,
client.tracedb.read().tracing_enabled(),
db,
@@ -2523,7 +2526,7 @@ impl SnapshotClient for Client {}
impl Drop for Client {
fn drop(&mut self) {
- self.engine.stop();
+ Arc::get_mut(&mut self.engine).and_then(|x| Some(x.stop()));
}
}
diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs
index 9cced0a0d..8b1b74066 100644
--- a/ethcore/src/engines/mod.rs
+++ b/ethcore/src/engines/mod.rs
@@ -18,6 +18,7 @@
mod authority_round;
mod basic_authority;
+mod clique;
mod instant_seal;
mod null_engine;
mod validator_set;
@@ -31,6 +32,7 @@ pub use self::epoch::{EpochVerifier, Transition as EpochTransition};
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::null_engine::NullEngine;
pub use self::signer::EngineSigner;
+pub use self::clique::Clique;
// TODO [ToDr] Remove re-export (#10130)
pub use types::engines::ForkChoice;
@@ -44,13 +46,12 @@ use builtin::Builtin;
use vm::{EnvInfo, Schedule, CreateContractAddress, CallType, ActionValue};
use error::Error;
use types::BlockNumber;
-use types::header::Header;
use snapshot::SnapshotComponents;
use spec::CommonParams;
use types::transaction::{self, UnverifiedTransaction, SignedTransaction};
-
use ethkey::{Signature};
-use parity_machine::{Machine, LocalizedMachine as Localized, TotalScoredHeader};
+use types::header::Header;
+use parity_machine::{Machine, LocalizedMachine as Localized, TotalScoredHeader, Header as MachineHeader};
use ethereum_types::{H256, U256, Address};
use unexpected::{Mismatch, OutOfBounds};
use bytes::Bytes;
@@ -118,7 +119,7 @@ pub enum Seal {
Proposal(Vec<Bytes>),
/// Regular block seal; should be part of the blockchain.
Regular(Vec<Bytes>),
- /// Engine does generate seal for this block right now.
+ /// Engine does not generate seal for this block right now.
None,
}
@@ -265,6 +266,9 @@ pub trait Engine<M: Machine>: Sync + Send {
Ok(())
}
+ /// Allow returning new block header after seal generation. Currently only used by Clique.
+ fn on_seal_block(&self, _block: &M::LiveBlock) -> Result<Option<M::Header>, M::Error> { Ok(None) }
+
/// None means that it requires external input (e.g. PoW) to seal a block.
/// Some(true) means the engine is currently prime for seal generation (i.e. node is the current validator).
/// Some(false) means that the node might seal internally but is not qualified now.
@@ -393,7 +397,7 @@ pub trait Engine<M: Machine>: Sync + Send {
fn step(&self) {}
/// Stops any services that the may hold the Engine and makes it safe to drop.
- fn stop(&self) {}
+ fn stop(&mut self) {}
/// Create a factory for building snapshot chunks and restoring from them.
/// Returning `None` indicates that this engine doesn't support snapshot creation.
@@ -427,6 +431,9 @@ pub trait Engine<M: Machine>: Sync + Send {
/// Check whether the given new block is the best block, after finalization check.
fn fork_choice(&self, new: &M::ExtendedHeader, best: &M::ExtendedHeader) -> ForkChoice;
+
+ /// Return author should used in executing txns for this block.
+ fn executive_author(&self, header: &M::Header) -> Address { header.author().clone() }
}
/// Check whether a given block is the best block based on the default total difficulty rule.
diff --git a/ethcore/src/ethereum/mod.rs b/ethcore/src/ethereum/mod.rs
index b7c60789a..d37ca9b4f 100644
--- a/ethcore/src/ethereum/mod.rs
+++ b/ethcore/src/ethereum/mod.rs
@@ -94,6 +94,11 @@ pub fn new_mix<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/mix.json"))
}
+/// Create a new Callisto chain spec
+pub fn new_callisto<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
+ load(params.into(), include_bytes!("../../res/ethereum/callisto.json"))
+}
+
/// Create a new Morden testnet chain spec.
pub fn new_morden<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/morden.json"))
@@ -109,16 +114,26 @@ pub fn new_kovan<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/kovan.json"))
}
+/// Create a new Rinkeby testnet chain spec.
+pub fn new_rinkeby<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
+ load(params.into(), include_bytes!("../../res/ethereum/rinkeby.json"))
+}
+
+/// Create a new Görli testnet chain spec.
+pub fn new_goerli<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
+ load(params.into(), include_bytes!("../../res/ethereum/goerli.json"))
+}
+
+/// Create a new Kotti testnet chain spec.
+pub fn new_kotti<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
+ load(params.into(), include_bytes!("../../res/ethereum/kotti.json"))
+}
+
/// Create a new POA Sokol testnet chain spec.
pub fn new_sokol<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/poasokol.json"))
}
-/// Create a new Callisto chaun spec
-pub fn new_callisto<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
- load(params.into(), include_bytes!("../../res/ethereum/callisto.json"))
-}
-
// For tests
/// Create a new Foundation Frontier-era chain spec as though it never changes to Homestead.
diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs
index 7d6bcbe49..cb2991d5b 100644
--- a/ethcore/src/miner/miner.rs
+++ b/ethcore/src/miner/miner.rs
@@ -630,6 +630,7 @@ impl Miner {
}
}
+ // TODO: This is only used in authority_round path, and should be refactored to merge with the other seal() path.
/// Attempts to perform internal sealing (one that does not require work) and handles the result depending on the type of Seal.
fn seal_and_import_block_internally<C>(&self, chain: &C, block: ClosedBlock) -> bool
where C: BlockChain + SealedBlockImporter,
diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs
index 4bd46b2bb..6e9b5b83e 100644
--- a/ethcore/src/spec/spec.rs
+++ b/ethcore/src/spec/spec.rs
@@ -35,7 +35,7 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
use builtin::Builtin;
use engines::{
- EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority,
+ EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique,
AuthorityRound, DEFAULT_BLOCKHASH_CONTRACT
};
use error::Error;
@@ -91,7 +91,7 @@ pub struct CommonParams {
pub eip161d_transition: BlockNumber,
/// Number of first block where EIP-98 rules begin.
pub eip98_transition: BlockNumber,
- /// Number of first block where EIP-658 rules begin.
+ /// Number of first block where EIP-658 (BYZANTIUM) rules begin.
pub eip658_transition: BlockNumber,
/// Number of first block where EIP-155 rules begin.
pub eip155_transition: BlockNumber,
@@ -99,9 +99,9 @@ pub struct CommonParams {
pub validate_receipts_transition: BlockNumber,
/// Validate transaction chain id.
pub validate_chain_id_transition: BlockNumber,
- /// Number of first block where EIP-140 (Metropolis: REVERT opcode) rules begin.
+ /// Number of first block where EIP-140 (BYZANTIUM: REVERT opcode) rules begin.
pub eip140_transition: BlockNumber,
- /// Number of first block where EIP-210 (Metropolis: BLOCKHASH changes) rules begin.
+ /// Number of first block where EIP-210 (CONSTANTINOPLE: BLOCKHASH changes) rules begin.
pub eip210_transition: BlockNumber,
/// EIP-210 Blockhash contract address.
pub eip210_contract_address: Address,
@@ -109,18 +109,18 @@ pub struct CommonParams {
pub eip210_contract_code: Bytes,
/// Gas allocated for EIP-210 blockhash update.
pub eip210_contract_gas: U256,
- /// Number of first block where EIP-211 (Metropolis: RETURNDATASIZE/RETURNDATACOPY) rules
+ /// Number of first block where EIP-211 (BYZANTIUM: RETURNDATASIZE/RETURNDATACOPY) rules
/// begin.
pub eip211_transition: BlockNumber,
- /// Number of first block where EIP-214 rules begin.
+ /// Number of first block where EIP-214 (BYZANTIUM) rules begin.
pub eip214_transition: BlockNumber,
- /// Number of first block where EIP-145 rules begin.
+ /// Number of first block where EIP-145 (CONSTANTINOPLE) rules begin.
pub eip145_transition: BlockNumber,
- /// Number of first block where EIP-1052 rules begin.
+ /// Number of first block where EIP-1052 (CONSTANTINOPLE) rules begin.
pub eip1052_transition: BlockNumber,
- /// Number of first block where EIP-1283 rules begin.
+ /// Number of first block where EIP-1283 (CONSTANTINOPLE) rules begin.
pub eip1283_transition: BlockNumber,
- /// Number of first block where EIP-1283 rules end.
+ /// Number of first block where EIP-1283 rules end. (CONSTANTINOPLE)
pub eip1283_disable_transition: BlockNumber,
/// Number of first block where EIP-1014 rules begin.
pub eip1014_transition: BlockNumber,
@@ -611,6 +611,8 @@ impl Spec {
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
+ ethjson::spec::Engine::Clique(clique) => Clique::new(clique.params.into(), machine)
+ .expect("Failed to start Clique consensus engine."),
ethjson::spec::Engine::AuthorityRound(authority_round) => AuthorityRound::new(authority_round.params.into(), machine)
.expect("Failed to start AuthorityRound consensus engine."),
}
@@ -827,7 +829,6 @@ impl Spec {
ethjson::spec::Spec::load(reader)
.map_err(fmt_err)
.map(load_machine_from)
-
}
/// Loads spec from json file. Provide factories for executing contracts and ensuring
diff --git a/json/src/spec/engine.rs b/json/src/spec/engine.rs
index 8941f89e1..702bae0b5 100644
--- a/json/src/spec/engine.rs
+++ b/json/src/spec/engine.rs
@@ -16,7 +16,7 @@
//! Engine deserialization.
-use super::{Ethash, BasicAuthority, AuthorityRound, NullEngine, InstantSeal};
+use super::{Ethash, BasicAuthority, AuthorityRound, NullEngine, InstantSeal, Clique};
/// Engine deserialization.
#[derive(Debug, PartialEq, Deserialize)]
@@ -34,6 +34,8 @@ pub enum Engine {
BasicAuthority(BasicAuthority),
/// AuthorityRound engine.
AuthorityRound(AuthorityRound),
+ /// Clique engine.
+ Clique(Clique)
}
#[cfg(test)]
@@ -130,5 +132,19 @@ mod tests {
Engine::AuthorityRound(_) => {}, // AuthorityRound is unit tested in its own file.
_ => panic!(),
};
+
+ let s = r#"{
+ "clique": {
+ "params": {
+ "peorid" : 15,
+ "epoch": 30000
+ }
+ }
+ }"#;
+ let deserialized: Engine = serde_json::from_str(s).unwrap();
+ match deserialized {
+ Engine::Clique(_) => {}, // AuthorityRound is unit tested in its own file.
+ _ => panic!(),
+ };
}
}
diff --git a/json/src/spec/mod.rs b/json/src/spec/mod.rs
index 1d6815d37..f1145be2e 100644
--- a/json/src/spec/mod.rs
+++ b/json/src/spec/mod.rs
@@ -31,6 +31,7 @@ pub mod authority_round;
pub mod null_engine;
pub mod instant_seal;
pub mod hardcoded_sync;
+pub mod clique;
pub use self::account::Account;
pub use self::builtin::{Builtin, Pricing, Linear};
@@ -44,6 +45,7 @@ pub use self::ethash::{Ethash, EthashParams, BlockReward};
pub use self::validator_set::ValidatorSet;
pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
pub use self::authority_round::{AuthorityRound, AuthorityRoundParams};
+pub use self::clique::{Clique, CliqueParams};
pub use self::null_engine::{NullEngine, NullEngineParams};
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::hardcoded_sync::HardcodedSync;
diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs
index c372e9bff..01f4469bb 100644
--- a/parity/cli/mod.rs
+++ b/parity/cli/mod.rs
@@ -300,7 +300,7 @@ usage! {
ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(),
"--chain=[CHAIN]",
- "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, tobalaba, expanse, musicoin, ellaism, easthub, social, mix, callisto, morden, ropsten, kovan, poasokol, testnet, or dev.",
+ "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, classic, poacore, tobalaba, expanse, musicoin, ellaism, easthub, social, mix, callisto, morden, ropsten, kovan, rinkeby, goerli, kotti, poasokol, testnet, or dev.",
ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(),
"--keys-path=[PATH]",
@@ -926,7 +926,7 @@ usage! {
"--whisper",
"Enable the Whisper network.",
- ARG arg_whisper_pool_size: (usize) = 10usize, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
+ ARG arg_whisper_pool_size: (usize) = 10usize, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
"--whisper-pool-size=[MB]",
"Target size of the whisper message pool in megabytes.",
diff --git a/parity/params.rs b/parity/params.rs
index a916d05a7..389b708ce 100644
--- a/parity/params.rs
+++ b/parity/params.rs
@@ -47,6 +47,9 @@ pub enum SpecType {
Morden,
Ropsten,
Kovan,
+ Rinkeby,
+ Goerli,
+ Kotti,
Sokol,
Dev,
Custom(String),
@@ -77,6 +80,9 @@ impl str::FromStr for SpecType {
"morden" | "classic-testnet" => SpecType::Morden,
"ropsten" => SpecType::Ropsten,
"kovan" | "testnet" => SpecType::Kovan,
+ "rinkeby" => SpecType::Rinkeby,
+ "goerli" | "görli" => SpecType::Goerli,
+ "kotti" => SpecType::Kotti,
"sokol" | "poasokol" => SpecType::Sokol,
"dev" => SpecType::Dev,
other => SpecType::Custom(other.into()),
@@ -102,6 +108,9 @@ impl fmt::Display for SpecType {
SpecType::Morden => "morden",
SpecType::Ropsten => "ropsten",
SpecType::Kovan => "kovan",
+ SpecType::Rinkeby => "rinkeby",
+ SpecType::Goerli => "goerli",
+ SpecType::Kotti => "kotti",
SpecType::Sokol => "sokol",
SpecType::Dev => "dev",
SpecType::Custom(ref custom) => custom,
@@ -127,6 +136,9 @@ impl SpecType {
SpecType::Morden => Ok(ethereum::new_morden(params)),
SpecType::Ropsten => Ok(ethereum::new_ropsten(params)),
SpecType::Kovan => Ok(ethereum::new_kovan(params)),
+ SpecType::Rinkeby => Ok(ethereum::new_rinkeby(params)),
+ SpecType::Goerli => Ok(ethereum::new_goerli(params)),
+ SpecType::Kotti => Ok(ethereum::new_kotti(params)),
SpecType::Sokol => Ok(ethereum::new_sokol(params)),
SpecType::Dev => Ok(Spec::new_instant()),
SpecType::Custom(ref filename) => {
@@ -385,6 +397,10 @@ mod tests {
assert_eq!(SpecType::Ropsten, "ropsten".parse().unwrap());
assert_eq!(SpecType::Kovan, "kovan".parse().unwrap());
assert_eq!(SpecType::Kovan, "testnet".parse().unwrap());
+ assert_eq!(SpecType::Rinkeby, "rinkeby".parse().unwrap());
+ assert_eq!(SpecType::Goerli, "goerli".parse().unwrap());
+ assert_eq!(SpecType::Goerli, "görli".parse().unwrap());
+ assert_eq!(SpecType::Kotti, "kotti".parse().unwrap());
assert_eq!(SpecType::Sokol, "sokol".parse().unwrap());
assert_eq!(SpecType::Sokol, "poasokol".parse().unwrap());
}
@@ -410,6 +426,9 @@ mod tests {
assert_eq!(format!("{}", SpecType::Morden), "morden");
assert_eq!(format!("{}", SpecType::Ropsten), "ropsten");
assert_eq!(format!("{}", SpecType::Kovan), "kovan");
+ assert_eq!(format!("{}", SpecType::Rinkeby), "rinkeby");
+ assert_eq!(format!("{}", SpecType::Goerli), "goerli");
+ assert_eq!(format!("{}", SpecType::Kotti), "kotti");
assert_eq!(format!("{}", SpecType::Sokol), "sokol");
assert_eq!(format!("{}", SpecType::Dev), "dev");
assert_eq!(format!("{}", SpecType::Custom("foo/bar".into())), "foo/bar");
diff --git a/scripts/gitlab/sign-win.cmd b/scripts/gitlab/sign-win.cmd
old mode 100755
new mode 100644
diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml
index 0f5405fcb..33b6aa846 100644
--- a/util/version/Cargo.toml
+++ b/util/version/Cargo.toml
@@ -3,8 +3,8 @@
[package]
name = "parity-version"
# NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION)
-version = "2.4.3"
-authors = ["Parity Technologies <admin@parity.io>"]
+version = "2.4.3-clique"
+authors = ["Parity Technologies <admin@parity.io>", "Yucong Sun"]
build = "build.rs"
[package.metadata]
@@ -19,6 +19,7 @@ track = "beta"
foundation = { forkBlock = 7280000, critical = false }
ropsten = { forkBlock = 4939394, critical = false }
kovan = { forkBlock = 10255201, critical = false }
+goerli = { forkBlock = 0, critical = false }
[dependencies]
parity-bytes = "0.1"