Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

[WIP] Failing EVM state test #20

Closed
wants to merge 2 commits into from
Closed

[WIP] Failing EVM state test #20

wants to merge 2 commits into from

Conversation

prestwich
Copy link
Contributor

@prestwich prestwich commented Jun 5, 2020

Writing tests trying to track down the state erasure issues documented here. Encountering a bad state while running lib tests on the contract.

A near identical test (without the near mocked env) is in src/evm_state.rs. It passes, which implies that introducing the bindgen and the mocked env causes some issue.

If I had to guess at a culprit it would be these lines

Failure occurs at L199 of src/tests/mod.rs. @bowenwang1996 can you take a look at this?

thread 'tests::state_management' panicked at 'called `Result::unwrap()` on an `Err` value: HostError(GuestPanic { panic_msg: "The collection is an inconsistent state. Did previous smart contract execution terminate unexpectedly?" })', /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/environment/mocked_blockchain.rs:161:9


   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  11: rust_begin_unwind
             at src/libstd/panicking.rs:385
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:89
  13: core::option::expect_none_failed
             at src/libcore/option.rs:1272
  14: core::result::Result<T,E>::unwrap
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libcore/result.rs:1005
  15: <near_sdk::environment::mocked_blockchain::MockedBlockchain as near_sdk::environment::blockchain_interface::BlockchainInterface>::panic_utf8
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/environment/mocked_blockchain.rs:161
  16: near_sdk::environment::env::panic::{{closure}}
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/environment/env.rs:612
  17: std::thread::local::LocalKey<T>::try_with
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/thread/local.rs:263
  18: std::thread::local::LocalKey<T>::with
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/thread/local.rs:239
  19: near_sdk::environment::env::panic
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/environment/env.rs:611
  20: near_sdk::collections::map::Map<K,V>::get_raw::{{closure}}
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/collections/map.rs:87
  21: core::option::Option<T>::map
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libcore/option.rs:458
  22: near_sdk::collections::map::Map<K,V>::get_raw
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/collections/map.rs:85
  23: near_sdk::collections::map::Map<K,V>::get
             at /home/james/.cargo/registry/src/github.com-1ecc6299db9ec823/near-sdk-0.9.2/src/collections/map.rs:177
  24: <near_evm::EvmContract as near_evm::evm_state::EvmState>::read_contract_storage
             at src/lib.rs:75
  25: near_evm::tests::state_management::{{closure}}
             at src/tests/mod.rs:199
  26: near_evm::tests::test_utils::run_test
             at src/tests/test_utils.rs:36
  27: near_evm::tests::state_management
             at src/tests/mod.rs:168
  28: near_evm::tests::state_management::{{closure}}
             at src/tests/mod.rs:167
  29: core::ops::function::FnOnce::call_once
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libcore/ops/function.rs:232
  30: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/liballoc/boxed.rs:1034
  31: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panic.rs:318
  32: std::panicking::try::do_call
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panicking.rs:297
  33: std::panicking::try
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panicking.rs:274
  34: std::panic::catch_unwind
             at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panic.rs:394
  35: test::run_test_in_process
             at src/libtest/lib.rs:541
  36: test::run_test::run_test_inner::{{closure}}
             at src/libtest/lib.rs:450
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test tests::state_management ... FAILED

@prestwich prestwich changed the base branch from master to travis_ci June 5, 2020 21:50
@prestwich prestwich changed the title Failing EVM state test [WIP] Failing EVM state test Jun 5, 2020
@ewilz ewilz force-pushed the travis_ci branch 2 times, most recently from 2bc0072 to a4537bb Compare June 6, 2020 15:40
@prestwich
Copy link
Contributor Author

Okay. I've isolated the specific failing pieces. This line appears on L199, L224, L229, and L254. It is the only part of the test that fails

assert_eq!(contract.read_contract_storage(&addr_0, storage_key_0), Some(storage_value_0));

@lexfrl lexfrl self-assigned this Jun 8, 2020
@prestwich
Copy link
Contributor Author

quick update @fckt I'm going to be rewriting the state management to something simpler, and I'm hopeful it'll solve this issue

@ilblackdragon
Copy link
Member

I think the reason is _contract_storage method creating new hashmaps mulitple times with the same prefix and then storing data in them separately - I filled it as an issue here near/near-sdk-rs#182

@prestwich
Copy link
Contributor Author

superseded by #21

@prestwich prestwich closed this Jun 9, 2020
@prestwich prestwich deleted the evm-state-test branch June 19, 2020 20:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants