Skip to content
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

Compilation error while running near-client test on nightly #4351

Closed
Longarithm opened this issue Jun 4, 2021 · 5 comments
Closed

Compilation error while running near-client test on nightly #4351

Longarithm opened this issue Jun 4, 2021 · 5 comments

Comments

@Longarithm
Copy link
Member

The following command fails on master since #4292:

% cargo test -p near-client cap_max_gas_price_tests --features nightly_protocol,nightly_protocol_features

   Compiling near-epoch-manager v0.0.1 (/Users/Shared/OldLaptop/Programming/nearcore/chain/epoch_manager)
   Compiling near-chunks v0.1.0 (/Users/Shared/OldLaptop/Programming/nearcore/chain/chunks)
error[E0574]: expected struct, variant or union type, found enum `BlockInfo`
   --> chain/epoch_manager/src/test_utils.rs:315:5
    |
315 |     BlockInfo {
    |     ^^^^^^^^^ not a struct, variant or union type

error: aborting due to previous error

Also, if we set exact protocol feature, the test is compiled but not passed:

% cargo test -p near-client cap_max_gas_price_tests --features nightly_protocol,protocol_feature_cap_max_gas_price
...
test cap_max_gas_price_tests::test_capped_gas_price ... FAILED

failures:

---- cap_max_gas_price_tests::test_capped_gas_price stdout ----
thread 'cap_max_gas_price_tests::test_capped_gas_price' panicked at 'assertion failed: !does_gas_price_exceed_limit(ProtocolFeature::CapMaxGasPrice.protocol_version())', chain/client/tests/process_blocks.rs:3188:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

cc: @bowenwang1996

@bowenwang1996
Copy link
Collaborator

bowenwang1996 commented Jun 4, 2021

Made it work with the following hack:

diff --git a/chain/client/Cargo.toml b/chain/client/Cargo.toml
index 8ba87da56..5ab171a0c 100644
--- a/chain/client/Cargo.toml
+++ b/chain/client/Cargo.toml
@@ -55,10 +55,10 @@ expensive_tests = []
 adversarial = ["near-network/adversarial", "near-chain/adversarial"]
 metric_recorder = ["near-client-primitives/metric_recorder"]
 delay_detector = ["near-chain/delay_detector", "near-network/delay_detector", "delay-detector"]
-protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "near-store/protocol_feature_block_header_v3"]
+protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "near-store/protocol_feature_block_header_v3", "nearcore/protocol_feature_block_header_v3"]
 protocol_feature_add_account_versions = ["near-primitives/protocol_feature_add_account_versions"]
 protocol_feature_fix_storage_usage = ["near-primitives/protocol_feature_fix_storage_usage"]
 protocol_feature_restore_receipts_after_fix = []
 protocol_feature_cap_max_gas_price = ["near-primitives/protocol_feature_cap_max_gas_price"]
 nightly_protocol = []
-nightly_protocol_features = ["nightly_protocol", "near-chain/nightly_protocol_features", "protocol_feature_block_header_v3", "protocol_feature_add_account_versions", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price"]
+nightly_protocol_features = ["nightly_protocol", "near-chain/nightly_protocol_features", "protocol_feature_block_header_v3", "protocol_feature_add_account_versions", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price", "nearcore/protocol_feature_fix_storage_usage", "nearcore/protocol_feature_restore_receipts_after_fix"]

The reason why it does not work is that nearcore is a dev dependency of near-client. When we compile with nightly_protocol_features, we enable protocol_version_block_header_v3 in core/primitives, which means that test_utils in near-epoch-manager actually imports

pub enum BlockInfo {
instead of
pub type BlockInfo = super::BlockInfoV1;
However, we did not enable protocol_feature_block_header_v3 in nearcore, which means that block_info in test_utils is which expects BlockInfo as a struct instead of an enum and that leads to the compilation error.

@matklad do you see a better way to fix this?

@matklad
Copy link
Contributor

matklad commented Jun 9, 2021

The cargo.toml patch by @bowenwang1996 I think is a good solution.

The root cause here is the combination of features, and the fact that we have circular dependencies. nearcore depends on near-client, but near-client depends on nearcore for testing. I feel that such cycles create a fair bit of complexity. Let me create a dedicated issue to tackle that!

EDIT: #4357

@bowenwang1996
Copy link
Collaborator

@Longarithm does my patch work for you?

@Longarithm
Copy link
Member Author

@bowenwang1996
Yes, thank you!
I currently use it here https://github.com/near/nearcore/pull/4344/files to run
cargo test -p near-client test_precompile_on_apply_state_part --features nightly_protocol,nightly_protocol_features -- --nocapture

@bowenwang1996
Copy link
Collaborator

Okay then let's close this issue in favor of #4357

near-bulldozer bot pushed a commit that referenced this issue Jun 15, 2021
Restore #4360. Previous version was reverted: #4363

The difference is that I don't add features needed for testing `near-client` described here: #4351 (comment)
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

No branches or pull requests

3 participants