Skip to content

Move PRs from Foundry#1979

Merged
majecty merged 55 commits intoCodeChain-io:masterfrom
majecty:f/copy-from-foundry
Aug 19, 2020
Merged

Move PRs from Foundry#1979
majecty merged 55 commits intoCodeChain-io:masterfrom
majecty:f/copy-from-foundry

Conversation

@majecty
Copy link

@majecty majecty commented Jul 30, 2020

@dynaxis @sgkim126 @byeongjee @junbeomlee @MSNTCS Could you check the commits you made? I moved commits from Foundty to CodeChain. Please tell me if there are omitted commits that should be moved to CodeChain or if I moved commits that should not be moved.

I run tests on my local machine. There are some flaky tests. If I run the tests multiple times, they eventually succeed.

I've moved refactoring and bug fix PRs from Foundry to CodeChain

@majecty majecty force-pushed the f/copy-from-foundry branch from b51e019 to 00475f0 Compare August 5, 2020 06:55
@majecty majecty changed the title [WIP] Move PRs from Foundry Move PRs from Foundry Aug 5, 2020
@majecty majecty marked this pull request as ready for review August 5, 2020 10:00
@dynaxis
Copy link
Member

dynaxis commented Aug 5, 2020

My commit for upgrading vergen is good to move to CodeChain. And looks ok.

@junha1
Copy link
Contributor

junha1 commented Aug 6, 2020

I think this error in https://travis-ci.com/github/CodeChain-io/codechain/jobs/368532029 is not just timeout

3) sync 3 nodes
       Connected in a circle
         All diverged by two nodes in the opposite
           It should be synced when the first node becomes ahead:
      AssertionError: expected { Object (value) } to deeply equal { Object (value) }
      + expected - actual
       {
      -  "value": "0dd0d442ca395b545ca10db2514dd926204986ff2c25b9876d44ac8374fbd293"
      +  "value": "ba7d733b1207f702c84134022782c474b8ba9880ea358e462657a144a32bf073"
       }

MSNTCS
MSNTCS previously approved these changes Aug 6, 2020
Copy link
Contributor

@MSNTCS MSNTCS left a comment

Choose a reason for hiding this comment

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

My Commits on foundry for auto self nomination is good to be included in codechain. SGTM

@majecty
Copy link
Author

majecty commented Aug 6, 2020

@junha1
The failed test is testing sync. It looks like some blocks are not synced in time. I think it can be a timing issue and it succeeded in my local machine multiple times.

I'll try to make the test more consistent.

@junha1
Copy link
Contributor

junha1 commented Aug 6, 2020

Ok. I'm ok with my commit

junha1
junha1 previously approved these changes Aug 6, 2020
@majecty
Copy link
Author

majecty commented Aug 6, 2020

Fixed by this PR: #1982

I found divide by zero panic. I'm investigating the cause. I'm not sure the bug was cause by this PR.

stack backtrace:
   0:     0x55f432f4c2d3 - backtrace::backtrace::libunwind::trace::h231104a04b7a2956
                        at /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.7/src/backtrace/libunwind.rs:53
                         - backtrace::backtrace::trace::hcf799d709bfe775d
                        at /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.7/src/backtrace/mod.rs:42
   1:     0x55f432f3d743 - backtrace::capture::Backtrace::new_unresolved::hf674184481555072
                        at /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.7/src/capture.rs:88
   2:     0x55f432f3d69d - backtrace::capture::Backtrace::new::hc53b747fb37ff970
                        at /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.7/src/capture.rs:63
   3:     0x55f4316ae47d - panic_hook::panic_message::hcf20e5160dbfff82
                        at util/panic_hook/src/lib.rs:76
   4:     0x55f4316add0a - panic_hook::panic_hook::h12a32b36292f2d30
                        at util/panic_hook/src/lib.rs:45
   5:     0x55f4316af5d7 - core::ops::function::Fn::call::h3f865c0a3aed5556
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/ops/function.rs:69
   6:     0x55f4337156ef - std::panicking::rust_panic_with_hook::hbe174577402a475d
                        at src/libstd/panicking.rs:468
   7:     0x55f4337151bd - std::panicking::continue_panic_fmt::h4d855dad868accf3
                        at src/libstd/panicking.rs:373
   8:     0x55f4337150a5 - rust_begin_unwind
                        at src/libstd/panicking.rs:302
   9:     0x55f43373686d - core::panicking::panic_fmt::hdeb7979ab6591473
                        at src/libcore/panicking.rs:139
  10:     0x55f4337367b9 - core::panicking::panic::hb5daa85c7c72fc62
                        at src/libcore/panicking.rs:70
  11:     0x55f431fbb555 - num_rational::Ratio<T>::new::hce449f4d68463c80
                        at /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.2.1/src/lib.rs:75
  12:     0x55f431d2703b - codechain_core::consensus::tendermint::engine::give_additional_rewards::{{closure}}::he9c03dbfc6dcb88f
                        at core/src/consensus/tendermint/engine.rs:469
  13:     0x55f431dcd925 - core::iter::adapters::map_fold::{{closure}}::h71236903ffc62f82
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/iter/adapters/mod.rs:694
  14:     0x55f431a07591 - core::iter::traits::iterator::Iterator::fold::ok::{{closure}}::h9f938db10e5bb926
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/iter/traits/iterator.rs:1828
  15:     0x55f4319a63ed - core::iter::traits::iterator::Iterator::try_fold::h303f6dc3acb3ffbe
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/iter/traits/iterator.rs:1709
  16:     0x55f4319a55e4 - core::iter::traits::iterator::Iterator::fold::h25dddc385bd91e0c
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/iter/traits/iterator.rs:1831
  17:     0x55f431dd796a - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::hcce643894de4016a
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/iter/adapters/mod.rs:727
  18:     0x55f431d269ff - codechain_core::consensus::tendermint::engine::give_additional_rewards::he6f5989ed0d7c6c6
                        at core/src/consensus/tendermint/engine.rs:467
  19:     0x55f4319ae130 - codechain_core::consensus::tendermint::engine::calculate_pending_rewards_of_the_term::h3d9d18415328eb0d
                        at core/src/consensus/tendermint/engine.rs:421
  20:     0x55f431eec08c - codechain_core::consensus::tendermint::engine::<impl codechain_core::consensus::ConsensusEngine for codechain
_core::consensus::tendermint::Tendermint>::on_close_block::h28969988be56a055
                        at core/src/consensus/tendermint/engine.rs:203
  21:     0x55f431afab94 - codechain_core::block::OpenBlock::close_impl::hafb958d4d6a3ed0a
                        at core/src/block.rs:218
  22:     0x55f431afb5ba - codechain_core::block::OpenBlock::close::h3da16d92cde7aae9
                        at core/src/block.rs:245
  23:     0x55f431b9d865 - codechain_core::miner::miner::Miner::prepare_block::h6689ff7b84ea1ad7
                        at core/src/miner/miner.rs:707
  24:     0x55f431ba107c - <codechain_core::miner::miner::Miner as codechain_core::miner::MinerService>::update_sealing::hadc8e620c0b2c2
17
                        at core/src/miner/miner.rs:976
  25:     0x55f431d3a889 - codechain_core::client::client::Client::update_sealing::h44435d4f3fcc1518
                        at core/src/client/client.rs:206
  26:     0x55f431a3c8ee - <codechain_core::service::ClientIoHandler as codechain_io::IoHandler<codechain_core::service::ClientIoMessage
>>::message::hb022c01be00d98b9
                        at core/src/service.rs:105
  27:     0x55f431a4c950 - codechain_io::worker::Worker::do_work::ha782f9c7fad94b36
                        at /mnt/sonnyexternal/juhyung/code/kodebox/codechain/util/io/src/worker.rs:141
  28:     0x55f431a4d31b - codechain_io::worker::Worker::work_loop::h9b6527d5d66fce9b
                        at /mnt/sonnyexternal/juhyung/code/kodebox/codechain/util/io/src/worker.rs:109
  29:     0x55f431a4b7b2 - codechain_io::worker::Worker::new::{{closure}}::h0dce92fd14971a42
                        at /mnt/sonnyexternal/juhyung/code/kodebox/codechain/util/io/src/worker.rs:83
  30:     0x55f431f28840 - std::sys_common::backtrace::__rust_begin_short_backtrace::h95eeccc291e8f144
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/sys_common/backtrace.rs:129
  31:     0x55f431ecb8e2 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hd70f9416e6cfd93f
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/thread/mod.rs:469
  32:     0x55f431ef5672 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hdf2eb0202bc07839
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/panic.rs:317
  33:     0x55f431f2de4d - std::panicking::try::do_call::hbca511378a28d0d4
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/panicking.rs:287
  34:     0x55f43371e439 - __rust_maybe_catch_panic
                        at src/libpanic_unwind/lib.rs:78
  35:     0x55f431f2d047 - std::panicking::try::h47aa68b0ace5918c
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/panicking.rs:265
  36:     0x55f431ef58a2 - std::panic::catch_unwind::hfcc45c8a7aa795de
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/panic.rs:396
  37:     0x55f431ecab8d - std::thread::Builder::spawn_unchecked::{{closure}}::hb64e46c01fe1a787
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/thread/mod.rs:468
  38:     0x55f431e5ffa3 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h5e9a0bfb62da7117
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libcore/ops/function.rs:227
  39:     0x55f43370355e - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h3534c64212330b0c
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/liballoc/boxed.rs:942
  40:     0x55f43371d4ff - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h338c10574a337ece
                        at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/liballoc/boxed.rs:942
                         - std::sys_common::thread::start_thread::h761ac6d57710d65d
                        at src/libstd/sys_common/thread.rs:13
                         - std::sys::unix::thread::Thread::new::thread_start::h61c012ef60f933c0
                        at src/libstd/sys/unix/thread.rs:79
  41:     0x7f08d34dd608 - start_thread
  42:     0x7f08d33e7102 - __clone
  43:                0x0 - <unknown>

Thread 'Client Worker #2' panicked at 'denominator == 0', /home/juhyung/.cargo/registry/src/github.com-1ecc6299db9ec823/num-rational-0.2
.1/src/lib.rs:75

This is a bug. Please report it at:

https://github.com/CodeChain-io/codechain/blob/master/core/src/consensus/tendermint/engine.rs#L474

Copy link
Contributor

@sgkim126 sgkim126 left a comment

Choose a reason for hiding this comment

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

codechain-stratum also uses parking_lot. You should upgrade it too. Others look good to me.

@majecty majecty force-pushed the f/copy-from-foundry branch 2 times, most recently from dc5aad1 to 43bb362 Compare August 18, 2020 02:30
@majecty
Copy link
Author

majecty commented Aug 18, 2020

@sgkim126 I updated stratum! Thanks.

@majecty
Copy link
Author

majecty commented Aug 18, 2020

@byeongjee Could you check this PR?
Please check your commits.

byeongjee
byeongjee previously approved these changes Aug 18, 2020
junha1
junha1 previously approved these changes Aug 19, 2020
MSNTCS
MSNTCS previously approved these changes Aug 19, 2020
Currently, we have a tool written in TypeScript to run auto-self-nominate. In
this new patch, codechain is able to run auto-self-nominate in a different
thread. In order to test the functionality of auto-self-nominate, a new
`selfnomination` test is added in `e2e.dynval/2/selfnomination.test.ts`.
Seulgi Kim and others added 24 commits August 19, 2020 11:36
The purpose of the encoded type is to read a few fields from binary
data when we don't want to full deserialize it. In the header sync, we
already deserialized the whole struct in the verification process. We
don't need to encoded Header when we have ctypes::Header.
We gain nothing from initializing extra data of genesis header with
hash of common params, because the check will be done by the same node,
and it will always succeed.
We can just use extra_data written in scheme file.
CodeChain was using only the VerifierType::Canon.
CodeChain is using only CanonVerifier. We are not using the `Verifier` abstraction.
Client::import_header function receives a header that is not
verified. Importer::import_headers assumes that received headers are
verified. To reduce misunderstanding, I renamed the function.
The name `import_sealed_block` does not give enough context.
Currently, AccountProvider in the miner is optional to support unit
tests who cannot use the account provider which uses the permanent
storage.
This commit makes the miner uses memory back-end AccountProvider for
test.
I changed the test code only. The tests were deprecated. I updated RLP
encoded data from CodeChain code and it worked.
The seal is an array of any RLP data. Wrapping them with Buffer makes
invalid RLP encoding.
Since Header has a cache of its hash using RefCell, the existence of
the cache changes the compare result.
This will make CodeChain in tests not to increase view to high.

Before this commit, some tests (for example dv.nomination.test.ts)
sometimes creates a block with a very high view like 9. It was because
blocks were created so fast and the timestamp of a block is too future
for CodeChain.
Currently, the client access the miner through the importer. It's better
to give a method to access the miner directly.
@majecty majecty dismissed stale reviews from MSNTCS, junha1, and byeongjee via 62cded4 August 19, 2020 02:37
@majecty majecty force-pushed the f/copy-from-foundry branch from 43bb362 to 62cded4 Compare August 19, 2020 02:37
@majecty majecty merged commit 9141174 into CodeChain-io:master Aug 19, 2020
@majecty majecty deleted the f/copy-from-foundry branch August 19, 2020 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants