filecoin-project / filecoin-ffi

C and CGO bindings for Filecoin's Rust libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot pass unit test

hsienfu opened this issue · comments

$ cd /path/to/filecoin-ffi
$ go test

go: downloading github.com/filecoin-project/specs-actors v0.6.0
go: extracting github.com/filecoin-project/specs-actors v0.6.0
go: finding github.com/filecoin-project/specs-actors v0.6.0
[src/proofs/api.rs:1022] &s = "StackedDrg2KiBV1"
[src/proofs/api.rs:1022] &s = "StackedDrg8MiBV1"
[src/proofs/api.rs:1022] &s = "StackedDrg512MiBV1"
[src/proofs/api.rs:1022] &s = "StackedDrg32GiBV1"
[src/proofs/api.rs:1022] &s = "StackedDrg64GiBV1"
--- FAIL: TestProofsLifecycle (0.25s)
    proofs_test.go:126:
                Error Trace:    proofs_test.go:126
                                                        workflows.go:115
                                                        proofs_test.go:30
                Error:          Received unexpected error:
                                Cache is only available for 32GiB and 64GiB sectors
                                github.com/filecoin-project/filecoin-ffi.SealPreCommitPhase1
                                        /usr/local/services/lotus/extern/filecoin-ffi/proofs.go:291
                                github.com/filecoin-project/filecoin-ffi.WorkflowProofsLifecycle
                                        /usr/local/services/lotus/extern/filecoin-ffi/workflows.go:114
                                github.com/filecoin-project/filecoin-ffi.TestProofsLifecycle
                                        /usr/local/services/lotus/extern/filecoin-ffi/proofs_test.go:30
                                testing.tRunner
                                        /usr/local/services/go/src/testing/testing.go:909
                                runtime.goexit
                                        /usr/local/services/go/src/runtime/asm_amd64.s:1357
                Test:           TestProofsLifecycle
                Messages:       []
devices: [GeForce RTX 2080 SUPER]
FAIL
exit status 1
FAIL    github.com/filecoin-project/filecoin-ffi        38.334s
commented

@hsienfu Update to the latest version, and there is a script you can use to run the tests (run_tests.sh) after building (build.sh)

Yes, I run the run_tests.sh, but

2020-07-01T16:48:21.388 INFO filecoin_proofs::api::seal > seal_commit_phase1:start
2020-07-01T16:48:21.388 INFO filecoin_proofs::pieces > verifying 2 pieces
2020-07-01T16:48:21.393 INFO filecoin_proofs::api::seal > seal_commit_phase1:finish
2020-07-01T16:48:21.394 INFO filcrypto::proofs::api > seal_commit_phase1: finish
2020-07-01T16:48:21.394 INFO filcrypto::proofs::api > seal_commit_phase2: start
2020-07-01T16:48:21.394 INFO filecoin_proofs::api::seal > seal_commit_phase2:start
2020-07-01T16:48:21.394 INFO filecoin_proofs::caches > trying parameters memory cache for: STACKED[2048]
2020-07-01T16:48:21.394 INFO filecoin_proofs::caches > no params in memory cache for STACKED[2048]
2020-07-01T16:48:21.394 INFO storage_proofs_core::parameter_cache > parameter set identifier for cache: layered_drgporep::PublicParams{ graph: stacked_graph::StackedGraph{expansion_degree: 8 base_graph: drgraph::BucketGraph{size: 64; degree: 6; hasher: poseidon_hasher} }, challenges: LayerChallenges { layers: 2, max_count: 2 }, tree: merkletree-poseidon_hasher-8-0-0 }
2020-07-01T16:48:21.394 INFO storage_proofs_core::parameter_cache > ensuring that all ancestor directories for: "/var/tmp/filecoin-proof-parameters/v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params" exist
2020-07-01T16:48:21.394 INFO storage_proofs_core::parameter_cache > checking cache_path: "/var/tmp/filecoin-proof-parameters/v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params" for parameters
2020-07-01T16:48:21.394 INFO filcrypto::proofs::api > seal_commit_phase2: finish
--- FAIL: TestProofsLifecycle (3.73s)
    proofs_test.go:126: 
        	Error Trace:	proofs_test.go:126
        	            				workflows.go:127
        	            				proofs_test.go:30
        	Error:      	Received unexpected error:
        	            	No cached parameters found for stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f
        	            	github.com/filecoin-project/filecoin-ffi.SealCommitPhase2
        	            		/usr/local/services/filecoin-ffi/proofs.go:382
        	            	github.com/filecoin-project/filecoin-ffi.WorkflowProofsLifecycle
        	            		/usr/local/services/filecoin-ffi/workflows.go:126
        	            	github.com/filecoin-project/filecoin-ffi.TestProofsLifecycle
        	            		/usr/local/services/filecoin-ffi/proofs_test.go:30
        	            	testing.tRunner
        	            		/usr/local/services/go/src/testing/testing.go:991
        	            	runtime.goexit
        	            		/usr/local/services/go/src/runtime/asm_amd64.s:1373
        	Test:       	TestProofsLifecycle
        	Messages:   	[]
devices: [GeForce RTX 2080 SUPER]

commented

The above error means that you do not have the parameter files required for proper operation, or running the tests. Lotus will help you download them (just run lotus daemon), or you can try running paramfetch from the rust-fil-proofs repo.

I have run the lotus daemon with ENV IPFS_GATEWAY=https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/
There are files in /var/tmp/filecoin-proof-parameters

-rw-r--r-- 1        3076 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.vk
-rw-r--r-- 1        3076 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.vk
-rw-r--r-- 1       13636 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.vk
-rw-r--r-- 1       13636 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.vk
-rw-r--r-- 1        3076 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk
-rw-r--r-- 1       13636 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.vk
-rw-r--r-- 1 60780374232 Jun 26 11:43 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.params
-rw-r--r-- 1     2481508 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.vk
-rw-r--r-- 1   192050232 Jun 26 11:44 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.params
-rw-r--r-- 1       13636 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.vk
-rw-r--r-- 1     2429764 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-2627e4006b67f99cef990c0a47d5426cb7ab0a0ad58fc1061547bf2d28b09def.vk
-rw-r--r-- 1       13636 Jun 26 11:18 v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-b62098629d07946e9028127e70295ed996fe3ed25b0f9f88eb610a0ab4385a3c.vk
-rw-r--r-- 1        4708 Jun 26 11:18 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.vk
-rw-r--r-- 1        4708 Jun 26 11:18 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-6babf46ce344ae495d558e7770a585b2382d54f225af8ed0397b8be7c3fcd472.vk
-rw-r--r-- 1        4708 Jun 26 11:18 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-ecd683648512ab1765faa2a5f14bab48f676e633467f0aa8aad4b55dcb0652bb.vk
-rw-r--r-- 1 47373928632 Jun 26 11:59 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.params
-rw-r--r-- 1       32356 Jun 26 11:18 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.vk
-rw-r--r-- 1       32356 Jun 26 11:18 v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.vk

Not found the /var/tmp/filecoin-proof-parameters/v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params file

commented

The params that you are missing are for 2KiB sectors, which several tests require. You will need them to run the tests. You can either generate them (may or may not work, depending on which paramcache build you use), or you can download them, using paramfetch. For unit tests, you will also need the parameters for 4/16/32KiB.

EDIT: If you have a working IPFS gateway and can use ipfs from the command line, you can find the cid for the missing files in the parameters.json file and retrieve the ones you need.

How to find the paramfetch command?
I can't compile it from github.com/filecoin-project/go-paramfetch.
lotus has 'fetch-params' subcommand:

2020-07-02T20:21:57.382+0800	WARN	main	lotus/main.go:81	fetching proof parameters:
    github.com/filecoin-project/lotus/cli.glob..func32
        /usr/local/services/lotus/cli/params.go:28
  - the following errors occurred:
     -  checking file /var/tmp/filecoin-proof-parameters/v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.params failed:
            github.com/filecoin-project/go-paramfetch.(*fetch).maybeFetchAsync.func1
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:99
          - checksum mismatch in param file /var/tmp/filecoin-proof-parameters/v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.params, 17e6e8e55a859e4492c0a1919f9afd85 != 09bff16aed893349d94485cfae366a9c:
            github.com/filecoin-project/go-paramfetch.(*fetch).checkFile
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:132
     -  checking file /var/tmp/filecoin-proof-parameters/v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params failed:
            github.com/filecoin-project/go-paramfetch.(*fetch).maybeFetchAsync.func1
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:99
          - checksum mismatch in param file /var/tmp/filecoin-proof-parameters/v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params, 6fc7f08cd756113a79a55d94eb0cad4a != cfc7b0897d1eee48c586f7beb89e67f7:
            github.com/filecoin-project/go-paramfetch.(*fetch).checkFile
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:132
     -  checking file /var/tmp/filecoin-proof-parameters/v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params failed:
            github.com/filecoin-project/go-paramfetch.(*fetch).maybeFetchAsync.func1
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:99
          - checksum mismatch in param file /var/tmp/filecoin-proof-parameters/v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params, 15deb169596726ebff47c546d15d47c0 != f5827f2d8801c62c831e0f972f6dc8bb:
            github.com/filecoin-project/go-paramfetch.(*fetch).checkFile
                /root/go/pkg/mod/github.com/filecoin-project/go-paramfetch@v0.0.2-0.20200605171344-fcac609550ca/paramfetch.go:132
commented

I was referring to a paramfetch command in the rust-fil-proofs repo. But the fetch-params errors you're showing above mean that the parameters you have on disk appear to not be correct. You should remove them (or move them out of the way) and re-run that command to retrieve them properly.

commented

Alternatively, if you have rust installed, you can clone https://github.com/filecoin-project/rust-fil-proofs and then run cargo run --bin paramfetch.

I make it by cargo build then target/debug/paramfetch -a.

checking: v27-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.vk
does file exist... no

30 files to fetch...

fetching: v27-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params
downloading file...

It consume 1 hour and size of file is still zero.

commented

It consume 1 hour and size of file is still zero.

I didn't make any claims about download speeds :-)

Aternatively, you can try to generate your own test parameters:

cargo run --release --bin paramcache -- -z 2048
cargo run --release --bin paramcache -- -z 4096
cargo run --release --bin paramcache -- -z 16384
cargo run --release --bin paramcache -- -z 32768

I generate 2KiB parameters and then run ./run_test.sh
FAIL: TestProofsLifecycle (31.89s)

2020-07-02T23:37:30.103 INFO filcrypto::proofs::api > verify_seal: start
2020-07-02T23:37:30.103 INFO filecoin_proofs::api::seal > verify_seal:start
2020-07-02T23:37:30.103 INFO filecoin_proofs::caches > trying parameters memory cache for: STACKED[2048]-verifying-key
2020-07-02T23:37:30.103 INFO filecoin_proofs::caches > found params in memory cache for STACKED[2048]-verifying-key
2020-07-02T23:37:30.103 INFO filecoin_proofs::api::seal > got verifying key (2048) while verifying seal
2020-07-02T23:37:30.119 INFO filecoin_proofs::api::seal > verify_seal:finish
2020-07-02T23:37:30.119 INFO filcrypto::proofs::api > verify_seal: finish
--- FAIL: TestProofsLifecycle (31.89s)
    proofs_test.go:122: 
        	Error Trace:	proofs_test.go:122
        	            				workflows.go:144
        	            				proofs_test.go:30
        	Error:      	Should be true
        	Test:       	TestProofsLifecycle
        	Messages:   	[proof wasn't valid]
devices: [GeForce RTX 2080 SUPER]

EDIT: proof wasn't valid

EDIT: Hardware

CPU: AMD Ryzen Threadripper 3970X 32-Core Processor
MEM: 256G 2666MHZ
GPU: GeForce RTX 2080 SUPER
SWAP: 256G NVMe
OS: Ubuntu 18.04 server
Disk: 14TiB  logical volume
commented

If the proof isn't valid, the parameters are likely bad/incorrect. Re-run the paramfetch and it'll tell you if they're valid.

The parameters is generated by cargo run --release --bin paramcache -- -z 2048.
Is it generated error?

commented

It's generally not safe to generate your own parameters because code version differences may not agree with what's expected by other releases that depend on different specific versions. So if paramfetch tells you that what you generated does not match what's expected (i.e. the official params), they are not valid.

It works! Thank you!

running 7 tests
test util::api::tests::test_init_log_fd ... ignored
test bls::api::tests::private_key_with_seed ... ok
test proofs::api::tests::test_proof_types ... ok
test proofs::api::tests::test_write_with_and_without_alignment ... ok
test bls::api::tests::key_verification ... ok
test util::api::tests::test_get_gpu_devices ... ok
test proofs::api::tests::test_sealing ... ok

test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out