Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ethcore: add clique engine #9981

Merged
merged 302 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
302 commits
Select commit Hold shift + click to select a range
6c0c97c
Merge pull request #18 from goerli/clique-voting
thefallentree Nov 19, 2018
4fc037c
fix broken sync
jwasinger Nov 19, 2018
cca282e
Merge pull request #19 from goerli/sync-fix
jwasinger Nov 20, 2018
5514e1a
Merge pull request #20 from paritytech/master
5chdn Nov 22, 2018
efc326d
correct seal fields
jwasinger Nov 25, 2018
e7233f3
ethcore: fix comment
5chdn Nov 28, 2018
3059f5a
parity: remove duplicate params
5chdn Nov 28, 2018
cf2ad32
clique: fix whitespaces
5chdn Nov 28, 2018
b045e13
Merge pull request #23 from paritytech/master
5chdn Nov 28, 2018
cbf224d
Merge pull request #22 from goerli/a5-config-fixes
5chdn Nov 28, 2018
d492700
ethcore: fix goerli chain spec
5chdn Nov 28, 2018
93869f6
Merge pull request #24 from goerli/a5-config-goerlispec
5chdn Nov 28, 2018
2430e66
refactor signer_snapshot into pending/finalized state
jwasinger Nov 29, 2018
afc7aac
Merge branch 'master' of github.com:paritytech/parity-ethereum into a…
5chdn Nov 29, 2018
c9e651e
Merge pull request #25 from goerli/a5-backport-downstream
5chdn Nov 29, 2018
314fe35
move close_block_extra_data after seal is applied
jwasinger Nov 30, 2018
d6ff43d
refactor most of the logic into the signer_snapshot
jwasinger Dec 1, 2018
9347601
clique: refactor locking logic out of the consensus engine interface
jwasinger Dec 1, 2018
ca62dde
Merge #21 "Voting logic from jwasinger. Fix up build.
thefallentree Dec 2, 2018
320fd9a
Fix jsonspec and add an unittest
thefallentree Dec 2, 2018
af0cc3d
Replace space with tabs
thefallentree Dec 2, 2018
3a67edf
Merge remote-tracking branch 'upstream/master'
thefallentree Dec 2, 2018
b7bf2d1
Unbroke sync
thefallentree Dec 4, 2018
f807ff5
Merge remote-tracking branch 'upstream/master'
thefallentree Dec 4, 2018
0802cac
Fix broken sync
thefallentree Dec 4, 2018
118b885
1/2 state tracking without votes
thefallentree Dec 10, 2018
f281ddc
2/2 implement vote tracking
thefallentree Dec 10, 2018
8a9c9a2
ci: use travis for goerli
5chdn Dec 12, 2018
07d30b9
ci: setup a clique network
5chdn Dec 12, 2018
4081552
ci: sync a görli node
5chdn Dec 12, 2018
0354f25
add clique deploy script
5chdn Dec 12, 2018
0b00878
ci: fix paths in clique deploy script
5chdn Dec 12, 2018
d353f75
ci: use docker compose
5chdn Dec 12, 2018
f65e298
Merge pull request #27 from paritytech/master
5chdn Dec 12, 2018
0c050d0
ci: fix travis job names
5chdn Dec 12, 2018
eeac578
Merge branch 'master' into a5-ci-travis
5chdn Dec 12, 2018
323295c
ci: fix build deps
5chdn Dec 12, 2018
6369f0b
ci: massively reduce tests
5chdn Dec 12, 2018
d8f0aeb
Revert "ci: massively reduce tests"
5chdn Dec 12, 2018
60f7fea
ci: run cargo test directly
5chdn Dec 12, 2018
44a8519
ci: separate build and test stages
5chdn Dec 12, 2018
e48505d
ci: cache rust installation
5chdn Dec 12, 2018
233d3c0
ci: simplify ci stages
5chdn Dec 12, 2018
3c2c263
ci: make clique deploy script executable
5chdn Dec 12, 2018
d047c82
ci: shutdown goerli sync after 20min
5chdn Dec 12, 2018
f461140
ci: remove slow sync stage
5chdn Dec 12, 2018
809dcda
ci: use timeout to finish jobs
5chdn Dec 12, 2018
1c2628d
ci: fix build path
5chdn Dec 12, 2018
02bb363
ci: use absolute paths to end this confusion
5chdn Dec 12, 2018
c21121c
ci: add geth and parity to path
5chdn Dec 12, 2018
59d1b11
ci: be more verbose
5chdn Dec 12, 2018
5ff6444
ci: allow for more relaxed caching timeout
5chdn Dec 12, 2018
416ceb6
ci: update repositories for custom ppa
5chdn Dec 12, 2018
704d3c3
ci: fix typo in file name
5chdn Dec 13, 2018
667da04
ci: fix docker compose file
5chdn Dec 13, 2018
1d261a8
ci: add ethkey to docker
5chdn Dec 14, 2018
e666f0e
ci: make sure deploy script is up to date with upstream
5chdn Dec 14, 2018
40c0b4d
ci: stop docker container after certain time
5chdn Dec 14, 2018
57de716
ci: force superuser to update permissions on docker files
5chdn Dec 14, 2018
a1a61d5
ci: reduce run time of script to ~30 min
5chdn Dec 14, 2018
a562838
ci: remove duplicate caching in travis
5chdn Dec 14, 2018
857805d
Merge pull request #26 from goerli/a5-ci-travis
5chdn Dec 14, 2018
d0f5e46
remove trace statements
jwasinger Dec 19, 2018
9887ed2
clique: add more validation involving the recent signer list
jwasinger Dec 19, 2018
ec45121
Merge pull request #28 from goerli/recent-signers
jwasinger Dec 23, 2018
916f6cc
ethcore: enable constantinople for rinkeby
5chdn Dec 25, 2018
28141c3
ethcore: fix whitespaces in rinkeby spec
5chdn Dec 25, 2018
14a39c6
ethcore: reformat goerli.json
5chdn Dec 25, 2018
227c612
Revert "ci: remove duplicate caching in travis"
5chdn Dec 25, 2018
a0616cf
Merge pull request #30 from paritytech/master
5chdn Dec 25, 2018
3c1fbd7
Merge pull request #32 from goerli/a5-ci-cache
5chdn Dec 25, 2018
0e75579
Merge pull request #31 from goerli/a5-config-rinkeby
5chdn Dec 25, 2018
863b983
tmp commit
jwasinger Dec 21, 2018
edc9dae
another tmp commit
jwasinger Dec 22, 2018
67bbd3a
it builds!
jwasinger Dec 23, 2018
3dcf4e6
add sealing capabilities
jwasinger Dec 24, 2018
66c374c
add seal_header hook to allow separation of block seal/importing code…
jwasinger Dec 27, 2018
458c2c6
clique: remove populate_from_parent.
jwasinger Dec 27, 2018
b9dde49
add panic
jwasinger Dec 29, 2018
8d0f40e
make turn delay random
jwasinger Dec 30, 2018
ec2a643
initialize OpenBlock properly in 'enact'
jwasinger Jan 2, 2019
e92ceb3
Merge pull request #29 from jwasinger/proposer
jwasinger Jan 5, 2019
2bbac44
Merge pull request #37 from paritytech/master
5chdn Jan 6, 2019
e92c712
Merge pull request #39 from paritytech/master
5chdn Jan 8, 2019
3e7e018
misc: remove duplicate lines
5chdn Jan 8, 2019
0e5dbef
misc: fix license headers
5chdn Jan 8, 2019
2e9a6f4
misc: convert spaces to tabs
5chdn Jan 8, 2019
b4ab154
misc: fix tabs
5chdn Jan 8, 2019
cf2fa65
Merge pull request #40 from goerli/a5-misc-tabspaces
5chdn Jan 8, 2019
ee12fdb
Update Cargo.toml
5chdn Jan 20, 2019
f2e6608
Update Cargo.toml
5chdn Jan 20, 2019
cf7fc72
Merge pull request #42 from paritytech/master
5chdn Jan 20, 2019
11e00a8
Update Cargo.toml
5chdn Jan 20, 2019
abc625d
clique: ensure validator restores state before trying to seal
jwasinger Jan 7, 2019
2aae31b
clique: make 'state' return an Error. Make some error messages more …
jwasinger Jan 8, 2019
fe3517c
Fix compile error after rebase & toolchain upgrade
thefallentree Jan 22, 2019
fcf787c
Merge pull request #38 from goerli/restore-voting-state
thefallentree Jan 22, 2019
2f4d8ea
fix a bunch of import warnings
thefallentree Jan 22, 2019
14c5e0d
Merge upstream master
thefallentree Jan 22, 2019
302b5e4
Refactor code
thefallentree Jan 25, 2019
73bf83a
Fix permissions
thefallentree Jan 26, 2019
be0e425
Refactoring syncing
thefallentree Jan 27, 2019
4e56a77
Merge remote-tracking branch 'upstream/master'
thefallentree Jan 27, 2019
a742e7e
Merge branch 'master' of github.com:goerli/parity-goerli
thefallentree Jan 27, 2019
210aa53
Implement full validator checks
thefallentree Jan 28, 2019
7599178
Refactor util functions to seperate file
thefallentree Jan 28, 2019
3d46f00
mining 1
thefallentree Jan 28, 2019
22ccb23
ethcore: add chainspec for kotti
5chdn Jan 28, 2019
a18c736
ethcore: rename pre-goerli configs
5chdn Jan 28, 2019
d36bbca
ethcore: load kotti chain spec
5chdn Jan 28, 2019
6c77d86
cli: add kotti to params
5chdn Jan 28, 2019
100b149
Implement working local sealing
thefallentree Jan 29, 2019
bf6a0df
making sealing & syncing work together
thefallentree Jan 29, 2019
4439b37
Merge pull request #45 from goerli/a5-config-kotti
thefallentree Jan 29, 2019
99821ce
Merge remote-tracking branch 'upstream/master'
thefallentree Jan 29, 2019
9730371
Relax timestamp checking
thefallentree Jan 30, 2019
a6aa972
ethcore: prepare for the real goerli to launch
5chdn Jan 30, 2019
46af42d
Merge remote-tracking branch 'upstream/master'
thefallentree Jan 30, 2019
6ee58dd
Merge branch 'master' of github.com:goerli/parity-goerli
thefallentree Jan 30, 2019
a5409e8
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 5, 2019
dbf54d7
Implement NOTURN wiggle properly & cleanupnup warnings
thefallentree Feb 5, 2019
df1a38b
Implement vote casting
thefallentree Feb 5, 2019
2ee251f
Update docs & skip signing if no signer
thefallentree Feb 5, 2019
c45320d
Optimize step-service interval
thefallentree Feb 5, 2019
b36849d
Record state on local sealed block
thefallentree Feb 5, 2019
e5552d2
Fix script filemode
thefallentree Feb 5, 2019
57b9c01
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 5, 2019
8a9fe57
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 9, 2019
6090cf9
Cleaning up codebase
thefallentree Feb 9, 2019
9f52edb
restore enact trace logging
thefallentree Feb 9, 2019
06c42d3
Delete clique.sh and move sync.sh
thefallentree Feb 9, 2019
5e2e808
remove travis.yml
thefallentree Feb 9, 2019
5cd3286
Remove dead code
thefallentree Feb 9, 2019
4f967e2
Cleanup compile warning
thefallentree Feb 9, 2019
9b78af4
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 12, 2019
df4fe78
address review comments
thefallentree Feb 12, 2019
24fcd3b
adding more comments and removing unwrap()
thefallentree Feb 12, 2019
f8fbfc4
ci: remove sync script
5chdn Feb 12, 2019
9e30bd5
Address review comments
thefallentree Feb 12, 2019
c80a0f3
fix compile error
thefallentree Feb 12, 2019
9724b0f
adding better debugging for timing
thefallentree Feb 12, 2019
3d01480
Implement an dedicated thread for sealing timing
thefallentree Feb 13, 2019
97af6a0
addressing review comments
thefallentree Feb 14, 2019
17ea04d
fix(add helper for timestamp overflows) (#10330)
niklasad1 Feb 12, 2019
db63dc1
snap: official image / test (#10168)
TriplEight Feb 12, 2019
459e57f
fix(docker): fix not receives SIGINT (#10059)
Feb 12, 2019
3b69a28
Don't add discovery initiators to the node table (#10305)
kirushik Feb 12, 2019
e7adcd8
change docker image based on debian instead of ubuntu due to the chan…
gabreal Feb 12, 2019
7a4893f
role back docker build image and docker deploy image to ubuntu:xenial…
gabreal Feb 12, 2019
b887052
Bundle protocol and packet_id together in chain sync (#10315)
elferdo Feb 13, 2019
bf9899d
snap: prefix version and populate candidate channel (#10343)
5chdn Feb 13, 2019
2c8c090
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 14, 2019
7e3a76d
engine: fix copyright header
5chdn Feb 14, 2019
e5fd014
scripts: restore permissions on sign command
5chdn Feb 14, 2019
775eb60
ethcore: enforce tabs
5chdn Feb 14, 2019
c25bed4
ethcore: enforce tabs
5chdn Feb 14, 2019
c98fe7f
ethcore: enforce tabs
5chdn Feb 14, 2019
2c9e1cf
Merge pull request #53 from goerli/a5-cleanup
5chdn Feb 15, 2019
270463d
Merge remote-tracking branch 'upstream/master'
thefallentree Feb 24, 2019
00f9ec5
addressing comments
thefallentree Feb 24, 2019
c5e99e1
addressing comments
thefallentree Feb 24, 2019
c7962b2
addressing more comments
thefallentree Feb 24, 2019
0329079
addressing more comments
thefallentree Feb 24, 2019
38b31fe
addressing more comments
thefallentree Feb 24, 2019
7ba7ce2
addressing more comments
thefallentree Feb 24, 2019
e53c22f
addressing more comments
thefallentree Feb 24, 2019
16d884e
Merge remote-tracking branch 'upstream/master'
thefallentree Mar 6, 2019
58e7e7b
json-spec: fix clique epoch to non-zero u64
soc1c Mar 9, 2019
2768340
ci: enable travis for parity goerli
soc1c Mar 9, 2019
13a2411
Merge pull request #55 from goerli/c1-ethstore-u64
ChainSafeSystems Mar 9, 2019
1bfe3f2
ci: don't separate build and test step
soc1c Mar 9, 2019
c36d01c
ci: don't run c++ tests on travis
soc1c Mar 9, 2019
4adb9da
Merge branch 'master' into c1-ci-travis
soc1c Mar 9, 2019
d690274
ci: simplify cargo test to squeeze into travis timeout
soc1c Mar 9, 2019
e3b1bfd
ci: don't run tests on travis at all
soc1c Mar 9, 2019
c146ef3
Merge pull request #56 from goerli/c1-ci-travis
soc1c Mar 9, 2019
3dea774
style(fixes)
niklasad1 Feb 25, 2019
8afdfaf
fix(add tests)
niklasad1 Mar 1, 2019
500266d
fix(recent_signer bug)
niklasad1 Mar 6, 2019
67d2e48
fix(complete all tests)
niklasad1 Mar 7, 2019
11b153b
fix(nits)
niklasad1 Mar 7, 2019
ecd8786
fix(simplify asserts)
niklasad1 Mar 7, 2019
b5d20f1
fix(cliqueState): simplify code
niklasad1 Mar 7, 2019
045d6ed
fix(nits)
niklasad1 Mar 7, 2019
a9afb61
docs(comments what's need to fixed)
niklasad1 Mar 7, 2019
ae03ab7
fix(revert unintended changes)
niklasad1 Mar 7, 2019
8d1fd4b
fix(tests)
niklasad1 Mar 8, 2019
a459508
fix(logs): voting logs
niklasad1 Mar 8, 2019
0d2e873
fix(readability + more logs)
niklasad1 Mar 9, 2019
1cf8f8f
fix(sync)
niklasad1 Mar 9, 2019
ba5b871
docs(add missing licens header)
niklasad1 Mar 9, 2019
479ddcd
fix(log): info! -> trace!
niklasad1 Mar 9, 2019
705fe3f
docs(fix nits) + fix(remove assert)
niklasad1 Mar 9, 2019
1e5dbbe
perf(use counter instead of vec)
niklasad1 Mar 9, 2019
6f7bffa
fix(remove needless block in match)
niklasad1 Mar 9, 2019
4ca34d8
fix(faulty comment)
niklasad1 Mar 9, 2019
1afbcab
grumbles(docs for tests)
niklasad1 Mar 9, 2019
e053dcb
fix(nits)
niklasad1 Mar 10, 2019
5e85edf
fix(revert_vote): only remove vote when votes == 0
niklasad1 Mar 10, 2019
b73f772
fix(vote counter): checked arithmetics
niklasad1 Mar 10, 2019
7e5cb80
fix(simplify tests)
niklasad1 Mar 10, 2019
06e1727
fix(nits)
niklasad1 Mar 11, 2019
0d0b901
Merge pull request #54 from niklasad1/goerli
soc1c Mar 12, 2019
df6fd20
fix(clique): err types
niklasad1 Mar 12, 2019
3a999a6
fix(clique utils): make use of errors
niklasad1 Mar 13, 2019
98218fe
fix(cleanup nits)
niklasad1 Mar 13, 2019
941d454
Merge pull request #59 from niklasad1/clique-errors
soc1c Mar 13, 2019
12ac5be
fix(clique sealing): don't read state no signer
niklasad1 Mar 13, 2019
5fa0228
Merge pull request #64 from niklasad1/revert-bad-change
jwasinger Mar 13, 2019
24f90ac
fix(replace Vec<Signers> with BTreeSet<Signers>)
niklasad1 Mar 13, 2019
2afa648
fix(tests): BTreeSet and more generic helpers
niklasad1 Mar 13, 2019
4bb1e45
fix(nits)
niklasad1 Mar 13, 2019
639c0d0
Merge pull request #61 from niklasad1/na-signers-btreeset
soc1c Mar 14, 2019
16d291c
Merge remote-tracking branch 'origin/master' into merge-parity
niklasad1 Mar 14, 2019
623d300
fix(ethcore_block_seal): remove needless `Box`
niklasad1 Mar 15, 2019
4b6680f
Merge pull request #68 from niklasad1/remove-needless-box
soc1c Mar 15, 2019
7968581
Merge pull request #66 from niklasad1/merge-parity
soc1c Mar 15, 2019
9cc75f8
Merge remote-tracking branch 'origin/master' into merge-parity-v2
niklasad1 Mar 20, 2019
748d65b
fix(faulty log): info -> trace
niklasad1 Mar 20, 2019
f4b613d
Merge pull request #69 from niklasad1/merge-parity-v2
soc1c Mar 20, 2019
ea5d77f
fix(checked SystemTime): prevent SystemTime panics
niklasad1 Mar 14, 2019
a126c53
style(chain cfg): space after `:`
niklasad1 Mar 21, 2019
ff196c3
style(fn enact): fix whitespace
niklasad1 Mar 21, 2019
302a4a6
docs(clique): StepService
niklasad1 Mar 21, 2019
ad395cd
docs(nit): fix faulty comment
niklasad1 Mar 21, 2019
242e886
docs(fix typo)
niklasad1 Mar 21, 2019
4ec9be7
style(fix bad indentation)
niklasad1 Mar 21, 2019
237c88a
Merge pull request #73 from niklasad1/fix-docs
soc1c Mar 21, 2019
9b742b3
Merge pull request #70 from niklasad1/faulty-log
soc1c Mar 21, 2019
25c2771
fix(bad regex match)
niklasad1 Mar 21, 2019
da06739
Merge pull request #72 from niklasad1/fix-style
soc1c Mar 21, 2019
8dad7b9
grumble(on_seal_block): make `&mut` to avoid clone
niklasad1 Mar 21, 2019
b27dabb
docs(on_seal_block): fix faulty documentation
niklasad1 Mar 22, 2019
ff71dd8
Merge pull request #65 from niklasad1/checked-systemtime
soc1c Mar 23, 2019
10755f9
Merge pull request #71 from niklasad1/block-needless-clone
soc1c Mar 23, 2019
a30b5d2
Delete .travis.yml
soc1c Mar 23, 2019
25352b1
docs: remove eth hf references in spec
soc1c Mar 23, 2019
0f81a29
Update client.rs
soc1c Mar 23, 2019
218aa55
Merge pull request #75 from paritytech/master
soc1c Mar 23, 2019
3ec8ab6
Merge pull request #77 from goerli/s1-docs-spec
soc1c Mar 23, 2019
f3e2fae
Merge pull request #78 from goerli/s1-logging-shutdown
soc1c Mar 23, 2019
455cd93
Merge pull request #76 from goerli/s1-ci-cleanup
soc1c Mar 23, 2019
0502915
fix(nits)
niklasad1 Mar 25, 2019
0b02823
Merge pull request #82 from niklasad1/na-cleanup
soc1c Mar 25, 2019
e39abfe
fix(clique step): `RwLock` -> `AtomicBool`
niklasad1 Mar 25, 2019
5dccb6b
Merge pull request #83 from niklasad1/StepService-AtomicBool
soc1c Mar 26, 2019
f384261
fix(clique): use `Duration::as_millis`
niklasad1 Mar 26, 2019
70c0617
Clean up some Clique documentation
HCastano Mar 26, 2019
7b5c361
Merge pull request #84 from niklasad1/na-fix-duration-asmillis
soc1c Mar 26, 2019
b2d1b3b
Merge pull request #85 from HCastano/hc-fix-clique-docs
soc1c Mar 26, 2019
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
937 changes: 937 additions & 0 deletions ethcore/res/ethereum/goerli.json

Large diffs are not rendered by default.

903 changes: 903 additions & 0 deletions ethcore/res/ethereum/rinkeby.json

Large diffs are not rendered by default.

88 changes: 32 additions & 56 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,7 @@ impl<'x> OpenBlock<'x> {
}

/// Get the environment info concerning this block.
pub fn env_info(&self) -> EnvInfo {
self.block.env_info()
}
pub fn env_info(&self) -> EnvInfo { self.block.env_info() }

/// Push a transaction into the block.
///
Expand Down Expand Up @@ -374,22 +372,6 @@ impl<'x> OpenBlock<'x> {
Ok(())
}

/// Populate self from a header.
soc1c marked this conversation as resolved.
Show resolved Hide resolved
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());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I removed this one because author is now initialized in the constructor of OpenBlock.

Because the actual author of Clique is recovered from signature of the header not the 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();
Expand Down Expand Up @@ -419,6 +401,10 @@ impl<'x> OpenBlock<'x> {
}));
s.block.header.set_gas_used(s.block.receipts.last().map_or_else(U256::zero, |r| r.gas_used));

if let Some(extra_data) = s.engine.close_block_extra_data(&s.block.header) {
s.block.header.set_extra_data(extra_data);
}

Ok(LockedBlock {
block: s.block,
})
Expand Down Expand Up @@ -496,6 +482,7 @@ impl LockedBlock {
Mismatch { expected: expected_seal_fields, found: seal.len() }));
}
s.block.header.set_seal(seal);

s.block.header.compute_hash();
Ok(SealedBlock {
block: s.block
Expand Down Expand Up @@ -563,39 +550,45 @@ fn enact(
is_epoch_begin: bool,
ancestry: &mut Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {
{
5chdn marked this conversation as resolved.
Show resolved Hide resolved
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(
engine,
factories,
tracing,
db,
parent,
last_hashes,
Address::new(),
(3141562.into(), 31415620.into()),
vec![],
engine.executive_author(&header), // Engine such as Clique will calculate author from extra_data. this is only important for executing contracts as the 'executive_author'
5chdn marked this conversation as resolved.
Show resolved Hide resolved
(*header.gas_limit(), *header.gas_limit()),
header.extra_data().clone(),
is_epoch_begin,
ancestry,
)?;

b.populate_from(&header);
// We must set timestamp here
b.block.header.set_timestamp(header.timestamp());
b.block.header.set_difficulty(*header.difficulty());
// {
// if ::log::max_level() >= ::log::Level::Trace {
// let env = b.env_info();
// 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",
// b.block.header.number(), s.root(), env.author, s.balance(&env.author)?);
// }
// }

niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
b.push_transactions(transactions)?;

// reset the author to what it was originally specified as now that transactions are applied
b.block.header.set_author(*header.author());

for u in 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
/// Enact the PreverifiedBlock given using `engine` on the database `db` with given `parent` block header
pub fn enact_verified(
block: PreverifiedBlock,
engine: &EthEngine,
Expand Down Expand Up @@ -659,36 +652,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(
5chdn marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -703,7 +679,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]
Expand Down
Loading