Compare commits

..
2082 Commits
Author SHA1 Message Date
Travis Person 613226dec5 New interop network info 2020-06-05 23:59:22 +00:00
Whyrusleeping 366359803a Merge pull request #1903 from filecoin-project/feat/reuse-get-tipset-by-height
reuse GetTipsetByHeight in GetRandomness
2020-06-05 16:06:28 -07:00
Łukasz Magiera 3b13397165 gofmt 2020-06-06 00:59:01 +02:00
Łukasz Magiera 163c2b2544 Merge remote-tracking branch 'origin/master' into next 2020-06-06 00:58:24 +02:00
Łukasz Magiera 9e2603c1bf Merge pull request #1937 from laser/bugs/916-standardize-cid-base32
print "client"-command CIDs as base32-encoded strs
2020-06-06 00:53:07 +02:00
Łukasz Magiera d27750590a Merge pull request #1928 from filecoin-project/fix/lsm-prov-deadlines
Make lotus-storage-miner deadlines correct
2020-06-06 00:37:09 +02:00
Łukasz Magiera 33a00ab9e5 Merge pull request #1938 from filecoin-project/deps/spect-actors-upd
Update specs-actors
2020-06-06 00:31:09 +02:00
Łukasz Magiera f765fe36d7 Make lotus-storage-miner deadlines correct 2020-06-06 00:28:32 +02:00
Whyrusleeping be7a95c9a5 Merge pull request #1915 from filecoin-project/feat/chain-index
implement chain index to make lookbacks faster
2020-06-05 15:13:47 -07:00
Aayush Rajasekaran 2571480bb6 Update chain-val, use tagged specs-actors 2020-06-05 18:13:30 -04:00
Jeromy 73d928751d disallow sourcing randomness from future epochs 2020-06-05 15:12:13 -07:00
Whyrusleeping 0c19544d94 Merge pull request #1941 from filecoin-project/deps/update-hamt
update to new hamt code with improved perf
2020-06-05 14:54:21 -07:00
laser a80dce2e3b move to client command 2020-06-05 14:22:29 -07:00
Jeromy fb09d1ad2b update to new hamt code with improved perf 2020-06-05 14:13:08 -07:00
laser 963e4dd2fc set a Base32 default explicitly 2020-06-05 13:52:36 -07:00
Łukasz Magiera a5d81c6cc9 Merge pull request #1932 from filecoin-project/feat/chainget-state
chain get: @state selector to prettify actor state
2020-06-05 22:42:36 +02:00
laser b167e73acb allow CLI consumer to specify CID encoding for output 2020-06-05 13:33:45 -07:00
Łukasz Magiera e7af464033 Merge pull request #1931 from filecoin-project/feat/compute-state-sub-links
compute-state html: Allow linking to internal executions
2020-06-05 22:29:23 +02:00
laser 28e454fd4a go mod tidy 2020-06-05 13:13:53 -07:00
laser 55a9c9ae0a client deal command outputs Base32-encoded CID 2020-06-05 13:13:33 -07:00
laser b3eef76cdd client commP outputs Base32-encoded string 2020-06-05 13:13:16 -07:00
Łukasz Magiera 3f81ff3507 Update specs-actors 2020-06-05 22:06:11 +02:00
laser 2347ba6f39 print "client"-command CIDs as base32-encoded strs
Fixes #916
2020-06-05 13:04:28 -07:00
Łukasz Magiera b9d3c26eae Merge pull request #1924 from filecoin-project/fix/sealing-betterering
Sealing Improvements
2020-06-05 21:58:31 +02:00
Łukasz Magiera cd6670205c Update sector-storage 2020-06-05 21:31:57 +02:00
Whyrusleeping 9f4ac4f4f3 Merge pull request #1934 from filecoin-project/bugs/return-on-error-#1611
fix unhandled nil return
2020-06-05 12:26:27 -07:00
shannonwells e4bed4d963 return on all err conditions 2020-06-05 11:20:07 -07:00
shannonwells 76b5c8b145 fix unhandled nil return 2020-06-05 11:20:07 -07:00
Łukasz Magiera 9836c45e03 Merge pull request #1935 from filecoin-project/feat/cap-batch-verify-threads
add a simple semaphore to batch verify seals
2020-06-05 20:19:45 +02:00
Jeromy 51f1712564 add a simple semaphore to batch verify seals 2020-06-05 10:47:49 -07:00
Łukasz Magiera e9eff8be5c Merge pull request #1933 from laser/bugs/1209-paramfetch-sigterm
pass context to paramfetch.GetParams
2020-06-05 19:46:23 +02:00
laser 4855045ea2 pass context to paramfetch.GetParams
Fixes #1209
2020-06-05 10:28:00 -07:00
Łukasz Magiera 6b06ae528c chain get: @state selector to prettify actor state 2020-06-05 17:41:21 +02:00
Łukasz Magiera 813961b458 compute-state html: Allow linking to internal executions 2020-06-05 14:57:37 +02:00
Łukasz Magiera 7ae9d26cd1 Merge remote-tracking branch 'origin/next' into fix/sealing-betterering 2020-06-05 14:00:47 +02:00
Łukasz Magiera 9e5cc7c910 Update fsm, sector-storage 2020-06-05 10:46:45 +02:00
Łukasz Magiera 7d166fd730 Merge pull request #1908 from filecoin-project/docs/cpu-choice
add a doc on amd vs intel cpus
2020-06-05 01:21:50 +02:00
Łukasz Magiera 60101fd97b Merge pull request #1926 from filecoin-project/chore/merge-master
Merge in master into next
2020-06-05 01:13:12 +02:00
Jakub Sztandera 0bc174697a Fix WindowPoStScheduler
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-05 00:52:45 +02:00
Jakub Sztandera 7bee5b3abc Merge remote-tracking branch 'origin/master' into next
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-05 00:33:43 +02:00
Aayush Rajasekaran 656b285195 Bugfix: Begin walkback when lookback target's height is too low 2020-06-04 18:17:54 -04:00
whyrusleeping 86083531c6 a couple bugfixes 2020-06-04 18:17:54 -04:00
Jeromy c01f70105f implement chain index to make lookbacks faster 2020-06-04 18:17:54 -04:00
Łukasz Magiera 5aafa91e22 Merge pull request #1898 from filecoin-project/deps/update
Update CLI lib
2020-06-04 23:45:39 +02:00
Łukasz Magiera bada564c10 Merge pull request #1912 from filecoin-project/asr/statesearch
search for a message should stop if we reach sender nonce of 0
2020-06-04 23:42:16 +02:00
Łukasz Magiera f9f0d86ddf Merge pull request #1913 from acruikshank/feat/1853-confirmations-in-StateWaitMsg2
Add confidence and timeout to message wait
2020-06-04 23:23:15 +02:00
vyzo 6beabb5e8a Merge pull request #1914 from filecoin-project/feat/update-pubsub
update libp2p dependencies
2020-06-04 22:50:48 +03:00
vyzo 3719938849 gomod: update go-maddr-filter 2020-06-04 22:35:33 +03:00
vyzo 6420990007 gomod: update go-libp2p-quic-transport 2020-06-04 22:34:07 +03:00
vyzo 1fab24b9bc gomod: update go-libp2p-kad-dht 2020-06-04 22:32:11 +03:00
Łukasz Magiera 8bbe63bd9d Add expected win rate to miner-info 2020-06-04 21:26:29 +02:00
Łukasz Magiera fa3b1552cf Update sector-storage intefraces 2020-06-04 21:26:29 +02:00
Łukasz Magiera c625b30781 Update fsm adapter 2020-06-04 21:26:29 +02:00
vyzo b339750757 gomod: update go-libp2p-yamux 2020-06-04 21:34:01 +03:00
acruikshank da960a9de4 more import rearrangement 2020-06-04 09:54:37 -04:00
vyzo 954a20ff4c gomod: update go-libp2p to v0.9.4 2020-06-04 14:25:17 +03:00
vyzo 8057b994cf go.mod: remove unecessary (and harmful) replace directive for go-systemd 2020-06-04 14:23:59 +03:00
acruikshank ea111b058e imports 2020-06-03 22:34:57 -04:00
acruikshank ce33074626 go fmt 2020-06-03 22:30:09 -04:00
acruikshank 5f95a92135 fix race (sort of) by increasing confidence 2020-06-03 22:18:38 -04:00
Jeromy cd817906b2 handle sourcing randomness from a future block 2020-06-03 18:30:43 -07:00
Jakub Sztandera 29dbc26dbd Update cli
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-04 01:01:41 +02:00
acruikshank 04f0130530 remove timeout 2020-06-03 17:42:06 -04:00
vyzo f210a6e91a pubsub: set Dout parameter to 3 (from the default of 2)
we are using a higher D value than the default, so this can be safely increased.
2020-06-04 00:03:31 +03:00
vyzo aded0706be gomod: update go-libp2p@v0.9.3 and go-libp2p-pubsub@v0.3.2 2020-06-04 00:02:54 +03:00
acruikshank 57567db017 tidy 2020-06-03 15:51:11 -04:00
acruikshank 5574e4f11b add confidence and timeout to message wait 2020-06-03 15:38:37 -04:00
Aayush Rajasekaran 4b01b666f6 Bugfix: searchback for a message should stop if we reach sender nonce of 0 2020-06-03 14:08:05 -04:00
Łukasz Magiera 35740895ed Merge pull request #1899 from filecoin-project/feat/1827-lotus-daemon-stop-cmd
add (sub)commands which shut down lotus daemon and storage miner
2020-06-03 19:15:20 +02:00
Jakub Sztandera 4c5d84d106 Merge pull request #1904 from filecoin-project/feat/peer-scores
Add `lotus net scores` for pubsub score visibility
2020-06-03 18:04:16 +02:00
Jeromy a8915f0331 add a doc on amd vs intel cpus 2020-06-03 08:45:53 -07:00
Jakub Sztandera 7f962e19c2 Fix lint
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-03 03:19:18 +02:00
Jakub Sztandera 186fd4da74 Add lotus net scores for pubsub score visibility
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-03 03:13:49 +02:00
Jeromy 2fdcf5347b reuse GetTipsetByHeight in GetRandomness 2020-06-02 17:35:23 -07:00
Jakub Sztandera 4a983995a8 Merge pull request #1901 from acruikshank/bugs/1893-chain-import-home-directory
Expand tilde before passing file name into chain import
2020-06-02 23:53:04 +02:00
Jakub Sztandera 263bdc9687 Merge pull request #1902 from filecoin-project/chore/merge-master
Merge in master into next
2020-06-02 23:23:41 +02:00
Jakub Sztandera 42c76aaebc Remove mod-download
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 23:11:17 +02:00
Jakub Sztandera 9326cb5411 Update golangci-lint, increase its timeout
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 23:07:48 +02:00
Jakub Sztandera 415b69155b Disable caches
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 23:02:37 +02:00
Jakub Sztandera 3423d29815 Prune go mod cache
Circle reports 1.9GB, should be closer to 300MB

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 22:54:29 +02:00
Jakub Sztandera 673a972fe9 Merge remote-tracking branch 'origin/master' into next
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 22:49:27 +02:00
acruikshank 1fd20b636b tidy 2020-06-02 16:48:50 -04:00
acruikshank d7a2556292 expand tilda before passing file name into chain import 2020-06-02 16:43:39 -04:00
Łukasz Magiera 8aa158d4e6 Merge pull request #1900 from filecoin-project/feat/subcall-timing-compute-state
add subcall timing to compute state output
2020-06-02 22:23:25 +02:00
Łukasz Magiera 3595b1f8e9 compute-state html: Add timing for internal executions 2020-06-02 22:06:03 +02:00
Jeromy 9b867a221a add subcall timing to compute state output 2020-06-02 12:53:24 -07:00
laser 46a016cdce name change, for consistency 2020-06-02 12:38:21 -07:00
laser bea9cd2fe2 rename to better convey intent + document 2020-06-02 12:35:11 -07:00
laser ee9d9a52a9 first take at a "lotus-storage-miner stop" command
Fixes #1827
2020-06-02 12:31:21 -07:00
laser 1e8a875edb shutdownChan instead of shutdownCh, for consistency 2020-06-02 12:31:01 -07:00
laser 36a93c90eb use a real ellipsis, kinda 2020-06-02 12:30:45 -07:00
laser 38d714a28a first take at "daemon stop" command
Fixes #1827

TODO: plumb the daemon-stopping into lotus-storage-miner, too
2020-06-02 12:29:58 -07:00
Whyrusleeping bbb954afc5 Merge pull request #1896 from filecoin-project/chore/lint-2
Fix even more lint warnings
2020-06-02 11:40:57 -07:00
Whyrusleeping de5d16eeac Merge pull request #1897 from filecoin-project/deps/update-json-rpc
update to fixed jsonrpc library
2020-06-02 11:36:31 -07:00
Jeromy 1968195da9 update to fixed jsonrpc library 2020-06-02 11:21:54 -07:00
Jakub Sztandera 22851df145 Undo change in events_test
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 18:46:43 +02:00
Jakub Sztandera 96ade5f2dd Cleanup more lint warnings
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 18:38:41 +02:00
laser 5e727819ad stub the "daemon stop" command 2020-06-02 08:09:18 -07:00
Jakub Sztandera 5605aae269 Fix even more lint warnings
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-02 16:29:39 +02:00
Łukasz Magiera c6b6c2990c Merge pull request #1888 from filecoin-project/feat/build-typ-version
Include build type in version
2020-06-01 21:18:30 +02:00
Łukasz Magiera a49dc90386 Fix version test 2020-06-01 21:11:37 +02:00
Łukasz Magiera 64f4e80446 Include build type in version 2020-06-01 20:49:39 +02:00
Łukasz Magiera e67253b6a8 Merge pull request #1887 from filecoin-project/feat/improve-datastore
fsrepo: Use LevelDB for metadata datastore
2020-06-01 20:21:15 +02:00
Łukasz Magiera c73326e96d fsrepo: Use LevelDB for metadata datastore 2020-06-01 20:13:07 +02:00
Łukasz Magiera 7003960fdd Merge remote-tracking branch 'origin/master' into next 2020-06-01 18:52:06 +02:00
Łukasz Magiera 0acc2a2a63 Merge pull request #1880 from filecoin-project/asr/minerfaults
Add an API method to list all faults occuring in a certain range
2020-06-01 18:47:09 +02:00
Łukasz Magiera 596f78f9e6 Merge pull request #1885 from filecoin-project/bugs/sector-size-usage-in-scripts
update scripts and docs to use human-readable sector size
2020-06-01 18:45:20 +02:00
Łukasz Magiera 17f1eec81f Merge pull request #1886 from filecoin-project/feat/1829-repo-already-locked
error message to tell user why repo is already locked
2020-06-01 18:43:05 +02:00
Łukasz Magiera f0d44ea396 Merge pull request #1884 from filecoin-project/feat/fountain-maddr-link
fountain/miner: Add a link to docs about creating owner address
2020-06-01 18:41:57 +02:00
Łukasz Magiera ad4712b593 Merge pull request #1873 from filecoin-project/feat/better-post-faults
wdpost: Better fault handling
2020-06-01 18:39:00 +02:00
laser 92b8d9ad17 tell user why repo is already locked
Fixes #1829
2020-06-01 09:37:10 -07:00
laser 12ff9fd76b update scripts and docs to use human-readable sector size
Commit #fa863595 modified various CLI commands to accept a 
human-readable sector size. We should update docs and scripts, too.
2020-06-01 09:20:44 -07:00
Łukasz Magiera e26cf4e003 fountain/miner: Add a link to docs about creating owner address 2020-06-01 17:49:15 +02:00
Łukasz Magiera b753cd4503 Run window post test on circle 2020-06-01 15:06:10 +02:00
Łukasz Magiera ee29a92021 Add a test for Window Post 2020-06-01 14:49:48 +02:00
Łukasz Magiera c3916e3a7f Merge pull request #1875 from filecoin-project/feat/check-verifreg-cmds
add commands to check individual balances for verifiers and clients
2020-06-01 13:00:08 +02:00
Aayush Rajasekaran ec0baefc48 Add an API method to list all faults occuring in a certain range 2020-05-31 00:57:52 -04:00
Jeromy 2a3d79f055 add commands to check individual balances for verifiers and clients 2020-05-29 14:47:17 -07:00
Whyrusleeping 1c01799a4b Merge pull request #1855 from filecoin-project/feat/systemd-usage
Add systemd documention to table of contents
2020-05-29 14:07:09 -07:00
WhyrusleepingandJakub Sztandera 4ef330ba8b Update scripts/lotus-daemon.service
Co-authored-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-29 14:02:07 -07:00
Łukasz Magiera cd2bf04a6b wdpost: Better fault handling 2020-05-29 21:36:11 +02:00
Łukasz Magiera f7a71f4be7 Merge pull request #1837 from filecoin-project/feat/secstor-unseal
Update sector-storage with ReadPiece impl
2020-05-29 20:36:40 +02:00
Łukasz Magiera e5c24ff32b Update sector-storage with ReadPiece impl 2020-05-29 19:53:35 +02:00
Whyrusleeping f87054bde4 Merge pull request #1858 from hayeah/fix-miner-stale-tipset
Fix block production timing to avoid mining old tipset
2020-05-29 10:41:25 -07:00
Łukasz Magiera e954cc0d67 Merge pull request #1872 from filecoin-project/asr/docs
Fix broken link
2020-05-29 18:44:00 +02:00
Aayush Rajasekaran 43c887f2b6 Fix broken link 2020-05-29 12:35:21 -04:00
Aayush Rajasekaran 1cf9b9a67f Merge pull request #1861 from filecoin-project/asr/printmoney
Correctly handle transfers with sender = receiver
2020-05-29 12:27:56 -04:00
Aayush Rajasekaran 7dd25c3ac5 Correctly handle transfers with sender = receiver 2020-05-29 12:15:41 -04:00
Jakub Sztandera 241c3fa673 Merge pull request #1869 from filecoin-project/feat/drand-pubsub
Add pubsub support to drand beacon
2020-05-29 18:06:38 +02:00
Łukasz Magiera 785eeb1eee Merge pull request #1850 from filecoin-project/chore/lint
Cleanup many lint warnings
2020-05-29 18:06:06 +02:00
Jakub Sztandera 30d82ba962 Explicity Watch for randomness
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-29 17:55:24 +02:00
Jakub Sztandera 002d021eb7 Enable HashMsgId
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-29 17:55:24 +02:00
Jakub Sztandera 71eb41b9aa Add pubsub support to drand beacon
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-29 17:55:17 +02:00
Łukasz Magiera f06369166e Merge pull request #1868 from filecoin-project/feat/pond-regen-methods
pond: rerun method-gen
2020-05-29 15:14:20 +02:00
Łukasz Magiera 5129fed7c8 pond: rerun method-gen 2020-05-29 14:36:56 +02:00
Łukasz Magiera f06794ae84 Merge pull request #1856 from filecoin-project/deps/specs-actors-batch-porep
update specs actors to version with batch porep verification
2020-05-29 14:13:04 +02:00
Howard Yeh 1cabecedee Fix block production timing to avoid mining old tipset 2020-05-29 18:13:58 +08:00
Whyrusleeping f17c32c593 Merge pull request #1749 from filecoin-project/feat/shed-verifreg
add some commands for interacting with verified registry actor to lot…
2020-05-28 17:41:28 -07:00
Whyrusleeping b59f88324c Merge pull request #1865 from filecoin-project/fix/missing-err-check-stored-ask
Add missing err check in storage ask initialization
2020-05-28 17:17:50 -07:00
hannahhoward 0c4db8cf6b fix(storageminer): add missing err check
Missing an err check in storage miner initialization in the stored ask
2020-05-28 17:05:17 -07:00
Jeromy 9c020e54b5 Add more verifreg commands to list verifiers and clients 2020-05-28 17:01:01 -07:00
Jeromy 9811375d18 add some commands for interacting with verified registry actor to lotus-shed 2020-05-28 17:01:00 -07:00
Whyrusleeping 2632621f7e Merge pull request #1862 from filecoin-project/mod-tidy/master
Mod-tidy on master
2020-05-28 14:52:00 -07:00
Jakub Sztandera d742efe165 Mod-tidy on master
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-28 23:50:29 +02:00
Jakub Sztandera 492ffac913 Merge pull request #1853 from shepf/master
update struct.go github url
2020-05-28 23:50:05 +02:00
Mike Greenberg 4acf0c7ec0 install service files in suitable path; tweak lotus svc restarting 2020-05-28 16:26:07 -04:00
Aayush Rajasekaran fa69adf45c update chain-validation 2020-05-28 13:21:12 -07:00
Aayush Rajasekaran fa04da2995 Update specs-actors and storage-fsm 2020-05-28 13:19:36 -07:00
Jeromy e2a554c2e6 update specs actors to version with batch porep verification 2020-05-28 13:19:18 -07:00
Jeromy 91da81c8bc mod tidy 2020-05-28 13:17:55 -07:00
Jeromy 7bd18290db Merge branch 'master' into next 2020-05-28 13:16:47 -07:00
Jeromy 8e55c91cd2 check neq zero exit code 2020-05-28 22:11:49 +02:00
Mike Greenberg 514339e855 update systemd services; include make directives and docs for use 2020-05-28 22:11:49 +02:00
frrist 9f8ecb0ac4 update chain-validation
- has new syscalls
2020-05-28 22:11:49 +02:00
frrist be1bbe88b0 update chain-val syscalls interface 2020-05-28 22:11:49 +02:00
Łukasz Magiera f1ccbe496a cli: Trim spaces from token file 2020-05-28 22:11:49 +02:00
vyzo 495554e565 gomod: update go-libp2p-pubsub@v0.3.1 2020-05-28 22:11:49 +02:00
Ignacio Hagopian 17c378c18a fix
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-28 22:11:49 +02:00
Ignacio Hagopian 6e63ea6cce revert file
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-28 22:11:49 +02:00
Ignacio Hagopian 10753f14d0 retrieve: make fileref optional
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-28 22:11:49 +02:00
Ignacio Hagopian 0af7cd1448 allow using ipfs for retrieval
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-28 22:11:49 +02:00
Ignacio Hagopian de3edc2ec7 remote ipfs support & automatic env
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-28 22:11:49 +02:00
Whyrusleeping d0eb4278ae Merge pull request #1860 from filecoin-project/fix/recovery-exit-code-check
check neq zero exit code
2020-05-28 12:59:29 -07:00
Jeromy b807bdbea0 check neq zero exit code 2020-05-28 08:45:34 -07:00
Mike Greenberg 386b818d16 add systemd documention to table of contents 2020-05-27 19:28:31 -04:00
Jakub Sztandera 8639409f74 go mod tidy
,
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-28 01:16:01 +02:00
Jakub Sztandera b372881e91 Fix more lint warnings
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-28 01:15:19 +02:00
Whyrusleeping fc351d08b0 Merge pull request #1849 from filecoin-project/feat/remove-drand-on-miner
Remove drand on miner side, MinerGetBaseInfo provides the same info
2020-05-27 16:06:08 -07:00
shepf eb325e6814 update struct.go github url 2020-05-28 07:05:53 +08:00
Jakub Sztandera 7232e5481c Use origin/next for linting
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-28 00:49:52 +02:00
Jakub Sztandera f26a336afb Use git.base_revision
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-28 00:45:17 +02:00
Whyrusleeping 70e690dac0 Merge pull request #1852 from filecoin-project/feat/systemd-usage
Update systemd usage and docs
2020-05-27 15:23:45 -07:00
Mike Greenberg 78e0c96f22 update systemd services; include make directives and docs for use 2020-05-27 17:17:18 -04:00
Jakub Sztandera d6615b6286 Cleanup many lint warnings
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 22:53:20 +02:00
Jakub Sztandera 4604b60fb1 Remove drand on miner side, MinerGetBaseInfo provides the same info
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 20:24:26 +02:00
Whyrusleeping 75041b96e4 Merge pull request #1815 from filecoin-project/frrist/new-chainval-syscalls
update chain-val syscalls interface
2020-05-27 11:00:16 -07:00
Whyrusleeping 8544bda14a Merge pull request #1846 from filecoin-project/feat/trim-token-file
cli: Trim spaces from token file
2020-05-27 10:58:09 -07:00
Whyrusleeping 745fba7d1f Merge pull request #1841 from filecoin-project/gomod/update-pubsub
Update go-libp2p-pubsub to v0.3.1
2020-05-27 10:50:19 -07:00
Łukasz Magiera 6986204657 Merge pull request #1848 from filecoin-project/feat/new-drand-client
Update go-log, reduce drand entry log level, add TAG env for dev scripts
2020-05-27 16:22:13 +02:00
Jakub Sztandera 3f9cde28fc Update go-log, reduce drand entry log level, add TAG env for dev scripts
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 16:19:21 +02:00
Jakub Sztandera aa682a377d Partially fix pond spawn
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 16:19:21 +02:00
Łukasz Magiera af1d54501f Merge pull request #1843 from jsign/jsign/2stackedprs
Allow remote IPFS node support & IPFS for data retrieval & automatic env wiring
2020-05-27 14:59:18 +02:00
Ignacio Hagopian 009cd92010 fix
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-27 09:50:32 -03:00
Łukasz Magiera 6386107b80 Merge pull request #1819 from filecoin-project/feat/new-drand-client
Switch to new drand client
2020-05-27 14:35:01 +02:00
Jakub Sztandera 218b2b82c1 Update drand chain info
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 14:09:04 +02:00
Jakub Sztandera b06b0147a9 Switch to new drand client
This is a preview of a change to new drand client.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-27 13:52:33 +02:00
Łukasz Magiera b74e8f5922 Merge pull request #1847 from waynewyang/Deadline-Index
fix: add deadline index for wdpost
2020-05-27 11:40:31 +02:00
waynewyang 94a7ef1c10 add deadline index for wdpost 2020-05-27 17:01:48 +08:00
Łukasz Magiera 02afd7d71f cli: Trim spaces from token file 2020-05-27 10:13:06 +02:00
Ignacio Hagopian a10690359c revert file
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-26 15:35:20 -03:00
Łukasz Magiera fa4ff89dca Set devnet params 2020-05-26 19:58:09 +02:00
Ignacio Hagopian bcd84cbe9d retrieve: make fileref optional
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-26 14:52:52 -03:00
Ignacio Hagopian 61daaa774b allow using ipfs for retrieval
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-26 14:52:52 -03:00
Ignacio Hagopian d5346f8326 remote ipfs support & automatic env
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-05-26 14:52:51 -03:00
frrist 8ce6921b18 update chain-validation
- has new syscalls
2020-05-26 10:51:19 -07:00
frrist c8f28103f3 update chain-val syscalls interface 2020-05-26 10:49:39 -07:00
vyzo 3cd3785385 gomod: update go-libp2p-pubsub@v0.3.1 2020-05-26 20:47:00 +03:00
Łukasz Magiera 9089aadbbf Merge pull request #1821 from filecoin-project/deps/update-ffi
update to latest ffi
2020-05-26 19:34:02 +02:00
Łukasz Magiera 02ca1937f8 mod tidy 2020-05-26 19:07:21 +02:00
Łukasz Magiera 6897110fe5 Merge pull request #1838 from waynewyang/wdpost-input-correct
Fix:the input sectors of wpost  must match with the minerActor
2020-05-26 15:00:58 +02:00
waynewyang b799af3e9a Fix:the input sectors of wpost must match with the minerActor 2020-05-26 17:58:20 +08:00
Łukasz Magiera 9641d93615 Merge pull request #1836 from waynewyang/Wdpost-Gaslimit
Set largest gaslimit for wdpost
2020-05-26 08:53:59 +02:00
waynewyang da6768c94d Set largest gaslimit for wdpost 2020-05-26 11:43:17 +08:00
Lucas Molas 54a8b88d6c Merge pull request #1832 from filecoin-project/fix/disable-relay
Unconditionally disable relay
2020-05-25 10:38:48 -03:00
vyzo ba6217cc2c go mod tidy 2020-05-25 13:46:53 +03:00
vyzo 314da26da3 unconditionally disable relay 2020-05-25 13:39:50 +03:00
Jeromy 646800b8a8 update to latest ffi 2020-05-22 09:26:14 -07:00
Lucas Molas 92d58ab191 Merge pull request #1820 from filecoin-project/fix/sink-message-topic-deliveries
sink message topic deliveries
2020-05-22 11:33:43 -03:00
vyzo 5531f27798 sink the FirstMessageDeliveries boost for the messages topic 2020-05-22 17:25:56 +03:00
vyzo cc98117df2 log block validation time 2020-05-22 17:21:37 +03:00
Whyrusleeping ffd340086e Merge pull request #1817 from filecoin-project/feat/sort-miners-by-deal-count
Add command to sort miners by deal counts
2020-05-21 16:06:44 -07:00
Jeromy 805686be2e Add command to sort miners by deal counts 2020-05-21 15:52:20 -07:00
Whyrusleeping 0d3f602d58 Merge pull request #1804 from filecoin-project/feat/seal-verify-shed
put a command for verifying seals into the shed
2020-05-21 10:07:19 -07:00
Whyrusleeping 83436842c5 Merge pull request #1802 from filecoin-project/feat/gfm-v0.2.7
Use latest go-fil-markets
2020-05-21 10:05:54 -07:00
Whyrusleeping bafb922ff7 Merge pull request #1811 from filecoin-project/feat/update-pubsub
Update pubsub and libp2p
2020-05-21 09:51:00 -07:00
Jeromy 6e024d9994 parse ticket and seal randomness flags 2020-05-21 08:26:32 -07:00
vyzo d597c3fb0d increase OpportunisticGraftThreshold to 5 2020-05-21 14:38:11 +03:00
vyzo 24cebb8b2f gomod: update go-libp2p@v0.9.2 2020-05-21 12:13:14 +03:00
vyzo 0cc8446a79 configure Dout=0 for bootstrappers, turn off Mesh Failure Penalty for messages as well 2020-05-21 12:11:22 +03:00
vyzo 3e383d909a gomod: update go-libp2p-pubsub@v0.3.0 2020-05-21 12:08:13 +03:00
hannahhoward 3264a9faad feat(deps): update to latest go-fil-markets
update to go-fil-markets v0.2.7 with latest changes, modify constructors as needed to accomodate new
DS Prefix customization
2020-05-20 16:01:03 -07:00
hannahhoward c52b75d59e fix(deps): update to new 0.2.7 2020-05-20 16:00:03 -07:00
shannonwells 652c257763 passing w/ new namespace wraps 2020-05-20 15:58:59 -07:00
shannonwells 060f23d748 mod tidy 2020-05-20 15:56:58 -07:00
shannonwells e68ab286f6 upgrade lotus to go-fil-markets v0.2.5 2020-05-20 15:56:58 -07:00
Jeromy 92e5cc5ad7 add args usage 2020-05-20 15:28:19 -07:00
Łukasz Magiera 6831ca9e03 Merge pull request #1808 from filecoin-project/feat/extract-jsonrpc-auth
Extract auth utils to go-jsonrpc
2020-05-20 22:22:53 +02:00
Łukasz Magiera f7325a69c1 Extract auth utils to go-jsonrpc 2020-05-20 20:37:45 +02:00
Łukasz Magiera bb78292faf Merge pull request #1807 from filecoin-project/feat/extract-jsonrpc
Extract lib/jsonrpc to go-jsonrpc
2020-05-20 19:58:50 +02:00
Łukasz Magiera eeca031525 extract lib/jsonrpc to go-jsonrpc 2020-05-20 19:49:09 +02:00
Jeromy f82e0e61e1 put a command for verifying seals into the shed 2020-05-20 10:10:35 -07:00
Łukasz Magiera 75e47db520 Merge pull request #1771 from filecoin-project/feat/post-recover
post: Handle Recovering sectors
2020-05-20 19:08:09 +02:00
Łukasz Magiera 3da1a0d8cc post: Declare recoveries for the next deadline 2020-05-20 19:07:31 +02:00
Travis Person a293bd798f init map 2020-05-20 18:41:22 +02:00
Łukasz Magiera ae60001dcc post: Handle Recovering sectors 2020-05-20 18:41:20 +02:00
Łukasz Magiera cea7c41023 Merge pull request #1761 from dtynn/fix/dtynn/use_abs_path_for_client_filestore
use abs path to construct FileManager
2020-05-20 12:49:53 +02:00
Łukasz Magiera 0fe7a0b2e3 Merge pull request #1764 from filecoin-project/feat/has-cache-bs
add blockstore 'Has' caching
2020-05-20 12:48:50 +02:00
Łukasz Magiera 267368d56c Merge pull request #1767 from filecoin-project/feat/html-trace-improvements
add tipset key and height to html trace output
2020-05-20 12:48:05 +02:00
Łukasz Magiera f5451ad455 Merge pull request #1795 from shannon-6block/master
Pset represents the proving sectors, and Sset repensents all sectors
2020-05-20 12:46:22 +02:00
Łukasz Magiera 555537c528 Merge pull request #1791 from filecoin-project/feat/api-gen-2
improving the autogenerated api docs
2020-05-20 12:40:49 +02:00
shannon cc5875c6bd Pset represents the proving sectors, and Sset repensents all sectors 2020-05-20 12:12:13 +08:00
Jeromy c54d050cb7 slightly better methodgroup parsing, and more group docs 2020-05-19 09:49:47 -07:00
Jeromy cb88237305 improving the autogenerated api docs 2020-05-19 08:48:58 -07:00
Whyrusleeping cc44167f2c Merge pull request #1564 from filecoin-project/feat/api-doc-gen
working on api documentation autogeneration
2020-05-18 19:24:31 -07:00
Whyrusleeping 78c656e4c1 Merge pull request #1788 from filecoin-project/asr/issuetemplate
Create an issue template for mining issues
2020-05-18 17:27:55 -07:00
Jeromy 607bcc401c very basic api documentation autogeneration 2020-05-18 17:20:54 -07:00
Whyrusleeping 7fd481ea6f Merge pull request #1766 from filecoin-project/feat/chain-get-decoders
Feat/chain get decoders
2020-05-18 16:06:41 -07:00
Whyrusleeping 9c91daf19a Merge pull request #1787 from filecoin-project/fix/dont-mine-below-min
having power below the minimum means not having power
2020-05-18 16:05:06 -07:00
Aayush Rajasekaran c1ef9d1731 Create an issue template for mining issues 2020-05-18 18:31:53 -04:00
Jeromy eaf69b160c having power below the minimum means not having power 2020-05-18 14:51:42 -07:00
Łukasz Magiera 269286e587 Merge pull request #1785 from filecoin-project/frrist/chain-val-update
update chain-validation
2020-05-18 23:49:11 +02:00
Łukasz Magiera f99c5416ce Merge pull request #1786 from filecoin-project/asr/clideal
Prevent client list-deals from crashing
2020-05-18 23:48:33 +02:00
Aayush Rajasekaran 8f6c3c2cc7 prevent client list-deals from crashing 2020-05-18 17:44:00 -04:00
frrist a2e25897e9 go mod tidy 2020-05-18 14:35:47 -07:00
frrist fc9e046ca7 update chain-validation 2020-05-18 12:50:36 -07:00
Travis Person 5730d46179 Merge pull request #1728 from filecoin-project/frrist/vm-transfer-exitcodes
return correct exit codes from vm transfer
2020-05-18 19:28:48 +00:00
frrist 9165f14693 feedback: fatal errors in vm.transfer 2020-05-18 12:00:52 -07:00
frrist 9305eca97c don't ignore transfer error in delete actor 2020-05-18 12:00:52 -07:00
frrist 0c2e4e2d4f return correct exitcodes from vm transfer 2020-05-18 12:00:52 -07:00
Łukasz Magiera 59725b3af3 Merge pull request #1784 from filecoin-project/feat/update-serialization-vectors
update serialization vectors
2020-05-18 20:34:44 +02:00
Whyrusleeping a0ab3483ed Merge pull request #1770 from filecoin-project/asr/test
Add an interop test for block header serialisation
2020-05-18 11:28:06 -07:00
Jeromy e6f3b79b23 update serialization vectors 2020-05-18 11:02:34 -07:00
Whyrusleeping 1ed6183344 Merge pull request #1782 from filecoin-project/fix/no-metrics-drand
Change drand to one without metrics
2020-05-18 10:24:15 -07:00
Jakub Sztandera 29b1ac964b mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-18 19:09:19 +02:00
Jakub Sztandera 8d637c515a Change drand to one without metrics
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-18 19:00:30 +02:00
Aayush Rajasekaran 5220a61fc5 Add an interop test for block header serialisation 2020-05-16 17:27:04 -04:00
Jeromy d9502693f0 add tipset key and height to html trace output 2020-05-16 12:53:51 -07:00
Whyrusleeping 9a0d0511c7 Merge pull request #1765 from filecoin-project/fix/miner-info-div-zero
avoid dividing by zero if pset is empty
2020-05-16 12:48:53 -07:00
Jeromy 72eb32ae3c add additional chain get decoders 2020-05-16 12:41:04 -07:00
Jeromy cf9e576028 avoid dividing by zero if pset is empty 2020-05-16 11:35:24 -07:00
Jeromy 9804bd3c4c add blockstore 'Has' caching 2020-05-16 11:31:14 -07:00
dtynn 30e2642f4d use abs path to construct FileManager 2020-05-16 09:36:38 +08:00
Whyrusleeping 54b3eafd6d Merge pull request #1758 from filecoin-project/fix/lotus-bench-secp
register secp signatures for lotus bench usage
2020-05-15 13:05:27 -07:00
Jeromy f6589407c1 register secp signatures for lotus bench usage 2020-05-15 13:01:45 -07:00
Łukasz Magiera 5c73602d24 Merge pull request #1757 from filecoin-project/feat/faster-mpool-add
cache signatures, and dont check them in a lock
2020-05-15 20:27:31 +02:00
Whyrusleeping 70657e35ba Merge pull request #1708 from filecoin-project/feat/block-validator
Improved pubsub block validator
2020-05-15 11:26:26 -07:00
Łukasz Magiera 908053015b Merge pull request #1753 from filecoin-project/feat/less-res-comm2
Update sector-storage with relaxed commit2 resource numbers
2020-05-15 20:17:41 +02:00
Whyrusleeping 8bae22ef61 Merge pull request #1746 from filecoin-project/bug/circleci-mac
install jq in /usr/local/bin
2020-05-15 11:17:12 -07:00
Łukasz Magiera 1012a64110 Merge pull request #1756 from filecoin-project/feat/ffi-88555ec98
Update FFI
2020-05-15 20:16:27 +02:00
Łukasz Magiera 9eb2399539 Merge pull request #1754 from filecoin-project/fix/initial-pledge
state: Calculate slightly larger initial pledge
2020-05-15 20:15:36 +02:00
Łukasz Magiera d539be4875 Merge pull request #1741 from filecoin-project/fix/json-out-chan-closing
properly select channel ID to close for handleOutChans
2020-05-15 20:10:10 +02:00
Jeromy 13fc3f2f54 remove stress test (not really a real test) 2020-05-15 11:00:13 -07:00
Jeromy 33ec4d332b cache signatures, and dont check them in a lock 2020-05-15 10:56:38 -07:00
Whyrusleeping d6bb0500df Merge pull request #1752 from filecoin-project/fix/mpool-slowness
miner: Optimize SelectMessages
2020-05-15 10:48:06 -07:00
Łukasz Magiera b90666b293 miner: optimize SelectMessages 2020-05-15 19:30:31 +02:00
Łukasz Magiera 173a72f374 Merge pull request #1755 from filecoin-project/fix/cw-tkt-crash
chainwatch: Don't crash with nil ticket
2020-05-15 19:17:45 +02:00
Łukasz Magiera 0ae0e89ddd Update FFI 2020-05-15 19:16:06 +02:00
Łukasz Magiera c4d01c04a4 chainwatch: don't crash with nil ticket 2020-05-15 19:06:52 +02:00
Łukasz Magiera 0b56ca3c21 Merge pull request #1751 from filecoin-project/fix/turnoff-block-mesh-penalty
Turn off Mesh Delivery Failure penalty
2020-05-15 19:02:46 +02:00
Łukasz Magiera 022348f426 state: Calculate slightly larger initial pledge 2020-05-15 16:53:35 +02:00
Łukasz Magiera ad108d6051 Update sector-storage with relaxed commit2 resource numbers 2020-05-15 16:00:14 +02:00
vyzo dbe2a1e2cd turn off Mesh Delivery Failure penalty 2020-05-15 12:50:20 +03:00
Aayush Rajasekaran f86a2ced06 Merge pull request #1747 from filecoin-project/asr/docs
Fix 3 typos
2020-05-14 18:34:59 -04:00
Aayush Rajasekaran f7a45f6c12 Fix 3 typos 2020-05-14 18:27:47 -04:00
ognots 658f78d75f install jq in /usr/local/bin
/home/ognots/.bin not in path, causing macos test to fail
2020-05-14 17:32:05 -04:00
Aayush Rajasekaran e9eaee6ef8 Merge pull request #1745 from filecoin-project/asr/docs
Docs finishing touches
2020-05-14 17:08:33 -04:00
Aayush Rajasekaran 505e30c7b2 Docs finishing touches 2020-05-14 16:27:20 -04:00
Whyrusleeping 1ac6f3fa33 Merge pull request #1744 from filecoin-project/fix/signed-message-accounting
use chainmsg type instead of unsigned message for gas price checking
2020-05-14 12:51:19 -07:00
Jeromy 88fa9726cc use chainmsg type instead of unsigned message for gas price checking 2020-05-14 12:44:26 -07:00
Whyrusleeping af87920b6f Merge pull request #1743 from filecoin-project/fix/message-validation-checks
reuse logic between message selection and validation
2020-05-14 12:38:22 -07:00
Jeromy 881b0517b1 reuse logic between message selection and validation 2020-05-14 12:29:11 -07:00
Łukasz Magiera 9b2b72819b Merge pull request #1742 from filecoin-project/asr/syncfix
Don't assert params must be empty for Methodnum = 0
2020-05-14 21:28:38 +02:00
Aayush Rajasekaran 2e74e1d2ae Don't assert params must be empty for Methodnum = 0 2020-05-14 15:10:07 -04:00
Jeromy edae6a3ae8 fix the problem 2020-05-14 12:05:01 -07:00
Jeromy 987571dd8c add test to demonstrate failure 2020-05-14 11:48:58 -07:00
Whyrusleeping 934b2df763 Merge pull request #1739 from filecoin-project/feat/testnet-phase-2
Testnet Phase 2 network info
2020-05-14 11:36:56 -07:00
vyzo 81bc159b3e cache successful block signature validation 2020-05-14 20:48:40 +03:00
vyzo 50e05ae1ba use sigs.CheckBlockSignature 2020-05-14 20:48:40 +03:00
vyzo 432c69c616 update message validator to provide rejection signal 2020-05-14 20:48:40 +03:00
vyzo e714294273 initialize map 2020-05-14 20:48:19 +03:00
vyzo c3a144bcb6 flesh out signature validation logic 2020-05-14 20:48:19 +03:00
vyzo dd86a289ce cache miner worker keys 2020-05-14 20:48:19 +03:00
vyzo 6e0dac06f4 utility to retrieve miner worker key from the chain 2020-05-14 20:48:19 +03:00
vyzo 5bd0e92068 remove source flagging from bogus CID blocks
it's ineffective.
2020-05-14 20:48:19 +03:00
vyzo b032d3524b configure behaviour penalty for gsv1.1 2020-05-14 20:48:19 +03:00
vyzo 6933df918a gomod: update go-libp2p-pubsub@master 2020-05-14 20:45:25 +03:00
Łukasz Magiera d1997b5857 Merge pull request #1740 from filecoin-project/feat/bootstrapper-profile
add profile for bootstrappers
2020-05-14 18:35:38 +02:00
Travis Person aafa00abe4 Testnet Phase 2 network info 2020-05-14 16:29:17 +00:00
Jeromy d3eb808ff4 add profile for bootstrappers 2020-05-14 09:27:07 -07:00
Łukasz Magiera d009b70171 Merge pull request #1727 from filecoin-project/fix/init-sector-size
properly handle parsing of miner init sector sizes
2020-05-14 12:37:47 +02:00
Whyrusleeping d358da43f7 Merge pull request #1731 from filecoin-project/asr/docs
Documentation updates and fixes
2020-05-13 21:32:10 -07:00
Whyrusleeping 6cfc7e3fa0 Merge pull request #1737 from filecoin-project/feat/cleanup-verify
some minor cleanup of data verification for preseals
2020-05-13 21:14:00 -07:00
Jeromy b5cb1fe1e0 some minor cleanup of data verification for preseals 2020-05-13 21:00:32 -07:00
Whyrusleeping 17dace9086 Merge pull request #1735 from filecoin-project/feat/verify-bootstrappers-data
Verify data for presealed data
2020-05-13 20:51:43 -07:00
Jeromy 50fae56baf Verify data for presealed data 2020-05-13 19:35:44 -07:00
Łukasz Magiera 42269e17cc Merge pull request #1733 from filecoin-project/feat/set-verifreg-root-key
set verifreg root key
2020-05-14 02:06:35 +02:00
Jeromy a9689d8345 set verifreg root key 2020-05-13 17:04:08 -07:00
Łukasz Magiera 32dad4d43b Merge pull request #1730 from filecoin-project/fix/events-api-revert-issue-1723
events: Fix revert+apply of msg execution, but not the message
2020-05-14 01:48:47 +02:00
Łukasz Magiera a88700bef4 Merge pull request #1732 from filecoin-project/fix/cleanup-makeout-chan
clean up output channel handling logic to prevent send on closed chan
2020-05-14 01:39:24 +02:00
Jeromy 8d85aedeff clean up output channel handling logic to prevent send on closed channels 2020-05-13 16:31:17 -07:00
Aayush Rajasekaran 744ae23c2c Documentation updates and fixes 2020-05-13 19:19:33 -04:00
Łukasz Magiera 4e13d284b7 events: Fix revert+apply of msg execution, but not the message 2020-05-14 00:48:36 +02:00
Łukasz Magiera 0533cf22e7 Merge pull request #1729 from filecoin-project/feat/disable-lotus-daemon-gpu
disable gpu usage for lotus daemon
2020-05-13 23:24:06 +02:00
Jeromy 17e969bc4a disable gpu usage for lotus daemon 2020-05-13 14:22:05 -07:00
Jakub Sztandera 8b0c0a9439 Merge pull request #1717 from filecoin-project/feat/archive-script
Add archive script
2020-05-13 23:03:15 +02:00
Jakub Sztandera 7d2462ce6b Switch to filecoin-project/lotus-archived
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-13 22:30:18 +02:00
Jeromy e34b20b839 fix nondeterminism 2020-05-13 13:21:46 -07:00
Jeromy 363f575e6c properly handle parsing of miner init sector sizes 2020-05-13 13:12:13 -07:00
Łukasz Magiera 2f272d2703 Merge pull request #1726 from filecoin-project/deps/sectorstorage-4051533c
Update sector-storage
2020-05-13 21:12:48 +02:00
Łukasz Magiera 9a21b75c66 Update sector-storage 2020-05-13 21:12:15 +02:00
hannahhoward bbd2fbc434 test(events): add test to demo issue 2020-05-13 12:10:56 -07:00
Łukasz Magiera b3fc18c988 Merge pull request #1721 from filecoin-project/feat/cli-help-ux
cli: Improve lotus helptext
2020-05-13 20:41:26 +02:00
Łukasz Magiera 4a8e45a88c Merge pull request #1722 from filecoin-project/fix/no-sector-proving-info
cli: fix proving info with no sectors
2020-05-13 20:41:14 +02:00
Łukasz Magiera e12e2b4e4e cli: fix proving info with no sectors 2020-05-13 19:58:49 +02:00
Łukasz Magiera 40972762df Merge pull request #1724 from filecoin-project/feat/wait-msg-cli-nice
make the wait-msg cli print out pretty printed return values
2020-05-13 19:57:14 +02:00
Jeromy 4f624465c2 make the wait-msg cli print out pretty printed return values 2020-05-13 10:53:02 -07:00
Łukasz Magiera 41c019b3d2 cli: Improve lotus helptext 2020-05-13 13:08:59 +02:00
Whyrusleeping ea6121a951 Merge pull request #1720 from filecoin-project/fix/check-gas-limits
check gas limits on messages more places
2020-05-12 22:43:31 -07:00
Jeromy 1d8c8b9a8e check gas limits on messages more places 2020-05-12 22:36:43 -07:00
Whyrusleeping 41ee20013e Merge pull request #1719 from filecoin-project/deps/specs-actors-0.5.2
update to specs actors 0.5.2
2020-05-12 21:09:15 -07:00
Jeromy 01192105b1 update to specs actors 0.5.2 2020-05-12 20:42:53 -07:00
Łukasz Magiera 29a8259b2a Merge pull request #1716 from filecoin-project/feat/msg-gas-limit
sync: enforce message gas limits
2020-05-13 04:32:01 +02:00
Jakub Sztandera 427cb1b14d Cleanup, fix shellcheck warning
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-13 04:21:00 +02:00
Jakub Sztandera 27fd150491 Adapt script for different org
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-13 04:19:14 +02:00
Jakub Sztandera c2acfb5c31 Add archive script
Add script for archiving branches outside of the main repo.
The branches will end up here: https://github.com/Kubuxu/lotus-archived

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-13 04:14:01 +02:00
Jakub Sztandera c642dce97f Merge pull request #1715 from filecoin-project/ci/lint-from-master
ci: lint-changes based on master
2020-05-13 03:48:33 +02:00
Łukasz Magiera 4c64f0ca11 sync: enforce message gas limits 2020-05-13 03:36:56 +02:00
Łukasz Magiera 29b592f62f ci: lint-changes based on master 2020-05-13 02:11:16 +02:00
Whyrusleeping d124d10f7c Merge pull request #1711 from filecoin-project/testnet/3-cleaned
Interop Staging - Cleaned
2020-05-12 17:04:10 -07:00
Whyrusleeping b857c8f9ba Merge pull request #1714 from filecoin-project/asr/specsupdate
Update specs-actors, re-enable full chain validation
2020-05-12 17:03:50 -07:00
Aayush Rajasekaran aec168e05f Update specs-actors, re-enable full chain validation 2020-05-12 19:52:33 -04:00
Whyrusleeping 686c92ba02 Merge pull request #1713 from filecoin-project/feat/hack-reward-initial-value
hack in an initial value for LastPerEpochReward for the genesis block
2020-05-12 16:39:48 -07:00
Jeromy 141c77e17e hack in an initial value for LastPerEpochReward for the genesis block 2020-05-12 16:32:54 -07:00
Whyrusleeping 3c673f0086 Merge pull request #1712 from filecoin-project/frrist/fix-broken-stuff
construct cron actor state correctly
2020-05-12 16:27:17 -07:00
frrist 5726c4bd30 construct cron actor state correctly 2020-05-12 16:12:28 -07:00
Jakub Sztandera 12e373fd43 Sign cleaned testnet/3
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-05-13 00:18:52 +02:00
Łukasz Magiera e3e86ec983 Merge pull request #1710 from filecoin-project/feat/bitfield-decode-shed
add method to decode and print all bitfield entries to lotus shed
2020-05-12 23:35:42 +02:00
Jeromy 3a3e390e90 add method to decode and print all bitfield entries to lotus shed 2020-05-12 14:22:21 -07:00
Łukasz Magiera b462d7eb0b Merge pull request #1709 from filecoin-project/docs/sealworker-updates
docs: Seal-worker updates
2020-05-12 22:06:54 +02:00
Łukasz Magiera 8b326c9dfe Merge pull request #1706 from filecoin-project/feat/specs-actors-v0.5
Update specs-actors to v0.5
2020-05-12 22:06:34 +02:00
Łukasz Magiera 150346ae51 docs: document some mining-related env vars 2020-05-12 22:05:55 +02:00
Łukasz Magiera ed67e4c5a9 docs: seal-worker updates 2020-05-12 21:09:40 +02:00
Łukasz Magiera dcd42eec11 Update sector-storage 2020-05-12 20:33:46 +02:00
Łukasz Magiera 6447198e0e Merge remote-tracking branch 'origin/testnet/3' into feat/specs-actors-v0.5 2020-05-12 20:25:53 +02:00
Łukasz Magiera 3003bb5731 Merge pull request #1707 from filecoin-project/feat/update-ffi
Update FFI
2020-05-12 20:24:45 +02:00
Łukasz Magiera d7b8cc6ef9 mod tidy 2020-05-12 20:23:10 +02:00
Łukasz Magiera 9597e4c501 Merge pull request #1675 from filecoin-project/frrist/puppet-actor
update chain-validation and add puppet actor
2020-05-12 20:20:00 +02:00
Łukasz Magiera f7314646ec Update FFI 2020-05-12 20:18:58 +02:00
Aayush Rajasekaran 46fb5f8602 update CV, skip nested sends test 2020-05-12 14:14:00 -04:00
Łukasz Magiera ba389598ee Cleanup build package 2020-05-12 19:59:28 +02:00
Łukasz Magiera e8d92a5f31 node: Use correct network name for DHT 2020-05-12 19:38:04 +02:00
Łukasz Magiera 741cfb7f00 Merge branch 'feat/specs-actors-v0.5' into frrist/puppet-actor 2020-05-12 19:04:04 +02:00
Łukasz Magiera 6056a52978 Update specs-actors to pre v0.5 2020-05-12 18:58:43 +02:00
Łukasz Magiera 4ea021d151 Merge pull request #1701 from filecoin-project/asr/syncvalidity
Message validation changes
2020-05-12 13:48:33 +02:00
Łukasz Magiera 6712560779 fix import ordering 2020-05-12 13:48:09 +02:00
Aayush Rajasekaran 6bf2dcd97c Message validation changes 2020-05-11 21:54:44 -04:00
Łukasz Magiera d3a99456ae Merge pull request #1702 from filecoin-project/feat/update-markets-0.2.3
Update markets 0.2.3
2020-05-12 01:55:51 +02:00
hannahhoward ecd180ecf4 feat(deps): update markets 0.2.3 2020-05-11 16:33:30 -07:00
Whyrusleeping cab07f61c5 Merge pull request #1697 from filecoin-project/feat/64g
Updates for 64G sectors
2020-05-11 15:17:26 -07:00
Łukasz Magiera ec83b9cf7c Fix tests post specs-actors update 2020-05-11 23:26:33 +02:00
Łukasz Magiera 0704ac4636 Merge remote-tracking branch 'origin/testnet/3' into feat/64g 2020-05-11 22:36:52 +02:00
Łukasz Magiera 6002e359ae Updates for 64G sectors 2020-05-11 22:24:42 +02:00
frrist 9a1d8cecfe update chain-validation
- has nested send puppet test
2020-05-11 12:57:23 -07:00
frrist f73366630f add puppet actor to vm invoker in driver 2020-05-11 11:48:55 -07:00
Whyrusleeping 728ae01012 Merge pull request #1665 from aagdere/aa/Add-Msig-Send-RPC
Added RPC calls for MsigCreate, MsigPropose, MsigApprove, and MsigCancel
2020-05-11 10:58:10 -07:00
Whyrusleeping 6c2c33db56 Merge pull request #1696 from filecoin-project/feat/update-markets-0.2.1
Update to fil-markets 0.2.1
2020-05-11 09:31:25 -07:00
Aris e7065df2d4 Added RPC calls for MsigCreate, MsigPropose, MsigApprove, and MsigCancel 2020-05-11 10:27:48 -04:00
hannahhoward fc2d61a55b fix(deps): update markets v0.2.2 2020-05-08 22:06:11 -07:00
hannahhoward 581e7e6fde chore(deps): update to fil-markets 0.2.1
Update fil-markets to 0.2.1 that no longer keeps streams open
2020-05-08 14:11:40 -07:00
Łukasz Magiera 66d67f66a7 Merge pull request #1685 from filecoin-project/feat/v26
v26 proofs
2020-05-08 22:14:41 +02:00
Łukasz Magiera 85dc2eb36f Merge pull request #1672 from filecoin-project/feat/bisect-errors
Some chain-bisect improvements / fixes
2020-05-08 22:14:19 +02:00
Łukasz Magiera 4cd861eb87 chain bisect: json-marshar the correct thing 2020-05-08 21:55:26 +02:00
Łukasz Magiera 7747c3eb40 Update sector-storage 2020-05-08 21:28:14 +02:00
Łukasz Magiera 00c107548e ffi: use v26 master 2020-05-08 20:36:32 +02:00
Łukasz Magiera e4cb28a310 Merge pull request #1694 from filecoin-project/fix/nil-protections
add some simple sanity checking to incoming blocks in the syncer
2020-05-08 20:26:50 +02:00
Jeromy da73b62074 that doesnt belong there, really 2020-05-08 11:18:01 -07:00
Jeromy d415aa779c also check bls aggregate signature nilness 2020-05-08 11:07:57 -07:00
Jeromy f8c15e2d2d more checks in sync 2020-05-08 11:06:47 -07:00
Łukasz Magiera b74e487af2 Merge pull request #1692 from filecoin-project/bugs/events-called-null-tipset
events: Fix called with confidence on null round
2020-05-08 20:00:41 +02:00
Jeromy 8a69467982 add some simple sanity checking to incoming blocks in the syncer 2020-05-08 10:59:18 -07:00
Łukasz Magiera 1ade0e7b92 events: Fix called with confidence on null round 2020-05-08 10:31:23 +02:00
hannahhoward e5a0252126 test(events): add test to repo issue
Add a test that shows that the called function is never hit above confidence if the scheduled
trigger is at a null tipset
2020-05-07 22:07:23 -07:00
Łukasz Magiera c36bfb36e5 Update sector-storage 2020-05-08 02:12:54 +02:00
Łukasz Magiera fbfab94114 bench: Fix unseal 2020-05-08 01:44:12 +02:00
Łukasz Magiera b23cef8d1e Merge pull request #1684 from filecoin-project/asr/chainval
Update and re-enable chain-validation
2020-05-07 17:31:56 +02:00
Łukasz Magiera 85240c938e Merge pull request #1687 from filecoin-project/feat/min-miner-2g
set minimum miner size to 2g
2020-05-07 17:30:41 +02:00
Łukasz Magiera 27c4cd6360 Merge pull request #1689 from filecoin-project/feat/lotus-shed-param-fetch
Add param fetch to lotus-shed
2020-05-07 17:30:01 +02:00
Łukasz Magiera 5d1b9f854e Merge pull request #1688 from filecoin-project/feat/https-facuet-setup-script
Use https for facuet on interop join script
2020-05-07 17:28:26 +02:00
Travis Person 14bbbe4feb Add param fetch to lotus-shed 2020-05-07 05:20:17 +00:00
Travis Person 34deb5e194 Use https for facuet on interop join script 2020-05-07 05:19:09 +00:00
Jeromy 0f75cb4dfd set minimum miner size to 2g 2020-05-06 22:05:43 -07:00
Aayush Rajasekaran dd79c66d41 Update and re-enable chain-validation 2020-05-06 21:44:09 -04:00
Łukasz Magiera 75642f393d v26 2020-05-07 01:22:59 +02:00
Whyrusleeping 97130684a2 Merge pull request #1680 from filecoin-project/deps/faster-publish-deals
update to specs-actors code with faster publish deals
2020-05-06 14:45:17 -07:00
Aayush Rajasekaran 981b449a3d Merge pull request #1683 from filecoin-project/asr/vmfix
Bugfix: Correctly transfer gas when failing to charge for retValue
2020-05-06 17:06:07 -04:00
Aayush Rajasekaran 187e386740 Bugfix: Correctly transfer gas when failing to charge for retValue 2020-05-06 16:53:32 -04:00
Jeromy b76e229f8e upgrade to v0.4.0 specs actors 2020-05-06 10:47:10 -07:00
Jeromy fa59cdc2ad update to specs-actors code with faster publish deals 2020-05-05 17:06:32 -07:00
Łukasz Magiera 523a7a9d8d Merge pull request #1670 from filecoin-project/feat/update-markets-0.2.0
Update go-fil-markets
2020-05-06 01:45:33 +02:00
Whyrusleeping 51142f45c3 Merge pull request #1678 from filecoin-project/asr/verifysig
The VerifySig syscall should verify sigs
2020-05-05 15:00:58 -07:00
Whyrusleeping 5a7fdfe3ed Merge pull request #1679 from filecoin-project/feat/collab-cluster-paramfetch
fetch groth parameters from proofs.filecoin.io
2020-05-05 15:00:43 -07:00
hannahhoward ed117719aa fix(deps): update to tagged go-fil-markets 2020-05-05 14:44:03 -07:00
Jeromy 66cafc7c71 fake signatures when constructing genesis state 2020-05-05 14:36:39 -07:00
ognots 397efddbc6 fetch groth parameters from proofs.filecoin.io
proof parameters are no longer pinned to IPFS public gateways, but on collab IPFS Cluster instead
change default gateway url to proofs.filecoin.io
2020-05-05 17:27:44 -04:00
Whyrusleeping 749db0bf45 Merge pull request #1677 from terichadbourne/patch-1
Add link to new conceptual docs site
2020-05-05 13:28:25 -07:00
Łukasz Magiera 60b78a74f7 Merge pull request #1676 from filecoin-project/cleanup/multi-addr-miner
block producers should have only one address
2020-05-05 22:12:32 +02:00
Teri Chadbourne 31c14dc908 Add link to new conceptual docs site 2020-05-05 16:00:24 -04:00
Jeromy 368fff246b replace outdated comment 2020-05-05 12:39:43 -07:00
Aayush Rajasekaran 8a9862bdb4 The VerifySig syscall should verify sigs 2020-05-05 15:26:34 -04:00
Jeromy 8b58f22c2e block producers should have only one address 2020-05-05 12:01:44 -07:00
Whyrusleeping 25c10e4b36 Merge pull request #1674 from filecoin-project/feat/update-pubsub
update go-libp2p-pubsub
2020-05-05 11:38:26 -07:00
vyzo 486fda17a2 gomod: update go-libp2p-pubsub@master 2020-05-05 21:12:16 +03:00
Whyrusleeping 1cd932fedd Merge pull request #1661 from filecoin-project/feat/better-pubsub-integration
Improved pubsub integration
2020-05-05 10:41:51 -07:00
Łukasz Magiera 50291408c7 Merge pull request #1673 from filecoin-project/fix/lookback-tipset
add flag to choose what to do when looking back tipsets in null rounds
2020-05-05 19:10:18 +02:00
Jeromy 74510adaaa add flag to choose what to do when looking back tipsets in null rounds 2020-05-05 10:06:05 -07:00
Łukasz Magiera 479a456279 chain bisect: Improve errors 2020-05-05 18:18:52 +02:00
vyzo eb24baa70c use go-libp2p-core/peer instead of the deprecated alias, try to pacify the silly linter 2020-05-05 17:26:59 +03:00
vyzo 4e5179557d flag block source when messages cannot be retrieved 2020-05-05 16:49:43 +03:00
vyzo 5824714cdc use extended validator interface 2020-05-05 16:35:03 +03:00
hannahhoward a9866c757e feat(deps): update go-fil-markets
Update to latest 0.2.0 release of go-fil-markets with less-blocking node io
2020-05-04 18:36:51 -07:00
Aayush Rajasekaran 299a017ef5 Merge pull request #1668 from filecoin-project/feat/actor-create-exit
dont override exit codes for actor creation failure
2020-05-04 19:41:38 -04:00
Jeromy a553d438c0 dont override exit codes for actor creation failure 2020-05-04 16:31:26 -07:00
Łukasz Magiera f865ae9f10 Merge pull request #1667 from filecoin-project/deps/update-cbor-gen
update to latest cbor-gen
2020-05-05 00:39:31 +02:00
Jeromy 1bd88b24d4 upgrade go-address 2020-05-04 15:23:07 -07:00
Jeromy d7af5c67e9 update to latest cbor-gen 2020-05-04 15:19:48 -07:00
Whyrusleeping ecd85c3b02 Merge pull request #1666 from unknow16/patch-1
fix: content bug
2020-05-04 13:16:55 -07:00
unknow16 4a68d02a4e fix: content bug 2020-05-05 03:58:54 +08:00
Whyrusleeping cf2e8b2cab Merge pull request #1664 from filecoin-project/fix/graphsync-field-indexes
block header changed, updating field indexes to match
2020-05-04 12:19:44 -07:00
Jeromy da72dfae3d block header changed, updating field indexes to match 2020-05-04 12:09:39 -07:00
Łukasz Magiera 80f7492d06 Merge pull request #1663 from filecoin-project/feat/compute-state-hashlinks
compute-state: html: Hash links to invocations
2020-05-04 20:52:01 +02:00
Łukasz Magiera 65752a9cc4 compute-state: html: Hash links to invocations 2020-05-04 20:30:27 +02:00
Łukasz Magiera f7e6e45442 Merge pull request #1662 from filecoin-project/feat/compute-state-html
compute-state: Add html output option
2020-05-04 20:21:04 +02:00
Łukasz Magiera 8770cf2f4b compute-state: html: Show top-level message CID 2020-05-04 20:19:01 +02:00
Łukasz Magiera 51f92b6ed0 mod tidy 2020-05-04 20:13:43 +02:00
Łukasz Magiera 2e0a3fca1a compute-state: decode returns/params 2020-05-04 20:12:58 +02:00
Łukasz Magiera 4f959adbc8 compute-state: html: Print invocation duration 2020-05-04 19:19:23 +02:00
Łukasz Magiera de701a06de compute-state: html: decode code / method names 2020-05-04 18:48:50 +02:00
vyzo e3f6e586ee use blake2b hash as the message ID function 2020-05-04 19:34:30 +03:00
vyzo 1b6f6b295b gomod: update go-libp2p-pubsub@master 2020-05-04 19:07:49 +03:00
Łukasz Magiera 2a2b63086a compute-state: Add html output option 2020-05-04 18:07:43 +02:00
vyzo 805d07bca6 turn off the mesh in bootstrappers 2020-05-04 19:04:24 +03:00
vyzo 112aca7896 pubsub-specific configuration 2020-05-04 18:30:54 +03:00
vyzo cfcf946556 gomod: update go-libp2p-pubsub@master 2020-05-04 18:13:54 +03:00
Aayush Rajasekaran c649fbf43b Merge pull request #1659 from filecoin-project/asr/hash
Use blake2b, instead of sha256, for ticket creation and verification
2020-05-02 12:26:39 -04:00
Aayush Rajasekaran c196570dd8 Use blake2b, instead of sha256, for ticket creation and verification 2020-05-01 22:43:36 -04:00
Whyrusleeping 63bc34a1a0 Merge pull request #1658 from filecoin-project/fix/winning-post-rand-epoch
winning post wants the actual epoch of the block, not the previous
2020-05-01 15:05:18 -07:00
Łukasz Magiera 584a4aba4c Merge pull request #1657 from filecoin-project/fix/worker-disconnect
workers: Handle disconnecting workers more gracefully
2020-05-01 23:10:52 +02:00
Łukasz Magiera 35b1963eeb gofmt 2020-05-01 21:51:31 +02:00
Łukasz Magiera 4014cbdb44 jsonrpc: Correctly cancel server-side contexts on lost connection 2020-05-01 21:50:34 +02:00
Jeromy be2a357102 winning post wants the actual epoch of the block, not the previous 2020-05-01 12:42:59 -07:00
Łukasz Magiera 971282a9a5 jsonrpc: Test hanging ctx on unclean disconnect 2020-05-01 21:30:32 +02:00
Łukasz Magiera f9be73c73e storageminer: Fix 'storage list' with disconnected storage 2020-05-01 20:43:39 +02:00
Łukasz Magiera c616e5e14e Merge remote-tracking branch 'origin/testnet/3' into fix/worker-disconnect 2020-05-01 20:33:11 +02:00
Łukasz Magiera bc1fa74d0c Merge pull request #1656 from filecoin-project/feat/sminer-cli-ux
storageminer: Improve CLI UX
2020-05-01 20:32:02 +02:00
Łukasz Magiera 9f2df68906 workers: handle disconnecting workers more gracefully 2020-05-01 20:15:06 +02:00
Łukasz Magiera 6077edb3d0 jsonrpc: Test channel closing on when connection drops 2020-05-01 16:52:05 +02:00
Łukasz Magiera d9acd484c0 storageminer: Improve CLI UX 2020-05-01 14:06:19 +02:00
Whyrusleeping b535a801bc Merge pull request #1654 from filecoin-project/asr/dealstest
Update HAMT and cbor, test to demonstrate HAMT issue
2020-04-30 19:28:00 -07:00
Aayush Rajasekaran d096c75c6e Update HAMT and cbor gen 2020-04-30 22:08:47 -04:00
Aayush Rajasekaran 897b269139 Test to demonstrate HAMT issue 2020-04-30 20:54:41 -04:00
Łukasz Magiera a6bb8ec688 Merge pull request #1652 from filecoin-project/feat/real-winpost-test
Test real winning post mining
2020-05-01 00:36:41 +02:00
Łukasz Magiera 72c27a9f73 Test real winning post mining 2020-05-01 00:31:58 +02:00
Łukasz Magiera 2e1441cde7 Merge pull request #1651 from filecoin-project/fix/randomness-for-mining-base
fix mining base randomness
2020-05-01 00:16:25 +02:00
Whyrusleeping 414dd9f74e Merge pull request #1650 from filecoin-project/feat/ldflags
Handle LDFLAGS
2020-04-30 15:11:52 -07:00
Jeromy bee25d221f fix mining base randomness 2020-04-30 15:11:14 -07:00
Jakub Sztandera 75076ba422 Update
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-30 23:24:51 +02:00
Jakub Sztandera de8499a69b Handle system LDFLAGS
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-30 23:20:26 +02:00
Łukasz Magiera 4d51f9f700 Merge pull request #1647 from filecoin-project/feat/this-weeks-randomness-changes-2
fix winning post inputs
2020-04-30 22:30:40 +02:00
Whyrusleeping 15847756cc Merge pull request #1646 from filecoin-project/asr/hamt
Update hamt
2020-04-30 13:22:03 -07:00
Jeromy c4852e04c9 Use miner address in randomness mixing 2020-04-30 13:21:46 -07:00
Aayush Rajasekaran 441734647d Update hamt 2020-04-30 16:11:23 -04:00
Łukasz Magiera 847a916cd7 Merge pull request #1626 from filecoin-project/feat/storage-better-fetch
Update sector-storage with better fetch logic
2020-04-30 22:00:50 +02:00
Łukasz Magiera a1a2bf1a0e Merge pull request #1643 from filecoin-project/asr/createactor
some create actor changes
2020-04-30 21:34:28 +02:00
Łukasz Magiera ed500dbbdf Merge remote-tracking branch 'origin/testnet/3' into asr/createactor 2020-04-30 21:29:04 +02:00
Łukasz Magiera 02c936c2ff Merge pull request #1649 from filecoin-project/fix/drand-peer-rotation
fix race condition, 'thundering herd'-like issue, and add logging
2020-04-30 21:22:17 +02:00
Jeromy 6caf725e14 fix race condition, 'thundering herd'-like issue, and add logging 2020-04-30 11:58:21 -07:00
Łukasz Magiera 5026091623 Merge remote-tracking branch 'origin/testnet/3' into feat/storage-better-fetch 2020-04-30 20:56:52 +02:00
Łukasz Magiera 6d1914ce43 Merge pull request #1645 from filecoin-project/feat/client-deal-start-epoch
Add flag to specify deal start epoch
2020-04-30 20:47:52 +02:00
Whyrusleeping f18f6bb994 Merge pull request #1642 from filecoin-project/deps/update-drand
Update drand to v0.8.1
2020-04-30 11:47:26 -07:00
Łukasz Magiera a1bb005b7c Merge pull request #1648 from filecoin-project/asr/fatal
Elevate an actor construction fail-case to fatal
2020-04-30 20:44:54 +02:00
Jeromy 931a862abc remove usage of previous round in beacon entries 2020-04-30 11:39:37 -07:00
Jeromy 4b3cc2ca7e fix winning post inputs 2020-04-30 11:27:22 -07:00
Aayush Rajasekaran 6cd3e7f7cb Update chain validation 2020-04-30 14:21:36 -04:00
Aayush Rajasekaran a047e158ed Add some validity checks to runtime.CreateActor() 2020-04-30 14:21:29 -04:00
Aayush Rajasekaran bd1ac4d91b Only charge for actor creation after making a meaningful state change 2020-04-30 14:18:26 -04:00
Travis Person 59dcbe93a4 Update drand to v0.8.1 2020-04-30 11:07:00 -07:00
Jeromy e345525672 Add flag to specify deal start epoch 2020-04-30 10:51:08 -07:00
Aayush Rajasekaran d9a1d912fd Elevate an actor construction fail-case to fatal 2020-04-30 13:46:33 -04:00
Whyrusleeping d7d2b12a32 Merge pull request #1635 from filecoin-project/feat/gossipsub-v1.1
Initial Gossipsub v1.1 integration
2020-04-30 10:43:18 -07:00
Whyrusleeping f16ae9dffb Merge pull request #1638 from filecoin-project/frrist/fix-lack-gas-retval
fix: insufficient gas remaining to cover retval
2020-04-30 10:20:17 -07:00
Whyrusleeping ae420fc9f4 Merge branch 'testnet/3' into feat/gossipsub-v1.1 2020-04-30 10:19:42 -07:00
Łukasz Magiera f6c4c2b72e Merge pull request #1641 from filecoin-project/feat/ipfsclient
Support making deals with data directly from IPFS nodes
2020-04-30 13:40:41 +02:00
Łukasz Magiera a0bdf95845 ipfsclient: Add some docs 2020-04-30 13:21:51 +02:00
Łukasz Magiera 0d4bf2e980 Merge branch 'testnet/3' into feat/ipfsclient 2020-04-30 13:09:47 +02:00
Łukasz Magiera be439d3b13 Merge remote-tracking branch 'origin/master' into testnet/3 2020-04-30 13:03:08 +02:00
Łukasz Magiera 81e3b714a2 gofmt 2020-04-30 12:51:19 +02:00
Łukasz Magiera e2b0e00547 Merge pull request #1644 from filecoin-project/feat/new-drand
New drand network
2020-04-30 11:47:47 +02:00
Travis Person a29f19e482 New drand network 2020-04-30 04:55:53 +00:00
Łukasz Magiera fce2ec0470 Merge pull request #1639 from filecoin-project/feat/this-weeks-randomness-changes
implement latest changes to randomness
2020-04-30 02:08:52 +02:00
Łukasz Magiera 5ec76d4b7b support making deals with data directly from IPFS nodes 2020-04-30 01:56:45 +02:00
Jeromy d73b369fa5 implement latest changes to randomness 2020-04-29 16:50:45 -07:00
frrist c66415ae4c fix: insufficient gas remaining to cover retval
proceed as in the case of method execution failure.
2020-04-29 16:38:34 -07:00
Whyrusleeping 639b800505 Merge pull request #1640 from filecoin-project/asr/misc
update chain validation to point to commit in master
2020-04-29 16:14:01 -07:00
Aayush Rajasekaran 35fcf04d3d update chain validation to point to commit in master 2020-04-29 19:05:18 -04:00
Łukasz Magiera e4bb94e939 Merge pull request #1637 from filecoin-project/feat/mpool-stat-local
mpool cli: --local flag
2020-04-30 00:39:34 +02:00
vyzo 43aca717d1 gossipsubv1.1: tweak score parameters 2020-04-29 23:15:29 +03:00
Łukasz Magiera cb5e5a1325 mpool cli: --local flag 2020-04-29 21:52:04 +02:00
vyzo 7de882b4d0 gossipsubv1.1: use score parameter helpers 2020-04-29 22:50:51 +03:00
vyzo 426bd4cfed gomod: update go-libp2p-pubsub 2020-04-29 22:49:24 +03:00
Łukasz Magiera 1e38e02456 Merge pull request #1636 from filecoin-project/feat/specs-actors-v0.3
specs-actors v0.3
2020-04-29 20:16:26 +02:00
Łukasz Magiera 89b19af43f specs-actors v0.3 2020-04-29 20:06:05 +02:00
Łukasz Magiera ba12b9ac3f Update sector-storage with scheduling improvements 2020-04-29 18:03:59 +02:00
vyzo f8f6e28985 fix linter complaint 2020-04-29 19:01:45 +03:00
vyzo 9570ebfe0a fix comparison logic for bootstrap peers 2020-04-29 18:56:58 +03:00
vyzo 667fb17b43 gossipsubv1.1: configure larger overlay D params 2020-04-29 17:09:39 +03:00
vyzo 7d7c83ef79 gossipsubv1.1: configure scores for bootstrapper PX 2020-04-29 17:03:41 +03:00
vyzo 6b56652768 gossipsubv1.1: score parameters and flood publishing 2020-04-29 16:41:44 +03:00
vyzo c7939ff580 gomod: use go-libp2p-pubsub@master 2020-04-29 14:40:01 +03:00
Łukasz Magiera 068e9a29d2 Merge remote-tracking branch 'origin/testnet/3' into feat/storage-better-fetch 2020-04-29 13:27:49 +02:00
Łukasz Magiera 014092443f Merge pull request #1619 from filecoin-project/feat/message-version-field
add version field to message type
2020-04-29 02:51:52 +02:00
Aayush Rajasekaran cf8691ed87 update chain validation 2020-04-28 20:31:41 -04:00
Jeromy eb4f4675a5 add version field to message type 2020-04-28 19:12:52 -04:00
Łukasz Magiera 41d925ab8a Merge pull request #1630 from filecoin-project/asr/misc
Minor / irrelevant improvements go here
2020-04-29 00:21:45 +02:00
Łukasz Magiera 2ead8c089e Merge pull request #1631 from filecoin-project/feat/on-chain-deal-states
add on-chain deal information to client list-deals output
2020-04-29 00:21:01 +02:00
Łukasz Magiera 1b0c0e10c6 Merge pull request #1632 from filecoin-project/feat/use-other-drand-server
use other drand server for now
2020-04-29 00:12:50 +02:00
Jeromy f186e1a4f7 use other drand server for now 2020-04-28 15:10:12 -07:00
Łukasz Magiera fb1788a3e9 Merge pull request #1621 from filecoin-project/feat/devnet-script
add script to run a local devnet, and helper command
2020-04-28 22:59:29 +02:00
Łukasz Magiera ac6573cca7 Merge pull request #1629 from filecoin-project/deps/update-specs-actors
WIP: updating to specs actors v0.2.0
2020-04-28 22:56:47 +02:00
Jeromy 6a27c65201 updating to specs actors v0.2.0 2020-04-28 13:52:07 -07:00
Łukasz Magiera 5c6cf8b619 Merge pull request #1625 from filecoin-project/feat/shed-bitfields
shed: Add some bitfield tools
2020-04-28 22:01:34 +02:00
Łukasz Magiera 6014530145 shed bitfield: use Count to check for overflows 2020-04-28 21:36:58 +02:00
laser 160bc0676f add on-chain deal information to client list-deals output 2020-04-28 11:37:20 -07:00
Whyrusleeping cd5cbcfe4f Merge pull request #1627 from filecoin-project/fix/safe-actor-serialization
vm: Don't treat actor state serialization errors as fatal
2020-04-28 10:50:53 -07:00
Aayush Rajasekaran ae47bc15ff Remove / rename fallback post stuff 2020-04-28 13:39:35 -04:00
Jeromy 33076d5b43 fix replace directive 2020-04-28 10:35:07 -07:00
Łukasz Magiera 9dcb42328e gofmt 2020-04-28 19:27:13 +02:00
Whyrusleeping 3ec736bc04 Merge pull request #1623 from filecoin-project/asr/validate
caller must be validated exactly once
2020-04-28 09:06:28 -07:00
Łukasz Magiera c760a88c22 vm: don't treat actor state serialization errors as fatal 2020-04-28 15:21:31 +02:00
Łukasz Magiera 8d35aacd31 Update sector-storage with better fetch logic 2020-04-28 14:57:53 +02:00
Łukasz Magiera 4579e9bb84 shed: add some bitfield tools 2020-04-28 10:44:10 +02:00
Aayush Rajasekaran 5900d765fd caller must be validated exactly once 2020-04-28 00:07:47 -04:00
Whyrusleeping e65d293ba4 Merge pull request #1607 from filecoin-project/feat/chainwatch-updates
chainwatch: Record drand entries
2020-04-27 16:23:47 -07:00
Whyrusleeping b2dda08368 respect shutdown signals when sleeping in miner code (#1617) 2020-04-27 15:54:41 -07:00
Travis PersonandTravis Person c807469a5a bitswap: disable provider (#1620)
Co-authored-by: Travis Person <travisperson@users.noreply.github.com>
2020-04-27 15:54:16 -07:00
Jeromy bfa93bb933 add script to run a local devnet, and helper command 2020-04-27 15:26:46 -07:00
Travis PersonandTravis Person d3796abac7 Quick setup script (#1352)
* Quick setup script

* Auto noncefix and properly record stderr of miner

* Use new pledge sector command

* Build native ffi

* Add PreCommit1 and PreCommit2

* Move into scripts dir

Co-authored-by: Travis Person <travisperson@users.noreply.github.com>
2020-04-27 12:52:55 -07:00
Jakub Sztandera bd3a43a367 Remove old cached params (#1618)
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-27 11:06:56 -07:00
ldoublewood b7c6cc5321 fix wrong special id (#1615) 2020-04-27 10:26:28 -07:00
Łukasz Magiera 939d7a7a0b Merge pull request #1606 from filecoin-project/asr/internal
Remove SysErrInternal, some interop / spec changes
2020-04-27 13:02:11 +02:00
Łukasz Magiera 33a419fbdb Merge pull request #1609 from filecoin-project/asr/misc
Fixes to multisig functionality in CLI
2020-04-27 12:54:06 +02:00
Aayush Rajasekaran fa1b559b2c CLI: multisig approve needs to recreate proposal hash 2020-04-26 19:47:18 -04:00
Aayush Rajasekaran e46c4652a5 Forbid internal message in State Transaction() 2020-04-25 02:01:26 -04:00
Aayush Rajasekaran 832657edfb Eliminate use of SysErrInternal, some interop changes 2020-04-25 01:55:59 -04:00
Aayush Rajasekaran c3b1cf19a4 Actually use the multisig source flag 2020-04-25 01:55:10 -04:00
Aayush Rajasekaran 1565e10fff Allow users to specify sender when creating multisigs 2020-04-25 01:55:10 -04:00
Łukasz Magiera e38484a109 Merge remote-tracking branch 'origin/testnet/3' into feat/chainwatch-updates 2020-04-25 00:27:59 +02:00
Łukasz Magiera 0522af155d chainwatch: Record drand entries 2020-04-25 00:25:33 +02:00
Łukasz Magiera 1947f26cdb Update specs-actors 2020-04-25 00:25:03 +02:00
Frrist 0f0589bcf5 Update validation driver to match latest in chain-validation (#1532)
* update driver to match new chain-validation interfaces

* update chain-validation

* update filecoin-ffi

* gofmt

* update chain-validation again
2020-04-24 15:08:16 -07:00
Łukasz Magiera e8e2b3a6f9 Merge pull request #1597 from filecoin-project/asr/misc
Various improvements to deal workflow
2020-04-24 23:07:33 +02:00
Łukasz Magiera 5287119f4e Merge pull request #1605 from filecoin-project/feat/update-specs-actors
update to specs actors with sectors fixes
2020-04-24 23:06:03 +02:00
Łukasz Magiera fd7af33d4b Merge pull request #1604 from filecoin-project/feat/better-sminer-info
storageminer: Print some balances in info
2020-04-24 23:05:06 +02:00
Łukasz Magiera af794a6281 storageminer: Print some balances in info 2020-04-24 23:02:27 +02:00
Jeromy 360d87cbab update to specs actors with sectors fixes 2020-04-24 10:51:47 -07:00
Łukasz Magiera bf0e50d717 Merge pull request #1603 from filecoin-project/feat/fixed-null-miner-cron
specs-actors: Fix miner cron on null blocks
2020-04-24 19:20:08 +02:00
Łukasz Magiera 55f7c81aaf specs-actors: Fix miner cron on null blocks 2020-04-24 19:12:30 +02:00
Łukasz Magiera a02bf83332 Merge pull request #1600 from filecoin-project/deps/badger2
Update badger
2020-04-24 16:58:28 +02:00
Jakub Sztandera 36cd9826aa Update badger
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-24 16:29:34 +02:00
Aayush Rajasekaran 7c22dabb63 default to setting max piece size to sector size 2020-04-24 01:01:22 -04:00
Aayush Rajasekaran 45722772fc Print a miner ask's max piece size 2020-04-24 01:01:22 -04:00
Aayush Rajasekaran 1a708b2e2a Resolve miner address before trying to verify ask siggy 2020-04-24 01:01:22 -04:00
Łukasz Magiera ab776352b1 Merge pull request #1595 from filecoin-project/feat/update-badger
update badger
2020-04-24 02:51:51 +02:00
Łukasz Magiera 15e07b38b6 Merge pull request #1594 from filecoin-project/fix/api-tags
apistruct: Check tags in tests
2020-04-24 02:47:12 +02:00
Jeromy e34ae07b9a update badger 2020-04-23 17:44:58 -07:00
Łukasz Magiera a28e64227b apistruct: Check tags in tests 2020-04-24 02:41:18 +02:00
Travis PersonandTravis Person 1b6aa537d3 fountain: decode peer id (#1593)
Co-authored-by: Travis Person <travisperson@users.noreply.github.com>
2020-04-23 17:34:31 -07:00
Łukasz Magiera 88ccd73139 Merge pull request #1592 from filecoin-project/feat/pond-methodgen
pond: Method mapping generator
2020-04-24 02:17:38 +02:00
Łukasz Magiera db2e1fc2c4 Merge pull request #1591 from filecoin-project/feat/import-analyze
add command to analyze import bench output
2020-04-24 02:14:49 +02:00
Łukasz Magiera fbd346a36b pond: Method mapping generator 2020-04-24 02:13:48 +02:00
Jeromy 7ee42e61d5 add command to analyze import bench output 2020-04-23 16:48:54 -07:00
Łukasz Magiera 9b55f4b471 Merge pull request #1578 from filecoin-project/cleanup/lotus-bench
Cleanup/lotus bench
2020-04-24 01:21:41 +02:00
Jeromy 86ccaa1981 properly load in registered proof type when benchmarking existing sectors 2020-04-24 01:16:26 +02:00
Jeromy a9b62bcc5c small amount of cleanup for lotus bench 2020-04-24 01:16:26 +02:00
Łukasz Magiera 016d0d15c3 Merge pull request #1588 from filecoin-project/feat/check-deps
Add tests for api depending on ffi
2020-04-24 01:08:02 +02:00
Łukasz Magiera da7db5fa98 Merge remote-tracking branch 'origin/testnet/3' into feat/check-deps 2020-04-24 00:59:15 +02:00
Łukasz Magiera 322ab8fd6f Merge pull request #1569 from filecoin-project/feat/dht-upgrade
Upgrade DHT Version
2020-04-24 00:57:56 +02:00
Jeromy 8ee296d130 fix tests 2020-04-23 15:53:24 -07:00
Łukasz Magiera e6ce6211de Merge remote-tracking branch 'origin/testnet/3' into feat/dht-upgrade 2020-04-24 00:50:23 +02:00
Łukasz Magiera 96f9d58066 Merge pull request #1575 from filecoin-project/feat/estimate-gas-price-api
add an api for estimating gas prices
2020-04-24 00:47:27 +02:00
Jeromy f4948dcba0 remove api dependency on sealing fsm package 2020-04-23 15:33:59 -07:00
Łukasz Magiera 309f54aa0c Update sector-storage 2020-04-23 15:29:31 -07:00
Jeromy ef1d485c6e move head change type out of chainstore package 2020-04-23 15:28:59 -07:00
Jakub Sztandera 041e9e14a2 Add tests for api depending on ffi
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-23 15:28:59 -07:00
Łukasz Magiera 233c84ef3e Merge pull request #1590 from filecoin-project/feat/newminer
Better mining tests, Fix no-sector miner panic
2020-04-24 00:14:19 +02:00
Łukasz Magiera c137b0cf73 Merge remote-tracking branch 'origin/testnet/3' into feat/newminer 2020-04-23 23:53:23 +02:00
Łukasz Magiera 86e7f5914b testing: test 2-miner mining 2020-04-23 23:20:02 +02:00
Łukasz Magiera 40f56243d1 testing: Node test refactoring 2020-04-23 23:16:39 +02:00
WhyrusleepingandŁukasz Magiera faa9002cce working on sector pledge requirements after specs-actors 1.0.0 (#1584)
* WIP: working on sector pledge requirements after specs-actors 1.0.0

* update storage-fsm with pledge collateral logic

* Set bigger balances for miners

* Return only additional required pledge

* split collateral methods into two methods

Co-authored-by: Łukasz Magiera <magik6k@gmail.com>
2020-04-23 12:39:34 -07:00
Łukasz Magiera df5e3f6227 Merge pull request #1589 from filecoin-project/feat/deal-id-in-list-deals-output
add deal identity to client list-deals output
2020-04-23 21:19:11 +02:00
laser 959d91ec65 add deal identity to client list-deals output 2020-04-23 12:08:16 -07:00
Yu DaandDa Yu 9b598e5ec3 fix #1574 (#1583)
* fix #1566

* fix #1566

Co-authored-by: Da Yu <dayu26@dadeMacBook-Pro.local>
2020-04-23 09:44:25 -07:00
Aayush Rajasekaran 58fe29d705 Merge pull request #1481 from jsign/jsign/testnet3/DoubleTestAPIDealFlowFAIL
Double Deal Flow test
2020-04-23 12:19:40 -04:00
Łukasz Magiera 70f21d6ca5 Merge pull request #1586 from yaohcn/fix/deploy-node-script
fix deploy node sh
2020-04-23 14:12:20 +02:00
yaohcn ecdedd33e2 fix deploy node sh 2020-04-23 16:48:31 +08:00
Whyrusleeping b761a2994b Merge pull request #1582 from filecoin-project/fix/fountain-proper-peerid
fountain: use proper peerid
2020-04-22 20:20:16 -07:00
Travis Person 1169fb4b86 mod tidy 2020-04-23 03:13:03 +00:00
Whyrusleeping c4302ddc1f Merge pull request #1581 from filecoin-project/fix/send-msg-cid
make send print its cid
2020-04-22 20:11:56 -07:00
Travis Person 332b6b9e0a fountain: use proper peerid 2020-04-23 02:57:47 +00:00
Jeromy 42c5c6b4e4 make send print its cid 2020-04-22 19:57:11 -07:00
Łukasz Magiera c89c21b47a Merge pull request #1579 from filecoin-project/fix/chainwatch-sql
chainwatch: fix sql syntax error
2020-04-23 01:08:35 +02:00
Travis Person 4e1dddab67 chainwatch: fix sql syntax error 2020-04-22 22:57:17 +00:00
Jeromy 1d5059c281 add tipsetkey to estimate gas api 2020-04-22 15:37:59 -07:00
Jeromy 7e7caa8859 more expressive estimate gas api 2020-04-22 15:28:51 -07:00
Jeromy 18f4e9d828 enable autonat service 2020-04-22 15:28:01 -07:00
Łukasz Magiera 93b30ab865 Merge pull request #1565 from filecoin-project/feat/retrieval-market-#1552
Feat/retrieval market #1552
2020-04-22 23:10:04 +02:00
Łukasz Magiera f7228f9465 gofmt 2020-04-22 23:09:43 +02:00
shannonwells f0fec60841 ensure unlock on error 2020-04-22 13:58:26 -07:00
Łukasz Magiera 6b2b2b678f Merge pull request #1577 from filecoin-project/fix/dont-empty-post
post: Don't send empty posts
2020-04-22 21:20:47 +02:00
Łukasz Magiera 262d7b2372 post: Don't send empty posts 2020-04-22 21:16:19 +02:00
Jeromy 9c704db12b mod tidy 2020-04-22 11:17:21 -07:00
Adin Schmahmann 9199c03f0d disable using the DHT to find provider records or arbitrary values 2020-04-22 11:13:26 -07:00
Adin Schmahmann 744a02eb5a update DHT options and use automatic DHT mode switching 2020-04-22 11:13:25 -07:00
Adin Schmahmann 83ad29648e update dht deps 2020-04-22 11:12:23 -07:00
Łukasz Magiera c8d23b5947 Merge pull request #1576 from filecoin-project/feat/reverse-lookup
cli: state lookup --reverse
2020-04-22 18:44:15 +02:00
Łukasz Magiera b621754514 cli: state lookup --reverse 2020-04-22 18:38:09 +02:00
Jeromy 2a97045317 add an api for estimating gas prices 2020-04-22 09:37:38 -07:00
Łukasz Magiera c64dbfcf40 Merge pull request #1571 from diwufeiwen/patch-1
Update miners.go
2020-04-22 14:46:59 +02:00
Łukasz Magiera 05df832ae4 Merge pull request #1572 from filecoin-project/fix/seed-merge-set-peerid
lotus-seed: preserve first peerid during merge
2020-04-22 14:42:49 +02:00
Łukasz Magiera f1ea33c658 Merge pull request #1573 from filecoin-project/fix/specs-actor-version
deps: update specs-actors due to lost commit during squash
2020-04-22 11:17:32 +02:00
Travis Person 8f500046ac deps: update specs-actors due to lost commit during squash 2020-04-22 02:38:56 +00:00
Travis Person 3285dd0cf1 lotus-seed: preserve first peerid during merge 2020-04-22 02:05:35 +00:00
diwufeiwen d873d8489d Update miners.go
Remove code that does n’t make sense
2020-04-22 10:00:57 +08:00
shannonwells 28c5697578 separate lock/unlock and do independent waiting per PR comments 2020-04-21 16:19:40 -07:00
shannonwells a9c98eab8d call paychmgr wait funcs, make sure tests are passing 2020-04-21 16:19:40 -07:00
shannonwells 162784e98f updates after rebase against feat/windowed-post 2020-04-21 16:19:40 -07:00
shannonwells 3ca71e146c missed return value 2020-04-21 16:19:40 -07:00
shannonwells fd7f4ef080 begin implementing funcs to support latest go-fil-markest retrieval market API 2020-04-21 16:19:40 -07:00
Ignacio Hagopian 1f2b767696 testnet/3 rebasing
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-04-21 19:38:04 -03:00
Ignacio Hagopian 1e810eb2c8 avoid rename after refactor
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-04-21 19:38:04 -03:00
Ignacio Hagopian 95c13ddd92 Double Deal Flow test failing
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-04-21 19:38:04 -03:00
Whyrusleeping f960cccc51 Merge pull request #1568 from filecoin-project/feat/fix-reward-redeem
fix reward redeem command to work again
2020-04-21 15:23:49 -07:00
Łukasz Magiera 4d5e3201c3 Merge pull request #1522 from filecoin-project/feat/windowed-post
Windowed PoSt
2020-04-22 00:15:56 +02:00
Jeromy e3f2dfaec0 fix reward redeem command to work again 2020-04-21 14:45:33 -07:00
Łukasz Magiera 9f9ae155e3 windowed post: Review cleanup 2020-04-21 23:38:33 +02:00
Łukasz Magiera eba0743d47 bench: --num-sectors option 2020-04-21 21:47:07 +02:00
Łukasz Magiera 24c764c91e Don't print QAPower as bytes 2020-04-21 21:46:50 +02:00
Łukasz Magiera f10eed3ae3 genesis: Setup verifier registry 2020-04-21 20:25:43 +02:00
Łukasz Magiera 9923c909c1 Merge remote-tracking branch 'origin/testnet/3' into feat/windowed-post 2020-04-21 19:28:00 +02:00
Łukasz Magiera c406b875fa gofmt, mod tidy 2020-04-21 19:23:49 +02:00
Łukasz Magiera 8be9494672 windowed post: Get correct sector set 2020-04-21 19:22:53 +02:00
Łukasz Magiera fcc51f3591 cli: Support --tipset in chain get /pstate 2020-04-21 17:07:12 +02:00
Łukasz Magiera c2806fe189 cli: allow specyfying tipset by @height 2020-04-21 17:06:54 +02:00
Łukasz Magiera f43ce74604 Update specs-actors 2020-04-21 16:32:17 +02:00
Łukasz Magiera 00eb0e6378 genesis: Add sectors to NewSectors set 2020-04-21 14:36:54 +02:00
Łukasz Magiera b941b29fe5 miner: Use correct randomness for sealing 2020-04-20 20:33:53 +02:00
Łukasz Magiera ecc38d1bd8 sync: env var to fix drand 2020-04-20 20:33:53 +02:00
Łukasz Magiera d99f40797e sync: env var to fix drand 2020-04-20 19:43:02 +02:00
Łukasz Magiera a86595bc88 Use nicer DeadlineInfo struct 2020-04-20 19:34:08 +02:00
Łukasz Magiera 851a7dc180 Merge pull request #1562 from filecoin-project/fix/websocket-client-disconnects
handle websocket clients disconnecting more properly
2020-04-20 18:55:46 +02:00
Jeromy 216072468f handle websocket clients disconnecting more properly 2020-04-20 09:52:16 -07:00
Łukasz Magiera 6dd2f5369e genesis: Fix importing 8k+ deals 2020-04-20 15:54:06 +02:00
Łukasz Magiera 32e45557fa Merge pull request #1558 from filecoin-project/fix/faucet-rate-limit
Rate limit fix
2020-04-18 02:28:52 +02:00
Łukasz Magiera f11b1bbbeb mpool: get nonce for correct address 2020-04-18 02:25:43 +02:00
Whyrusleeping bb7bb2600a Merge pull request #1559 from filecoin-project/fix/commp-convert-cmd
parse input as hex
2020-04-17 17:25:16 -07:00
Jeromy 2de6a38c8b update docs 2020-04-17 17:12:39 -07:00
Jeromy 3962194fad parse input as hex 2020-04-17 17:09:09 -07:00
Łukasz Magiera 9c5cda0efa Merge pull request #1557 from filecoin-project/feat/power-table-lookback
Use lookback to get sector set and power for miners
2020-04-18 01:53:54 +02:00
Jeromy 91f56742c4 Use lookback to get sector set and power for miners 2020-04-17 16:44:18 -07:00
Łukasz Magiera fe6d666150 Get all tests to pass 2020-04-18 01:14:39 +02:00
Łukasz Magiera 99a3902c07 Fix deal flow tests 2020-04-18 01:13:02 +02:00
Łukasz Magiera ba73b9d3c4 Fix DealFlow test 2020-04-18 01:01:11 +02:00
Łukasz Magiera 3b7ae0d6d9 mod tidy, gofmt 2020-04-18 00:02:43 +02:00
Łukasz Magiera 712e2683d6 miner: proving info commands 2020-04-18 00:02:18 +02:00
Jeromy 073962a60d resolve addresses to IDs for checks 2020-04-17 14:23:30 -07:00
Jeromy 24b7661837 fix up some tests 2020-04-17 13:44:13 -07:00
Łukasz Magiera e6270e4291 Update fsm; get sectorset form correct ts 2020-04-17 21:49:32 +02:00
Travis Person 850803f138 Rate limit fix 2020-04-17 18:24:29 +00:00
Łukasz Magiera a40872f74d Merge pull request #1554 from filecoin-project/feat/increase-gen-gas
increase gas limit during genesis generation
2020-04-17 19:54:55 +02:00
Łukasz Magiera 8e13920e7b cbor-gen 2020-04-17 19:53:09 +02:00
Łukasz Magiera 8828668541 mpool: Adjust sends from ID addresses 2020-04-17 18:47:14 +02:00
Łukasz Magiera 93b2b6d65d Merge branch 'testnet/3' into feat/windowed-post 2020-04-17 18:38:20 +02:00
Łukasz Magiera ebc2895d15 gofmt, mod tidy 2020-04-17 18:27:11 +02:00
Łukasz Magiera 95bd55b754 Merge pull request #1544 from dayu26/interopnet_dy
fix error "unknown address protocol" when run lotus msig create in cli/…
2020-04-17 18:25:13 +02:00
Łukasz Magiera f7666bc641 Drop commented-out code 2020-04-17 18:24:23 +02:00
Łukasz Magiera 769cf43b52 seed: Set valid PeerIDs 2020-04-17 18:22:17 +02:00
Łukasz Magiera cdbf79fff5 non-debug 2k sector build mode 2020-04-17 17:58:20 +02:00
Łukasz Magiera bab352fb44 Wireup WinningPost validation 2020-04-17 16:47:19 +02:00
Jeromy 708988244d WIP: working on winning post integration 2020-04-16 22:39:55 -07:00
Jeromy 4153f128ef a more betterer supply impl 2020-04-16 16:03:38 -07:00
Łukasz Magiera 706c0b8d3a Stub syscalls.TotalFilCircSupply 2020-04-17 00:19:54 +02:00
Łukasz Magiera 15a4565714 Fix deal publishing 2020-04-16 23:43:39 +02:00
Łukasz Magiera 918b759d03 mpool: Fix PushWithNonce for ID addresses 2020-04-16 23:06:31 +02:00
Łukasz Magiera 50a8b6a184 Update GetMinerSlashed 2020-04-16 22:52:40 +02:00
Łukasz Magiera dc2a67f13f Fix worker key resolving 2020-04-16 22:38:42 +02:00
Whyrusleeping 0db5fc422a Merge pull request #1534 from filecoin-project/patch/syscalls
VerifyConsensusFault syscall impl
2020-04-16 13:33:58 -07:00
Łukasz Magiera 6eaafcf79d wireup windowPost scheduling logic to miner actor 2020-04-16 22:11:07 +02:00
Whyrusleeping 06970a662c Merge pull request #1524 from filecoin-project/asr/vmminer
Two minor improvements
2020-04-16 13:06:03 -07:00
Henri S 8594af970f fix typo: 2020-04-16 15:52:49 -04:00
Aayush Rajasekaran 6a8e4bf87e Lower a log level 2020-04-16 15:34:01 -04:00
Aayush Rajasekaran 4a93ad33f9 Propose Deal: Fail early if data doesn't fit in a sector 2020-04-16 15:34:01 -04:00
Aayush Rajasekaran 14ad808a00 Remove unused fields from VM 2020-04-16 15:34:01 -04:00
Łukasz Magiera afdfc8807d api: Single method for static miner info 2020-04-16 19:36:36 +02:00
Łukasz Magiera 8338be3a6e Fix genesis creation 2020-04-16 19:17:56 +02:00
Łukasz Magiera 98f3cab24e Update specs-actors 2020-04-16 18:41:45 +02:00
Łukasz Magiera f88e400d74 make things build 2020-04-16 00:17:39 +02:00
Łukasz Magiera 246a9f0e45 gofmt 2020-04-15 22:41:20 +02:00
Łukasz Magiera 85993848be bring back api.StateMinerProvingSet 2020-04-15 22:40:46 +02:00
Łukasz Magiera 0336b32fcd windowpost: Wire up challenge generation 2020-04-15 22:22:58 +02:00
Travis Person 16347270e0 increase gas limit during genesis generation 2020-04-15 20:09:33 +00:00
Łukasz Magiera 149bb56b8e wip updates to sector set handling 2020-04-15 21:59:11 +02:00
Whyrusleeping 8a83415596 Merge pull request #1541 from filecoin-project/feat/drand-2
real drand network integration
2020-04-15 11:22:00 -07:00
Aayush Rajasekaran c0204cdd83 Add a shed command to turn raw commPs into CIDs 2020-04-15 14:01:00 -04:00
Aayush Rajasekaran efd435d763 Treat proposed deals as manual iff a commP is provided 2020-04-15 14:00:53 -04:00
Aayush Rajasekaran fc933858e1 Add an API method to calculate piece CIDs 2020-04-15 14:00:42 -04:00
Jakub Sztandera c34fb24cef Reove 2048 min power in shared params
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-15 16:49:17 +02:00
Jakub Sztandera 56eaf143db fix lint
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-15 16:37:03 +02:00
Jakub Sztandera c2db85b99b mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-15 16:36:21 +02:00
Jakub Sztandera 08e74a90f9 Add missing files
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-15 16:13:20 +02:00
Jeromy 05536042f9 drop outdated comment 2020-04-14 16:37:10 -07:00
Jeromy 4e6839b5ef some small cleanup 2020-04-14 15:13:52 -07:00
Jakub Sztandera 0feab0aad4 Bake drand public key into build params
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 22:34:44 +02:00
Jakub Sztandera 0c5e3e2533 Make tests use mock beacon
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 20:41:05 +02:00
Jakub Sztandera eb501f7290 Cache more
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 19:55:53 +02:00
Jakub Sztandera 5ab9636365 Call VerifyBeacon, hack around genesis
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 16:52:18 +02:00
Jakub Sztandera 624dd7d2ce Verify PrevRound too
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 16:18:34 +02:00
Jakub Sztandera 3e976fd74b Make tests pass
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-14 16:09:11 +02:00
Da Yu 2a10a79460 fix error unknown address protocol when run lotus msig create in cli/mutisig.go 2020-04-14 17:18:19 +08:00
Jeromy 674be39af1 real drand network integration 2020-04-13 20:06:10 -07:00
Łukasz Magiera e4641fc7ed bench: Also bench windowed post 2020-04-14 00:17:37 +02:00
Łukasz Magiera 5bf80a60f1 Get proof type in NewWinningPoStProver constructor 2020-04-13 23:25:46 +02:00
Łukasz Magiera bb3789b130 Fix ADT uses 2020-04-13 23:06:11 +02:00
Łukasz Magiera ac8aaf2739 chain cli: Update slash-consensus cmd 2020-04-13 23:05:16 +02:00
Łukasz Magiera 349b2890bf Drop 'rewards list' for now 2020-04-13 22:43:27 +02:00
Łukasz Magiera 2db9c24817 genesis: Update power state construction 2020-04-13 22:41:05 +02:00
Łukasz Magiera ff5494af4e Cleanup gohacks, use ffi master 2020-04-13 22:21:13 +02:00
Henri S a4cdfe89fd fix parent grinding check 2020-04-13 15:55:53 -04:00
Henri S 23dc776bd1 finalize logic, still need to import appropriate fields to the shim 2020-04-13 15:55:53 -04:00
Henri S aa5cec39ca first stab 2020-04-13 15:55:53 -04:00
Łukasz Magiera 704978a6ba genesis: Set ssize in VerifyDealsOnSectorProveCommitParams 2020-04-11 01:46:55 +02:00
Łukasz Magiera a2554952d1 Some electionPoSt -> winningPoSt renaming 2020-04-11 00:22:45 +02:00
Łukasz Magiera d3ffe48fcb Get things to mostly build 2020-04-10 23:29:05 +02:00
Łukasz Magiera e053cd6b9c Merge remote-tracking branch 'origin/testnet/3' into feat/windowed-post 2020-04-10 23:09:01 +02:00
Łukasz Magiera 613e61222b mostly wire up WindowedPoSt 2020-04-10 23:07:18 +02:00
Łukasz Magiera 3426611340 Merge pull request #1526 from filecoin-project/feat/pass-deal-schedule-for-pre-commit-expiry-scheduling
provide deal scheduling info to FSM so that it can set pre-commit expiry
2020-04-10 23:05:50 +02:00
Łukasz Magiera 1c75bf30ac genesis: Try updating for QA power 2020-04-10 22:04:04 +02:00
Łukasz Magiera 072dd8b744 Merge remote-tracking branch 'origin/testnet/3' into feat/windowed-post 2020-04-10 20:38:25 +02:00
Łukasz Magiera 0f0015f45c Merge pull request #1520 from filecoin-project/feat/graphsync-chainsync-extension
Update to latest go-fil-markets w/ enhanced Graphsync
2020-04-10 20:27:05 +02:00
laser 19573c0319 adjust imports to conform to convention 2020-04-10 08:22:28 -07:00
laser 4a12a98451 set pre-commit expiration to 10000000, which was original value in FSM 2020-04-10 08:22:28 -07:00
laser 6dffe9377f provide deal scheduling info to FSM so that it can set pre-commit expiry 2020-04-10 08:22:28 -07:00
Łukasz Magiera b0fe8b8b4c v25: get bench to almost work 2020-04-10 14:19:06 +02:00
Łukasz Magiera 37e7c512e6 Update ffi (v25 proofs) 2020-04-09 23:17:23 +02:00
Łukasz Magiera 70d654e4a6 Merge pull request #1527 from filecoin-project/feat/drand
Initial randomness beacon implementation
2020-04-09 19:48:09 +02:00
Jeromy 09b013b7a5 close resp chan 2020-04-09 10:35:43 -07:00
Jeromy 83416e2758 remove deadcode 2020-04-09 10:34:54 -07:00
Jeromy ac271b021d finish addressing review 2020-04-09 10:13:09 -07:00
Jakub Sztandera 7ee6388686 Make drand build
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-09 14:39:51 +02:00
Jakub Sztandera 029ffc2dc3 go mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-09 14:33:37 +02:00
Jeromy 1a3ab63e47 WIP: drand client integration 2020-04-08 19:55:17 -07:00
Jeromy c5c18659a4 address some review 2020-04-08 17:24:10 -07:00
Whyrusleeping 4bf784b44f Merge pull request #1529 from filecoin-project/asr/type
Sever the API's dependency on VM
2020-04-08 16:25:00 -07:00
Jeromy ef6fb1b756 rename beacon to randombeacon 2020-04-08 16:10:08 -07:00
Aayush Rajasekaran 17e9feb633 Sever the API's dependency on VM 2020-04-08 18:27:31 -04:00
Jakub Sztandera 1bd28bdb6a Fix lint errors
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:37:04 +02:00
Jakub Sztandera f17929f032 Change lint-changes to base of testnet/3
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:30:37 +02:00
Jakub Sztandera 661d373fa2 Fix blockheader tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:27:55 +02:00
Jakub Sztandera d909119bb6 Make debug_advance build, still doesn't work
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:19:17 +02:00
Jakub Sztandera f4f649acf4 Fix chainwatch
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:17:44 +02:00
Jakub Sztandera d71ba5039b Merge branch 'feat/drand' of github.com:filecoin-project/lotus into feat/drand
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:08:35 +02:00
Jakub Sztandera ce4978d8c3 Reintroduce correct ticket randomness alongside ElectionProof
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 21:06:41 +02:00
Whyrusleeping 69353e8210 Merge pull request #1516 from jsign/jsign/fixdockerfile
docker: fix build, upgrade Go
2020-04-08 11:15:19 -07:00
Jeromy be85f2aff7 handle beacon gaps 2020-04-08 10:49:50 -07:00
Jakub Sztandera 9a17beba9e Skip block header test vectors
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 18:48:47 +02:00
Jakub Sztandera 2d2b89fcd8 make debug_advance build
Still doesn't work

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 18:46:57 +02:00
Jakub Sztandera f1c890ca54 Tests pass
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 18:31:16 +02:00
Jeromy 8e0ca306d2 more wiring up of drandomness 2020-04-08 08:11:42 -07:00
Łukasz Magiera 2b0bf372a7 Merge pull request #1507 from filecoin-project/feat/completions
Shell completions
2020-04-08 16:29:18 +02:00
Jakub Sztandera c16806eb78 gofmt
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-08 14:54:06 +02:00
hannahhoward cda2be93f5 fix(deps): update gs/data-transfer/markets to master 2020-04-07 23:27:41 -07:00
hannahhoward 00cd89750d feat(deps): update fil-markets, graphsync
Updates dependencies for graphsync, fil-markets, data-transfer. Moves to new graphsync blockstore
swapping capabilities, and also locks down graphsync impl so it does not accept arbitrary requests
2020-04-07 23:25:29 -07:00
Aayush Rajasekaran 1120298b05 Merge pull request #1523 from filecoin-project/asr/docs
Add info for miners who want to accept storage deals
2020-04-07 20:51:21 -04:00
Aayush Rajasekaran d73a9f4f34 Add info for miners who want to accept storage deals 2020-04-07 20:40:44 -04:00
Jeromy 056284c00b wip: chain sync winner check 2020-04-07 15:54:01 -07:00
Jakub Sztandera 9fd1b95fd5 Fix build errors
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-07 15:32:23 -07:00
Jakub Sztandera 9c250f24fa Nex wip
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-07 15:32:23 -07:00
Jakub Sztandera afdb1db529 drand wip
,
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-07 15:32:23 -07:00
Jeromy 7075eaba26 WIP: random beacon interface
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-07 15:32:23 -07:00
Łukasz Magiera 09aa1507c8 v25 proof parameters 2020-04-07 21:59:22 +02:00
Łukasz Magiera e36f356908 wip changes for windowed post 2020-04-07 21:55:34 +02:00
Łukasz Magiera f2dd0f046e wdpost: Make chain notif loop reconnect friendly 2020-04-07 20:02:52 +02:00
Łukasz Magiera 5524241645 fpost -> windowPost renaming 2020-04-07 19:41:41 +02:00
Łukasz Magiera 7e96b15091 Merge pull request #1519 from filecoin-project/feat/extracted-fsm
consume newly-extracted storage FSM
2020-04-07 18:42:53 +02:00
Łukasz Magiera 9b99850585 Merge pull request #1521 from filecoin-project/interopnet
New interop network info
2020-04-07 18:36:37 +02:00
laser 110c869dd3 cut over to storage-fsm, deleting local sealing package 2020-04-07 09:34:09 -07:00
Travis Person 6603fc5975 Add new bootstrapper 2020-04-07 05:09:46 +01:00
Travis Person 298e942edf New interop network info 2020-04-07 03:50:15 +01:00
Łukasz Magiera 086a66efc9 Merge pull request #1517 from filecoin-project/feat/lotus-agnostic-node-interface
remove lotus types from sealing package in preparation for extraction
2020-04-07 00:42:30 +02:00
laser 43f4db2308 SectorID -> SectorNumber 2020-04-06 15:31:33 -07:00
Łukasz Magiera 4ee8254133 Merge pull request #1510 from filecoin-project/feat/fsm-updates
FSM Updates
2020-04-06 23:11:46 +02:00
laser 0170418fc1 revert name change 2020-04-06 14:05:26 -07:00
laser c268b5b7ac use latest sector-storage 2020-04-06 13:42:27 -07:00
laser 2f4732760a update CBOR encoders/decoders 2020-04-06 13:35:29 -07:00
laser ab44ae1354 move to types 2020-04-06 13:31:49 -07:00
laser 2781e16ef4 go mod tidy 2020-04-06 13:27:27 -07:00
laser f53250ee90 reorder imports 2020-04-06 13:27:14 -07:00
laser dcd9e7da27 miscellaneous fixes post-rebase 2020-04-06 13:23:37 -07:00
laser 650a31b050 remove all lotus types from sealing package in preparation for extraction
events adapter

implement StateWaitMsg and StateComputeDataCommitment

implement StateGetSectorPreCommitOnChainInfo

implement ChainHead and SendMsg

implement remaining methods
2020-04-06 12:57:55 -07:00
Jeromy 3ad16c58d7 cache address resolutions in state tree 2020-04-06 12:32:22 -07:00
Łukasz Magiera 6c285898a8 Merge pull request #1513 from filecoin-project/fix/miner-remote-sealer-addr
Fix/miner remote sealer addr
2020-04-06 20:36:44 +02:00
Łukasz Magiera 68fa9f20c3 Merge pull request #1511 from filecoin-project/fix/runtime-exit-edge-cases
handle some runtime error edge cases
2020-04-06 20:34:22 +02:00
Ignacio Hagopian 312bab0843 docker: fix build, upgrade Go
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-04-06 11:25:18 -03:00
Łukasz Magiera 8448771ce6 Merge pull request #1512 from filecoin-project/feat/cache-addr-resolves
cache address resolutions in state tree
2020-04-04 05:06:31 +02:00
Łukasz Magiera f05be81275 fsm: Get correct interactive randomness if it lands on a nullblock 2020-04-04 04:57:05 +02:00
Łukasz Magiera 303d4a31fe fsm: Handle invalid Commits 2020-04-04 03:50:05 +02:00
Łukasz Magiera 9a7aa3fc87 chain get: @Hu: for uvaring hamt keys 2020-04-04 03:49:42 +02:00
lanzafame 209e8b3041 only add RemoteListenAddress to StorageMinerNode config 2020-04-04 09:56:52 +10:00
Jeromy bb6e8de056 cache address resolutions in state tree 2020-04-03 16:26:52 -07:00
Jeromy ab51501849 remove todo 2020-04-03 15:50:52 -07:00
Jeromy 2d5becaaba further removals 2020-04-03 15:05:59 -07:00
Jeromy 4c6fa1b2c0 handle some runtime error edge cases 2020-04-03 14:38:11 -07:00
Łukasz Magiera 4d92798f5b fsm: Update cbor-gen 2020-04-03 21:34:20 +02:00
Łukasz Magiera 6284fad33e fsm: Implement handlers for Commit errors 2020-04-03 19:45:48 +02:00
Łukasz Magiera a63a0b3077 sealing fsm: Separate precommit 1/2 2020-04-03 18:54:15 +02:00
Łukasz Magiera 147e18e28e fsm: Fix tests after changisg SectorState to a string 2020-04-03 18:36:48 +02:00
Łukasz Magiera a1b35aa9d5 Change api.SectorState to a string 2020-04-03 18:29:31 +02:00
Łukasz Magiera 847bdb203a Merge pull request #1508 from filecoin-project/feat/reward-list-fil
rewards cli: Print amount in list as Fil
2020-04-03 15:39:06 +02:00
Łukasz Magiera 2ddbb19c3a Merge pull request #1509 from filecoin-project/feat/update-ffi-paths
Update FFI
2020-04-03 15:38:48 +02:00
Łukasz Magiera 23d6dc67cf Update FFI 2020-04-03 07:04:40 +02:00
lanzafame 27e81f37f3 fix todo comment 2020-04-03 15:01:39 +10:00
lanzafame 3ba2b0e365 instead of guessing the address, just use a config value 2020-04-03 14:54:07 +10:00
Łukasz Magiera dd6adcd240 rewards cli: Print amount in list as Fil 2020-04-03 06:31:59 +02:00
Łukasz Magiera 5b6bbfe903 Merge pull request #1506 from filecoin-project/feat/faster-snapshots
avoid flushing disk when doing state tree snapshots
2020-04-03 04:04:57 +02:00
Łukasz Magiera 2bdedefa05 Shell completions 2020-04-03 04:03:53 +02:00
Jeromy 7a475d5ca5 drop outdated comment 2020-04-02 18:52:18 -07:00
Jeromy 89b15c03cf nil out layers when dropping to allow for GC 2020-04-02 18:20:49 -07:00
Jeromy 212c346c21 avoid flushing disk when doing state tree snapshots 2020-04-02 17:18:25 -07:00
Łukasz Magiera 11777c5f24 Merge pull request #1502 from filecoin-project/feat/import-bench
add a command to lotus-bench to benchmark importing and validating
2020-04-03 01:30:12 +02:00
Jeromy beaa3dffab add a command to lotus-bench to benchmark importing and validating a chain 2020-04-02 16:18:38 -07:00
Łukasz Magiera d060dda0c5 Merge pull request #1505 from filecoin-project/fix/pond-tskeys
pond: Use tipestKeys for state calls
2020-04-03 01:17:01 +02:00
Łukasz Magiera 91c9f447cd Merge pull request #1504 from filecoin-project/interopnet
New interop network info
2020-04-03 01:11:17 +02:00
Łukasz Magiera 0417e4bd0c pond: Use tipestKeys for state calls 2020-04-03 01:09:31 +02:00
Whyrusleeping a5552e4c36 Merge pull request #1496 from filecoin-project/feat/shed-importcar
shed: import-car for state debugging
2020-04-02 15:29:41 -07:00
Travis Person 698f529602 New interop network info 2020-04-02 23:02:40 +01:00
Łukasz Magiera 48821e6272 Merge pull request #1501 from filecoin-project/fix/aerrors-exitcode-type
use exitcode type from specs actors instead of byte
2020-04-02 21:04:32 +02:00
Jeromy 8a265a0e8d use exitcode type from specs actors instead of byte 2020-04-02 11:24:38 -07:00
Łukasz Magiera c7e206b993 Merge pull request #1498 from filecoin-project/interopnet
New interop network info
2020-04-02 07:07:50 +02:00
Travis Person c41ad767c5 New interop network info 2020-04-02 05:55:24 +01:00
Łukasz Magiera 31571cf655 Merge pull request #1497 from filecoin-project/fix/gas-rewards
use gas used in block rewards
2020-04-02 06:18:33 +02:00
whyrusleeping aa23266c6f use gas used in block rewards 2020-04-01 21:16:16 -07:00
Łukasz Magiera acfb7cee07 shed: import-car for state debugging 2020-04-02 05:28:35 +02:00
Łukasz Magiera f6adbc369a Merge pull request #1495 from filecoin-project/feat/mining-use-base-state
Add GetMiningBaseInfo api and use it for mining
2020-04-02 04:36:56 +02:00
Jeromy fe1d61b276 also use correct set when validating blocks 2020-04-01 18:39:38 -07:00
Jeromy c55501024e remove hacky bits 2020-04-01 18:25:58 -07:00
Jeromy 5b9ee1dea9 Add GetMiningBaseInfo api and use it for mining 2020-04-01 18:15:25 -07:00
Łukasz Magiera 7bbc8a4652 Merge pull request #1491 from filecoin-project/feat/sm-init-ssize-str
storageminer: Parse pretty sector sizes in init
2020-04-02 00:27:39 +02:00
Łukasz Magiera 67a47f428f Merge pull request #1492 from filecoin-project/feat/wallet-import-gfc
allow wallet import to import keys in go-filecoin key format
2020-04-02 00:04:22 +02:00
Łukasz Magiera f15eb8b172 Merge pull request #1487 from filecoin-project/fix/partial-sync-responses
properly handle partial sync responses
2020-04-02 00:03:25 +02:00
Jeromy fb287e8385 allow wallet import to import keys in go-filecoin key format 2020-04-01 15:01:14 -07:00
Łukasz Magiera fa86359549 storageminer: Parse pretty sector sizes in init 2020-04-01 23:56:49 +02:00
Łukasz Magiera 7ef08bfbdf Merge pull request #1490 from filecoin-project/fix/charge-gas
Fix charge gas in case of overcharge
2020-04-01 23:00:28 +02:00
Jakub Sztandera ff510b7542 Merge pull request #1489 from filecoin-project/feat/disable-bst-buf
bufbs: Env var to disable blockstore buffering
2020-04-01 22:56:54 +02:00
Jakub Sztandera 013f441658 Fix charge gas in case of overcharge
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-01 22:55:10 +02:00
Łukasz Magiera 565099f06f Merge pull request #1488 from filecoin-project/feat/rbf
Add Replace by Fee
2020-04-01 22:45:01 +02:00
Łukasz Magiera f727f1db26 bufbs: Env var to disable blockstore buffering 2020-04-01 22:37:34 +02:00
Jakub Sztandera d88c2f8a43 Add Replace by Fee
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-04-01 22:26:14 +02:00
Jeromy 27d57264d9 properly handle partial sync responses 2020-04-01 11:35:09 -07:00
Łukasz Magiera f6c260c49f Merge pull request #1484 from filecoin-project/fix/interop-improvements
several fixes and improvements while debugging interop
2020-04-01 17:51:42 +02:00
Łukasz Magiera cdd97ce959 Revert ticket compare function to comparing vrf hashes 2020-04-01 17:44:51 +02:00
Jeromy 417d434973 several fixes and improvements while debugging interop 2020-03-31 18:35:23 -07:00
Whyrusleeping 12f288016d Merge pull request #1483 from filecoin-project/feat/chain-get-pstate
chain get: /pstate prefix
2020-03-31 17:13:41 -07:00
Łukasz Magiera 77a84e7e6b Merge remote-tracking branch 'origin/testnet/3' into feat/chain-get-pstate 2020-04-01 02:09:33 +02:00
Łukasz Magiera 7d2f9366b4 Merge pull request #1482 from filecoin-project/feat/netname-from-genesis
Get network name from genesis
2020-04-01 02:06:42 +02:00
Łukasz Magiera 4ae1238c0c chain get: /pstate prefix 2020-04-01 02:06:26 +02:00
Łukasz Magiera 13f2c21e1d Get network name from genesis 2020-04-01 01:15:49 +02:00
Whyrusleeping ea135991e3 Merge pull request #1480 from filecoin-project/feat/better-deal-info
Better deal info at the command line
2020-03-31 13:29:07 -07:00
Whyrusleeping 0526ee8042 Merge pull request #1472 from jsign/jsign/testnet3/badfiledescriptor
fix ClientRetrieve with CAR exporting & add test coverage
2020-03-31 13:28:00 -07:00
hannahhoward ae3f7522f0 feat(cli): use MarketListIncompleteDeals for miner deals cmd
Switch from DealsList to MarketListIncompleteDeals which (while poorly named) provides much more
information about what's happening with a miners deals
2020-03-31 11:54:37 -07:00
hannahhoward 0c69e99b7c feat(cli): add message to deal output
Add the message field to deal output for client deals -- message will often contain additional
useful info about what happened with the deal, especially for errors
2020-03-31 11:53:30 -07:00
Whyrusleeping be4ac89b57 Merge pull request #1479 from filecoin-project/interopnet
New interop network info
2020-03-31 11:45:45 -07:00
Travis Person 663e2874a1 New interop network info 2020-03-31 19:38:43 +01:00
Łukasz Magiera 16cc3e94ac Merge pull request #1478 from subvisual/pfac/testnet3-fix-deals-import-arg-check
Fix offline deal import command arguments check
2020-03-31 20:38:29 +02:00
Pedro Costa 5e2a94e22f Fix offline deal import command arguments check
Why:

* It is failing if the number of arguments is the expected one.
2020-03-31 19:18:13 +01:00
Łukasz Magiera b78ea464e5 Merge pull request #1477 from filecoin-project/asr/update
Update chain-validation, enable state root validation
2020-03-31 18:58:52 +02:00
Aayush Rajasekaran 8ec19812e3 Update chain-validation, enable state root validation 2020-03-31 03:09:42 -04:00
Ignacio Hagopian 8f89501118 fix ClientRetrieve with CAR exporting & add test coverage
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-03-30 11:08:20 -03:00
Łukasz Magiera 34e9e9fe34 Merge pull request #1469 from filecoin-project/feat/extract-sectorstorage
Extract sector-storage
2020-03-28 01:44:09 +01:00
Łukasz Magiera 95ee1c1cde Extract sector-storage 2020-03-28 01:32:39 +01:00
Łukasz Magiera eb6bc0399a Merge pull request #1468 from filecoin-project/feat/untangle-secstorage
sectorstorage: Untangle from lotus deps
2020-03-27 22:37:19 +01:00
Łukasz Magiera c66d3dfad7 sectorstorage: Untangle from lotus deps 2020-03-27 22:35:33 +01:00
Łukasz Magiera de1f2be505 Merge pull request #1458 from filecoin-project/feat/merge-sectorbuilder
Merge sectorbuilder into sectorstorage
2020-03-27 18:53:58 +01:00
Łukasz Magiera ddd3b3f587 Merge pull request #1460 from filecoin-project/interopnet
New interop network info
2020-03-27 18:51:30 +01:00
Łukasz Magiera cba97000c8 Merge pull request #1467 from filecoin-project/fix/charge-gas
use charge gas safe in places we return errors
2020-03-27 18:49:03 +01:00
Łukasz Magiera f882c5b229 sectorstorage: Address review 2020-03-27 18:45:32 +01:00
Jeromy 97a7b449e6 use charge gas safe in places we return errors 2020-03-27 10:11:21 -07:00
Łukasz Magiera dc49a81a05 Merge pull request #1463 from filecoin-project/feat/readd-api-flag
re add storage miner api flag
2020-03-27 16:11:26 +01:00
Jeromy 3470ed7847 re add storage miner api flag 2020-03-26 22:19:29 -07:00
Travis Person 93a90fbe82 New interop network info 2020-03-27 03:45:57 +00:00
Whyrusleeping a0b25c3718 Merge pull request #1462 from filecoin-project/fix/low-gas-limit
Increase low gas limits everywhere to 10000
2020-03-26 20:27:35 -07:00
Travis Person 838a50be39 Increase low gas limits everywhere to 10000 2020-03-27 03:24:35 +00:00
Whyrusleeping bb7820cfd7 Merge pull request #1461 from filecoin-project/fix/no-fatal-errors
dont  use fatal errors in the vm
2020-03-26 20:22:08 -07:00
Jeromy 672956af5d addressing review 2020-03-26 20:13:32 -07:00
Jeromy 1b50be09af dont use fatal errors in the vm 2020-03-26 20:03:04 -07:00
Travis Person 59e77ba6c8 Merge pull request #1457 from filecoin-project/feat/exitcodes
Update to new sepcs actors, more debug
2020-03-26 17:54:25 -07:00
Travis Person 090261f304 Revert gas exhausted exit code to SysErrOutOfGas 2020-03-27 00:19:34 +00:00
Jakub Sztandera 06cfbf5742 Switch exitcodes
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 22:11:06 +01:00
Łukasz Magiera e050e0307e Cleanup after dropping sectorbuilder 2020-03-26 20:35:16 +01:00
Jakub Sztandera 326490be86 Fix miner
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 17:26:48 +01:00
Jakub Sztandera 437a418afe update filecoin-ffi
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 17:20:57 +01:00
Jakub Sztandera 7b19e26692 Update filecoin-ffi
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 14:41:02 +01:00
Aayush Rajasekaran dc5159ce74 Update chain-validation, make necessary changes 2020-03-26 06:41:02 -04:00
Aayush Rajasekaran 1e1d0676ae Set system actor's initial state correctly 2020-03-26 06:38:45 -04:00
Łukasz Magiera 4be54a976c Merge sectorbuilder into sectorstorage 2020-03-26 03:51:06 +01:00
Łukasz Magiera ac3ca7981f Merge pull request #1456 from filecoin-project/fix/seal-with-fillers
Fix sealing sectors with multiple pieces
2020-03-26 02:28:34 +01:00
Łukasz Magiera 6399499e9b Fix sealing sectors with multiple pieces 2020-03-26 02:18:13 +01:00
Jakub Sztandera edf03c9ba8 Use adt.Empty
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 02:00:25 +01:00
Jakub Sztandera 7a6eb723ad Use correct epoch for vrf
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 01:33:35 +01:00
Jakub Sztandera 300c89f541 Update to new sepcs actors, more debug
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-26 01:02:13 +01:00
Łukasz Magiera 78b4872793 Merge pull request #1454 from filecoin-project/feat/wocker-task-flags
seal-worker: Task type flags
2020-03-25 22:32:46 +01:00
Łukasz Magiera d686fce7f9 stores: Mute serve-stat debug log 2020-03-25 22:23:01 +01:00
Łukasz Magiera ae69e0fef1 seal-worker: Task type flags 2020-03-25 22:15:10 +01:00
Łukasz Magiera 5a7d18e9f3 Merge pull request #1453 from filecoin-project/feat/auth-apiinfo
cli: auth api-info
2020-03-25 21:46:59 +01:00
Łukasz Magiera 91c640197c cli: auth api-info 2020-03-25 21:42:24 +01:00
Łukasz Magiera 02e5148720 Merge pull request #1451 from filecoin-project/feat/secstor-move-sealed
sectorstorage: Move sealed sectors to storage in FinalizeSector
2020-03-25 21:22:44 +01:00
Łukasz Magiera 42c9d53ae1 workers: gofmt 2020-03-25 21:20:24 +01:00
Łukasz Magiera 05f52b1fad stores: 'None' file type 2020-03-25 21:19:58 +01:00
Whyrusleeping 1aef03bdd7 Merge pull request #1450 from filecoin-project/asr/gas
Re: #1446: Enable gas tracking in validation tests
2020-03-25 12:53:57 -07:00
Whyrusleeping 6851b8d7bf Merge pull request #1452 from jsign/jsign/testnet3/includedealid
Include DealID in DealInfo
2020-03-25 12:50:24 -07:00
Ignacio Hagopian 3896902d49 include DealID in DealInfo
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-03-25 16:30:59 -03:00
Jeromy 088d693eea code review changes 2020-03-25 12:13:09 -07:00
Łukasz Magiera 00cfb3bdcf sectorstorage: Move sealed sectors to storage in FinalizeSector 2020-03-25 19:21:53 +01:00
Aayush Rajasekaran 60ec264470 enable gas validation 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 7b9872c473 don't skip any tests 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran ebcefa80e3 provide msg length to vm::ApplyMessage 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran c951e0cc83 do not reprocess duplicate messages in a block 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 3a0df321d1 actually create new bls keys 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 3896631a1c Remove pre-execution validity checks on messages 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 490f85e690 Send implicit messages for block rewards, cron ticks, state calls, and genesis setup 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran ad15750be3 Charge sender no gas, and penalise miner for certain invalid messages 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 654f933d3f set up builtin actors correctly for validation testing 2020-03-25 08:25:03 -04:00
Aayush Rajasekaran 09a46e5d80 fix some gas charge bugs, and make our new account actor creation follow GFC 2020-03-25 08:25:03 -04:00
Łukasz Magiera 08ca60cfa8 Merge pull request #1405 from filecoin-project/feat/new-workers
New workers
2020-03-25 01:31:48 +01:00
Łukasz Magiera 201d0a4b19 Merge remote-tracking branch 'origin/testnet/3' into feat/new-workers 2020-03-25 01:02:23 +01:00
Łukasz Magiera cfc65f525a sectorstorage: wire up closing logic 2020-03-25 00:52:55 +01:00
Łukasz Magiera ecf53f88ce workers: More review related fixes 2020-03-25 00:37:40 +01:00
Whyrusleeping 60ea9e6ec8 Merge pull request #1426 from filecoin-project/asr/statewait
Re: #1412: Add a non-blocking version of StateWaitMsg
2020-03-24 16:17:47 -07:00
Whyrusleeping f7b0bb0e9c Merge pull request #1448 from filecoin-project/fix/retval-checking
chain validation nil return values should be []byte{}
2020-03-24 14:10:51 -07:00
Łukasz Magiera 146bfe75f8 sectorstorage: Remove unsealed sector in FinalizeSector 2020-03-24 21:28:07 +01:00
Jeromy ec0d0a51db chain validation nil return values should be []byte{} 2020-03-24 13:09:04 -07:00
Łukasz Magiera 5de17e903c storageminer: Config for local worker task types 2020-03-24 20:38:00 +01:00
Łukasz Magiera 62cf9a5dd7 Update FFI 2020-03-24 19:41:25 +01:00
Łukasz Magiera c7122597be Merge remote-tracking branch 'origin/testnet/3' into feat/new-workers 2020-03-24 19:18:39 +01:00
Łukasz Magiera 5b8c6b687e Merge pull request #1447 from filecoin-project/interopnet
New interop network info
2020-03-24 19:17:49 +01:00
Łukasz Magiera 66a682b55d Merge remote-tracking branch 'origin/testnet/3' into feat/new-workers 2020-03-24 19:09:02 +01:00
Łukasz Magiera 726c9c1fe7 workers: Address review 2020-03-24 19:01:04 +01:00
Travis Person a2162672a7 New interop network info 2020-03-24 17:49:57 +00:00
Whyrusleeping 71f0acd7a3 Merge pull request #1442 from filecoin-project/feat/chainval-tests
WIP: updating and getting chainval tests passing
2020-03-24 10:00:07 -07:00
Whyrusleeping 1d16857997 Merge pull request #1445 from jimpick/fix/spelling
Error message spelling fixes
2020-03-24 09:22:08 -07:00
Aayush Rajasekaran d350a9d415 Re: #1412: Add a non-blocking version of StateWaitMsg
- This commit adds a new method called StateSearchMsg
- We can probably overhaul StateWaitMsg onto this new method at a later point in time
2020-03-24 06:43:15 -04:00
Aayush Rajasekaran d5b1bfe197 only skip one test 2020-03-24 04:44:50 -04:00
Aayush Rajasekaran df13cfa52b Only resolve origin to pubkey address when creating a new account actor 2020-03-24 04:43:09 -04:00
Aayush Rajasekaran 753e8ff7f5 Award gas fees to miners correctly 2020-03-24 03:35:58 -04:00
Aayush Rajasekaran 9ccc02d664 Load actor states afresh before making state changes
- Not doing this is causing bugs when reverting, since the actor cache gets reset
2020-03-24 03:33:22 -04:00
Jim Pick bc914de388 Error message spelling fixes 2020-03-23 23:54:39 -07:00
Jeromy 14591e718d skip tests so we can get this merged in 2020-03-23 18:52:39 -07:00
Jeromy 9e67bef4bd drop balance checks in block validation 2020-03-23 18:50:58 -07:00
Jeromy 2228f13f99 a couple vm fixes 2020-03-23 18:50:58 -07:00
Jeromy 6fe245a278 use proper exitcodes for caller validation 2020-03-23 18:50:28 -07:00
Aayush Rajasekaran 066b755b6a set up initial account state of new Secp accounts 2020-03-23 18:50:28 -07:00
Aayush Rajasekaran 72c6552b0b Allow invocation of account actor methods 2020-03-23 18:50:28 -07:00
Aayush Rajasekaran 05d43af3fc Only try to resolve origin address during top-level invocation 2020-03-23 18:50:28 -07:00
Jeromy 1c55c6afba update to anorths chainval PR 2020-03-23 18:50:28 -07:00
Jeromy 8bc4195b7a WIP: updating and getting chainval tests passing 2020-03-23 18:50:18 -07:00
Whyrusleeping d74ede5a79 Merge pull request #1428 from filecoin-project/feat/graphsync-fetching
WIP: integrate graphsync for chainsync requests
2020-03-23 18:47:17 -07:00
Łukasz Magiera 8559c89560 storageminer: More storage stats in storage list 2020-03-23 23:43:38 +01:00
Jeromy 719cec13d5 prefer blocksync, fallback to graphsync 2020-03-23 13:46:15 -07:00
Łukasz Magiera 8d1fab1e05 sectorstorage: Enable sealing on the local worker by default 2020-03-23 17:28:40 +01:00
Łukasz Magiera 0bb37d1fd6 sectorstorage: Fix remote sector deletion 2020-03-23 16:40:36 +01:00
Łukasz Magiera a3ba8eb0d7 workers: Basic monitoring tools 2020-03-23 15:56:22 +01:00
Łukasz Magiera 80d0f1f2c1 storageminer: Cleanup CLI 2020-03-23 13:29:24 +01:00
Łukasz Magiera cb1e7bd1b1 sector index: Don't add duplicate storage URLs 2020-03-23 13:12:43 +01:00
Łukasz Magiera eeec5a1bba Merge pull request #1274 from filecoin-project/feat/doc/actors
doc: add comments related to actor code review
2020-03-23 12:49:41 +01:00
Łukasz Magiera 5e4a7e54df Rename agvmgr+sealmgr to sectorstorage 2020-03-23 12:47:10 +01:00
Łukasz Magiera cd618dfdbd gofmt 2020-03-22 22:39:27 +01:00
Łukasz Magiera d43f2a2e3b workers: Address review 2020-03-22 22:39:06 +01:00
Łukasz Magiera 881ed6aef7 Merge pull request #1440 from filecoin-project/fix/genesis-field-values
Fix/genesis field values
2020-03-22 22:10:33 +01:00
Łukasz Magiera df9aa0e357 storagemitner: manage ulimit on start 2020-03-22 22:08:22 +01:00
Łukasz Magiera 09c9fcce00 workers: fix panics with schedQueue 2020-03-22 21:45:12 +01:00
Łukasz Magiera 66d71d9974 sealing: Improve sector log 2020-03-22 21:44:27 +01:00
Łukasz Magiera 971fe6fdfd workers: Drop sectors from origin after transfers 2020-03-22 05:27:28 +01:00
Jeromy f1dbd35407 change genesis fields to match interop 2020-03-21 15:25:00 -07:00
Jeromy f3781e8329 update and rerun cbor gen 2020-03-21 14:17:01 -07:00
whyrusleeping 9d7f19b950 some cleanup 2020-03-20 21:30:24 -07:00
hannahhoward 2e9a052f62 fix(chainsync): support longer graphsync fetches with loop 2020-03-20 21:30:24 -07:00
hannahhoward 34f755b2b9 feat(chainsync): fixes to make graphsync work for chain fetching
- store to chain blockstore (ok for now, since storage provider is a seperate process)
- simplify request fetching and processing
2020-03-20 21:30:24 -07:00
whyrusleeping 1076a1a89d WIP: integrate graphsync for chainsync requests 2020-03-20 21:30:24 -07:00
Whyrusleeping 21255eddee Merge pull request #1439 from filecoin-project/fix/chain-export
Rewrite chain export walker function to actually do the right thing
2020-03-20 19:55:11 -07:00
Jeromy 6fcfd0a4f0 add a test to roundtrip export/import a chain 2020-03-20 18:22:24 -07:00
Jeromy 921f11db34 Rewrite chain export walker function to actually do the right thing 2020-03-20 17:18:57 -07:00
Łukasz Magiera 709fd034b4 mod tidy 2020-03-20 23:43:20 +01:00
Łukasz Magiera e6aa01653a Merge remote-tracking branch 'origin/testnet/3' into feat/new-workers 2020-03-20 23:42:46 +01:00
Łukasz Magiera c6f67911de storageminer: Improve storage find cmd 2020-03-20 23:39:07 +01:00
Łukasz Magiera c57c0e7f55 workers: Memory based scheduling 2020-03-20 23:30:17 +01:00
Whyrusleeping aad449f28a Merge pull request #1425 from filecoin-project/fix/randomness-for-ec
use proper lookback, and proper serialization for randomness generation
2020-03-20 15:03:22 -07:00
Whyrusleeping a3fd1d4b51 Merge pull request #1401 from filecoin-project/fix/nonce-miss-no-gas
Missmatching nonce does not charge gas
2020-03-20 14:56:33 -07:00
Jeromy 90f43d99ca cbor marshal address for ticket generation 2020-03-20 14:56:05 -07:00
Łukasz Magiera 628a598ca0 Merge pull request #1431 from luqz/master
Correct the number of waiting blocks
2020-03-20 22:18:38 +01:00
Whyrusleeping 0ca935e0b9 Merge pull request #1417 from filecoin-project/fix/sshot-after-gas
take snapshot after gas transfer so its not reverted on method failure
2020-03-20 14:16:54 -07:00
Whyrusleeping f9bd0fb2ce Merge pull request #1433 from filecoin-project/feat/serialization-vectors
Integrate updated serialization vectors as tests
2020-03-20 14:11:28 -07:00
Jeromy 588a55c9d7 update chain validation 2020-03-20 14:08:47 -07:00
whyrusleeping 84fd969710 take snapshot after gas transfer so its not reverted on method failure 2020-03-20 13:50:46 -07:00
Whyrusleeping badaa5fad1 Merge pull request #1429 from filecoin-project/asr/NAA
Calculate new actor addresses as per updated spec
2020-03-20 13:50:08 -07:00
Jakub Sztandera 4ba4de3379 Missmatching nonce does not charge gas
It should charge miner but we don't have that mechanism yet.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-20 20:44:45 +01:00
Aayush Rajasekaran ef288b8a6c Calculate new actor addresses as per updated spec 2020-03-20 15:43:08 -04:00
whyrusleeping 438aac190f use proper lookback, and proper serialization for randomness generation 2020-03-20 12:20:56 -07:00
Whyrusleeping 7b69697439 Merge pull request #1434 from filecoin-project/feat/more-gas
Rework gas charging
2020-03-20 12:18:18 -07:00
Whyrusleeping 9df4fce282 Merge pull request #1438 from filecoin-project/frrist/display-chainval-testname
print chain-validation test name when running
2020-03-20 12:03:53 -07:00
Whyrusleeping 78de82158d Merge pull request #1436 from filecoin-project/asr/hash
Use blake2b, not SHA, for VRFs
2020-03-20 11:30:04 -07:00
Aayush Rajasekaran 5e46c0b4e9 Use blake2b, not SHA, for VRFs 2020-03-20 11:23:22 -07:00
Jakub Sztandera c874bd6a15 go mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-20 19:01:12 +01:00
frrist e6b0eaed61 go mod tidy 2020-03-20 10:41:10 -07:00
frrist 100fc47812 print chain-validation test name when running
- makes debugging easier
2020-03-20 10:35:59 -07:00
Jakub Sztandera ac09a6432c Skip failing tests, update chain-validation
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-20 18:21:13 +01:00
Jakub Sztandera ae40654907 Rework gas charging 2020-03-20 03:26:40 -04:00
Łukasz Magiera 076cc428af workers: Fix moving storage around in later steps 2020-03-20 01:55:49 +01:00
Łukasz Magiera e0c15b24fc storageminer: Fix preseal meta import for genesis miners 2020-03-20 01:20:01 +01:00
Łukasz Magiera 978a718159 storage: storage find command 2020-03-19 20:51:33 +01:00
Łukasz Magiera 314fba049f workers: get sectors back to miner process after precommit 2020-03-19 20:17:58 +01:00
Łukasz Magiera 80cca91584 workers: get to executing tasks remotely! 2020-03-19 18:11:45 +01:00
Łukasz Magiera d87b7c264d stores: Use index in local store 2020-03-19 16:11:04 +01:00
Jason b96aedd720 Correct the number of waiting blocks 2020-03-19 16:00:42 +08:00
whyrusleeping 905fc968bf Integrate updated serialization vectors as tests 2020-03-18 22:53:15 -07:00
Łukasz Magiera 2fa3f2578f impl: Move CommonAPI into a separate pkg 2020-03-19 03:31:53 +01:00
Łukasz Magiera 1ed7779701 Merge remote-tracking branch 'origin/testnet/3' into feat/new-workers 2020-03-19 03:28:55 +01:00
Łukasz Magiera 825a3e1d5c Merge pull request #1424 from filecoin-project/feat/state-tree-itnerop
add simple test for helping to test state tree interop
2020-03-19 03:24:30 +01:00
Łukasz Magiera 2d1e30ae3b workers: Call find* on remote 2020-03-19 03:23:21 +01:00
Whyrusleeping 6d9b8ee0dc Merge pull request #1423 from filecoin-project/interopnet
New interop network info
2020-03-18 17:24:49 -07:00
whyrusleeping 1fb70fc0e0 add simple test for helping to test state tree interop 2020-03-18 17:23:59 -07:00
Travis Person da631478a8 New interop network info 2020-03-19 00:22:59 +00:00
Lucas Molas d21cb96ddb doc: add comments related to actor code review 2020-03-18 16:43:58 -07:00
Łukasz Magiera 94ebbd9d90 workers: Actually register in miner 2020-03-19 00:23:32 +01:00
Whyrusleeping 7b0fc4ae7e Merge pull request #1422 from filecoin-project/feat/update-specs-actors-2
update to latest specs actors code
2020-03-18 15:25:41 -07:00
whyrusleeping f1327b75c3 update to latest specs actors code 2020-03-18 15:16:50 -07:00
Łukasz Magiera 3676daf7dc Merge pull request #1421 from filecoin-project/fix/gas-limit-type
change gas limit to be a normal int64
2020-03-18 22:41:16 +01:00
whyrusleeping ddf1beac6c change gas limit to be a normal int64 2020-03-18 13:45:37 -07:00
Łukasz Magiera 500ce56371 Merge pull request #1415 from filecoin-project/fix/debug-miner-size
Fix/debug miner size
2020-03-18 21:00:16 +01:00
Łukasz Magiera ff5a6773b1 Merge pull request #1419 from filecoin-project/feat/update-to-latest-go-fil-markets
update to latest go-fil-markets
2020-03-18 20:58:51 +01:00
laser 366db2f38c adjust import order as per PR feedback 2020-03-18 12:43:06 -07:00
laser 4458d090b3 tidy 2020-03-18 11:57:32 -07:00
laser f59bf6fab1 wire up dtypes.ClientDatastore 2020-03-18 11:57:22 -07:00
laser a8dd6a831c implement storage client and provider node adapters 2020-03-18 11:37:32 -07:00
Łukasz Magiera 14e387e3ac Merge pull request #1418 from filecoin-project/asr/cli
Add a minor detail to the FAQs
2020-03-18 19:07:27 +01:00
Łukasz Magiera b2d4d37539 Merge pull request #1416 from filecoin-project/feat/import-data-usage
Feat/import data usage
2020-03-18 19:06:37 +01:00
laser 6622576cf8 update retrieval provider node adapter to new API 2020-03-18 10:53:06 -07:00
laser ec3e86ad18 update retrieval client node adapter to new API 2020-03-18 10:44:54 -07:00
laser eacf991bb2 update go-fil-markets dependency 2020-03-18 10:21:50 -07:00
Aayush Rajasekaran 163527a021 Merge pull request #1313 from filecoin-project/asr/spam
Re: #1302: Refine invalid message filtering
2020-03-18 03:24:12 -04:00
Aayush Rajasekaran 6fda3c877e Re: #1302: Refine invalid message filtering
- This commit slightly weakens the current invalid message check
- The behaviour is that if you can't add a message to your pool, you *probably* won't broadcast it to your peers
- The exceptions are that you will broadcast a message if you fail to validate it because nonce / balance lookup fails
- This commit also lowers the invalid message log to debug (to lessen the annoyance of several invalid messages coming in, and hopefully to prevent confusion among node operators)
2020-03-18 03:14:18 -04:00
Aayush Rajasekaran 4dfe467e66 Merge pull request #1383 from filecoin-project/asr/actoraddress
New Actor Addresses should be generated as per spec
2020-03-18 03:10:42 -04:00
Aayush Rajasekaran 993505b461 Enable full validation tests 2020-03-18 02:57:11 -04:00
Aayush Rajasekaran f22f427cde Put the correct error into ExecutionResult 2020-03-18 02:57:11 -04:00
Aayush Rajasekaran 51cf5d5f1b New Actor Addresses should be generated as per spec
- The pubkey address address of the sender should be used, not the ID address
- We should use the internal callSeqNum as input (was hard-coded to zero)
- The external message nonce should be used, not the actor's nonce in the post-increment state
2020-03-18 02:57:11 -04:00
Whyrusleeping 8d0b2947d6 Merge pull request #1409 from filecoin-project/feat/proofs-v24
Update to v24 params
2020-03-17 22:24:52 -07:00
whyrusleeping 66a950942e add a usage text to import-data command 2020-03-17 22:08:14 -07:00
Whyrusleeping df0a19d5c4 Merge pull request #1413 from filecoin-project/feat/single-graphsync
unified graphsync instance
2020-03-17 22:07:21 -07:00
Łukasz Magiera d8c8832a37 stores: fix StorageList 2020-03-18 05:40:25 +01:00
whyrusleeping 24fb72f926 Set minimum miner size to 2048 bytes in debug mode 2020-03-17 20:30:55 -07:00
Łukasz Magiera 5f2caffb51 Fix tests after specs-storage changes 2020-03-18 02:08:11 +01:00
hannahhoward f259bc6a09 feat(graphsync): unified graphsync instance
setup a single graphsync that loads from both the chainstore & client blockstore
2020-03-17 17:25:12 -07:00
Łukasz Magiera d8ce5078d9 Use new specs-storage interface 2020-03-17 21:19:52 +01:00
Łukasz Magiera de1c984b48 workers: Handle init on first run 2020-03-16 19:46:02 +01:00
Łukasz Magiera 9e6ec71520 Merge pull request #1402 from filecoin-project/fix/jsonrpc-resanderr
Fix Error and Result being returne at the same time in JSON-RPC
2020-03-16 19:31:48 +01:00
Łukasz Magiera 7e997e40f3 workers: Simple storage diagnostics 2020-03-16 18:50:07 +01:00
Łukasz Magiera 416a0d2722 Merge branch 'feat/proofs-v24' into feat/new-workers 2020-03-16 10:45:22 +01:00
Łukasz Magiera 1f9fdf0c5c gofmt 2020-03-16 10:43:27 +01:00
Aayush Rajasekaran 77019c547b Add a minor detail to the FAQs 2020-03-15 21:57:46 -04:00
Łukasz Magiera a71906525a seed: Support parsing string sector-size 2020-03-15 21:42:44 +01:00
Łukasz Magiera 630df050c0 bench: Option to skip commit2 2020-03-15 18:48:53 +01:00
Jakub Sztandera 06ce4f21c5 Warn on non zero result with error
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-14 15:08:24 +01:00
Łukasz Magiera 1bc55714ed Update to v24 params 2020-03-14 03:45:44 +01:00
Łukasz Magiera f4bf6ee186 Merge pull request #1408 from jimpick/fix/websocket-upgrade-case
Make websocket connection upgrade header check case-insensitive
2020-03-13 22:28:33 +01:00
Jim Pick b6d5ea629b Make websocket connection upgrade header check case-insensitive
I was having troubles configuring an nginx reverse-proxy when
using Websockets.

It turns out my configuration was sending a "Connection: upgrade"
header, but Lotus expected "Connection: Upgrade".

This commit converts the check to be case-insensitive.

Some of the examples on the MDN page show lower-case "upgrade",
so I think it's not unusual for the usage to vary.
2020-03-13 13:07:39 -07:00
Łukasz Magiera e6ec20b4ca Merge branch 'testnet/3' into feat/new-workers 2020-03-13 17:58:13 +01:00
Łukasz Magiera 96730bae75 workers: Report sectors paths after worker creates them 2020-03-13 17:54:55 +01:00
Łukasz Magiera 2c7f579838 workers: Implement SectorIndex 2020-03-13 12:59:19 +01:00
Łukasz Magiera a75ad492f1 workers: Declare sectors after fetching in remote store 2020-03-13 11:40:24 +01:00
Łukasz Magiera bc7fede68b workers: Wire up most pieces 2020-03-13 02:37:38 +01:00
Łukasz Magiera 86871e5abc workers: Basic Remote store 2020-03-13 01:23:05 +01:00
Frrist 7371274ea7 update chain-validation: adds miner workflow test (#1403)
* update chain-validation. adds miner workflow test
* replace real sealing with mocked impl
2020-03-12 10:22:45 -07:00
Łukasz Magiera 56968d858c workers: Make LocalWorker public 2020-03-11 22:23:16 +01:00
Whyrusleeping 954085d33e Merge pull request #1404 from filecoin-project/asr/segfault
Bugfix: Check if vmctx is nil before dereferencing in ApplyMessage
2020-03-11 13:29:33 -07:00
Aayush Rajasekaran 4777ca21c3 Bugfix: Check if vmctx is nil before dereferencing in ApplyMessage 2020-03-11 15:42:51 -04:00
Jakub Sztandera 21b34ba133 Fix chan handling
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-11 19:14:49 +01:00
Jakub Sztandera 8d870a03b5 Fix Error and Result being returne at the same time in JSON-RPC
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-11 18:48:02 +01:00
Whyrusleeping a0f1c8c87f Merge pull request #1397 from filecoin-project/feat/interoptnet
new interoptnet
2020-03-11 01:06:13 -07:00
Travis Person 66add465bd new interoptnet 2020-03-11 08:02:15 +00:00
Whyrusleeping ad753c90ff Merge pull request #1396 from filecoin-project/fix/power-deduction
move power deduction out of the loop
2020-03-11 00:30:49 -07:00
whyrusleeping 3d6577838c move power deduction out of the loop 2020-03-11 00:29:17 -07:00
Łukasz Magiera 71afcb0333 workrs: refactor sector store for more composability 2020-03-11 08:22:21 +01:00
Whyrusleeping fb91ea2470 Merge pull request #1389 from filecoin-project/feat/chain-get-raw-type
cli: add cbor-hex type to chain get
2020-03-11 00:10:57 -07:00
Whyrusleeping 4d572d3ae8 Merge pull request #1395 from filecoin-project/deps/update-specs-actors-2
update specs actors with post and cron fixes
2020-03-11 00:09:43 -07:00
whyrusleeping 3971bf0c99 update specs actors with post and cron fixes 2020-03-11 00:08:51 -07:00
Whyrusleeping 9bad73b995 Merge pull request #1388 from filecoin-project/fix/nonce-before-gas
Check for correct nonce before taking gas
2020-03-10 23:58:28 -07:00
Whyrusleeping d48d073bcf Merge pull request #1394 from filecoin-project/fix/fallbackpost-finally
get fallback post running successfully!
2020-03-10 23:41:41 -07:00
whyrusleeping 16d087cce4 get fallback post running successfully! 2020-03-10 23:30:48 -07:00
Łukasz Magiera 7e2e30f94b workers: Transfer logic refactoring 2020-03-11 06:49:17 +01:00
Łukasz Magiera eb61a36fd7 workers: RPC scaffolding 2020-03-11 02:58:02 +01:00
Whyrusleeping 65506376a4 Merge pull request #1390 from filecoin-project/fix/genesis-double-power-accounting
Don't double account for miner power when setting up genesis blocks
2020-03-10 18:56:47 -07:00
Whyrusleeping d4c0dfa851 Merge pull request #1392 from jsign/jsign/addDealId
Add DealID to DealInfo
2020-03-10 18:45:07 -07:00
Ignacio Hagopian 07df6e010f add dealID in DealInfo
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
2020-03-10 21:48:55 -03:00
Travis Person 6faffd832c cli: add cbor-hex type to chain get 2020-03-10 23:12:10 +00:00
Whyrusleeping 61e5b05262 Merge pull request #1386 from filecoin-project/fix/replay-not-found
dont panic when replay fails to find a message
2020-03-10 15:52:40 -07:00
Whyrusleeping f8f0d7def7 Merge pull request #1387 from filecoin-project/misc/less-errors
Less noisy mapool add
2020-03-10 15:50:01 -07:00
whyrusleeping 14f9724bc9 Don't double account for miner power when setting up genesis blocks 2020-03-10 15:42:41 -07:00
Jakub Sztandera f3c4288311 Check for correct nonce before taking gas
Otherwise as a miner you are able to include an invalid message forever
and get whole GasLimit of gas from it every time.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-10 21:14:50 +01:00
Jakub Sztandera cc7d25394c Less noisy mapool add
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-10 21:06:58 +01:00
whyrusleeping baca881473 dont panic when replay fails to find a message 2020-03-10 12:44:50 -07:00
Whyrusleeping da52596d79 Merge pull request #1382 from filecoin-project/feat/interoptnet
new interoptnet
2020-03-09 23:48:24 -07:00
whyrusleeping 1beab85d61 Drop debug messages 2020-03-09 23:46:13 -07:00
Travis Person d19f5e411c new interoptnet 2020-03-10 06:45:26 +00:00
Łukasz Magiera eeca91e43d Merge pull request #1381 from filecoin-project/feat/stats-nosync
stats: add flag to disable sync wait
2020-03-10 07:12:52 +01:00
Travis Person e9a7c8c7fa stats: add flag to disable sync wait 2020-03-10 06:10:16 +00:00
Łukasz Magiera a9dc2aa58b Merge pull request #1375 from filecoin-project/feat/mpool-debug-future
mpool: add debug logs for future detection
2020-03-10 07:02:41 +01:00
Łukasz Magiera 238d022d8d Merge pull request #1380 from filecoin-project/feat/update-specs-actors
update to latest specs-actors
2020-03-10 07:02:11 +01:00
whyrusleeping bccec5af95 update to latest specs-actors 2020-03-09 22:43:43 -07:00
Travis Person 0fe55f81f6 mpool: add debug logs for future detection 2020-03-10 05:41:24 +00:00
Whyrusleeping 7b5e7178f4 Merge pull request #1369 from filecoin-project/fix/reward-ticket-count
pass ticket count into reward application message
2020-03-09 22:35:46 -07:00
Whyrusleeping 8be9134e32 Merge pull request #1378 from filecoin-project/feat/clean-up-spec-shim
squash the spec shim and the vmcontext into the new runtime type
2020-03-09 22:28:07 -07:00
whyrusleeping 85e17fa5b0 fix state cid accounting after 'Transaction' calls 2020-03-09 22:20:46 -07:00
whyrusleeping 114cb2d2aa squash the spec shim and the vmcontext into the new runtime type 2020-03-09 21:44:29 -07:00
Łukasz Magiera 69a854de8b Merge pull request #1377 from filecoin-project/feat/enable-32gb-sectors
fountain: add 32GiB sectors
2020-03-10 03:24:45 +01:00
Travis Person c655162dd6 fountain: add 32GiB sectors 2020-03-10 02:21:37 +00:00
Łukasz Magiera dcd12bff7c Merge pull request #1376 from filecoin-project/feat/shed-ncfix-auto
shed: auto mode for nonce-fix
2020-03-10 03:01:37 +01:00
Łukasz Magiera 47e3b5b902 shed: make non-auto nonce-fix safer 2020-03-10 02:11:07 +01:00
Łukasz Magiera 2bf9f10f16 mpool stat: sort by address 2020-03-10 01:44:15 +01:00
Łukasz Magiera 9daaaa3ec2 shed: corect start nonce in nc-fix 2020-03-10 01:28:59 +01:00
Łukasz Magiera e396454138 shed: auto mode for nonce-fix 2020-03-10 01:26:10 +01:00
Łukasz Magiera 5d6d75f546 Merge pull request #1373 from filecoin-project/fix/amgr-races
storage: Improve thread safety
2020-03-09 23:11:17 +01:00
Łukasz Magiera 26374e2644 cli: Handle sighup 2020-03-09 23:03:33 +01:00
Łukasz Magiera 0c3f4eb7dd storageminer: Create dir with --init 2020-03-09 23:00:29 +01:00
Łukasz Magiera f3798f9d40 Merge pull request #1374 from filecoin-project/fix/state-power-json
make state power a pointer so it marshals properly
2020-03-09 22:48:53 +01:00
Łukasz Magiera 24956a49f4 gofmt 2020-03-09 22:47:58 +01:00
Łukasz Magiera 0c2af7a8ee repo: Fix fsrepo.SetStorage on init 2020-03-09 22:46:17 +01:00
whyrusleeping 26ca72e252 make state power a pointer so it marshals properly 2020-03-09 14:41:57 -07:00
Łukasz Magiera fe85c4111a update sectorbuilder with precommit1 mkdir fix 2020-03-09 22:13:13 +01:00
Łukasz Magiera b3d8273a03 storage: Referance path struct by pointer 2020-03-09 20:41:05 +01:00
Łukasz Magiera 01087e01d2 storage: Improve thread safety 2020-03-09 20:22:30 +01:00
Łukasz Magiera 946fff39a6 chainwatch: Fix message index creation 2020-03-09 19:18:30 +01:00
Whyrusleeping 70552e3e0d Merge pull request #1368 from filecoin-project/feat/build-cleanup
build: Remove unused vars, fix debug build
2020-03-09 11:03:27 -07:00
Łukasz Magiera f8159dcbfc Merge pull request #1372 from filecoin-project/fix/lint-not-working
Update golangci lint to resolve some files not being linted
2020-03-09 16:48:24 +01:00
Jakub Sztandera b6880c5f50 Update golangci lint to resolve some files not being linted
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-03-09 13:25:26 +01:00
Łukasz Magiera 2eb06760a3 Merge pull request #1371 from filecoin-project/feat/update
interopnet: pull lastest master
2020-03-09 09:43:15 +01:00
Łukasz Magiera 06d18484f6 Merge remote-tracking branch 'origin/master' into feat/update 2020-03-09 09:34:31 +01:00
Łukasz Magiera 5902daf3b5 chainwatch: Add to/from message indexes 2020-03-09 09:34:04 +01:00
whyrusleeping f1ff55f8b6 pass ticket count into reward application message 2020-03-09 00:45:40 -07:00
Whyrusleeping e6ba4a227a Merge pull request #1367 from filecoin-project/feat/chainget-hamtaddr
chain get: hamt-address type
2020-03-09 00:05:32 -07:00
Łukasz Magiera 72bf00bf00 circle: test debug build 2020-03-09 08:01:59 +01:00
Łukasz Magiera 1647798396 build: Remove unused vars, fix debug build 2020-03-09 07:54:29 +01:00
Łukasz Magiera 13a8e2c09d chain get: hamt-address type 2020-03-09 07:45:24 +01:00
Łukasz Magiera 2ff4a2846b Merge pull request #1366 from filecoin-project/fix/set-price-units
Add units to set price command
2020-03-09 07:28:42 +01:00
Łukasz Magiera 6981cfb8bc Merge pull request #1365 from filecoin-project/feat/miner-storage-add
storageminer: 'storage attach' command
2020-03-09 07:28:11 +01:00
Łukasz Magiera 0b14ab8000 fountain: Fix miner wait page title 2020-03-09 07:27:07 +01:00
whyrusleeping 33aa9bd03f Add units to set price command 2020-03-08 23:22:11 -07:00
Łukasz Magiera 1cf26fc652 repo: Implement memrepo.SetStorage 2020-03-09 07:21:42 +01:00
Łukasz Magiera c10142816e Merge pull request #1363 from filecoin-project/feat/cwatch-update
Update chainwatch
2020-03-09 07:16:40 +01:00
Whyrusleeping f9c38ac35e Merge pull request #1362 from filecoin-project/fix/no-storage-init
storageminer: Correctly initialize storage.json with --no-local-storage
2020-03-08 23:16:20 -07:00
Whyrusleeping 93137b02be Merge pull request #1364 from filecoin-project/feat/no-path-storage
storage: Allow starting with no paths
2020-03-08 23:15:53 -07:00
Łukasz Magiera 33fcf8eb44 gofmt, mod tidy 2020-03-09 07:13:45 +01:00
Łukasz Magiera c87ebe8590 storageminer: storage attach cmd 2020-03-09 07:13:22 +01:00
Łukasz Magiera 4b576cde50 storagemgr: Actually set updated config in AddLocalStorage 2020-03-09 06:56:32 +01:00
Łukasz Magiera f01e8bc509 storage: Allow starting with no paths 2020-03-09 06:52:12 +01:00
Łukasz Magiera 7c94f2f3be storageminer: Correctly initialize storage.json with --no-local-storage 2020-03-09 06:45:12 +01:00
Łukasz Magiera a46296d340 Update chainwatch 2020-03-09 06:43:32 +01:00
Łukasz Magiera bf1d3579c1 Merge pull request #1361 from filecoin-project/feat/interoptnet
New interopt network info
2020-03-09 06:17:14 +01:00
Travis Person ba0c667cad New interopt network info 2020-03-09 05:12:53 +00:00
Whyrusleeping 3a94d9d176 Merge pull request #1354 from filecoin-project/feat/state-compute-trace
implement compute state trace output
2020-03-08 21:22:40 -07:00
Whyrusleeping 4aa0669e61 Merge pull request #1360 from filecoin-project/feat/more-chain-get-types
Add more chain get types
2020-03-08 21:22:30 -07:00
whyrusleeping bf6948f8d6 update to latest specs-actors 2020-03-08 21:21:46 -07:00
Travis Person 9216a1eb07 Add more chain get types 2020-03-09 03:16:43 +00:00
whyrusleeping 4260cc38c9 implement compute state trace output 2020-03-08 20:07:25 -07:00
Łukasz Magiera 697ab30304 Merge pull request #1328 from filecoin-project/metrics/rework-default-view
remove high cardinality tags from metrics
2020-03-08 21:40:16 +01:00
Łukasz Magiera 85f01e4ded Merge pull request #1355 from filecoin-project/fix/fpost-again
Fix fallback post scheduling to hopefully do the right thing
2020-03-08 21:36:48 +01:00
whyrusleeping ab51c7e2d2 Fix fallback post scheduling to hopefully do the right thing 2020-03-08 00:19:38 -08:00
Łukasz Magiera cb1e797d72 Merge pull request #1353 from filecoin-project/feat/merge-master
Merge master back into testnet/3
2020-03-08 09:05:46 +01:00
whyrusleeping 24bf720a9a Merge branch 'master' into testnet/3 2020-03-07 16:46:12 -08:00
Whyrusleeping c553a6f458 Merge pull request #1349 from filecoin-project/feat/chain-get-types
add some type info to chain get
2020-03-07 16:10:00 -08:00
Łukasz Magiera bd708fa205 Merge pull request #1347 from filecoin-project/fix/reward-balance
fix initial reward actor balance
2020-03-07 07:10:15 +01:00
Łukasz Magiera 9c75c1365f Merge pull request #1351 from filecoin-project/fix/fpost
fixup fallback post
2020-03-07 06:41:10 +01:00
whyrusleeping f41f324fbc fixup fallback post 2020-03-06 21:26:00 -08:00
Łukasz Magiera b24fb44fba Merge pull request #1350 from filecoin-project/feat/interoptnet-info
interoptnet
2020-03-07 06:25:16 +01:00
Travis Person ea38116571 interoptnet 2020-03-07 03:50:08 +00:00
Whyrusleeping 0b5991850c Merge pull request #1346 from filecoin-project/feat/stat-cmd
Add stat-obj to API and a few extras
2020-03-06 18:55:48 -08:00
whyrusleeping cdd37bda1c add some type info to chain get 2020-03-06 18:47:19 -08:00
whyrusleeping 34ad13fc22 fix initial reward actor balance 2020-03-06 17:33:24 -08:00
Travis Person 1a31571493 lotu-shed: add stateroot stats command 2020-03-07 00:55:11 +00:00
Travis Person ebca777efd cli: export load tipset function 2020-03-07 00:46:20 +00:00
Travis Person 7628a64a55 cmd: add stat-obj 2020-03-07 00:43:44 +00:00
Whyrusleeping 84a887cc58 Merge pull request #1345 from filecoin-project/fix/noop-plan-loop
sealing: Fix noop plan loop
2020-03-06 15:39:52 -08:00
Łukasz Magiera 8f7f2e77c3 Merge pull request #1344 from filecoin-project/asr/debug
fix make debug
2020-03-07 00:07:53 +01:00
Łukasz Magiera a2f4d467fd sealing: Fix noop plan loop 2020-03-07 00:03:57 +01:00
Whyrusleeping f17962182f Merge pull request #1343 from filecoin-project/feat/sb-pc1-mkdir-fix
Update sectorbuilder to fix the mkdir bug in precommit1
2020-03-06 14:38:32 -08:00
Aayush Rajasekaran 55f155a72c fix make debug 2020-03-06 14:31:16 -08:00
Łukasz Magiera a962479ce7 Update sectorbuilder to fix the mkdir bug in precommit1 2020-03-06 23:26:22 +01:00
Łukasz Magiera d70fe95104 Merge pull request #1342 from filecoin-project/fix/miner-init-redux
Fix/miner init redux
2020-03-06 23:24:45 +01:00
whyrusleeping 4101147a5b one more miner init issue 2020-03-06 14:23:21 -08:00
Whyrusleeping 8a6b3cff57 Merge pull request #1317 from filecoin-project/feat/car-import
Add ability to import CAR files and retrieve to a CAR file
2020-03-06 13:27:17 -08:00
hannahhoward eef48c4be3 feat(client): support car to filestore
Store filestore reference for CAR files
2020-03-06 13:14:02 -08:00
hannahhoward 9f5f70a93f feat(client): add car import/export option
adds option on client file import and client retrieval to read/write to CAR file
2020-03-06 13:14:02 -08:00
Whyrusleeping 7662f03629 Merge pull request #1312 from filecoin-project/asr/internal
Re: #1239: Expose information about invoked messages
2020-03-06 12:41:47 -08:00
Łukasz Magiera 3a923e8aae Merge pull request #1340 from filecoin-project/feat/lib-dedupe
Switch to using extracted libs
2020-03-06 20:22:21 +01:00
Aayush Rajasekaran 340afc3503 Add information about internal message executions to SimulationResult
- The VM now tracks a list of ExecutionResults to keep track of internal messages
2020-03-06 11:11:06 -08:00
Aayush Rajasekaran 2d63b007f2 Unify MethodCall and ReplayResults into SimulationResult
- Call and Replay now return the same type, which includes both Message and MessageReceipt
2020-03-06 11:10:40 -08:00
Łukasz Magiera 3cab8bd5d1 gofmt 2020-03-06 20:01:28 +01:00
Łukasz Magiera 3d1a5f4bf3 libs: Use go-statemachine 2020-03-06 20:01:03 +01:00
Łukasz Magiera 79237a9309 libs: Remove rlepluslazy (using specs-actors everywhere) 2020-03-06 19:52:38 +01:00
Łukasz Magiera e51fa5c9ac libs: Use zerocomm from sectorbuilder 2020-03-06 19:50:41 +01:00
Łukasz Magiera 61802b9d42 Merge pull request #1334 from filecoin-project/feat/miner-rewards-cmd
add command to inspect and redeem block rewards
2020-03-06 19:05:03 +01:00
Łukasz Magiera 38241d66cb Merge branch 'testnet/3' into feat/miner-rewards-cmd 2020-03-06 19:04:36 +01:00
Łukasz Magiera b019e41f1c Merge pull request #1339 from filecoin-project/fix/fountain-create-miner-return
fountain: decode create miner results correctly
2020-03-06 09:14:05 +01:00
Łukasz Magiera ea0dcdcfac Merge pull request #1338 from filecoin-project/fix/miner-init
fix storage miner init logic
2020-03-06 09:11:27 +01:00
Whyrusleeping 05a95cace5 Merge pull request #1336 from filecoin-project/vet/some-go-vet-fixes
some go vet fixes
2020-03-06 00:11:13 -08:00
Whyrusleeping 30d28a942e Merge pull request #1335 from filecoin-project/feat/update-sb-ffi
Update FFI
2020-03-06 00:10:53 -08:00
Travis Person 277c037676 fountain: decode create miner results correctly 2020-03-06 08:08:07 +00:00
whyrusleeping 09c543c526 fix storage miner init logic 2020-03-06 00:06:59 -08:00
Łukasz Magiera b15c476698 node_test: set sector counters in repo 2020-03-06 08:47:03 +01:00
Whyrusleeping 3e67ca855a Merge pull request #1337 from filecoin-project/feat/testnet3-reduce-minimum
Reduce minimum to 2GiB
2020-03-05 23:19:40 -08:00
Travis Person bc5cd3c2a1 reduce minimum to 2GiB 2020-03-06 07:17:28 +00:00
whyrusleeping 16096e2c71 some go vet fixes 2020-03-05 22:46:07 -08:00
Łukasz Magiera 52d0ecd977 mod tidy 2020-03-06 07:08:22 +01:00
whyrusleeping 0b9c770b4e mod tidy 2020-03-05 21:49:41 -08:00
Łukasz Magiera 7d3e16986c sectorbuilder type updates 2020-03-06 06:38:59 +01:00
whyrusleeping 1183e082af add command to inspect and redeem block rewards 2020-03-05 21:32:52 -08:00
Łukasz Magiera ec00636b52 Update FFI 2020-03-06 05:54:43 +01:00
Łukasz Magiera 1a2eb56b54 Merge pull request #1332 from filecoin-project/Stebalien-chore/update-deps
chore(dep): update dependencies
2020-03-06 05:47:02 +01:00
Łukasz Magiera e0d0d49ea0 Merge branch 'testnet/3' of github.com:filecoin-project/go-lotus into testnet/3 2020-03-06 01:43:13 +01:00
Łukasz Magiera ac3d0dc30c Config fauces for inteop devnet 2020-03-06 01:42:59 +01:00
whyrusleeping 56cb88819c add 512MB params to testnet in non-debug mode 2020-03-05 16:41:06 -08:00
Steven Allen 6992fd4dba chore(dep): update dependencies
Updates:

* cid, multihash, and multiaddr to ensure that minimal varints are used.
* log to deduplicate some code between version 2 and version 1.
* multistream to avoid writing from multiple threads.
* badger/datastore to harden prefix handling in queries.
* libp2p to 0.5.2

BREAKING:

The new libp2p version now formats addresses with /p2p instead of /ipfs. /ipfs
multiaddrs are still supported.
2020-03-05 16:28:42 -08:00
Łukasz Magiera 4244ab72d5 Merge pull request #1331 from filecoin-project/deps/update-specs-actors
update to latest specs-actors
2020-03-06 01:24:55 +01:00
whyrusleeping 8a7f249aaa update to latest specs-actors 2020-03-05 16:20:57 -08:00
Łukasz Magiera 0ef6c756b6 Merge pull request #1305 from filecoin-project/feat/4stage-seal
Begin work on integrating new sectorbuilder interfaces
2020-03-06 00:59:42 +01:00
Łukasz Magiera 1c052b7c81 Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal 2020-03-06 00:59:12 +01:00
Łukasz Magiera a5c6d83cd9 gofmt; mod tidy 2020-03-05 23:43:41 +01:00
Łukasz Magiera d10b84d8cd worker: Fix build 2020-03-05 23:40:40 +01:00
Łukasz Magiera 16cb27b5f9 Get node_test to pass 2020-03-05 23:27:30 +01:00
Łukasz Magiera 1461e475da storage: Support adding paths at runtime 2020-03-05 23:02:01 +01:00
Whyrusleeping 71c87ac32f Merge pull request #1329 from filecoin-project/frrist/enable-gas-tracking
Frrist/enable gas tracking
2020-03-05 13:51:27 -08:00
frrist b8394c3573 update, you guessed it, chain-validation 2020-03-05 13:41:35 -08:00
frrist 00f5ee6064 add TODO for return value checking 2020-03-05 13:41:35 -08:00
frrist f4b07a7293 enable multisig tests 2020-03-05 13:41:35 -08:00
frrist a34a6c65e7 fix gas limit check in apply message 2020-03-05 13:41:35 -08:00
frrist 4e41479464 bls key deterministic, enable paych test 2020-03-05 13:41:35 -08:00
Frrist e4728eb719 update chain-val with latest tests (#1325)
* update chain-val with latest tests
2020-03-05 13:39:28 -08:00
Whyrusleeping 1a0bcfe018 Merge pull request #1326 from filecoin-project/asr/cli
Re: #1307: Provide ArgsUsage for all CLI commands
2020-03-05 13:11:04 -08:00
whyrusleeping 2cd06e3ea0 update to latest specs-actors 2020-03-05 13:02:33 -08:00
Łukasz Magiera a5e5918fc5 mod tidy; gofmt 2020-03-05 20:21:06 +01:00
Łukasz Magiera fa5bc3a5a9 Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal 2020-03-05 20:20:47 +01:00
Łukasz Magiera 7d95e134eb storageminer: Print what we can in info cmd 2020-03-05 19:26:05 +01:00
Łukasz Magiera f06bf6721e sealmgr: Implement all sealing steps 2020-03-05 19:19:32 +01:00
Adrian Lanzafame d0c748460e remove high cardinality tags from metrics 2020-03-05 19:47:20 +10:00
Łukasz Magiera 4beed065b6 sealmgr: Working local addpiece 2020-03-05 03:18:22 +01:00
Łukasz Magiera 0760968a3b Merge pull request #1327 from filecoin-project/fix/reward-actor
Fix/reward actor
2020-03-05 02:53:50 +01:00
whyrusleeping eef3aaee60 mod tidy 2020-03-04 17:42:13 -08:00
whyrusleeping 4e9e3f3dc3 make state tree snapshots properly stack based 2020-03-04 17:19:15 -08:00
Łukasz Magiera c91d970c41 storageminer: Init with default local storage 2020-03-05 02:12:52 +01:00
Aayush Rajasekaran e9afba3490 Add ArgsUsages to the CLI where missing
- This commit also standardises some notation
2020-03-04 16:58:46 -08:00
Aayush Rajasekaran f2c518455e Improve UX when importing keys into wallet using CLI 2020-03-04 16:57:03 -08:00
Łukasz Magiera 7db1dd52bd storagemgr: Wire up most of AddPiece logic 2020-03-05 01:38:07 +01:00
Łukasz Magiera 76698fe2db jsonrpc: Don't try to reconnect on the server side 2020-03-05 01:34:29 +01:00
whyrusleeping 5076b2b950 fix reward actor and block reward application 2020-03-04 13:21:24 -08:00
Łukasz Magiera e483383a44 node: wire up new storage manager 2020-03-04 20:42:49 +01:00
Łukasz Magiera 799ff17c7c Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal 2020-03-04 06:37:11 +01:00
Łukasz Magiera 1d3877fab3 sync: Use correct epost randomness 2020-03-04 06:32:33 +01:00
Łukasz Magiera f50e26e5dd update sectorbuilder 2020-03-04 06:32:13 +01:00
whyrusleeping 37d5baf0b2 fix blocks topic 2020-03-03 21:03:35 -08:00
Łukasz Magiera 9bf4aa7546 Merge pull request #1321 from filecoin-project/feat/chainwatch-miner-heads-stateroot-index
chainwatch: add stateroot index on miner_heads
2020-03-04 05:55:46 +01:00
Travis Person 9b98ef5de4 chainwatch: add stateroot index on miner_heads 2020-03-04 04:50:53 +00:00
Łukasz Magiera 4e46d00eb6 Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal 2020-03-04 04:01:13 +01:00
Łukasz Magiera dcf5fb36f3 Merge pull request #1242 from filecoin-project/feat/offline-deal-making
Feat/offline deal making
2020-03-04 03:53:52 +01:00
whyrusleeping 9169a073b6 add miner side commands and a few other goodies 2020-03-03 18:49:00 -08:00
Łukasz Magiera 12d870e274 sealmgr: Read only multi-path file manager 2020-03-04 03:24:08 +01:00
whyrusleeping 52acfb88ee use proper manual piece and size setting 2020-03-03 18:19:28 -08:00
whyrusleeping 2be2891647 wire up lotus side of make deal for manual commP 2020-03-03 16:18:08 -08:00
whyrusleeping 99c842e027 integrate client interface to allow for offline deals 2020-03-03 16:18:08 -08:00
Whyrusleeping e7f6554c68 Merge pull request #1318 from filecoin-project/fix/net-cmds
fix a few libp2p related problems
2020-03-03 16:10:34 -08:00
Whyrusleeping 0025b3c1dc Merge pull request #1300 from filecoin-project/frrist/chainval-integrate
implement chain-validation driver
2020-03-03 16:10:16 -08:00
Whyrusleeping 08ce9258d1 Merge pull request #1315 from filecoin-project/conform-protocol-names-to-spec
conform protocol ids to spec
2020-03-03 16:08:50 -08:00
whyrusleeping 7b11224130 go mod updates, and a couple small fixes 2020-03-03 16:07:27 -08:00
whyrusleeping 0da2f81252 get most of the chain validation tests passing 2020-03-03 16:06:41 -08:00
frrist 1c864d1eef fixs after rebase 2020-03-03 16:06:41 -08:00
whyrusleeping 8657b4698f fix invoker tests 2020-03-03 16:06:41 -08:00
frrist dfad346cff add test skipper and update chain-validation 2020-03-03 16:06:41 -08:00
whyrusleeping 0f6c365411 Do proper shimming for chain validation library 2020-03-03 16:06:41 -08:00
frrist bd91008462 clean up validation config 2020-03-03 16:06:41 -08:00
frrist 72132c851b update chain-validation version for miner creation 2020-03-03 16:06:41 -08:00
frrist 0de43748f7 better test name 2020-03-03 16:06:41 -08:00
frrist b60458d236 implement chain-validation driver 2020-03-03 16:06:41 -08:00
Whyrusleeping 8f1bf7a0ed Merge pull request #1320 from filecoin-project/feat/fix-signature-verification
Fix signature verification in adapters
2020-03-03 16:01:05 -08:00
whyrusleeping 33ca9dabef mod tidy 2020-03-03 15:50:45 -08:00
whyrusleeping d6723935b9 fixup to match spec, move constants to common location 2020-03-03 15:48:25 -08:00
Łukasz Magiera a0dbb6bdd6 Storage Manager refactor 2020-03-03 23:19:22 +01:00
hannahhoward 72c0dbd8e5 fix(markets): fix sig verification
fix handling of signatures in the adapters
2020-03-03 13:23:06 -08:00
Whyrusleeping 41bf668189 Merge pull request #1294 from natewalck/more-opencensus-metrics
More opencensus metrics
2020-03-03 12:02:13 -08:00
whyrusleeping c51a83b404 fix a few libp2p related problems 2020-03-02 20:55:25 -08:00
hannahhoward 9beacabd66 fix(paychmgr): Fix issues with payment channels
Load full addresses for payment channels so they can be signed, fixes bugs with saving vouchers and
catching duplicates, updates to version of go-fil-markets that solves a retrieval bug to complete
retrieval deal
2020-03-02 18:15:32 -08:00
lanzafame 4f2baa8953 conform protocol ids to spec
Signed-off-by: lanzafame <adrianlanzafame92@gmail.com>
2020-03-03 11:34:43 +10:00
Łukasz Magiera 3abb59a550 sealmgr: Interfaces; simple initial impl 2020-03-03 01:46:58 +01:00
Łukasz Magiera 2cca6ab3db Merge pull request #1314 from filecoin-project/feat/storage-miner-default-worker-count
Reduce default storage miner worker count
2020-03-03 00:30:46 +01:00
Travis Person c362d75a38 Reduce default storage miner worker count
The current default worker count of 5 can result in high memory usage of
the lotus-storage-miner process when a user starts multiple sector
pledges within a short time of each other and can result in the process
being killed for OOM.

Reducing the worker count to 2 will provide a safer default.
2020-03-02 23:28:05 +00:00
Jim bce50a802b Merge pull request #1308 from filecoin-project/asr/clidocs
Documentation updates
2020-03-01 21:46:06 -08:00
whyrusleeping 61fcbd1664 remove unnecessary cid casting 2020-03-01 20:38:18 -08:00
Aayush Rajasekaran e1570eedf3 Add a section for the CLI to lotu.sh 2020-03-01 20:30:17 -08:00
Aayush Rajasekaran 06ea2f573e Correct some sync info on lotu.sh 2020-03-01 20:30:17 -08:00
whyrusleeping ca882725ce fixup imports 2020-03-01 17:15:18 -08:00
whyrusleeping 60b19c51ef more misc fixes 2020-03-01 17:09:38 -08:00
Nate Walck 65cd13301c Add ReceivedFrom to block validation failure metrics 2020-03-01 20:01:52 -05:00
Nate Walck 8283bb994a Add block metrics to incoming pubsub validate funcs 2020-03-01 19:57:16 -05:00
Nate Walck 33af2409e8 Use head notif func for current node height, add pubsub metrics 2020-03-01 19:26:09 -05:00
Łukasz Magiera 98dbb2f70f bench: set correct registered proofs on things 2020-03-01 22:05:13 +01:00
Łukasz Magiera f4310e8f69 bench: set sector size in saved commit2 inputs 2020-03-01 05:26:10 +01:00
Łukasz Magiera 3c7880cc10 Merge pull request #1292 from filecoin-project/asr/clisign
Re: #1290: Add sign and verify CLI commands
2020-03-01 04:50:33 +01:00
Łukasz Magiera ee3e631b1a bench: Prove command 2020-03-01 03:52:46 +01:00
Łukasz Magiera 4521ff3e95 Merge pull request #1306 from filecoin-project/fix/payment-channel-specs-actors
Fix issues with payment channels
2020-03-01 03:31:18 +01:00
hannahhoward fed548623d fix(deps): update go-fil-markets 2020-02-28 19:32:33 -08:00
hannahhoward bda5315866 fix(paychmr): decode address correctly, pass wallet 2020-02-28 19:26:33 -08:00
hannahhoward 0d7afef0c5 fix(paychmgr): add to paych serialziation 2020-02-28 19:26:33 -08:00
Łukasz Magiera 342e85d378 bench: flag to save commit2 input 2020-02-29 03:31:25 +01:00
Łukasz Magiera 9794c04b94 Update sectorbuilder with Fr fix 2020-02-29 03:31:14 +01:00
Łukasz Magiera f54a555aa8 Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal 2020-02-29 03:21:01 +01:00
Łukasz Magiera fa245c1e53 Merge pull request #1299 from filecoin-project/feat/update-sectorbuilder
Update lotus to use v23 proofs
2020-02-29 03:14:19 +01:00
whyrusleeping 194093469a fix subtool builds 2020-02-28 18:05:19 -08:00
whyrusleeping c7508a0512 self review fixes 2020-02-28 18:02:40 -08:00
whyrusleeping 1a07cb7bbf a few more fixes 2020-02-28 17:12:47 -08:00
whyrusleeping cf2eefdfbe Fix up client storage deal matcher 2020-02-28 16:05:56 -08:00
Aayush Rajasekaran fe8db295e7 Re: #1290: Add a lotus wallet verify API and CLI command
- The command takes an address, message, and signature, and returns true if the sig is valid
2020-02-28 15:56:15 -08:00
Aayush Rajasekaran f6bda96d5a Re: #1290: Add a lotus wallet sign CLI command
- The command takes an address and a message (in hex) and prints out a signature of the msg
2020-02-28 15:56:00 -08:00
whyrusleeping 115167659d tidy that mod go 2020-02-28 14:02:54 -08:00
whyrusleeping 713059275d progress is made incrementally 2020-02-28 14:00:34 -08:00
whyrusleeping 5b657a2905 pass on proper sector types 2020-02-28 12:52:14 -08:00
whyrusleeping b03d2e2f9e un go-mod hack things, integrate newly merged fixes 2020-02-28 11:31:28 -08:00
whyrusleeping 0945d8725e fixing miner logic to make more tests pass 2020-02-28 11:31:28 -08:00
Łukasz Magiera 2a1253e45a types: Simplify Ticket.Equals 2020-02-28 11:31:28 -08:00
Henri S 96555aa74b update to use VRF digest appropriately and simplify drawing rand past genesis 2020-02-28 11:31:28 -08:00
hannahhoward 44f73103db fix(markets): detect storage deal active correctly
Use SectorStartEpoch to determine if a deal is active, rather than Proposal.StartEpoch
2020-02-28 11:31:28 -08:00
Łukasz Magiera 5a4f917c60 4-stage v23 lotus-bench 2020-02-28 19:06:59 +01:00
Łukasz Magiera e1aa4d6265 Merge pull request #1295 from filecoin-project/patch/specRand
Patch/spec rand
2020-02-28 18:23:54 +01:00
Łukasz Magiera 43bcae17b3 types: Simplify Ticket.Equals 2020-02-28 18:21:22 +01:00
Łukasz Magiera d5b8defcbb Begin work on integrating new sectorbuilder interfaces 2020-02-28 18:17:40 +01:00
Nate Walck 7db39115e8 Fixed ctx issue, changed to track failures instead of success 2020-02-27 23:43:52 -05:00
Łukasz Magiera a97e7ea52a Merge pull request #1303 from filecoin-project/feat/stats-head-buffer
stats: add small head change buffer to reduce collecting extraneous stats from small reorgs
2020-02-28 04:13:50 +01:00
Travis Person 7f731db9dd stats: add small head change buffer to reduce collecting extraneous stats from small reorgs 2020-02-28 03:01:23 +00:00
Nate Walck 353c5d8b12 Relocation opencensus metrics to its own package and add more node stats 2020-02-27 21:49:18 -05:00
Whyrusleeping b9c51e359f Merge pull request #1301 from filecoin-project/feat/message-filtering
implement basic message filtering
2020-02-27 17:55:47 -08:00
whyrusleeping 00efd097c7 implement basic message filtering 2020-02-27 17:40:16 -08:00
Łukasz Magiera 4dc35285dd Minimum sector size is now 2k 2020-02-28 01:48:34 +01:00
Łukasz Magiera 9161b865f3 v23 parameters.json 2020-02-28 01:08:43 +01:00
Łukasz Magiera 58f8481a12 sbmock: Set commR with correct cid codec 2020-02-28 00:49:28 +01:00
Łukasz Magiera f83bbc2cbe Regen cbor marshalers 2020-02-28 00:34:48 +01:00
whyrusleeping d8dda1ee66 debugging test failure 2020-02-27 15:14:15 -08:00
whyrusleeping e4dcb7441b fixup lotus-bench 2020-02-27 14:23:05 -08:00
whyrusleeping df6e3e83bf make it all build finally 2020-02-27 13:45:31 -08:00
Łukasz Magiera 01ea48a8fe Merge pull request #1297 from filecoin-project/fix/detect-deal-active-correctly
fix(markets): detect storage deal active correctly
2020-02-27 18:05:07 +01:00
Łukasz Magiera 48619dc238 Merge branch 'feat/update-sectorbuilder' of github.com:filecoin-project/go-lotus into feat/update-sectorbuilder 2020-02-27 01:56:15 +01:00
Łukasz Magiera 2aeab13aae zerocomm: 'Fix' the test 2020-02-27 01:56:09 +01:00
whyrusleeping 6c12068fb7 more fixes for random garbage 2020-02-26 16:42:39 -08:00
hannahhoward c1979f2c7f fix(markets): detect storage deal active correctly
Use SectorStartEpoch to determine if a deal is active, rather than Proposal.StartEpoch
2020-02-26 15:48:07 -08:00
whyrusleeping 767392332e WIP: update sectorbuilder 2020-02-26 14:54:34 -08:00
Whyrusleeping 0eeb6c16d9 Merge pull request #1293 from natewalck/opencensus-prometheus
Swap to opencensus for publishing data to prometheus
2020-02-26 10:48:15 -08:00
Łukasz Magiera cb09e48e8c Some test fixes 2020-02-26 10:05:22 +01:00
Henri S cf0a3af1f8 update to use VRF digest appropriately and simplify drawing rand past genesis 2020-02-25 21:47:42 -08:00
Nate Walck a3504dd51e Change lotusInfo opencensus key back to info 2020-02-25 20:11:55 -05:00
Nate Walck 0ce86e999a Add commit tag so we have that info as well 2020-02-25 19:59:51 -05:00
Nate Walck 2d2aefea16 Change lotus info counter name to version 2020-02-25 19:54:46 -05:00
Nate Walck 6b1e781602 export data under /debug/metrics to mirror go-ipfs 2020-02-25 19:49:32 -05:00
Nate Walck f9dac3a291 Swap to opencensus for publishing data to prometheus 2020-02-25 19:40:07 -05:00
Łukasz Magiera 1b6646b55a Merge pull request #1243 from filecoin-project/feat/specs-actors
Spec Actors integration
2020-02-26 00:31:59 +01:00
Łukasz Magiera 0a9e0acc6f types: Drop some redundant alias types 2020-02-25 22:09:22 +01:00
Łukasz Magiera ae634ef7df actors: Remove addrass aliases 2020-02-25 21:54:58 +01:00
Łukasz Magiera cd10a3126b actors: drop a bunch of type aliases 2020-02-25 21:35:15 +01:00
Łukasz Magiera f1d9033194 Address some minor review nits 2020-02-25 21:25:52 +01:00
Łukasz Magiera 1920981713 hello: regen type-gen 2020-02-25 21:21:58 +01:00
Whyrusleeping 0b845c9b1d Merge pull request #1291 from filcloud/fix-shed-make
fix shed make mistake
2020-02-25 10:47:16 -08:00
wanghui e2617f2780 fix shed make mistake 2020-02-25 15:48:41 +08:00
Łukasz Magiera 5d9b869d93 gofmt; mod tidy 2020-02-24 18:45:42 +01:00
Łukasz Magiera 794429dd55 post-upstream-merge fixes 2020-02-24 18:45:25 +01:00
Łukasz Magiera d787aa5007 Merge branch 'testnet/3' into feat/specs-actors 2020-02-24 18:32:02 +01:00
Łukasz Magiera def0e0a7a1 Merge remote-tracking branch 'origin/master' into testnet/3 2020-02-24 17:30:46 +01:00
Łukasz Magiera 9f0e0ced5e Merge pull request #1155 from jsign/issue127_2
fix issue #127
2020-02-24 17:22:58 +01:00
Łukasz Magiera a6a63d35e5 Merge pull request #1275 from filecoin-project/feat/cli-state-miner-info
cli: add state miner-info command
2020-02-24 15:29:19 +01:00
Łukasz Magiera 06cb004c33 Merge pull request #1276 from filecoin-project/asr/findpeer
Re: #1232: Add a FindPeer RPC method
2020-02-24 15:28:10 +01:00
Łukasz Magiera 25e99c6a64 Merge pull request #1288 from natewalck/add-prometheus-endpoint
Enable Prometheus metrics endpoint and add lotus version
2020-02-24 15:26:37 +01:00
Łukasz Magiera 929161c070 pond: Update some mapping arrays 2020-02-24 01:05:20 +01:00
Łukasz Magiera ba6d1091f2 pond: Fix node startup 2020-02-24 00:39:45 +01:00
Nate Walck cff1fcfe9d Move promhttp above manet.Listen 2020-02-23 17:54:49 -05:00
Nate Walck 6df2cf552a Remove commented out imports 2020-02-23 17:38:44 -05:00
Nate Walck c0ef65f442 Enable Prometheus metrics endpoint and add lotus version 2020-02-23 17:35:29 -05:00
whyrusleeping 66624b1a8f fixup debug advance cmd 2020-02-23 13:30:42 -08:00
Łukasz Magiera 1d417685d1 Fix Sealing in TestAPIDealFlow 2020-02-23 21:33:10 +01:00
Łukasz Magiera 917df9a5b8 More unified randomness handling 2020-02-23 21:00:47 +01:00
Łukasz Magiera a82d156ccb Deal flow fixes 2020-02-23 16:50:36 +01:00
Łukasz Magiera 7d499df001 Merge pull request #1282 from filecoin-project/fix/chainwatch-memory
chainwatch: reduce memory usage during large chain gaps
2020-02-23 12:11:06 +01:00
whyrusleeping 97425ea1c9 fix some tests 2020-02-22 23:49:15 -08:00
Łukasz Magiera 226685dc1c Implement committed capacity sectors 2020-02-23 01:47:47 +01:00
Łukasz Magiera 1381baf088 Generate zero CommP table 2020-02-22 15:06:38 +01:00
Łukasz Magiera 03b8ab724a state replay: find correct tipset 2020-02-22 14:31:13 +01:00
Łukasz Magiera b8428423a1 get chain to runnable state 2020-02-22 14:10:46 +01:00
Łukasz Magiera 99c0e14fd8 Fix genesis writing 2020-02-22 13:03:41 +01:00
Łukasz Magiera b12482df89 move peermgr, tracing into lib 2020-02-22 12:36:22 +01:00
Łukasz Magiera e655e8bc19 remove unused bin directory 2020-02-22 12:32:35 +01:00
Łukasz Magiera 57064c97e0 docs: Fix add-miner command in local-dev-net.md 2020-02-21 22:02:30 +01:00
Łukasz Magiera 111d35deef seed: New genesis creation commands 2020-02-21 21:57:00 +01:00
Łukasz Magiera 3b29aacfdc Fix debug build 2020-02-21 20:31:45 +01:00
Łukasz Magiera 18627e77ff gofmt; mod tidy 2020-02-21 20:28:20 +01:00
Łukasz Magiera 4e98f2e438 some test fixes 2020-02-21 20:28:01 +01:00
Łukasz Magiera d6dffed203 Fix genesis car generation 2020-02-21 20:27:29 +01:00
Łukasz Magiera 5b96b648b4 hello fixes 2020-02-21 20:25:57 +01:00
Travis Person 837dd0d241 chainsync: make batch size configurable 2020-02-21 18:49:49 +00:00
Travis Person ec50048a29 chainsync: add http debug 2020-02-21 18:49:21 +00:00
Travis Person 54315ce50f chainsync: move address map into batch cycle 2020-02-21 18:48:52 +00:00
Łukasz Magiera 49ece5fddf storageminer: Fix build 2020-02-21 19:20:22 +01:00
Łukasz Magiera 852e888232 cmd/lotus: Fix build 2020-02-21 19:00:10 +01:00
Łukasz Magiera a6268f055d storageminer: Update api interfaces 2020-02-21 18:43:44 +01:00
Łukasz Magiera 104871d6c9 paych: Lanes are back to u64 2020-02-21 18:26:44 +01:00
Łukasz Magiera c744dc06c6 Fix implicit account creation 2020-02-21 18:13:50 +01:00
Łukasz Magiera 57c43183e6 update specs-actors 2020-02-21 17:57:40 +01:00
Whyrusleeping 1ad725a04c Merge pull request #1284 from filecoin-project/version-bump-0-2-8
bump version to 0.2.8
2020-02-20 15:45:39 -08:00
Travis Person a898b18fd6 bump version to 0.2.8 2020-02-20 21:48:17 +00:00
whyrusleeping 00d7bd1a77 chain/gen tests now pass! 2020-02-20 00:37:10 -08:00
Travis Person 28ec00500b chainwatch: reduce memory usage during large chain gaps 2020-02-20 03:06:41 +00:00
Łukasz Magiera 69ec3c205a Merge remote-tracking branch 'origin/master' into testnet/3 2020-02-19 22:10:14 +01:00
Łukasz Magiera 35d14788d3 stmgr: Fix GetPower 2020-02-19 21:39:10 +01:00
Łukasz Magiera c69c9e62c2 stmgr: Correctly read sectorset 2020-02-19 21:34:21 +01:00
Łukasz Magiera 835e3d803f vm: don't follow replica CIDs in copy 2020-02-19 20:39:00 +01:00
Łukasz Magiera 9c31f61db4 sectorset updates 2020-02-19 20:26:11 +01:00
Travis Person cb4ae013c6 cli: add state miner-info command
Resolves #1270
2020-02-19 18:17:50 +00:00
Łukasz Magiera 3394645f7a chainstore: Update weight function to use new actors 2020-02-19 18:55:59 +01:00
Łukasz Magiera 0fa362cc23 Merge pull request #1280 from filecoin-project/asr/fix
Fix #1278: debug_advance should have its API calls updated
2020-02-19 18:17:39 +01:00
Aayush Rajasekaran 61401e5e82 Fix #1278: debug_advance should have its API calls updated
- This was forgotten in commit 6097000
2020-02-18 23:14:08 -05:00
Łukasz Magiera e9019c8bcc Working Genesis Generator 2020-02-18 22:38:08 +01:00
Aayush Rajasekaran c742d45b19 Re: #1232: Add a FindPeer RPC method
- Given a Peer ID, this method looks into the DHT to find that peer's addresses
- This commit also adds a CLI command to use this new RPC endpoint
2020-02-18 16:31:42 -05:00
Whyrusleeping 6afeb2e72b Merge pull request #1268 from filecoin-project/feat/simple-spam-protection
basic gossip spam protection logic
2020-02-18 10:39:36 -08:00
Whyrusleeping b5d50f2b52 Merge pull request #1272 from filecoin-project/misc/add-gofmt-to-golangcilint
Add gofmt to golangci-lint
2020-02-18 09:23:55 -08:00
Whyrusleeping 7e0be91cfd Merge pull request #1263 from filecoin-project/asr/state-api
Re: #1250: API methods should receive TipSetKeys, not TipSets, as input
2020-02-18 09:22:33 -08:00
whyrusleeping 4f6ec225cf mark peer for disconnection in connmgr 2020-02-18 09:20:17 -08:00
Jakub Sztandera b2a0ad68dd Add gofmt to golangci-lint
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-18 13:19:04 +01:00
whyrusleeping 6d0eec6395 working towards a working genesis generator 2020-02-17 23:15:30 -08:00
Aayush Rajasekaran 60970008c8 Re: #1250: API methods should receive TipSetKeys, not TipSets, as input 2020-02-17 19:53:43 -05:00
Łukasz Magiera 4ad160ef80 specs-actors: Update cbor-gen 2020-02-17 22:42:15 +01:00
Łukasz Magiera 038582ba44 vm: Fix getActorCode 2020-02-17 22:11:03 +01:00
Whyrusleeping 4750f32ab6 Merge pull request #1253 from filecoin-project/feat/bad-ts-cache-reasons
mark down reason for block inclusion in bad tipset cache
2020-02-17 12:20:20 -08:00
Whyrusleeping 1c9072bf6e Merge pull request #1235 from filecoin-project/feat/tls
Prefer tls
2020-02-17 11:26:50 -08:00
Whyrusleeping 656c022ed6 Merge pull request #1260 from filecoin-project/doc/miner-wallet-bls
docs: Provide clearer instructions around bls wallets for miners
2020-02-17 11:17:32 -08:00
Jakub Sztandera 4d5af19b9d Merge pull request #1258 from filecoin-project/feat/expose-jet-permission-error
Expose JWT permission error
2020-02-17 20:16:12 +01:00
Whyrusleeping fc227561ba Merge pull request #1254 from filecoin-project/feat/no-ffi-in-types
Remove ffi from types package
2020-02-17 11:13:56 -08:00
Jakub Sztandera d26a2bcf6b Merge pull request #1269 from filecoin-project/feat/add-graphsync
Add graphsync
2020-02-17 20:04:56 +01:00
Whyrusleeping ca0bed47c4 Merge pull request #1261 from filecoin-project/asr/faucet
Faucet: Provide more info when a user tries to create a miner with a non-BLS address
2020-02-17 11:00:11 -08:00
Whyrusleeping 4f4f18482a Merge pull request #1266 from filecoin-project/feat/cmd-log
cmd: add log command
2020-02-17 10:39:56 -08:00
Łukasz Magiera d0c158b019 genesis: Handle CreateMiner return correctly 2020-02-17 19:20:38 +01:00
Łukasz Magiera 140187dc2a vm: Fix Commit 2020-02-17 19:00:20 +01:00
Łukasz Magiera 3e4ebd6c9d actors: fix miner constructor 2020-02-17 18:19:06 +01:00
Jakub Sztandera 8af80169c0 Add graphsync
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-17 18:15:30 +01:00
Łukasz Magiera 4ad63d9b63 update specs-actors; update GetRandomness 2020-02-17 09:46:12 +01:00
Łukasz Magiera af8c379ac8 vm: More runtime methods 2020-02-17 09:19:54 +01:00
Łukasz Magiera 9f7bd983b3 vm: implement NewActorAddress 2020-02-17 08:59:53 +01:00
whyrusleeping 1dafcf24f1 basic gossip spam protection logic 2020-02-16 21:51:18 -08:00
Łukasz Magiera b6354dfb74 vm: Partially fix vm runtime shim 2020-02-16 23:15:12 +01:00
Travis Person d6cf76a91a cmd: add log command
Add a log command to the common api which allows for listing all
initialized golog subsystems, and setting their log level during
runtime.

Command description also adds golog environment variable documentation.
2020-02-15 06:04:55 +00:00
Jim a34537ae9f Merge pull request #1264 from filecoin-project/asr/docs
Docs: Add a Lotus-only FAQs section to the Lotus website.
2020-02-14 19:21:40 -08:00
Aayush Rajasekaran 85c7864f78 Docs: Add a Lotus-only FAQs section to the Lotus website. 2020-02-14 18:38:14 -08:00
Łukasz Magiera 5ced1ab905 gofmt 2020-02-14 22:38:30 +01:00
Łukasz Magiera a92099258b genesis: Register system actor 2020-02-14 22:38:18 +01:00
Łukasz Magiera d5027bfbb2 Fix amt bug 2020-02-14 21:33:41 +01:00
Łukasz Magiera c544c2b5c5 Set hamt bitwidth 2020-02-14 15:14:39 +01:00
Łukasz Magiera 48c5494cf9 use specs-actors birfields 2020-02-14 01:24:24 +01:00
Łukasz Magiera 74bf9119cc spects-actors: More type propagation 2020-02-13 04:50:45 +01:00
Aayush Rajasekaran f24d947388 Faucet: Provide more info when a user tries to create a miner with a non-BLS address 2020-02-12 18:41:23 -08:00
Łukasz Magiera 36aed6f871 Update cbor-gen 2020-02-13 02:37:28 +01:00
Łukasz Magiera e1a593c22e Rename paych -> paychmgr to fix cbor-gen 2020-02-13 01:28:23 +01:00
Łukasz Magiera e5ab64a3ab Fix client market impl, gofmt 2020-02-13 01:15:33 +01:00
Łukasz Magiera 91b2d2c2fe cbor-gen fixes 2020-02-13 01:10:07 +01:00
Łukasz Magiera 4684446315 Merge pull request #1259 from filecoin-project/feat/spec-actors-markets-update
feat(markets): use non-custom go-fil-markets, from master
2020-02-13 00:57:41 +01:00
Łukasz Magiera 0d6cfc879d Use specs-actors ignatures 2020-02-13 00:52:36 +01:00
Łukasz Magiera 5afaca6fa5 paych: Update to specs paych code 2020-02-13 00:52:19 +01:00
Travis Person 78c0c9b21a docs: Provide clearer instructions around bls wallets for miners 2020-02-12 23:36:56 +00:00
hannahhoward 720e29848b feat(markets): use non-custom go-fil-markets, from master 2020-02-12 14:32:26 -08:00
Łukasz Magiera 255f511abd storageminer: Updates to new types 2020-02-12 23:12:11 +01:00
Łukasz Magiera 220bd376b4 seed: Update lotus-seed for new genesis types 2020-02-12 22:41:59 +01:00
Oggy Nots 6bf87e28e9 create and publish github release (#1216)
* create and publish github release

* creates a tarball of 'lotus', 'lotus-storage-miner' and
'lotus-seal-worker' for darwin and linux
* computes and saves IPFS CID and sha512sum for each architecture
* creates a github release and uploads all artifacts
* triggered by tags matching regex /^v\d+\.\d+\.\d+$/ ie. v0.1.0

* add licenses and readme
2020-02-12 16:28:37 -05:00
Jakub Sztandera 49167cc55f Expose JWT permission error
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 21:25:29 +01:00
Łukasz Magiera a2b6aa8e67 Merge pull request #1257 from filecoin-project/feat/expand-repo-log
Expand "repo" string before logging
2020-02-12 21:05:36 +01:00
Jakub Sztandera c7ffaad763 Expand "repo" string before logging
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 21:00:07 +01:00
Jakub Sztandera 14580b6144 Import go-systemd properly
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 20:44:35 +01:00
Łukasz Magiera d68041c394 Merge pull request #1255 from filecoin-project/feat/new-hello
Use new hello
2020-02-12 20:44:05 +01:00
Jakub Sztandera 8610bcbec3 Use tuple encoding
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 19:23:15 +01:00
Jakub Sztandera 50702f309f Use new hello protocol
Using map encoder.
Types in LatencyMessage are int64 in spec, butl 1. tupled generator
does not support int64 right now; 2. there is no harm in using uint64 here.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 19:08:49 +01:00
Jakub Sztandera 5c3ed4d91a Remove ffi from types package
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-12 18:41:35 +01:00
whyrusleeping 243b295559 expose bad block cache reasons through api/cli 2020-02-11 23:44:55 -08:00
Łukasz Magiera 0aaf7b25a9 Propagate spec actor types more 2020-02-12 08:44:20 +01:00
Łukasz Magiera 526cfea568 state: fix actor lookup 2020-02-12 08:22:55 +01:00
whyrusleeping 0661a1bbfc mark down reason for block inclusion in bad tipset cache 2020-02-11 23:21:11 -08:00
Łukasz Magiera 22047d20ef actors: Wire up specs-actors init 2020-02-12 03:13:19 +01:00
Łukasz Magiera ca3eabafef genesis: Cleanup miner creation 2020-02-12 03:13:00 +01:00
Łukasz Magiera 23b662fe7d actors: Remove cborgen for old types 2020-02-12 03:12:39 +01:00
Łukasz Magiera 048759a147 genesis: Correct early state construction 2020-02-12 02:15:02 +01:00
Łukasz Magiera a4f6b739be genesis: Change template types 2020-02-12 01:58:55 +01:00
Whyrusleeping 5133ff16ba Merge pull request #1247 from filecoin-project/fix/lotus-shed-keyinfo
lotus-shed: add back support for bls and secp after sig changes
2020-02-11 13:40:42 -08:00
Łukasz Magiera 63e801e00f genesis: Cleanup the structure 2020-02-11 21:48:03 +01:00
Łukasz Magiera 201eb3bab8 Merge pull request #1251 from filecoin-project/asr/lotus-docs
Use HTTPS for links to the dashboard
2020-02-11 21:04:14 +01:00
Aayush Rajasekaran c4b790a910 Use HTTPS for links to the dashboard
- The link doesn't reliably work without HTTPS specified
2020-02-11 11:51:11 -08:00
Jim dbcf2c3cf5 Merge pull request #1248 from filecoin-project/@jimmylee/small-docs-update
documentation: adds file name length limit
2020-02-10 23:00:09 -08:00
jimmylee a9cb1d6543 documentation: adds file name length limit 2020-02-10 22:31:45 -08:00
Łukasz Magiera 3343e82307 wip gengen fixing 2020-02-11 04:31:28 +01:00
Łukasz Magiera 4d5c4d89ce stmgr: Update stmgr utils 2020-02-11 03:33:27 +01:00
Łukasz Magiera 91ca4a841a specs-actors: Import miner/power/cron/paych code 2020-02-11 02:43:26 +01:00
Łukasz Magiera 07ae3e49a3 mocksb: Update to the new interface 2020-02-11 02:23:03 +01:00
Łukasz Magiera e326a444b1 Merge pull request #1222 from filecoin-project/feat/support-multi-storage-miner-init
Support multi storage directories in miner init
2020-02-11 02:16:55 +01:00
Łukasz Magiera fa2c6605c2 Fix compilation after dep updates 2020-02-11 02:11:58 +01:00
Travis Person bc15d5234e lotus-shed: add back support for bls and secp after sig changes 2020-02-11 01:04:50 +00:00
Łukasz Magiera 05c262eb9f Merge pull request #1246 from filecoin-project/feat/msg-wait-cmd
expose StateWaitMsg through the cli
2020-02-11 01:50:52 +01:00
Łukasz Magiera a593a4f6f4 update ffi 2020-02-11 01:44:39 +01:00
whyrusleeping 1e1668e949 expose StateWaitMsg through the cli 2020-02-10 16:38:02 -08:00
Łukasz Magiera 6dce181314 Update specs-actors 2020-02-10 22:25:22 +01:00
Łukasz Magiera c0ed0dda8e specs-actors: Fis some test compilation errors 2020-02-10 20:16:36 +01:00
Łukasz Magiera 7e70536bf1 specs-actors: Finish type cleanup 2020-02-10 19:21:10 +01:00
Łukasz Magiera c72727b4fd specs-actors: Fix most compilation errors 2020-02-09 07:06:32 +01:00
Łukasz Magiera 41daf5ad28 gofmt 2020-02-08 03:18:37 +01:00
Łukasz Magiera 13435aebdc Spec Actors integration 2020-02-08 03:18:32 +01:00
Jakub Sztandera 352fb9f9ea Prefer tls
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-07 14:04:47 +01:00
Łukasz Magiera fc46938383 Merge pull request #1234 from filecoin-project/fix/signature-tests
add proper signature imports to tests
2020-02-07 08:15:43 +01:00
whyrusleeping 0309e2332c add proper signature imports to tests 2020-02-06 23:01:37 -08:00
Łukasz Magiera 17c3d158d2 Merge pull request #1233 from filecoin-project/fix/mark-bad
mark bad should be respected for every incoming tipset
2020-02-07 07:42:01 +01:00
whyrusleeping d4338047af mark bad should be respected for every incoming tipset 2020-02-06 22:39:24 -08:00
Łukasz Magiera 3aa521600a Merge pull request #1231 from filecoin-project/feat/update-msig-refs
actors: Drop refs to multisig_actor.go
2020-02-06 21:01:43 +01:00
Łukasz Magiera fc8bf8c15d Fix validation with extracted msig 2020-02-06 21:01:29 +01:00
Łukasz Magiera 3d3c1dbbb4 import key algs in wallet 2020-02-06 20:56:56 +01:00
Łukasz Magiera 1d0d429435 actors: Drop refs to multisig_actor.go 2020-02-06 20:49:21 +01:00
Łukasz Magiera 604c234484 Merge remote-tracking branch 'origin/master' into testnet/3 2020-02-06 20:32:25 +01:00
Łukasz Magiera 72c89ab89b Merge pull request #1223 from filecoin-project/fix/squash-forks
squash forks and use correct amt library everywhere
2020-02-06 20:14:55 +01:00
Łukasz Magiera 53d5efa944 Merge pull request #1227 from filecoin-project/fix/retrieval-market-errors
Update go-fil-markets to solve retrieval bug
2020-02-06 19:59:02 +01:00
Łukasz Magiera 44c1e3a347 Merge pull request #1228 from steven004/statepower
better power show
2020-02-06 19:34:46 +01:00
steven004 709fd12b7f better power show 2020-02-06 14:25:30 +08:00
Jakub Sztandera 21a603ed8f Merge pull request #1226 from filecoin-project/fix/dbg-errcheck
debug: Check error in AdvanceBlockCmd
2020-02-06 07:05:57 +01:00
hannahhoward d2c5d81e59 fix(deps): update go-fil-markets
update go-fil-markets to latest to solve an issue with retrieval
2020-02-05 18:48:47 -08:00
Łukasz Magiera 85f91a1114 debug: Check error in AdvanceBlockCmd 2020-02-06 03:09:52 +01:00
whyrusleeping 411a69233b merge miner and miner2 files 2020-02-05 17:07:29 -08:00
Łukasz Magiera cbf63aab1e Merge branch 'master' into testnet/3 2020-02-05 21:27:04 +01:00
Whyrusleeping dbb504e3d8 Merge pull request #1225 from filecoin-project/fix/fix-markets-integration
fix(go-fil-markets): fix integration
2020-02-04 20:59:26 -08:00
hannahhoward d42cd6a5e2 fix(deps): mod tidy 2020-02-04 20:10:58 -08:00
hannahhoward 97b645cd55 fix(go-fil-markets): fix integration
remove broken aspects of go-fil-markets integration and update versins
2020-02-04 20:08:08 -08:00
whyrusleeping faf05cafcf squash forks and use correct amt library everywhere 2020-02-04 18:26:42 -08:00
Łukasz Magiera e7a1be4dde Merge pull request #1217 from filecoin-project/feat/worker-prefetch
worker: Prefetch data in background
2020-02-05 03:09:24 +01:00
Travis Person e9470d873e Update usage 2020-02-05 00:07:44 +00:00
Travis Person cf8e90fa3e Load sectorbuilder config during storage miner init 2020-02-05 00:07:44 +00:00
Travis Person 62146b7bb3 Add pre-sealed-metadata flag to miner init
Metadata for presealed sectors now must be specified
2020-02-04 23:16:10 +00:00
Łukasz Magiera c013ef3b30 Merge pull request #1219 from filecoin-project/feat/auto-shim
Make it all build
2020-02-05 00:01:41 +01:00
Łukasz Magiera 575e962d16 Merge pull request #1220 from filecoin-project/fix/other-commands
Fix lotus-seed with sigs changes
2020-02-04 23:53:51 +01:00
Jakub Sztandera 70da3e124a Fix lotus-seed with sigs changes
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 23:49:10 +01:00
whyrusleeping f357edb8a4 mod tidy that code 2020-02-04 14:22:18 -08:00
whyrusleeping 028a113737 Make it all build 2020-02-04 14:19:05 -08:00
Łukasz Magiera 4bd6d7be1a storageminer: Work around broken fastPledgeCommitment 2020-02-04 21:46:31 +01:00
Jakub Sztandera 8d1ef188b1 Merge pull request #1211 from filecoin-project/feat/auto-shim
Invoker autoshim
2020-02-04 21:13:26 +01:00
Łukasz Magiera 63af9f2a9e worker: Paramfetch once 2020-02-04 20:17:18 +01:00
Łukasz Magiera 1a9c775407 worker: Prefetch data in background 2020-02-04 20:09:08 +01:00
Whyrusleeping 955b86deea Merge pull request #1188 from filecoin-project/feat/sigs-standalone
Don't depend on ffi
2020-02-04 10:45:21 -08:00
Łukasz Magiera 6eb342b8ee Merge pull request #1212 from filecoin-project/fix/remote-put-commit
remote: Fix put in commit
2020-02-04 18:22:12 +01:00
Jakub Sztandera 5bc1cb2aa3 Fix CheckBlockSignature, add docks
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 15:12:10 +01:00
Jakub Sztandera cb05001e5a mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 15:12:10 +01:00
Jakub Sztandera ad9e4db3d6 Reduce sig import locations
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 15:12:10 +01:00
Jakub Sztandera 5e6ab42cb8 Don't depend on ffi
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 15:12:04 +01:00
Łukasz Magiera 63ee6b6791 remote: Fix put in commit 2020-02-04 08:01:13 +01:00
Jakub Sztandera 54076e9a6b Invoker autoshim
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-02-04 07:46:24 +01:00
Łukasz Magiera d9f3b6c121 Merge pull request #1148 from filecoin-project/feat/msig-integration
DO NOT MERGE: Feat/msig integration
2020-02-04 07:19:49 +01:00
Łukasz Magiera d7548ab2f7 Merge pull request #1152 from filecoin-project/feat/update-markets
Update go-fil-markets to spec compliance, add CAR file support
2020-02-04 07:18:44 +01:00
Łukasz Magiera 0e81c1cf7e Merge branch 'testnet/3' into feat/update-markets 2020-02-04 07:17:22 +01:00
Łukasz Magiera f837cb5513 Merge pull request #1184 from filecoin-project/feat/chain-bisect
chain: bisect cmd
2020-02-04 04:43:31 +01:00
Łukasz Magiera b7ff44485a bisect: Allow any command 2020-02-04 04:40:49 +01:00
whyrusleeping 9cee31193c clean up tests and fix cli commands 2020-02-03 19:37:55 -08:00
Łukasz Magiera 9935e3acfc Merge pull request #1191 from filecoin-project/feat/new-sb-fs
Sectorbuilder FS refactor
2020-02-04 04:19:39 +01:00
Łukasz Magiera 90ecfbe0e4 Merge branch 'master' into feat/new-sb-fs 2020-02-04 04:15:25 +01:00
Łukasz Magiera 0ca349033d Merge pull request #1205 from filecoin-project/fix/readme
drop 'experimental' from readme description
2020-02-04 03:53:06 +01:00
whyrusleeping 30a922513b finish the shimming, pull shim code into separate file 2020-02-03 18:52:18 -08:00
whyrusleeping 8c169bb236 add to the shim, get tests passing 2020-02-03 18:52:18 -08:00
whyrusleeping cd976ad79f tests are mostly passing! 2020-02-03 18:52:18 -08:00
whyrusleeping baa3d09577 WIP: one more step before distraction 2020-02-03 18:52:18 -08:00
whyrusleeping c73c5987c7 WIP: integrate multisig actor from specs-actors 2020-02-03 18:52:18 -08:00
whyrusleeping dfe87c9f6f update to latest hamt changes 2020-02-03 18:52:18 -08:00
Łukasz Magiera 5cc089be12 Merge pull request #1207 from filecoin-project/feat/api-bstore
api-backed blockstore
2020-02-04 03:52:01 +01:00
Łukasz Magiera a8d18c8ac9 api-backed blockstore 2020-02-04 03:47:59 +01:00
whyrusleeping cc0635335c drop 'experimental' from readme description 2020-02-03 17:52:46 -08:00
Łukasz Magiera 65d8769002 Merge pull request #1203 from filecoin-project/feat/split-post-scheduler-from-storage-miner
split PoSt scheduler from Miner in preparation for extraction
2020-02-04 02:13:12 +01:00
laser d8f5330c29 don't consume short-lived context 2020-02-03 15:48:11 -08:00
laser ea2f53745e split FPoStScheduler from Miner
Rationale: Nodes want to handle scheduling of PoSts. Splitting the 
FPoStScheduler from the Miner allows nodes to reuse the Miner w/out 
having to reuse the PoSt scheduler.
2020-02-03 15:48:11 -08:00
Łukasz Magiera c9bd682c33 Merge pull request #1178 from filecoin-project/feat/multisig-balance-rpc
add a method to query available multisig balance
2020-02-04 00:43:08 +01:00
Łukasz Magiera 04c8bca073 Merge pull request #1195 from filecoin-project/test/fork-height-activation
add a test to ensure there are no off-by-one errors in fork activatio…
2020-02-03 23:26:56 +01:00
Whyrusleeping 7f1335a8dd Merge pull request #1196 from filecoin-project/fix/slash-blocks
Fix slash blocks
2020-02-03 10:17:43 -08:00
Łukasz Magiera ff77198a08 Update sectorbuilder with later cache mkdir 2020-02-03 18:37:40 +01:00
Łukasz Magiera 8da64d710e sealing: Work around broken remote sector put 2020-02-03 04:48:56 +01:00
Łukasz Magiera e453a38865 sealing: fix finalize with cache only 2020-02-02 20:36:15 +01:00
Jakub Sztandera ce7be477ce Fix slash blocks
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-31 17:07:37 -08:00
whyrusleeping 01b6ddbbd3 add a test to ensure there are no off-by-one errors in fork activation logic 2020-01-31 15:52:39 -08:00
Łukasz Magiera 37929ff75f sealing: more logging in pledge sector flow 2020-01-31 20:22:31 +01:00
Łukasz Magiera b6ba0ed47c fix pledgeReader with small sectors 2020-01-31 20:07:20 +01:00
Łukasz Magiera 87f7315f5a mod tidy 2020-01-31 19:57:28 +01:00
Łukasz Magiera 1b6ad6d2a1 worker: Fix transfer urls 2020-01-31 19:56:48 +01:00
Łukasz Magiera a62572bb76 Merge remote-tracking branch 'origin/master' into feat/new-sb-fs 2020-01-31 08:36:47 +01:00
Whyrusleeping f752770a47 Merge pull request #1185 from filecoin-project/fork/snowball
WIP, fork, fix slashing power calc
2020-01-30 21:31:37 -08:00
whyrusleeping d117cb61b6 change withUpdates to match fork height logic 2020-01-30 21:20:57 -08:00
whyrusleeping c071b2dc47 move back fork point, set new version 2020-01-30 21:15:00 -08:00
whyrusleeping d70ebd2ba5 some code review 2020-01-30 21:10:37 -08:00
whyrusleeping cda7f08b76 use less than, not equals 2020-01-30 21:05:41 -08:00
whyrusleeping 19a65319ee test and fix fork, add bigint parsing to lotus shed 2020-01-30 18:14:20 -08:00
WhyrusleepingandŁukasz Magiera 7402b14df3 Update chain/actors/actor_miner2.go
Co-Authored-By: Łukasz Magiera <magik6k@users.noreply.github.com>
2020-01-30 17:51:19 -08:00
whyrusleeping 0622eb7634 put miner changes behind a fork switch 2020-01-30 17:36:33 -08:00
Łukasz Magiera 95f344540e Fix tests 2020-01-31 02:27:38 +01:00
Łukasz Magiera ee9060aa14 Update sectorbuilder 2020-01-31 02:18:48 +01:00
Jakub Sztandera c6fd45727d Add state fork logic
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-30 17:17:34 -08:00
Jakub Sztandera cd27f5a4bc Merge pull request #1186 from filecoin-project/feat/lazy-param-box
build: Lazy ParametersJson
2020-01-30 16:37:38 -08:00
whyrusleeping 8ad8fa902d extra careful power checks on slashing 2020-01-30 16:36:18 -08:00
Jakub Sztandera 7861b5e6cb Merge pull request #1189 from filecoin-project/revert/rle-fix
Revert "Fix small bug in RLE"
2020-01-30 16:15:06 -08:00
Jakub Sztandera 70aaa8fc92 Revert "Fix small bug in RLE"
This reverts commit 6ed57ede6a.

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-30 16:14:32 -08:00
Jakub Sztandera e441b48ea7 Merge pull request #1187 from filecoin-project/fix/rle-bitcap
Fix small bug in RLE
2020-01-30 15:49:38 -08:00
Jakub Sztandera 6ed57ede6a Fix small bug in RLE
Thanks @frrist

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-30 15:18:54 -08:00
Łukasz Magiera aefc463586 build: Lazy ParametersJson 2020-01-30 23:50:24 +01:00
Jakub Sztandera f2340579a5 Fix power calculations
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-30 14:01:47 -08:00
Łukasz Magiera de5577ca70 chain: bisect cmd 2020-01-30 22:32:59 +01:00
Łukasz Magiera 316b11445e storageminer: Print fault data in info 2020-01-30 19:38:03 +01:00
Łukasz Magiera b42e481600 Merge pull request #1182 from zhy2006/master
fix:a bug of the power percentage in lotus-storage-miner info
2020-01-30 08:18:49 +01:00
Yang e5a48800ab fix:a bug of the power percentage in lotus-storage-miner info 2020-01-30 15:02:50 +08:00
Łukasz Magiera db50d01db9 Merge remote-tracking branch 'origin/master' into feat/new-sb-fs 2020-01-30 07:46:47 +01:00
Łukasz Magiera cec2085790 sealing: Fix pledgeReader 2020-01-30 07:41:30 +01:00
Łukasz Magiera 75ee71e35a Merge branch 'master' into feat/new-sb-fs 2020-01-30 07:39:52 +01:00
Whyrusleeping 7f9a3ac584 Merge pull request #1175 from filecoin-project/feat/fake-mine
Intoroduce advance-block command
2020-01-29 17:36:22 -08:00
Jakub Sztandera 1e9f293994 Return errors
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-29 17:35:32 -08:00
whyrusleeping b5f9a385ae add a method to query available multisig balance 2020-01-29 17:23:16 -08:00
Whyrusleeping f1114d3852 Merge pull request #1177 from filecoin-project/fix/fastpledge-math
Fix fast pledge math
2020-01-29 17:06:20 -08:00
Łukasz Magiera d27187b1de Fix fast pledge math 2020-01-30 02:01:10 +01:00
Łukasz Magiera 4aaa758543 fpost: better fault checks 2020-01-30 01:50:58 +01:00
Łukasz Magiera 03f07042ff fpost: print message apply result 2020-01-29 23:47:28 +01:00
Jakub Sztandera bcbfc931ba Intoroduce advance-block command
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-29 14:40:19 -08:00
Łukasz Magiera e2b2026fa5 actually call finalizeSector 2020-01-29 23:37:31 +01:00
Łukasz Magiera 4b8b79dbe0 sealing: FinalizeSector step 2020-01-29 22:25:06 +01:00
Whyrusleeping 9e5cc46638 Merge pull request #1158 from filecoin-project/feat/par-pledge
sealing: Parallel CommP calc in pledge sector
2020-01-29 12:15:22 -08:00
Łukasz Magiera ba542cf67a test fastPledgeCommitment 2020-01-29 21:01:20 +01:00
Łukasz Magiera 3f58ffe572 storageminer: New storage config 2020-01-29 20:53:45 +01:00
Łukasz Magiera 25f544f3db sealing: round parts in fastPledgeCommitment 2020-01-29 20:12:27 +01:00
Jim df747c8216 Merge pull request #1171 from filecoin-project/@jimmylee/docs-update-2
documentation: updates library schema with fedora instructions
2020-01-29 01:06:54 -08:00
jimmylee 53da298c4f documentation: updates library schema with fedora instructions 2020-01-29 01:04:43 -08:00
Jim 73c7f40ce3 Merge pull request #1170 from filecoin-project/@jimmylee/docs-update
lotus client list-deals
2020-01-29 00:52:53 -08:00
jimmylee 66bfadb71a documentation: adds lotus client list-deals for checking the status of a deal 2020-01-29 00:51:05 -08:00
Łukasz Magiera 5af64c53b6 initial sectorbuilder FS refactor integration 2020-01-29 00:08:02 +01:00
Łukasz Magiera b60860456d Merge pull request #1168 from filecoin-project/bugs/invalid-state-transition
planCommitting must handle SectorCommitFailed
2020-01-28 23:32:42 +01:00
hannahhoward 00941e4461 fix(sectorblocks): minor cleanups
add error check, slice keys
2020-01-28 14:15:12 -08:00
Whyrusleeping 095a309aef Merge pull request #1160 from terorie/docker-more-binaries
Dockerfile: more binaries
2020-01-28 14:11:09 -08:00
Whyrusleeping 834383b7e5 Merge pull request #1159 from jsign/fixdocker
Dockerfile: fixes
2020-01-28 14:10:27 -08:00
hannahhoward 503b16f6b1 style(deps): mod tidy 2020-01-28 14:08:13 -08:00
hannahhoward 433f9ff211 fix(markets): update version, pass payment interval params 2020-01-28 14:08:13 -08:00
hannahhoward be26c56362 feat(client): provide more informative retrieval message 2020-01-28 14:08:13 -08:00
hannahhoward 1a2c3adb2f fix(deps): update go-fil-markets 2020-01-28 14:08:13 -08:00
hannahhoward b8077fadaa fix(dealstate): update deal states to match current 2020-01-28 14:08:13 -08:00
hannahhoward 17a4a99f9c test(integration): reduce to fit in sector size
Reduce deal size to fit in sector
2020-01-28 14:08:13 -08:00
hannahhoward 71289b58ff feat(markets): update to support car files
Upgrades lotus version of go-fil-markets to its head, which supports car files and handles tracking
of pieces, reducing the size of sectorBlocks
2020-01-28 14:08:13 -08:00
laser 1cdf29244c write basic test affirming state change 2020-01-28 12:39:07 -08:00
laser cb665caf9e planCommitting must handle SectorCommitFailed
The SectorCommitFailed struct can be created from within Sealing#handleCommitting, and is created if actors.SerializeParams(params) produces an error or if m.api.MpoolPushMessage(ctx.Context(), msg) produces an error.
2020-01-28 11:46:26 -08:00
Jakub Sztandera eb4b85aea5 Merge pull request #1161 from filecoin-project/feat/chainwatch-challe
Add all challenges to chainwatch
2020-01-27 20:32:41 -08:00
Whyrusleeping 9c6c5aef5d Merge pull request #1162 from filecoin-project/feat/show-where-you-run
Add log to show where is the lotus running
2020-01-27 17:16:36 -08:00
Jakub Sztandera 050d552b9d Add log to show where is the lotus running
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:39:35 -08:00
Jakub Sztandera cf86bc6e23 fix insert
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:10:13 -08:00
Jakub Sztandera af61dfd8cd Fix order
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:09:00 -08:00
Jakub Sztandera 2a2a18a163 Add candidate
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:07:32 -08:00
Jakub Sztandera 29f3d6aa28 fix typo
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:03:09 -08:00
Jakub Sztandera 4379ff60f6 Create them table
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:01:24 -08:00
Jakub Sztandera a55a37c17b Pass the error
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 13:00:13 -08:00
Jakub Sztandera 5532093d58 Commit only once
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 12:59:07 -08:00
Jakub Sztandera 752be27815 Add all challenges to chainwatch
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-27 12:16:08 -08:00
Richard Patel 80903e86fa Dockerfile: more binaries 2020-01-27 20:02:56 +01:00
jsign dc076c6441 remove Dockerfile in base
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-27 15:14:24 -03:00
jsign c6e63db7b4 rebase and reapply
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-27 15:08:08 -03:00
jsign dff6e87ce9 Dockerfile: fixes
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-27 15:06:41 -03:00
Whyrusleeping c765289da9 Merge pull request #1154 from eshon/misc/docker-directory
Create a directory for Docker files, merge ldoublewood's Docker
2020-01-27 10:04:10 -08:00
jsign 3106f512b2 define method retry freq as a constant
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-26 21:52:19 -03:00
Whyrusleeping 2841edfb96 Merge pull request #1157 from filecoin-project/feat/cli/stategetdeal
cli: state get-deal
2020-01-25 10:17:49 -08:00
Łukasz Magiera c9c437cb3b sealing: Parallel CommP calc in pledge sector 2020-01-25 12:15:28 +01:00
Łukasz Magiera c0e317f829 cli: state get-deal 2020-01-25 11:41:17 +01:00
jsign 54f2e6ea3a extra fixes
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-24 22:48:30 -03:00
jsign dbd51ff8e7 fix issue #127
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-24 21:15:49 -03:00
eshon 63a5124f57 Moving lotus PR 745 into a tools/dockers/ directory and adding some other examples 2020-01-24 23:24:54 +01:00
ldoublewood eda726ec34 restore Makefile 2020-01-24 23:24:54 +01:00
ldoublewood bab23aa7b1 add docker support 2020-01-24 23:24:54 +01:00
Whyrusleeping 7b258eddc4 Merge pull request #975 from filecoin-project/feat/cli-slashing
chain slash-consensus command
2020-01-24 14:14:03 -08:00
Jakub Sztandera 3bf0bd6ce9 Merge pull request #1153 from filecoin-project/feat/version-bump
Bump version following blocksync bugfixes
2020-01-24 14:10:17 -08:00
whyrusleeping 0ed981be19 Bump version following blocksync bugfixes 2020-01-24 13:58:57 -08:00
Łukasz Magiera 77113844a2 chain slash-consensus command 2020-01-24 13:58:06 -08:00
Whyrusleeping 9da4296e21 Merge pull request #745 from filcloud/fix/pr-docker
add docker support
2020-01-24 13:48:30 -08:00
Łukasz Magiera 9fc5f0cd9d Merge pull request #1124 from filecoin-project/feat/sector-recovery
sealing: Implement some common error states
2020-01-24 21:25:03 +01:00
Łukasz Magiera 2f2e7be12a sealing: docstrings for sanity-checks 2020-01-24 21:15:02 +01:00
Whyrusleeping 9892bf4379 Merge pull request #1147 from filecoin-project/upd/badger
Update badger
2020-01-24 11:49:36 -08:00
Whyrusleeping 351a683812 Merge pull request #1151 from filecoin-project/lotus-health-v2
refactor lotus-health agent for robustness
2020-01-24 11:44:47 -08:00
ognots 445b7f3388 refactor lotus-health agent for robustness
add retry logic when calls to API fail.
if API reconnects fail, restart lotus-daemon as it means lotus-daemon is likely unhealthy.

wait for lotus node's chain to sync during each check cycle, to avoid restarting lotus-daemon if needing to sync.

handle SIGTERM properly.

general cleanup and refactor of code, getting ready of unnecessary channels
2020-01-24 11:46:47 -05:00
Łukasz Magiera 9e95372e5d Merge pull request #1149 from filecoin-project/fix/peermgr-ts
make expand peers thread safe
2020-01-24 17:38:35 +01:00
Łukasz Magiera b5660b58b3 Merge remote-tracking branch 'origin/master' into feat/sector-recovery 2020-01-24 01:53:58 +01:00
Jakub Sztandera b472ea371a Merge pull request #1150 from filecoin-project/feat/sync-dashboard
Sync dashboard to what we have on stats.testnet.filecoin.io
2020-01-23 16:21:11 -08:00
Travis Person 6703bd2c71 Sync dashboard to what we have on stats.testnet.filecoin.io 2020-01-24 00:13:15 +00:00
Jakub Sztandera 36388de4e1 make expand peers thread safe
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-23 15:40:17 -08:00
Jakub Sztandera 10159ba1bb Merge pull request #1145 from filecoin-project/fix/blocksync-spam
limit blocksync response sizes
2020-01-23 15:21:01 -08:00
Jakub Sztandera 792a2cad82 limit blocksync response sizes
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-23 14:24:52 -08:00
Jakub Sztandera 7f1b12d29e Merge pull request #1137 from filecoin-project/feat/chainwatch-active-deals
chainwatch: Track deal activations
2020-01-23 13:21:39 -08:00
Jakub Sztandera 23b46a05f7 Update badger
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-23 12:46:32 -08:00
Jakub Sztandera cd14a5eb40 Merge pull request #1142 from filecoin-project/feat/bs2
Add incremental timeouts to blocksync fetching
2020-01-23 12:44:08 -08:00
Jakub Sztandera 2256e62648 Improve warning
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-23 12:39:23 -08:00
Jakub Sztandera 6b42a78c3f Cleanup
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-23 12:35:57 -08:00
Łukasz Magiera 6b2b22782b sealing: PreCommitFailed can go to SealFailed 2020-01-23 18:45:57 +01:00
Łukasz Magiera de52d3cadd sealing: Handlef for PreCommitFailed 2020-01-23 18:34:04 +01:00
Łukasz Magiera 7e43c40529 storageminer: Use tabwriter in sectors list 2020-01-23 17:15:45 +01:00
Łukasz Magiera df9dfa9d0c sealing: Don't infinite-loop on fatal errors 2020-01-23 17:11:58 +01:00
Łukasz Magiera 08a2e0f82c sealing: Errors are hard 2020-01-23 17:02:55 +01:00
Łukasz Magiera 01dc9c767e sealing: Error types that can actually be checked 2020-01-23 16:57:50 +01:00
Łukasz Magiera 67b441838b sealing: Actually call handleSealFailed 2020-01-23 16:47:33 +01:00
Łukasz Magiera 94f2948020 sealing: implement handler for sealFailed 2020-01-23 16:38:10 +01:00
Łukasz Magiera f5540195de worker: Fix progress bars 2020-01-23 15:38:36 +01:00
Łukasz Magiera 558e4c7669 Fix tests after sectorbuilder update 2020-01-23 15:33:28 +01:00
Łukasz Magiera c3a5da8586 storageminer: log flag for sector status 2020-01-23 15:18:05 +01:00
Łukasz Magiera 02c8ab7839 sealing: Check ticket expiration 2020-01-23 15:05:44 +01:00
Łukasz Magiera 8414569428 Merge remote-tracking branch 'origin/master' into feat/sector-recovery 2020-01-23 14:29:44 +01:00
Łukasz Magiera bd97eb98c5 Merge pull request #1141 from filecoin-project/fix/no-cgo
Make it buld without cgo
2020-01-23 14:10:56 +01:00
Łukasz Magiera e67fbda305 mod tidy 2020-01-23 13:29:43 +01:00
Łukasz Magiera 26e6bc32ee sealing: check deal expiration 2020-01-23 13:17:45 +01:00
Łukasz Magiera 11a6bff416 miner: Handle stop signal when sleeping 2020-01-23 11:10:42 +01:00
Łukasz Magiera e67ee227a3 sealing: Nonzero exit on commit isn't fatal 2020-01-23 11:02:20 +01:00
Łukasz Magiera f8ec1d9d22 Merge remote-tracking branch 'origin/master' into feat/sector-recovery 2020-01-23 10:52:10 +01:00
Łukasz Magiera 7fb3360d6f storage: Fix handing stop call 2020-01-23 10:46:46 +01:00
Jakub Sztandera cb35625a53 Remove log
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-22 16:04:33 -08:00
Jakub Sztandera 26870501a7 mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-22 16:04:13 -08:00
Jakub Sztandera f5d061f34f Add incremental timeouts to blocksync fetching
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-22 15:57:42 -08:00
Jakub Sztandera 362fbbf913 Add blockheader_cgo file
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-22 15:55:52 -08:00
Jakub Sztandera f8d5f610b6 Merge pull request #1140 from filecoin-project/feat/profiling-work
wire up tracing into state tree flush, add pprof flag
2020-01-22 15:47:19 -08:00
Łukasz Magiera e43174f2af sealing: Not getting seal ticket isn't fatal 2020-01-22 22:16:45 +01:00
whyrusleeping 16523c2ef9 fixup tests 2020-01-22 12:56:40 -08:00
Łukasz Magiera d3a9006272 sealing: Wire up sector event log 2020-01-22 21:29:19 +01:00
Jakub Sztandera a404d535ee Make it buld without cgo
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-22 12:03:12 -08:00
whyrusleeping dcd01df2d3 wire up tracing into state tree flush, add pprof flag 2020-01-22 11:53:06 -08:00
Łukasz Magiera ba5a5d1248 sealing: wire up checkPieces and checkSeal 2020-01-22 20:47:29 +01:00
Łukasz Magiera 052b090bbf sealing: Fix planOne for global events 2020-01-22 19:30:56 +01:00
Łukasz Magiera 4654d9c192 chainwatch: Util routines / views 2020-01-22 16:12:47 +01:00
Łukasz Magiera 1e877eae86 sealing: Add Log field to SectorInfo 2020-01-22 03:41:39 +01:00
Łukasz Magiera 3c934ea21f Merge branch 'master' into feat/sector-recovery 2020-01-22 03:27:11 +01:00
Łukasz Magiera 52718e514c chainwatch: Track deal activations 2020-01-22 03:22:12 +01:00
Łukasz Magiera 4310cc23ce Merge pull request #1135 from filecoin-project/feat/listmsgs-cids
cli: state: --cids flag for list-messages
2020-01-22 00:33:53 +01:00
Łukasz Magiera bfb1cc6379 cli: state: --cids flag for list-messages 2020-01-21 23:54:01 +01:00
Jakub Sztandera cbfc675f4f Merge pull request #1120 from dtynn/fix/current_commit_flag
fix CurrentCommit in Makefile
2020-01-21 13:42:43 -08:00
Jakub Sztandera e7b5d678a9 rearange quotes
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-21 13:40:30 -08:00
ognots effacec817 range over right index to prevent bounds errors
the test scenario 'healthyHeadCheckWindow5' was causing index out of bounds errors.
the second range function in checkWindow was iterating over the incorrect slice of cids.
should be comparing latest items in slices first
2020-01-21 16:07:53 -05:00
Łukasz Magiera 3a89388039 Merge pull request #1134 from filecoin-project/feat/multisig-cli
add a CLI for multisig wallets
2020-01-21 21:05:41 +01:00
WhyrusleepingandŁukasz Magiera 3366c02a36 Update cli/multisig.go
Co-Authored-By: Łukasz Magiera <magik6k@users.noreply.github.com>
2020-01-21 11:52:59 -08:00
WhyrusleepingandŁukasz Magiera a26cc96a49 Update cli/multisig.go
Co-Authored-By: Łukasz Magiera <magik6k@users.noreply.github.com>
2020-01-21 11:52:50 -08:00
whyrusleeping 6d9ac84359 add a CLI for multisig wallets 2020-01-21 11:02:51 -08:00
Łukasz Magiera 882507e915 Merge pull request #1133 from filecoin-project/fix/build
Fix master build
2020-01-21 19:58:08 +01:00
Łukasz Magiera 08e1b52281 Fix master build 2020-01-21 19:51:17 +01:00
Łukasz Magiera cf153f89df Merge pull request #1131 from filecoin-project/feat/soft-map-cbg
cbor-gen: Soft struct-map unmarshaling
2020-01-21 19:44:39 +01:00
Łukasz Magiera d2401bc339 Update cbor-gen, error on unknown fields 2020-01-21 17:28:55 +01:00
Łukasz Magiera fd0bfc8777 Merge pull request #1089 from filecoin-project/feat/state-call-cmd
implement state call command for easy method calling
2020-01-21 17:16:54 +01:00
Łukasz Magiera 7b295d7bb0 Merge pull request #1115 from filecoin-project/feat/chainwatch-json-states
chainwatch: Store json states
2020-01-21 17:15:33 +01:00
Łukasz Magiera b6563ffc29 Merge pull request #1123 from filecoin-project/fix/jsonrpc-chclose-panic
jsonrpc: Fix channel closing race
2020-01-21 17:14:55 +01:00
Jakub Sztandera 2594ff6233 Merge pull request #1121 from filecoin-project/fix/mpool-stat-errs
mpool stat: Don't exit on StateGetActor error
2020-01-21 17:13:57 +01:00
Jakub Sztandera 807d803a81 Merge pull request #1130 from filecoin-project/fix/fpost-no-candidates
fpost: More logging
2020-01-21 17:07:22 +01:00
Łukasz Magiera 2076cb106d cobr-gen: Soft struct-map unmarshaling 2020-01-21 17:05:10 +01:00
Łukasz Magiera 5b304fa20a fpost: More logging 2020-01-21 16:01:42 +01:00
Łukasz Magiera fbc0330fa8 jsonrpc: Fix channel registration deadlock 2020-01-21 14:48:17 +01:00
Łukasz Magiera f5bfaff003 Merge pull request #1128 from filecoin-project/feat/chain-export-2
Implement chain import and exporting
2020-01-21 03:35:24 +01:00
Łukasz Magiera eac17a8328 mod tidy 2020-01-21 03:35:03 +01:00
Łukasz Magiera f9c9316990 Merge pull request #1127 from filecoin-project/bug/lotus-health
fixes health agent bug
2020-01-21 03:29:51 +01:00
whyrusleeping d9f5f6e2c6 add flag to halt after chain importing 2020-01-20 17:58:58 -08:00
whyrusleeping 955b755055 wire up importing 2020-01-20 17:53:55 -08:00
ognots 0c6e4c6c40 fixes health agent bug
was passing wrong variable to updateWindow function argument.
also updates duplicate function comment
2020-01-20 20:34:13 -05:00
whyrusleeping 57812fc61d chain export should work now 2020-01-20 15:51:28 -08:00
whyrusleeping 62f05d4c14 WIP: chain export 2020-01-20 15:51:28 -08:00
Łukasz Magiera e4de5c55ac sealing: Some state renaming 2020-01-20 23:04:46 +01:00
Łukasz Magiera efaf2c720b sealing: WIP SectorInfo sanity checks 2020-01-20 23:04:27 +01:00
Łukasz Magiera d1f419c9d1 jsonrpc: Fix channel closing race 2020-01-20 19:21:16 +01:00
Łukasz Magiera c5ece2a892 Merge pull request #1119 from dtynn/fix/some_sealing_problems
small fixes
2020-01-20 17:05:14 +01:00
Łukasz Magiera 7712d97270 mpool stat: Don't exit on StateGetActor error 2020-01-20 16:18:02 +01:00
dtynn 8e90d5fb17 fix CurrentCommit in Makefile 2020-01-20 18:22:42 +08:00
dtynn b2fcca87ff small fixes 2020-01-20 16:23:56 +08:00
Łukasz Magiera a46a9bb42e chainwatch: Store deals 2020-01-20 01:49:52 +01:00
Łukasz Magiera 62d661f898 chainwatch: Store json states 2020-01-19 22:48:19 +01:00
Łukasz Magiera 4436148fa1 Merge pull request #1117 from filecoin-project/fix/dont-override-loglvl
lotuslog: Don't override log levels
2020-01-19 21:38:36 +01:00
Łukasz Magiera 3886e050b0 lotuslog: don't override log levels 2020-01-19 21:18:35 +01:00
Łukasz Magiera ff4b0c8f5d Merge pull request #1110 from filecoin-project/fix/nil-newts-fpost-panic
fpost: Don't panic with nil new tipset
2020-01-19 21:17:51 +01:00
Łukasz Magiera f82ee0a2a7 Merge pull request #1116 from filecoin-project/fix/v0.2.5
Correctly update proving set & sector set with amt2
2020-01-19 17:53:59 +01:00
Łukasz Magiera b5d603dd46 Cleaner fork logic in onSuccessfulPoSt2 2020-01-19 17:44:44 +01:00
Łukasz Magiera 0b8ae006d3 Schedule the fork at 11000 2020-01-19 17:37:28 +01:00
Łukasz Magiera 55fd0a4e60 stmgr: Exetute miner amt after correctly switching to amt2 in miner code 2020-01-19 17:27:43 +01:00
Łukasz Magiera 3c4acbc6cb Merge pull request #1107 from dtynn/feat/bootybay-fork
correctly update proving set & sector set with amt2
2020-01-19 17:22:23 +01:00
Jakub Sztandera 8224aab851 Merge pull request #1112 from zhy2006/master
fix: calculate expected cost for sorting peers
2020-01-19 16:00:48 +01:00
Jakub Sztandera 28604f5a4c Merge pull request #1114 from filecoin-project/feat/bench-nits
bench: Don't print unseal results when unsealing is skipped
2020-01-19 15:58:38 +01:00
Łukasz Magiera 533081454a bench: Don't print unseal results when unsealing is skipped 2020-01-19 15:56:37 +01:00
Łukasz Magiera e94e64652b Merge pull request #1054 from filecoin-project/feat/event-states
Sector state machine changes
2020-01-19 15:53:07 +01:00
Yang 489ecef47b fix: calculate expected cost for sorting peers 2020-01-19 13:48:15 +08:00
dtynn 8b42ca76f8 add onSuccessfulPoSt2 2020-01-19 08:22:12 +08:00
Łukasz Magiera be2d138aac fpost: Don't panic with nil new tipset 2020-01-18 16:00:22 +01:00
Łukasz Magiera 1e782b3de2 Merge branch 'master' into feat/event-states 2020-01-18 14:40:59 +01:00
dtynn 8bd62165f5 RemoveFromSectorSet2 is declared but never used, remove redclared one 2020-01-18 20:08:44 +08:00
dtynn ae8a9a93bf correctly update proving set & sector set with amt2 after some fork height 2020-01-18 19:41:34 +08:00
Łukasz Magiera f7ab2103ce Merge pull request #1106 from terorie/debug-trust-params
params_debug.go: remove $TRUST_PARAMS override
2020-01-18 12:26:37 +01:00
Richard Patel c3d5a9848b params_debug.go: remove $TRUST_PARAMS override 2020-01-18 10:38:51 +01:00
Whyrusleeping 6d6d82a304 Merge pull request #1104 from filecoin-project/feat/frigid-fork
Catch cases where new old miners with bad code were getting made
2020-01-17 22:11:09 -08:00
whyrusleeping bc83c0221b bump that version 2020-01-17 21:45:51 -08:00
whyrusleeping c6bf252a21 use right fork trigger height 2020-01-17 21:35:45 -08:00
whyrusleeping f9ea6969c3 Catch cases where new old miners with bad code were getting made 2020-01-17 21:20:56 -08:00
whyrusleeping 9e956ff9f4 handle integers and peer IDs 2020-01-17 18:27:29 -08:00
whyrusleeping 0a45e97699 implement state call command for easy method calling 2020-01-17 18:27:29 -08:00
Whyrusleeping 3962d4204b Merge pull request #1096 from filecoin-project/fix/msgset-add-error
Add missing fields to duplicate message error
2020-01-17 16:22:20 -08:00
Jakub Sztandera fd76216652 Merge pull request #1101 from filecoin-project/patch/faulty-declare
fixup bitfield serialization in manual faulty sector handler
2020-01-17 18:19:35 +01:00
whyrusleeping 2a7dcb6e17 fixup bitfield serialization in manual faulty sector handler 2020-01-17 00:13:00 -08:00
Whyrusleeping b02eaee0d4 Merge pull request #1100 from filecoin-project/feat/blizzar-fork
The Blizzard Fork
2020-01-16 23:28:01 -08:00
whyrusleeping 6ccf24ce6c Fix miner tests, push back fork time 2020-01-16 23:10:47 -08:00
whyrusleeping c6186a03f1 quick mechanism to prevent miners from submitting slashable blocks 2020-01-16 22:58:10 -08:00
whyrusleeping ee4f503e10 Set fork height 2020-01-16 22:47:27 -08:00
whyrusleeping 0c227e89b2 fix last miner test, go mod tidy 2020-01-16 22:39:23 -08:00
whyrusleeping 128933a655 fix slashing test 2020-01-16 22:27:56 -08:00
whyrusleeping 055b215bc7 don't allow slashing with old blocks 2020-01-16 22:14:00 -08:00
whyrusleeping 611dd77442 properly filter messages during compute state 2020-01-16 19:36:54 -08:00
whyrusleeping fb173c058e WIP: blizzard fork changes and test utilities 2020-01-16 18:33:43 -08:00
whyrusleeping 2edb32979f move fork constant and tag fork branch with comment 2020-01-16 15:11:08 -08:00
whyrusleeping e3bed8d12a Catch passing duplicate block to arbitrate consensus fault 2020-01-16 15:11:08 -08:00
Jakub Sztandera 84de47377c Intoroduce AMT v2 and amtFsck
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-16 23:21:16 +01:00
Travis Person 06c99d0e18 Add missing fields to duplicate message error 2020-01-16 17:13:00 +00:00
Łukasz Magiera 0aebec6697 Merge branch 'master' into feat/event-states 2020-01-16 03:59:14 +01:00
Łukasz Magiera d4c50b8ea0 sealing: gofmt 2020-01-16 03:54:57 +01:00
Łukasz Magiera cc424d64fe sealing: Handle events based on current state 2020-01-16 03:53:59 +01:00
Jakub Sztandera 48ea36d37f Merge pull request #1092 from filecoin-project/feat/fountain-additional-pledge-collateral
Add more collateral to CreateStorageMiner call in fountain
2020-01-16 02:32:12 +01:00
Łukasz Magiera ffdd436b52 sealing: Handle seed changes more correctly 2020-01-16 02:25:49 +01:00
Travis Person ec9286eb4b Add more collateral to CreateStorageMiner call in fountain 2020-01-16 01:04:04 +00:00
Travis Person 68f8d60323 Adding fields to warning in vm ApplyMessage (#1090)
* Adding fields to warning in vm ApplyMessage
2020-01-16 01:36:16 +01:00
Jakub Sztandera 5cabb068c0 Merge pull request #1091 from filecoin-project/fix/fountain-rice
Fix fountain rice command
2020-01-16 01:35:01 +01:00
Travis Person 01079b0815 Fix fountain rice command 2020-01-16 00:29:23 +00:00
Whyrusleeping 7e15aa243e Merge pull request #1084 from jsign/resolveforks
new api to calculate arbitrary forks revert and applys
2020-01-15 12:55:14 -08:00
Łukasz Magiera e9ca6c0871 sealing: More cleanup 2020-01-15 21:53:14 +01:00
Łukasz Magiera 604bf64ef6 Move miner sealing logic into a separate package 2020-01-15 21:49:11 +01:00
Łukasz Magiera 925e057acb Some sector fsm tests 2020-01-15 21:04:02 +01:00
Jakub Sztandera c47e96ca45 Merge pull request #1088 from jiaruihuang/master
a bit more than the minimum collateral at the time of miner creation
2020-01-15 18:53:34 +01:00
Jiarui.Huang 6354a8ce03 So we should pass a bit more than the minimum collateral at the time of miner creation
Even 0.1% more would be enough# Please enter the commit message for your changes. Lines starting
2020-01-16 01:30:01 +08:00
Jakub Sztandera 85ec972abb Merge pull request #1087 from terorie/fix-go-flags
Makefile: fix $GOFLAGS
2020-01-15 15:29:23 +01:00
Richard Patel a8d38ad82f Makefile: fix $GOFLAGS 2020-01-15 14:56:53 +01:00
Łukasz Magiera be6badc6a5 Merge pull request #1086 from filecoin-project/fix/worker-cleanup-sealed
worker: Remove staging sectors in PreCommit
2020-01-15 02:50:21 +01:00
Łukasz Magiera cf9275a2a2 worker: Remove staging sectors in PreCommit 2020-01-15 02:37:37 +01:00
Łukasz Magiera 66f707c243 Merge pull request #1085 from filecoin-project/fix/worker-cleanup-sealed
worker: Cleanup sealed sector data in commit
2020-01-15 02:29:14 +01:00
Łukasz Magiera 1163e46622 worker: Cleanup sealed sector data in commit 2020-01-15 02:24:13 +01:00
jsign 08b99ff413 new api to calculate arbitrary forks revert and applys
Signed-off-by: jsign <jsign.uy@gmail.com>
2020-01-14 21:24:08 -03:00
Łukasz Magiera 23472aa4f2 statemachine: don't force users to see reflect 2020-01-15 01:08:20 +01:00
Łukasz Magiera 05edf50931 Merge branch 'master' into feat/event-states 2020-01-15 00:35:52 +01:00
Łukasz Magiera a8e39962d0 Merge pull request #1053 from filecoin-project/lotus-health
health agent to monitor lotus
2020-01-14 18:41:51 +01:00
ognots 5a42bb166e add rice for good health
allows lotus-health to be compiled and distributed properly
2020-01-14 12:18:45 -05:00
ognots 3953227702 use lotus cli and GetFullNodeAPI
also some other minor bug fixes
2020-01-14 12:18:45 -05:00
ognots d8d8ce7526 health agent to monitor lotus
watch if chain head changes in a given window of api polls
allows setting a threshold of how many times the chain head can remain
unchanged before failing health check
also can set interval for polling chain head
on failure, restarts systemd unit
2020-01-14 12:18:45 -05:00
Jakub Sztandera 95e754601e Merge pull request #1080 from filecoin-project/fix/nil-sigs
Fix nil signature verification
2020-01-14 17:15:45 +01:00
Łukasz Magiera 5e11da7316 build: bump version 2020-01-14 16:53:05 +01:00
Łukasz Magiera 24e36852af Fix nil signature verification 2020-01-14 16:52:01 +01:00
Łukasz Magiera 458acbf33d mod tidy 2020-01-14 16:39:25 +01:00
Łukasz Magiera 8a9707788c Merge branch 'master' into feat/event-states 2020-01-14 16:31:10 +01:00
Jakub Sztandera e9351135bc Merge pull request #1078 from filecoin-project/fix/seselctmsgs-softfail
miner: Don't fail on actor not found in selectMessages
2020-01-14 16:17:14 +01:00
Łukasz Magiera 1bb9cfee53 gofmt 2020-01-14 16:12:42 +01:00
Łukasz Magiera 7da41f0fdc miner: Don't fail on actor not found in selectMessages 2020-01-14 16:12:26 +01:00
Łukasz Magiera f22e933ab1 Merge pull request #1077 from filecoin-project/fix/chainwatch-append-params
chainmatch: Append params rice box
2020-01-14 15:27:45 +01:00
Łukasz Magiera affa4c1b07 chainmatch: Append params rice box 2020-01-14 15:24:46 +01:00
Łukasz Magiera 0011c321e2 Merge pull request #1071 from filecoin-project/feat/chainwatch-pg
Use postgres in chainwatch
2020-01-14 14:14:02 +01:00
Jakub Sztandera 1924eb1471 Merge pull request #1075 from filecoin-project/fix/acf-check
Add additional checks to ACF
2020-01-14 13:42:33 +01:00
Jakub Sztandera ce8c2fd656 Bump version
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-14 13:37:20 +01:00
Jakub Sztandera c2fdca470d Add additional checks to ACF
Fixes https://github.com/filecoin-project/lotus/issues/1074

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-14 13:22:41 +01:00
Jakub Sztandera 4f1bead0de Merge pull request #1070 from filecoin-project/fix/drop-1g-faucet
Drop 1g sector option from faucet
2020-01-14 12:43:47 +01:00
Łukasz Magiera 2dc2e0ba56 Drop 1g sector option from faucet 2020-01-14 06:23:10 +01:00
Łukasz Magiera 14128819de Correctly handle multi parent blocks 2020-01-14 06:17:31 +01:00
Łukasz Magiera a1e2a4452c Merge remote-tracking branch 'origin/master' into feat/chainwatch-pg 2020-01-14 06:09:30 +01:00
Whyrusleeping 3b34eba612 Merge pull request #997 from filecoin-project/feat/testnet2
Testnet2
2020-01-13 19:48:34 -08:00
Łukasz Magiera 11ac026b62 Merge branch 'feat/testnet2' into feat/chainwatch-pg 2020-01-14 04:20:39 +01:00
Łukasz Magiera 05970ffadd Merge pull request #1068 from filecoin-project/feat/testnet2-new-genesis
New testnet2 genesis
2020-01-14 04:15:11 +01:00
Travis Person 488a156e6f New testnet2 genesis 2020-01-14 03:10:31 +00:00
Łukasz Magiera a0f2bb0755 Increase block delay for TestAPIDealFlowReal 2020-01-14 03:51:14 +01:00
Whyrusleeping 9fded49470 Merge pull request #1067 from filecoin-project/feat/mock-sb-verif
Deal tests with mock sectorbuilder
2020-01-13 18:40:10 -08:00
Łukasz Magiera 69752b419d Update sectorbuilder 2020-01-14 03:09:34 +01:00
Łukasz Magiera 3d3e85c52d mod tidy 2020-01-14 03:05:46 +01:00
Łukasz Magiera 94a21e3aeb Update deps 2020-01-14 03:05:46 +01:00
Łukasz Magiera 2ca0c152ba Deal tests on mock sectorbuilder 2020-01-14 03:05:46 +01:00
Łukasz Magiera a2bcc1fec2 Mostly functional mock sectorbuilder 2020-01-14 03:05:35 +01:00
Łukasz Magiera 6cdac5df4f Merge pull request #1066 from filecoin-project/docs/1k-params-debug
note that you need to manually download params when building in debug
2020-01-14 02:17:27 +01:00
whyrusleeping 92357b3a8b note that you need to manually download params when building in debug mode 2020-01-13 17:15:42 -08:00
Łukasz Magiera 872ee5b7e7 Merge pull request #1065 from filecoin-project/bug/more-rice
Add rice calls to stats and lotus-shed
2020-01-14 01:53:57 +01:00
Travis Person 4d30ab77be Add rice calls to stats and lotus-shed 2020-01-14 00:50:48 +00:00
Łukasz Magiera 85f0f0bf81 mod tidy 2020-01-14 00:38:08 +01:00
Łukasz Magiera d6174292b3 Merge pull request #1064 from filecoin-project/fix/drop-th-pnet
Drop pnet from townhall
2020-01-14 00:37:29 +01:00
Łukasz Magiera 0bf41bcd10 Drop pnet from townhall 2020-01-14 00:36:05 +01:00
Łukasz Magiera 027a0e805b Merge pull request #1063 from filecoin-project/feat/no-more-pnet
remove private network and put dht into a sub namespace
2020-01-14 00:31:11 +01:00
whyrusleeping fefd21ad9c remove private network and put dht into a sub namespace 2020-01-13 15:29:06 -08:00
Łukasz Magiera d9c803ea9e Merge pull request #1062 from filecoin-project/feat/no-more-1gb-sectors
remove support for 1gb sectors
2020-01-14 00:21:21 +01:00
whyrusleeping 0414e99fe7 remove support for 1gb sectors 2020-01-13 15:18:26 -08:00
Łukasz Magiera 0fb51a95cc Merge pull request #1061 from filecoin-project/feat/testnet2-network
Add bootstrap peers and genesis
2020-01-13 23:13:39 +01:00
Travis Person 9298d183bf Add bootstrap peers and genesis 2020-01-13 22:08:11 +00:00
Łukasz Magiera 0402abe36b Fix tests 2020-01-13 21:59:21 +01:00
Łukasz Magiera 44112da971 Merge pull request #1060 from filecoin-project/feat/reserve-sector-states
Revesve some sector states
2020-01-13 21:56:13 +01:00
Łukasz Magiera 2ed89f496f Revesve some sector states 2020-01-13 21:54:28 +01:00
Łukasz Magiera 2fecf3a8f1 Fix tests 2020-01-13 21:51:34 +01:00
Łukasz Magiera 2ef8c1ae0c statemachine: Better naming 2020-01-13 18:44:59 +01:00
Łukasz Magiera 2fea9433d8 sectors: Correctly set CommitMessage 2020-01-13 18:18:52 +01:00
Łukasz Magiera e06c19b51c update deps 2020-01-13 17:39:54 +01:00
Łukasz Magiera 34abc3d023 Merge branch 'feat/testnet2' into feat/event-states 2020-01-13 15:52:43 +01:00
Łukasz Magiera d78a5e0a9f Decimal types for some miner columns 2020-01-13 14:01:11 +01:00
Łukasz Magiera 719171faa3 Set smaller batch size 2020-01-13 00:46:54 +01:00
Łukasz Magiera a896b30039 gofmt 2020-01-10 20:55:58 +01:00
Łukasz Magiera 50bac00329 Merge branch 'master' into feat/testnet2 2020-01-10 20:55:40 +01:00
Łukasz Magiera b6fda30719 Merge pull request #1057 from filecoin-project/feat/markets-extraction
Markets Extraction
2020-01-10 20:49:09 +01:00
Whyrusleeping fd4af3f7a9 Merge pull request #1056 from filecoin-project/fix/candidate-dupe
check for duplicate candidates in block headers
2020-01-10 11:24:46 -08:00
Łukasz Magiera f6d41ee77d Port sector state maching to evtsm 2020-01-10 20:24:15 +01:00
hannahhoward 0ce1bf706b refactor(markets): reorg file structure 2020-01-10 10:33:26 -08:00
hannahhoward 56653eeca6 fix(storagemarket): fix compile errors 2020-01-10 10:01:48 -08:00
whyrusleeping 83605dfd95 check for duplicate candidates in block headers 2020-01-10 09:57:58 -08:00
hannahhoward 353f93fddf fix(storagemarketadapter): minor fix for test 2020-01-10 09:49:41 -08:00
hannahhoward 65ecb33630 feat(storagemarket): extract storage market
remove all shared components, point at go-fil-components repo
2020-01-10 09:49:07 -08:00
hannahhoward 0a4eeb7cb1 refactor(retrievalmarket): switch to go-fil-markets repo
Switch go-fil-components to go-fil-markets
2020-01-10 09:13:12 -08:00
Łukasz Magiera 469136ee86 Merge pull request #1040 from filecoin-project/feat/fork-signaling
Add fork signaling to blockheader
2020-01-10 13:33:29 +01:00
hannahhoward ccf359d057 feat(retrieval): extract retrievalmarket
Extract retrieval market and modify shared types
2020-01-09 19:46:07 -08:00
Łukasz Magiera d6b0648610 Merge pull request #951 from filecoin-project/feat/storage-market-skeleton
Storage Market: Draw clean interfaces and node boundaries around storage market
2020-01-10 03:58:39 +01:00
hannahhoward da4528932a feat(storagemarket): initial extraction
Types for storage market

Modify deals.Provider to implement storagemarket.StorageProvider

Inject storagemarket.StorageProvider

Storage Provider interfaces

Storage Client interfaces

Add ValidatePublishedDeal to ClientNodeAdapter

Remove FundManager from client

Remove Wallet from client

Remove StateManager, Events, Wallet from client

Rebasing

- Copy types.BigInt, use TokenAmount/BigInt for token amounts
- Remove auto-imported log package
- Move `checkAskSignature` to a client file.
- Plumb contexts through

fix(storagemarket): use publish cids

Switch back to publish message cids to reduce the dependency surface area
2020-01-10 03:29:46 +01:00
Łukasz Magiera 5f460b380d Merge pull request #1045 from filecoin-project/feat/mock-sectorbuilder
WIP: implement mock sectorbuilder for easier storage miner testing
2020-01-10 01:33:43 +01:00
Łukasz Magiera 55f76f19d3 Merge pull request #1051 from filecoin-project/feat/self-deal-no-sig
don't require signatures for self deals
2020-01-10 01:25:06 +01:00
Łukasz Magiera 0bafc00b52 Merge pull request #1052 from filecoin-project/feat/coverage-integration
Renable codecov, improve CI
2020-01-10 01:21:53 +01:00
Jakub Sztandera d309b56ad6 Codecov ignore cbor gen
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-09 23:52:44 +01:00
whyrusleeping 6c9289df0a don't require signatures for self deals 2020-01-09 14:18:06 -08:00
Jakub Sztandera a82a0769fa Disable buildall on macos (it takes forever)
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-09 23:13:07 +01:00
Jakub Sztandera 61849ef7ea Enable codecov
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-09 23:12:33 +01:00
Jakub Sztandera 960b6012c2 Count coverage of integration tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-09 22:53:41 +01:00
Łukasz Magiera da2a11ed76 Event-based state machine 2020-01-09 22:23:31 +01:00
Łukasz Magiera f0f8d83980 Merge pull request #826 from filecoin-project/feat/retrieval-market-skeleton
Retrieval Market Cleanup W/ Node Interfaces
2020-01-09 22:06:46 +01:00
whyrusleeping 45e576addf mod tidy 2020-01-09 12:59:37 -08:00
whyrusleeping 7534ac1e1a add ability to control seal operations completion time 2020-01-09 12:50:45 -08:00
whyrusleeping bda85e4097 more features, better locking 2020-01-09 11:23:42 -08:00
whyrusleeping 5e16aab51b fix tests, expand interfaces a little 2020-01-09 10:28:14 -08:00
Jakub Sztandera f572d9735d Merge pull request #1049 from filecoin-project/fix/sb-ds-prefix
Pass correct datastore into sectorbuilder
2020-01-09 15:33:15 +01:00
Łukasz Magiera fac47bfc54 Pass correct datastore into sectorbuilder 2020-01-09 14:23:44 +01:00
whyrusleeping cc56389dbb attempt to fix the DI loading, still not working 2020-01-08 20:51:18 -08:00
whyrusleeping 60969c69a7 implement a mocked out sectorbuilder, probably not useful yet 2020-01-08 20:27:14 -08:00
hannahhoward 99309ec0dc fix(retrievalmarket): add mutex for subscribers
Add a mutex to protect access to the subscriber list for retrieval market
2020-01-08 19:46:11 -08:00
whyrusleeping d08898ef37 make storage miner acccept an interface to the sectorbuilder 2020-01-08 17:10:17 -08:00
Łukasz Magiera b7e35ae3ed Merge pull request #1042 from filecoin-project/feat/limit-seal-proof-lookback
Set hard limit on maximum randomness lookback for seal proof submissions
2020-01-09 01:14:46 +01:00
whyrusleeping 7ba34535b7 Set hard limit on maximum randomness lookback for seal proof submissions 2020-01-08 14:43:03 -08:00
Łukasz Magiera 8cbcbbd7a4 Merge branch 'feat/testnet2' of github.com:filecoin-project/go-lotus into feat/testnet2 2020-01-08 22:44:54 +01:00
Łukasz Magiera 36a5c7d8f5 Merge branch 'master' into feat/testnet2 2020-01-08 22:38:45 +01:00
hannahhoward 5b74a71dd3 feat(retrievalmarket): extract skeleton interfaces
Define all types to spec, modify interfaces, wrap old code

fix(builder): use client blockstore for retrieval

feat(retrieval): add node implementations

add node adapters for client & provider so that retrieval can be extracted
2020-01-08 12:45:43 -08:00
Łukasz Magiera 716b2a4bcb Merge pull request #1041 from filecoin-project/fix/paramsjson-embed
paramfetch: bring parameters.json back to this repo
2020-01-08 21:41:32 +01:00
Łukasz Magiera 13c8fe3fb3 mod tidy 2020-01-08 21:31:44 +01:00
Łukasz Magiera da38822dfd paramfetch: bring parameters.json back to this repo 2020-01-08 21:31:35 +01:00
Łukasz Magiera f36d81070b mod tidy 2020-01-08 21:15:55 +01:00
Jakub Sztandera 959b725ab6 Merge pull request #1038 from filecoin-project/feat/new-golog
Update go-log to v2
2020-01-08 20:41:55 +01:00
Łukasz Magiera 3891f015d7 Merge pull request #1039 from filecoin-project/feat/secpk-default
switch default key type to secp256k1
2020-01-08 20:40:08 +01:00
Jakub Sztandera 8cfb4aafcd Add fork signaling to blockheader
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 20:31:08 +01:00
whyrusleeping 6ce9a7f225 switch default key type to secp256k1 2020-01-08 11:24:18 -08:00
Jakub Sztandera 1ed62628a7 Update go-log to v2
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 20:22:31 +01:00
Jakub Sztandera b5328d01cf Update to go-log v1.0.1
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 20:20:56 +01:00
Jakub Sztandera 72a62d49b3 Merge pull request #1037 from filecoin-project/feat/badger2
Update to badger v2
2020-01-08 20:20:11 +01:00
Jakub Sztandera 886898b137 Update to badger v2
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 19:56:45 +01:00
Łukasz Magiera a9ca6d4065 Merge branch 'master' into feat/chainwatch-pg 2020-01-08 18:50:58 +01:00
Jakub Sztandera 00683549ae Merge pull request #1036 from filecoin-project/feat/v0.1.6
v0.1.6
2020-01-08 18:44:49 +01:00
Łukasz Magiera f32bacb32d v0.1.6 2020-01-08 18:42:19 +01:00
Łukasz Magiera 5a12d60c6f Merge pull request #1035 from filecoin-project/fix/rle-count
Verify RLE+ counts
2020-01-08 18:41:06 +01:00
Jakub Sztandera f627ff2383 Verify RLE+ counts
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 18:30:13 +01:00
Łukasz Magiera 79028397ad chainwatch: sync in batches 2020-01-08 17:29:46 +01:00
Łukasz Magiera 1b5e1c4753 gofmt 2020-01-08 15:18:30 +01:00
Łukasz Magiera 855fb26a81 mod tidy 2020-01-08 15:18:13 +01:00
Łukasz Magiera ab922ed1ba Merge remote-tracking branch 'origin/master' into feat/chainwatch-pg 2020-01-08 15:08:34 +01:00
Łukasz Magiera f198e81af1 Merge pull request #1032 from filecoin-project/feat/drop-most-fatal-errors
reduce most vm errors to non-fatal, explicitly mark disk issues as fatal
2020-01-08 14:58:35 +01:00
Jakub Sztandera 83cbf141a8 Merge pull request #1034 from filecoin-project/feat/lotuslog
Set logging levels in a single place
2020-01-08 14:57:55 +01:00
Łukasz Magiera 9fd183e74f Merge pull request #500 from filecoin-project/feat/dt-implementation
Extract Data Transfer Implementation
2020-01-08 14:52:01 +01:00
Łukasz Magiera 31173ff4b4 Set logging levels in a single place 2020-01-08 14:49:34 +01:00
Łukasz Magiera bf9aa4465b mod tidy 2020-01-08 14:20:43 +01:00
hannahhoward 5312340bf9 refactor(datatransfer): use independent repo
Use independent repo for go-data-transfer
2020-01-08 14:20:31 +01:00
hannahhoward 61e2568b8d feat(datatransfer): implement and extract
feat(datatransfer): setup implementation path

Sets up a path to implementation, offering both the dagservice implementation and a future graphsync
implement, establishes message interfaces and network layer, and isolates the datatransfer module
from the app

WIP using CBOR encoding for dataxfermsg

* Bring cbor-gen stuff into datatransfer package
* make transferRequest private struct
* add transferResponse + funcs
* Rename VoucherID to VoucherType
* more tests passing

WIP trying out some stuff
* Embed request/response in message so all the interfaces work AND the CBOR unmarshaling works: this is more like the spec anyway
* get rid of pb stuff

all message tests passing, some others in datatransfer

Some cleanup for PR

Cleanup for PR, clarifying and additional comments

mod tidy

Respond to PR comments:
* Make DataTransferRequest/Response be returned in from Net
* Regenerate cbor_gen and fix the generator caller so it works better
* Please the linters

Fix tests

Initiate push and pull requests (#536)

* add issue link for data TransferID generation
* comment out failing but not relevant tests
* finish voucher rename from Identifier --> Type

tests passing

cleanup for PR

remove unused fmt import in graphsync_test

a better reflection

send data transfer response

other tests passing

feat(datatransfer): milestone 2 infrastructure

Setup test path for all tickets for milestone 2

responses alert subscribers when request is not accepted (#607)

Graphsync response is scheduled when a valid push request is received (#625)

fix(datatransfer): fix tests

fix an error with read buffers in tests

fix(deps): fix go.sum

Feat/dt graphsync pullreqs (#627)

* graphsync responses to pull requests

Feat/dt initiator cleanup (#645)

* ChannelID.To --> ChannelID.Initiator
* We now store our peer ID (from host.ID()) so it can be used when creating ChannelIDs.
* InProgressChannels returns all of impl.channels, currently just for testing
* Implements go-data-transfer issue
* Some assertions were changed based on the above.
* Renamed some variables and added some assertions based on the new understanding
* Updated SHA for graphsync module
* Updated fakeGraphSync test structs to use new interfaces from new SHA above

Techdebt/dt split graphsync impl receiver (#651)

* Split up graphsyncImpl and graphsyncReceiver
* rename graphsync to utils

DTM sends data over graphsync for validated push requests (#665)

* create channels when a request is received. register push request hook with graphsync. fix tests.
* better NewReaders
* use mutex lock around impl.channels access
* fix(datatransfer): fix test uncertainty
* fix a data race and also don't use random bytes in basic block which can fail
* privatize 3 funcs

with @hannahhoward

Feat/dt gs pullrequests (#693)

* Implements DTM Sends Data Over Graphsync For Validated Pull Requests
* rename a field in a test struct
* refactor a couple of private functions (one was refactored out of existence)

Feat/dt subscribe, file Xfer round trip (#720)

Implements the rest of Subscriber Is Notified When Request Completed #24:
* send a graphsync message within a go func and consume responses until error or transfer is complete.
* notify subscribers of results.
* Rename datatransfer.Event to EventCode.
* datatransfer.Event is now a struct that includes a message and a timestamp as well as the Event.Code int, formerly Event, update all uses
* Add extension data to graphsync request hook, gsReq
* rename sendRequest to sendDtRequest, to distinguish it from sendGsRequest, where Dt = datatransfer, Gs = graphsync
* use a mutex lock for last transfer ID
* obey the linter

Don't respond with error in gsReqRcdHook when we can't find the datatransfer extension. (#754)

* update to correct graphsync version, update tests & code to call the new graphsync hooks
* getExtensionData returns an empty struct + nil if we can't find our extension
* Don't respond with error when we can't find the extension.
* Test for same
* mod tidy

minor fix to go.sum

feat(datatransfer): switch to graphsync implementation

Move over to real graphsync implementation of data transfer, add constructors for graphsync
instances on client and miner side

fix(datatransfer): Fix validators

Validators were checking payload cid against commP -- which are not the same any more. Added a
payloadCid to client deal to maintain the record, fixed validator logic

Feat/dt extraction use go-fil-components/datatransfer (#770)

* Initial commit after changing to go-fil-components/datatransfer
* blow away the datatransfer dir
* use go-fil-components master after its PR #1 was merged
* go mod tidy

use a package

updates after rebase with master
2020-01-08 14:19:28 +01:00
Łukasz Magiera 1392dcc273 Merge remote-tracking branch 'origin/master' into feat/testnet2 2020-01-08 13:53:01 +01:00
Łukasz Magiera 117bea4e4e Merge pull request #1030 from filecoin-project/feat/chain-list-messages
implement list-messages command
2020-01-08 13:50:55 +01:00
Łukasz Magiera 86a22a3896 Merge pull request #1029 from filecoin-project/feat/mpoolpush-cid
mpool: Return CID in MpoolPush
2020-01-08 13:43:03 +01:00
whyrusleeping 95a89ad192 implement list-messages command 2020-01-08 13:41:23 +01:00
Łukasz Magiera 5153f67a2e Merge pull request #1033 from filecoin-project/feat/sync-mark-bad
Add command to mark given blocks as bad
2020-01-08 13:35:34 +01:00
Łukasz Magiera 4de01190a1 api: Require admin perm for SyncMarkBad 2020-01-08 13:34:53 +01:00
Jakub Sztandera d213bd1fee Merge pull request #1025 from filecoin-project/fix/faults-counting
Fix faults handling
2020-01-08 11:03:14 +01:00
whyrusleeping 80c19df4bb go mod tidy 2020-01-07 21:45:10 -08:00
whyrusleeping 897cf72933 Add command to mark given blocks as bad 2020-01-07 21:42:15 -08:00
Whyrusleeping 11bfab67f9 Merge pull request #986 from filecoin-project/feat/update-stats-to-golog
Use golog in stats tool, and better sync control
2020-01-07 21:38:56 -08:00
whyrusleeping 62db7a6dda fix build 2020-01-07 21:10:43 -08:00
Łukasz Magiera a11e8093e5 mpool: Return CID in MpoolPush 2020-01-07 21:10:30 -08:00
whyrusleeping 3965e1053e fix build 2020-01-07 21:05:45 -08:00
whyrusleeping e41dbdad90 reduce most vm errors to non-fatal, explicitly mark disk issues as fatal 2020-01-07 19:46:55 -08:00
Jakub Sztandera 64496690bb go mod tidy
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 23:09:46 +01:00
Jakub Sztandera f572cdea47 Fix logic, improve tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 23:03:58 +01:00
Jakub Sztandera 5e775929be Cleanup handing and add tests
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 23:03:58 +01:00
Jakub Sztandera 65724133ea Add tests
,
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 23:03:58 +01:00
Jakub Sztandera a63c34a902 Handle faults in ss and pss correctly
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 23:03:18 +01:00
Jakub Sztandera dbc729d049 Validate length of RLE
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-07 22:54:43 +01:00
Łukasz Magiera 7b134b8317 Merge pull request #1031 from filecoin-project/feat/block-message-limit
introduce a limit on the number of messages a block can have
2020-01-07 21:48:57 +01:00
Łukasz Magiera 22e9815928 Merge remote-tracking branch 'origin/master' into feat/testnet2 2020-01-07 21:45:30 +01:00
whyrusleeping a109ae1490 introduce a limit on the number of messages a block can have 2020-01-07 12:41:26 -08:00
Łukasz Magiera f019b80af0 Merge pull request #998 from filecoin-project/feat/move_sectorbuilder_to_module
replace sectorbuilder with go-sectorbuilder
2020-01-07 18:03:58 +01:00
laser 0ffec0a9ad go mod tidy 2020-01-07 08:27:08 -08:00
laser 841f9c3627 reorganize imports to pass linter 2020-01-07 08:23:12 -08:00
laser 20321bb476 handle rebase 2020-01-07 08:18:35 -08:00
laser 4bbc693d9c go mod tidy 2020-01-07 07:52:19 -08:00
laser 3ae1bd5b78 add paramfetch import to lotus-bench 2020-01-07 07:52:06 -08:00
laser ce837da935 point go-sectorbuilder to head of master 2020-01-07 07:48:53 -08:00
laser 1b4ddefe27 manage Groth parameter cache keys by hand
I've moved paramfetch.go and parameters.json into the go-sectorbuilder module, so the CircleCI checksum-calculating functions won't work as-written. We'll need to manage the cache key manually.
2020-01-07 07:48:44 -08:00
laser abf6acc211 moved logger from paramfetch.go (no longer in lotus) to genesis.go 2020-01-07 07:48:44 -08:00
acruikshank 7873213b11 switch sectorbuilder from lib to external module
point to correct version of sectorbuilder + ensure go-datastore stays at 0.1.1

replace local address type with go-address

consume paramfetch.GetParams instead of local paramfetch.go

remove constants now defined in sectorbuilder
2020-01-07 07:48:43 -08:00
Łukasz Magiera 97ae184d0a Merge remote-tracking branch 'origin/master' into feat/testnet2 2020-01-07 15:06:35 +01:00
Łukasz Magiera 8f0c02043b Merge pull request #992 from filecoin-project/feat/extract-cborutil
Extract cborutil library
2020-01-07 15:04:08 +01:00
Łukasz Magiera 1e7f10e387 gofmt 2020-01-07 15:00:10 +01:00
hannahhoward 718acb0a86 refactor(cborutil): extract cborutil library
Use extracted cborutil library
2020-01-07 14:59:35 +01:00
Łukasz Magiera 85097a871f Merge pull request #991 from filecoin-project/feat/extract-address
Extract address type & crypto utils
2020-01-07 14:57:39 +01:00
hannahhoward 14ecd1929b refactor(crypto): use extracted crypto library 2020-01-07 14:53:30 +01:00
hannahhoward 8418464d91 refactor(address): use extracted address library
Switch to using extracted address library
2020-01-07 14:53:27 +01:00
Łukasz Magiera f6b96480d1 Merge pull request #1008 from steven004/EnhanceRle
Enhance rleplus testing
2020-01-07 14:44:02 +01:00
Łukasz Magiera 29af953cec Merge pull request #1013 from adam-hanna/master
adds fedora installation instructions
2020-01-07 14:34:51 +01:00
Łukasz Magiera 8e407acd76 Merge pull request #1020 from filecoin-project/feat/consume-extracted-paramfetch
consume newly-extracted paramfetch
2020-01-07 14:33:15 +01:00
Łukasz Magiera 2635028933 Merge pull request #1024 from filecoin-project/fix/sizestr-overflow
Fix SizeStr index out of band
2020-01-07 14:30:15 +01:00
Łukasz Magiera 605562467d Flatten fork code for testnet2 2020-01-06 19:39:57 +01:00
Jakub Sztandera 2d22f9c3d3 Fix SizeStr index out of band
add test for it

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-06 15:27:19 +01:00
laser 19db1d88bc go mod tidy 2020-01-02 11:12:05 -08:00
laser 6a740a6d67 consume newly-extracted paramfetch 2020-01-02 11:08:49 -08:00
Adam Hanna 9fd56318fe adds fedora installation instructions 2019-12-27 21:58:00 +00:00
steven004 fdbbf65fea comment print 2019-12-24 13:42:30 +08:00
Jim f6c6fba812 Merge pull request #1007 from filecoin-project/@jimmylee/docs-update
@jimmylee/docs update
2019-12-24 04:25:52 +01:00
@wwwjim a24fca671e documentation: adds library organization as json so its fully controllable from the lotus repo 2019-12-23 19:21:42 -08:00
steven004 d313d97947 Add a little more check 2019-12-24 08:51:10 +08:00
@wwwjim 5ecd5093a9 documentation: renames redundant filename 2019-12-23 10:35:16 -08:00
Jim 99de8aa557 Merge pull request #1004 from filecoin-project/@jimmylee/docs-update
@jimmylee/docs update
2019-12-23 06:45:38 +01:00
wwwjim 5e04e5b85d documentation: adds chain sync progress command to troubleshooting 2019-12-22 21:43:37 -08:00
wwwjim 0458062bce desktop: updates proof parameter step with environment variable 2019-12-22 21:39:26 -08:00
wwwjim 9ae6bcc5df documentation: reduces script to one line in local-dev-net.md 2019-12-22 21:31:55 -08:00
wwwjim 727ae2b877 documentation: adds glossary to the documentation directory 2019-12-22 21:25:51 -08:00
Whyrusleeping 30b857bc8a Merge pull request #999 from filecoin-project/fix/sector-set-removal
don't fail execution if the fault set contains an invalid sector ID
2019-12-20 20:15:25 -08:00
whyrusleeping dafad17a9b also test fault values out of range 2019-12-20 20:04:38 -08:00
whyrusleeping 8098d23768 test to ensure that submitting bad faults doesnt cause an error 2019-12-20 20:02:18 -08:00
whyrusleeping 5d9d51ba2d don't fail execution if the fault set contains an invalid sector ID 2019-12-20 19:33:11 -08:00
Travis Person eea9144ebe Use golog in stats tool, and better sync control 2019-12-19 15:58:26 +01:00
Łukasz Magiera 97cf3f70a5 chainwatch: sub to mpool/blocks afetr initial sync 2019-12-13 15:47:51 +01:00
Łukasz Magiera 2e9655a4e0 More fixes 2019-12-13 14:42:01 +01:00
Łukasz Magiera 3d666b3992 Merge branch 'feat/chainwatch-stuff' into feat/chainwatch-pg 2019-12-13 12:57:59 +01:00
Łukasz Magiera a246be587e chainwatch: fix ui queries 2019-12-13 12:48:42 +01:00
Łukasz Magiera f2ea12571f Optimise mpool update processing 2019-12-13 12:04:24 +01:00
Łukasz Magiera 165ac1d556 Merge remote-tracking branch 'origin/master' into feat/chainwatch-pg 2019-12-13 10:34:24 +01:00
Łukasz Magiera 1018999096 WIP fixing queries 2019-12-13 10:30:51 +01:00
Łukasz Magiera 04691a13da chainwatch: Fix postgres data import 2019-12-12 19:34:28 +01:00
Łukasz Magiera e34e5b27ba Merge branch 'master' into feat/chainwatch-pg 2019-12-12 17:57:35 +01:00
Łukasz Magiera 66ee9d209d wip 2019-12-11 23:17:44 +01:00
Łukasz Magiera 830f2cbdd3 Merge branch 'master' into feat/chainwatch-pg 2019-12-11 22:13:08 +01:00
Łukasz Magiera b6b06f67dc chainwatch: Postgres 2019-12-11 00:42:36 +01:00
Łukasz Magiera 3edc93f117 wip chainwatch ui 2019-12-07 23:44:45 +01:00
ldoublewood 86f078dbea restore Makefile 2019-12-05 14:47:23 +08:00
ldoublewood f739b7e377 add docker support 2019-12-05 11:31:32 +08:00
472 changed files with 32738 additions and 33742 deletions
+138 -41
View File
@@ -1,12 +1,15 @@
version: 2.1
orbs:
go: gotest/tools@0.0.9
go: gotest/tools@0.0.13
executors:
golang:
docker:
- image: circleci/golang:1.13
- image: circleci/golang:1.14.2
resource_class: 2xlarge
ubuntu:
docker:
- image: ubuntu:19.10
commands:
install-deps:
@@ -24,6 +27,8 @@ commands:
description: is a darwin build environment?
type: boolean
steps:
- checkout
- git_fetch_all_tags
- checkout
- when:
condition: << parameters.linux >>
@@ -37,17 +42,36 @@ commands:
- restore_cache:
name: Restore parameters cache
keys:
- 'v20-1k-lotus-params-{{ checksum "build/proof-params/parameters.json" }}-{{ checksum "build/paramfetch.go" }}'
- 'v20-1k-lotus-params-{{ checksum "build/proof-params/parameters.json" }}-'
- 'v25-2k-lotus-params'
paths:
- /var/tmp/filecoin-proof-parameters/
- run: ./lotus fetch-params --proving-params 1024
- run: ./lotus fetch-params --proving-params 2048
- save_cache:
name: Save parameters cache
key: 'v20-1k-lotus-params-{{ checksum "build/proof-params/parameters.json" }}-{{ checksum "build/paramfetch.go" }}'
key: 'v25-2k-lotus-params'
paths:
- /var/tmp/filecoin-proof-parameters/
install_ipfs:
steps:
- run: |
apt update
apt install -y wget
wget https://github.com/ipfs/go-ipfs/releases/download/v0.4.22/go-ipfs_v0.4.22_linux-amd64.tar.gz
wget https://github.com/ipfs/go-ipfs/releases/download/v0.4.22/go-ipfs_v0.4.22_linux-amd64.tar.gz.sha512
if [ "$(sha512sum go-ipfs_v0.4.22_linux-amd64.tar.gz)" != "$(cat go-ipfs_v0.4.22_linux-amd64.tar.gz.sha512)" ]
then
echo "ipfs failed checksum check"
exit 1
fi
tar -xf go-ipfs_v0.4.22_linux-amd64.tar.gz
mv go-ipfs/ipfs /usr/local/bin/ipfs
chmod +x /usr/local/bin/ipfs
git_fetch_all_tags:
steps:
- run:
name: fetch all tags
command: |
git fetch --all
jobs:
mod-tidy-check:
@@ -55,7 +79,6 @@ jobs:
steps:
- install-deps
- prepare
- go/mod-download
- go/mod-tidy-check
build-all:
@@ -63,18 +86,29 @@ jobs:
steps:
- install-deps
- prepare
- go/mod-download
- run: sudo apt-get update
- run: sudo apt-get install npm
- restore_cache:
name: restore go mod cache
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
- run:
command: make buildall
- store_artifacts:
path: lotus
- store_artifacts:
path: lotus-storage-miner
- store_artifacts:
path: lotus-seal-worker
- run: mkdir linux && mv lotus lotus-storage-miner lotus-seal-worker linux/
- persist_to_workspace:
root: "."
paths:
- linux
build-debug:
executor: golang
steps:
- install-deps
- prepare
- run:
command: make debug
test: &test
description: |
@@ -91,6 +125,9 @@ jobs:
type: string
default: "./..."
description: Import paths of packages to be tested.
winpost-test:
type: string
default: "0"
test-suite-name:
type: string
default: unit
@@ -101,7 +138,7 @@ jobs:
description: gotestsum format. https://github.com/gotestyourself/gotestsum#format
coverage:
type: string
default: -coverprofile=coverage.txt
default: -coverprofile=coverage.txt -coverpkg=github.com/filecoin-project/lotus/...
description: Coverage flag. Set to the empty string to disable.
codecov-upload:
type: boolean
@@ -113,10 +150,6 @@ jobs:
steps:
- install-deps
- prepare
- go/mod-download
- restore_cache:
name: restore go mod cache
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
- run:
command: make deps lotus
no_output_timeout: 30m
@@ -128,6 +161,7 @@ jobs:
environment:
GOTESTSUM_JUNITFILE: /tmp/test-reports/<< parameters.test-suite-name >>/junit.xml
GOTESTSUM_FORMAT: << parameters.gotestsum-format >>
LOTUS_TEST_WINDOW_POST: << parameters.winpost-test >>
command: |
mkdir -p /tmp/test-reports/<< parameters.test-suite-name >>
gotestsum -- \
@@ -146,15 +180,10 @@ jobs:
shell: /bin/bash -eo pipefail
command: |
bash <(curl -s https://codecov.io/bash)
- save_cache:
name: save go mod cache
key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }}
paths:
- "~/go/pkg"
- "~/go/src/github.com"
- "~/go/src/golang.org"
test-short:
test-short:
<<: *test
test-window-post:
<<: *test
build-macos:
@@ -169,8 +198,8 @@ jobs:
- run:
name: Install go
command: |
curl -O https://dl.google.com/go/go1.13.4.darwin-amd64.pkg && \
sudo installer -pkg go1.13.4.darwin-amd64.pkg -target /
curl -O https://dl.google.com/go/go1.14.2.darwin-amd64.pkg && \
sudo installer -pkg go1.14.2.darwin-amd64.pkg -target /
- run:
name: Install pkg-config
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config
@@ -182,21 +211,26 @@ jobs:
- run:
name: Install jq
command: |
mkdir $HOME/.bin
curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output $HOME/.bin/jq
chmod +x $HOME/.bin/jq
curl --location https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output /usr/local/bin/jq
chmod +x /usr/local/bin/jq
- restore_cache:
name: restore go mod and cargo cache
name: restore cargo cache
key: v3-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/lotus/go.sum" }}
- install-deps
- go/mod-download
- run:
command: make buildall
command: make build
no_output_timeout: 30m
- store_artifacts:
path: lotus
- store_artifacts:
path: lotus-storage-miner
- store_artifacts:
path: lotus-seal-worker
- run: mkdir darwin && mv lotus lotus-storage-miner lotus-seal-worker darwin/
- persist_to_workspace:
root: "."
paths:
- darwin
- save_cache:
name: save cargo cache
key: v3-go-deps-{{ arch }}-{{ checksum "~/go/src/github.com/filecoin-project/lotus/go.sum" }}
@@ -204,6 +238,14 @@ jobs:
- "~/.rustup"
- "~/.cargo"
gofmt:
executor: golang
steps:
- install-deps
- prepare
- run:
command: "! go fmt ./... 2>&1 | read"
lint: &lint
description: |
Run golangci-lint.
@@ -213,7 +255,7 @@ jobs:
default: golang
golangci-lint-version:
type: string
default: 1.17.1
default: 1.27.0
concurrency:
type: string
default: '2'
@@ -229,7 +271,6 @@ jobs:
steps:
- install-deps
- prepare
- go/mod-download
- run:
command: make deps
no_output_timeout: 30m
@@ -239,7 +280,7 @@ jobs:
- run:
name: Lint
command: |
$HOME/.local/bin/golangci-lint run -v \
$HOME/.local/bin/golangci-lint run -v --timeout 2m \
--concurrency << parameters.concurrency >> << parameters.args >>
lint-changes:
<<: *lint
@@ -247,16 +288,72 @@ jobs:
lint-all:
<<: *lint
publish:
description: publish binary artifacts
executor: ubuntu
steps:
- run:
name: Install git jq curl
command: apt update && apt install -y git jq curl
- checkout
- git_fetch_all_tags
- checkout
- install_ipfs
- attach_workspace:
at: "."
- run:
name: Create bundles
command: ./scripts/build-bundle.sh
- run:
name: Publish release
command: ./scripts/publish-release.sh
workflows:
version: 2.1
ci:
jobs:
- lint-changes:
args: "--new-from-rev origin/master"
- test
args: "--new-from-rev origin/next"
- mod-tidy-check
- gofmt
- test:
codecov-upload: true
- test-window-post:
go-test-flags: "-run=TestWindowedPost"
winpost-test: "1"
- test-short:
go-test-flags: "--timeout 10m --short"
- mod-tidy-check
- build-all
- build-macos
filters:
tags:
only:
- /^v\d+\.\d+\.\d+$/
- build-debug
- build-all:
requires:
- test-short
filters:
tags:
only:
- /^v\d+\.\d+\.\d+$/
- build-macos:
requires:
- test-short
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+$/
- publish:
requires:
- build-all
- build-macos
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v\d+\.\d+\.\d+$/
+2
View File
@@ -1 +1,3 @@
comment: off
ignore:
- "cbor_gen.go"
+1
View File
@@ -0,0 +1 @@
.gitignore
+34
View File
@@ -0,0 +1,34 @@
---
name: Sealing Issues
about: Create a report for help with sealing (commit) failures.
title: ''
labels: 'sealing'
assignees: ''
---
Please provide all the information requested here to help us troubleshoot "commit failed" issues.
If the information requested is missing, we will probably have to just ask you to provide it anyway,
before we can help debug.
**Describe the problem**
A brief description of the problem you encountered while proving (sealing) a sector.
Including what commands you ran, and a description of your setup, is very helpful.
**Sectors list**
The output of `./lotus-storage-miner sectors list`.
**Sectors status**
The output of `./lotus-storage-miner sectors status --log <sectorId>` for the failed sector(s).
**Lotus storage miner logs**
Please go through the logs of your storage miner, and include screenshots of any error-like messages you find.
**Version**
The output of `./lotus --version`.
+5 -1
View File
@@ -2,6 +2,8 @@
/lotus-storage-miner
/lotus-seal-worker
/lotus-seed
/lotus-health
/lotus-shed
/pond
/townhall
/fountain
@@ -13,7 +15,6 @@
/cmd/lotus-townhall/townhall/node_modules
/cmd/lotus-townhall/townhall/build
extern/filecoin-ffi/rust/target
**/*.h
**/*.a
**/*.pc
/**/*/.DS_STORE
@@ -25,6 +26,9 @@ build/paramfetch.sh
/blocks.svg
/chainwatch
/chainwatch.db
/bundle
/darwin
/linux
*-fuzz.zip
/chain/types/work_msg/
+3
View File
@@ -2,3 +2,6 @@
path = extern/filecoin-ffi
url = https://github.com/filecoin-project/filecoin-ffi.git
branch = master
[submodule "extern/serialization-vectors"]
path = extern/serialization-vectors
url = https://github.com/filecoin-project/serialization-vectors
+17 -2
View File
@@ -1,7 +1,8 @@
linters:
disable-all: true
enable:
- vet
- gofmt
- govet
- goimports
- misspell
- goconst
@@ -21,13 +22,27 @@ issues:
- "func name will be used as test\\.Test.* by other packages, and that stutters; consider calling this"
- "Potential file inclusion via variable"
- "should have( a package)? comment"
- "Error return value of `logging.SetLogLevel` is not checked"
exclude-use-default: false
exclude-rules:
- path: lotuspond
linters:
- errcheck
- path: node/modules/lp2p
linters:
- golint
- path: ".*_test.go"
- path: build/params_.*\.go
linters:
- golint
- path: api/apistruct/struct.go
linters:
- golint
- path: .*_test.go
linters:
- gosec
+59 -7
View File
@@ -3,6 +3,8 @@ SHELL=/usr/bin/env bash
all: build
.PHONY: all
unexport GOFLAGS
GOVERSION:=$(shell go version | cut -d' ' -f 3 | cut -d. -f 2)
ifeq ($(shell expr $(GOVERSION) \< 13), 1)
$(warning Your Golang version is go 1.$(GOVERSION))
@@ -14,12 +16,19 @@ MODULES:=
CLEAN:=
BINS:=
GOFLAGS+=-ldflags="-X "github.com/filecoin-project/lotus/build".CurrentCommit=+git$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))"
ldflags=-X=github.com/filecoin-project/lotus/build.CurrentCommit=+git.$(subst -,.,$(shell git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))
ifneq ($(strip $(LDFLAGS)),)
ldflags+=-extldflags=$(LDFLAGS)
endif
GOFLAGS+=-ldflags="$(ldflags)"
## FFI
FFI_PATH:=extern/filecoin-ffi/
FFI_DEPS:=libfilecoin.a filecoin.pc filecoin.h
FFI_DEPS:=.install-filcrypto
FFI_DEPS:=$(addprefix $(FFI_PATH),$(FFI_DEPS))
$(FFI_DEPS): build/.filecoin-install ;
@@ -51,6 +60,9 @@ deps: $(BUILD_DEPS)
debug: GOFLAGS+=-tags=debug
debug: lotus lotus-storage-miner lotus-seal-worker lotus-seed
2k: GOFLAGS+=-tags=2k
2k: lotus lotus-storage-miner lotus-seal-worker lotus-seed
lotus: $(BUILD_DEPS)
rm -f lotus
go build $(GOFLAGS) -o lotus ./cmd/lotus
@@ -76,8 +88,9 @@ BINS+=lotus-seal-worker
lotus-shed: $(BUILD_DEPS)
rm -f lotus-shed
go build $(GOFLAGS) -o lotus-shed ./cmd/lotus-shed
.PHONY: lotus-seal-worker
BINS+=lotus-seal-worker
go run github.com/GeertJohan/go.rice/rice append --exec lotus-shed -i ./build
.PHONY: lotus-shed
BINS+=lotus-shed
build: lotus lotus-storage-miner lotus-seal-worker
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
@@ -90,6 +103,19 @@ install:
install -C ./lotus-storage-miner /usr/local/bin/lotus-storage-miner
install -C ./lotus-seal-worker /usr/local/bin/lotus-seal-worker
install-services: install
mkdir -p /usr/local/lib/systemd/system
install -C -m 0644 ./scripts/lotus-daemon.service /usr/local/lib/systemd/system/lotus-daemon.service
install -C -m 0644 ./scripts/lotus-miner.service /usr/local/lib/systemd/system/lotus-miner.service
systemctl daemon-reload
@echo
@echo "lotus and lotus-miner services installed. Don't forget to 'systemctl enable lotus|lotus-miner' for it to be enabled on startup."
clean-services:
rm -f /usr/local/lib/systemd/system/lotus-daemon.service
rm -f /usr/local/lib/systemd/system/lotus-miner.service
systemctl daemon-reload
# TOOLS
lotus-seed: $(BUILD_DEPS)
@@ -106,7 +132,7 @@ benchmarks:
@curl -X POST 'http://benchmark.kittyhawk.wtf/benchmark' -d '@bench.json' -u "${benchmark_http_cred}"
.PHONY: benchmarks
pond: build
pond: 2k
go build -o pond ./lotuspond
(cd lotuspond/front && npm i && CI=false npm run build)
.PHONY: pond
@@ -123,14 +149,14 @@ BINS+=townhall
fountain:
rm -f fountain
go build -o fountain ./cmd/lotus-fountain
go run github.com/GeertJohan/go.rice/rice append --exec fountain -i ./cmd/lotus-fountain
go run github.com/GeertJohan/go.rice/rice append --exec fountain -i ./cmd/lotus-fountain -i ./build
.PHONY: fountain
BINS+=fountain
chainwatch:
rm -f chainwatch
go build -o chainwatch ./cmd/lotus-chainwatch
go run github.com/GeertJohan/go.rice/rice append --exec chainwatch -i ./cmd/lotus-chainwatch
go run github.com/GeertJohan/go.rice/rice append --exec chainwatch -i ./cmd/lotus-chainwatch -i ./build
.PHONY: chainwatch
BINS+=chainwatch
@@ -144,13 +170,34 @@ BINS+=bench
stats:
rm -f stats
go build -o stats ./tools/stats
go run github.com/GeertJohan/go.rice/rice append --exec stats -i ./build
.PHONY: stats
BINS+=stats
health:
rm -f lotus-health
go build -o lotus-health ./cmd/lotus-health
go run github.com/GeertJohan/go.rice/rice append --exec lotus-health -i ./build
.PHONY: health
BINS+=health
# MISC
buildall: $(BINS)
completions:
./scripts/make-completions.sh lotus
./scripts/make-completions.sh lotus-storage-miner
.PHONY: completions
install-completions:
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
install -C ./scripts/bash-completion/lotus-storage-miner /usr/share/bash-completion/completions/lotus-storage-miner
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
install -C ./scripts/zsh-completion/lotus-storage-miner /usr/local/share/zsh/site-functions/_lotus-storage-miner
clean:
rm -rf $(CLEAN) $(BINS)
-$(MAKE) -C $(FFI_PATH) clean
@@ -164,5 +211,10 @@ dist-clean:
type-gen:
go run ./gen/main.go
method-gen:
(cd ./lotuspond/front/src/chain && go run ./methodgen.go)
gen: type-gen method-gen
print-%:
@echo $*=$($*)
+1 -1
View File
@@ -2,7 +2,7 @@
# Project Lotus - 莲
Lotus is an experimental implementation of the Filecoin Distributed Storage Network. For more details about Filecoin, check out the [Filecoin Spec](https://github.com/filecoin-project/specs).
Lotus is an implementation of the Filecoin Distributed Storage Network. For more details about Filecoin, check out the [Filecoin Spec](https://github.com/filecoin-project/specs).
## Development
+14 -5
View File
@@ -4,17 +4,18 @@ import (
"context"
"fmt"
"github.com/filecoin-project/lotus/build"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
)
type Permission = string
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/build"
)
type Common interface {
// Auth
AuthVerify(ctx context.Context, token string) ([]Permission, error)
AuthNew(ctx context.Context, perms []Permission) ([]byte, error)
AuthVerify(ctx context.Context, token string) ([]auth.Permission, error)
AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error)
// network
@@ -23,12 +24,20 @@ type Common interface {
NetConnect(context.Context, peer.AddrInfo) error
NetAddrsListen(context.Context) (peer.AddrInfo, error)
NetDisconnect(context.Context, peer.ID) error
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
NetPubsubScores(context.Context) ([]PubsubScore, error)
// ID returns peerID of libp2p node backing this API
ID(context.Context) (peer.ID, error)
// Version provides information about API provider
Version(context.Context) (Version, error)
LogList(context.Context) ([]string, error)
LogSetLevel(context.Context, string, string) error
// trigger graceful shutdown
Shutdown(context.Context) error
}
// Version provides various build-time information
+246 -88
View File
@@ -8,63 +8,95 @@ import (
"github.com/ipfs/go-filestore"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
// FullNode API is a low-level interface to the Filecoin network full node
type FullNode interface {
Common
// chain
// TODO: TipSetKeys
// MethodGroup: Chain
// The Chain method group contains methods for interacting with the
// blockchain, but that do not require any form of state computation
// ChainNotify returns channel with chain head updates
// First message is guaranteed to be of len == 1, and type == 'current'
ChainNotify(context.Context) (<-chan []*store.HeadChange, error)
ChainNotify(context.Context) (<-chan []*HeadChange, error)
// ChainHead returns the current head of the chain
ChainHead(context.Context) (*types.TipSet, error)
ChainGetRandomness(context.Context, types.TipSetKey, int64) ([]byte, error)
// ChainGetRandomness is used to sample the chain for randomness
ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
// ChainGetBlock returns the block specified by the given CID
ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
ChainGetBlockMessages(context.Context, cid.Cid) (*BlockMessages, error)
ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error)
ChainGetParentMessages(context.Context, cid.Cid) ([]Message, error)
ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet) (*types.TipSet, error)
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainSetHead(context.Context, *types.TipSet) error
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainStatObj(context.Context, cid.Cid, cid.Cid) (ObjStat, error)
ChainSetHead(context.Context, types.TipSetKey) error
ChainGetGenesis(context.Context) (*types.TipSet, error)
ChainTipSetWeight(context.Context, *types.TipSet) (types.BigInt, error)
ChainGetNode(ctx context.Context, p string) (interface{}, error)
ChainTipSetWeight(context.Context, types.TipSetKey) (types.BigInt, error)
ChainGetNode(ctx context.Context, p string) (*IpldObject, error)
ChainGetMessage(context.Context, cid.Cid) (*types.Message, error)
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*HeadChange, error)
ChainExport(context.Context, types.TipSetKey) (<-chan []byte, error)
// syncer
// MethodGroup: Sync
// The Sync method group contains methods for interacting with and
// observing the lotus sync service
// SyncState returns the current status of the lotus sync system
SyncState(context.Context) (*SyncState, error)
// SyncSubmitBlock can be used to submit a newly created block to the
// network through this node
SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) error
SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error)
SyncMarkBad(ctx context.Context, bcid cid.Cid) error
SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error)
// messages
MpoolPending(context.Context, *types.TipSet) ([]*types.SignedMessage, error)
MpoolPush(context.Context, *types.SignedMessage) error // TODO: remove
// MethodGroup: Mpool
// The Mpool methods are for interacting with the message pool. The message pool
// manages all incoming and outgoing 'messages' going over the network.
MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error)
MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error) // get nonce, sign, push
MpoolGetNonce(context.Context, address.Address) (uint64, error)
MpoolSub(context.Context) (<-chan MpoolUpdate, error)
MpoolEstimateGasPrice(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error)
// FullNodeStruct
// MethodGroup: Miner
// miner
MinerCreateBlock(context.Context, address.Address, *types.TipSet, *types.Ticket, *types.EPostProof, []*types.SignedMessage, uint64, uint64) (*types.BlockMsg, error)
MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*MiningBaseInfo, error)
MinerCreateBlock(context.Context, *BlockTemplate) (*types.BlockMsg, error)
// // UX ?
// wallet
// MethodGroup: Wallet
WalletNew(context.Context, string) (address.Address, error)
WalletNew(context.Context, crypto.SigType) (address.Address, error)
WalletHas(context.Context, address.Address) (bool, error)
WalletList(context.Context) ([]address.Address, error)
WalletBalance(context.Context, address.Address) (types.BigInt, error)
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
WalletSignMessage(context.Context, address.Address, *types.Message) (*types.SignedMessage, error)
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) bool
WalletDefaultAddress(context.Context) (address.Address, error)
WalletSetDefault(context.Context, address.Address) error
WalletExport(context.Context, address.Address) (*types.KeyInfo, error)
@@ -72,15 +104,23 @@ type FullNode interface {
// Other
// MethodGroup: Client
// The Client methods all have to do with interacting with the storage and
// retrieval markets as a client
// ClientImport imports file under the specified path into filestore
ClientImport(ctx context.Context, path string) (cid.Cid, error)
ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error)
ClientImport(ctx context.Context, ref FileRef) (cid.Cid, error)
// ClientStartDeal proposes a deal with a miner
ClientStartDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error)
// ClientGetDeal info returns the latest information about a given deal
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error)
ClientListDeals(ctx context.Context) ([]DealInfo, error)
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
ClientFindData(ctx context.Context, root cid.Cid) ([]QueryOffer, error)
ClientRetrieve(ctx context.Context, order RetrievalOrder, path string) error
ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error)
ClientRetrieve(ctx context.Context, order RetrievalOrder, ref *FileRef) error
ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error)
ClientCalcCommP(ctx context.Context, inpath string, miner address.Address) (*CommPRet, error)
ClientGenCar(ctx context.Context, ref FileRef, outpath string) error
// ClientUnimport removes references to the specified file from filestore
//ClientUnimport(path string)
@@ -90,52 +130,85 @@ type FullNode interface {
//ClientListAsks() []Ask
// MethodGroup: State
// The State methods are used to query, inspect, and interact with chain state
// if tipset is nil, we'll use heaviest
StateCall(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error)
StateReplay(context.Context, *types.TipSet, cid.Cid) (*ReplayResults, error)
StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error)
StateReadState(ctx context.Context, act *types.Actor, ts *types.TipSet) (*ActorState, error)
StateCall(context.Context, *types.Message, types.TipSetKey) (*InvocResult, error)
StateReplay(context.Context, types.TipSetKey, cid.Cid) (*InvocResult, error)
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
StateReadState(ctx context.Context, act *types.Actor, tsk types.TipSetKey) (*ActorState, error)
StateListMessages(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error)
StateMinerSectors(context.Context, address.Address, *types.TipSet) ([]*ChainSectorInfo, error)
StateMinerProvingSet(context.Context, address.Address, *types.TipSet) ([]*ChainSectorInfo, error)
StateMinerPower(context.Context, address.Address, *types.TipSet) (MinerPower, error)
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error)
StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error)
StateMinerSectorSize(context.Context, address.Address, *types.TipSet) (uint64, error)
StatePledgeCollateral(context.Context, *types.TipSet) (types.BigInt, error)
StateWaitMsg(context.Context, cid.Cid) (*MsgWait, error)
StateListMiners(context.Context, *types.TipSet) ([]address.Address, error)
StateListActors(context.Context, *types.TipSet) ([]address.Address, error)
StateMarketBalance(context.Context, address.Address, *types.TipSet) (actors.StorageParticipantBalance, error)
StateMarketParticipants(context.Context, *types.TipSet) (map[string]actors.StorageParticipantBalance, error)
StateMarketDeals(context.Context, *types.TipSet) (map[string]actors.OnChainDeal, error)
StateMarketStorageDeal(context.Context, uint64, *types.TipSet) (*actors.OnChainDeal, error)
StateLookupID(context.Context, address.Address, *types.TipSet) (address.Address, error)
StateNetworkName(context.Context) (dtypes.NetworkName, error)
StateMinerSectors(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*ChainSectorInfo, error)
StateMinerProvingSet(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error)
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
// Returns all non-expired Faults that occur within lookback epochs of the given tipset
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
StatePledgeCollateral(context.Context, types.TipSetKey) (types.BigInt, error)
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*MsgLookup, error)
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
StateListMiners(context.Context, types.TipSetKey) ([]address.Address, error)
StateListActors(context.Context, types.TipSetKey) ([]address.Address, error)
StateMarketBalance(context.Context, address.Address, types.TipSetKey) (MarketBalance, error)
StateMarketParticipants(context.Context, types.TipSetKey) (map[string]MarketBalance, error)
StateMarketDeals(context.Context, types.TipSetKey) (map[string]MarketDeal, error)
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error)
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error)
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error)
StateMinerSectorCount(context.Context, address.Address, *types.TipSet) (MinerSectors, error)
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (MinerSectors, error)
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*ComputeStateOutput, error)
MarketEnsureAvailable(context.Context, address.Address, types.BigInt) error
// MethodGroup: Msig
// The Msig methods are used to interact with multisig wallets on the
// filecoin network
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
MsigCreate(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MsigCancel(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
MarketEnsureAvailable(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error)
// MarketFreeBalance
// MethodGroup: Paych
// The Paych methods are for interacting with and managing payment channels
PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error)
PaychList(context.Context) ([]address.Address, error)
PaychStatus(context.Context, address.Address) (*PaychStatus, error)
PaychClose(context.Context, address.Address) (cid.Cid, error)
PaychAllocateLane(ctx context.Context, ch address.Address) (uint64, error)
PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error)
PaychVoucherCheckValid(context.Context, address.Address, *types.SignedVoucher) error
PaychVoucherCheckSpendable(context.Context, address.Address, *types.SignedVoucher, []byte, []byte) (bool, error)
PaychVoucherCreate(context.Context, address.Address, types.BigInt, uint64) (*types.SignedVoucher, error)
PaychVoucherAdd(context.Context, address.Address, *types.SignedVoucher, []byte, types.BigInt) (types.BigInt, error)
PaychVoucherList(context.Context, address.Address) ([]*types.SignedVoucher, error)
PaychVoucherSubmit(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error)
PaychVoucherCheckValid(context.Context, address.Address, *paych.SignedVoucher) error
PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error)
PaychVoucherCreate(context.Context, address.Address, types.BigInt, uint64) (*paych.SignedVoucher, error)
PaychVoucherAdd(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error)
PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error)
PaychVoucherSubmit(context.Context, address.Address, *paych.SignedVoucher) (cid.Cid, error)
}
type FileRef struct {
Path string
IsCAR bool
}
type MinerSectors struct {
Pset uint64
Sset uint64
Pset uint64
}
type Import struct {
@@ -147,17 +220,20 @@ type Import struct {
type DealInfo struct {
ProposalCid cid.Cid
State DealState
State storagemarket.StorageDealStatus
Message string // more information about deal state, particularly errors
Provider address.Address
PieceRef []byte // cid bytes
PieceCID cid.Cid
Size uint64
PricePerEpoch types.BigInt
Duration uint64
DealID abi.DealID
}
type MsgWait struct {
type MsgLookup struct {
Receipt types.MessageReceipt
TipSet *types.TipSet
}
@@ -175,9 +251,8 @@ type Message struct {
}
type ChainSectorInfo struct {
SectorID uint64
CommD []byte
CommR []byte
Info miner.SectorOnChainInfo
ID abi.SectorNumber
}
type ActorState struct {
@@ -206,20 +281,21 @@ type ChannelInfo struct {
type PaymentInfo struct {
Channel address.Address
ChannelMessage *cid.Cid
Vouchers []*types.SignedVoucher
Vouchers []*paych.SignedVoucher
}
type VoucherSpec struct {
Amount types.BigInt
TimeLock uint64
MinClose uint64
Amount types.BigInt
TimeLockMin abi.ChainEpoch
TimeLockMax abi.ChainEpoch
MinSettle abi.ChainEpoch
Extra *types.ModVerifyParams
Extra *paych.ModVerifyParams
}
type MinerPower struct {
MinerPower types.BigInt
TotalPower types.BigInt
MinerPower power.Claim
TotalPower power.Claim
}
type QueryOffer struct {
@@ -227,42 +303,76 @@ type QueryOffer struct {
Root cid.Cid
Size uint64
MinPrice types.BigInt
Miner address.Address
MinerPeerID peer.ID
Size uint64
MinPrice types.BigInt
PaymentInterval uint64
PaymentIntervalIncrease uint64
Miner address.Address
MinerPeerID peer.ID
}
func (o *QueryOffer) Order(client address.Address) RetrievalOrder {
return RetrievalOrder{
Root: o.Root,
Size: o.Size,
Total: o.MinPrice,
Client: client,
Root: o.Root,
Size: o.Size,
Total: o.MinPrice,
PaymentInterval: o.PaymentInterval,
PaymentIntervalIncrease: o.PaymentIntervalIncrease,
Client: client,
Miner: o.Miner,
MinerPeerID: o.MinerPeerID,
}
}
type MarketBalance struct {
Escrow big.Int
Locked big.Int
}
type MarketDeal struct {
Proposal market.DealProposal
State market.DealState
}
type RetrievalOrder struct {
// TODO: make this less unixfs specific
Root cid.Cid
Size uint64
// TODO: support offset
Total types.BigInt
Client address.Address
Miner address.Address
MinerPeerID peer.ID
Total types.BigInt
PaymentInterval uint64
PaymentIntervalIncrease uint64
Client address.Address
Miner address.Address
MinerPeerID peer.ID
}
type ReplayResults struct {
Msg *types.Message
Receipt *types.MessageReceipt
Error string
type InvocResult struct {
Msg *types.Message
MsgRct *types.MessageReceipt
InternalExecutions []*types.ExecutionResult
Error string
Duration time.Duration
}
type MethodCall struct {
types.MessageReceipt
Error string
}
type StartDealParams struct {
Data *storagemarket.DataRef
Wallet address.Address
Miner address.Address
EpochPrice types.BigInt
MinBlocksDuration uint64
DealStartEpoch abi.ChainEpoch
}
type IpldObject struct {
Cid cid.Cid
Obj interface{}
}
type ActiveSync struct {
@@ -270,7 +380,7 @@ type ActiveSync struct {
Target *types.TipSet
Stage SyncStateStage
Height uint64
Height abi.ChainEpoch
Start time.Time
End time.Time
@@ -303,3 +413,51 @@ type MpoolUpdate struct {
Type MpoolChange
Message *types.SignedMessage
}
type ComputeStateOutput struct {
Root cid.Cid
Trace []*InvocResult
}
type MiningBaseInfo struct {
MinerPower types.BigInt
NetworkPower types.BigInt
Sectors []abi.SectorInfo
WorkerKey address.Address
SectorSize abi.SectorSize
PrevBeaconEntry types.BeaconEntry
BeaconEntries []types.BeaconEntry
}
type BlockTemplate struct {
Miner address.Address
Parents types.TipSetKey
Ticket *types.Ticket
Eproof *types.ElectionProof
BeaconValues []types.BeaconEntry
Messages []*types.SignedMessage
Epoch abi.ChainEpoch
Timestamp uint64
WinningPoStProof []abi.PoStProof
}
type CommPRet struct {
Root cid.Cid
Size abi.UnpaddedPieceSize
}
type HeadChange struct {
Type string
Val *types.TipSet
}
type MsigProposeResponse int
const (
MsigApprove MsigProposeResponse = iota
MsigCancel
)
type Fault struct {
Miner address.Address
Epoch abi.ChainEpoch
}
+78 -69
View File
@@ -1,112 +1,121 @@
package api
import (
"bytes"
"context"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/sector-storage/storiface"
"github.com/filecoin-project/specs-actors/actors/abi"
)
// alias because cbor-gen doesn't like non-alias types
type SectorState = uint64
const (
UndefinedSectorState SectorState = iota
Empty // TODO: Is this useful
Packing // sector not in sealStore, and not on chain
Unsealed // sealing / queued
PreCommitting // on chain pre-commit
PreCommitted // waiting for seed
Committing
CommitWait // waiting for message to land on chain
Proving
SealFailed
PreCommitFailed
SealCommitFailed
CommitFailed
FailedUnrecoverable
Faulty // sector is corrupted or gone for some reason
FaultReported // sector has been declared as a fault on chain
FaultedFinal // fault declared on chain
)
var SectorStates = []string{
UndefinedSectorState: "UndefinedSectorState",
Empty: "Empty",
Packing: "Packing",
Unsealed: "Unsealed",
PreCommitting: "PreCommitting",
PreCommitted: "PreCommitted",
Committing: "Committing",
CommitWait: "CommitWait",
Proving: "Proving",
SealFailed: "SealFailed",
PreCommitFailed: "PreCommitFailed",
SealCommitFailed: "SealCommitFailed",
CommitFailed: "CommitFailed",
FailedUnrecoverable: "FailedUnrecoverable",
Faulty: "Faulty",
FaultReported: "FaultReported",
FaultedFinal: "FaultedFinal",
}
// StorageMiner is a low-level interface to the Filecoin network storage miner node
type StorageMiner interface {
Common
ActorAddress(context.Context) (address.Address, error)
ActorSectorSize(context.Context, address.Address) (uint64, error)
ActorSectorSize(context.Context, address.Address) (abi.SectorSize, error)
MiningBase(context.Context) (*types.TipSet, error)
// Temp api for testing
PledgeSector(context.Context) error
// Get the status of a given sector by ID
SectorsStatus(context.Context, uint64) (SectorInfo, error)
SectorsStatus(context.Context, abi.SectorNumber) (SectorInfo, error)
// List all staged sectors
SectorsList(context.Context) ([]uint64, error)
SectorsList(context.Context) ([]abi.SectorNumber, error)
SectorsRefs(context.Context) (map[string][]SealedRef, error)
SectorsUpdate(context.Context, uint64, SectorState) error
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
WorkerStats(context.Context) (sectorbuilder.WorkerStats, error)
StorageList(ctx context.Context) (map[stores.ID][]stores.Decl, error)
StorageLocal(ctx context.Context) (map[stores.ID]string, error)
StorageStat(ctx context.Context, id stores.ID) (stores.FsStat, error)
// WorkerQueue registers a remote worker
WorkerQueue(context.Context, sectorbuilder.WorkerCfg) (<-chan sectorbuilder.WorkerTask, error)
// WorkerConnect tells the node to connect to workers RPC
WorkerConnect(context.Context, string) error
WorkerStats(context.Context) (map[uint64]storiface.WorkerStats, error)
WorkerDone(ctx context.Context, task uint64, res sectorbuilder.SealRes) error
stores.SectorIndex
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error)
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
MarketSetPrice(context.Context, types.BigInt) error
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
StorageAddLocal(ctx context.Context, path string) error
}
type SealRes struct {
Err string
GoErr error `json:"-"`
Proof []byte
}
type SectorLog struct {
Kind string
Timestamp uint64
Trace string
Message string
}
type SectorInfo struct {
SectorID uint64
SectorID abi.SectorNumber
State SectorState
CommD []byte
CommR []byte
CommD *cid.Cid
CommR *cid.Cid
Proof []byte
Deals []uint64
Ticket sectorbuilder.SealTicket
Seed sectorbuilder.SealSeed
Deals []abi.DealID
Ticket SealTicket
Seed SealSeed
Retries uint64
LastErr string
Log []SectorLog
}
type SealedRef struct {
SectorID uint64
SectorID abi.SectorNumber
Offset uint64
Size uint64
Size abi.UnpaddedPieceSize
}
type SealedRefs struct {
Refs []SealedRef
}
type SealTicket struct {
Value abi.SealRandomness
Epoch abi.ChainEpoch
}
type SealSeed struct {
Value abi.InteractiveSealRandomness
Epoch abi.ChainEpoch
}
func (st *SealTicket) Equals(ost *SealTicket) bool {
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
}
func (st *SealSeed) Equals(ost *SealSeed) bool {
return bytes.Equal(st.Value, ost.Value) && st.Epoch == ost.Epoch
}
type SectorState string
+34
View File
@@ -0,0 +1,34 @@
package api
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
)
func goCmd() string {
var exeSuffix string
if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
if _, err := os.Stat(path); err == nil {
return path
}
return "go"
}
func TestDoesntDependOnFFI(t *testing.T) {
deps, err := exec.Command(goCmd(), "list", "-deps", "github.com/filecoin-project/lotus/api").Output()
if err != nil {
t.Fatal(err)
}
for _, pkg := range strings.Fields(string(deps)) {
if pkg == "github.com/filecoin-project/filecoin-ffi" {
t.Fatal("api depends on filecoin-ffi")
}
}
}
+36
View File
@@ -0,0 +1,36 @@
package api
import (
"context"
"io"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/sector-storage/sealtasks"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/sector-storage/storiface"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-storage/storage"
"github.com/filecoin-project/lotus/build"
)
type WorkerAPI interface {
Version(context.Context) (build.Version, error)
// TODO: Info() (name, ...) ?
TaskTypes(context.Context) (map[sealtasks.TaskType]struct{}, error) // TaskType -> Weight
Paths(context.Context) ([]stores.StoragePath, error)
Info(context.Context) (storiface.WorkerInfo, error)
storage.Sealer
MoveStorage(ctx context.Context, sector abi.SectorID) error
UnsealPiece(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error
ReadPiece(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error
Fetch(context.Context, abi.SectorID, stores.SectorFileType, stores.PathType, stores.AcquireMode) error
Closing(context.Context) (<-chan struct{}, error)
}
+67
View File
@@ -0,0 +1,67 @@
package apibstore
import (
"context"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
"golang.org/x/xerrors"
)
type ChainIO interface {
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainHasObj(context.Context, cid.Cid) (bool, error)
}
type apiBStore struct {
api ChainIO
}
func NewAPIBlockstore(cio ChainIO) blockstore.Blockstore {
return &apiBStore{
api: cio,
}
}
func (a *apiBStore) DeleteBlock(cid.Cid) error {
return xerrors.New("not supported")
}
func (a *apiBStore) Has(c cid.Cid) (bool, error) {
return a.api.ChainHasObj(context.TODO(), c)
}
func (a *apiBStore) Get(c cid.Cid) (blocks.Block, error) {
bb, err := a.api.ChainReadObj(context.TODO(), c)
if err != nil {
return nil, err
}
return blocks.NewBlockWithCid(bb, c)
}
func (a *apiBStore) GetSize(c cid.Cid) (int, error) {
bb, err := a.api.ChainReadObj(context.TODO(), c)
if err != nil {
return 0, err
}
return len(bb), nil
}
func (a *apiBStore) Put(blocks.Block) error {
return xerrors.New("not supported")
}
func (a *apiBStore) PutMany([]blocks.Block) error {
return xerrors.New("not supported")
}
func (a *apiBStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
return nil, xerrors.New("not supported")
}
func (a *apiBStore) HashOnRead(enabled bool) {
return
}
var _ blockstore.Blockstore = &apiBStore{}
+15 -82
View File
@@ -1,105 +1,38 @@
package apistruct
import (
"context"
"reflect"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/api"
)
type permKey int
var permCtxKey permKey
const (
// When changing these, update docs/API.md too
PermRead api.Permission = "read" // default
PermWrite api.Permission = "write"
PermSign api.Permission = "sign" // Use wallet keys for signing
PermAdmin api.Permission = "admin" // Manage permissions
PermRead auth.Permission = "read" // default
PermWrite auth.Permission = "write"
PermSign auth.Permission = "sign" // Use wallet keys for signing
PermAdmin auth.Permission = "admin" // Manage permissions
)
var AllPermissions = []api.Permission{PermRead, PermWrite, PermSign, PermAdmin}
var defaultPerms = []api.Permission{PermRead}
func WithPerm(ctx context.Context, perms []api.Permission) context.Context {
return context.WithValue(ctx, permCtxKey, perms)
}
var AllPermissions = []auth.Permission{PermRead, PermWrite, PermSign, PermAdmin}
var DefaultPerms = []auth.Permission{PermRead}
func PermissionedStorMinerAPI(a api.StorageMiner) api.StorageMiner {
var out StorageMinerStruct
permissionedAny(a, &out.Internal)
permissionedAny(a, &out.CommonStruct.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
return &out
}
func PermissionedFullAPI(a api.FullNode) api.FullNode {
var out FullNodeStruct
permissionedAny(a, &out.Internal)
permissionedAny(a, &out.CommonStruct.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.CommonStruct.Internal)
return &out
}
func HasPerm(ctx context.Context, perm api.Permission) bool {
callerPerms, ok := ctx.Value(permCtxKey).([]api.Permission)
if !ok {
callerPerms = defaultPerms
}
for _, callerPerm := range callerPerms {
if callerPerm == perm {
return true
}
}
return false
}
func permissionedAny(in interface{}, out interface{}) {
rint := reflect.ValueOf(out).Elem()
ra := reflect.ValueOf(in)
for f := 0; f < rint.NumField(); f++ {
field := rint.Type().Field(f)
requiredPerm := api.Permission(field.Tag.Get("perm"))
if requiredPerm == "" {
panic("missing 'perm' tag on " + field.Name) // ok
}
// Validate perm tag
ok := false
for _, perm := range AllPermissions {
if requiredPerm == perm {
ok = true
break
}
}
if !ok {
panic("unknown 'perm' tag on " + field.Name) // ok
}
fn := ra.MethodByName(field.Name)
rint.Field(f).Set(reflect.MakeFunc(field.Type, func(args []reflect.Value) (results []reflect.Value) {
ctx := args[0].Interface().(context.Context)
if HasPerm(ctx, requiredPerm) {
return fn.Call(args)
}
err := xerrors.Errorf("missing permission to invoke '%s' (need '%s')", field.Name, requiredPerm)
rerr := reflect.ValueOf(&err).Elem()
if field.Type.NumOut() == 2 {
return []reflect.Value{
reflect.Zero(field.Type.Out(0)),
rerr,
}
} else {
return []reflect.Value{rerr}
}
}))
}
func PermissionedWorkerAPI(a api.WorkerAPI) api.WorkerAPI {
var out WorkerStruct
auth.PermissionedProxy(AllPermissions, DefaultPerms, a, &out.Internal)
return &out
}
+531 -167
View File
@@ -2,18 +2,30 @@ package apistruct
import (
"context"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"io"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/sector-storage/sealtasks"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/sector-storage/storiface"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-storage/storage"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
// All permissions are listed in permissioned.go
@@ -21,17 +33,24 @@ var _ = AllPermissions
type CommonStruct struct {
Internal struct {
AuthVerify func(ctx context.Context, token string) ([]api.Permission, error) `perm:"read"`
AuthNew func(ctx context.Context, perms []api.Permission) ([]byte, error) `perm:"admin"`
AuthVerify func(ctx context.Context, token string) ([]auth.Permission, error) `perm:"read"`
AuthNew func(ctx context.Context, perms []auth.Permission) ([]byte, error) `perm:"admin"`
NetConnectedness func(context.Context, peer.ID) (network.Connectedness, error) `perm:"read"`
NetPeers func(context.Context) ([]peer.AddrInfo, error) `perm:"read"`
NetConnect func(context.Context, peer.AddrInfo) error `perm:"write"`
NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"`
NetDisconnect func(context.Context, peer.ID) error `perm:"write"`
NetFindPeer func(context.Context, peer.ID) (peer.AddrInfo, error) `perm:"read"`
NetPubsubScores func(context.Context) ([]api.PubsubScore, error) `perm:"read"`
ID func(context.Context) (peer.ID, error) `perm:"read"`
Version func(context.Context) (api.Version, error) `perm:"read"`
LogList func(context.Context) ([]string, error) `perm:"write"`
LogSetLevel func(context.Context, string, string) error `perm:"write"`
Shutdown func(context.Context) error `perm:"admin"`
}
}
@@ -40,79 +59,108 @@ type FullNodeStruct struct {
CommonStruct
Internal struct {
ChainNotify func(context.Context) (<-chan []*store.HeadChange, error) `perm:"read"`
ChainHead func(context.Context) (*types.TipSet, error) `perm:"read"`
ChainGetRandomness func(context.Context, types.TipSetKey, int64) ([]byte, error) `perm:"read"`
ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"`
ChainGetTipSet func(context.Context, types.TipSetKey) (*types.TipSet, error) `perm:"read"`
ChainGetBlockMessages func(context.Context, cid.Cid) (*api.BlockMessages, error) `perm:"read"`
ChainGetParentReceipts func(context.Context, cid.Cid) ([]*types.MessageReceipt, error) `perm:"read"`
ChainGetParentMessages func(context.Context, cid.Cid) ([]api.Message, error) `perm:"read"`
ChainGetTipSetByHeight func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) `perm:"read"`
ChainReadObj func(context.Context, cid.Cid) ([]byte, error) `perm:"read"`
ChainSetHead func(context.Context, *types.TipSet) error `perm:"admin"`
ChainGetGenesis func(context.Context) (*types.TipSet, error) `perm:"read"`
ChainTipSetWeight func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"`
ChainGetNode func(ctx context.Context, p string) (interface{}, error) `perm:"read"`
ChainNotify func(context.Context) (<-chan []*api.HeadChange, error) `perm:"read"`
ChainHead func(context.Context) (*types.TipSet, error) `perm:"read"`
ChainGetRandomness func(context.Context, types.TipSetKey, crypto.DomainSeparationTag, abi.ChainEpoch, []byte) (abi.Randomness, error) `perm:"read"`
ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"`
ChainGetTipSet func(context.Context, types.TipSetKey) (*types.TipSet, error) `perm:"read"`
ChainGetBlockMessages func(context.Context, cid.Cid) (*api.BlockMessages, error) `perm:"read"`
ChainGetParentReceipts func(context.Context, cid.Cid) ([]*types.MessageReceipt, error) `perm:"read"`
ChainGetParentMessages func(context.Context, cid.Cid) ([]api.Message, error) `perm:"read"`
ChainGetTipSetByHeight func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) `perm:"read"`
ChainReadObj func(context.Context, cid.Cid) ([]byte, error) `perm:"read"`
ChainHasObj func(context.Context, cid.Cid) (bool, error) `perm:"read"`
ChainStatObj func(context.Context, cid.Cid, cid.Cid) (api.ObjStat, error) `perm:"read"`
ChainSetHead func(context.Context, types.TipSetKey) error `perm:"admin"`
ChainGetGenesis func(context.Context) (*types.TipSet, error) `perm:"read"`
ChainTipSetWeight func(context.Context, types.TipSetKey) (types.BigInt, error) `perm:"read"`
ChainGetNode func(ctx context.Context, p string) (*api.IpldObject, error) `perm:"read"`
ChainGetMessage func(context.Context, cid.Cid) (*types.Message, error) `perm:"read"`
ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, error) `perm:"read"`
ChainExport func(context.Context, types.TipSetKey) (<-chan []byte, error) `perm:"read"`
SyncState func(context.Context) (*api.SyncState, error) `perm:"read"`
SyncSubmitBlock func(ctx context.Context, blk *types.BlockMsg) error `perm:"write"`
SyncIncomingBlocks func(ctx context.Context) (<-chan *types.BlockHeader, error) `perm:"read"`
SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"`
MpoolPending func(context.Context, *types.TipSet) ([]*types.SignedMessage, error) `perm:"read"`
MpoolPush func(context.Context, *types.SignedMessage) error `perm:"write"`
MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"`
MpoolSub func(context.Context) (<-chan api.MpoolUpdate, error) `perm:"read"`
MpoolPending func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"`
MpoolPush func(context.Context, *types.SignedMessage) (cid.Cid, error) `perm:"write"`
MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"`
MpoolSub func(context.Context) (<-chan api.MpoolUpdate, error) `perm:"read"`
MpoolEstimateGasPrice func(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error) `perm:"read"`
MinerCreateBlock func(context.Context, address.Address, *types.TipSet, *types.Ticket, *types.EPostProof, []*types.SignedMessage, uint64, uint64) (*types.BlockMsg, error) `perm:"write"`
MinerGetBaseInfo func(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*api.MiningBaseInfo, error) `perm:"read"`
MinerCreateBlock func(context.Context, *api.BlockTemplate) (*types.BlockMsg, error) `perm:"write"`
WalletNew func(context.Context, string) (address.Address, error) `perm:"write"`
WalletNew func(context.Context, crypto.SigType) (address.Address, error) `perm:"write"`
WalletHas func(context.Context, address.Address) (bool, error) `perm:"write"`
WalletList func(context.Context) ([]address.Address, error) `perm:"write"`
WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"`
WalletSign func(context.Context, address.Address, []byte) (*types.Signature, error) `perm:"sign"`
WalletSign func(context.Context, address.Address, []byte) (*crypto.Signature, error) `perm:"sign"`
WalletSignMessage func(context.Context, address.Address, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
WalletVerify func(context.Context, address.Address, []byte, *crypto.Signature) bool `perm:"read"`
WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"`
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
ClientImport func(ctx context.Context, path string) (cid.Cid, error) `perm:"admin"`
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
ClientFindData func(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
ClientStartDeal func(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) `perm:"admin"`
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, path string) error `perm:"admin"`
ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) `perm:"read"`
ClientImport func(ctx context.Context, ref api.FileRef) (cid.Cid, error) `perm:"admin"`
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
ClientFindData func(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
ClientStartDeal func(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) `perm:"admin"`
ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"`
ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"`
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error `perm:"admin"`
ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) `perm:"read"`
ClientCalcCommP func(ctx context.Context, inpath string, miner address.Address) (*api.CommPRet, error) `perm:"read"`
ClientGenCar func(ctx context.Context, ref api.FileRef, outpath string) error `perm:"write"`
StateMinerSectors func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerProvingSet func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerPower func(context.Context, address.Address, *types.TipSet) (api.MinerPower, error) `perm:"read"`
StateMinerWorker func(context.Context, address.Address, *types.TipSet) (address.Address, error) `perm:"read"`
StateMinerPeerID func(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) `perm:"read"`
StateMinerElectionPeriodStart func(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) `perm:"read"`
StateMinerSectorSize func(context.Context, address.Address, *types.TipSet) (uint64, error) `perm:"read"`
StateCall func(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
StateReplay func(context.Context, *types.TipSet, cid.Cid) (*api.ReplayResults, error) `perm:"read"`
StateGetActor func(context.Context, address.Address, *types.TipSet) (*types.Actor, error) `perm:"read"`
StateReadState func(context.Context, *types.Actor, *types.TipSet) (*api.ActorState, error) `perm:"read"`
StatePledgeCollateral func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"`
StateWaitMsg func(context.Context, cid.Cid) (*api.MsgWait, error) `perm:"read"`
StateListMiners func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"`
StateListActors func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"`
StateMarketBalance func(context.Context, address.Address, *types.TipSet) (actors.StorageParticipantBalance, error) `perm:"read"`
StateMarketParticipants func(context.Context, *types.TipSet) (map[string]actors.StorageParticipantBalance, error) `perm:"read"`
StateMarketDeals func(context.Context, *types.TipSet) (map[string]actors.OnChainDeal, error) `perm:"read"`
StateMarketStorageDeal func(context.Context, uint64, *types.TipSet) (*actors.OnChainDeal, error) `perm:"read"`
StateLookupID func(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) `perm:"read"`
StateChangedActors func(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) `perm:"read"`
StateGetReceipt func(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
StateMinerSectorCount func(context.Context, address.Address, *types.TipSet) (api.MinerSectors, error) `perm:"read"`
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
StateMinerSectors func(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerProvingSet func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) `perm:"read"`
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error) `perm:"read"`
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
StateMinerInitialPledgeCollateral func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) `perm:"read"`
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
StateReplay func(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error) `perm:"read"`
StateGetActor func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error) `perm:"read"`
StateReadState func(context.Context, *types.Actor, types.TipSetKey) (*api.ActorState, error) `perm:"read"`
StatePledgeCollateral func(context.Context, types.TipSetKey) (types.BigInt, error) `perm:"read"`
StateWaitMsg func(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) `perm:"read"`
StateSearchMsg func(context.Context, cid.Cid) (*api.MsgLookup, error) `perm:"read"`
StateListMiners func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
StateListActors func(context.Context, types.TipSetKey) ([]address.Address, error) `perm:"read"`
StateMarketBalance func(context.Context, address.Address, types.TipSetKey) (api.MarketBalance, error) `perm:"read"`
StateMarketParticipants func(context.Context, types.TipSetKey) (map[string]api.MarketBalance, error) `perm:"read"`
StateMarketDeals func(context.Context, types.TipSetKey) (map[string]api.MarketDeal, error) `perm:"read"`
StateMarketStorageDeal func(context.Context, abi.DealID, types.TipSetKey) (*api.MarketDeal, error) `perm:"read"`
StateLookupID func(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) `perm:"read"`
StateAccountKey func(context.Context, address.Address, types.TipSetKey) (address.Address, error) `perm:"read"`
StateChangedActors func(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) `perm:"read"`
StateGetReceipt func(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) `perm:"read"`
StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error) `perm:"read"`
StateListMessages func(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
MarketEnsureAvailable func(context.Context, address.Address, types.BigInt) error `perm:"sign"`
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
MsigCreate func(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
MsigCancel func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
MarketEnsureAvailable func(context.Context, address.Address, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
PaychGet func(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*api.ChannelInfo, error) `perm:"sign"`
PaychList func(context.Context) ([]address.Address, error) `perm:"read"`
@@ -120,49 +168,102 @@ type FullNodeStruct struct {
PaychClose func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"`
PaychAllocateLane func(context.Context, address.Address) (uint64, error) `perm:"sign"`
PaychNewPayment func(ctx context.Context, from, to address.Address, vouchers []api.VoucherSpec) (*api.PaymentInfo, error) `perm:"sign"`
PaychVoucherCheck func(context.Context, *types.SignedVoucher) error `perm:"read"`
PaychVoucherCheckValid func(context.Context, address.Address, *types.SignedVoucher) error `perm:"read"`
PaychVoucherCheckSpendable func(context.Context, address.Address, *types.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"`
PaychVoucherAdd func(context.Context, address.Address, *types.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"`
PaychVoucherCreate func(context.Context, address.Address, types.BigInt, uint64) (*types.SignedVoucher, error) `perm:"sign"`
PaychVoucherList func(context.Context, address.Address) ([]*types.SignedVoucher, error) `perm:"write"`
PaychVoucherSubmit func(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error) `perm:"sign"`
PaychVoucherCheck func(context.Context, *paych.SignedVoucher) error `perm:"read"`
PaychVoucherCheckValid func(context.Context, address.Address, *paych.SignedVoucher) error `perm:"read"`
PaychVoucherCheckSpendable func(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"`
PaychVoucherAdd func(context.Context, address.Address, *paych.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"`
PaychVoucherCreate func(context.Context, address.Address, big.Int, uint64) (*paych.SignedVoucher, error) `perm:"sign"`
PaychVoucherList func(context.Context, address.Address) ([]*paych.SignedVoucher, error) `perm:"write"`
PaychVoucherSubmit func(context.Context, address.Address, *paych.SignedVoucher) (cid.Cid, error) `perm:"sign"`
}
}
func (c *FullNodeStruct) StateMinerSectorCount(ctx context.Context, addr address.Address, ts *types.TipSet) (api.MinerSectors, error) {
return c.Internal.StateMinerSectorCount(ctx, addr, ts)
func (c *FullNodeStruct) StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MinerSectors, error) {
return c.Internal.StateMinerSectorCount(ctx, addr, tsk)
}
type StorageMinerStruct struct {
CommonStruct
Internal struct {
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
ActorSectorSize func(context.Context, address.Address) (uint64, error) `perm:"read"`
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
ActorSectorSize func(context.Context, address.Address) (abi.SectorSize, error) `perm:"read"`
MiningBase func(context.Context) (*types.TipSet, error) `perm:"read"`
MarketImportDealData func(context.Context, cid.Cid, string) error `perm:"write"`
MarketListDeals func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
MarketListIncompleteDeals func(ctx context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
MarketSetPrice func(context.Context, types.BigInt) error `perm:"admin"`
PledgeSector func(context.Context) error `perm:"write"`
SectorsStatus func(context.Context, uint64) (api.SectorInfo, error) `perm:"read"`
SectorsList func(context.Context) ([]uint64, error) `perm:"read"`
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
SectorsUpdate func(context.Context, uint64, api.SectorState) error `perm:"write"`
SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"`
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"write"`
WorkerStats func(context.Context) (sectorbuilder.WorkerStats, error) `perm:"read"`
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"`
WorkerQueue func(ctx context.Context, cfg sectorbuilder.WorkerCfg) (<-chan sectorbuilder.WorkerTask, error) `perm:"admin"` // TODO: worker perm
WorkerDone func(ctx context.Context, task uint64, res sectorbuilder.SealRes) error `perm:"admin"`
StorageList func(context.Context) (map[stores.ID][]stores.Decl, error) `perm:"admin"`
StorageLocal func(context.Context) (map[stores.ID]string, error) `perm:"admin"`
StorageStat func(context.Context, stores.ID) (stores.FsStat, error) `perm:"admin"`
StorageAttach func(context.Context, stores.StorageInfo, stores.FsStat) error `perm:"admin"`
StorageDeclareSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType, bool) error `perm:"admin"`
StorageDropSector func(context.Context, stores.ID, abi.SectorID, stores.SectorFileType) error `perm:"admin"`
StorageFindSector func(context.Context, abi.SectorID, stores.SectorFileType, bool) ([]stores.SectorStorageInfo, error) `perm:"admin"`
StorageInfo func(context.Context, stores.ID) (stores.StorageInfo, error) `perm:"admin"`
StorageBestAlloc func(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, sealing stores.PathType) ([]stores.StorageInfo, error) `perm:"admin"`
StorageReportHealth func(ctx context.Context, id stores.ID, report stores.HealthReport) error `perm:"admin"`
StorageLock func(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) error `perm:"admin"`
DealsImportData func(ctx context.Context, dealPropCid cid.Cid, file string) error `perm:"write"`
DealsList func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
StorageAddLocal func(ctx context.Context, path string) error `perm:"admin"`
}
}
func (c *CommonStruct) AuthVerify(ctx context.Context, token string) ([]api.Permission, error) {
type WorkerStruct struct {
Internal struct {
// TODO: lower perms
Version func(context.Context) (build.Version, error) `perm:"admin"`
TaskTypes func(context.Context) (map[sealtasks.TaskType]struct{}, error) `perm:"admin"`
Paths func(context.Context) ([]stores.StoragePath, error) `perm:"admin"`
Info func(context.Context) (storiface.WorkerInfo, error) `perm:"admin"`
SealPreCommit1 func(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, pieces []abi.PieceInfo) (storage.PreCommit1Out, error) `perm:"admin"`
SealPreCommit2 func(context.Context, abi.SectorID, storage.PreCommit1Out) (cids storage.SectorCids, err error) `perm:"admin"`
SealCommit1 func(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (storage.Commit1Out, error) `perm:"admin"`
SealCommit2 func(context.Context, abi.SectorID, storage.Commit1Out) (storage.Proof, error) `perm:"admin"`
FinalizeSector func(context.Context, abi.SectorID) error `perm:"admin"`
MoveStorage func(ctx context.Context, sector abi.SectorID) error `perm:"admin"`
UnsealPiece func(context.Context, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize, abi.SealRandomness, cid.Cid) error `perm:"admin"`
ReadPiece func(context.Context, io.Writer, abi.SectorID, storiface.UnpaddedByteIndex, abi.UnpaddedPieceSize) error `perm:"admin"`
Fetch func(context.Context, abi.SectorID, stores.SectorFileType, stores.PathType, stores.AcquireMode) error `perm:"admin"`
Closing func(context.Context) (<-chan struct{}, error) `perm:"admin"`
}
}
// CommonStruct
func (c *CommonStruct) AuthVerify(ctx context.Context, token string) ([]auth.Permission, error) {
return c.Internal.AuthVerify(ctx, token)
}
func (c *CommonStruct) AuthNew(ctx context.Context, perms []api.Permission) ([]byte, error) {
func (c *CommonStruct) AuthNew(ctx context.Context, perms []auth.Permission) ([]byte, error) {
return c.Internal.AuthNew(ctx, perms)
}
func (c *CommonStruct) NetPubsubScores(ctx context.Context) ([]api.PubsubScore, error) {
return c.Internal.NetPubsubScores(ctx)
}
func (c *CommonStruct) NetConnectedness(ctx context.Context, pid peer.ID) (network.Connectedness, error) {
return c.Internal.NetConnectedness(ctx, pid)
}
@@ -183,6 +284,10 @@ func (c *CommonStruct) NetDisconnect(ctx context.Context, p peer.ID) error {
return c.Internal.NetDisconnect(ctx, p)
}
func (c *CommonStruct) NetFindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) {
return c.Internal.NetFindPeer(ctx, p)
}
// ID implements API.ID
func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
return c.Internal.ID(ctx)
@@ -193,12 +298,26 @@ func (c *CommonStruct) Version(ctx context.Context) (api.Version, error) {
return c.Internal.Version(ctx)
}
func (c *CommonStruct) LogList(ctx context.Context) ([]string, error) {
return c.Internal.LogList(ctx)
}
func (c *CommonStruct) LogSetLevel(ctx context.Context, group, level string) error {
return c.Internal.LogSetLevel(ctx, group, level)
}
func (c *CommonStruct) Shutdown(ctx context.Context) error {
return c.Internal.Shutdown(ctx)
}
// FullNodeStruct
func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) {
return c.Internal.ClientListImports(ctx)
}
func (c *FullNodeStruct) ClientImport(ctx context.Context, path string) (cid.Cid, error) {
return c.Internal.ClientImport(ctx, path)
func (c *FullNodeStruct) ClientImport(ctx context.Context, ref api.FileRef) (cid.Cid, error) {
return c.Internal.ClientImport(ctx, ref)
}
func (c *FullNodeStruct) ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error) {
@@ -209,8 +328,8 @@ func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid) ([]ap
return c.Internal.ClientFindData(ctx, root)
}
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Address, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
return c.Internal.ClientStartDeal(ctx, data, addr, miner, price, blocksDuration)
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) {
return c.Internal.ClientStartDeal(ctx, params)
}
func (c *FullNodeStruct) ClientGetDealInfo(ctx context.Context, deal cid.Cid) (*api.DealInfo, error) {
return c.Internal.ClientGetDealInfo(ctx, deal)
@@ -220,19 +339,26 @@ func (c *FullNodeStruct) ClientListDeals(ctx context.Context) ([]api.DealInfo, e
return c.Internal.ClientListDeals(ctx)
}
func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path string) error {
return c.Internal.ClientRetrieve(ctx, order, path)
func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, ref *api.FileRef) error {
return c.Internal.ClientRetrieve(ctx, order, ref)
}
func (c *FullNodeStruct) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) {
func (c *FullNodeStruct) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) {
return c.Internal.ClientQueryAsk(ctx, p, miner)
}
func (c *FullNodeStruct) MpoolPending(ctx context.Context, ts *types.TipSet) ([]*types.SignedMessage, error) {
return c.Internal.MpoolPending(ctx, ts)
func (c *FullNodeStruct) ClientCalcCommP(ctx context.Context, inpath string, miner address.Address) (*api.CommPRet, error) {
return c.Internal.ClientCalcCommP(ctx, inpath, miner)
}
func (c *FullNodeStruct) MpoolPush(ctx context.Context, smsg *types.SignedMessage) error {
func (c *FullNodeStruct) ClientGenCar(ctx context.Context, ref api.FileRef, outpath string) error {
return c.Internal.ClientGenCar(ctx, ref, outpath)
}
func (c *FullNodeStruct) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
return c.Internal.MpoolPending(ctx, tsk)
}
func (c *FullNodeStruct) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (cid.Cid, error) {
return c.Internal.MpoolPush(ctx, smsg)
}
@@ -244,23 +370,31 @@ func (c *FullNodeStruct) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate,
return c.Internal.MpoolSub(ctx)
}
func (c *FullNodeStruct) MinerCreateBlock(ctx context.Context, addr address.Address, base *types.TipSet, ticket *types.Ticket, eproof *types.EPostProof, msgs []*types.SignedMessage, height, ts uint64) (*types.BlockMsg, error) {
return c.Internal.MinerCreateBlock(ctx, addr, base, ticket, eproof, msgs, height, ts)
func (c *FullNodeStruct) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.MpoolEstimateGasPrice(ctx, nblocksincl, sender, limit, tsk)
}
func (c *FullNodeStruct) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) {
return c.Internal.MinerGetBaseInfo(ctx, maddr, epoch, tsk)
}
func (c *FullNodeStruct) MinerCreateBlock(ctx context.Context, bt *api.BlockTemplate) (*types.BlockMsg, error) {
return c.Internal.MinerCreateBlock(ctx, bt)
}
func (c *FullNodeStruct) ChainHead(ctx context.Context) (*types.TipSet, error) {
return c.Internal.ChainHead(ctx)
}
func (c *FullNodeStruct) ChainGetRandomness(ctx context.Context, pts types.TipSetKey, round int64) ([]byte, error) {
return c.Internal.ChainGetRandomness(ctx, pts, round)
func (c *FullNodeStruct) ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
return c.Internal.ChainGetRandomness(ctx, tsk, personalization, randEpoch, entropy)
}
func (c *FullNodeStruct) ChainGetTipSetByHeight(ctx context.Context, h uint64, ts *types.TipSet) (*types.TipSet, error) {
return c.Internal.ChainGetTipSetByHeight(ctx, h, ts)
func (c *FullNodeStruct) ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) {
return c.Internal.ChainGetTipSetByHeight(ctx, h, tsk)
}
func (c *FullNodeStruct) WalletNew(ctx context.Context, typ string) (address.Address, error) {
func (c *FullNodeStruct) WalletNew(ctx context.Context, typ crypto.SigType) (address.Address, error) {
return c.Internal.WalletNew(ctx, typ)
}
@@ -276,7 +410,7 @@ func (c *FullNodeStruct) WalletBalance(ctx context.Context, a address.Address) (
return c.Internal.WalletBalance(ctx, a)
}
func (c *FullNodeStruct) WalletSign(ctx context.Context, k address.Address, msg []byte) (*types.Signature, error) {
func (c *FullNodeStruct) WalletSign(ctx context.Context, k address.Address, msg []byte) (*crypto.Signature, error) {
return c.Internal.WalletSign(ctx, k, msg)
}
@@ -284,6 +418,10 @@ func (c *FullNodeStruct) WalletSignMessage(ctx context.Context, k address.Addres
return c.Internal.WalletSignMessage(ctx, k, msg)
}
func (c *FullNodeStruct) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) bool {
return c.Internal.WalletVerify(ctx, k, msg, sig)
}
func (c *FullNodeStruct) WalletDefaultAddress(ctx context.Context) (address.Address, error) {
return c.Internal.WalletDefaultAddress(ctx)
}
@@ -324,7 +462,7 @@ func (c *FullNodeStruct) ChainGetParentMessages(ctx context.Context, b cid.Cid)
return c.Internal.ChainGetParentMessages(ctx, b)
}
func (c *FullNodeStruct) ChainNotify(ctx context.Context) (<-chan []*store.HeadChange, error) {
func (c *FullNodeStruct) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
return c.Internal.ChainNotify(ctx)
}
@@ -332,22 +470,42 @@ func (c *FullNodeStruct) ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte,
return c.Internal.ChainReadObj(ctx, obj)
}
func (c *FullNodeStruct) ChainSetHead(ctx context.Context, ts *types.TipSet) error {
return c.Internal.ChainSetHead(ctx, ts)
func (c *FullNodeStruct) ChainHasObj(ctx context.Context, o cid.Cid) (bool, error) {
return c.Internal.ChainHasObj(ctx, o)
}
func (c *FullNodeStruct) ChainStatObj(ctx context.Context, obj, base cid.Cid) (api.ObjStat, error) {
return c.Internal.ChainStatObj(ctx, obj, base)
}
func (c *FullNodeStruct) ChainSetHead(ctx context.Context, tsk types.TipSetKey) error {
return c.Internal.ChainSetHead(ctx, tsk)
}
func (c *FullNodeStruct) ChainGetGenesis(ctx context.Context) (*types.TipSet, error) {
return c.Internal.ChainGetGenesis(ctx)
}
func (c *FullNodeStruct) ChainTipSetWeight(ctx context.Context, ts *types.TipSet) (types.BigInt, error) {
return c.Internal.ChainTipSetWeight(ctx, ts)
func (c *FullNodeStruct) ChainTipSetWeight(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.ChainTipSetWeight(ctx, tsk)
}
func (c *FullNodeStruct) ChainGetNode(ctx context.Context, p string) (interface{}, error) {
func (c *FullNodeStruct) ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error) {
return c.Internal.ChainGetNode(ctx, p)
}
func (c *FullNodeStruct) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error) {
return c.Internal.ChainGetMessage(ctx, mc)
}
func (c *FullNodeStruct) ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*api.HeadChange, error) {
return c.Internal.ChainGetPath(ctx, from, to)
}
func (c *FullNodeStruct) ChainExport(ctx context.Context, tsk types.TipSetKey) (<-chan []byte, error) {
return c.Internal.ChainExport(ctx, tsk)
}
func (c *FullNodeStruct) SyncState(ctx context.Context) (*api.SyncState, error) {
return c.Internal.SyncState(ctx)
}
@@ -360,95 +518,168 @@ func (c *FullNodeStruct) SyncIncomingBlocks(ctx context.Context) (<-chan *types.
return c.Internal.SyncIncomingBlocks(ctx)
}
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) {
return c.Internal.StateMinerSectors(ctx, addr, ts)
func (c *FullNodeStruct) SyncMarkBad(ctx context.Context, bcid cid.Cid) error {
return c.Internal.SyncMarkBad(ctx, bcid)
}
func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) {
return c.Internal.StateMinerProvingSet(ctx, addr, ts)
func (c *FullNodeStruct) SyncCheckBad(ctx context.Context, bcid cid.Cid) (string, error) {
return c.Internal.SyncCheckBad(ctx, bcid)
}
func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, ts *types.TipSet) (api.MinerPower, error) {
return c.Internal.StateMinerPower(ctx, a, ts)
func (c *FullNodeStruct) StateNetworkName(ctx context.Context) (dtypes.NetworkName, error) {
return c.Internal.StateNetworkName(ctx)
}
func (c *FullNodeStruct) StateMinerWorker(ctx context.Context, m address.Address, ts *types.TipSet) (address.Address, error) {
return c.Internal.StateMinerWorker(ctx, m, ts)
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, filter *abi.BitField, filterOut bool, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
return c.Internal.StateMinerSectors(ctx, addr, filter, filterOut, tsk)
}
func (c *FullNodeStruct) StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) {
return c.Internal.StateMinerPeerID(ctx, m, ts)
func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
return c.Internal.StateMinerProvingSet(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
return c.Internal.StateMinerElectionPeriodStart(ctx, actor, ts)
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
return c.Internal.StateMinerProvingDeadline(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateMinerSectorSize(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
return c.Internal.StateMinerSectorSize(ctx, actor, ts)
func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
return c.Internal.StateMinerPower(ctx, a, tsk)
}
func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) {
return c.Internal.StateCall(ctx, msg, ts)
func (c *FullNodeStruct) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) {
return c.Internal.StateMinerInfo(ctx, actor, tsk)
}
func (c *FullNodeStruct) StateReplay(ctx context.Context, ts *types.TipSet, mc cid.Cid) (*api.ReplayResults, error) {
return c.Internal.StateReplay(ctx, ts, mc)
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) (*miner.Deadlines, error) {
return c.Internal.StateMinerDeadlines(ctx, m, tsk)
}
func (c *FullNodeStruct) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) {
return c.Internal.StateGetActor(ctx, actor, ts)
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*abi.BitField, error) {
return c.Internal.StateMinerFaults(ctx, actor, tsk)
}
func (c *FullNodeStruct) StateReadState(ctx context.Context, act *types.Actor, ts *types.TipSet) (*api.ActorState, error) {
return c.Internal.StateReadState(ctx, act, ts)
func (c *FullNodeStruct) StateAllMinerFaults(ctx context.Context, cutoff abi.ChainEpoch, endTsk types.TipSetKey) ([]*api.Fault, error) {
return c.Internal.StateAllMinerFaults(ctx, cutoff, endTsk)
}
func (c *FullNodeStruct) StatePledgeCollateral(ctx context.Context, ts *types.TipSet) (types.BigInt, error) {
return c.Internal.StatePledgeCollateral(ctx, ts)
func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*abi.BitField, error) {
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
}
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid) (*api.MsgWait, error) {
return c.Internal.StateWaitMsg(ctx, msgc)
}
func (c *FullNodeStruct) StateListMiners(ctx context.Context, ts *types.TipSet) ([]address.Address, error) {
return c.Internal.StateListMiners(ctx, ts)
func (c *FullNodeStruct) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, snum abi.SectorNumber, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, snum, tsk)
}
func (c *FullNodeStruct) StateListActors(ctx context.Context, ts *types.TipSet) ([]address.Address, error) {
return c.Internal.StateListActors(ctx, ts)
func (c *FullNodeStruct) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.StateMinerAvailableBalance(ctx, maddr, tsk)
}
func (c *FullNodeStruct) StateMarketBalance(ctx context.Context, addr address.Address, ts *types.TipSet) (actors.StorageParticipantBalance, error) {
return c.Internal.StateMarketBalance(ctx, addr, ts)
func (c *FullNodeStruct) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
return c.Internal.StateSectorPreCommitInfo(ctx, maddr, n, tsk)
}
func (c *FullNodeStruct) StateMarketParticipants(ctx context.Context, ts *types.TipSet) (map[string]actors.StorageParticipantBalance, error) {
return c.Internal.StateMarketParticipants(ctx, ts)
func (c *FullNodeStruct) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
return c.Internal.StateSectorGetInfo(ctx, maddr, n, tsk)
}
func (c *FullNodeStruct) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]actors.OnChainDeal, error) {
return c.Internal.StateMarketDeals(ctx, ts)
func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error) {
return c.Internal.StateCall(ctx, msg, tsk)
}
func (c *FullNodeStruct) StateMarketStorageDeal(ctx context.Context, dealid uint64, ts *types.TipSet) (*actors.OnChainDeal, error) {
return c.Internal.StateMarketStorageDeal(ctx, dealid, ts)
func (c *FullNodeStruct) StateReplay(ctx context.Context, tsk types.TipSetKey, mc cid.Cid) (*api.InvocResult, error) {
return c.Internal.StateReplay(ctx, tsk, mc)
}
func (c *FullNodeStruct) StateLookupID(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
return c.Internal.StateLookupID(ctx, addr, ts)
func (c *FullNodeStruct) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {
return c.Internal.StateGetActor(ctx, actor, tsk)
}
func (c *FullNodeStruct) StateReadState(ctx context.Context, act *types.Actor, tsk types.TipSetKey) (*api.ActorState, error) {
return c.Internal.StateReadState(ctx, act, tsk)
}
func (c *FullNodeStruct) StatePledgeCollateral(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.StatePledgeCollateral(ctx, tsk)
}
func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid, confidence uint64) (*api.MsgLookup, error) {
return c.Internal.StateWaitMsg(ctx, msgc, confidence)
}
func (c *FullNodeStruct) StateSearchMsg(ctx context.Context, msgc cid.Cid) (*api.MsgLookup, error) {
return c.Internal.StateSearchMsg(ctx, msgc)
}
func (c *FullNodeStruct) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
return c.Internal.StateListMiners(ctx, tsk)
}
func (c *FullNodeStruct) StateListActors(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
return c.Internal.StateListActors(ctx, tsk)
}
func (c *FullNodeStruct) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) {
return c.Internal.StateMarketBalance(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateMarketParticipants(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketBalance, error) {
return c.Internal.StateMarketParticipants(ctx, tsk)
}
func (c *FullNodeStruct) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketDeal, error) {
return c.Internal.StateMarketDeals(ctx, tsk)
}
func (c *FullNodeStruct) StateMarketStorageDeal(ctx context.Context, dealid abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) {
return c.Internal.StateMarketStorageDeal(ctx, dealid, tsk)
}
func (c *FullNodeStruct) StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
return c.Internal.StateLookupID(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
return c.Internal.StateAccountKey(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateChangedActors(ctx context.Context, olnstate cid.Cid, newstate cid.Cid) (map[string]types.Actor, error) {
return c.Internal.StateChangedActors(ctx, olnstate, newstate)
}
func (c *FullNodeStruct) StateGetReceipt(ctx context.Context, msg cid.Cid, ts *types.TipSet) (*types.MessageReceipt, error) {
return c.Internal.StateGetReceipt(ctx, msg, ts)
func (c *FullNodeStruct) StateGetReceipt(ctx context.Context, msg cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
return c.Internal.StateGetReceipt(ctx, msg, tsk)
}
func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr address.Address, amt types.BigInt) error {
return c.Internal.MarketEnsureAvailable(ctx, addr, amt)
func (c *FullNodeStruct) StateListMessages(ctx context.Context, match *types.Message, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) {
return c.Internal.StateListMessages(ctx, match, tsk, toht)
}
func (c *FullNodeStruct) StateCompute(ctx context.Context, height abi.ChainEpoch, msgs []*types.Message, tsk types.TipSetKey) (*api.ComputeStateOutput, error) {
return c.Internal.StateCompute(ctx, height, msgs, tsk)
}
func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.Address, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
}
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req int64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
return c.Internal.MsigCreate(ctx, req, addrs, val, src, gp)
}
func (c *FullNodeStruct) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
return c.Internal.MsigPropose(ctx, msig, to, amt, src, method, params)
}
func (c *FullNodeStruct) MsigApprove(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
return c.Internal.MsigApprove(ctx, msig, txID, proposer, to, amt, src, method, params)
}
func (c *FullNodeStruct) MsigCancel(ctx context.Context, msig address.Address, txID uint64, proposer address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {
return c.Internal.MsigCancel(ctx, msig, txID, proposer, to, amt, src, method, params)
}
func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr, wallet address.Address, amt types.BigInt) (cid.Cid, error) {
return c.Internal.MarketEnsureAvailable(ctx, addr, wallet, amt)
}
func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*api.ChannelInfo, error) {
@@ -463,23 +694,23 @@ func (c *FullNodeStruct) PaychStatus(ctx context.Context, pch address.Address) (
return c.Internal.PaychStatus(ctx, pch)
}
func (c *FullNodeStruct) PaychVoucherCheckValid(ctx context.Context, addr address.Address, sv *types.SignedVoucher) error {
func (c *FullNodeStruct) PaychVoucherCheckValid(ctx context.Context, addr address.Address, sv *paych.SignedVoucher) error {
return c.Internal.PaychVoucherCheckValid(ctx, addr, sv)
}
func (c *FullNodeStruct) PaychVoucherCheckSpendable(ctx context.Context, addr address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (bool, error) {
func (c *FullNodeStruct) PaychVoucherCheckSpendable(ctx context.Context, addr address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) {
return c.Internal.PaychVoucherCheckSpendable(ctx, addr, sv, secret, proof)
}
func (c *FullNodeStruct) PaychVoucherAdd(ctx context.Context, addr address.Address, sv *types.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
func (c *FullNodeStruct) PaychVoucherAdd(ctx context.Context, addr address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
return c.Internal.PaychVoucherAdd(ctx, addr, sv, proof, minDelta)
}
func (c *FullNodeStruct) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*types.SignedVoucher, error) {
func (c *FullNodeStruct) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*paych.SignedVoucher, error) {
return c.Internal.PaychVoucherCreate(ctx, pch, amt, lane)
}
func (c *FullNodeStruct) PaychVoucherList(ctx context.Context, pch address.Address) ([]*types.SignedVoucher, error) {
func (c *FullNodeStruct) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) {
return c.Internal.PaychVoucherList(ctx, pch)
}
@@ -495,15 +726,21 @@ func (c *FullNodeStruct) PaychNewPayment(ctx context.Context, from, to address.A
return c.Internal.PaychNewPayment(ctx, from, to, vouchers)
}
func (c *FullNodeStruct) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *types.SignedVoucher) (cid.Cid, error) {
func (c *FullNodeStruct) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (cid.Cid, error) {
return c.Internal.PaychVoucherSubmit(ctx, ch, sv)
}
// StorageMinerStruct
func (c *StorageMinerStruct) ActorAddress(ctx context.Context) (address.Address, error) {
return c.Internal.ActorAddress(ctx)
}
func (c *StorageMinerStruct) ActorSectorSize(ctx context.Context, addr address.Address) (uint64, error) {
func (c *StorageMinerStruct) MiningBase(ctx context.Context) (*types.TipSet, error) {
return c.Internal.MiningBase(ctx)
}
func (c *StorageMinerStruct) ActorSectorSize(ctx context.Context, addr address.Address) (abi.SectorSize, error) {
return c.Internal.ActorSectorSize(ctx, addr)
}
@@ -512,12 +749,12 @@ func (c *StorageMinerStruct) PledgeSector(ctx context.Context) error {
}
// Get the status of a given sector by ID
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid uint64) (api.SectorInfo, error) {
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid abi.SectorNumber) (api.SectorInfo, error) {
return c.Internal.SectorsStatus(ctx, sid)
}
// List all staged sectors
func (c *StorageMinerStruct) SectorsList(ctx context.Context) ([]uint64, error) {
func (c *StorageMinerStruct) SectorsList(ctx context.Context) ([]abi.SectorNumber, error) {
return c.Internal.SectorsList(ctx)
}
@@ -525,22 +762,149 @@ func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]api.
return c.Internal.SectorsRefs(ctx)
}
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id uint64, state api.SectorState) error {
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
return c.Internal.SectorsUpdate(ctx, id, state)
}
func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (sectorbuilder.WorkerStats, error) {
func (c *StorageMinerStruct) WorkerConnect(ctx context.Context, url string) error {
return c.Internal.WorkerConnect(ctx, url)
}
func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (map[uint64]storiface.WorkerStats, error) {
return c.Internal.WorkerStats(ctx)
}
func (c *StorageMinerStruct) WorkerQueue(ctx context.Context, cfg sectorbuilder.WorkerCfg) (<-chan sectorbuilder.WorkerTask, error) {
return c.Internal.WorkerQueue(ctx, cfg)
func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.StorageInfo, st stores.FsStat) error {
return c.Internal.StorageAttach(ctx, si, st)
}
func (c *StorageMinerStruct) WorkerDone(ctx context.Context, task uint64, res sectorbuilder.SealRes) error {
return c.Internal.WorkerDone(ctx, task, res)
func (c *StorageMinerStruct) StorageDeclareSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType, primary bool) error {
return c.Internal.StorageDeclareSector(ctx, storageId, s, ft, primary)
}
func (c *StorageMinerStruct) StorageDropSector(ctx context.Context, storageId stores.ID, s abi.SectorID, ft stores.SectorFileType) error {
return c.Internal.StorageDropSector(ctx, storageId, s, ft)
}
func (c *StorageMinerStruct) StorageFindSector(ctx context.Context, si abi.SectorID, types stores.SectorFileType, allowFetch bool) ([]stores.SectorStorageInfo, error) {
return c.Internal.StorageFindSector(ctx, si, types, allowFetch)
}
func (c *StorageMinerStruct) StorageList(ctx context.Context) (map[stores.ID][]stores.Decl, error) {
return c.Internal.StorageList(ctx)
}
func (c *StorageMinerStruct) StorageLocal(ctx context.Context) (map[stores.ID]string, error) {
return c.Internal.StorageLocal(ctx)
}
func (c *StorageMinerStruct) StorageStat(ctx context.Context, id stores.ID) (stores.FsStat, error) {
return c.Internal.StorageStat(ctx, id)
}
func (c *StorageMinerStruct) StorageInfo(ctx context.Context, id stores.ID) (stores.StorageInfo, error) {
return c.Internal.StorageInfo(ctx, id)
}
func (c *StorageMinerStruct) StorageBestAlloc(ctx context.Context, allocate stores.SectorFileType, spt abi.RegisteredProof, pt stores.PathType) ([]stores.StorageInfo, error) {
return c.Internal.StorageBestAlloc(ctx, allocate, spt, pt)
}
func (c *StorageMinerStruct) StorageReportHealth(ctx context.Context, id stores.ID, report stores.HealthReport) error {
return c.Internal.StorageReportHealth(ctx, id, report)
}
func (c *StorageMinerStruct) StorageLock(ctx context.Context, sector abi.SectorID, read stores.SectorFileType, write stores.SectorFileType) error {
return c.Internal.StorageLock(ctx, sector, read, write)
}
func (c *StorageMinerStruct) MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error {
return c.Internal.MarketImportDealData(ctx, propcid, path)
}
func (c *StorageMinerStruct) MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error) {
return c.Internal.MarketListDeals(ctx)
}
func (c *StorageMinerStruct) MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) {
return c.Internal.MarketListIncompleteDeals(ctx)
}
func (c *StorageMinerStruct) MarketSetPrice(ctx context.Context, p types.BigInt) error {
return c.Internal.MarketSetPrice(ctx, p)
}
func (c *StorageMinerStruct) DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error {
return c.Internal.DealsImportData(ctx, dealPropCid, file)
}
func (c *StorageMinerStruct) DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error) {
return c.Internal.DealsList(ctx)
}
func (c *StorageMinerStruct) StorageAddLocal(ctx context.Context, path string) error {
return c.Internal.StorageAddLocal(ctx, path)
}
// WorkerStruct
func (w *WorkerStruct) Version(ctx context.Context) (build.Version, error) {
return w.Internal.Version(ctx)
}
func (w *WorkerStruct) TaskTypes(ctx context.Context) (map[sealtasks.TaskType]struct{}, error) {
return w.Internal.TaskTypes(ctx)
}
func (w *WorkerStruct) Paths(ctx context.Context) ([]stores.StoragePath, error) {
return w.Internal.Paths(ctx)
}
func (w *WorkerStruct) Info(ctx context.Context) (storiface.WorkerInfo, error) {
return w.Internal.Info(ctx)
}
func (w *WorkerStruct) SealPreCommit1(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, pieces []abi.PieceInfo) (storage.PreCommit1Out, error) {
return w.Internal.SealPreCommit1(ctx, sector, ticket, pieces)
}
func (w *WorkerStruct) SealPreCommit2(ctx context.Context, sector abi.SectorID, p1o storage.PreCommit1Out) (storage.SectorCids, error) {
return w.Internal.SealPreCommit2(ctx, sector, p1o)
}
func (w *WorkerStruct) SealCommit1(ctx context.Context, sector abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (storage.Commit1Out, error) {
return w.Internal.SealCommit1(ctx, sector, ticket, seed, pieces, cids)
}
func (w *WorkerStruct) SealCommit2(ctx context.Context, sector abi.SectorID, c1o storage.Commit1Out) (storage.Proof, error) {
return w.Internal.SealCommit2(ctx, sector, c1o)
}
func (w *WorkerStruct) FinalizeSector(ctx context.Context, sector abi.SectorID) error {
return w.Internal.FinalizeSector(ctx, sector)
}
func (w *WorkerStruct) MoveStorage(ctx context.Context, sector abi.SectorID) error {
return w.Internal.MoveStorage(ctx, sector)
}
func (w *WorkerStruct) UnsealPiece(ctx context.Context, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, c cid.Cid) error {
return w.Internal.UnsealPiece(ctx, id, index, size, randomness, c)
}
func (w *WorkerStruct) ReadPiece(ctx context.Context, writer io.Writer, id abi.SectorID, index storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) error {
return w.Internal.ReadPiece(ctx, writer, id, index, size)
}
func (w *WorkerStruct) Fetch(ctx context.Context, id abi.SectorID, fileType stores.SectorFileType, ptype stores.PathType, am stores.AcquireMode) error {
return w.Internal.Fetch(ctx, id, fileType, ptype, am)
}
func (w *WorkerStruct) Closing(ctx context.Context) (<-chan struct{}, error) {
return w.Internal.Closing(ctx)
}
var _ api.Common = &CommonStruct{}
var _ api.FullNode = &FullNodeStruct{}
var _ api.StorageMiner = &StorageMinerStruct{}
var _ api.WorkerAPI = &WorkerStruct{}
+9
View File
@@ -0,0 +1,9 @@
package apistruct
import "testing"
func TestPermTags(t *testing.T) {
_ = PermissionedFullAPI(&FullNodeStruct{})
_ = PermissionedStorMinerAPI(&StorageMinerStruct{})
_ = PermissionedWorkerAPI(&WorkerStruct{})
}
+530 -214
View File
@@ -1,16 +1,17 @@
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package api
import (
"fmt"
"io"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
var _ = xerrors.Errorf
func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
@@ -22,11 +23,17 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
return err
}
scratch := make([]byte, 9)
// t.Channel (address.Address) (struct)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Channel")))); err != nil {
if len("Channel") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Channel\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Channel"))); err != nil {
return err
}
if _, err := w.Write([]byte("Channel")); err != nil {
if _, err := io.WriteString(w, "Channel"); err != nil {
return err
}
@@ -35,10 +42,14 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
}
// t.ChannelMessage (cid.Cid) (struct)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("ChannelMessage")))); err != nil {
if len("ChannelMessage") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"ChannelMessage\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("ChannelMessage"))); err != nil {
return err
}
if _, err := w.Write([]byte("ChannelMessage")); err != nil {
if _, err := io.WriteString(w, "ChannelMessage"); err != nil {
return err
}
@@ -47,20 +58,28 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
return err
}
} else {
if err := cbg.WriteCid(w, *t.ChannelMessage); err != nil {
if err := cbg.WriteCidBuf(scratch, w, *t.ChannelMessage); err != nil {
return xerrors.Errorf("failed to write cid field t.ChannelMessage: %w", err)
}
}
// t.Vouchers ([]*types.SignedVoucher) (slice)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Vouchers")))); err != nil {
// t.Vouchers ([]*paych.SignedVoucher) (slice)
if len("Vouchers") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Vouchers\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Vouchers"))); err != nil {
return err
}
if _, err := w.Write([]byte("Vouchers")); err != nil {
if _, err := io.WriteString(w, "Vouchers"); err != nil {
return err
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil {
if len(t.Vouchers) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Vouchers was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Vouchers))); err != nil {
return err
}
for _, v := range t.Vouchers {
@@ -73,8 +92,9 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -82,114 +102,97 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input should be of type map")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
if extra > cbg.MaxLength {
return fmt.Errorf("PaymentInfo: map struct too large (%d)", extra)
}
var name string
n := extra
// t.Channel (address.Address) (struct)
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
name = string(sval)
}
if name != "Channel" {
return fmt.Errorf("expected struct map entry %s to be Channel", name)
}
{
if err := t.Channel.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.ChannelMessage (cid.Cid) (struct)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
name = string(sval)
}
if name != "ChannelMessage" {
return fmt.Errorf("expected struct map entry %s to be ChannelMessage", name)
}
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
{
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
} else {
c, err := cbg.ReadCid(br)
name = string(sval)
}
switch name {
// t.Channel (address.Address) (struct)
case "Channel":
{
if err := t.Channel.UnmarshalCBOR(br); err != nil {
return xerrors.Errorf("unmarshaling t.Channel: %w", err)
}
}
// t.ChannelMessage (cid.Cid) (struct)
case "ChannelMessage":
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.ChannelMessage: %w", err)
}
t.ChannelMessage = &c
}
}
// t.Vouchers ([]*paych.SignedVoucher) (slice)
case "Vouchers":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return xerrors.Errorf("failed to read cid field t.ChannelMessage: %w", err)
return err
}
t.ChannelMessage = &c
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Vouchers = make([]*paych.SignedVoucher, extra)
}
for i := 0; i < int(extra); i++ {
var v paych.SignedVoucher
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Vouchers[i] = &v
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
}
// t.Vouchers ([]*types.SignedVoucher) (slice)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
name = string(sval)
}
if name != "Vouchers" {
return fmt.Errorf("expected struct map entry %s to be Vouchers", name)
}
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Vouchers = make([]*types.SignedVoucher, extra)
}
for i := 0; i < int(extra); i++ {
var v types.SignedVoucher
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Vouchers[i] = &v
}
return nil
}
func (t *SealedRef) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
@@ -199,48 +202,64 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error {
return err
}
// t.SectorID (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("SectorID")))); err != nil {
scratch := make([]byte, 9)
// t.SectorID (abi.SectorNumber) (uint64)
if len("SectorID") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SectorID\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("SectorID"))); err != nil {
return err
}
if _, err := w.Write([]byte("SectorID")); err != nil {
if _, err := io.WriteString(w, "SectorID"); err != nil {
return err
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorID)); err != nil {
return err
}
// t.Offset (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Offset")))); err != nil {
if len("Offset") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Offset\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Offset"))); err != nil {
return err
}
if _, err := w.Write([]byte("Offset")); err != nil {
if _, err := io.WriteString(w, "Offset"); err != nil {
return err
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Offset))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Offset)); err != nil {
return err
}
// t.Size (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Size")))); err != nil {
// t.Size (abi.UnpaddedPieceSize) (uint64)
if len("Size") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Size\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Size"))); err != nil {
return err
}
if _, err := w.Write([]byte("Size")); err != nil {
if _, err := io.WriteString(w, "Size"); err != nil {
return err
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
return err
}
return nil
}
func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -248,84 +267,78 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input should be of type map")
}
if extra != 3 {
return fmt.Errorf("cbor input had wrong number of fields")
if extra > cbg.MaxLength {
return fmt.Errorf("SealedRef: map struct too large (%d)", extra)
}
var name string
n := extra
// t.SectorID (uint64) (uint64)
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
{
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
name = string(sval)
}
name = string(sval)
}
switch name {
// t.SectorID (abi.SectorNumber) (uint64)
case "SectorID":
if name != "SectorID" {
return fmt.Errorf("expected struct map entry %s to be SectorID", name)
}
{
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SectorID = uint64(extra)
// t.Offset (uint64) (uint64)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SectorID = abi.SectorNumber(extra)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
// t.Offset (uint64) (uint64)
case "Offset":
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Offset = uint64(extra)
}
// t.Size (abi.UnpaddedPieceSize) (uint64)
case "Size":
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Size = abi.UnpaddedPieceSize(extra)
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
name = string(sval)
}
if name != "Offset" {
return fmt.Errorf("expected struct map entry %s to be Offset", name)
}
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Offset = uint64(extra)
// t.Size (uint64) (uint64)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
name = string(sval)
}
if name != "Size" {
return fmt.Errorf("expected struct map entry %s to be Size", name)
}
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Size = uint64(extra)
return nil
}
func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
@@ -335,15 +348,25 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
return err
}
scratch := make([]byte, 9)
// t.Refs ([]api.SealedRef) (slice)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Refs")))); err != nil {
if len("Refs") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Refs\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Refs"))); err != nil {
return err
}
if _, err := w.Write([]byte("Refs")); err != nil {
if _, err := io.WriteString(w, "Refs"); err != nil {
return err
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Refs)))); err != nil {
if len(t.Refs) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Refs was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Refs))); err != nil {
return err
}
for _, v := range t.Refs {
@@ -356,8 +379,9 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -365,50 +389,342 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input should be of type map")
}
if extra != 1 {
return fmt.Errorf("cbor input had wrong number of fields")
if extra > cbg.MaxLength {
return fmt.Errorf("SealedRefs: map struct too large (%d)", extra)
}
var name string
n := extra
// t.Refs ([]api.SealedRef) (slice)
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
{
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
name = string(sval)
}
name = string(sval)
}
switch name {
// t.Refs ([]api.SealedRef) (slice)
case "Refs":
if name != "Refs" {
return fmt.Errorf("expected struct map entry %s to be Refs", name)
}
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Refs: array too large (%d)", extra)
}
if extra > cbg.MaxLength {
return fmt.Errorf("t.Refs: array too large (%d)", extra)
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Refs = make([]SealedRef, extra)
}
for i := 0; i < int(extra); i++ {
if extra > 0 {
t.Refs = make([]SealedRef, extra)
}
var v SealedRef
if err := v.UnmarshalCBOR(br); err != nil {
for i := 0; i < int(extra); i++ {
var v SealedRef
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Refs[i] = v
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
}
return nil
}
func (t *SealTicket) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{162}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Value (abi.SealRandomness) (slice)
if len("Value") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Value\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Value"))); err != nil {
return err
}
if _, err := io.WriteString(w, "Value"); err != nil {
return err
}
if len(t.Value) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Value was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Value))); err != nil {
return err
}
if _, err := w.Write(t.Value); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
if len("Epoch") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Epoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Epoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, "Epoch"); err != nil {
return err
}
if t.Epoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
return err
}
}
return nil
}
func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("SealTicket: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.Value (abi.SealRandomness) (slice)
case "Value":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Value: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
t.Value = make([]byte, extra)
if _, err := io.ReadFull(br, t.Value); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
case "Epoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
var extraI int64
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Epoch = abi.ChainEpoch(extraI)
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
}
return nil
}
func (t *SealSeed) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{162}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Value (abi.InteractiveSealRandomness) (slice)
if len("Value") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Value\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Value"))); err != nil {
return err
}
if _, err := io.WriteString(w, "Value"); err != nil {
return err
}
if len(t.Value) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Value was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Value))); err != nil {
return err
}
if _, err := w.Write(t.Value); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
if len("Epoch") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Epoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Epoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, "Epoch"); err != nil {
return err
}
if t.Epoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
return err
}
}
return nil
}
func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
if extra > cbg.MaxLength {
return fmt.Errorf("SealSeed: map struct too large (%d)", extra)
}
var name string
n := extra
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
name = string(sval)
}
switch name {
// t.Value (abi.InteractiveSealRandomness) (slice)
case "Value":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if extra > cbg.ByteArrayMaxLen {
return fmt.Errorf("t.Value: byte array too large (%d)", extra)
}
if maj != cbg.MajByteString {
return fmt.Errorf("expected byte array")
}
t.Value = make([]byte, extra)
if _, err := io.ReadFull(br, t.Value); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
case "Epoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
var extraI int64
if err != nil {
return err
}
switch maj {
case cbg.MajUnsignedInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 positive overflow")
}
case cbg.MajNegativeInt:
extraI = int64(extra)
if extraI < 0 {
return fmt.Errorf("int64 negative oveflow")
}
extraI = -1 - extraI
default:
return fmt.Errorf("wrong type for int64 field: %d", maj)
}
t.Epoch = abi.ChainEpoch(extraI)
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
t.Refs[i] = v
}
return nil
+21 -4
View File
@@ -1,11 +1,12 @@
package client
import (
"github.com/filecoin-project/lotus/api/apistruct"
"net/http"
"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/lib/jsonrpc"
"github.com/filecoin-project/lotus/api/apistruct"
)
// NewCommonRPC creates a new http jsonrpc client.
@@ -14,7 +15,9 @@ func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.C
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
[]interface{}{
&res.Internal,
}, requestHeader)
},
requestHeader,
)
return &res, closer, err
}
@@ -38,7 +41,21 @@ func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMine
[]interface{}{
&res.CommonStruct.Internal,
&res.Internal,
}, requestHeader)
},
requestHeader,
)
return &res, closer, err
}
func NewWorkerRPC(addr string, requestHeader http.Header) (api.WorkerAPI, jsonrpc.ClientCloser, error) {
var res apistruct.WorkerStruct
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
[]interface{}{
&res.Internal,
},
requestHeader,
)
return &res, closer, err
}
+338
View File
@@ -0,0 +1,338 @@
package main
import (
"encoding/json"
"fmt"
"go/ast"
"go/parser"
"go/token"
"reflect"
"sort"
"strings"
"time"
"unicode"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-filestore"
"github.com/libp2p/go-libp2p-core/network"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/multiformats/go-multiaddr"
)
var ExampleValues = map[reflect.Type]interface{}{
reflect.TypeOf(auth.Permission("")): auth.Permission("write"),
reflect.TypeOf(""): "string value",
reflect.TypeOf(uint64(42)): uint64(42),
reflect.TypeOf(byte(7)): byte(7),
reflect.TypeOf([]byte{}): []byte("byte array"),
}
func addExample(v interface{}) {
ExampleValues[reflect.TypeOf(v)] = v
}
func init() {
c, err := cid.Decode("bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4")
if err != nil {
panic(err)
}
ExampleValues[reflect.TypeOf(c)] = c
c2, err := cid.Decode("bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve")
if err != nil {
panic(err)
}
tsk := types.NewTipSetKey(c, c2)
ExampleValues[reflect.TypeOf(tsk)] = tsk
addr, err := address.NewIDAddress(1234)
if err != nil {
panic(err)
}
ExampleValues[reflect.TypeOf(addr)] = addr
pid, err := peer.IDB58Decode("12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf")
if err != nil {
panic(err)
}
addExample(pid)
addExample(bitfield.NewFromSet([]uint64{5}))
addExample(abi.RegisteredProof_StackedDRG32GiBPoSt)
addExample(abi.ChainEpoch(10101))
addExample(crypto.SigTypeBLS)
addExample(int64(9))
addExample(abi.MethodNum(1))
addExample(exitcode.ExitCode(0))
addExample(crypto.DomainSeparationTag_ElectionProofProduction)
addExample(true)
addExample(abi.UnpaddedPieceSize(1024))
addExample(abi.UnpaddedPieceSize(1024).Padded())
addExample(abi.DealID(5432))
addExample(filestore.StatusFileChanged)
addExample(abi.SectorNumber(9))
addExample(abi.SectorSize(32 * 1024 * 1024 * 1024))
addExample(api.MpoolChange(0))
addExample(network.Connected)
addExample(dtypes.NetworkName("lotus"))
addExample(api.SyncStateStage(1))
addExample(build.APIVersion)
addExample(api.PCHInbound)
addExample(time.Minute)
addExample(&types.ExecutionResult{
Msg: exampleValue(reflect.TypeOf(&types.Message{})).(*types.Message),
MsgRct: exampleValue(reflect.TypeOf(&types.MessageReceipt{})).(*types.MessageReceipt),
})
addExample(map[string]types.Actor{
"t01236": exampleValue(reflect.TypeOf(types.Actor{})).(types.Actor),
})
addExample(map[string]api.MarketDeal{
"t026363": exampleValue(reflect.TypeOf(api.MarketDeal{})).(api.MarketDeal),
})
addExample(map[string]api.MarketBalance{
"t026363": exampleValue(reflect.TypeOf(api.MarketBalance{})).(api.MarketBalance),
})
maddr, err := multiaddr.NewMultiaddr("/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior")
if err != nil {
panic(err)
}
// because reflect.TypeOf(maddr) returns the concrete type...
ExampleValues[reflect.TypeOf(struct{ A multiaddr.Multiaddr }{}).Field(0).Type] = maddr
}
func exampleValue(t reflect.Type) interface{} {
v, ok := ExampleValues[t]
if ok {
return v
}
switch t.Kind() {
case reflect.Slice:
out := reflect.New(t).Elem()
reflect.Append(out, reflect.ValueOf(exampleValue(t.Elem())))
return out.Interface()
case reflect.Chan:
return exampleValue(t.Elem())
case reflect.Struct:
es := exampleStruct(t)
v := reflect.ValueOf(es).Elem().Interface()
ExampleValues[t] = v
return v
case reflect.Array:
out := reflect.New(t).Elem()
for i := 0; i < t.Len(); i++ {
out.Index(i).Set(reflect.ValueOf(exampleValue(t.Elem())))
}
return out.Interface()
case reflect.Ptr:
if t.Elem().Kind() == reflect.Struct {
es := exampleStruct(t.Elem())
//ExampleValues[t] = es
return es
}
case reflect.Interface:
return struct{}{}
}
panic(fmt.Sprintf("No example value for type: %s", t))
}
func exampleStruct(t reflect.Type) interface{} {
ns := reflect.New(t)
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if strings.Title(f.Name) == f.Name {
ns.Elem().Field(i).Set(reflect.ValueOf(exampleValue(f.Type)))
}
}
return ns.Interface()
}
type Visitor struct {
Methods map[string]ast.Node
}
func (v *Visitor) Visit(node ast.Node) ast.Visitor {
st, ok := node.(*ast.TypeSpec)
if !ok {
return v
}
if st.Name.Name != "FullNode" {
return nil
}
iface := st.Type.(*ast.InterfaceType)
for _, m := range iface.Methods.List {
if len(m.Names) > 0 {
v.Methods[m.Names[0].Name] = m
}
}
return v
}
const noComment = "There are not yet any comments for this method."
func parseApiASTInfo() (map[string]string, map[string]string) { //nolint:golint
fset := token.NewFileSet()
pkgs, err := parser.ParseDir(fset, "./api", nil, parser.AllErrors|parser.ParseComments)
if err != nil {
fmt.Println("parse error: ", err)
}
ap := pkgs["api"]
f := ap.Files["api/api_full.go"]
cmap := ast.NewCommentMap(fset, f, f.Comments)
v := &Visitor{make(map[string]ast.Node)}
ast.Walk(v, pkgs["api"])
groupDocs := make(map[string]string)
out := make(map[string]string)
for mn, node := range v.Methods {
cs := cmap.Filter(node).Comments()
if len(cs) == 0 {
out[mn] = noComment
} else {
for _, c := range cs {
if strings.HasPrefix(c.Text(), "MethodGroup:") {
parts := strings.Split(c.Text(), "\n")
groupName := strings.TrimSpace(parts[0][12:])
comment := strings.Join(parts[1:], "\n")
groupDocs[groupName] = comment
break
}
}
last := cs[len(cs)-1].Text()
if !strings.HasPrefix(last, "MethodGroup:") {
out[mn] = last
} else {
out[mn] = noComment
}
}
}
return out, groupDocs
}
type MethodGroup struct {
GroupName string
Header string
Methods []*Method
}
type Method struct {
Comment string
Name string
InputExample string
ResponseExample string
}
func methodGroupFromName(mn string) string {
i := strings.IndexFunc(mn[1:], func(r rune) bool {
return unicode.IsUpper(r)
})
if i < 0 {
return ""
}
return mn[:i+1]
}
func main() {
comments, groupComments := parseApiASTInfo()
groups := make(map[string]*MethodGroup)
var api struct{ api.FullNode }
t := reflect.TypeOf(api)
for i := 0; i < t.NumMethod(); i++ {
m := t.Method(i)
groupName := methodGroupFromName(m.Name)
g, ok := groups[groupName]
if !ok {
g = new(MethodGroup)
g.Header = groupComments[groupName]
g.GroupName = groupName
groups[groupName] = g
}
var args []interface{}
ft := m.Func.Type()
for j := 2; j < ft.NumIn(); j++ {
inp := ft.In(j)
args = append(args, exampleValue(inp))
}
v, err := json.Marshal(args)
if err != nil {
panic(err)
}
outv := exampleValue(ft.Out(0))
ov, err := json.Marshal(outv)
if err != nil {
panic(err)
}
g.Methods = append(g.Methods, &Method{
Name: m.Name,
Comment: comments[m.Name],
InputExample: string(v),
ResponseExample: string(ov),
})
}
var groupslice []*MethodGroup
for _, g := range groups {
groupslice = append(groupslice, g)
}
sort.Slice(groupslice, func(i, j int) bool {
return groupslice[i].GroupName < groupslice[j].GroupName
})
for _, g := range groupslice {
g := g
fmt.Printf("## %s\n", g.GroupName)
fmt.Printf("%s\n\n", g.Header)
sort.Slice(g.Methods, func(i, j int) bool {
return g.Methods[i].Name < g.Methods[j].Name
})
for _, m := range g.Methods {
fmt.Printf("### %s\n", m.Name)
fmt.Printf("%s\n\n", m.Comment)
fmt.Printf("Inputs: `%s`\n\n", m.InputExample)
fmt.Printf("Response: `%s`\n\n", m.ResponseExample)
}
}
}
+142 -33
View File
@@ -11,12 +11,22 @@ import (
"testing"
"time"
logging "github.com/ipfs/go-log"
"github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log/v2"
"github.com/ipld/go-car"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
dag "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test"
unixfile "github.com/ipfs/go-unixfs/file"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl"
ipld "github.com/ipfs/go-ipld-format"
)
func init() {
@@ -24,11 +34,11 @@ func init() {
build.InsecurePoStValidation = true
}
func TestDealFlow(t *testing.T, b APIBuilder) {
os.Setenv("BELLMAN_NO_GPU", "1")
func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")
ctx := context.Background()
n, sn := b(t, 1, []int{0})
n, sn := b(t, 1, oneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI)
miner := sn[0]
@@ -42,21 +52,42 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
}
time.Sleep(time.Second)
data := make([]byte, 1000)
rand.New(rand.NewSource(5)).Read(data)
mine := true
done := make(chan struct{})
go func() {
defer close(done)
for mine {
time.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
t.Error(err)
}
}
}()
r := bytes.NewReader(data)
fcid, err := client.ClientImportLocal(ctx, r)
makeDeal(t, ctx, 6, client, miner, carExport)
mine = false
fmt.Println("shutting down mining")
<-done
}
func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")
ctx := context.Background()
n, sn := b(t, 1, oneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI)
miner := sn[0]
addrinfo, err := client.NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}
maddr, err := miner.ActorAddress(ctx)
if err != nil {
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
fmt.Println("FILE CID: ", fcid)
time.Sleep(time.Second)
mine := true
done := make(chan struct{})
@@ -64,24 +95,68 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
go func() {
defer close(done)
for mine {
time.Sleep(time.Second)
fmt.Println("mining a block now")
if err := sn[0].MineOne(ctx); err != nil {
time.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
t.Error(err)
}
}
}()
addr, err := client.WalletDefaultAddress(ctx)
if err != nil {
t.Fatal(err)
}
deal, err := client.ClientStartDeal(ctx, fcid, addr, maddr, types.NewInt(40000000), 100)
makeDeal(t, ctx, 6, client, miner, false)
makeDeal(t, ctx, 7, client, miner, false)
mine = false
fmt.Println("shutting down mining")
<-done
}
func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNodeAPI, miner TestStorageNode, carExport bool) {
data := make([]byte, 1600)
rand.New(rand.NewSource(int64(rseed))).Read(data)
r := bytes.NewReader(data)
fcid, err := client.ClientImportLocal(ctx, r)
if err != nil {
t.Fatal(err)
}
fmt.Println("FILE CID: ", fcid)
deal := startDeal(t, ctx, miner, client, fcid)
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
time.Sleep(time.Second)
waitDealSealed(t, ctx, client, deal)
// Retrieval
testRetrieval(t, ctx, err, client, fcid, carExport, data)
}
func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client *impl.FullNodeAPI, fcid cid.Cid) *cid.Cid {
maddr, err := miner.ActorAddress(ctx)
if err != nil {
t.Fatal(err)
}
addr, err := client.WalletDefaultAddress(ctx)
if err != nil {
t.Fatal(err)
}
deal, err := client.ClientStartDeal(ctx, &api.StartDealParams{
Data: &storagemarket.DataRef{Root: fcid},
Wallet: addr,
Miner: maddr,
EpochPrice: types.NewInt(1000000),
MinBlocksDuration: 100,
})
if err != nil {
t.Fatalf("%+v", err)
}
return deal
}
func waitDealSealed(t *testing.T, ctx context.Context, client *impl.FullNodeAPI, deal *cid.Cid) {
loop:
for {
di, err := client.ClientGetDealInfo(ctx, *deal)
@@ -89,22 +164,22 @@ loop:
t.Fatal(err)
}
switch di.State {
case api.DealRejected:
case storagemarket.StorageDealProposalRejected:
t.Fatal("deal rejected")
case api.DealFailed:
case storagemarket.StorageDealFailing:
t.Fatal("deal failed")
case api.DealError:
t.Fatal("deal errored")
case api.DealComplete:
case storagemarket.StorageDealError:
t.Fatal("deal errored", di.Message)
case storagemarket.StorageDealActive:
fmt.Println("COMPLETE", di)
break loop
}
fmt.Println("Deal state: ", api.DealStates[di.State])
fmt.Println("Deal state: ", storagemarket.DealStates[di.State])
time.Sleep(time.Second / 2)
}
}
// Retrieval
func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.FullNodeAPI, fcid cid.Cid, carExport bool, data []byte) {
offers, err := client.ClientFindData(ctx, fcid)
if err != nil {
t.Fatal(err)
@@ -118,14 +193,18 @@ loop:
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(rpath)
defer os.RemoveAll(rpath) //nolint:errcheck
caddr, err := client.WalletDefaultAddress(ctx)
if err != nil {
t.Fatal(err)
}
err = client.ClientRetrieve(ctx, offers[0].Order(caddr), filepath.Join(rpath, "ret"))
ref := &api.FileRef{
Path: filepath.Join(rpath, "ret"),
IsCAR: carExport,
}
err = client.ClientRetrieve(ctx, offers[0].Order(caddr), ref)
if err != nil {
t.Fatalf("%+v", err)
}
@@ -135,11 +214,41 @@ loop:
t.Fatal(err)
}
if carExport {
rdata = extractCarData(t, ctx, rdata, rpath)
}
if !bytes.Equal(rdata, data) {
t.Fatal("wrong data retrieved")
}
}
mine = false
fmt.Println("shutting down mining")
<-done
func extractCarData(t *testing.T, ctx context.Context, rdata []byte, rpath string) []byte {
bserv := dstest.Bserv()
ch, err := car.LoadCar(bserv.Blockstore(), bytes.NewReader(rdata))
if err != nil {
t.Fatal(err)
}
b, err := bserv.GetBlock(ctx, ch.Roots[0])
if err != nil {
t.Fatal(err)
}
nd, err := ipld.Decode(b)
if err != nil {
t.Fatal(err)
}
dserv := dag.NewDAGService(bserv)
fil, err := unixfile.NewUnixfsFile(ctx, dserv, nd)
if err != nil {
t.Fatal(err)
}
outPath := filepath.Join(rpath, "retLoadedCAR")
if err := files.WriteTo(fil, outPath); err != nil {
t.Fatal(err)
}
rdata, err = ioutil.ReadFile(outPath)
if err != nil {
t.Fatal(err)
}
return rdata
}
+172 -4
View File
@@ -1,31 +1,199 @@
package test
import (
"bytes"
"context"
"fmt"
"math/rand"
"os"
"sync/atomic"
"testing"
"time"
logging "github.com/ipfs/go-log/v2"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/node/impl"
)
var log = logging.Logger("apitest")
func (ts *testSuite) testMining(t *testing.T) {
ctx := context.Background()
apis, sn := ts.makeNodes(t, 1, []int{0})
apis, sn := ts.makeNodes(t, 1, oneMiner)
api := apis[0]
h1, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, uint64(0), h1.Height())
require.Equal(t, abi.ChainEpoch(0), h1.Height())
newHeads, err := api.ChainNotify(ctx)
require.NoError(t, err)
<-newHeads
err = sn[0].MineOne(ctx)
err = sn[0].MineOne(ctx, func(bool) {})
require.NoError(t, err)
<-newHeads
h2, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, uint64(1), h2.Height())
require.Equal(t, abi.ChainEpoch(1), h2.Height())
}
func (ts *testSuite) testMiningReal(t *testing.T) {
build.InsecurePoStValidation = false
defer func() {
build.InsecurePoStValidation = true
}()
ctx := context.Background()
apis, sn := ts.makeNodes(t, 1, oneMiner)
api := apis[0]
h1, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, abi.ChainEpoch(0), h1.Height())
newHeads, err := api.ChainNotify(ctx)
require.NoError(t, err)
<-newHeads
err = sn[0].MineOne(ctx, func(bool) {})
require.NoError(t, err)
<-newHeads
h2, err := api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, abi.ChainEpoch(1), h2.Height())
err = sn[0].MineOne(ctx, func(bool) {})
require.NoError(t, err)
<-newHeads
h2, err = api.ChainHead(ctx)
require.NoError(t, err)
require.Equal(t, abi.ChainEpoch(2), h2.Height())
}
func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")
// test making a deal with a fresh miner, and see if it starts to mine
ctx := context.Background()
n, sn := b(t, 1, []StorageMiner{
{Full: 0, Preseal: PresealGenesis},
{Full: 0, Preseal: 0}, // TODO: Add support for storage miners on non-first full node
})
client := n[0].FullNode.(*impl.FullNodeAPI)
provider := sn[1]
genesisMiner := sn[0]
addrinfo, err := client.NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}
if err := provider.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
if err := genesisMiner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
data := make([]byte, 600)
rand.New(rand.NewSource(5)).Read(data)
r := bytes.NewReader(data)
fcid, err := client.ClientImportLocal(ctx, r)
if err != nil {
t.Fatal(err)
}
fmt.Println("FILE CID: ", fcid)
var mine int32 = 1
done := make(chan struct{})
minedTwo := make(chan struct{})
go func() {
defer close(done)
prevExpect := 0
for atomic.LoadInt32(&mine) != 0 {
wait := make(chan int, 2)
mdone := func(mined bool) {
go func() {
n := 0
if mined {
n = 1
}
wait <- n
}()
}
if err := sn[0].MineOne(ctx, mdone); err != nil {
t.Error(err)
}
if err := sn[1].MineOne(ctx, mdone); err != nil {
t.Error(err)
}
expect := <-wait
expect += <-wait
time.Sleep(blocktime)
for {
n := 0
for i, node := range sn {
mb, err := node.MiningBase(ctx)
if err != nil {
t.Error(err)
return
}
if len(mb.Cids()) != expect {
log.Warnf("node %d mining base not complete (%d, want %d)", i, len(mb.Cids()), expect)
continue
}
n++
}
if n == len(sn) {
break
}
time.Sleep(blocktime)
}
if prevExpect == 2 && expect == 2 && minedTwo != nil {
close(minedTwo)
minedTwo = nil
}
prevExpect = expect
}
}()
deal := startDeal(t, ctx, provider, client, fcid)
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
time.Sleep(time.Second)
waitDealSealed(t, ctx, client, deal)
<-minedTwo
atomic.StoreInt32(&mine, 0)
fmt.Println("shutting down mining")
<-done
}
+21 -9
View File
@@ -4,9 +4,11 @@ import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/stretchr/testify/assert"
)
type TestNode struct {
@@ -16,7 +18,16 @@ type TestNode struct {
type TestStorageNode struct {
api.StorageMiner
MineOne func(context.Context) error
MineOne func(context.Context, func(bool)) error
}
var PresealGenesis = -1
const GenesisPreseals = 2
type StorageMiner struct {
Full int
Preseal int
}
// APIBuilder is a function which is invoked in test suite to provide
@@ -24,7 +35,7 @@ type TestStorageNode struct {
//
// storage array defines storage nodes, numbers in the array specify full node
// index the storage node 'belongs' to
type APIBuilder func(t *testing.T, nFull int, storage []int) ([]TestNode, []TestStorageNode)
type APIBuilder func(t *testing.T, nFull int, storage []StorageMiner) ([]TestNode, []TestStorageNode)
type testSuite struct {
makeNodes APIBuilder
}
@@ -39,25 +50,26 @@ func TestApis(t *testing.T, b APIBuilder) {
t.Run("id", ts.testID)
t.Run("testConnectTwo", ts.testConnectTwo)
t.Run("testMining", ts.testMining)
t.Run("testMiningReal", ts.testMiningReal)
}
var oneMiner = []StorageMiner{{Full: 0, Preseal: PresealGenesis}}
func (ts *testSuite) testVersion(t *testing.T) {
ctx := context.Background()
apis, _ := ts.makeNodes(t, 1, []int{0})
apis, _ := ts.makeNodes(t, 1, oneMiner)
api := apis[0]
v, err := api.Version(ctx)
if err != nil {
t.Fatal(err)
}
if v.Version != build.BuildVersion {
t.Error("Version didn't work properly")
}
require.Equal(t, v.Version, build.BuildVersion)
}
func (ts *testSuite) testID(t *testing.T) {
ctx := context.Background()
apis, _ := ts.makeNodes(t, 1, []int{0})
apis, _ := ts.makeNodes(t, 1, oneMiner)
api := apis[0]
id, err := api.ID(ctx)
@@ -69,7 +81,7 @@ func (ts *testSuite) testID(t *testing.T) {
func (ts *testSuite) testConnectTwo(t *testing.T) {
ctx := context.Background()
apis, _ := ts.makeNodes(t, 2, []int{0})
apis, _ := ts.makeNodes(t, 2, oneMiner)
p, err := apis[0].NetPeers(ctx)
if err != nil {
+169
View File
@@ -0,0 +1,169 @@
package test
import (
"context"
"fmt"
"github.com/filecoin-project/lotus/api"
"os"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/specs-actors/actors/abi"
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
sealing "github.com/filecoin-project/storage-fsm"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl"
)
func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
os.Setenv("BELLMAN_NO_GPU", "1")
ctx := context.Background()
n, sn := b(t, 1, oneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI)
miner := sn[0]
addrinfo, err := client.NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
mine := true
done := make(chan struct{})
go func() {
defer close(done)
for mine {
time.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
t.Error(err)
}
}
}()
pledgeSectors(t, ctx, miner, nSectors)
mine = false
<-done
}
func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n int) {
for i := 0; i < n; i++ {
err := miner.PledgeSector(ctx)
require.NoError(t, err)
}
for {
s, err := miner.SectorsList(ctx) // Note - the test builder doesn't import genesis sectors into FSM
require.NoError(t, err)
fmt.Printf("Sectors: %d\n", len(s))
if len(s) >= n {
break
}
time.Sleep(100 * time.Millisecond)
}
fmt.Printf("All sectors is fsm\n")
s, err := miner.SectorsList(ctx)
require.NoError(t, err)
toCheck := map[abi.SectorNumber]struct{}{}
for _, number := range s {
toCheck[number] = struct{}{}
}
for len(toCheck) > 0 {
for n := range toCheck {
st, err := miner.SectorsStatus(ctx, n)
require.NoError(t, err)
if st.State == api.SectorState(sealing.Proving) {
delete(toCheck, n)
}
if strings.Contains(string(st.State), "Fail") {
t.Fatal("sector in a failed state", st.State)
}
}
time.Sleep(100 * time.Millisecond)
fmt.Printf("WaitSeal: %d\n", len(s))
}
}
func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
os.Setenv("BELLMAN_NO_GPU", "1")
ctx := context.Background()
n, sn := b(t, 1, oneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI)
miner := sn[0]
addrinfo, err := client.NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
mine := true
done := make(chan struct{})
go func() {
defer close(done)
for mine {
time.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool) {}); err != nil {
t.Error(err)
}
}
}()
pledgeSectors(t, ctx, miner, nSectors)
maddr, err := miner.ActorAddress(ctx)
require.NoError(t, err)
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
require.NoError(t, err)
fmt.Printf("Running one proving periods\n")
for {
head, err := client.ChainHead(ctx)
require.NoError(t, err)
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
break
}
if head.Height()%100 == 0 {
fmt.Printf("@%d\n", head.Height())
}
time.Sleep(blocktime)
}
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
require.NoError(t, err)
ssz, err := miner.ActorSectorSize(ctx, maddr)
require.NoError(t, err)
require.Equal(t, p.MinerPower, p.TotalPower)
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+GenesisPreseals)))
// TODO: Inject faults here
mine = false
<-done
}
+12 -30
View File
@@ -3,40 +3,12 @@ package api
import (
"encoding/json"
"github.com/libp2p/go-libp2p-core/peer"
ma "github.com/multiformats/go-multiaddr"
)
type DealState = uint64
const (
DealUnknown = DealState(iota)
DealRejected // Provider didn't like the proposal
DealAccepted // Proposal accepted, data moved
DealStaged // Data put into the sector
DealSealing // Data in process of being sealed
DealFailed
DealComplete
// Internal
DealError // deal failed with an unexpected error
DealNoUpdate = DealUnknown
)
var DealStates = []string{
"DealUnknown",
"DealRejected",
"DealAccepted",
"DealStaged",
"DealSealing",
"DealFailed",
"DealComplete",
"DealError",
}
// TODO: check if this exists anywhere else
type MultiaddrSlice []ma.Multiaddr
func (m *MultiaddrSlice) UnmarshalJSON(raw []byte) (err error) {
@@ -57,3 +29,13 @@ func (m *MultiaddrSlice) UnmarshalJSON(raw []byte) (err error) {
}
var _ json.Unmarshaler = new(MultiaddrSlice)
type ObjStat struct {
Size uint64
Links uint64
}
type PubsubScore struct {
ID peer.ID
Score float64
}
+5 -5
View File
@@ -3,13 +3,13 @@ package api
import (
"context"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/crypto"
)
type SignFunc = func(context.Context, []byte) (*types.Signature, error)
type SignFunc = func(context.Context, []byte) (*crypto.Signature, error)
type Signer func(context.Context, address.Address, []byte) (*types.Signature, error)
type Signer func(context.Context, address.Address, []byte) (*crypto.Signature, error)
type Signable interface {
Sign(context.Context, SignFunc) error
@@ -17,7 +17,7 @@ type Signable interface {
func SignWith(ctx context.Context, signer Signer, addr address.Address, signable ...Signable) error {
for _, s := range signable {
err := s.Sign(ctx, func(ctx context.Context, b []byte) (*types.Signature, error) {
err := s.Sign(ctx, func(ctx context.Context, b []byte) (*crypto.Signature, error) {
return signer(ctx, addr, b)
})
if err != nil {
-177
View File
@@ -1,177 +0,0 @@
#!/bin/sh
GOCC=${GOCC=go}
die() {
echo "$@" >&2
exit 1
}
have_binary() {
type "$1" > /dev/null 2> /dev/null
}
check_writable() {
printf "" > "$1" && rm "$1"
}
try_download() {
url="$1"
output="$2"
command="$3"
util_name="$(set -- $command; echo "$1")"
if ! have_binary "$util_name"; then
return 1
fi
printf '==> Using %s to download "%s" to "%s"\n' "$util_name" "$url" "$output"
if eval "$command"; then
echo "==> Download complete!"
return
else
echo "error: couldn't download with $util_name ($?)"
return 1
fi
}
download() {
dl_url="$1"
dl_output="$2"
test "$#" -eq "2" || die "download requires exactly two arguments, was given $@"
if ! check_writable "$dl_output"; then
die "download error: cannot write to $dl_output"
fi
try_download "$dl_url" "$dl_output" "wget '$dl_url' -O '$dl_output'" && return
try_download "$dl_url" "$dl_output" "curl --silent --fail --output '$dl_output' '$dl_url'" && return
try_download "$dl_url" "$dl_output" "fetch '$dl_url' -o '$dl_output'" && return
try_download "$dl_url" "$dl_output" "http '$dl_url' > '$dl_output'" && return
try_download "$dl_url" "$dl_output" "ftp -o '$dl_output' '$dl_url'" && return
die "Unable to download $dl_url. exiting."
}
unarchive() {
ua_archivetype="$1"
ua_infile="$2"
ua_outfile="$3"
ua_distname="$4"
ua_binpostfix=""
ua_os=$(uname -o)
if [ "$ua_os" = "Msys" ] || [ "$ua_os" = "Cygwin" ] ; then
ua_binpostfix=".exe"
fi
ua_outfile="$ua_outfile$ua_binpostfix"
if ! check_writable "$ua_outfile"; then
die "unarchive error: cannot write to $ua_outfile"
fi
case "$ua_archivetype" in
tar.gz)
if have_binary tar; then
echo "==> using 'tar' to extract binary from archive"
< "$ua_infile" tar -Ozxf - "$ua_distname/$ua_distname$ua_binpostfix" > "$ua_outfile" \
|| die "tar has failed"
else
die "no binary on system for extracting tar files"
fi
;;
zip)
if have_binary unzip; then
echo "==> using 'unzip' to extract binary from archive"
unzip -p "$ua_infile" "$ua_distname/$ua_distname$ua_binpostfix" > "$ua_outfile" \
|| die "unzip has failed"
else
die "no installed method for extracting .zip archives"
fi
;;
*)
die "unrecognized archive type '$ua_archivetype'"
esac
chmod +x "$ua_outfile" || die "chmod has failed"
}
get_go_vars() {
if [ ! -z "$GOOS" ] && [ ! -z "$GOARCH" ]; then
printf "%s-%s" "$GOOS" "$GOARCH"
elif have_binary go; then
printf "%s-%s" "$($GOCC env GOOS)" "$($GOCC env GOARCH)"
else
die "no way of determining system GOOS and GOARCH\nPlease manually set GOOS and GOARCH then retry."
fi
}
mkurl() {
m_root="$1"
m_name="$2"
m_vers="$3"
m_archive="$4"
m_govars=$(get_go_vars) || die "could not get go env vars"
echo "https://ipfs.io$m_root/$m_name/$m_vers/${m_name}_${m_vers}_$m_govars.$m_archive"
}
distroot="$1"
distname="$2"
outpath="$3"
version="$4"
if [ -z "$distroot" ] || [ -z "$distname" ] || [ -z "$outpath" ] || [ -z "$version" ]; then
die "usage: dist_get <distroot> <distname> <outpath> <version>"
fi
case $version in
v*)
# correct input
;;
*)
echo "invalid version '$version'" >&2
die "versions must begin with 'v', for example: v0.4.0"
;;
esac
# TODO: don't depend on the go tool being installed to detect this
goenv=$(get_go_vars) || die "could not get go env vars"
case $goenv in
linux-*)
archive="tar.gz"
;;
darwin-*)
archive="tar.gz"
;;
windows-*)
archive="zip"
;;
freebsd-*)
archive="tar.gz"
;;
openbsd-*)
archive="tar.gz"
;;
*)
echo "unrecognized system environment: $goenv" >&2
die "currently only linux, darwin, windows and freebsd are supported by this script"
esac
mkdir -p bin/tmp
url=$(mkurl "$distroot" "$distname" "$version" "$archive")
tmpfi="bin/tmp/$distname.$archive"
download "$url" "$tmpfi"
if [ $? -ne 0 ]; then
die "failed to download $url to $tmpfi"
fi
unarchive "$archive" "$tmpfi" "$outpath" "$distname"
if [ $? -ne 0 ]; then
die "failed to extract archive $tmpfi"
fi
+6 -6
View File
@@ -1,6 +1,6 @@
/dns4/lotus-bootstrap-0.dfw.fil-test.net/tcp/1347/p2p/12D3KooWHwGBSiLR5ts7KW9MgH4BMzC2iXe18kwAQ8Ee3LUd1jeR
/dns4/lotus-bootstrap-1.dfw.fil-test.net/tcp/1347/p2p/12D3KooWCLFaawdhLGcSpiqg43DtZ9QzPQ6HcB8Vvyu2Cnta8UWc
/dns4/lotus-bootstrap-0.fra.fil-test.net/tcp/1347/p2p/12D3KooWMmaL7eaUCF6tVAghVmgozxz4uztbuFUQv6dyFpHRarHR
/dns4/lotus-bootstrap-1.fra.fil-test.net/tcp/1347/p2p/12D3KooWLLpNYoKdf9NgcWudBhXLdTcXncqAsTzozw1scMMu6nS5
/dns4/lotus-bootstrap-0.sin.fil-test.net/tcp/1347/p2p/12D3KooWCNL9vXaXwNs3Bu8uRAJK4pxpCyPeM7jZLSDpJma1wrV8
/dns4/lotus-bootstrap-1.sin.fil-test.net/tcp/1347/p2p/12D3KooWNGGxFda1eC5U2YKAgs4ypoFHn3Z3xHCsjmFdrCcytoxm
/dns4/t01000.miner.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWALjK9ai1gzssE4H9kwmS7CVqkENedeJJzmgVS9YMtLii
/ip4/34.217.110.132/tcp/1347/p2p/12D3KooWALjK9ai1gzssE4H9kwmS7CVqkENedeJJzmgVS9YMtLii
/dns4/peer0.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWSJYjQMi2MGaeyRAWvDnEAAC7GdFSRXk5Lns6G1ajSMA7
/ip4/54.187.182.170/tcp/1347/p2p/12D3KooWSJYjQMi2MGaeyRAWvDnEAAC7GdFSRXk5Lns6G1ajSMA7
/dns4/peer1.interopnet.kittyhawk.wtf/tcp/1347/p2p/12D3KooWPdeoNGcaGTxWdENfzEYJ9WqGVkJAxi2aHpX4TjkbeGkj
/ip4/52.24.84.39/tcp/1347/p2p/12D3KooWPdeoNGcaGTxWdENfzEYJ9WqGVkJAxi2aHpX4TjkbeGkj
-3
View File
@@ -1,4 +1 @@
package build
const ForkCCM = 1750
const ForkNoPowerEPSUpdates = 16450
+9 -3
View File
@@ -1,16 +1,22 @@
package build
import rice "github.com/GeertJohan/go.rice"
import (
rice "github.com/GeertJohan/go.rice"
logging "github.com/ipfs/go-log/v2"
)
// moved from now-defunct build/paramfetch.go
var log = logging.Logger("build")
func MaybeGenesis() []byte {
builtinGen, err := rice.FindBox("genesis")
if err != nil {
log.Warn("loading built-in genesis: %s", err)
log.Warnf("loading built-in genesis: %s", err)
return nil
}
genBytes, err := builtinGen.Bytes("devnet.car")
if err != nil {
log.Warn("loading built-in genesis: %s", err)
log.Warnf("loading built-in genesis: %s", err)
}
return genBytes
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
package build
import rice "github.com/GeertJohan/go.rice"
func ParametersJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
}
-189
View File
@@ -1,189 +0,0 @@
package build
import (
"encoding/hex"
"encoding/json"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
rice "github.com/GeertJohan/go.rice"
logging "github.com/ipfs/go-log"
"github.com/minio/blake2b-simd"
"go.uber.org/multierr"
"golang.org/x/xerrors"
pb "gopkg.in/cheggaaa/pb.v1"
)
var log = logging.Logger("build")
//const gateway = "http://198.211.99.118/ipfs/"
const gateway = "https://ipfs.io/ipfs/"
const paramdir = "/var/tmp/filecoin-proof-parameters"
const dirEnv = "FIL_PROOFS_PARAMETER_CACHE"
type paramFile struct {
Cid string `json:"cid"`
Digest string `json:"digest"`
SectorSize uint64 `json:"sector_size"`
}
type fetch struct {
wg sync.WaitGroup
fetchLk sync.Mutex
errs []error
}
func getParamDir() string {
if os.Getenv(dirEnv) == "" {
return paramdir
}
return os.Getenv(dirEnv)
}
func GetParams(storageSize uint64) error {
if err := os.Mkdir(getParamDir(), 0755); err != nil && !os.IsExist(err) {
return err
}
var params map[string]paramFile
paramBytes := rice.MustFindBox("proof-params").MustBytes("parameters.json")
if err := json.Unmarshal(paramBytes, &params); err != nil {
return err
}
ft := &fetch{}
for name, info := range params {
if storageSize != info.SectorSize && strings.HasSuffix(name, ".params") {
continue
}
ft.maybeFetchAsync(name, info)
}
return ft.wait()
}
func (ft *fetch) maybeFetchAsync(name string, info paramFile) {
ft.wg.Add(1)
go func() {
defer ft.wg.Done()
path := filepath.Join(getParamDir(), name)
err := ft.checkFile(path, info)
if !os.IsNotExist(err) && err != nil {
log.Warn(err)
}
if err == nil {
return
}
ft.fetchLk.Lock()
defer ft.fetchLk.Unlock()
if err := doFetch(path, info); err != nil {
ft.errs = append(ft.errs, xerrors.Errorf("fetching file %s failed: %w", path, err))
return
}
err = ft.checkFile(path, info)
if err != nil {
ft.errs = append(ft.errs, xerrors.Errorf("checking file %s failed: %w", path, err))
err := os.Remove(path)
if err != nil {
ft.errs = append(ft.errs, xerrors.Errorf("remove file %s failed: %w", path, err))
}
}
}()
}
func (ft *fetch) checkFile(path string, info paramFile) error {
if os.Getenv("TRUST_PARAMS") == "1" {
log.Warn("Assuming parameter files are ok. DO NOT USE IN PRODUCTION")
return nil
}
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
h := blake2b.New512()
if _, err := io.Copy(h, f); err != nil {
return err
}
sum := h.Sum(nil)
strSum := hex.EncodeToString(sum[:16])
if strSum == info.Digest {
log.Infof("Parameter file %s is ok", path)
return nil
}
return xerrors.Errorf("checksum mismatch in param file %s, %s != %s", path, strSum, info.Digest)
}
func (ft *fetch) wait() error {
ft.wg.Wait()
return multierr.Combine(ft.errs...)
}
func doFetch(out string, info paramFile) error {
gw := os.Getenv("IPFS_GATEWAY")
if gw == "" {
gw = gateway
}
log.Infof("Fetching %s from %s", out, gw)
outf, err := os.OpenFile(out, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
return err
}
defer outf.Close()
fStat, err := outf.Stat()
if err != nil {
return err
}
header := http.Header{}
header.Set("Range", "bytes="+strconv.FormatInt(fStat.Size(), 10)+"-")
url, err := url.Parse(gw + info.Cid)
if err != nil {
return err
}
log.Infof("GET %s", url)
req := http.Request{
Method: "GET",
URL: url,
Header: header,
Close: true,
}
resp, err := http.DefaultClient.Do(&req)
if err != nil {
return err
}
defer resp.Body.Close()
bar := pb.New64(resp.ContentLength)
bar.Units = pb.U_BYTES
bar.ShowSpeed = true
bar.Start()
_, err = io.Copy(outf, bar.NewProxyReader(resp.Body))
bar.Finish()
return err
}
+35
View File
@@ -0,0 +1,35 @@
// +build debug 2k
package build
import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
)
func init() {
power.ConsensusMinerMinPower = big.NewInt(2048)
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
abi.RegisteredProof_StackedDRG2KiBSeal: {},
}
verifreg.MinVerifiedDealSize = big.NewInt(256)
BuildType |= Build2k
}
// Seconds
const BlockDelay = 2
const PropagationDelay = 3
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
// which the miner is slashed
//
// Epochs
const SlashablePowerDelay = 20
// Epochs
const InteractivePoRepConfidence = 6
+4 -31
View File
@@ -2,36 +2,9 @@
package build
import "os"
var SectorSizes = []uint64{1024}
// Seconds
const BlockDelay = 6
const PropagationDelay = 3
// FallbackPoStDelay is the number of epochs the miner needs to wait after
// ElectionPeriodStart before starting fallback post computation
//
// Epochs
const FallbackPoStDelay = 10
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
// which the miner is slashed
//
// Epochs
const SlashablePowerDelay = 20
// Epochs
const InteractivePoRepDelay = 2
// Epochs
const InteractivePoRepConfidence = 6
// Bytes
var MinimumMinerPower uint64 = 2 << 10 // 2KiB
func init() {
os.Setenv("TRUST_PARAMS", "1")
InsecurePoStValidation = true
BuildType |= BuildDebug
}
// NOTE: Also includes settings from params_2k
+58 -38
View File
@@ -2,31 +2,49 @@ package build
import (
"math/big"
"sort"
"github.com/libp2p/go-libp2p-core/protocol"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
func DefaultSectorSize() abi.SectorSize {
szs := make([]abi.SectorSize, 0, len(miner.SupportedProofTypes))
for spt := range miner.SupportedProofTypes {
ss, err := spt.SectorSize()
if err != nil {
panic(err)
}
szs = append(szs, ss)
}
sort.Slice(szs, func(i, j int) bool {
return szs[i] < szs[j]
})
return szs[0]
}
// Core network constants
func BlocksTopic(netName dtypes.NetworkName) string { return "/fil/blocks/" + string(netName) }
func MessagesTopic(netName dtypes.NetworkName) string { return "/fil/msgs/" + string(netName) }
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
return protocol.ID("/fil/kad/" + string(netName))
}
// /////
// Storage
const UnixfsChunkSize uint64 = 1 << 20
const UnixfsLinksPerLevel = 1024
func SupportedSectorSize(ssize uint64) bool {
for _, ss := range SectorSizes {
if ssize == ss {
return true
}
}
return false
}
// /////
// Payments
// Epochs
const PaymentChannelClosingDelay = 6 * 60 * 60 / BlockDelay // six hours
// /////
// Consensus / Network
@@ -37,10 +55,11 @@ const AllowableClockDrift = 1
const ForkLengthThreshold = Finality
// Blocks (e)
const BlocksPerEpoch = 5
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
// Epochs
const Finality = 500
const Finality = miner.ChainFinalityish
const MessageConfidence = 5
// constants for Weight calculation
// The ratio of weight contributed by short-term vs long-term factors in a given round
@@ -54,22 +73,18 @@ const WRatioDen = 2
const SealRandomnessLookback = Finality
// Epochs
const SealRandomnessLookbackLimit = SealRandomnessLookback + 2000
const SealRandomnessLookbackLimit = SealRandomnessLookback + 2000 // TODO: Get from spec specs-actors
// 1 / n
const SectorChallengeRatioDiv = 25
const MaxFallbackPostChallengeCount = 10
// Maximum lookback that randomness can be sourced from for a seal proof submission
const MaxSealLookback = SealRandomnessLookbackLimit + 2000 // TODO: Get from specs-actors
// /////
// Mining
// Epochs
const EcRandomnessLookback = 300
const TicketRandomnessLookback = 1
const PowerCollateralProportion = 5
const PerCapitaCollateralProportion = 1
const CollateralPrecision = 1000
const WinningPoStSectorSetLookback = 10
// /////
// Devnet settings
@@ -77,23 +92,15 @@ const CollateralPrecision = 1000
const TotalFilecoin = 2_000_000_000
const MiningRewardTotal = 1_400_000_000
const InitialRewardStr = "153856861913558700202"
var InitialReward *big.Int
const FilecoinPrecision = 1_000_000_000_000_000_000
var InitialRewardBalance *big.Int
// TODO: Move other important consts here
func init() {
InitialReward = new(big.Int)
var ok bool
InitialReward, ok = InitialReward.
SetString(InitialRewardStr, 10)
if !ok {
panic("could not parse InitialRewardStr")
}
InitialRewardBalance = big.NewInt(MiningRewardTotal)
InitialRewardBalance = InitialRewardBalance.Mul(InitialRewardBalance, big.NewInt(FilecoinPrecision))
}
// Sync
@@ -102,3 +109,16 @@ const BadBlockCacheSize = 1 << 15
// assuming 4000 messages per round, this lets us not lose any messages across a
// 10 block reorg.
const BlsSignatureCacheSize = 40000
// Size of signature verification cache
// 32k keeps the cache around 10MB in size, max
const VerifSigCacheSize = 32000
// ///////
// Limits
// TODO: If this is gonna stay, it should move to specs-actors
const BlockMessageLimit = 512
const BlockGasLimit = 100_000_000_000
var DrandChain = `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"138a324aa6540f93d0dad002aa89454b1bec2b6e948682cde6bd4db40f4b7c9b"}`
+17 -25
View File
@@ -1,34 +1,26 @@
// +build !debug
// +build !2k
package build
var SectorSizes = []uint64{
1 << 30,
32 << 30,
import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
)
func init() {
power.ConsensusMinerMinPower = big.NewInt(1024 << 20)
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
abi.RegisteredProof_StackedDRG512MiBSeal: {},
abi.RegisteredProof_StackedDRG32GiBSeal: {},
abi.RegisteredProof_StackedDRG64GiBSeal: {},
}
}
// Seconds
const BlockDelay = 45
const BlockDelay = builtin.EpochDurationSeconds
const PropagationDelay = 6
// FallbackPoStDelay is the number of epochs the miner needs to wait after
// ElectionPeriodStart before starting fallback post computation
//
// Epochs
const FallbackPoStDelay = 30
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
// which the miner is slashed
//
// Epochs
const SlashablePowerDelay = 200
// Epochs
const InteractivePoRepDelay = 8
// Epochs
const InteractivePoRepConfidence = 6
// Bytes
var MinimumMinerPower uint64 = 512 << 30 // 512GB
-20
View File
@@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
function b64() {
f="$1"
case `uname` in
Darwin)
base64 -i "$f"
;;
Linux)
base64 "$f" -w 0
;;
esac
printf "unsupported system" 1>&2
exit 1
}
sed "s/{{PARAMSJSON}}/$(b64 build/proof-params/parameters.json)/g" build/proof-params/paramfetch.sh.template > ./build/paramfetch.sh
chmod +x ./build/paramfetch.sh
+137 -88
View File
@@ -1,103 +1,152 @@
{
"v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.params": {
"cid": "QmX7tYeNPWae2fjZ3Am6GB9dmHvLqvoz8dKo3PR98VYxH9",
"digest": "39a9edec3355516674f0d12b926be493",
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params": {
"cid": "QmYkygifkXnrnsN4MJsjBFHTQJHx294CyikDgDK8nYxdGh",
"digest": "df3f30442a6d6b4192f5071fb17e820c",
"sector_size": 2048
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.vk": {
"cid": "QmdXyqbmy2bkJA9Kyhh6z25GrTCq48LwX6c1mxPsm54wi7",
"digest": "0bea3951abf9557a3569f68e52a30c6c",
"sector_size": 2048
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.params": {
"cid": "Qmf5XZZtP5VcYTf65MbKjLVabcS6cYMbr2rFShmfJzh5e5",
"digest": "655e6277638edc8c658094f6f0b33d54",
"sector_size": 536870912
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.vk": {
"cid": "QmPuhdWnAXBks43emnkqi9FQzyU1gASKyz23zrD27BPGs8",
"digest": "57690e3a6a94c3f704802a674b34f36b",
"sector_size": 536870912
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.params": {
"cid": "QmPNVgTN7N5vDtD5u7ERMTLcvUtrKRBfYVUDr6uW3pKhX7",
"digest": "3d390654f58e603b896ac70c653f5676",
"sector_size": 2048
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.vk": {
"cid": "Qmbj61Zez7v5xA7nSCnmWbyLYznWJDWeusz7Yg8EcgVdoN",
"digest": "8c170a164743c39576a7f47a1b51e6f3",
"sector_size": 2048
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.params": {
"cid": "QmRApb8RZoBK3cqicT7V3ydXg8yVvqPFMPrQNXP33aBihp",
"digest": "b1b58ff9a297b82885e8a7dfb035f83c",
"sector_size": 8388608
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.vk": {
"cid": "QmcytF1dTdqMFoyXi931j1RgmGtLfR9LLLaBznRt1tPQyD",
"digest": "1a09e00c641f192f55af3433a028f050",
"sector_size": 8388608
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.params": {
"cid": "QmPvr54tWaVeP4WnekivzUAJitTqsQfvikBvAHNEaDNQSw",
"digest": "9380e41368ed4083dbc922b290d3b786",
"sector_size": 8388608
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk": {
"cid": "QmXyVLVDRCcxA9SjT7PeK8HFtyxZ2ZH3SHa8KoGLw8VGJt",
"digest": "f0731a7e20f90704bd38fc5d27882f6d",
"sector_size": 8388608
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.params": {
"cid": "Qmf5f6ko3dqj7qauzXpZqxM9B2x2sL977K6gE2ppNwuJPv",
"digest": "273ebb8c896326b7c292bee8b775fd38",
"sector_size": 536870912
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-0-0-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.vk": {
"cid": "QmfP3MQe8koW63n5MkDENENVHxib78MJYYyZvbneCsuze8",
"digest": "3dd94da9da64e51b3445bc528d84e76d",
"sector_size": 536870912
},
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.params": {
"cid": "QmYEeeCE8uT2bsVkxcqqUYeMmMEbe6rfmo8wQCv7jFHqqm",
"digest": "c947f2021304ed43b7216f7a8436e294",
"sector_size": 34359738368
},
"v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.vk": {
"cid": "QmbNGx7pNbGiEr8ykoHxVXHW2LNSmGdsxKtj1onZCyguCX",
"digest": "0227ae7df4f2affe529ebafbbc7540ee",
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.vk": {
"cid": "QmXB63ExriFjB4ywWnXTnFwCcLFfCeEP3h15qtL5i7F4aX",
"digest": "ab20d7b253e7e9a0d2ccdf7599ec8ec3",
"sector_size": 34359738368
},
"v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.params": {
"cid": "QmRGZsNp4mp1cZshcXqt3VMuWscAEsiMa2iepF4CsWWoiv",
"digest": "991041a354b12c280542741f58c7f2ca",
"sector_size": 1024
},
"v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.vk": {
"cid": "QmWpmrhCGVcfqLyqp5oGAnhPmCE5hGTPaauHi25mpQwRSU",
"digest": "91fac550e1f9bccab213830bb0c85bd6",
"sector_size": 1024
},
"v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.params": {
"cid": "QmenSZXh1EsSyHiSRvA6wb8yaPhYBTjrKehJw96Px5HnN4",
"digest": "6322eacd2773163ddd51f9ca7d645fc4",
"sector_size": 1073741824
},
"v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.vk": {
"cid": "QmPvZoMKofw6eDhDg5ESJA2QAZP8HvM6qMQk7fw4pq9bQf",
"digest": "0df62745fceac922e3e70847cfc70b52",
"sector_size": 1073741824
},
"v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.params": {
"cid": "QmVibFqzkZoL8cwQmzj8njPokCQGCCx4pBcUH77bzgJgV9",
"digest": "de9d71e672f286706a1673bd57abdaac",
"sector_size": 16777216
},
"v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.vk": {
"cid": "QmZa5FX27XyiEXQQLQpHqtMJKLzrcY8wMuj3pxzmSimSyu",
"digest": "7f796d3a0f13499181e44b5eee0cc744",
"sector_size": 16777216
},
"v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.params": {
"cid": "Qmbt2SWWAmMcYoY3DAiRDXA8fAuqdqRLWucJMSxYmzBCmN",
"digest": "151ae0ae183fc141e8c2bebc28e5cc10",
"sector_size": 268435456
},
"v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.vk": {
"cid": "QmUxvPu4xdVmjMFihUKoYyEdXBqxsXkvmxRweU7KouWHji",
"digest": "95eb89588e9d1832aca044c3a13178af",
"sector_size": 268435456
},
"v20-stacked-proof-of-replication-117839dacd1ef31e5968a6fd13bcd6fa86638d85c40c9241a1d07c2a954eb89b.params": {
"cid": "QmQZe8eLo2xXbhSDxtyYZNqEjqjdcWGdADywECRvNEZQdX",
"digest": "fcd50e2e08a8560a6bb3418e883567ed",
"sector_size": 268435456
},
"v20-stacked-proof-of-replication-117839dacd1ef31e5968a6fd13bcd6fa86638d85c40c9241a1d07c2a954eb89b.vk": {
"cid": "Qme1hn6QT1covfoUFGDZkqoE1pMTax9FNW3nWWmTNqFe7y",
"digest": "872e244d86499fd659082e3bcf3f13e7",
"sector_size": 268435456
},
"v20-stacked-proof-of-replication-b46f3a1051afbb67f70aae7082da95def62eee943662f3e1bf69837fb08aaae4.params": {
"cid": "QmSfrPDC9jwY4MKrjzhCqDBBAG44wSDM8oE5NuDwWSh2xN",
"digest": "0a338b941c5f17946340de5fc95cab30",
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.params": {
"cid": "QmW5Yxg3L1NSzuQVcRMHMbG3uvVoi4dTLzVaDpnEUPQpnA",
"digest": "079ba19645828ae42b22b0e3f4866e8d",
"sector_size": 34359738368
},
"v20-stacked-proof-of-replication-b46f3a1051afbb67f70aae7082da95def62eee943662f3e1bf69837fb08aaae4.vk": {
"cid": "QmTDGynCmnbaZNBP3Bv3F3duC3ecKRubCKeMUiQQZYbGpF",
"digest": "c752e070a6b7aa8b79aa661a6b600b55",
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-0-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.vk": {
"cid": "QmQzZ5dJ11tcSBees38WX41tZLXS9BqpEti253m5QcnTNs",
"digest": "c76125a50a7de315165de359b5174ae4",
"sector_size": 34359738368
},
"v20-stacked-proof-of-replication-e71093863cadc71de61f38311ee45816633973bbf34849316b147f8d2e66f199.params": {
"cid": "QmXjSSnMUnc7EjQBYtTHhvLU3kXJTbUyhVhJRSTRehh186",
"digest": "efa407fd09202dffd15799a8518e73d3",
"sector_size": 1024
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-2627e4006b67f99cef990c0a47d5426cb7ab0a0ad58fc1061547bf2d28b09def.params": {
"cid": "QmNk3wga1tS53FUu1QnkK8ehWA2cqpCnSEAPv3KLxdJxNa",
"digest": "421e4790c0b80e0107a7ff67acf14084",
"sector_size": 68719476736
},
"v20-stacked-proof-of-replication-e71093863cadc71de61f38311ee45816633973bbf34849316b147f8d2e66f199.vk": {
"cid": "QmYHW3zhQouDP4okFbXSsRMcZ8bokKGvzxqbv7ZrunPMiG",
"digest": "b2f09a0ccb62da28c890d5b881c8dcd2",
"sector_size": 1024
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-2627e4006b67f99cef990c0a47d5426cb7ab0a0ad58fc1061547bf2d28b09def.vk": {
"cid": "QmVQCHGsrUtbn9RjHs1e6GXfeXDW5m9w4ge48PSX3Z2as2",
"digest": "8b60e9cc1470a6729c687d6cf0a1f79c",
"sector_size": 68719476736
},
"v20-stacked-proof-of-replication-e99a585174b6a45b254ba4780d72c89ad808c305c6d11711009ade4f39dba8e9.params": {
"cid": "QmUhyfNeLb32LfSkjsUwTFYLXQGMj6JQ8daff4DdVMt79q",
"digest": "b53c1916a63839ec345aa2224e9198b7",
"sector_size": 1073741824
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-b62098629d07946e9028127e70295ed996fe3ed25b0f9f88eb610a0ab4385a3c.params": {
"cid": "QmTL3VvydaMFWKvE5VzxjgKsJYgL9JMM4JVYNtQxdj9JK1",
"digest": "2685f31124b22ea6b2857e5a5e87ffa3",
"sector_size": 68719476736
},
"v20-stacked-proof-of-replication-e99a585174b6a45b254ba4780d72c89ad808c305c6d11711009ade4f39dba8e9.vk": {
"cid": "QmWReGfbuoozNErbskmFvqV4q36BY6F2WWb4cVFc3zoYkA",
"digest": "20d58a3fae7343481f8298a2dd493dd7",
"sector_size": 1073741824
"v26-proof-of-spacetime-fallback-merkletree-poseidon_hasher-8-8-2-b62098629d07946e9028127e70295ed996fe3ed25b0f9f88eb610a0ab4385a3c.vk": {
"cid": "QmSVWbLqQYbUbbJyfsRMzEib2rfSqMtnPks1Nw22omcBQm",
"digest": "efe703cd2839597c7ca5c2a906b74296",
"sector_size": 68719476736
},
"v20-stacked-proof-of-replication-f571ee2386f4c65a68e802747f2d78691006fc81a67971c4d9641403fffece16.params": {
"cid": "QmSAHu14Pe8iav6BYCt9XkpHJ73XM7tcpY4d9JK9BST9HU",
"digest": "7698426202c7e07b26ef056d31485b3a",
"sector_size": 16777216
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.params": {
"cid": "QmU9dH31nZZUJnsogR4Ld4ySUcH6wm2RgmGiujwnqtbU6k",
"digest": "fcef8e87ae2afd7a28aae44347b804cf",
"sector_size": 2048
},
"v20-stacked-proof-of-replication-f571ee2386f4c65a68e802747f2d78691006fc81a67971c4d9641403fffece16.vk": {
"cid": "QmaKtFLShnhMGVn7P9UsHjkgqtqRFSwCStqqykBN7u8dax",
"digest": "834408e5c3fce6ec5d1bf64e64cee94e",
"sector_size": 16777216
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-032d3138d22506ec0082ed72b2dcba18df18477904e35bafee82b3793b06832f.vk": {
"cid": "QmdJ15DMGPooye5NaPcRfXUdHUDibcN7hKjbmTGuu1K4AQ",
"digest": "2ee2b3518229680db15161d4f582af37",
"sector_size": 2048
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-6babf46ce344ae495d558e7770a585b2382d54f225af8ed0397b8be7c3fcd472.params": {
"cid": "QmZgtxcY3tMXXQxZTA7ZTUDXLVUnfxNcerXgeW4gG2NnfP",
"digest": "3273c7135cb75684248b475781b738ee",
"sector_size": 536870912
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-6babf46ce344ae495d558e7770a585b2382d54f225af8ed0397b8be7c3fcd472.vk": {
"cid": "QmSS6ZkAV2aGZcgKgdPpEEgihXF1ryZX8PSAZDWSoeL1d4",
"digest": "1519b5f61d9044a59f2bdc57537c094b",
"sector_size": 536870912
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-ecd683648512ab1765faa2a5f14bab48f676e633467f0aa8aad4b55dcb0652bb.params": {
"cid": "QmQBGXeiNn6hVwbR6qFarQqiNGDdKk4h9ucfyvcXyfYz2N",
"digest": "7d5f896f435c38e93bcda6dd168d860b",
"sector_size": 8388608
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-0-0-sha256_hasher-ecd683648512ab1765faa2a5f14bab48f676e633467f0aa8aad4b55dcb0652bb.vk": {
"cid": "QmPrZgBVGMckEAeu5eSJnLmiAwcPQjKjZe5ir6VaQ5AxKs",
"digest": "fe6d2de44580a0db5a4934688899b92f",
"sector_size": 8388608
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.params": {
"cid": "QmZL2cq45XJn5BFzagAZwgFmLrcM1W6CXoiEF9C5j5tjEF",
"digest": "acdfed9f0512bc85a01a9fb871d475d5",
"sector_size": 34359738368
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-0-sha256_hasher-82a357d2f2ca81dc61bb45f4a762807aedee1b0a53fd6c4e77b46a01bfef7820.vk": {
"cid": "QmQ4zB7nNa1tDYNifBkExRnZtwtxZw775iaqvVsZyRi6Q2",
"digest": "524a2f3e9d6826593caebc41bb545c40",
"sector_size": 34359738368
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.params": {
"cid": "QmY7DitNKXFeLQt9QoVQkfjM1EvRnprqUVxjmkTXkHDNka",
"digest": "f27271c0537ba65ade2ec045f8fbd069",
"sector_size": 68719476736
},
"v26-stacked-proof-of-replication-merkletree-poseidon_hasher-8-8-2-sha256_hasher-96f1b4a04c5c51e4759bbf224bbc2ef5a42c7100f16ec0637123f16a845ddfb2.vk": {
"cid": "QmUJsvoCuQ4LszPmeRVAkMYb5qY95ctz3UXKhu8xLzyFKo",
"digest": "576b292938c6c9d0a0e721bd867a543b",
"sector_size": 68719476736
}
}
}
-95
View File
@@ -1,95 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
PARAMS='{{PARAMSJSON}}'
die() {
echo "$@" >&2
exit 1
}
have_binary() {
type "$1" > /dev/null 2> /dev/null
}
check_writable() {
printf "" > "$1" && rm "$1"
}
try_download() {
url="$1"
output="$2"
command="$3"
util_name="$(set -- $command; echo "$1")"
if ! have_binary "$util_name"; then
return 1
fi
printf '==> Using %s to download "%s" to "%s"\n' "$util_name" "$url" "$output"
if eval "$command"; then
echo "==> Download complete!"
return
else
echo "error: couldn't download with $util_name ($?)"
return 1
fi
}
download() {
dl_url="$1"
dl_output="$2"
test "$#" -eq "2" || die "download requires exactly two arguments, was given $@"
if ! check_writable "$dl_output"; then
die "download error: cannot write to $dl_output"
fi
try_download "$dl_url" "$dl_output" "wget '$dl_url' -O '$dl_output'" && return
try_download "$dl_url" "$dl_output" "curl --silent --fail --output '$dl_output' '$dl_url'" && return
try_download "$dl_url" "$dl_output" "fetch '$dl_url' -o '$dl_output'" && return
try_download "$dl_url" "$dl_output" "http '$dl_url' > '$dl_output'" && return
try_download "$dl_url" "$dl_output" "ftp -o '$dl_output' '$dl_url'" && return
die "Unable to download $dl_url. exiting."
}
fetch_ipget() {
local dest="$1"
local cid="$2"
IPGET_PARAMS="--node=spawn -p=/ip4/138.201.67.219/tcp/4002/ws/ipfs/QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA -p=/ip4/138.201.67.218/tcp/4002/ws/ipfs/QmbVWZQhCGrS7DhgLqWbgvdmKN7JueKCREVanfnVpgyq8x -p=/ip4/94.130.135.167/tcp/4002/ws/ipfs/QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE -p=/ip4/138.201.68.74/tcp/4001/ipfs/QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR -p=/ip4/138.201.67.220/tcp/4001/ipfs/QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i"
./bin/ipget $IPGET_PARAMS -o "$dest" "$cid"
}
fetch_gateway() {
local dest="$1"
local cid="$2"
local url="http://198.211.99.118/ipfs/$cid"
download "$url" "$dest"
}
OUT_DIR="/var/tmp/filecoin-proof-parameters"
mkdir -p $OUT_DIR
printf $PARAMS | base64 -d | jq '. | to_entries | map("'$OUT_DIR'/\(.key) \(.value.cid) \(.value.digest)") | .[]' --raw-output | \
while read -r dest cid digest; do
if [[ -f "$dest" ]]; then
b2=$(b2sum "$dest" | head -c 32)
if [[ "$digest" == "$b2" ]]; then
echo "$dest exists and has correct hash"
continue
else
echo "$dest has incorrect hash"
rm -f "$dest"
fi
fi
echo "downloading $dest"
fetch_gateway "$dest" "$cid"
done
+26 -3
View File
@@ -3,11 +3,33 @@ package build
import "fmt"
var CurrentCommit string
var BuildType int
const (
BuildDefault = 0
Build2k = 0x1
BuildDebug = 0x3
)
func buildType() string {
switch BuildType {
case BuildDefault:
return ""
case BuildDebug:
return "+debug"
case Build2k:
return "+2k"
default:
return "+huh?"
}
}
// BuildVersion is the local build version, set by build system
const BuildVersion = "0.1.5"
const BuildVersion = "0.4.0"
var UserVersion = BuildVersion + CurrentCommit
func UserVersion() string {
return BuildVersion + buildType() + CurrentCommit
}
type Version uint32
@@ -31,8 +53,9 @@ func (ve Version) EqMajorMinor(v2 Version) bool {
}
// APIVersion is a semver version of the rpc api exposed
var APIVersion Version = newVer(0, 1, 5)
var APIVersion Version = newVer(0, 3, 0)
//nolint:varcheck,deadcode
const (
majorMask = 0xff0000
minorMask = 0xffff00
-48
View File
@@ -1,48 +0,0 @@
package actors
import (
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
)
type CronActor struct{}
type callTuple struct {
addr address.Address
method uint64
}
var CronActors = []callTuple{
{StoragePowerAddress, SPAMethods.CheckProofSubmissions},
}
type CronActorState struct{}
type cAMethods struct {
EpochTick uint64
}
var CAMethods = cAMethods{2}
func (ca CronActor) Exports() []interface{} {
return []interface{}{
1: nil,
2: ca.EpochTick,
}
}
func (ca CronActor) EpochTick(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
if vmctx.Message().From != CronAddress {
return nil, aerrors.New(1, "EpochTick is only callable as a part of tipset state computation")
}
for _, call := range CronActors {
_, err := vmctx.Send(call.addr, call.method, types.NewInt(0), nil)
if err != nil {
return nil, err // todo: this very bad?
}
}
return nil, nil
}
-242
View File
@@ -1,242 +0,0 @@
package actors
import (
"bytes"
"context"
"encoding/binary"
"fmt"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
cbor "github.com/ipfs/go-ipld-cbor"
logging "github.com/ipfs/go-log"
mh "github.com/multiformats/go-multihash"
)
var log = logging.Logger("actors")
var EmptyCBOR cid.Cid
const (
GasCreateActor = 100
)
func init() {
n, err := cbor.WrapObject(map[string]string{}, mh.SHA2_256, -1)
if err != nil {
panic(err) // ok
}
EmptyCBOR = n.Cid()
}
type InitActor struct{}
type InitActorState struct {
AddressMap cid.Cid
NextID uint64
}
type iAMethods struct {
Exec uint64
}
var IAMethods = iAMethods{2}
func (ia InitActor) Exports() []interface{} {
return []interface{}{
1: nil,
2: ia.Exec,
}
}
type ExecParams struct {
Code cid.Cid
Params []byte
}
func CreateExecParams(act cid.Cid, obj cbg.CBORMarshaler) ([]byte, aerrors.ActorError) {
encparams, err := SerializeParams(obj)
if err != nil {
return nil, aerrors.Wrap(err, "creating ExecParams")
}
return SerializeParams(&ExecParams{
Code: act,
Params: encparams,
})
}
func (ia InitActor) Exec(act *types.Actor, vmctx types.VMContext, p *ExecParams) ([]byte, aerrors.ActorError) {
beginState := vmctx.Storage().GetHead()
var self InitActorState
if err := vmctx.Storage().Get(beginState, &self); err != nil {
return nil, err
}
if err := vmctx.ChargeGas(GasCreateActor); err != nil {
return nil, aerrors.Wrap(err, "run out of gas")
}
// Make sure that only the actors defined in the spec can be launched.
if !IsBuiltinActor(p.Code) {
return nil, aerrors.New(1,
"cannot launch actor instance that is not a builtin actor")
}
// Ensure that singletons can be only launched once.
// TODO: do we want to enforce this? If so how should actors be marked as such?
if IsSingletonActor(p.Code) {
return nil, aerrors.New(1, "cannot launch another actor of this type")
}
// This generates a unique address for this actor that is stable across message
// reordering
creator := vmctx.Message().From
nonce := vmctx.Message().Nonce
addr, err := ComputeActorAddress(creator, nonce)
if err != nil {
return nil, err
}
// Set up the actor itself
actor := types.Actor{
Code: p.Code,
Balance: types.NewInt(0),
Head: EmptyCBOR,
Nonce: 0,
}
// The call to the actors constructor will set up the initial state
// from the given parameters, setting `actor.Head` to a new value when successful.
// TODO: can constructors fail?
//actor.Constructor(p.Params)
// Store the mapping of address to actor ID.
idAddr, nerr := self.AddActor(vmctx.Ipld(), addr)
if nerr != nil {
return nil, aerrors.Escalate(err, "adding new actor mapping")
}
// NOTE: This is a privileged call that only the init actor is allowed to make
// FIXME: Had to comment this because state is not in interface
state, err := vmctx.StateTree()
if err != nil {
return nil, err
}
if err := state.SetActor(idAddr, &actor); err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
return nil, aerrors.Absorb(err, 1, "SetActor, actor not found")
}
return nil, aerrors.Escalate(err, "inserting new actor into state tree")
}
// '1' is reserved for constructor methods
_, err = vmctx.Send(idAddr, 1, vmctx.Message().Value, p.Params)
if err != nil {
return nil, err
}
c, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(beginState, c); err != nil {
return nil, err
}
return idAddr.Bytes(), nil
}
func IsBuiltinActor(code cid.Cid) bool {
switch code {
case StorageMarketCodeCid, StoragePowerCodeCid, StorageMinerCodeCid, AccountCodeCid, InitCodeCid, MultisigCodeCid, PaymentChannelCodeCid:
return true
default:
return false
}
}
func IsSingletonActor(code cid.Cid) bool {
return code == StoragePowerCodeCid || code == StorageMarketCodeCid || code == InitCodeCid || code == CronCodeCid
}
func (ias *InitActorState) AddActor(cst *hamt.CborIpldStore, addr address.Address) (address.Address, error) {
nid := ias.NextID
amap, err := hamt.LoadNode(context.TODO(), cst, ias.AddressMap)
if err != nil {
return address.Undef, err
}
if err := amap.Set(context.TODO(), string(addr.Bytes()), nid); err != nil {
return address.Undef, err
}
if err := amap.Flush(context.TODO()); err != nil {
return address.Undef, err
}
ncid, err := cst.Put(context.TODO(), amap)
if err != nil {
return address.Undef, err
}
ias.AddressMap = ncid
ias.NextID++
return NewIDAddress(nid)
}
func (ias *InitActorState) Lookup(cst *hamt.CborIpldStore, addr address.Address) (address.Address, error) {
amap, err := hamt.LoadNode(context.TODO(), cst, ias.AddressMap)
if err != nil {
return address.Undef, xerrors.Errorf("ias lookup failed loading hamt node: %w", err)
}
var val interface{}
err = amap.Find(context.TODO(), string(addr.Bytes()), &val)
if err != nil {
return address.Undef, xerrors.Errorf("ias lookup failed to do find: %w", err)
}
ival, ok := val.(uint64)
if !ok {
return address.Undef, fmt.Errorf("invalid value in init actor state, expected uint64, got %T", val)
}
return address.NewIDAddress(ival)
}
type AccountActorState struct {
Address address.Address
}
func ComputeActorAddress(creator address.Address, nonce uint64) (address.Address, ActorError) {
buf := new(bytes.Buffer)
_, err := buf.Write(creator.Bytes())
if err != nil {
return address.Undef, aerrors.Escalate(err, "could not write address")
}
err = binary.Write(buf, binary.BigEndian, nonce)
if err != nil {
return address.Undef, aerrors.Escalate(err, "could not write nonce")
}
addr, err := address.NewActorAddress(buf.Bytes())
if err != nil {
return address.Undef, aerrors.Escalate(err, "could not create address")
}
return addr, nil
}
File diff suppressed because it is too large Load Diff
-157
View File
@@ -1,157 +0,0 @@
package actors_test
import (
"bytes"
"context"
"math/rand"
"testing"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
hamt "github.com/ipfs/go-hamt-ipld"
blockstore "github.com/ipfs/go-ipfs-blockstore"
cbg "github.com/whyrusleeping/cbor-gen"
)
func TestMinerCommitSectors(t *testing.T) {
var worker, client address.Address
var minerAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&worker, 1000000),
HarnessAddr(&client, 1000000),
HarnessActor(&minerAddr, &worker, actors.StorageMinerCodeCid,
func() cbg.CBORMarshaler {
return &actors.StorageMinerConstructorParams{
Owner: worker,
Worker: worker,
SectorSize: 1024,
PeerID: "fakepeerid",
}
}),
}
h := NewHarness(t, opts...)
h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, aerrors.ActorError) {
// all proofs are valid
return true, nil
}
ret, _ := h.SendFunds(t, worker, minerAddr, types.NewInt(100000))
ApplyOK(t, ret)
ret, _ = h.InvokeWithValue(t, client, actors.StorageMarketAddress, actors.SMAMethods.AddBalance, types.NewInt(2000), nil)
ApplyOK(t, ret)
addSectorToMiner(h, t, minerAddr, worker, client, 1)
assertSectorIDs(h, t, minerAddr, []uint64{1})
}
func addSectorToMiner(h *Harness, t *testing.T, minerAddr, worker, client address.Address, sid uint64) {
t.Helper()
s := sectorbuilder.UserBytesForSectorSize(1024)
deal := h.makeFakeDeal(t, minerAddr, worker, client, s)
ret, _ := h.Invoke(t, worker, actors.StorageMarketAddress, actors.SMAMethods.PublishStorageDeals,
&actors.PublishStorageDealsParams{
Deals: []actors.StorageDealProposal{*deal},
})
ApplyOK(t, ret)
var dealIds actors.PublishStorageDealResponse
if err := dealIds.UnmarshalCBOR(bytes.NewReader(ret.Return)); err != nil {
t.Fatal(err)
}
dealid := dealIds.DealIDs[0]
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.PreCommitSector,
&actors.SectorPreCommitInfo{
SectorNumber: sid,
CommR: []byte("cats"),
SealEpoch: 10,
DealIDs: []uint64{dealid},
})
ApplyOK(t, ret)
h.BlockHeight += 100
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.ProveCommitSector,
&actors.SectorProveCommitInfo{
Proof: []byte("prooofy"),
SectorID: sid,
DealIDs: []uint64{dealid}, // TODO: weird that i have to pass this again
})
ApplyOK(t, ret)
}
func assertSectorIDs(h *Harness, t *testing.T, maddr address.Address, ids []uint64) {
t.Helper()
sectors, err := getMinerSectorSet(context.TODO(), h.vm.StateTree(), h.bs, maddr)
if err != nil {
t.Fatal(err)
}
if len(sectors) != len(ids) {
t.Fatal("miner has wrong number of sectors in their sector set")
}
all := make(map[uint64]bool)
for _, s := range sectors {
all[s.SectorID] = true
}
for _, id := range ids {
if !all[id] {
t.Fatal("expected to find sector ID: ", id)
}
}
}
func getMinerSectorSet(ctx context.Context, st types.StateTree, bs blockstore.Blockstore, maddr address.Address) ([]*api.ChainSectorInfo, error) {
mact, err := st.GetActor(maddr)
if err != nil {
return nil, err
}
cst := hamt.CSTFromBstore(bs)
var mstate actors.StorageMinerActorState
if err := cst.Get(ctx, mact.Head, &mstate); err != nil {
return nil, err
}
return stmgr.LoadSectorsFromSet(ctx, bs, mstate.Sectors)
}
func (h *Harness) makeFakeDeal(t *testing.T, miner, worker, client address.Address, size uint64) *actors.StorageDealProposal {
data := make([]byte, size)
rand.Read(data)
commP, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(data), size)
if err != nil {
t.Fatal(err)
}
prop := actors.StorageDealProposal{
PieceRef: commP[:],
PieceSize: size,
//PieceSerialization SerializationMode // Needs to be here as it tells how data in the sector maps to PieceRef cid
Client: client,
Provider: miner,
ProposalExpiration: 10000,
Duration: 150,
StoragePricePerEpoch: types.NewInt(1),
StorageCollateral: types.NewInt(0),
}
if err := api.SignWith(context.TODO(), h.w.Sign, client, &prop); err != nil {
t.Fatal(err)
}
return &prop
}
-431
View File
@@ -1,431 +0,0 @@
package actors
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
cbg "github.com/whyrusleeping/cbor-gen"
)
type MultiSigActor struct{}
type MultiSigActorState struct {
Signers []address.Address
Required uint64
NextTxID uint64
InitialBalance types.BigInt
StartingBlock uint64
UnlockDuration uint64
//TODO: make this map/sharray/whatever
Transactions []MTransaction
}
func (msas MultiSigActorState) canSpend(act *types.Actor, amnt types.BigInt, height uint64) bool {
if msas.UnlockDuration == 0 {
return true
}
offset := height - msas.StartingBlock
if offset > msas.UnlockDuration {
return true
}
minBalance := types.BigDiv(msas.InitialBalance, types.NewInt(msas.UnlockDuration))
minBalance = types.BigMul(minBalance, types.NewInt(offset))
return !minBalance.LessThan(types.BigSub(act.Balance, amnt))
}
func (msas MultiSigActorState) isSigner(addr address.Address) bool {
for _, s := range msas.Signers {
if s == addr {
return true
}
}
return false
}
func (msas MultiSigActorState) getTransaction(txid uint64) (*MTransaction, ActorError) {
if txid >= uint64(len(msas.Transactions)) {
return nil, aerrors.Newf(1, "could not get transaction (numbers of tx %d,want to get txid %d)", len(msas.Transactions), txid)
}
return &msas.Transactions[txid], nil
}
type MTransaction struct {
Created uint64 // NOT USED ??
TxID uint64
To address.Address
Value types.BigInt
Method uint64
Params []byte
Approved []address.Address
Complete bool
Canceled bool
RetCode uint64
}
func (tx MTransaction) Active() ActorError {
if tx.Complete {
return aerrors.New(2, "transaction already completed")
}
if tx.Canceled {
return aerrors.New(3, "transaction canceled")
}
return nil
}
type musigMethods struct {
MultiSigConstructor uint64
Propose uint64
Approve uint64
Cancel uint64
ClearCompleted uint64
AddSigner uint64
RemoveSigner uint64
SwapSigner uint64
ChangeRequirement uint64
}
var MultiSigMethods = musigMethods{1, 2, 3, 4, 5, 6, 7, 8, 9}
func (msa MultiSigActor) Exports() []interface{} {
return []interface{}{
1: msa.MultiSigConstructor,
2: msa.Propose,
3: msa.Approve,
4: msa.Cancel,
//5: msa.ClearCompleted,
6: msa.AddSigner,
7: msa.RemoveSigner,
8: msa.SwapSigner,
9: msa.ChangeRequirement,
}
}
type MultiSigConstructorParams struct {
Signers []address.Address
Required uint64
UnlockDuration uint64
}
func (MultiSigActor) MultiSigConstructor(act *types.Actor, vmctx types.VMContext,
params *MultiSigConstructorParams) ([]byte, ActorError) {
self := &MultiSigActorState{
Signers: params.Signers,
Required: params.Required,
}
if params.UnlockDuration != 0 {
self.InitialBalance = vmctx.Message().Value
self.UnlockDuration = params.UnlockDuration
self.StartingBlock = vmctx.BlockHeight()
}
head, err := vmctx.Storage().Put(self)
if err != nil {
return nil, aerrors.Wrap(err, "could not put new head")
}
err = vmctx.Storage().Commit(EmptyCBOR, head)
if err != nil {
return nil, aerrors.Wrap(err, "could not commit new head")
}
return nil, nil
}
type MultiSigProposeParams struct {
To address.Address
Value types.BigInt
Method uint64
Params []byte
}
func (MultiSigActor) load(vmctx types.VMContext) (cid.Cid, *MultiSigActorState, ActorError) {
var self MultiSigActorState
head := vmctx.Storage().GetHead()
err := vmctx.Storage().Get(head, &self)
if err != nil {
return cid.Undef, nil, aerrors.Wrap(err, "could not get self")
}
return head, &self, nil
}
func (msa MultiSigActor) loadAndVerify(vmctx types.VMContext) (cid.Cid, *MultiSigActorState, ActorError) {
head, self, err := msa.load(vmctx)
if err != nil {
return cid.Undef, nil, err
}
if !self.isSigner(vmctx.Message().From) {
return cid.Undef, nil, aerrors.New(1, "not authorized")
}
return head, self, nil
}
func (MultiSigActor) save(vmctx types.VMContext, oldHead cid.Cid, self *MultiSigActorState) ActorError {
newHead, err := vmctx.Storage().Put(self)
if err != nil {
return aerrors.Wrap(err, "could not put new head")
}
err = vmctx.Storage().Commit(oldHead, newHead)
if err != nil {
return aerrors.Wrap(err, "could not commit new head")
}
return nil
}
func (msa MultiSigActor) Propose(act *types.Actor, vmctx types.VMContext,
params *MultiSigProposeParams) ([]byte, ActorError) {
head, self, err := msa.loadAndVerify(vmctx)
if err != nil {
return nil, err
}
txid := self.NextTxID
self.NextTxID++
{
tx := MTransaction{
TxID: txid,
To: params.To,
Value: params.Value,
Method: params.Method,
Params: params.Params,
Approved: []address.Address{vmctx.Message().From},
}
self.Transactions = append(self.Transactions, tx)
}
tx, err := self.getTransaction(txid)
if err != nil {
return nil, err
}
if self.Required == 1 {
if !self.canSpend(act, tx.Value, vmctx.BlockHeight()) {
return nil, aerrors.New(100, "transaction amount exceeds available")
}
_, err := vmctx.Send(tx.To, tx.Method, tx.Value, tx.Params)
if aerrors.IsFatal(err) {
return nil, err
}
tx.RetCode = uint64(aerrors.RetCode(err))
tx.Complete = true
}
err = msa.save(vmctx, head, self)
if err != nil {
return nil, aerrors.Wrap(err, "saving state")
}
// REVIEW: On one hand, I like being very explicit about how we're doing the serialization
// on the other, maybe we shouldnt do direct calls to underlying serialization libs?
return cbg.CborEncodeMajorType(cbg.MajUnsignedInt, tx.TxID), nil
}
type MultiSigTxID struct {
TxID uint64
}
func (msa MultiSigActor) Approve(act *types.Actor, vmctx types.VMContext,
params *MultiSigTxID) ([]byte, ActorError) {
head, self, err := msa.loadAndVerify(vmctx)
if err != nil {
return nil, err
}
tx, err := self.getTransaction(params.TxID)
if err != nil {
return nil, err
}
if err := tx.Active(); err != nil {
return nil, aerrors.Wrap(err, "could not approve")
}
for _, signer := range tx.Approved {
if signer == vmctx.Message().From {
return nil, aerrors.New(4, "already signed this message")
}
}
tx.Approved = append(tx.Approved, vmctx.Message().From)
if uint64(len(tx.Approved)) >= self.Required {
if !self.canSpend(act, tx.Value, vmctx.BlockHeight()) {
return nil, aerrors.New(100, "transaction amount exceeds available")
}
_, err := vmctx.Send(tx.To, tx.Method, tx.Value, tx.Params)
if aerrors.IsFatal(err) {
return nil, err
}
tx.RetCode = uint64(aerrors.RetCode(err))
tx.Complete = true
}
return nil, msa.save(vmctx, head, self)
}
func (msa MultiSigActor) Cancel(act *types.Actor, vmctx types.VMContext,
params *MultiSigTxID) ([]byte, ActorError) {
head, self, err := msa.loadAndVerify(vmctx)
if err != nil {
return nil, err
}
tx, err := self.getTransaction(params.TxID)
if err != nil {
return nil, err
}
if err := tx.Active(); err != nil {
return nil, aerrors.Wrap(err, "could not cancel")
}
proposer := tx.Approved[0]
if proposer != vmctx.Message().From && self.isSigner(proposer) {
return nil, aerrors.New(4, "cannot cancel another signers transaction")
}
tx.Canceled = true
return nil, msa.save(vmctx, head, self)
}
type MultiSigAddSignerParam struct {
Signer address.Address
Increase bool
}
func (msa MultiSigActor) AddSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigAddSignerParam) ([]byte, ActorError) {
head, self, err := msa.load(vmctx)
if err != nil {
return nil, err
}
msg := vmctx.Message()
if msg.From != msg.To {
return nil, aerrors.New(4, "add signer must be called by wallet itself")
}
if self.isSigner(params.Signer) {
return nil, aerrors.New(5, "new address is already a signer")
}
self.Signers = append(self.Signers, params.Signer)
if params.Increase {
self.Required = self.Required + 1
}
return nil, msa.save(vmctx, head, self)
}
type MultiSigRemoveSignerParam struct {
Signer address.Address
Decrease bool
}
func (msa MultiSigActor) RemoveSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigRemoveSignerParam) ([]byte, ActorError) {
head, self, err := msa.load(vmctx)
if err != nil {
return nil, err
}
msg := vmctx.Message()
if msg.From != msg.To {
return nil, aerrors.New(4, "remove signer must be called by wallet itself")
}
if !self.isSigner(params.Signer) {
return nil, aerrors.New(5, "given address was not a signer")
}
newSigners := make([]address.Address, 0, len(self.Signers)-1)
for _, s := range self.Signers {
if s != params.Signer {
newSigners = append(newSigners, s)
}
}
if params.Decrease || uint64(len(self.Signers)-1) < self.Required {
self.Required = self.Required - 1
}
self.Signers = newSigners
return nil, msa.save(vmctx, head, self)
}
type MultiSigSwapSignerParams struct {
From address.Address
To address.Address
}
func (msa MultiSigActor) SwapSigner(act *types.Actor, vmctx types.VMContext,
params *MultiSigSwapSignerParams) ([]byte, ActorError) {
head, self, err := msa.load(vmctx)
if err != nil {
return nil, err
}
msg := vmctx.Message()
if msg.From != msg.To {
return nil, aerrors.New(4, "swap signer must be called by wallet itself")
}
if !self.isSigner(params.From) {
return nil, aerrors.New(5, "given old address was not a signer")
}
if self.isSigner(params.To) {
return nil, aerrors.New(6, "given new address was already a signer")
}
newSigners := make([]address.Address, 0, len(self.Signers))
for _, s := range self.Signers {
if s != params.From {
newSigners = append(newSigners, s)
}
}
newSigners = append(newSigners, params.To)
self.Signers = newSigners
return nil, msa.save(vmctx, head, self)
}
type MultiSigChangeReqParams struct {
Req uint64
}
func (msa MultiSigActor) ChangeRequirement(act *types.Actor, vmctx types.VMContext,
params *MultiSigChangeReqParams) ([]byte, ActorError) {
head, self, err := msa.load(vmctx)
if err != nil {
return nil, err
}
msg := vmctx.Message()
if msg.From != msg.To {
return nil, aerrors.New(4, "change requirement must be called by wallet itself")
}
if params.Req < 1 {
return nil, aerrors.New(5, "requirement must be at least 1")
}
if params.Req > uint64(len(self.Signers)) {
return nil, aerrors.New(6, "requirement must be at most the numbers of signers")
}
self.Required = params.Req
return nil, msa.save(vmctx, head, self)
}
-97
View File
@@ -1,97 +0,0 @@
package actors_test
import (
"testing"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/stretchr/testify/assert"
cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
)
func TestMultiSigCreate(t *testing.T) {
var creatorAddr, sig1Addr, sig2Addr, outsideAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&creatorAddr, 100000),
HarnessAddr(&sig1Addr, 100000),
HarnessAddr(&sig2Addr, 100000),
HarnessAddr(&outsideAddr, 100000),
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.MultisigCodeCid,
&actors.MultiSigConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},
Required: 2,
})
ApplyOK(t, ret)
}
func ApplyOK(t testing.TB, ret *vm.ApplyRet) {
t.Helper()
if ret.ExitCode != 0 {
t.Fatalf("exit code should be 0, got %d, actorErr: %+v", ret.ExitCode, ret.ActorErr)
}
if ret.ActorErr != nil {
t.Fatalf("somehow got an error with exit == 0: %s", ret.ActorErr)
}
}
func TestMultiSigOps(t *testing.T) {
var creatorAddr, sig1Addr, sig2Addr, outsideAddr address.Address
var multSigAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&creatorAddr, 100000),
HarnessAddr(&sig1Addr, 100000),
HarnessAddr(&sig2Addr, 100000),
HarnessAddr(&outsideAddr, 100000),
HarnessActor(&multSigAddr, &creatorAddr, actors.MultisigCodeCid,
func() cbg.CBORMarshaler {
return &actors.MultiSigConstructorParams{
Signers: []address.Address{creatorAddr, sig1Addr, sig2Addr},
Required: 2,
}
}),
}
h := NewHarness(t, opts...)
{
const chargeVal = 2000
// Send funds into the multisig
ret, _ := h.SendFunds(t, creatorAddr, multSigAddr, types.NewInt(chargeVal))
ApplyOK(t, ret)
h.AssertBalanceChange(t, creatorAddr, -chargeVal)
h.AssertBalanceChange(t, multSigAddr, chargeVal)
}
{
// Transfer funds outside of multsig
const sendVal = 1000
ret, _ := h.Invoke(t, creatorAddr, multSigAddr, actors.MultiSigMethods.Propose,
&actors.MultiSigProposeParams{
To: outsideAddr,
Value: types.NewInt(sendVal),
})
ApplyOK(t, ret)
var txIDParam actors.MultiSigTxID
err := cbor.DecodeInto(ret.Return, &txIDParam.TxID)
assert.NoError(t, err, "decoding txid")
ret, _ = h.Invoke(t, outsideAddr, multSigAddr, actors.MultiSigMethods.Approve,
&txIDParam)
assert.Equal(t, uint8(1), ret.ExitCode, "outsideAddr should not approve")
h.AssertBalanceChange(t, multSigAddr, 0)
ret2, _ := h.Invoke(t, sig1Addr, multSigAddr, actors.MultiSigMethods.Approve,
&txIDParam)
ApplyOK(t, ret2)
h.AssertBalanceChange(t, outsideAddr, sendVal)
h.AssertBalanceChange(t, multSigAddr, -sendVal)
}
}
-302
View File
@@ -1,302 +0,0 @@
package actors
import (
"bytes"
"fmt"
"github.com/ipfs/go-cid"
"github.com/minio/blake2b-simd"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
)
type PaymentChannelActor struct{}
type PaymentInfo struct {
PayChActor address.Address
Payer address.Address
ChannelMessage *cid.Cid
Vouchers []*types.SignedVoucher
}
type LaneState struct {
Closed bool
Redeemed types.BigInt
Nonce uint64
}
type PaymentChannelActorState struct {
From address.Address
To address.Address
ToSend types.BigInt
ClosingAt uint64
MinCloseHeight uint64
// TODO: needs to be map[uint64]*laneState
// waiting on refmt#35 to be fixed
LaneStates map[string]*LaneState
}
func (pca PaymentChannelActor) Exports() []interface{} {
return []interface{}{
1: pca.Constructor,
2: pca.UpdateChannelState,
3: pca.Close,
4: pca.Collect,
5: pca.GetOwner,
6: pca.GetToSend,
}
}
type pcaMethods struct {
Constructor uint64
UpdateChannelState uint64
Close uint64
Collect uint64
GetOwner uint64
GetToSend uint64
}
var PCAMethods = pcaMethods{1, 2, 3, 4, 5, 6}
type PCAConstructorParams struct {
To address.Address
}
func (pca PaymentChannelActor) Constructor(act *types.Actor, vmctx types.VMContext, params *PCAConstructorParams) ([]byte, ActorError) {
var self PaymentChannelActorState
self.From = vmctx.Origin()
self.To = params.To
self.LaneStates = make(map[string]*LaneState)
storage := vmctx.Storage()
c, err := storage.Put(&self)
if err != nil {
return nil, err
}
if err := storage.Commit(EmptyCBOR, c); err != nil {
return nil, err
}
return nil, nil
}
type PCAUpdateChannelStateParams struct {
Sv types.SignedVoucher
Secret []byte
Proof []byte
}
func hash(b []byte) []byte {
s := blake2b.Sum256(b)
return s[:]
}
type PaymentVerifyParams struct {
Extra []byte
Proof []byte
}
func (pca PaymentChannelActor) UpdateChannelState(act *types.Actor, vmctx types.VMContext, params *PCAUpdateChannelStateParams) ([]byte, ActorError) {
var self PaymentChannelActorState
oldstate := vmctx.Storage().GetHead()
storage := vmctx.Storage()
if err := storage.Get(oldstate, &self); err != nil {
return nil, err
}
sv := params.Sv
vb, nerr := sv.SigningBytes()
if nerr != nil {
return nil, aerrors.Escalate(nerr, "failed to serialize signedvoucher")
}
if err := vmctx.VerifySignature(sv.Signature, self.From, vb); err != nil {
return nil, err
}
if vmctx.BlockHeight() < sv.TimeLock {
return nil, aerrors.New(2, "cannot use this voucher yet!")
}
if len(sv.SecretPreimage) > 0 {
if !bytes.Equal(hash(params.Secret), sv.SecretPreimage) {
return nil, aerrors.New(3, "incorrect secret!")
}
}
if sv.Extra != nil {
encoded, err := SerializeParams(&PaymentVerifyParams{sv.Extra.Data, params.Proof})
if err != nil {
return nil, err
}
_, err = vmctx.Send(sv.Extra.Actor, sv.Extra.Method, types.NewInt(0), encoded)
if err != nil {
return nil, aerrors.Newf(4, "spend voucher verification failed: %s", err)
}
}
ls, ok := self.LaneStates[fmt.Sprint(sv.Lane)]
if !ok {
ls = new(LaneState)
ls.Redeemed = types.NewInt(0) // TODO: kinda annoying that this doesnt default to a usable value
self.LaneStates[fmt.Sprint(sv.Lane)] = ls
}
if ls.Closed {
return nil, aerrors.New(5, "cannot redeem a voucher on a closed lane")
}
if ls.Nonce > sv.Nonce {
return nil, aerrors.New(6, "voucher has an outdated nonce, cannot redeem")
}
mergeValue := types.NewInt(0)
for _, merge := range sv.Merges {
if merge.Lane == sv.Lane {
return nil, aerrors.New(7, "voucher cannot merge its own lane")
}
ols := self.LaneStates[fmt.Sprint(merge.Lane)]
if ols.Nonce >= merge.Nonce {
return nil, aerrors.New(8, "merge in voucher has outdated nonce, cannot redeem")
}
mergeValue = types.BigAdd(mergeValue, ols.Redeemed)
ols.Nonce = merge.Nonce
}
ls.Nonce = sv.Nonce
balanceDelta := types.BigSub(sv.Amount, types.BigAdd(mergeValue, ls.Redeemed))
ls.Redeemed = sv.Amount
newSendBalance := types.BigAdd(self.ToSend, balanceDelta)
if newSendBalance.LessThan(types.NewInt(0)) {
// TODO: is this impossible?
return nil, aerrors.New(9, "voucher would leave channel balance negative")
}
if newSendBalance.GreaterThan(act.Balance) {
return nil, aerrors.New(10, "not enough funds in channel to cover voucher")
}
log.Info("vals: ", newSendBalance, sv.Amount, balanceDelta, mergeValue, ls.Redeemed)
self.ToSend = newSendBalance
if sv.MinCloseHeight != 0 {
if self.ClosingAt != 0 && self.ClosingAt < sv.MinCloseHeight {
self.ClosingAt = sv.MinCloseHeight
}
if self.MinCloseHeight < sv.MinCloseHeight {
self.MinCloseHeight = sv.MinCloseHeight
}
}
ncid, err := storage.Put(&self)
if err != nil {
return nil, err
}
if err := storage.Commit(oldstate, ncid); err != nil {
return nil, err
}
return nil, nil
}
func (pca PaymentChannelActor) Close(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
var self PaymentChannelActorState
storage := vmctx.Storage()
oldstate := storage.GetHead()
if err := storage.Get(oldstate, &self); err != nil {
return nil, err
}
if vmctx.Message().From != self.From && vmctx.Message().From != self.To {
return nil, aerrors.New(1, "not authorized to close channel")
}
if self.ClosingAt != 0 {
return nil, aerrors.New(2, "channel already closing")
}
self.ClosingAt = vmctx.BlockHeight() + build.PaymentChannelClosingDelay
if self.ClosingAt < self.MinCloseHeight {
self.ClosingAt = self.MinCloseHeight
}
ncid, err := storage.Put(&self)
if err != nil {
return nil, err
}
if err := storage.Commit(oldstate, ncid); err != nil {
return nil, err
}
return nil, nil
}
func (pca PaymentChannelActor) Collect(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
var self PaymentChannelActorState
storage := vmctx.Storage()
oldstate := storage.GetHead()
if err := storage.Get(oldstate, &self); err != nil {
return nil, err
}
if self.ClosingAt == 0 {
return nil, aerrors.New(1, "payment channel not closing or closed")
}
if vmctx.BlockHeight() < self.ClosingAt {
return nil, aerrors.New(2, "payment channel not closed yet")
}
_, err := vmctx.Send(self.From, 0, types.BigSub(act.Balance, self.ToSend), nil)
if err != nil {
return nil, err
}
_, err = vmctx.Send(self.To, 0, self.ToSend, nil)
if err != nil {
return nil, err
}
self.ToSend = types.NewInt(0)
ncid, err := storage.Put(&self)
if err != nil {
return nil, err
}
if err := storage.Commit(oldstate, ncid); err != nil {
return nil, err
}
return nil, nil
}
func (pca PaymentChannelActor) GetOwner(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
var self PaymentChannelActorState
storage := vmctx.Storage()
if err := storage.Get(storage.GetHead(), &self); err != nil {
return nil, err
}
return self.From.Bytes(), nil
}
func (pca PaymentChannelActor) GetToSend(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, aerrors.ActorError) {
var self PaymentChannelActorState
storage := vmctx.Storage()
if err := storage.Get(storage.GetHead(), &self); err != nil {
return nil, err
}
return self.ToSend.Bytes(), nil
}
-93
View File
@@ -1,93 +0,0 @@
package actors_test
import (
"context"
"testing"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
)
func TestPaychCreate(t *testing.T) {
var creatorAddr, targetAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&creatorAddr, 100000),
HarnessAddr(&targetAddr, 100000),
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.PaymentChannelCodeCid,
&actors.PCAConstructorParams{
To: targetAddr,
})
ApplyOK(t, ret)
}
func signVoucher(t *testing.T, w *wallet.Wallet, addr address.Address, sv *types.SignedVoucher) {
vb, err := sv.SigningBytes()
if err != nil {
t.Fatal(err)
}
sig, err := w.Sign(context.TODO(), addr, vb)
if err != nil {
t.Fatal(err)
}
sv.Signature = sig
}
func TestPaychUpdate(t *testing.T) {
var creatorAddr, targetAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&creatorAddr, 100000),
HarnessAddr(&targetAddr, 100000),
}
h := NewHarness(t, opts...)
ret, _ := h.CreateActor(t, creatorAddr, actors.PaymentChannelCodeCid,
&actors.PCAConstructorParams{
To: targetAddr,
})
ApplyOK(t, ret)
pch, err := address.NewFromBytes(ret.Return)
if err != nil {
t.Fatal(err)
}
ret, _ = h.SendFunds(t, creatorAddr, pch, types.NewInt(5000))
ApplyOK(t, ret)
sv := &types.SignedVoucher{
Amount: types.NewInt(100),
Nonce: 1,
}
signVoucher(t, h.w, creatorAddr, sv)
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.UpdateChannelState, &actors.PCAUpdateChannelStateParams{
Sv: *sv,
})
ApplyOK(t, ret)
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.GetToSend, nil)
ApplyOK(t, ret)
bi := types.BigFromBytes(ret.Return)
if bi.String() != "100" {
t.Fatal("toSend amount was wrong: ", bi.String())
}
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.Close, nil)
ApplyOK(t, ret)
// now we have to 'wait' for the chain to advance.
h.BlockHeight = 1000
ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.Collect, nil)
ApplyOK(t, ret)
h.AssertBalanceChange(t, targetAddr, 100)
h.AssertBalanceChange(t, creatorAddr, -100)
}
-670
View File
@@ -1,670 +0,0 @@
package actors
import (
"bytes"
"context"
"sort"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-amt-ipld"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
)
type StorageMarketActor struct{}
type smaMethods struct {
Constructor uint64
WithdrawBalance uint64
AddBalance uint64
CheckLockedBalance uint64
PublishStorageDeals uint64
HandleCronAction uint64
SettleExpiredDeals uint64
ProcessStorageDealsPayment uint64
SlashStorageDealCollateral uint64
GetLastExpirationFromDealIDs uint64
ActivateStorageDeals uint64
ComputeDataCommitment uint64
}
var SMAMethods = smaMethods{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
func (sma StorageMarketActor) Exports() []interface{} {
return []interface{}{
2: sma.WithdrawBalance,
3: sma.AddBalance,
// 4: sma.CheckLockedBalance,
5: sma.PublishStorageDeals,
// 6: sma.HandleCronAction,
// 7: sma.SettleExpiredDeals,
// 8: sma.ProcessStorageDealsPayment,
// 9: sma.SlashStorageDealCollateral,
// 10: sma.GetLastExpirationFromDealIDs,
11: sma.ActivateStorageDeals, // TODO: move under PublishStorageDeals after specs team approves
12: sma.ComputeDataCommitment,
}
}
type StorageParticipantBalance struct {
Locked types.BigInt
Available types.BigInt
}
type StorageMarketState struct {
Balances cid.Cid // hamt<addr, StorageParticipantBalance>
Deals cid.Cid // amt<StorageDeal>
NextDealID uint64 // TODO: spec
}
// TODO: Drop in favour of car storage
type SerializationMode = uint64
const (
SerializationUnixFSv0 = iota
// IPLD / car
)
type StorageDealProposal struct {
PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea
PieceSize uint64
Client address.Address
Provider address.Address
ProposalExpiration uint64
Duration uint64 // TODO: spec
StoragePricePerEpoch types.BigInt
StorageCollateral types.BigInt
ProposerSignature *types.Signature
}
func (sdp *StorageDealProposal) TotalStoragePrice() types.BigInt {
return types.BigMul(sdp.StoragePricePerEpoch, types.NewInt(sdp.Duration))
}
type SignFunc = func(context.Context, []byte) (*types.Signature, error)
func (sdp *StorageDealProposal) Sign(ctx context.Context, sign SignFunc) error {
if sdp.ProposerSignature != nil {
return xerrors.New("signature already present in StorageDealProposal")
}
var buf bytes.Buffer
if err := sdp.MarshalCBOR(&buf); err != nil {
return err
}
sig, err := sign(ctx, buf.Bytes())
if err != nil {
return err
}
sdp.ProposerSignature = sig
return nil
}
func (sdp *StorageDealProposal) Cid() (cid.Cid, error) {
nd, err := cborutil.AsIpld(sdp)
if err != nil {
return cid.Undef, err
}
return nd.Cid(), nil
}
func (sdp *StorageDealProposal) Verify() error {
unsigned := *sdp
unsigned.ProposerSignature = nil
var buf bytes.Buffer
if err := unsigned.MarshalCBOR(&buf); err != nil {
return err
}
return sdp.ProposerSignature.Verify(sdp.Client, buf.Bytes())
}
type OnChainDeal struct {
PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea
PieceSize uint64
Client address.Address
Provider address.Address
ProposalExpiration uint64
Duration uint64 // TODO: spec
StoragePricePerEpoch types.BigInt
StorageCollateral types.BigInt
ActivationEpoch uint64 // 0 = inactive
}
type WithdrawBalanceParams struct {
Balance types.BigInt
}
func (sma StorageMarketActor) WithdrawBalance(act *types.Actor, vmctx types.VMContext, params *WithdrawBalanceParams) ([]byte, ActorError) {
// TODO: (spec) this should be 2-stage
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
b, bnd, err := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), self.Balances, vmctx.Message().From)
if err != nil {
return nil, aerrors.Wrap(err, "could not get balance")
}
balance := b[0]
if balance.Available.LessThan(params.Balance) {
return nil, aerrors.Newf(1, "can not withdraw more funds than available: %s > %s", params.Balance, b[0].Available)
}
balance.Available = types.BigSub(balance.Available, params.Balance)
_, err = vmctx.Send(vmctx.Message().From, 0, params.Balance, nil)
if err != nil {
return nil, aerrors.Wrap(err, "sending funds failed")
}
bcid, err := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{
vmctx.Message().From: balance,
})
if err != nil {
return nil, err
}
self.Balances = bcid
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
return nil, vmctx.Storage().Commit(old, nroot)
}
func (sma StorageMarketActor) AddBalance(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
b, bnd, err := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), self.Balances, vmctx.Message().From)
if err != nil {
return nil, aerrors.Wrap(err, "could not get balance")
}
balance := b[0]
balance.Available = types.BigAdd(balance.Available, vmctx.Message().Value)
bcid, err := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{
vmctx.Message().From: balance,
})
if err != nil {
return nil, err
}
self.Balances = bcid
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
return nil, vmctx.Storage().Commit(old, nroot)
}
func setMarketBalances(vmctx types.VMContext, nd *hamt.Node, set map[address.Address]StorageParticipantBalance) (cid.Cid, ActorError) {
keys := make([]address.Address, 0, len(set))
for k := range set {
keys = append(keys, k)
}
sort.Slice(keys, func(i, j int) bool {
return bytes.Compare(keys[i].Bytes(), keys[j].Bytes()) < 0
})
for _, addr := range keys {
balance := set[addr]
if err := nd.Set(vmctx.Context(), string(addr.Bytes()), &balance); err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "setting new balance")
}
}
if err := nd.Flush(vmctx.Context()); err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "flushing balance hamt")
}
c, err := vmctx.Ipld().Put(vmctx.Context(), nd)
if err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to balances storage")
}
return c, nil
}
func GetMarketBalances(ctx context.Context, store *hamt.CborIpldStore, rcid cid.Cid, addrs ...address.Address) ([]StorageParticipantBalance, *hamt.Node, ActorError) {
ctx, span := trace.StartSpan(ctx, "GetMarketBalances")
defer span.End()
nd, err := hamt.LoadNode(ctx, store, rcid)
if err != nil {
return nil, nil, aerrors.HandleExternalError(err, "failed to load miner set")
}
out := make([]StorageParticipantBalance, len(addrs))
for i, a := range addrs {
var balance StorageParticipantBalance
err = nd.Find(ctx, string(a.Bytes()), &balance)
switch err {
case hamt.ErrNotFound:
out[i] = StorageParticipantBalance{
Locked: types.NewInt(0),
Available: types.NewInt(0),
}
case nil:
out[i] = balance
default:
return nil, nil, aerrors.HandleExternalError(err, "failed to do set lookup")
}
}
return out, nd, nil
}
/*
func (sma StorageMarketActor) CheckLockedBalance(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
*/
type PublishStorageDealsParams struct {
Deals []StorageDealProposal
}
type PublishStorageDealResponse struct {
DealIDs []uint64
}
func (sma StorageMarketActor) PublishStorageDeals(act *types.Actor, vmctx types.VMContext, params *PublishStorageDealsParams) ([]byte, ActorError) {
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
deals, err := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Deals)
if err != nil {
return nil, aerrors.HandleExternalError(err, "loading deals amt")
}
// todo: handle duplicate deals
if len(params.Deals) == 0 {
return nil, aerrors.New(1, "no storage deals in params.Deals")
}
out := PublishStorageDealResponse{
DealIDs: make([]uint64, len(params.Deals)),
}
workerBytes, aerr := vmctx.Send(params.Deals[0].Provider, MAMethods.GetWorkerAddr, types.NewInt(0), nil)
if aerr != nil {
return nil, aerr
}
providerWorker, err := address.NewFromBytes(workerBytes)
if err != nil {
return nil, aerrors.HandleExternalError(err, "parsing provider worker address bytes")
}
// TODO: REVIEW: Do we want to check if provider exists in the power actor?
for i, deal := range params.Deals {
if err := self.validateDeal(vmctx, deal, providerWorker); err != nil {
return nil, err
}
err := deals.Set(self.NextDealID, &OnChainDeal{
PieceRef: deal.PieceRef,
PieceSize: deal.PieceSize,
Client: deal.Client,
Provider: deal.Provider,
ProposalExpiration: deal.ProposalExpiration,
Duration: deal.Duration,
StoragePricePerEpoch: deal.StoragePricePerEpoch,
StorageCollateral: deal.StorageCollateral,
ActivationEpoch: 0,
})
if err != nil {
return nil, aerrors.HandleExternalError(err, "setting deal in deal AMT")
}
out.DealIDs[i] = self.NextDealID
self.NextDealID++
}
dealsCid, err := deals.Flush()
if err != nil {
return nil, aerrors.HandleExternalError(err, "saving deals AMT")
}
self.Deals = dealsCid
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, aerrors.HandleExternalError(err, "storing state failed")
}
aerr = vmctx.Storage().Commit(old, nroot)
if aerr != nil {
return nil, aerr
}
var outBuf bytes.Buffer
if err := out.MarshalCBOR(&outBuf); err != nil {
return nil, aerrors.HandleExternalError(err, "serialising output")
}
return outBuf.Bytes(), nil
}
func (st *StorageMarketState) validateDeal(vmctx types.VMContext, deal StorageDealProposal, providerWorker address.Address) aerrors.ActorError {
ctx, span := trace.StartSpan(vmctx.Context(), "validateDeal")
defer span.End()
if vmctx.BlockHeight() > deal.ProposalExpiration {
return aerrors.New(1, "deal proposal already expired")
}
if vmctx.Message().From != providerWorker {
return aerrors.New(2, "Deals must be submitted by the miner worker")
}
if err := deal.Verify(); err != nil {
return aerrors.Absorb(err, 3, "verifying proposer signature")
}
// TODO: do some caching (changes gas so needs to be in spec too)
b, bnd, aerr := GetMarketBalances(ctx, vmctx.Ipld(), st.Balances, deal.Client, providerWorker)
if aerr != nil {
return aerrors.Wrap(aerr, "getting client, and provider balances")
}
clientBalance := b[0]
providerBalance := b[1]
totalPrice := deal.TotalStoragePrice()
if clientBalance.Available.LessThan(totalPrice) {
return aerrors.Newf(5, "client doesn't have enough available funds to cover storage price; %d < %d", clientBalance.Available, totalPrice)
}
clientBalance = lockFunds(clientBalance, totalPrice)
// TODO: REVIEW: Not clear who pays for this
if providerBalance.Available.LessThan(deal.StorageCollateral) {
return aerrors.Newf(6, "provider doesn't have enough available funds to cover StorageCollateral; %d < %d", providerBalance.Available, deal.StorageCollateral)
}
providerBalance = lockFunds(providerBalance, deal.StorageCollateral)
// TODO: piece checks (e.g. size > sectorSize)?
bcid, aerr := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{
deal.Client: clientBalance,
providerWorker: providerBalance,
})
if aerr != nil {
return aerr
}
st.Balances = bcid
return nil
}
type ActivateStorageDealsParams struct {
Deals []uint64
}
func (sma StorageMarketActor) ActivateStorageDeals(act *types.Actor, vmctx types.VMContext, params *ActivateStorageDealsParams) ([]byte, ActorError) {
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
deals, err := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Deals)
if err != nil {
return nil, aerrors.HandleExternalError(err, "loading deals amt")
}
for _, deal := range params.Deals {
var dealInfo OnChainDeal
if err := deals.Get(deal, &dealInfo); err != nil {
if _, is := err.(*amt.ErrNotFound); is {
return nil, aerrors.New(3, "deal not found")
}
return nil, aerrors.HandleExternalError(err, "getting deal info failed")
}
if vmctx.Message().From != dealInfo.Provider {
return nil, aerrors.New(1, "ActivateStorageDeals can only be called by the deal provider")
}
if vmctx.BlockHeight() > dealInfo.ProposalExpiration {
return nil, aerrors.New(2, "deal cannot be activated: proposal expired")
}
if dealInfo.ActivationEpoch > 0 {
// this probably can't happen in practice
return nil, aerrors.New(3, "deal already active")
}
dealInfo.ActivationEpoch = vmctx.BlockHeight()
if err := deals.Set(deal, &dealInfo); err != nil {
return nil, aerrors.HandleExternalError(err, "setting deal info in AMT failed")
}
}
dealsCid, err := deals.Flush()
if err != nil {
return nil, aerrors.HandleExternalError(err, "saving deals AMT")
}
self.Deals = dealsCid
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, aerrors.HandleExternalError(err, "storing state failed")
}
aerr := vmctx.Storage().Commit(old, nroot)
if aerr != nil {
return nil, aerr
}
return nil, nil
}
type ProcessStorageDealsPaymentParams struct {
DealIDs []uint64
}
func (sma StorageMarketActor) ProcessStorageDealsPayment(act *types.Actor, vmctx types.VMContext, params *ProcessStorageDealsPaymentParams) ([]byte, ActorError) {
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
deals, err := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Deals)
if err != nil {
return nil, aerrors.HandleExternalError(err, "loading deals amt")
}
// TODO: Would be nice if send could assert actor type
workerBytes, aerr := vmctx.Send(vmctx.Message().From, MAMethods.GetWorkerAddr, types.NewInt(0), nil)
if aerr != nil {
return nil, aerr
}
providerWorker, err := address.NewFromBytes(workerBytes)
if err != nil {
return nil, aerrors.HandleExternalError(err, "parsing provider worker address bytes")
}
for _, deal := range params.DealIDs {
var dealInfo OnChainDeal
if err := deals.Get(deal, &dealInfo); err != nil {
if _, is := err.(*amt.ErrNotFound); is {
return nil, aerrors.New(2, "deal not found")
}
return nil, aerrors.HandleExternalError(err, "getting deal info failed")
}
if dealInfo.Provider != vmctx.Message().From {
return nil, aerrors.New(3, "ProcessStorageDealsPayment can only be called by deal provider")
}
if vmctx.BlockHeight() < dealInfo.ActivationEpoch {
// TODO: This is probably fatal
return nil, aerrors.New(4, "ActivationEpoch lower than block height")
}
if vmctx.BlockHeight() > dealInfo.ActivationEpoch+dealInfo.Duration {
// Deal expired, miner should drop it
// TODO: process payment for the remainder of last proving period
return nil, nil
}
toPay := types.BigMul(dealInfo.StoragePricePerEpoch, types.NewInt(build.SlashablePowerDelay))
b, bnd, aerr := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), self.Balances, dealInfo.Client, providerWorker)
if aerr != nil {
return nil, aerr
}
clientBal := b[0]
providerBal := b[1]
clientBal.Locked, providerBal.Available = transferFunds(clientBal.Locked, providerBal.Available, toPay)
// TODO: call set once
bcid, aerr := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{
dealInfo.Client: clientBal,
providerWorker: providerBal,
})
if aerr != nil {
return nil, aerr
}
self.Balances = bcid
}
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, aerrors.HandleExternalError(err, "storing state failed")
}
aerr = vmctx.Storage().Commit(old, nroot)
if aerr != nil {
return nil, aerr
}
return nil, nil
}
func lockFunds(p StorageParticipantBalance, amt types.BigInt) StorageParticipantBalance {
p.Available, p.Locked = transferFunds(p.Available, p.Locked, amt)
return p
}
func transferFunds(from, to, amt types.BigInt) (types.BigInt, types.BigInt) {
// TODO: some asserts
return types.BigSub(from, amt), types.BigAdd(to, amt)
}
type ComputeDataCommitmentParams struct {
DealIDs []uint64
SectorSize uint64
}
func (sma StorageMarketActor) ComputeDataCommitment(act *types.Actor, vmctx types.VMContext, params *ComputeDataCommitmentParams) ([]byte, ActorError) {
var self StorageMarketState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
deals, err := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.Deals)
if err != nil {
return nil, aerrors.HandleExternalError(err, "loading deals amt")
}
if len(params.DealIDs) == 0 {
return nil, aerrors.New(3, "no deal IDs")
}
var pieces []sectorbuilder.PublicPieceInfo
for _, deal := range params.DealIDs {
var dealInfo OnChainDeal
if err := deals.Get(deal, &dealInfo); err != nil {
if _, is := err.(*amt.ErrNotFound); is {
return nil, aerrors.New(4, "deal not found")
}
return nil, aerrors.HandleExternalError(err, "getting deal info failed")
}
if dealInfo.Provider != vmctx.Message().From {
return nil, aerrors.New(5, "referenced deal was not from caller")
}
var commP [32]byte
copy(commP[:], dealInfo.PieceRef)
pieces = append(pieces, sectorbuilder.PublicPieceInfo{
Size: dealInfo.PieceSize,
CommP: commP,
})
}
commd, err := sectorbuilder.GenerateDataCommitment(params.SectorSize, pieces)
if err != nil {
return nil, aerrors.Absorb(err, 6, "failed to generate data commitment from pieces")
}
return commd[:], nil
}
/*
func (sma StorageMarketActor) HandleCronAction(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) SettleExpiredDeals(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) SlashStorageDealCollateral(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) GetLastExpirationFromDealIDs(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
*/
-797
View File
@@ -1,797 +0,0 @@
package actors
import (
"bytes"
"context"
"io"
"github.com/filecoin-project/go-amt-ipld"
cid "github.com/ipfs/go-cid"
hamt "github.com/ipfs/go-hamt-ipld"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"go.opencensus.io/trace"
xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
)
type StoragePowerActor struct{}
type spaMethods struct {
Constructor uint64
CreateStorageMiner uint64
ArbitrateConsensusFault uint64
UpdateStorage uint64
GetTotalStorage uint64
PowerLookup uint64
IsValidMiner uint64
PledgeCollateralForSize uint64
CheckProofSubmissions uint64
}
var SPAMethods = spaMethods{1, 2, 3, 4, 5, 6, 7, 8, 9}
func (spa StoragePowerActor) Exports() []interface{} {
return []interface{}{
//1: spa.StoragePowerConstructor,
2: spa.CreateStorageMiner,
3: spa.ArbitrateConsensusFault,
4: spa.UpdateStorage,
5: spa.GetTotalStorage,
6: spa.PowerLookup,
7: spa.IsValidMiner,
8: spa.PledgeCollateralForSize,
9: spa.CheckProofSubmissions,
}
}
type StoragePowerState struct {
Miners cid.Cid
ProvingBuckets cid.Cid // amt[ProvingPeriodBucket]hamt[minerAddress]struct{}
MinerCount uint64
LastMinerCheck uint64
TotalStorage types.BigInt
}
type CreateStorageMinerParams struct {
Owner address.Address
Worker address.Address
SectorSize uint64
PeerID peer.ID
}
func (spa StoragePowerActor) CreateStorageMiner(act *types.Actor, vmctx types.VMContext, params *CreateStorageMinerParams) ([]byte, ActorError) {
if !build.SupportedSectorSize(params.SectorSize) {
return nil, aerrors.New(1, "Unsupported sector size")
}
var self StoragePowerState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
reqColl, err := pledgeCollateralForSize(vmctx, types.NewInt(0), self.TotalStorage, self.MinerCount+1)
if err != nil {
return nil, err
}
if vmctx.Message().Value.LessThan(reqColl) {
return nil, aerrors.Newf(1, "not enough funds passed to cover required miner collateral (needed %s, got %s)", reqColl, vmctx.Message().Value)
}
encoded, err := CreateExecParams(StorageMinerCodeCid, &StorageMinerConstructorParams{
Owner: params.Owner,
Worker: params.Worker,
SectorSize: params.SectorSize,
PeerID: params.PeerID,
})
if err != nil {
return nil, err
}
ret, err := vmctx.Send(InitAddress, IAMethods.Exec, vmctx.Message().Value, encoded)
if err != nil {
return nil, err
}
naddr, nerr := address.NewFromBytes(ret)
if nerr != nil {
return nil, aerrors.Absorb(nerr, 2, "could not read address of new actor")
}
ncid, err := MinerSetAdd(context.TODO(), vmctx, self.Miners, naddr)
if err != nil {
return nil, err
}
self.Miners = ncid
self.MinerCount++
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return naddr.Bytes(), nil
}
type ArbitrateConsensusFaultParams struct {
Block1 *types.BlockHeader
Block2 *types.BlockHeader
}
func (spa StoragePowerActor) ArbitrateConsensusFault(act *types.Actor, vmctx types.VMContext, params *ArbitrateConsensusFaultParams) ([]byte, ActorError) {
if params.Block1.Miner != params.Block2.Miner {
return nil, aerrors.New(2, "blocks must be from the same miner")
}
rval, err := vmctx.Send(params.Block1.Miner, MAMethods.GetWorkerAddr, types.NewInt(0), nil)
if err != nil {
return nil, aerrors.Wrap(err, "failed to get miner worker")
}
worker, oerr := address.NewFromBytes(rval)
if oerr != nil {
// REVIEW: should this be fatal? i can't think of a real situation that would get us here
return nil, aerrors.Absorb(oerr, 3, "response from 'GetWorkerAddr' was not a valid address")
}
if err := params.Block1.CheckBlockSignature(vmctx.Context(), worker); err != nil {
return nil, aerrors.Absorb(err, 4, "block1 did not have valid signature")
}
if err := params.Block2.CheckBlockSignature(vmctx.Context(), worker); err != nil {
return nil, aerrors.Absorb(err, 5, "block2 did not have valid signature")
}
// see the "Consensus Faults" section of the faults spec (faults.md)
// for details on these slashing conditions.
if !shouldSlash(params.Block1, params.Block2) {
return nil, aerrors.New(6, "blocks do not prove a slashable offense")
}
var self StoragePowerState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
if types.BigCmp(self.TotalStorage, types.NewInt(0)) == 0 {
return nil, aerrors.Fatal("invalid state, storage power actor has zero total storage")
}
miner := params.Block1.Miner
if has, err := MinerSetHas(vmctx, self.Miners, miner); err != nil {
return nil, aerrors.Wrapf(err, "failed to check miner in set")
} else if !has {
return nil, aerrors.New(7, "either already slashed or not a miner")
}
minerPower, err := powerLookup(context.TODO(), vmctx, &self, miner)
if err != nil {
return nil, err
}
slashedCollateral, err := pledgeCollateralForSize(vmctx, minerPower, self.TotalStorage, self.MinerCount)
if err != nil {
return nil, err
}
enc, err := SerializeParams(&MinerSlashConsensusFault{
Slasher: vmctx.Message().From,
AtHeight: params.Block1.Height,
SlashedCollateral: slashedCollateral,
})
if err != nil {
return nil, err
}
_, err = vmctx.Send(miner, MAMethods.SlashConsensusFault, types.NewInt(0), enc)
if err != nil {
return nil, err
}
// Remove the miner from the list of network miners
ncid, err := MinerSetRemove(context.TODO(), vmctx, self.Miners, miner)
if err != nil {
return nil, err
}
self.Miners = ncid
self.MinerCount--
self.TotalStorage = types.BigSub(self.TotalStorage, minerPower)
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return nil, nil
}
func cidArrContains(a []cid.Cid, b cid.Cid) bool {
for _, c := range a {
if b == c {
return true
}
}
return false
}
func shouldSlash(block1, block2 *types.BlockHeader) bool {
// First slashing condition, blocks have the same ticket round
if block1.Height == block2.Height {
return true
}
/* Second slashing condition requires having access to the parent tipset blocks
// This might not always be available, needs some thought on the best way to deal with this
// Second slashing condition, miner ignored own block when mining
// Case A: block2 could have been in block1's parent set but is not
b1ParentHeight := block1.Height - len(block1.Tickets)
block1ParentTipSet := block1.Parents
if !cidArrContains(block1.Parents, block2.Cid()) &&
b1ParentHeight == block2.Height &&
block1ParentTipSet.ParentCids == block2.ParentCids {
return true
}
// Case B: block1 could have been in block2's parent set but is not
block2ParentTipSet := parentOf(block2)
if !block2Parent.contains(block1) &&
block2ParentTipSet.Height == block1.Height &&
block2ParentTipSet.ParentCids == block1.ParentCids {
return true
}
*/
return false
}
type UpdateStorageParams struct {
Delta types.BigInt
NextSlashDeadline uint64
PreviousSlashDeadline uint64
}
func (spa StoragePowerActor) UpdateStorage(act *types.Actor, vmctx types.VMContext, params *UpdateStorageParams) ([]byte, ActorError) {
var self StoragePowerState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
has, err := MinerSetHas(vmctx, self.Miners, vmctx.Message().From)
if err != nil {
return nil, err
}
if !has {
return nil, aerrors.New(1, "update storage must only be called by a miner actor")
}
self.TotalStorage = types.BigAdd(self.TotalStorage, params.Delta)
previousBucket := params.PreviousSlashDeadline % build.SlashablePowerDelay
nextBucket := params.NextSlashDeadline % build.SlashablePowerDelay
if previousBucket == nextBucket && params.PreviousSlashDeadline != 0 {
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return nil, nil // Nothing to do
}
buckets, eerr := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingBuckets)
if eerr != nil {
return nil, aerrors.HandleExternalError(eerr, "loading proving buckets amt")
}
if params.PreviousSlashDeadline != 0 { // delete from previous bucket
err := deleteMinerFromBucket(vmctx, buckets, previousBucket)
if err != nil {
return nil, aerrors.Wrapf(err, "delete from bucket %d, next %d", previousBucket, nextBucket)
}
}
err = addMinerToBucket(vmctx, buckets, nextBucket)
if err != nil {
return nil, err
}
self.ProvingBuckets, eerr = buckets.Flush()
if eerr != nil {
return nil, aerrors.HandleExternalError(eerr, "flushing proving buckets")
}
nroot, err := vmctx.Storage().Put(&self)
if err != nil {
return nil, err
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return nil, nil
}
func deleteMinerFromBucket(vmctx types.VMContext, buckets *amt.Root, previousBucket uint64) aerrors.ActorError {
var bucket cid.Cid
err := buckets.Get(previousBucket, &bucket)
switch err.(type) {
case *amt.ErrNotFound:
return aerrors.HandleExternalError(err, "proving bucket missing")
case nil: // noop
default:
return aerrors.HandleExternalError(err, "getting proving bucket")
}
bhamt, err := hamt.LoadNode(vmctx.Context(), vmctx.Ipld(), bucket)
if err != nil {
return aerrors.HandleExternalError(err, "failed to load proving bucket")
}
err = bhamt.Delete(vmctx.Context(), string(vmctx.Message().From.Bytes()))
if err != nil {
return aerrors.HandleExternalError(err, "deleting miner from proving bucket")
}
err = bhamt.Flush(vmctx.Context())
if err != nil {
return aerrors.HandleExternalError(err, "flushing previous proving bucket")
}
bucket, err = vmctx.Ipld().Put(vmctx.Context(), bhamt)
if err != nil {
return aerrors.HandleExternalError(err, "putting previous proving bucket hamt")
}
err = buckets.Set(previousBucket, bucket)
if err != nil {
return aerrors.HandleExternalError(err, "setting previous proving bucket cid in amt")
}
return nil
}
func addMinerToBucket(vmctx types.VMContext, buckets *amt.Root, nextBucket uint64) aerrors.ActorError {
var bhamt *hamt.Node
var bucket cid.Cid
err := buckets.Get(nextBucket, &bucket)
switch err.(type) {
case *amt.ErrNotFound:
bhamt = hamt.NewNode(vmctx.Ipld())
case nil:
bhamt, err = hamt.LoadNode(vmctx.Context(), vmctx.Ipld(), bucket)
if err != nil {
return aerrors.HandleExternalError(err, "failed to load proving bucket")
}
default:
return aerrors.HandleExternalError(err, "getting proving bucket")
}
err = bhamt.Set(vmctx.Context(), string(vmctx.Message().From.Bytes()), CborNull)
if err != nil {
return aerrors.HandleExternalError(err, "setting miner in proving bucket")
}
err = bhamt.Flush(vmctx.Context())
if err != nil {
return aerrors.HandleExternalError(err, "flushing previous proving bucket")
}
bucket, err = vmctx.Ipld().Put(vmctx.Context(), bhamt)
if err != nil {
return aerrors.HandleExternalError(err, "putting previous proving bucket hamt")
}
err = buckets.Set(nextBucket, bucket)
if err != nil {
return aerrors.HandleExternalError(err, "setting previous proving bucket cid in amt")
}
return nil
}
func (spa StoragePowerActor) GetTotalStorage(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
var self StoragePowerState
if err := vmctx.Storage().Get(vmctx.Storage().GetHead(), &self); err != nil {
return nil, err
}
return self.TotalStorage.Bytes(), nil
}
type PowerLookupParams struct {
Miner address.Address
}
func (spa StoragePowerActor) PowerLookup(act *types.Actor, vmctx types.VMContext, params *PowerLookupParams) ([]byte, ActorError) {
var self StoragePowerState
if err := vmctx.Storage().Get(vmctx.Storage().GetHead(), &self); err != nil {
return nil, aerrors.Wrap(err, "getting head")
}
pow, err := powerLookup(context.TODO(), vmctx, &self, params.Miner)
if err != nil {
return nil, err
}
return pow.Bytes(), nil
}
func powerLookup(ctx context.Context, vmctx types.VMContext, self *StoragePowerState, miner address.Address) (types.BigInt, ActorError) {
has, err := MinerSetHas(vmctx, self.Miners, miner)
if err != nil {
return types.EmptyInt, err
}
if !has {
return types.EmptyInt, aerrors.New(1, "miner not registered with storage power actor")
}
// TODO: Use local amt
ret, err := vmctx.Send(miner, MAMethods.GetPower, types.NewInt(0), nil)
if err != nil {
return types.EmptyInt, aerrors.Wrap(err, "invoke Miner.GetPower")
}
return types.BigFromBytes(ret), nil
}
type IsValidMinerParam struct {
Addr address.Address
}
func (spa StoragePowerActor) IsValidMiner(act *types.Actor, vmctx types.VMContext, param *IsValidMinerParam) ([]byte, ActorError) {
var self StoragePowerState
if err := vmctx.Storage().Get(vmctx.Storage().GetHead(), &self); err != nil {
return nil, err
}
has, err := MinerSetHas(vmctx, self.Miners, param.Addr)
if err != nil {
return nil, err
}
if !has {
log.Warnf("Miner INVALID: not in set: %s", param.Addr)
return cbg.CborBoolFalse, nil
}
ret, err := vmctx.Send(param.Addr, MAMethods.IsSlashed, types.NewInt(0), nil)
if err != nil {
return nil, err
}
slashed := bytes.Equal(ret, cbg.CborBoolTrue)
if slashed {
log.Warnf("Miner INVALID: /SLASHED/ : %s", param.Addr)
}
return cbg.EncodeBool(!slashed), nil
}
type PledgeCollateralParams struct {
Size types.BigInt
}
func (spa StoragePowerActor) PledgeCollateralForSize(act *types.Actor, vmctx types.VMContext, param *PledgeCollateralParams) ([]byte, ActorError) {
var self StoragePowerState
if err := vmctx.Storage().Get(vmctx.Storage().GetHead(), &self); err != nil {
return nil, err
}
totalCollateral, err := pledgeCollateralForSize(vmctx, param.Size, self.TotalStorage, self.MinerCount)
if err != nil {
return nil, err
}
return totalCollateral.Bytes(), nil
}
func pledgeCollateralForSize(vmctx types.VMContext, size, totalStorage types.BigInt, minerCount uint64) (types.BigInt, aerrors.ActorError) {
netBalance, err := vmctx.GetBalance(NetworkAddress)
if err != nil {
return types.EmptyInt, err
}
// TODO: the spec says to also grab 'total vested filecoin' and include it as available
// If we don't factor that in, we effectively assume all of the locked up filecoin is 'available'
// the blocker on that right now is that its hard to tell how much filecoin is unlocked
availableFilecoin := types.BigSub(
types.BigMul(types.NewInt(build.TotalFilecoin), types.NewInt(build.FilecoinPrecision)),
netBalance,
)
totalPowerCollateral := types.BigDiv(
types.BigMul(
availableFilecoin,
types.NewInt(build.PowerCollateralProportion),
),
types.NewInt(build.CollateralPrecision),
)
totalPerCapitaCollateral := types.BigDiv(
types.BigMul(
availableFilecoin,
types.NewInt(build.PerCapitaCollateralProportion),
),
types.NewInt(build.CollateralPrecision),
)
// REVIEW: for bootstrapping purposes, we skip the power portion of the
// collateral if there is no collateral in the network yet
powerCollateral := types.NewInt(0)
if types.BigCmp(totalStorage, types.NewInt(0)) != 0 {
powerCollateral = types.BigDiv(
types.BigMul(
totalPowerCollateral,
size,
),
totalStorage,
)
}
perCapCollateral := types.BigDiv(
totalPerCapitaCollateral,
types.NewInt(minerCount),
)
return types.BigAdd(powerCollateral, perCapCollateral), nil
}
func (spa StoragePowerActor) CheckProofSubmissions(act *types.Actor, vmctx types.VMContext, param *struct{}) ([]byte, ActorError) {
if vmctx.Message().From != CronAddress {
return nil, aerrors.New(1, "CheckProofSubmissions is only callable from the cron actor")
}
var self StoragePowerState
old := vmctx.Storage().GetHead()
if err := vmctx.Storage().Get(old, &self); err != nil {
return nil, err
}
for i := self.LastMinerCheck; i < vmctx.BlockHeight(); i++ {
height := i + 1
err := checkProofSubmissionsAtH(vmctx, &self, height)
if err != nil {
return nil, err
}
}
self.LastMinerCheck = vmctx.BlockHeight()
nroot, aerr := vmctx.Storage().Put(&self)
if aerr != nil {
return nil, aerr
}
if err := vmctx.Storage().Commit(old, nroot); err != nil {
return nil, err
}
return nil, nil
}
func checkProofSubmissionsAtH(vmctx types.VMContext, self *StoragePowerState, height uint64) aerrors.ActorError {
bucketID := height % build.SlashablePowerDelay
buckets, eerr := amt.LoadAMT(types.WrapStorage(vmctx.Storage()), self.ProvingBuckets)
if eerr != nil {
return aerrors.HandleExternalError(eerr, "loading proving buckets amt")
}
var bucket cid.Cid
err := buckets.Get(bucketID, &bucket)
switch err.(type) {
case *amt.ErrNotFound:
return nil // nothing to do
case nil:
default:
return aerrors.HandleExternalError(err, "getting proving bucket")
}
bhamt, err := hamt.LoadNode(vmctx.Context(), vmctx.Ipld(), bucket)
if err != nil {
return aerrors.HandleExternalError(err, "failed to load proving bucket")
}
err = bhamt.ForEach(vmctx.Context(), func(k string, val interface{}) error {
_, span := trace.StartSpan(vmctx.Context(), "StoragePowerActor.CheckProofSubmissions.loop")
defer span.End()
maddr, err := address.NewFromBytes([]byte(k))
if err != nil {
return aerrors.Escalate(err, "parsing miner address")
}
span.AddAttributes(trace.StringAttribute("miner", maddr.String()))
params, err := SerializeParams(&CheckMinerParams{NetworkPower: self.TotalStorage})
if err != nil {
return err
}
ret, err := vmctx.Send(maddr, MAMethods.CheckMiner, types.NewInt(0), params)
if err != nil {
return err
}
if len(ret) == 0 {
return nil // miner is fine
}
var power types.BigInt
if err := power.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
return xerrors.Errorf("unmarshaling CheckMiner response (%x): %w", ret, err)
}
if power.GreaterThan(types.NewInt(0)) {
log.Warnf("slashing miner %s for missed PoSt (%s B, H: %d, Bucket: %d)", maddr, power, height, bucketID)
self.TotalStorage = types.BigSub(self.TotalStorage, power)
}
return nil
})
if err != nil {
return aerrors.HandleExternalError(err, "iterating miners in proving bucket")
}
return nil
}
func MinerSetHas(vmctx types.VMContext, rcid cid.Cid, maddr address.Address) (bool, aerrors.ActorError) {
nd, err := hamt.LoadNode(vmctx.Context(), vmctx.Ipld(), rcid)
if err != nil {
return false, aerrors.HandleExternalError(err, "failed to load miner set")
}
err = nd.Find(vmctx.Context(), string(maddr.Bytes()), nil)
switch err {
case hamt.ErrNotFound:
return false, nil
case nil:
return true, nil
default:
return false, aerrors.HandleExternalError(err, "failed to do set lookup")
}
}
func MinerSetList(ctx context.Context, cst *hamt.CborIpldStore, rcid cid.Cid) ([]address.Address, error) {
nd, err := hamt.LoadNode(ctx, cst, rcid)
if err != nil {
return nil, xerrors.Errorf("failed to load miner set: %w", err)
}
var out []address.Address
err = nd.ForEach(ctx, func(k string, val interface{}) error {
addr, err := address.NewFromBytes([]byte(k))
if err != nil {
return err
}
out = append(out, addr)
return nil
})
if err != nil {
return nil, err
}
return out, nil
}
func MinerSetAdd(ctx context.Context, vmctx types.VMContext, rcid cid.Cid, maddr address.Address) (cid.Cid, aerrors.ActorError) {
nd, err := hamt.LoadNode(ctx, vmctx.Ipld(), rcid)
if err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to load miner set")
}
mkey := string(maddr.Bytes())
err = nd.Find(ctx, mkey, nil)
if err == nil {
return cid.Undef, aerrors.New(20, "miner already in set")
}
if !xerrors.Is(err, hamt.ErrNotFound) {
return cid.Undef, aerrors.HandleExternalError(err, "failed to do miner set check")
}
if err := nd.Set(ctx, mkey, uint64(1)); err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "adding miner address to set failed")
}
if err := nd.Flush(ctx); err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to flush miner set")
}
c, err := vmctx.Ipld().Put(ctx, nd)
if err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to persist miner set to storage")
}
return c, nil
}
func MinerSetRemove(ctx context.Context, vmctx types.VMContext, rcid cid.Cid, maddr address.Address) (cid.Cid, aerrors.ActorError) {
nd, err := hamt.LoadNode(ctx, vmctx.Ipld(), rcid)
if err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to load miner set")
}
mkey := string(maddr.Bytes())
switch nd.Delete(ctx, mkey) {
default:
return cid.Undef, aerrors.HandleExternalError(err, "failed to delete miner from set")
case hamt.ErrNotFound:
return cid.Undef, aerrors.New(1, "miner not found in set on delete")
case nil:
}
if err := nd.Flush(ctx); err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to flush miner set")
}
c, err := vmctx.Ipld().Put(ctx, nd)
if err != nil {
return cid.Undef, aerrors.HandleExternalError(err, "failed to persist miner set to storage")
}
return c, nil
}
type cbgNull struct{}
var CborNull = &cbgNull{}
func (cbgNull) MarshalCBOR(w io.Writer) error {
n, err := w.Write(cbg.CborNull)
if err != nil {
return err
}
if n != 1 {
return xerrors.New("expected to write 1 byte")
}
return nil
}
func (cbgNull) UnmarshalCBOR(r io.Reader) error {
b := [1]byte{}
n, err := r.Read(b[:])
if err != nil {
return err
}
if n != 1 {
return xerrors.New("expected 1 byte")
}
if !bytes.Equal(b[:], cbg.CborNull) {
return xerrors.New("expected cbor null")
}
return nil
}
-174
View File
@@ -1,174 +0,0 @@
package actors_test
import (
"context"
"fmt"
"testing"
"github.com/filecoin-project/lotus/build"
cbg "github.com/whyrusleeping/cbor-gen"
. "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/chain/wallet"
cid "github.com/ipfs/go-cid"
hamt "github.com/ipfs/go-hamt-ipld"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
mh "github.com/multiformats/go-multihash"
"github.com/stretchr/testify/assert"
)
func TestStorageMarketCreateAndSlashMiner(t *testing.T) {
var ownerAddr, workerAddr address.Address
opts := []HarnessOpt{
HarnessAddr(&ownerAddr, 1000000),
HarnessAddr(&workerAddr, 100000),
}
h := NewHarness(t, opts...)
var minerAddr address.Address
{
// cheating the bootstrapping problem
cheatStorageMarketTotal(t, h.vm, h.cs.Blockstore())
ret, _ := h.InvokeWithValue(t, ownerAddr, StoragePowerAddress, SPAMethods.CreateStorageMiner,
types.NewInt(500000),
&CreateStorageMinerParams{
Owner: ownerAddr,
Worker: workerAddr,
SectorSize: build.SectorSizes[0],
PeerID: "fakepeerid",
})
ApplyOK(t, ret)
var err error
minerAddr, err = address.NewFromBytes(ret.Return)
assert.NoError(t, err)
}
{
ret, _ := h.Invoke(t, ownerAddr, StoragePowerAddress, SPAMethods.IsValidMiner,
&IsValidMinerParam{Addr: minerAddr})
ApplyOK(t, ret)
var output bool
err := cbor.DecodeInto(ret.Return, &output)
if err != nil {
t.Fatalf("error decoding: %+v", err)
}
if !output {
t.Fatalf("%s is miner but IsValidMiner call returned false", minerAddr)
}
}
{
ret, _ := h.Invoke(t, ownerAddr, StoragePowerAddress, SPAMethods.PowerLookup,
&PowerLookupParams{Miner: minerAddr})
ApplyOK(t, ret)
power := types.BigFromBytes(ret.Return)
if types.BigCmp(power, types.NewInt(0)) != 0 {
t.Fatalf("power should be zero, is: %s", power)
}
}
{
ret, _ := h.Invoke(t, ownerAddr, minerAddr, MAMethods.GetOwner, nil)
ApplyOK(t, ret)
oA, err := address.NewFromBytes(ret.Return)
assert.NoError(t, err)
assert.Equal(t, ownerAddr, oA, "return from GetOwner should be equal to the owner")
}
{
b1 := fakeBlock(t, minerAddr, 100)
b2 := fakeBlock(t, minerAddr, 101)
signBlock(t, h.w, workerAddr, b1)
signBlock(t, h.w, workerAddr, b2)
ret, _ := h.Invoke(t, ownerAddr, StoragePowerAddress, SPAMethods.ArbitrateConsensusFault,
&ArbitrateConsensusFaultParams{
Block1: b1,
Block2: b2,
})
ApplyOK(t, ret)
}
{
ret, _ := h.Invoke(t, ownerAddr, StoragePowerAddress, SPAMethods.PowerLookup,
&PowerLookupParams{Miner: minerAddr})
assert.Equal(t, ret.ExitCode, byte(1))
}
{
ret, _ := h.Invoke(t, ownerAddr, StoragePowerAddress, SPAMethods.IsValidMiner, &IsValidMinerParam{minerAddr})
ApplyOK(t, ret)
assert.Equal(t, ret.Return, cbg.CborBoolFalse)
}
}
func cheatStorageMarketTotal(t *testing.T, vm *vm.VM, bs bstore.Blockstore) {
t.Helper()
sma, err := vm.StateTree().GetActor(StoragePowerAddress)
if err != nil {
t.Fatal(err)
}
cst := hamt.CSTFromBstore(bs)
var smastate StoragePowerState
if err := cst.Get(context.TODO(), sma.Head, &smastate); err != nil {
t.Fatal(err)
}
smastate.TotalStorage = types.NewInt(10000)
c, err := cst.Put(context.TODO(), &smastate)
if err != nil {
t.Fatal(err)
}
sma.Head = c
if err := vm.StateTree().SetActor(StoragePowerAddress, sma); err != nil {
t.Fatal(err)
}
}
func fakeBlock(t *testing.T, minerAddr address.Address, ts uint64) *types.BlockHeader {
c := fakeCid(t, 1)
return &types.BlockHeader{Height: 5, Miner: minerAddr, Timestamp: ts, ParentStateRoot: c, Messages: c, ParentMessageReceipts: c, BLSAggregate: types.Signature{Type: types.KTBLS}}
}
func fakeCid(t *testing.T, s int) cid.Cid {
t.Helper()
c, err := cid.NewPrefixV1(cid.Raw, mh.IDENTITY).Sum([]byte(fmt.Sprintf("%d", s)))
if err != nil {
t.Fatal(err)
}
return c
}
func signBlock(t *testing.T, w *wallet.Wallet, worker address.Address, blk *types.BlockHeader) {
t.Helper()
sb, err := blk.SigningBytes()
if err != nil {
t.Fatal(err)
}
sig, err := w.Sign(context.TODO(), worker, sb)
if err != nil {
t.Fatal(err)
}
blk.BlockSig = sig
}
-52
View File
@@ -1,52 +0,0 @@
package actors
import (
"github.com/filecoin-project/lotus/chain/address"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
)
var AccountCodeCid cid.Cid
var CronCodeCid cid.Cid
var StoragePowerCodeCid cid.Cid
var StorageMarketCodeCid cid.Cid
var StorageMinerCodeCid cid.Cid
var MultisigCodeCid cid.Cid
var InitCodeCid cid.Cid
var PaymentChannelCodeCid cid.Cid
var InitAddress = mustIDAddress(0)
var NetworkAddress = mustIDAddress(1)
var StoragePowerAddress = mustIDAddress(2)
var StorageMarketAddress = mustIDAddress(3) // TODO: missing from spec
var CronAddress = mustIDAddress(4)
var BurntFundsAddress = mustIDAddress(99)
func mustIDAddress(i uint64) address.Address {
a, err := address.NewIDAddress(i)
if err != nil {
panic(err) // ok
}
return a
}
func init() {
pref := cid.NewPrefixV1(cid.Raw, mh.IDENTITY)
mustSum := func(s string) cid.Cid {
c, err := pref.Sum([]byte(s))
if err != nil {
panic(err) // ok
}
return c
}
AccountCodeCid = mustSum("fil/1/account") // TODO: spec
CronCodeCid = mustSum("fil/1/cron")
StoragePowerCodeCid = mustSum("fil/1/power")
StorageMarketCodeCid = mustSum("fil/1/market")
StorageMinerCodeCid = mustSum("fil/1/miner")
MultisigCodeCid = mustSum("fil/1/multisig")
InitCodeCid = mustSum("fil/1/init")
PaymentChannelCodeCid = mustSum("fil/1/paych")
}
-158
View File
@@ -1,158 +0,0 @@
package actors_test
import (
"context"
"encoding/binary"
"fmt"
"testing"
"github.com/filecoin-project/lotus/build"
. "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
dstore "github.com/ipfs/go-datastore"
bstore "github.com/ipfs/go-ipfs-blockstore"
)
func blsaddr(n uint64) address.Address {
buf := make([]byte, 48)
binary.PutUvarint(buf, n)
addr, err := address.NewBLSAddress(buf)
if err != nil {
panic(err) // ok
}
return addr
}
func setupVMTestEnv(t *testing.T) (*vm.VM, []address.Address, bstore.Blockstore) {
bs := bstore.NewBlockstore(dstore.NewMapDatastore())
from := blsaddr(0)
maddr := blsaddr(1)
actors := map[address.Address]types.BigInt{
from: types.NewInt(1000000),
maddr: types.NewInt(0),
}
st, err := gen.MakeInitialStateTree(bs, actors)
if err != nil {
t.Fatal(err)
}
stateroot, err := st.Flush()
if err != nil {
t.Fatal(err)
}
cs := store.NewChainStore(bs, nil)
// TODO: should probabaly mock out the randomness bit, nil works for now
vm, err := vm.NewVM(stateroot, 1, nil, maddr, cs.Blockstore())
if err != nil {
t.Fatal(err)
}
return vm, []address.Address{from, maddr}, bs
}
func TestVMInvokeMethod(t *testing.T) {
vm, addrs, _ := setupVMTestEnv(t)
from := addrs[0]
var err error
cenc, err := SerializeParams(&StorageMinerConstructorParams{Owner: from, Worker: from})
if err != nil {
t.Fatal(err)
}
execparams := &ExecParams{
Code: StorageMinerCodeCid,
Params: cenc,
}
enc, err := SerializeParams(execparams)
if err != nil {
t.Fatal(err)
}
msg := &types.Message{
To: InitAddress,
From: from,
Method: IAMethods.Exec,
Params: enc,
GasPrice: types.NewInt(1),
GasLimit: types.NewInt(10000),
Value: types.NewInt(0),
}
ret, err := vm.ApplyMessage(context.TODO(), msg)
if err != nil {
t.Fatal(err)
}
if ret.ExitCode != 0 {
t.Fatal("invocation failed")
}
outaddr, err := address.NewFromBytes(ret.Return)
if err != nil {
t.Fatal(err)
}
if outaddr.String() != "t0102" {
t.Fatal("hold up")
}
}
func TestStorageMarketActorCreateMiner(t *testing.T) {
vm, addrs, bs := setupVMTestEnv(t)
from := addrs[0]
maddr := addrs[1]
cheatStorageMarketTotal(t, vm, bs)
params := &StorageMinerConstructorParams{
Owner: maddr,
Worker: maddr,
SectorSize: build.SectorSizes[0],
PeerID: "fakepeerid",
}
var err error
enc, err := SerializeParams(params)
if err != nil {
t.Fatal(err)
}
msg := &types.Message{
To: StoragePowerAddress,
From: from,
Method: SPAMethods.CreateStorageMiner,
Params: enc,
GasPrice: types.NewInt(1),
GasLimit: types.NewInt(10000),
Value: types.NewInt(50000),
}
ret, err := vm.ApplyMessage(context.TODO(), msg)
if err != nil {
t.Fatal(err)
}
if ret.ExitCode != 0 {
fmt.Println(ret.ActorErr)
t.Fatal("invocation failed: ", ret.ExitCode)
}
outaddr, err := address.NewFromBytes(ret.Return)
if err != nil {
t.Fatal(err)
}
if outaddr.String() != "t0102" {
t.Fatal("hold up")
}
}
-14
View File
@@ -1,14 +0,0 @@
package actors
import (
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/address"
)
func NewIDAddress(id uint64) (address.Address, ActorError) {
a, err := address.NewIDAddress(id)
if err != nil {
return address.Undef, aerrors.Escalate(err, "could not create ID Address")
}
return a, nil
}
+5 -4
View File
@@ -3,13 +3,14 @@ package aerrors
import (
"fmt"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"golang.org/x/xerrors"
)
func IsFatal(err ActorError) bool {
return err != nil && err.IsFatal()
}
func RetCode(err ActorError) uint8 {
func RetCode(err ActorError) exitcode.ExitCode {
if err == nil {
return 0
}
@@ -25,12 +26,12 @@ type internalActorError interface {
type ActorError interface {
error
IsFatal() bool
RetCode() uint8
RetCode() exitcode.ExitCode
}
type actorError struct {
fatal bool
retCode uint8
retCode exitcode.ExitCode
msg string
frame xerrors.Frame
@@ -41,7 +42,7 @@ func (e *actorError) IsFatal() bool {
return e.fatal
}
func (e *actorError) RetCode() uint8 {
func (e *actorError) RetCode() exitcode.ExitCode {
return e.retCode
}
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"testing"
. "github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/stretchr/testify/assert"
"golang.org/x/xerrors"
@@ -31,5 +32,5 @@ func TestAbsorbeError(t *testing.T) {
aw3 := Wrap(aw2, "creating miner in storage market")
t.Logf("Verbose error: %+v", aw3)
t.Logf("Normal error: %v", aw3)
assert.Equal(t, uint8(35), RetCode(aw3))
assert.Equal(t, exitcode.ExitCode(35), RetCode(aw3))
}
+29 -6
View File
@@ -4,12 +4,13 @@ import (
"errors"
"fmt"
hamt "github.com/ipfs/go-hamt-ipld"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
cbor "github.com/ipfs/go-ipld-cbor"
"golang.org/x/xerrors"
)
// New creates a new non-fatal error
func New(retCode uint8, message string) ActorError {
func New(retCode exitcode.ExitCode, message string) ActorError {
if retCode == 0 {
return &actorError{
fatal: true,
@@ -29,7 +30,7 @@ func New(retCode uint8, message string) ActorError {
}
// Newf creates a new non-fatal error
func Newf(retCode uint8, format string, args ...interface{}) ActorError {
func Newf(retCode exitcode.ExitCode, format string, args ...interface{}) ActorError {
if retCode == 0 {
return &actorError{
fatal: true,
@@ -48,6 +49,27 @@ func Newf(retCode uint8, format string, args ...interface{}) ActorError {
}
}
// todo: bit hacky
func NewfSkip(skip int, retCode exitcode.ExitCode, format string, args ...interface{}) ActorError {
if retCode == 0 {
return &actorError{
fatal: true,
retCode: 0,
msg: "tried creating an error and setting RetCode to 0",
frame: xerrors.Caller(skip),
err: fmt.Errorf(format, args...),
}
}
return &actorError{
retCode: retCode,
msg: fmt.Sprintf(format, args...),
frame: xerrors.Caller(skip),
}
}
func Fatal(message string, args ...interface{}) ActorError {
return &actorError{
fatal: true,
@@ -95,7 +117,7 @@ func Wrapf(err ActorError, format string, args ...interface{}) ActorError {
}
// Absorb takes and error and makes in not fatal ActorError
func Absorb(err error, retCode uint8, msg string) ActorError {
func Absorb(err error, retCode exitcode.ExitCode, msg string) ActorError {
if err == nil {
return nil
}
@@ -160,7 +182,7 @@ func HandleExternalError(err error, msg string) ActorError {
}
}
if xerrors.Is(err, &hamt.SerializationError{}) {
if xerrors.Is(err, &cbor.SerializationError{}) {
return &actorError{
fatal: false,
retCode: 253,
@@ -171,7 +193,8 @@ func HandleExternalError(err error, msg string) ActorError {
}
return &actorError{
fatal: true,
fatal: false,
retCode: 219,
msg: msg,
frame: xerrors.Caller(1),
File diff suppressed because it is too large Load Diff
-5
View File
@@ -1,5 +0,0 @@
package actors
import "github.com/filecoin-project/lotus/chain/actors/aerrors"
type ActorError = aerrors.ActorError
-46
View File
@@ -1,46 +0,0 @@
package actors
import (
"reflect"
"sort"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/types"
)
type update struct {
start uint64
method interface{}
}
func withUpdates(updates ...update) interface{} {
sort.Slice(updates, func(i, j int) bool { // so we iterate from newest below
return updates[i].start > updates[j].start
})
// <script type="application/javascript">
typ := reflect.TypeOf(updates[0].method)
out := reflect.MakeFunc(typ, func(args []reflect.Value) (results []reflect.Value) {
vmctx := args[1].Interface().(types.VMContext)
for _, u := range updates {
if vmctx.BlockHeight() >= u.start {
return reflect.ValueOf(u.method).Call(args)
}
}
return reflect.ValueOf(notFound(vmctx)).Call([]reflect.Value{})
})
return out.Interface()
// </script>
}
func notFound(vmctx types.VMContext) func() ([]byte, ActorError) {
return func() ([]byte, ActorError) {
return nil, aerrors.Fatal("no code for method %d at height %d", vmctx.Message().Method, vmctx.BlockHeight())
}
}
-337
View File
@@ -1,337 +0,0 @@
package actors_test
import (
"bytes"
"context"
"math/rand"
"testing"
"github.com/ipfs/go-cid"
dstore "github.com/ipfs/go-datastore"
hamt "github.com/ipfs/go-hamt-ipld"
blockstore "github.com/ipfs/go-ipfs-blockstore"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/chain/wallet"
)
const testGasLimit = 10000
type HarnessInit struct {
NAddrs uint64
Addrs map[address.Address]types.BigInt
Miner address.Address
}
type HarnessStage int
const (
HarnessPreInit HarnessStage = iota
HarnessPostInit
)
type HarnessOpt func(testing.TB, *Harness) error
type Harness struct {
HI HarnessInit
Stage HarnessStage
Nonces map[address.Address]uint64
GasCharges map[address.Address]types.BigInt
Rand vm.Rand
BlockHeight uint64
lastBalanceCheck map[address.Address]types.BigInt
ctx context.Context
bs blockstore.Blockstore
vm *vm.VM
cs *store.ChainStore
w *wallet.Wallet
}
var HarnessMinerFunds = types.NewInt(1000000)
func HarnessAddr(addr *address.Address, value uint64) HarnessOpt {
return func(t testing.TB, h *Harness) error {
if h.Stage != HarnessPreInit {
return nil
}
hi := &h.HI
if addr.Empty() {
k, err := h.w.GenerateKey(types.KTSecp256k1)
if err != nil {
t.Fatal(err)
}
*addr = k
}
hi.Addrs[*addr] = types.NewInt(value)
return nil
}
}
func HarnessMiner(addr *address.Address) HarnessOpt {
return func(_ testing.TB, h *Harness) error {
if h.Stage != HarnessPreInit {
return nil
}
hi := &h.HI
if addr.Empty() {
*addr = hi.Miner
return nil
}
delete(hi.Addrs, hi.Miner)
hi.Miner = *addr
return nil
}
}
func HarnessActor(actor *address.Address, creator *address.Address, code cid.Cid, params func() cbg.CBORMarshaler) HarnessOpt {
return func(t testing.TB, h *Harness) error {
if h.Stage != HarnessPostInit {
return nil
}
if !actor.Empty() {
return xerrors.New("actor address should be empty")
}
ret, _ := h.CreateActor(t, *creator, code, params())
if ret.ExitCode != 0 {
return xerrors.Errorf("creating actor: %w", ret.ActorErr)
}
var err error
*actor, err = address.NewFromBytes(ret.Return)
return err
}
}
func HarnessCtx(ctx context.Context) HarnessOpt {
return func(t testing.TB, h *Harness) error {
h.ctx = ctx
return nil
}
}
func NewHarness(t *testing.T, options ...HarnessOpt) *Harness {
w, err := wallet.NewWallet(wallet.NewMemKeyStore())
if err != nil {
t.Fatal(err)
}
h := &Harness{
Stage: HarnessPreInit,
Nonces: make(map[address.Address]uint64),
Rand: &fakeRand{},
HI: HarnessInit{
NAddrs: 1,
Miner: blsaddr(0),
Addrs: map[address.Address]types.BigInt{
blsaddr(0): HarnessMinerFunds,
},
},
GasCharges: make(map[address.Address]types.BigInt),
lastBalanceCheck: make(map[address.Address]types.BigInt),
w: w,
ctx: context.Background(),
bs: bstore.NewBlockstore(dstore.NewMapDatastore()),
BlockHeight: 0,
}
for _, opt := range options {
err := opt(t, h)
if err != nil {
t.Fatalf("Applying options: %v", err)
}
}
st, err := gen.MakeInitialStateTree(h.bs, h.HI.Addrs)
if err != nil {
t.Fatal(err)
}
stateroot, err := st.Flush()
if err != nil {
t.Fatal(err)
}
stateroot, err = gen.SetupStorageMarketActor(h.bs, stateroot, nil)
if err != nil {
t.Fatal(err)
}
h.cs = store.NewChainStore(h.bs, nil)
h.vm, err = vm.NewVM(stateroot, 1, h.Rand, h.HI.Miner, h.cs.Blockstore())
if err != nil {
t.Fatal(err)
}
h.Stage = HarnessPostInit
for _, opt := range options {
err := opt(t, h)
if err != nil {
t.Fatalf("Applying options: %v", err)
}
}
return h
}
func (h *Harness) Apply(t testing.TB, msg types.Message) (*vm.ApplyRet, *state.StateTree) {
t.Helper()
if msg.Nonce == 0 {
msg.Nonce, _ = h.Nonces[msg.From]
h.Nonces[msg.From] = msg.Nonce + 1
}
ret, err := h.vm.ApplyMessage(h.ctx, &msg)
if err != nil {
t.Fatalf("Applying message: %+v", err)
}
if ret != nil {
if prev, ok := h.GasCharges[msg.From]; ok {
h.GasCharges[msg.From] = types.BigAdd(prev, ret.GasUsed)
} else {
h.GasCharges[msg.From] = ret.GasUsed
}
}
stateroot, err := h.vm.Flush(context.TODO())
if err != nil {
t.Fatalf("Flushing VM: %+v", err)
}
cst := hamt.CSTFromBstore(h.bs)
state, err := state.LoadStateTree(cst, stateroot)
if err != nil {
t.Fatalf("Loading state tree: %+v", err)
}
return ret, state
}
func (h *Harness) CreateActor(t testing.TB, from address.Address,
code cid.Cid, params cbg.CBORMarshaler) (*vm.ApplyRet, *state.StateTree) {
t.Helper()
return h.Apply(t, types.Message{
To: actors.InitAddress,
From: from,
Method: actors.IAMethods.Exec,
Params: DumpObject(t,
&actors.ExecParams{
Code: code,
Params: DumpObject(t, params),
}),
GasPrice: types.NewInt(1),
GasLimit: types.NewInt(testGasLimit),
Value: types.NewInt(0),
})
}
func (h *Harness) SendFunds(t testing.TB, from address.Address, to address.Address,
value types.BigInt) (*vm.ApplyRet, *state.StateTree) {
t.Helper()
return h.Apply(t, types.Message{
To: to,
From: from,
Method: 0,
Value: value,
GasPrice: types.NewInt(1),
GasLimit: types.NewInt(testGasLimit),
})
}
func (h *Harness) Invoke(t testing.TB, from address.Address, to address.Address,
method uint64, params cbg.CBORMarshaler) (*vm.ApplyRet, *state.StateTree) {
t.Helper()
return h.InvokeWithValue(t, from, to, method, types.NewInt(0), params)
}
func (h *Harness) InvokeWithValue(t testing.TB, from address.Address, to address.Address,
method uint64, value types.BigInt, params cbg.CBORMarshaler) (*vm.ApplyRet, *state.StateTree) {
t.Helper()
h.vm.SetBlockHeight(h.BlockHeight)
return h.Apply(t, types.Message{
To: to,
From: from,
Method: method,
Value: value,
Params: DumpObject(t, params),
GasPrice: types.NewInt(1),
GasLimit: types.NewInt(testGasLimit),
})
}
func (h *Harness) AssertBalance(t testing.TB, addr address.Address, amt uint64) {
t.Helper()
b, err := h.vm.ActorBalance(addr)
if err != nil {
t.Fatalf("%+v", err)
}
if types.BigCmp(types.NewInt(amt), b) != 0 {
t.Errorf("expected %s to have balanced of %d. Instead has %s", addr, amt, b)
}
}
func (h *Harness) AssertBalanceChange(t testing.TB, addr address.Address, amt int64) {
t.Helper()
lastBalance, ok := h.lastBalanceCheck[addr]
if !ok {
lastBalance, ok = h.HI.Addrs[addr]
if !ok {
lastBalance = types.NewInt(0)
}
}
var expected types.BigInt
if amt >= 0 {
expected = types.BigAdd(lastBalance, types.NewInt(uint64(amt)))
} else {
expected = types.BigSub(lastBalance, types.NewInt(uint64(-amt)))
}
h.lastBalanceCheck[addr] = expected
if gasUsed, ok := h.GasCharges[addr]; ok {
expected = types.BigSub(expected, gasUsed)
}
b, err := h.vm.ActorBalance(addr)
if err != nil {
t.Fatalf("%+v", err)
}
if types.BigCmp(expected, b) != 0 {
t.Errorf("expected %s to have balanced of %d. Instead has %s", addr, amt, b)
}
}
func DumpObject(t testing.TB, obj cbg.CBORMarshaler) []byte {
if obj == nil {
return nil
}
t.Helper()
b := new(bytes.Buffer)
if err := obj.MarshalCBOR(b); err != nil {
t.Fatalf("dumping params: %+v", err)
}
return b.Bytes()
}
type fakeRand struct{}
func (fr *fakeRand) GetRandomness(ctx context.Context, h int64) ([]byte, error) {
out := make([]byte, 32)
rand.New(rand.NewSource(h)).Read(out)
return out, nil
}
-4
View File
@@ -7,10 +7,6 @@ import (
cbg "github.com/whyrusleeping/cbor-gen"
)
var (
EmptyStructCBOR = []byte{0xa0}
)
func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) {
buf := new(bytes.Buffer)
if err := i.MarshalCBOR(buf); err != nil {
-415
View File
@@ -1,415 +0,0 @@
package address
import (
"bytes"
"encoding/json"
"fmt"
"io"
"strconv"
bls "github.com/filecoin-project/filecoin-ffi"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/minio/blake2b-simd"
"github.com/multiformats/go-varint"
"github.com/polydawn/refmt/obj/atlas"
"golang.org/x/xerrors"
cbg "github.com/whyrusleeping/cbor-gen"
)
func init() {
cbor.RegisterCborType(addressAtlasEntry)
}
var addressAtlasEntry = atlas.BuildEntry(Address{}).Transform().
TransformMarshal(atlas.MakeMarshalTransformFunc(
func(a Address) (string, error) {
return string(a.Bytes()), nil
})).
TransformUnmarshal(atlas.MakeUnmarshalTransformFunc(
func(x string) (Address, error) {
return NewFromBytes([]byte(x))
})).
Complete()
// Address is the go type that represents an address in the filecoin network.
type Address struct{ str string }
// Undef is the type that represents an undefined address.
var Undef = Address{}
// Network represents which network an address belongs to.
type Network = byte
const (
// Mainnet is the main network.
Mainnet Network = iota
// Testnet is the test network.
Testnet
)
// MainnetPrefix is the main network prefix.
const MainnetPrefix = "f"
// TestnetPrefix is the main network prefix.
const TestnetPrefix = "t"
// Protocol represents which protocol an address uses.
type Protocol = byte
const (
// ID represents the address ID protocol.
ID Protocol = iota
// SECP256K1 represents the address SECP256K1 protocol.
SECP256K1
// Actor represents the address Actor protocol.
Actor
// BLS represents the address BLS protocol.
BLS
Unknown = Protocol(255)
)
// Protocol returns the protocol used by the address.
func (a Address) Protocol() Protocol {
if len(a.str) == 0 {
return Unknown
}
return a.str[0]
}
// Payload returns the payload of the address.
func (a Address) Payload() []byte {
return []byte(a.str[1:])
}
// Bytes returns the address as bytes.
func (a Address) Bytes() []byte {
return []byte(a.str)
}
// String returns an address encoded as a string.
func (a Address) String() string {
str, err := encode(Testnet, a)
if err != nil {
panic(err) // I don't know if this one is okay
}
return str
}
// Empty returns true if the address is empty, false otherwise.
func (a Address) Empty() bool {
return a == Undef
}
// Unmarshal unmarshals the cbor bytes into the address.
func (a Address) Unmarshal(b []byte) error {
return cbor.DecodeInto(b, &a)
}
// Marshal marshals the address to cbor.
func (a Address) Marshal() ([]byte, error) {
return cbor.DumpObject(a)
}
// UnmarshalJSON implements the json unmarshal interface.
func (a *Address) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
addr, err := decode(s)
if err != nil {
return err
}
*a = addr
return nil
}
// MarshalJSON implements the json marshal interface.
func (a Address) MarshalJSON() ([]byte, error) {
return []byte(`"` + a.String() + `"`), nil
}
// Format implements the Formatter interface.
func (a Address) Format(f fmt.State, c rune) {
switch c {
case 'v':
if a.Empty() {
fmt.Fprint(f, UndefAddressString) //nolint: errcheck
} else {
fmt.Fprintf(f, "[%x - %x]", a.Protocol(), a.Payload()) // nolint: errcheck
}
case 's':
fmt.Fprintf(f, "%s", a.String()) // nolint: errcheck
default:
fmt.Fprintf(f, "%"+string(c), a.Bytes()) // nolint: errcheck
}
}
func (a *Address) Scan(value interface{}) error {
switch value := value.(type) {
case string:
a1, err := decode(value)
if err != nil {
return err
}
*a = a1
return nil
default:
return xerrors.New("non-string types unsupported")
}
}
// NewIDAddress returns an address using the ID protocol.
func NewIDAddress(id uint64) (Address, error) {
return newAddress(ID, varint.ToUvarint(id))
}
// NewSecp256k1Address returns an address using the SECP256K1 protocol.
func NewSecp256k1Address(pubkey []byte) (Address, error) {
return newAddress(SECP256K1, addressHash(pubkey))
}
// NewActorAddress returns an address using the Actor protocol.
func NewActorAddress(data []byte) (Address, error) {
return newAddress(Actor, addressHash(data))
}
// NewBLSAddress returns an address using the BLS protocol.
func NewBLSAddress(pubkey []byte) (Address, error) {
return newAddress(BLS, pubkey)
}
// NewFromString returns the address represented by the string `addr`.
func NewFromString(addr string) (Address, error) {
return decode(addr)
}
// NewFromBytes return the address represented by the bytes `addr`.
func NewFromBytes(addr []byte) (Address, error) {
if len(addr) == 0 {
return Undef, nil
}
if len(addr) == 1 {
return Undef, ErrInvalidLength
}
return newAddress(addr[0], addr[1:])
}
// Checksum returns the checksum of `ingest`.
func Checksum(ingest []byte) []byte {
return hash(ingest, checksumHashConfig)
}
// ValidateChecksum returns true if the checksum of `ingest` is equal to `expected`>
func ValidateChecksum(ingest, expect []byte) bool {
digest := Checksum(ingest)
return bytes.Equal(digest, expect)
}
func addressHash(ingest []byte) []byte {
return hash(ingest, payloadHashConfig)
}
func newAddress(protocol Protocol, payload []byte) (Address, error) {
switch protocol {
case ID:
_, n, err := varint.FromUvarint(payload)
if err != nil {
return Undef, xerrors.Errorf("could not decode: %v: %w", err, ErrInvalidPayload)
}
if n != len(payload) {
return Undef, xerrors.Errorf("different varint length (v:%d != p:%d): %w",
n, len(payload), ErrInvalidPayload)
}
case SECP256K1, Actor:
if len(payload) != PayloadHashLength {
return Undef, ErrInvalidPayload
}
case BLS:
if len(payload) != bls.PublicKeyBytes {
return Undef, ErrInvalidPayload
}
default:
return Undef, ErrUnknownProtocol
}
explen := 1 + len(payload)
buf := make([]byte, explen)
buf[0] = protocol
copy(buf[1:], payload)
return Address{string(buf)}, nil
}
func encode(network Network, addr Address) (string, error) {
if addr == Undef {
return UndefAddressString, nil
}
var ntwk string
switch network {
case Mainnet:
ntwk = MainnetPrefix
case Testnet:
ntwk = TestnetPrefix
default:
return UndefAddressString, ErrUnknownNetwork
}
var strAddr string
switch addr.Protocol() {
case SECP256K1, Actor, BLS:
cksm := Checksum(append([]byte{addr.Protocol()}, addr.Payload()...))
strAddr = ntwk + fmt.Sprintf("%d", addr.Protocol()) + AddressEncoding.WithPadding(-1).EncodeToString(append(addr.Payload(), cksm[:]...))
case ID:
i, n, err := varint.FromUvarint(addr.Payload())
if err != nil {
return UndefAddressString, xerrors.Errorf("could not decode varint: %w", err)
}
if n != len(addr.Payload()) {
return UndefAddressString, xerrors.Errorf("payload contains additional bytes")
}
strAddr = fmt.Sprintf("%s%d%d", ntwk, addr.Protocol(), i)
default:
return UndefAddressString, ErrUnknownProtocol
}
return strAddr, nil
}
func decode(a string) (Address, error) {
if len(a) == 0 {
return Undef, nil
}
if a == UndefAddressString {
return Undef, nil
}
if len(a) > MaxAddressStringLength || len(a) < 3 {
return Undef, ErrInvalidLength
}
if string(a[0]) != MainnetPrefix && string(a[0]) != TestnetPrefix {
return Undef, ErrUnknownNetwork
}
var protocol Protocol
switch a[1] {
case '0':
protocol = ID
case '1':
protocol = SECP256K1
case '2':
protocol = Actor
case '3':
protocol = BLS
default:
return Undef, ErrUnknownProtocol
}
raw := a[2:]
if protocol == ID {
// 20 is length of math.MaxUint64 as a string
if len(raw) > 20 {
return Undef, ErrInvalidLength
}
id, err := strconv.ParseUint(raw, 10, 64)
if err != nil {
return Undef, ErrInvalidPayload
}
return newAddress(protocol, varint.ToUvarint(id))
}
payloadcksm, err := AddressEncoding.WithPadding(-1).DecodeString(raw)
if err != nil {
return Undef, err
}
payload := payloadcksm[:len(payloadcksm)-ChecksumHashLength]
cksm := payloadcksm[len(payloadcksm)-ChecksumHashLength:]
if protocol == SECP256K1 || protocol == Actor {
if len(payload) != 20 {
return Undef, ErrInvalidPayload
}
}
if !ValidateChecksum(append([]byte{protocol}, payload...), cksm) {
return Undef, ErrInvalidChecksum
}
return newAddress(protocol, payload)
}
func hash(ingest []byte, cfg *blake2b.Config) []byte {
hasher, err := blake2b.New(cfg)
if err != nil {
// If this happens sth is very wrong.
panic(fmt.Sprintf("invalid address hash configuration: %v", err)) // ok
}
if _, err := hasher.Write(ingest); err != nil {
// blake2bs Write implementation never returns an error in its current
// setup. So if this happens sth went very wrong.
panic(fmt.Sprintf("blake2b is unable to process hashes: %v", err)) // ok
}
return hasher.Sum(nil)
}
func (a Address) MarshalCBOR(w io.Writer) error {
if a == Undef {
return fmt.Errorf("cannot marshal undefined address")
}
abytes := a.Bytes()
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(abytes)))); err != nil {
return err
}
if _, err := w.Write(abytes); err != nil {
return err
}
return nil
}
func (a *Address) UnmarshalCBOR(br io.Reader) error {
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajByteString {
return fmt.Errorf("cbor type for address unmarshal was not byte string")
}
if extra > 64 {
return fmt.Errorf("too many bytes to unmarshal for an address")
}
buf := make([]byte, int(extra))
if _, err := io.ReadFull(br, buf); err != nil {
return err
}
addr, err := NewFromBytes(buf)
if err != nil {
return err
}
if addr == Undef {
return fmt.Errorf("cbor input should not contain empty addresses")
}
*a = addr
return nil
}
func IDFromAddress(addr Address) (uint64, error) {
if addr.Protocol() != ID {
return 0, xerrors.Errorf("cannot get id from non id address")
}
i, _, err := varint.FromUvarint(addr.Payload())
return i, err
}
-542
View File
@@ -1,542 +0,0 @@
package address
import (
"bytes"
"encoding/base32"
"fmt"
"math"
"math/rand"
"strconv"
"testing"
"time"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/multiformats/go-varint"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/lib/crypto"
)
func init() {
rand.Seed(time.Now().Unix())
}
func TestRandomIDAddress(t *testing.T) {
assert := assert.New(t)
addr, err := NewIDAddress(uint64(rand.Int()))
assert.NoError(err)
assert.Equal(ID, addr.Protocol())
str, err := encode(Testnet, addr)
assert.NoError(err)
maybe, err := decode(str)
assert.NoError(err)
assert.Equal(addr, maybe)
}
var allTestAddresses = []string{
"t00",
"t01",
"t010",
"t0150",
"t0499",
"t01024",
"t01729",
"t0999999",
"t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq",
"t12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a",
"t1wbxhu3ypkuo6eyp6hjx6davuelxaxrvwb2kuwva",
"t1xtwapqc6nh4si2hcwpr3656iotzmlwumogqbuaa",
"t1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy",
"t17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy",
"t24vg6ut43yw2h2jqydgbg2xq7x6f4kub3bg6as6i",
"t25nml2cfbljvn4goqtclhifepvfnicv6g7mfmmvq",
"t2nuqrg7vuysaue2pistjjnt3fadsdzvyuatqtfei",
"t24dd4ox4c2vpf5vk5wkadgyyn6qtuvgcpxxon64a",
"t2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y",
"t3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a",
"t3wmuu6crofhqmm3v4enos73okk2l366ck6yc4owxwbdtkmpk42ohkqxfitcpa57pjdcftql4tojda2poeruwa",
"t3s2q2hzhkpiknjgmf4zq3ejab2rh62qbndueslmsdzervrhapxr7dftie4kpnpdiv2n6tvkr743ndhrsw6d3a",
"t3q22fijmmlckhl56rn5nkyamkph3mcfu5ed6dheq53c244hfmnq2i7efdma3cj5voxenwiummf2ajlsbxc65a",
"t3u5zgwa4ael3vuocgc5mfgygo4yuqocrntuuhcklf4xzg5tcaqwbyfabxetwtj4tsam3pbhnwghyhijr5mixa",
}
func TestVectorsIDAddress(t *testing.T) {
testCases := []struct {
input uint64
expected string
}{
{uint64(0), "t00"},
{uint64(1), "t01"},
{uint64(10), "t010"},
{uint64(150), "t0150"},
{uint64(499), "t0499"},
{uint64(1024), "t01024"},
{uint64(1729), "t01729"},
{uint64(999999), "t0999999"},
{math.MaxUint64, fmt.Sprintf("t0%s", strconv.FormatUint(math.MaxUint64, 10))},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing actorID address: %s", tc.expected), func(t *testing.T) {
assert := assert.New(t)
// Round trip encoding and decoding from string
addr, err := NewIDAddress(tc.input)
assert.NoError(err)
assert.Equal(tc.expected, addr.String())
maybeAddr, err := NewFromString(tc.expected)
assert.NoError(err)
assert.Equal(ID, maybeAddr.Protocol())
id, _, err := varint.FromUvarint(maybeAddr.Payload())
assert.NoError(err)
assert.Equal(tc.input, id)
// Round trip to and from bytes
maybeAddrBytes, err := NewFromBytes(maybeAddr.Bytes())
assert.NoError(err)
assert.Equal(maybeAddr, maybeAddrBytes)
// Round trip encoding and decoding json
b, err := addr.MarshalJSON()
assert.NoError(err)
var newAddr Address
err = newAddr.UnmarshalJSON(b)
assert.NoError(err)
assert.Equal(addr, newAddr)
})
}
}
func TestSecp256k1Address(t *testing.T) {
assert := assert.New(t)
sk, err := crypto.GenerateKey()
assert.NoError(err)
addr, err := NewSecp256k1Address(crypto.PublicKey(sk))
assert.NoError(err)
assert.Equal(SECP256K1, addr.Protocol())
str, err := encode(Mainnet, addr)
assert.NoError(err)
maybe, err := decode(str)
assert.NoError(err)
assert.Equal(addr, maybe)
}
func TestVectorSecp256k1Address(t *testing.T) {
testCases := []struct {
input []byte
expected string
}{
{[]byte{4, 148, 2, 250, 195, 126, 100, 50, 164, 22, 163, 160, 202, 84,
38, 181, 24, 90, 179, 178, 79, 97, 52, 239, 162, 92, 228, 135, 200,
45, 46, 78, 19, 191, 69, 37, 17, 224, 210, 36, 84, 33, 248, 97, 59,
193, 13, 114, 250, 33, 102, 102, 169, 108, 59, 193, 57, 32, 211,
255, 35, 63, 208, 188, 5},
"t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq"},
{[]byte{4, 118, 135, 185, 16, 55, 155, 242, 140, 190, 58, 234, 103, 75,
18, 0, 12, 107, 125, 186, 70, 255, 192, 95, 108, 148, 254, 42, 34,
187, 204, 38, 2, 255, 127, 92, 118, 242, 28, 165, 93, 54, 149, 145,
82, 176, 225, 232, 135, 145, 124, 57, 53, 118, 238, 240, 147, 246,
30, 189, 58, 208, 111, 127, 218},
"t12fiakbhe2gwd5cnmrenekasyn6v5tnaxaqizq6a"},
{[]byte{4, 222, 253, 208, 16, 1, 239, 184, 110, 1, 222, 213, 206, 52,
248, 71, 167, 58, 20, 129, 158, 230, 65, 188, 182, 11, 185, 41, 147,
89, 111, 5, 220, 45, 96, 95, 41, 133, 248, 209, 37, 129, 45, 172,
65, 99, 163, 150, 52, 155, 35, 193, 28, 194, 255, 53, 157, 229, 75,
226, 135, 234, 98, 49, 155},
"t1wbxhu3ypkuo6eyp6hjx6davuelxaxrvwb2kuwva"},
{[]byte{4, 3, 237, 18, 200, 20, 182, 177, 13, 46, 224, 157, 149, 180,
104, 141, 178, 209, 128, 208, 169, 163, 122, 107, 106, 125, 182, 61,
41, 129, 30, 233, 115, 4, 121, 216, 239, 145, 57, 233, 18, 73, 202,
189, 57, 50, 145, 207, 229, 210, 119, 186, 118, 222, 69, 227, 224,
133, 163, 118, 129, 191, 54, 69, 210},
"t1xtwapqc6nh4si2hcwpr3656iotzmlwumogqbuaa"},
{[]byte{4, 247, 150, 129, 154, 142, 39, 22, 49, 175, 124, 24, 151, 151,
181, 69, 214, 2, 37, 147, 97, 71, 230, 1, 14, 101, 98, 179, 206, 158,
254, 139, 16, 20, 65, 97, 169, 30, 208, 180, 236, 137, 8, 0, 37, 63,
166, 252, 32, 172, 144, 251, 241, 251, 242, 113, 48, 164, 236, 195,
228, 3, 183, 5, 118},
"t1xcbgdhkgkwht3hrrnui3jdopeejsoatkzmoltqy"},
{[]byte{4, 66, 131, 43, 248, 124, 206, 158, 163, 69, 185, 3, 80, 222,
125, 52, 149, 133, 156, 164, 73, 5, 156, 94, 136, 221, 231, 66, 133,
223, 251, 158, 192, 30, 186, 188, 95, 200, 98, 104, 207, 234, 235,
167, 174, 5, 191, 184, 214, 142, 183, 90, 82, 104, 120, 44, 248, 111,
200, 112, 43, 239, 138, 31, 224},
"t17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy"},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing secp256k1 address: %s", tc.expected), func(t *testing.T) {
assert := assert.New(t)
// Round trip encoding and decoding from string
addr, err := NewSecp256k1Address(tc.input)
assert.NoError(err)
assert.Equal(tc.expected, addr.String())
maybeAddr, err := NewFromString(tc.expected)
assert.NoError(err)
assert.Equal(SECP256K1, maybeAddr.Protocol())
assert.Equal(addressHash(tc.input), maybeAddr.Payload())
// Round trip to and from bytes
maybeAddrBytes, err := NewFromBytes(maybeAddr.Bytes())
assert.NoError(err)
assert.Equal(maybeAddr, maybeAddrBytes)
// Round trip encoding and decoding json
b, err := addr.MarshalJSON()
assert.NoError(err)
var newAddr Address
err = newAddr.UnmarshalJSON(b)
assert.NoError(err)
assert.Equal(addr, newAddr)
})
}
}
func TestRandomActorAddress(t *testing.T) {
assert := assert.New(t)
actorMsg := make([]byte, 20)
rand.Read(actorMsg)
addr, err := NewActorAddress(actorMsg)
assert.NoError(err)
assert.Equal(Actor, addr.Protocol())
str, err := encode(Mainnet, addr)
assert.NoError(err)
maybe, err := decode(str)
assert.NoError(err)
assert.Equal(addr, maybe)
}
func TestVectorActorAddress(t *testing.T) {
testCases := []struct {
input []byte
expected string
}{
{[]byte{118, 18, 129, 144, 205, 240, 104, 209, 65, 128, 68, 172, 192,
62, 11, 103, 129, 151, 13, 96},
"t24vg6ut43yw2h2jqydgbg2xq7x6f4kub3bg6as6i"},
{[]byte{44, 175, 184, 226, 224, 107, 186, 152, 234, 101, 124, 92, 245,
244, 32, 35, 170, 35, 232, 142},
"t25nml2cfbljvn4goqtclhifepvfnicv6g7mfmmvq"},
{[]byte{2, 44, 158, 14, 162, 157, 143, 64, 197, 106, 190, 195, 92, 141,
88, 125, 160, 166, 76, 24},
"t2nuqrg7vuysaue2pistjjnt3fadsdzvyuatqtfei"},
{[]byte{223, 236, 3, 14, 32, 79, 15, 89, 216, 15, 29, 94, 233, 29, 253,
6, 109, 127, 99, 189},
"t24dd4ox4c2vpf5vk5wkadgyyn6qtuvgcpxxon64a"},
{[]byte{61, 58, 137, 232, 221, 171, 84, 120, 50, 113, 108, 109, 70, 140,
53, 96, 201, 244, 127, 216},
"t2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y"},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing Actor address: %s", tc.expected), func(t *testing.T) {
assert := assert.New(t)
// Round trip encoding and decoding from string
addr, err := NewActorAddress(tc.input)
assert.NoError(err)
assert.Equal(tc.expected, addr.String())
maybeAddr, err := NewFromString(tc.expected)
assert.NoError(err)
assert.Equal(Actor, maybeAddr.Protocol())
assert.Equal(addressHash(tc.input), maybeAddr.Payload())
// Round trip to and from bytes
maybeAddrBytes, err := NewFromBytes(maybeAddr.Bytes())
assert.NoError(err)
assert.Equal(maybeAddr, maybeAddrBytes)
// Round trip encoding and decoding json
b, err := addr.MarshalJSON()
assert.NoError(err)
var newAddr Address
err = newAddr.UnmarshalJSON(b)
assert.NoError(err)
assert.Equal(addr, newAddr)
})
}
}
func TestRandomBLSAddress(t *testing.T) {
assert := assert.New(t)
pk := ffi.PrivateKeyPublicKey(ffi.PrivateKeyGenerate())
addr, err := NewBLSAddress(pk[:])
assert.NoError(err)
assert.Equal(BLS, addr.Protocol())
str, err := encode(Mainnet, addr)
assert.NoError(err)
maybe, err := decode(str)
assert.NoError(err)
assert.Equal(addr, maybe)
}
func TestVectorBLSAddress(t *testing.T) {
testCases := []struct {
input []byte
expected string
}{
{[]byte{173, 88, 223, 105, 110, 45, 78, 145, 234, 134, 200, 129, 233, 56,
186, 78, 168, 27, 57, 94, 18, 121, 123, 132, 185, 207, 49, 75, 149, 70,
112, 94, 131, 156, 122, 153, 214, 6, 178, 71, 221, 180, 249, 172, 122,
52, 20, 221},
"t3vvmn62lofvhjd2ugzca6sof2j2ubwok6cj4xxbfzz4yuxfkgobpihhd2thlanmsh3w2ptld2gqkn2jvlss4a"},
{[]byte{179, 41, 79, 10, 46, 41, 224, 198, 110, 188, 35, 93, 47, 237,
202, 86, 151, 191, 120, 74, 246, 5, 199, 90, 246, 8, 230, 166, 61, 92,
211, 142, 168, 92, 168, 152, 158, 14, 253, 233, 24, 139, 56, 47,
147, 114, 70, 13},
"t3wmuu6crofhqmm3v4enos73okk2l366ck6yc4owxwbdtkmpk42ohkqxfitcpa57pjdcftql4tojda2poeruwa"},
{[]byte{150, 161, 163, 228, 234, 122, 20, 212, 153, 133, 230, 97, 178,
36, 1, 212, 79, 237, 64, 45, 29, 9, 37, 178, 67, 201, 35, 88, 156,
15, 188, 126, 50, 205, 4, 226, 158, 215, 141, 21, 211, 125, 58, 170,
63, 230, 218, 51},
"t3s2q2hzhkpiknjgmf4zq3ejab2rh62qbndueslmsdzervrhapxr7dftie4kpnpdiv2n6tvkr743ndhrsw6d3a"},
{[]byte{134, 180, 84, 37, 140, 88, 148, 117, 247, 209, 111, 90, 172, 1,
138, 121, 246, 193, 22, 157, 32, 252, 51, 146, 29, 216, 181, 206, 28,
172, 108, 52, 143, 144, 163, 96, 54, 36, 246, 174, 185, 27, 100, 81,
140, 46, 128, 149},
"t3q22fijmmlckhl56rn5nkyamkph3mcfu5ed6dheq53c244hfmnq2i7efdma3cj5voxenwiummf2ajlsbxc65a"},
{[]byte{167, 114, 107, 3, 128, 34, 247, 90, 56, 70, 23, 88, 83, 96, 206,
230, 41, 7, 10, 45, 157, 40, 113, 41, 101, 229, 242, 110, 204, 64,
133, 131, 130, 128, 55, 36, 237, 52, 242, 114, 3, 54, 240, 157, 182,
49, 240, 116},
"t3u5zgwa4ael3vuocgc5mfgygo4yuqocrntuuhcklf4xzg5tcaqwbyfabxetwtj4tsam3pbhnwghyhijr5mixa"},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing bls address: %s", tc.expected), func(t *testing.T) {
assert := assert.New(t)
// Round trip encoding and decoding from string
addr, err := NewBLSAddress(tc.input)
assert.NoError(err)
assert.Equal(tc.expected, addr.String())
maybeAddr, err := NewFromString(tc.expected)
assert.NoError(err)
assert.Equal(BLS, maybeAddr.Protocol())
assert.Equal(tc.input, maybeAddr.Payload())
// Round trip to and from bytes
maybeAddrBytes, err := NewFromBytes(maybeAddr.Bytes())
assert.NoError(err)
assert.Equal(maybeAddr, maybeAddrBytes)
// Round trip encoding and decoding json
b, err := addr.MarshalJSON()
assert.NoError(err)
var newAddr Address
err = newAddr.UnmarshalJSON(b)
assert.NoError(err)
assert.Equal(addr, newAddr)
})
}
}
func TestInvalidStringAddresses(t *testing.T) {
testCases := []struct {
input string
expetErr error
}{
{"Q2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y", ErrUnknownNetwork},
{"t4gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr23y", ErrUnknownProtocol},
{"t2gfvuyh7v2sx3patm5k23wdzmhyhtmqctasbr24y", ErrInvalidChecksum},
{"t0banananananannnnnnnnn", ErrInvalidLength},
{"t0banananananannnnnnnn", ErrInvalidPayload},
{"t2gfvuyh7v2sx3patm1k23wdzmhyhtmqctasbr24y", base32.CorruptInputError(16)}, // '1' is not in base32 alphabet
{"t2gfvuyh7v2sx3paTm1k23wdzmhyhtmqctasbr24y", base32.CorruptInputError(14)}, // 'T' is not in base32 alphabet
{"t2", ErrInvalidLength},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing string address: %s", tc.expetErr), func(t *testing.T) {
assert := assert.New(t)
_, err := NewFromString(tc.input)
assert.Equal(tc.expetErr, err)
})
}
}
func TestInvalidByteAddresses(t *testing.T) {
testCases := []struct {
input []byte
expetErr error
}{
// Unknown Protocol
{[]byte{4, 4, 4}, ErrUnknownProtocol},
// ID protocol
{[]byte{0}, ErrInvalidLength},
// SECP256K1 Protocol
{append([]byte{1}, make([]byte, PayloadHashLength-1)...), ErrInvalidPayload},
{append([]byte{1}, make([]byte, PayloadHashLength+1)...), ErrInvalidPayload},
// Actor Protocol
{append([]byte{2}, make([]byte, PayloadHashLength-1)...), ErrInvalidPayload},
{append([]byte{2}, make([]byte, PayloadHashLength+1)...), ErrInvalidPayload},
// BLS Protocol
{append([]byte{3}, make([]byte, ffi.PublicKeyBytes-1)...), ErrInvalidPayload},
{append([]byte{3}, make([]byte, ffi.PrivateKeyBytes+1)...), ErrInvalidPayload},
}
for _, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("testing byte address: %s", tc.expetErr), func(t *testing.T) {
assert := assert.New(t)
_, err := NewFromBytes(tc.input)
assert.Equal(tc.expetErr, err)
})
}
}
func TestChecksum(t *testing.T) {
assert := assert.New(t)
data := []byte("helloworld")
bata := []byte("kittinmittins")
cksm := Checksum(data)
assert.Len(cksm, ChecksumHashLength)
assert.True(ValidateChecksum(data, cksm))
assert.False(ValidateChecksum(bata, cksm))
}
func TestAddressFormat(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
a, err := NewActorAddress([]byte("hello"))
require.NoError(err)
assert.Equal("t2wvjry4bx6bwj6kkhcmvgu5zafqyi5cjzbtet3va", a.String())
assert.Equal("02B5531C7037F06C9F2947132A6A77202C308E8939", fmt.Sprintf("%X", a))
assert.Equal("[2 - b5531c7037f06c9f2947132a6a77202c308e8939]", fmt.Sprintf("%v", a))
assert.Equal("", fmt.Sprintf("%X", Undef))
assert.Equal(UndefAddressString, Undef.String())
assert.Equal(UndefAddressString, fmt.Sprintf("%v", Undef))
}
func TestCborMarshal(t *testing.T) {
for _, a := range allTestAddresses {
addr, err := NewFromString(a)
if err != nil {
t.Fatal(err)
}
buf := new(bytes.Buffer)
if err := addr.MarshalCBOR(buf); err != nil {
t.Fatal(err)
}
/*
// Note: this is commented out because we're currently serializing addresses as cbor "text strings", not "byte strings".
// This is to get around the restriction that refmt only allows string keys in maps.
// if you change it to serialize to byte strings and uncomment this, the tests pass fine
oldbytes, err := cbor.DumpObject(addr)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(oldbytes, buf.Bytes()) {
t.Fatalf("serialization doesnt match old serialization: %s", a)
}
*/
var out Address
if err := out.UnmarshalCBOR(buf); err != nil {
t.Fatal(err)
}
if out != addr {
t.Fatalf("failed to round trip %s", a)
}
}
}
func BenchmarkCborMarshal(b *testing.B) {
addr, err := NewFromString("t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq")
if err != nil {
b.Fatal(err)
}
b.ReportAllocs()
b.ResetTimer()
buf := new(bytes.Buffer)
for i := 0; i < b.N; i++ {
buf.Reset()
if err := addr.MarshalCBOR(buf); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkCborUnmarshal(b *testing.B) {
addr, err := NewFromString("t15ihq5ibzwki2b4ep2f46avlkrqzhpqgtga7pdrq")
if err != nil {
b.Fatal(err)
}
buf := new(bytes.Buffer)
if err := addr.MarshalCBOR(buf); err != nil {
b.Fatal(err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
var a Address
if err := a.UnmarshalCBOR(bytes.NewReader(buf.Bytes())); err != nil {
b.Fatal(err)
}
}
}
func TestIDEdgeCase(t *testing.T) {
a, err := NewFromBytes([]byte{0, 0x80})
_ = a.String()
assert.Error(t, err)
}
-94
View File
@@ -1,94 +0,0 @@
package address
import (
"fmt"
"math/rand"
"testing"
)
func blsaddr(n int64) Address {
buf := make([]byte, 48)
r := rand.New(rand.NewSource(n))
r.Read(buf)
addr, err := NewBLSAddress(buf)
if err != nil {
panic(err) // ok
}
return addr
}
func makeActorAddresses(n int) [][]byte {
var addrs [][]byte
for i := 0; i < n; i++ {
a, err := NewActorAddress([]byte(fmt.Sprintf("ACTOR ADDRESS %d", i)))
if err != nil {
panic(err) // ok
}
addrs = append(addrs, a.Bytes())
}
return addrs
}
func makeBlsAddresses(n int64) [][]byte {
var addrs [][]byte
for i := int64(0); i < n; i++ {
addrs = append(addrs, blsaddr(n).Bytes())
}
return addrs
}
func makeSecpAddresses(n int) [][]byte {
var addrs [][]byte
for i := 0; i < n; i++ {
r := rand.New(rand.NewSource(int64(i)))
buf := make([]byte, 32)
r.Read(buf)
a, err := NewSecp256k1Address(buf)
if err != nil {
panic(err) // ok
}
addrs = append(addrs, a.Bytes())
}
return addrs
}
func makeIDAddresses(n int) [][]byte {
var addrs [][]byte
for i := 0; i < n; i++ {
a, err := NewIDAddress(uint64(i))
if err != nil {
panic(err) // ok
}
addrs = append(addrs, a.Bytes())
}
return addrs
}
func BenchmarkParseActorAddress(b *testing.B) {
benchTestWithAddrs := func(a [][]byte) func(b *testing.B) {
return func(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := NewFromBytes(a[i%len(a)])
if err != nil {
b.Fatal(err)
}
}
}
}
b.Run("actor", benchTestWithAddrs(makeActorAddresses(20)))
b.Run("bls", benchTestWithAddrs(makeBlsAddresses(20)))
b.Run("secp256k1", benchTestWithAddrs(makeSecpAddresses(20)))
b.Run("id", benchTestWithAddrs(makeIDAddresses(20)))
}
-65
View File
@@ -1,65 +0,0 @@
package address
import (
"encoding/base32"
"errors"
"github.com/minio/blake2b-simd"
)
func init() {
var err error
TestAddress, err = NewActorAddress([]byte("satoshi"))
if err != nil {
panic(err)
}
TestAddress2, err = NewActorAddress([]byte("nakamoto"))
if err != nil {
panic(err)
}
}
var (
// TestAddress is an account with some initial funds in it.
TestAddress Address
// TestAddress2 is an account with some initial funds in it.
TestAddress2 Address
)
var (
// ErrUnknownNetwork is returned when encountering an unknown network in an address.
ErrUnknownNetwork = errors.New("unknown address network")
// ErrUnknownProtocol is returned when encountering an unknown protocol in an address.
ErrUnknownProtocol = errors.New("unknown address protocol")
// ErrInvalidPayload is returned when encountering an invalid address payload.
ErrInvalidPayload = errors.New("invalid address payload")
// ErrInvalidLength is returned when encountering an address of invalid length.
ErrInvalidLength = errors.New("invalid address length")
// ErrInvalidChecksum is returned when encountering an invalid address checksum.
ErrInvalidChecksum = errors.New("invalid address checksum")
)
// UndefAddressString is the string used to represent an empty address when encoded to a string.
var UndefAddressString = "<empty>"
// PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols.
const PayloadHashLength = 20
// ChecksumHashLength defines the hash length used for calculating address checksums.
const ChecksumHashLength = 4
// MaxAddressStringLength is the max length of an address encoded as a string
// it include the network prefx, protocol, and bls publickey
const MaxAddressStringLength = 2 + 84
var payloadHashConfig = &blake2b.Config{Size: PayloadHashLength}
var checksumHashConfig = &blake2b.Config{Size: ChecksumHashLength}
const encodeStd = "abcdefghijklmnopqrstuvwxyz234567"
// AddressEncoding defines the base32 config used for address encoding and decoding.
var AddressEncoding = base32.NewEncoding(encodeStd)
-20
View File
@@ -1,20 +0,0 @@
package address
import (
"fmt"
)
// NewForTestGetter returns a closure that returns an address unique to that invocation.
// The address is unique wrt the closure returned, not globally.
func NewForTestGetter() func() Address {
i := 0
return func() Address {
s := fmt.Sprintf("address%d", i)
i++
newAddr, err := NewActorAddress([]byte(s))
if err != nil {
panic(err)
}
return newAddr
}
}
+9 -4
View File
@@ -21,10 +21,15 @@ func NewBadBlockCache() *BadBlockCache {
}
}
func (bts *BadBlockCache) Add(c cid.Cid) {
bts.badBlocks.Add(c, nil)
func (bts *BadBlockCache) Add(c cid.Cid, reason string) {
bts.badBlocks.Add(c, reason)
}
func (bts *BadBlockCache) Has(c cid.Cid) bool {
return bts.badBlocks.Contains(c)
func (bts *BadBlockCache) Has(c cid.Cid) (string, bool) {
rval, ok := bts.badBlocks.Get(c)
if !ok {
return "", false
}
return rval.(string), true
}
+89
View File
@@ -0,0 +1,89 @@
package beacon
import (
"context"
"time"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
logging "github.com/ipfs/go-log"
"golang.org/x/xerrors"
)
var log = logging.Logger("beacon")
type Response struct {
Entry types.BeaconEntry
Err error
}
type RandomBeacon interface {
Entry(context.Context, uint64) <-chan Response
VerifyEntry(types.BeaconEntry, types.BeaconEntry) error
MaxBeaconRoundForEpoch(abi.ChainEpoch, types.BeaconEntry) uint64
}
func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.BeaconEntry) error {
maxRound := b.MaxBeaconRoundForEpoch(h.Height, prevEntry)
if maxRound == prevEntry.Round {
if len(h.BeaconEntries) != 0 {
return xerrors.Errorf("expected not to have any beacon entries in this block, got %d", len(h.BeaconEntries))
}
return nil
}
last := h.BeaconEntries[len(h.BeaconEntries)-1]
if last.Round != maxRound {
return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
}
for i, e := range h.BeaconEntries {
if err := b.VerifyEntry(e, prevEntry); err != nil {
return xerrors.Errorf("beacon entry %d (%d - %x (%d)) was invalid: %w", i, e.Round, e.Data, len(e.Data), err)
}
prevEntry = e
}
return nil
}
func BeaconEntriesForBlock(ctx context.Context, beacon RandomBeacon, round abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) {
start := time.Now()
maxRound := beacon.MaxBeaconRoundForEpoch(round, prev)
if maxRound == prev.Round {
return nil, nil
}
// TODO: this is a sketchy way to handle the genesis block not having a beacon entry
if prev.Round == 0 {
prev.Round = maxRound - 1
}
cur := maxRound
var out []types.BeaconEntry
for cur > prev.Round {
rch := beacon.Entry(ctx, cur)
select {
case resp := <-rch:
if resp.Err != nil {
return nil, xerrors.Errorf("beacon entry request returned error: %w", resp.Err)
}
out = append(out, resp.Entry)
cur = resp.Entry.Round - 1
case <-ctx.Done():
return nil, xerrors.Errorf("context timed out waiting on beacon entry to come back for round %d: %w", round, ctx.Err())
}
}
log.Debugw("fetching beacon entries", "took", time.Since(start), "numEntries", len(out))
reverse(out)
return out, nil
}
func reverse(arr []types.BeaconEntry) {
for i := 0; i < len(arr)/2; i++ {
arr[i], arr[len(arr)-(1+i)] = arr[len(arr)-(1+i)], arr[i]
}
}
+192
View File
@@ -0,0 +1,192 @@
package drand
import (
"bytes"
"context"
"sync"
"time"
dchain "github.com/drand/drand/chain"
dclient "github.com/drand/drand/client"
gclient "github.com/drand/drand/cmd/relay-gossip/client"
dlog "github.com/drand/drand/log"
"github.com/drand/kyber"
kzap "github.com/go-kit/kit/log/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/xerrors"
logging "github.com/ipfs/go-log"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
)
var log = logging.Logger("drand")
var drandServers = []string{
"https://pl-eu.testnet.drand.sh",
"https://pl-us.testnet.drand.sh",
"https://pl-sin.testnet.drand.sh",
}
var drandChain *dchain.Info
func init() {
var err error
drandChain, err = dchain.InfoFromJSON(bytes.NewReader([]byte(build.DrandChain)))
if err != nil {
panic("could not unmarshal chain info: " + err.Error())
}
}
type drandPeer struct {
addr string
tls bool
}
func (dp *drandPeer) Address() string {
return dp.addr
}
func (dp *drandPeer) IsTLS() bool {
return dp.tls
}
type DrandBeacon struct {
client dclient.Client
pubkey kyber.Point
// seconds
interval time.Duration
drandGenTime uint64
filGenTime uint64
filRoundTime uint64
cacheLk sync.Mutex
localCache map[uint64]types.BeaconEntry
}
func NewDrandBeacon(genesisTs, interval uint64, ps *pubsub.PubSub) (*DrandBeacon, error) {
if genesisTs == 0 {
panic("what are you doing this cant be zero")
}
dlogger := dlog.NewKitLoggerFrom(kzap.NewZapSugarLogger(
log.SugaredLogger.Desugar(), zapcore.InfoLevel))
opts := []dclient.Option{
dclient.WithChainInfo(drandChain),
dclient.WithHTTPEndpoints(drandServers),
dclient.WithCacheSize(1024),
dclient.WithLogger(dlogger),
}
if ps != nil {
opts = append(opts, gclient.WithPubsub(ps))
} else {
log.Info("drand beacon without pubsub")
}
client, err := dclient.New(opts...)
if err != nil {
return nil, xerrors.Errorf("creating drand client")
}
go func() {
// Explicitly Watch until that is fixed in drand
ch := client.Watch(context.Background())
for range ch {
}
log.Error("dranch Watch bork")
}()
db := &DrandBeacon{
client: client,
localCache: make(map[uint64]types.BeaconEntry),
}
db.pubkey = drandChain.PublicKey
db.interval = drandChain.Period
db.drandGenTime = uint64(drandChain.GenesisTime)
db.filRoundTime = interval
db.filGenTime = genesisTs
return db, nil
}
func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Response {
out := make(chan beacon.Response, 1)
if round != 0 {
be := db.getCachedValue(round)
if be != nil {
out <- beacon.Response{Entry: *be}
close(out)
return out
}
}
go func() {
start := time.Now()
log.Infow("start fetching randomness", "round", round)
resp, err := db.client.Get(ctx, round)
var br beacon.Response
if err != nil {
br.Err = xerrors.Errorf("drand failed Get request: %w", err)
} else {
br.Entry.Round = resp.Round()
br.Entry.Data = resp.Signature()
}
log.Infow("done fetching randomness", "round", round, "took", time.Since(start))
out <- br
close(out)
}()
return out
}
func (db *DrandBeacon) cacheValue(e types.BeaconEntry) {
db.cacheLk.Lock()
defer db.cacheLk.Unlock()
db.localCache[e.Round] = e
}
func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry {
db.cacheLk.Lock()
defer db.cacheLk.Unlock()
v, ok := db.localCache[round]
if !ok {
return nil
}
return &v
}
func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error {
if prev.Round == 0 {
// TODO handle genesis better
return nil
}
b := &dchain.Beacon{
PreviousSig: prev.Data,
Round: curr.Round,
Signature: curr.Data,
}
err := dchain.VerifyBeacon(db.pubkey, b)
if err == nil {
db.cacheValue(curr)
}
return err
}
func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {
// TODO: sometimes the genesis time for filecoin is zero and this goes negative
latestTs := ((uint64(filEpoch) * db.filRoundTime) + db.filGenTime) - db.filRoundTime
dround := (latestTs - db.drandGenTime) / uint64(db.interval.Seconds())
return dround
}
var _ beacon.RandomBeacon = (*DrandBeacon)(nil)
+22
View File
@@ -0,0 +1,22 @@
package drand
import (
"os"
"testing"
dchain "github.com/drand/drand/chain"
dclient "github.com/drand/drand/client"
"github.com/stretchr/testify/assert"
)
func TestPrintGroupInfo(t *testing.T) {
c, err := dclient.NewHTTPClient(drandServers[0], nil, nil)
assert.NoError(t, err)
cg := c.(interface {
FetchChainInfo(groupHash []byte) (*dchain.Info, error)
})
chain, err := cg.FetchChainInfo(nil)
assert.NoError(t, err)
err = chain.ToJSON(os.Stdout)
assert.NoError(t, err)
}
+64
View File
@@ -0,0 +1,64 @@
package beacon
import (
"bytes"
"context"
"encoding/binary"
"time"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/minio/blake2b-simd"
"golang.org/x/xerrors"
)
// Mock beacon assumes that filecoin rounds are 1:1 mapped with the beacon rounds
type mockBeacon struct {
interval time.Duration
}
func NewMockBeacon(interval time.Duration) RandomBeacon {
mb := &mockBeacon{interval: interval}
return mb
}
func (mb *mockBeacon) RoundTime() time.Duration {
return mb.interval
}
func (mb *mockBeacon) entryForIndex(index uint64) types.BeaconEntry {
buf := make([]byte, 8)
binary.BigEndian.PutUint64(buf, index)
rval := blake2b.Sum256(buf)
return types.BeaconEntry{
Round: index,
Data: rval[:],
}
}
func (mb *mockBeacon) Entry(ctx context.Context, index uint64) <-chan Response {
e := mb.entryForIndex(index)
out := make(chan Response, 1)
out <- Response{Entry: e}
return out
}
func (mb *mockBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry) error {
// TODO: cache this, especially for bls
oe := mb.entryForIndex(from.Round)
if !bytes.Equal(from.Data, oe.Data) {
return xerrors.Errorf("mock beacon entry was invalid!")
}
return nil
}
func (mb *mockBeacon) IsEntryForEpoch(e types.BeaconEntry, epoch abi.ChainEpoch, nulls int) (bool, error) {
return int64(e.Round) <= int64(epoch) && int64(epoch)-int64(nulls) >= int64(e.Round), nil
}
func (mb *mockBeacon) MaxBeaconRoundForEpoch(epoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {
return uint64(epoch)
}
var _ RandomBeacon = (*mockBeacon)(nil)
+43 -24
View File
@@ -3,18 +3,18 @@ package blocksync
import (
"bufio"
"context"
"time"
"github.com/libp2p/go-libp2p-core/protocol"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
logging "github.com/ipfs/go-log"
logging "github.com/ipfs/go-log/v2"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
)
@@ -25,11 +25,7 @@ type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream,
const BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
func init() {
cbor.RegisterCborType(BlockSyncRequest{})
cbor.RegisterCborType(BlockSyncResponse{})
cbor.RegisterCborType(BSTipSet{})
}
const BlockSyncMaxRequestLength = 800
type BlockSyncService struct {
cs *store.ChainStore
@@ -55,8 +51,17 @@ func ParseBSOptions(optfield uint64) *BSOptions {
}
const (
BSOptBlocks = 1 << 0
BSOptMessages = 1 << 1
BSOptBlocks = 1 << iota
BSOptMessages
)
const (
StatusOK = uint64(0)
StatusPartial = uint64(101)
StatusNotFound = uint64(201)
StatusGoAway = uint64(202)
StatusInternalError = uint64(203)
StatusBadRequest = uint64(204)
)
type BlockSyncResponse struct {
@@ -86,35 +91,37 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
ctx, span := trace.StartSpan(context.Background(), "blocksync.HandleStream")
defer span.End()
defer s.Close()
defer s.Close() //nolint:errcheck
var req BlockSyncRequest
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
log.Warnf("failed to read block sync request: %s", err)
return
}
log.Infof("block sync request for: %s %d", req.Start, req.RequestLength)
log.Infow("block sync request", "start", req.Start, "len", req.RequestLength)
resp, err := bss.processRequest(ctx, &req)
resp, err := bss.processRequest(ctx, s.Conn().RemotePeer(), &req)
if err != nil {
log.Warn("failed to process block sync request: ", err)
return
}
writeDeadline := 60 * time.Second
_ = s.SetDeadline(time.Now().Add(writeDeadline))
if err := cborutil.WriteCborRPC(s, resp); err != nil {
log.Warn("failed to write back response for handle stream: ", err)
log.Warnw("failed to write back response for handle stream", "err", err, "peer", s.Conn().RemotePeer())
return
}
}
func (bss *BlockSyncService) processRequest(ctx context.Context, req *BlockSyncRequest) (*BlockSyncResponse, error) {
func (bss *BlockSyncService) processRequest(ctx context.Context, p peer.ID, req *BlockSyncRequest) (*BlockSyncResponse, error) {
_, span := trace.StartSpan(ctx, "blocksync.ProcessRequest")
defer span.End()
opts := ParseBSOptions(req.Options)
if len(req.Start) == 0 {
return &BlockSyncResponse{
Status: 204,
Status: StatusBadRequest,
Message: "no cids given in blocksync request",
}, nil
}
@@ -122,35 +129,47 @@ func (bss *BlockSyncService) processRequest(ctx context.Context, req *BlockSyncR
span.AddAttributes(
trace.BoolAttribute("blocks", opts.IncludeBlocks),
trace.BoolAttribute("messages", opts.IncludeMessages),
trace.Int64Attribute("reqlen", int64(req.RequestLength)),
)
chain, err := bss.collectChainSegment(types.NewTipSetKey(req.Start...), req.RequestLength, opts)
reqlen := req.RequestLength
if reqlen > BlockSyncMaxRequestLength {
log.Warnw("limiting blocksync request length", "orig", req.RequestLength, "peer", p)
reqlen = BlockSyncMaxRequestLength
}
chain, err := collectChainSegment(bss.cs, types.NewTipSetKey(req.Start...), reqlen, opts)
if err != nil {
log.Warn("encountered error while responding to block sync request: ", err)
return &BlockSyncResponse{
Status: 203,
Status: StatusInternalError,
Message: err.Error(),
}, nil
}
status := StatusOK
if reqlen < req.RequestLength {
status = StatusPartial
}
return &BlockSyncResponse{
Chain: chain,
Status: 0,
Status: status,
}, nil
}
func (bss *BlockSyncService) collectChainSegment(start types.TipSetKey, length uint64, opts *BSOptions) ([]*BSTipSet, error) {
func collectChainSegment(cs *store.ChainStore, start types.TipSetKey, length uint64, opts *BSOptions) ([]*BSTipSet, error) {
var bstips []*BSTipSet
cur := start
for {
var bst BSTipSet
ts, err := bss.cs.LoadTipSet(cur)
ts, err := cs.LoadTipSet(cur)
if err != nil {
return nil, xerrors.Errorf("failed loading tipset %s: %w", cur, err)
}
if opts.IncludeMessages {
bmsgs, bmincl, smsgs, smincl, err := bss.gatherMessages(ts)
bmsgs, bmincl, smsgs, smincl, err := gatherMessages(cs, ts)
if err != nil {
return nil, xerrors.Errorf("gather messages failed: %w", err)
}
@@ -175,7 +194,7 @@ func (bss *BlockSyncService) collectChainSegment(start types.TipSetKey, length u
}
}
func (bss *BlockSyncService) gatherMessages(ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
func gatherMessages(cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
blsmsgmap := make(map[cid.Cid]uint64)
secpkmsgmap := make(map[cid.Cid]uint64)
var secpkmsgs []*types.SignedMessage
@@ -183,7 +202,7 @@ func (bss *BlockSyncService) gatherMessages(ts *types.TipSet) ([]*types.Message,
var secpkincl, blsincl [][]uint64
for _, b := range ts.Blocks() {
bmsgs, smsgs, err := bss.cs.MessagesForBlock(b)
bmsgs, smsgs, err := cs.MessagesForBlock(b)
if err != nil {
return nil, nil, nil, nil, err
}
+76 -29
View File
@@ -12,47 +12,52 @@ import (
blocks "github.com/ipfs/go-block-format"
bserv "github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid"
graphsync "github.com/ipfs/go-graphsync"
gsnet "github.com/ipfs/go-graphsync/network"
host "github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
incrt "github.com/filecoin-project/lotus/lib/increadtimeout"
"github.com/filecoin-project/lotus/lib/peermgr"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/peermgr"
)
type BlockSync struct {
bserv bserv.BlockService
gsync graphsync.GraphExchange
host host.Host
syncPeers *bsPeerTracker
peerMgr *peermgr.PeerMgr
}
func NewBlockSyncClient(bserv dtypes.ChainBlockService, h host.Host, pmgr peermgr.MaybePeerMgr) *BlockSync {
func NewBlockSyncClient(bserv dtypes.ChainBlockService, h host.Host, pmgr peermgr.MaybePeerMgr, gs dtypes.Graphsync) *BlockSync {
return &BlockSync{
bserv: bserv,
host: h,
syncPeers: newPeerTracker(pmgr.Mgr),
peerMgr: pmgr.Mgr,
gsync: gs,
}
}
func (bs *BlockSync) processStatus(req *BlockSyncRequest, res *BlockSyncResponse) error {
switch res.Status {
case 101: // Partial Response
case StatusPartial: // Partial Response
return xerrors.Errorf("not handling partial blocksync responses yet")
case 201: // req.Start not found
case StatusNotFound: // req.Start not found
return xerrors.Errorf("not found")
case 202: // Go Away
case StatusGoAway: // Go Away
return xerrors.Errorf("not handling 'go away' blocksync responses yet")
case 203: // Internal Error
case StatusInternalError: // Internal Error
return xerrors.Errorf("block sync peer errored: %s", res.Message)
case 204:
case StatusBadRequest:
return xerrors.Errorf("block sync request invalid: %s", res.Message)
default:
return xerrors.Errorf("unrecognized response code: %d", res.Status)
@@ -100,7 +105,7 @@ func (bs *BlockSync) GetBlocks(ctx context.Context, tsk types.TipSetKey, count i
continue
}
if res.Status == 0 {
if res.Status == StatusOK || res.Status == StatusPartial {
resp, err := bs.processBlocksResponse(req, res)
if err != nil {
return nil, xerrors.Errorf("success response from peer failed to process: %w", err)
@@ -109,6 +114,7 @@ func (bs *BlockSync) GetBlocks(ctx context.Context, tsk types.TipSetKey, count i
bs.host.ConnManager().TagPeer(p, "bsync", 25)
return resp, nil
}
oerr = bs.processStatus(req, res)
if oerr != nil {
log.Warnf("BlockSync peer %s response was an error: %s", p.String(), oerr)
@@ -140,7 +146,7 @@ func (bs *BlockSync) GetFullTipSet(ctx context.Context, p peer.ID, tsk types.Tip
return bstsToFullTipSet(bts)
case 101: // Partial Response
return nil, xerrors.Errorf("partial responses are not handled")
return nil, xerrors.Errorf("partial responses are not handled for single tipset fetching")
case 201: // req.Start not found
return nil, fmt.Errorf("not found")
case 202: // Go Away
@@ -180,7 +186,7 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun
req := &BlockSyncRequest{
Start: h.Cids(),
RequestLength: count,
Options: BSOptMessages | BSOptBlocks,
Options: BSOptMessages,
}
var err error
@@ -194,11 +200,16 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun
continue
}
if res.Status == 0 {
if res.Status == StatusOK {
bs.syncPeers.logGlobalSuccess(time.Since(start))
return res.Chain, nil
}
if res.Status == StatusPartial {
// TODO: track partial response sizes to ensure we don't overrequest too often
return res.Chain, nil
}
err = bs.processStatus(req, res)
if err != nil {
log.Warnf("BlockSync peer %s response was an error: %s", p.String(), err)
@@ -228,29 +239,62 @@ func (bs *BlockSync) sendRequestToPeer(ctx context.Context, p peer.ID, req *Bloc
}
}()
start := time.Now()
if span.IsRecordingEvents() {
span.AddAttributes(
trace.StringAttribute("peer", p.Pretty()),
)
}
gsproto := string(gsnet.ProtocolGraphsync)
supp, err := bs.host.Peerstore().SupportsProtocols(p, BlockSyncProtocolID, gsproto)
if err != nil {
return nil, xerrors.Errorf("failed to get protocols for peer: %w", err)
}
if len(supp) == 0 {
return nil, xerrors.Errorf("peer %s supports no known sync protocols", p)
}
switch supp[0] {
case BlockSyncProtocolID:
res, err := bs.fetchBlocksBlockSync(ctx, p, req)
if err != nil {
return nil, xerrors.Errorf("blocksync req failed: %w", err)
}
return res, nil
case gsproto:
res, err := bs.fetchBlocksGraphSync(ctx, p, req)
if err != nil {
return nil, xerrors.Errorf("graphsync req failed: %w", err)
}
return res, nil
default:
return nil, xerrors.Errorf("peerstore somehow returned unexpected protocols: %v", supp)
}
}
func (bs *BlockSync) fetchBlocksBlockSync(ctx context.Context, p peer.ID, req *BlockSyncRequest) (*BlockSyncResponse, error) {
ctx, span := trace.StartSpan(ctx, "blockSyncFetch")
defer span.End()
start := time.Now()
s, err := bs.host.NewStream(inet.WithNoDial(ctx, "should already have connection"), p, BlockSyncProtocolID)
if err != nil {
bs.RemovePeer(p)
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
}
s.SetDeadline(time.Now().Add(10 * time.Second))
defer s.SetDeadline(time.Time{})
_ = s.SetWriteDeadline(time.Now().Add(5 * time.Second))
if err := cborutil.WriteCborRPC(s, req); err != nil {
_ = s.SetWriteDeadline(time.Time{})
bs.syncPeers.logFailure(p, time.Since(start))
return nil, err
}
_ = s.SetWriteDeadline(time.Time{})
var res BlockSyncResponse
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &res); err != nil {
r := incrt.New(s, 50<<10, 5*time.Second)
if err := cborutil.ReadCborRPC(bufio.NewReader(r), &res); err != nil {
bs.syncPeers.logFailure(p, time.Since(start))
return nil, err
}
@@ -264,7 +308,6 @@ func (bs *BlockSync) sendRequestToPeer(ctx context.Context, p peer.ID, req *Bloc
}
bs.syncPeers.logSuccess(p, time.Since(start))
return &res, nil
}
@@ -455,7 +498,7 @@ func (bpt *bsPeerTracker) prefSortedPeers() []peer.ID {
getPeerInitLat := func(p peer.ID) float64 {
var res float64
if bpt.pmgr != nil {
if lat, ok := bpt.pmgr.GetPeerLatency(out[i]); ok {
if lat, ok := bpt.pmgr.GetPeerLatency(p); ok {
res = float64(lat)
}
}
@@ -476,7 +519,7 @@ func (bpt *bsPeerTracker) prefSortedPeers() []peer.ID {
failRateJ := float64(pj.failures) / float64(pj.failures+pj.successes)
costJ = float64(pj.averageTime) + failRateJ*float64(bpt.avgGlobalTime)
} else {
costI = getPeerInitLat(out[i])
costJ = getPeerInitLat(out[j])
}
return costI < costJ
@@ -518,26 +561,30 @@ func (bpt *bsPeerTracker) logSuccess(p peer.ID, dur time.Duration) {
bpt.lk.Lock()
defer bpt.lk.Unlock()
if pi, ok := bpt.peers[p]; !ok {
var pi *peerStats
var ok bool
if pi, ok = bpt.peers[p]; !ok {
log.Warnw("log success called on peer not in tracker", "peerid", p.String())
return
} else {
pi.successes++
logTime(pi, dur)
}
pi.successes++
logTime(pi, dur)
}
func (bpt *bsPeerTracker) logFailure(p peer.ID, dur time.Duration) {
bpt.lk.Lock()
defer bpt.lk.Unlock()
if pi, ok := bpt.peers[p]; !ok {
var pi *peerStats
var ok bool
if pi, ok = bpt.peers[p]; !ok {
log.Warn("log failure called on peer not in tracker", "peerid", p.String())
return
} else {
pi.failures++
logTime(pi, dur)
}
pi.failures++
logTime(pi, dur)
}
func (bpt *bsPeerTracker) removePeer(p peer.ID) {
+110 -61
View File
@@ -1,3 +1,5 @@
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package blocksync
import (
@@ -5,54 +7,60 @@ import (
"io"
"github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
var _ = xerrors.Errorf
var lengthBufBlockSyncRequest = []byte{131}
func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{131}); err != nil {
if _, err := w.Write(lengthBufBlockSyncRequest); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Start ([]cid.Cid) (slice)
if len(t.Start) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Start was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Start)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Start))); err != nil {
return err
}
for _, v := range t.Start {
if err := cbg.WriteCid(w, v); err != nil {
if err := cbg.WriteCidBuf(scratch, w, v); err != nil {
return xerrors.Errorf("failed writing cid field t.Start: %w", err)
}
}
// t.RequestLength (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.RequestLength))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.RequestLength)); err != nil {
return err
}
// t.Options (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Options))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Options)); err != nil {
return err
}
return nil
}
func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -66,7 +74,7 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
// t.Start ([]cid.Cid) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -78,9 +86,11 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Start = make([]cid.Cid, extra)
}
for i := 0; i < int(extra); i++ {
c, err := cbg.ReadCid(br)
@@ -92,42 +102,54 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
// t.RequestLength (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.RequestLength = uint64(extra)
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.RequestLength = uint64(extra)
// t.Options (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Options = uint64(extra)
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Options = uint64(extra)
return nil
}
var lengthBufBlockSyncResponse = []byte{131}
func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{131}); err != nil {
if _, err := w.Write(lengthBufBlockSyncResponse); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Chain ([]*blocksync.BSTipSet) (slice)
if len(t.Chain) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Chain was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Chain)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Chain))); err != nil {
return err
}
for _, v := range t.Chain {
@@ -137,7 +159,8 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
}
// t.Status (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Status)); err != nil {
return err
}
@@ -146,10 +169,10 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field t.Message was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len(t.Message))); err != nil {
return err
}
if _, err := w.Write([]byte(t.Message)); err != nil {
if _, err := io.WriteString(w, t.Message); err != nil {
return err
}
return nil
@@ -157,8 +180,9 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -172,7 +196,7 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
// t.Chain ([]*blocksync.BSTipSet) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -184,9 +208,11 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Chain = make([]*BSTipSet, extra)
}
for i := 0; i < int(extra); i++ {
var v BSTipSet
@@ -199,18 +225,22 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
// t.Status (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Status = uint64(extra)
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Status = uint64(extra)
// t.Message (string) (string)
{
sval, err := cbg.ReadString(br)
sval, err := cbg.ReadStringBuf(br, scratch)
if err != nil {
return err
}
@@ -220,21 +250,25 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
return nil
}
var lengthBufBSTipSet = []byte{133}
func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{133}); err != nil {
if _, err := w.Write(lengthBufBSTipSet); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Blocks ([]*types.BlockHeader) (slice)
if len(t.Blocks) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Blocks was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Blocks)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Blocks))); err != nil {
return err
}
for _, v := range t.Blocks {
@@ -248,7 +282,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.BlsMessages was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMessages)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.BlsMessages))); err != nil {
return err
}
for _, v := range t.BlsMessages {
@@ -262,7 +296,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.BlsMsgIncludes was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMsgIncludes)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.BlsMsgIncludes))); err != nil {
return err
}
for _, v := range t.BlsMsgIncludes {
@@ -270,11 +304,11 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field v was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(v)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(v))); err != nil {
return err
}
for _, v := range v {
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil {
return err
}
}
@@ -285,7 +319,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.SecpkMessages was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMessages)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.SecpkMessages))); err != nil {
return err
}
for _, v := range t.SecpkMessages {
@@ -299,7 +333,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.SecpkMsgIncludes was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMsgIncludes)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.SecpkMsgIncludes))); err != nil {
return err
}
for _, v := range t.SecpkMsgIncludes {
@@ -307,11 +341,11 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field v was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(v)))); err != nil {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(v))); err != nil {
return err
}
for _, v := range v {
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, v); err != nil {
if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil {
return err
}
}
@@ -321,8 +355,9 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
maj, extra, err := cbg.CborReadHeader(br)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -336,7 +371,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
// t.Blocks ([]*types.BlockHeader) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -348,9 +383,11 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.Blocks = make([]*types.BlockHeader, extra)
}
for i := 0; i < int(extra); i++ {
var v types.BlockHeader
@@ -363,7 +400,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
// t.BlsMessages ([]*types.Message) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -375,9 +412,11 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.BlsMessages = make([]*types.Message, extra)
}
for i := 0; i < int(extra); i++ {
var v types.Message
@@ -390,7 +429,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
// t.BlsMsgIncludes ([][]uint64) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -402,16 +441,18 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.BlsMsgIncludes = make([][]uint64, extra)
}
for i := 0; i < int(extra); i++ {
{
var maj byte
var extra uint64
var err error
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -423,12 +464,14 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.BlsMsgIncludes[i] = make([]uint64, extra)
}
for j := 0; j < int(extra); j++ {
maj, val, err := cbg.CborReadHeader(br)
maj, val, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return xerrors.Errorf("failed to read uint64 for t.BlsMsgIncludes[i] slice: %w", err)
}
@@ -437,7 +480,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
return xerrors.Errorf("value read for array t.BlsMsgIncludes[i] was not a uint, instead got %d", maj)
}
t.BlsMsgIncludes[i][j] = val
t.BlsMsgIncludes[i][j] = uint64(val)
}
}
@@ -445,7 +488,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
// t.SecpkMessages ([]*types.SignedMessage) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -457,9 +500,11 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.SecpkMessages = make([]*types.SignedMessage, extra)
}
for i := 0; i < int(extra); i++ {
var v types.SignedMessage
@@ -472,7 +517,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
// t.SecpkMsgIncludes ([][]uint64) (slice)
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -484,16 +529,18 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.SecpkMsgIncludes = make([][]uint64, extra)
}
for i := 0; i < int(extra); i++ {
{
var maj byte
var extra uint64
var err error
maj, extra, err = cbg.CborReadHeader(br)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return err
}
@@ -505,12 +552,14 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
if extra > 0 {
t.SecpkMsgIncludes[i] = make([]uint64, extra)
}
for j := 0; j < int(extra); j++ {
maj, val, err := cbg.CborReadHeader(br)
maj, val, err := cbg.CborReadHeaderBuf(br, scratch)
if err != nil {
return xerrors.Errorf("failed to read uint64 for t.SecpkMsgIncludes[i] slice: %w", err)
}
@@ -519,7 +568,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
return xerrors.Errorf("value read for array t.SecpkMsgIncludes[i] was not a uint, instead got %d", maj)
}
t.SecpkMsgIncludes[i][j] = val
t.SecpkMsgIncludes[i][j] = uint64(val)
}
}
+151
View File
@@ -0,0 +1,151 @@
package blocksync
import (
"context"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-graphsync"
"github.com/ipld/go-ipld-prime"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
store "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
basicnode "github.com/ipld/go-ipld-prime/node/basic"
ipldselector "github.com/ipld/go-ipld-prime/traversal/selector"
selectorbuilder "github.com/ipld/go-ipld-prime/traversal/selector/builder"
)
const (
// AMT selector recursion. An AMT has arity of 8 so this gives allows
// us to retrieve trees with 8^10 (1,073,741,824) elements.
amtRecursionDepth = uint32(10)
// some constants for looking up tuple encoded struct fields
// field index of Parents field in a block header
blockIndexParentsField = 5
// field index of Messages field in a block header
blockIndexMessagesField = 10
// field index of AMT node in AMT head
amtHeadNodeFieldIndex = 2
// field index of links array AMT node
amtNodeLinksFieldIndex = 1
// field index of values array AMT node
amtNodeValuesFieldIndex = 2
// maximum depth per traversal
maxRequestLength = 50
)
var amtSelector selectorbuilder.SelectorSpec
func init() {
// builer for selectors
ssb := selectorbuilder.NewSelectorSpecBuilder(basicnode.Style.Any)
// amt selector -- needed to selector through a messages AMT
amtSelector = ssb.ExploreIndex(amtHeadNodeFieldIndex,
ssb.ExploreRecursive(ipldselector.RecursionLimitDepth(int(amtRecursionDepth)),
ssb.ExploreUnion(
ssb.ExploreIndex(amtNodeLinksFieldIndex,
ssb.ExploreAll(ssb.ExploreRecursiveEdge())),
ssb.ExploreIndex(amtNodeValuesFieldIndex,
ssb.ExploreAll(ssb.Matcher())))))
}
func selectorForRequest(req *BlockSyncRequest) ipld.Node {
// builer for selectors
ssb := selectorbuilder.NewSelectorSpecBuilder(basicnode.Style.Any)
bso := ParseBSOptions(req.Options)
if bso.IncludeMessages {
return ssb.ExploreRecursive(ipldselector.RecursionLimitDepth(int(req.RequestLength)),
ssb.ExploreIndex(blockIndexParentsField,
ssb.ExploreUnion(
ssb.ExploreAll(
ssb.ExploreIndex(blockIndexMessagesField,
ssb.ExploreRange(0, 2, amtSelector),
)),
ssb.ExploreIndex(0, ssb.ExploreRecursiveEdge()),
))).Node()
}
return ssb.ExploreRecursive(ipldselector.RecursionLimitDepth(int(req.RequestLength)), ssb.ExploreIndex(blockIndexParentsField,
ssb.ExploreUnion(
ssb.ExploreAll(
ssb.Matcher(),
),
ssb.ExploreIndex(0, ssb.ExploreRecursiveEdge()),
))).Node()
}
func firstTipsetSelector(req *BlockSyncRequest) ipld.Node {
// builer for selectors
ssb := selectorbuilder.NewSelectorSpecBuilder(basicnode.Style.Any)
bso := ParseBSOptions(req.Options)
if bso.IncludeMessages {
return ssb.ExploreIndex(blockIndexMessagesField,
ssb.ExploreRange(0, 2, amtSelector),
).Node()
}
return ssb.Matcher().Node()
}
func (bs *BlockSync) executeGsyncSelector(ctx context.Context, p peer.ID, root cid.Cid, sel ipld.Node) error {
extension := graphsync.ExtensionData{
Name: "chainsync",
Data: nil,
}
_, errs := bs.gsync.Request(ctx, p, cidlink.Link{Cid: root}, sel, extension)
for err := range errs {
return xerrors.Errorf("failed to complete graphsync request: %w", err)
}
return nil
}
// Fallback for interacting with other non-lotus nodes
func (bs *BlockSync) fetchBlocksGraphSync(ctx context.Context, p peer.ID, req *BlockSyncRequest) (*BlockSyncResponse, error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
immediateTsSelector := firstTipsetSelector(req)
// Do this because we can only request one root at a time
for _, r := range req.Start {
if err := bs.executeGsyncSelector(ctx, p, r, immediateTsSelector); err != nil {
return nil, err
}
}
if req.RequestLength > maxRequestLength {
req.RequestLength = maxRequestLength
}
sel := selectorForRequest(req)
// execute the selector forreal
if err := bs.executeGsyncSelector(ctx, p, req.Start[0], sel); err != nil {
return nil, err
}
// Now pull the data we fetched out of the chainstore (where it should now be persisted)
tempcs := store.NewChainStore(bs.bserv.Blockstore(), datastore.NewMapDatastore(), nil)
opts := ParseBSOptions(req.Options)
tsk := types.NewTipSetKey(req.Start...)
chain, err := collectChainSegment(tempcs, tsk, req.RequestLength, opts)
if err != nil {
return nil, xerrors.Errorf("failed to load chain data from chainstore after successful graphsync response (start = %v): %w", req.Start, err)
}
return &BlockSyncResponse{Chain: chain}, nil
}
-883
View File
@@ -1,883 +0,0 @@
package deals
import (
"fmt"
"io"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
var _ = xerrors.Errorf
func (t *AskRequest) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{129}); err != nil {
return err
}
// t.Miner (address.Address) (struct)
if err := t.Miner.MarshalCBOR(w); err != nil {
return err
}
return nil
}
func (t *AskRequest) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 1 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Miner (address.Address) (struct)
{
if err := t.Miner.UnmarshalCBOR(br); err != nil {
return err
}
}
return nil
}
func (t *AskResponse) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{129}); err != nil {
return err
}
// t.Ask (types.SignedStorageAsk) (struct)
if err := t.Ask.MarshalCBOR(w); err != nil {
return err
}
return nil
}
func (t *AskResponse) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 1 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Ask (types.SignedStorageAsk) (struct)
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.Ask = new(types.SignedStorageAsk)
if err := t.Ask.UnmarshalCBOR(br); err != nil {
return err
}
}
}
return nil
}
func (t *Proposal) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{130}); err != nil {
return err
}
// t.DealProposal (actors.StorageDealProposal) (struct)
if err := t.DealProposal.MarshalCBOR(w); err != nil {
return err
}
// t.Piece (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.Piece); err != nil {
return xerrors.Errorf("failed to write cid field t.Piece: %w", err)
}
return nil
}
func (t *Proposal) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.DealProposal (actors.StorageDealProposal) (struct)
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.DealProposal = new(actors.StorageDealProposal)
if err := t.DealProposal.UnmarshalCBOR(br); err != nil {
return err
}
}
}
// t.Piece (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Piece: %w", err)
}
t.Piece = c
}
return nil
}
func (t *Response) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{132}); err != nil {
return err
}
// t.State (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
return err
}
// t.Message (string) (string)
if len(t.Message) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Message was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.Message)); err != nil {
return err
}
// t.Proposal (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.Proposal); err != nil {
return xerrors.Errorf("failed to write cid field t.Proposal: %w", err)
}
// t.StorageDealSubmission (types.SignedMessage) (struct)
if err := t.StorageDealSubmission.MarshalCBOR(w); err != nil {
return err
}
return nil
}
func (t *Response) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 4 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.State (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.State = uint64(extra)
// t.Message (string) (string)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
t.Message = string(sval)
}
// t.Proposal (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Proposal: %w", err)
}
t.Proposal = c
}
// t.StorageDealSubmission (types.SignedMessage) (struct)
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.StorageDealSubmission = new(types.SignedMessage)
if err := t.StorageDealSubmission.UnmarshalCBOR(br); err != nil {
return err
}
}
}
return nil
}
func (t *SignedResponse) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{130}); err != nil {
return err
}
// t.Response (deals.Response) (struct)
if err := t.Response.MarshalCBOR(w); err != nil {
return err
}
// t.Signature (types.Signature) (struct)
if err := t.Signature.MarshalCBOR(w); err != nil {
return err
}
return nil
}
func (t *SignedResponse) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Response (deals.Response) (struct)
{
if err := t.Response.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.Signature (types.Signature) (struct)
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.Signature = new(types.Signature)
if err := t.Signature.UnmarshalCBOR(br); err != nil {
return err
}
}
}
return nil
}
func (t *ClientDealProposal) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{136}); err != nil {
return err
}
// t.Data (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.Data); err != nil {
return xerrors.Errorf("failed to write cid field t.Data: %w", err)
}
// t.PricePerEpoch (types.BigInt) (struct)
if err := t.PricePerEpoch.MarshalCBOR(w); err != nil {
return err
}
// t.ProposalExpiration (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil {
return err
}
// t.Duration (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil {
return err
}
// t.ProviderAddress (address.Address) (struct)
if err := t.ProviderAddress.MarshalCBOR(w); err != nil {
return err
}
// t.Client (address.Address) (struct)
if err := t.Client.MarshalCBOR(w); err != nil {
return err
}
// t.MinerWorker (address.Address) (struct)
if err := t.MinerWorker.MarshalCBOR(w); err != nil {
return err
}
// t.MinerID (peer.ID) (string)
if len(t.MinerID) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.MinerID was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.MinerID)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.MinerID)); err != nil {
return err
}
return nil
}
func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 8 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Data (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Data: %w", err)
}
t.Data = c
}
// t.PricePerEpoch (types.BigInt) (struct)
{
if err := t.PricePerEpoch.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.ProposalExpiration (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.ProposalExpiration = uint64(extra)
// t.Duration (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Duration = uint64(extra)
// t.ProviderAddress (address.Address) (struct)
{
if err := t.ProviderAddress.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.Client (address.Address) (struct)
{
if err := t.Client.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.MinerWorker (address.Address) (struct)
{
if err := t.MinerWorker.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.MinerID (peer.ID) (string)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
t.MinerID = peer.ID(sval)
}
return nil
}
func (t *ClientDeal) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{135}); err != nil {
return err
}
// t.ProposalCid (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.ProposalCid); err != nil {
return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err)
}
// t.Proposal (actors.StorageDealProposal) (struct)
if err := t.Proposal.MarshalCBOR(w); err != nil {
return err
}
// t.State (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
return err
}
// t.Miner (peer.ID) (string)
if len(t.Miner) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Miner was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Miner)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.Miner)); err != nil {
return err
}
// t.MinerWorker (address.Address) (struct)
if err := t.MinerWorker.MarshalCBOR(w); err != nil {
return err
}
// t.DealID (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
return err
}
// t.PublishMessage (types.SignedMessage) (struct)
if err := t.PublishMessage.MarshalCBOR(w); err != nil {
return err
}
return nil
}
func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 7 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.ProposalCid (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.ProposalCid: %w", err)
}
t.ProposalCid = c
}
// t.Proposal (actors.StorageDealProposal) (struct)
{
if err := t.Proposal.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.State (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.State = uint64(extra)
// t.Miner (peer.ID) (string)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
t.Miner = peer.ID(sval)
}
// t.MinerWorker (address.Address) (struct)
{
if err := t.MinerWorker.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.DealID (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.DealID = uint64(extra)
// t.PublishMessage (types.SignedMessage) (struct)
{
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.PublishMessage = new(types.SignedMessage)
if err := t.PublishMessage.UnmarshalCBOR(br); err != nil {
return err
}
}
}
return nil
}
func (t *MinerDeal) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{135}); err != nil {
return err
}
// t.Client (peer.ID) (string)
if len(t.Client) > cbg.MaxLength {
return xerrors.Errorf("Value in field t.Client was too long")
}
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Client)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.Client)); err != nil {
return err
}
// t.Proposal (actors.StorageDealProposal) (struct)
if err := t.Proposal.MarshalCBOR(w); err != nil {
return err
}
// t.ProposalCid (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.ProposalCid); err != nil {
return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err)
}
// t.State (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
return err
}
// t.Ref (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.Ref); err != nil {
return xerrors.Errorf("failed to write cid field t.Ref: %w", err)
}
// t.DealID (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
return err
}
// t.SectorID (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
return err
}
return nil
}
func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 7 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Client (peer.ID) (string)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
t.Client = peer.ID(sval)
}
// t.Proposal (actors.StorageDealProposal) (struct)
{
if err := t.Proposal.UnmarshalCBOR(br); err != nil {
return err
}
}
// t.ProposalCid (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.ProposalCid: %w", err)
}
t.ProposalCid = c
}
// t.State (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.State = uint64(extra)
// t.Ref (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Ref: %w", err)
}
t.Ref = c
}
// t.DealID (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.DealID = uint64(extra)
// t.SectorID (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.SectorID = uint64(extra)
return nil
}
func (t *StorageDataTransferVoucher) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{130}); err != nil {
return err
}
// t.Proposal (cid.Cid) (struct)
if err := cbg.WriteCid(w, t.Proposal); err != nil {
return xerrors.Errorf("failed to write cid field t.Proposal: %w", err)
}
// t.DealID (uint64) (uint64)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
return err
}
return nil
}
func (t *StorageDataTransferVoucher) UnmarshalCBOR(r io.Reader) error {
br := cbg.GetPeeker(r)
maj, extra, err := cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajArray {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.Proposal (cid.Cid) (struct)
{
c, err := cbg.ReadCid(br)
if err != nil {
return xerrors.Errorf("failed to read cid field t.Proposal: %w", err)
}
t.Proposal = c
}
// t.DealID (uint64) (uint64)
maj, extra, err = cbg.CborReadHeader(br)
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.DealID = uint64(extra)
return nil
}
-311
View File
@@ -1,311 +0,0 @@
package deals
import (
"context"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
"github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/events"
"github.com/filecoin-project/lotus/chain/market"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/statestore"
"github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/retrieval/discovery"
)
var log = logging.Logger("deals")
type ClientDeal struct {
ProposalCid cid.Cid
Proposal actors.StorageDealProposal
State api.DealState
Miner peer.ID
MinerWorker address.Address
DealID uint64
PublishMessage *types.SignedMessage
s inet.Stream
}
type Client struct {
sm *stmgr.StateManager
chain *store.ChainStore
h host.Host
w *wallet.Wallet
// dataTransfer
// TODO: once the data transfer module is complete, the
// client will listen to events on the data transfer module
// Because we are using only a fake DAGService
// implementation, there's no validation or events on the client side
dataTransfer dtypes.ClientDataTransfer
dag dtypes.ClientDAG
discovery *discovery.Local
events *events.Events
fm *market.FundMgr
deals *statestore.StateStore
conns map[cid.Cid]inet.Stream
incoming chan *ClientDeal
updated chan clientDealUpdate
stop chan struct{}
stopped chan struct{}
}
type clientDealUpdate struct {
newState api.DealState
id cid.Cid
err error
mut func(*ClientDeal)
}
type clientApi struct {
full.ChainAPI
full.StateAPI
}
func NewClient(sm *stmgr.StateManager, chain *store.ChainStore, h host.Host, w *wallet.Wallet, dag dtypes.ClientDAG, dataTransfer dtypes.ClientDataTransfer, discovery *discovery.Local, fm *market.FundMgr, deals dtypes.ClientDealStore, chainapi full.ChainAPI, stateapi full.StateAPI) *Client {
c := &Client{
sm: sm,
chain: chain,
h: h,
w: w,
dataTransfer: dataTransfer,
dag: dag,
discovery: discovery,
fm: fm,
events: events.NewEvents(context.TODO(), &clientApi{chainapi, stateapi}),
deals: deals,
conns: map[cid.Cid]inet.Stream{},
incoming: make(chan *ClientDeal, 16),
updated: make(chan clientDealUpdate, 16),
stop: make(chan struct{}),
stopped: make(chan struct{}),
}
return c
}
func (c *Client) Run(ctx context.Context) {
go func() {
defer close(c.stopped)
for {
select {
case deal := <-c.incoming:
c.onIncoming(deal)
case update := <-c.updated:
c.onUpdated(ctx, update)
case <-c.stop:
return
}
}
}()
}
func (c *Client) onIncoming(deal *ClientDeal) {
log.Info("incoming deal")
if _, ok := c.conns[deal.ProposalCid]; ok {
log.Errorf("tracking deal connection: already tracking connection for deal %s", deal.ProposalCid)
return
}
c.conns[deal.ProposalCid] = deal.s
if err := c.deals.Begin(deal.ProposalCid, deal); err != nil {
// We may have re-sent the proposal
log.Errorf("deal tracking failed: %s", err)
c.failDeal(deal.ProposalCid, err)
return
}
go func() {
c.updated <- clientDealUpdate{
newState: api.DealUnknown,
id: deal.ProposalCid,
err: nil,
}
}()
}
func (c *Client) onUpdated(ctx context.Context, update clientDealUpdate) {
log.Infof("Client deal %s updated state to %s", update.id, api.DealStates[update.newState])
var deal ClientDeal
err := c.deals.Mutate(update.id, func(d *ClientDeal) error {
d.State = update.newState
if update.mut != nil {
update.mut(d)
}
deal = *d
return nil
})
if update.err != nil {
log.Errorf("deal %s failed: %s", update.id, update.err)
c.failDeal(update.id, update.err)
return
}
if err != nil {
c.failDeal(update.id, err)
return
}
switch update.newState {
case api.DealUnknown: // new
c.handle(ctx, deal, c.new, api.DealAccepted)
case api.DealAccepted:
c.handle(ctx, deal, c.accepted, api.DealStaged)
case api.DealStaged:
c.handle(ctx, deal, c.staged, api.DealSealing)
case api.DealSealing:
c.handle(ctx, deal, c.sealing, api.DealNoUpdate)
// TODO: DealComplete -> watch for faults, expiration, etc.
}
}
type ClientDealProposal struct {
Data cid.Cid
PricePerEpoch types.BigInt
ProposalExpiration uint64
Duration uint64
ProviderAddress address.Address
Client address.Address
MinerWorker address.Address
MinerID peer.ID
}
func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, error) {
if err := c.fm.EnsureAvailable(ctx, p.Client, types.BigMul(p.PricePerEpoch, types.NewInt(p.Duration))); err != nil {
return cid.Undef, xerrors.Errorf("adding market funds failed: %w", err)
}
commP, pieceSize, err := c.commP(ctx, p.Data)
if err != nil {
return cid.Undef, xerrors.Errorf("computing commP failed: %w", err)
}
dealProposal := &actors.StorageDealProposal{
PieceRef: commP,
PieceSize: uint64(pieceSize),
Client: p.Client,
Provider: p.ProviderAddress,
ProposalExpiration: p.ProposalExpiration,
Duration: p.Duration,
StoragePricePerEpoch: p.PricePerEpoch,
StorageCollateral: types.NewInt(uint64(pieceSize)), // TODO: real calc
}
if err := api.SignWith(ctx, c.w.Sign, p.Client, dealProposal); err != nil {
return cid.Undef, xerrors.Errorf("signing deal proposal failed: %w", err)
}
proposalNd, err := cborutil.AsIpld(dealProposal)
if err != nil {
return cid.Undef, xerrors.Errorf("getting proposal node failed: %w", err)
}
s, err := c.h.NewStream(ctx, p.MinerID, DealProtocolID)
if err != nil {
return cid.Undef, xerrors.Errorf("connecting to storage provider failed: %w", err)
}
proposal := &Proposal{
DealProposal: dealProposal,
Piece: p.Data,
}
if err := cborutil.WriteCborRPC(s, proposal); err != nil {
s.Reset()
return cid.Undef, xerrors.Errorf("sending proposal to storage provider failed: %w", err)
}
deal := &ClientDeal{
ProposalCid: proposalNd.Cid(),
Proposal: *dealProposal,
State: api.DealUnknown,
Miner: p.MinerID,
MinerWorker: p.MinerWorker,
s: s,
}
c.incoming <- deal
return deal.ProposalCid, c.discovery.AddPeer(p.Data, discovery.RetrievalPeer{
Address: dealProposal.Provider,
ID: deal.Miner,
})
}
func (c *Client) QueryAsk(ctx context.Context, p peer.ID, a address.Address) (*types.SignedStorageAsk, error) {
s, err := c.h.NewStream(ctx, p, AskProtocolID)
if err != nil {
return nil, xerrors.Errorf("failed to open stream to miner: %w", err)
}
req := &AskRequest{
Miner: a,
}
if err := cborutil.WriteCborRPC(s, req); err != nil {
return nil, xerrors.Errorf("failed to send ask request: %w", err)
}
var out AskResponse
if err := cborutil.ReadCborRPC(s, &out); err != nil {
return nil, xerrors.Errorf("failed to read ask response: %w", err)
}
if out.Ask == nil {
return nil, xerrors.Errorf("got no ask back")
}
if out.Ask.Ask.Miner != a {
return nil, xerrors.Errorf("got back ask for wrong miner")
}
if err := c.checkAskSignature(out.Ask); err != nil {
return nil, xerrors.Errorf("ask was not properly signed")
}
return out.Ask, nil
}
func (c *Client) List() ([]ClientDeal, error) {
var out []ClientDeal
if err := c.deals.List(&out); err != nil {
return nil, err
}
return out, nil
}
func (c *Client) GetDeal(d cid.Cid) (*ClientDeal, error) {
var out ClientDeal
if err := c.deals.Get(d, &out); err != nil {
return nil, err
}
return &out, nil
}
func (c *Client) Stop() {
close(c.stop)
<-c.stopped
}
-233
View File
@@ -1,233 +0,0 @@
package deals
import (
"bytes"
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
)
type clientHandlerFunc func(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error)
func (c *Client) handle(ctx context.Context, deal ClientDeal, cb clientHandlerFunc, next api.DealState) {
go func() {
mut, err := cb(ctx, deal)
if err != nil {
next = api.DealError
}
if err == nil && next == api.DealNoUpdate {
return
}
select {
case c.updated <- clientDealUpdate{
newState: next,
id: deal.ProposalCid,
err: err,
mut: mut,
}:
case <-c.stop:
}
}()
}
func (c *Client) new(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) {
resp, err := c.readStorageDealResp(deal)
if err != nil {
return nil, err
}
// TODO: verify StorageDealSubmission
if err := c.disconnect(deal); err != nil {
return nil, err
}
/* data transfer happens */
if resp.State != api.DealAccepted {
return nil, xerrors.Errorf("deal wasn't accepted (State=%d)", resp.State)
}
return func(info *ClientDeal) {
info.PublishMessage = resp.StorageDealSubmission
}, nil
}
func (c *Client) accepted(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) {
log.Infow("DEAL ACCEPTED!")
pubmsg := deal.PublishMessage.Message
pw, err := stmgr.GetMinerWorker(ctx, c.sm, nil, deal.Proposal.Provider)
if err != nil {
return nil, xerrors.Errorf("getting miner worker failed: %w", err)
}
if pubmsg.From != pw {
return nil, xerrors.Errorf("deal wasn't published by storage provider: from=%s, provider=%s", pubmsg.From, deal.Proposal.Provider)
}
if pubmsg.To != actors.StorageMarketAddress {
return nil, xerrors.Errorf("deal publish message wasn't set to StorageMarket actor (to=%s)", pubmsg.To)
}
if pubmsg.Method != actors.SMAMethods.PublishStorageDeals {
return nil, xerrors.Errorf("deal publish message called incorrect method (method=%s)", pubmsg.Method)
}
var params actors.PublishStorageDealsParams
if err := params.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil {
return nil, err
}
dealIdx := -1
for i, storageDeal := range params.Deals {
// TODO: make it less hacky
sd := storageDeal
eq, err := cborutil.Equals(&deal.Proposal, &sd)
if err != nil {
return nil, err
}
if eq {
dealIdx = i
break
}
}
if dealIdx == -1 {
return nil, xerrors.Errorf("deal publish didn't contain our deal (message cid: %s)", deal.PublishMessage.Cid())
}
// TODO: timeout
_, ret, err := c.sm.WaitForMessage(ctx, deal.PublishMessage.Cid())
if err != nil {
return nil, xerrors.Errorf("waiting for deal publish message: %w", err)
}
if ret.ExitCode != 0 {
return nil, xerrors.Errorf("deal publish failed: exit=%d", ret.ExitCode)
}
var res actors.PublishStorageDealResponse
if err := res.UnmarshalCBOR(bytes.NewReader(ret.Return)); err != nil {
return nil, err
}
return func(info *ClientDeal) {
info.DealID = res.DealIDs[dealIdx]
}, nil
}
func (c *Client) staged(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) {
// TODO: Maybe wait for pre-commit
return nil, nil
}
func (c *Client) sealing(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) {
checkFunc := func(ts *types.TipSet) (done bool, more bool, err error) {
sd, err := stmgr.GetStorageDeal(ctx, c.sm, deal.DealID, ts)
if err != nil {
// TODO: This may be fine for some errors
return false, false, xerrors.Errorf("failed to look up deal on chain: %w", err)
}
if sd.ActivationEpoch > 0 {
select {
case c.updated <- clientDealUpdate{
newState: api.DealComplete,
id: deal.ProposalCid,
}:
case <-c.stop:
}
return true, false, nil
}
return false, true, nil
}
called := func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (more bool, err error) {
defer func() {
if err != nil {
select {
case c.updated <- clientDealUpdate{
newState: api.DealComplete,
id: deal.ProposalCid,
err: xerrors.Errorf("handling applied event: %w", err),
}:
case <-c.stop:
}
}
}()
if msg == nil {
log.Error("timed out waiting for deal activation... what now?")
return false, nil
}
sd, err := stmgr.GetStorageDeal(ctx, c.sm, deal.DealID, ts)
if err != nil {
return false, xerrors.Errorf("failed to look up deal on chain: %w", err)
}
if sd.ActivationEpoch == 0 {
return false, xerrors.Errorf("deal wasn't active: deal=%d, parentState=%s, h=%d", deal.DealID, ts.ParentState(), ts.Height())
}
log.Infof("Storage deal %d activated at epoch %d", deal.DealID, sd.ActivationEpoch)
select {
case c.updated <- clientDealUpdate{
newState: api.DealComplete,
id: deal.ProposalCid,
}:
case <-c.stop:
}
return false, nil
}
revert := func(ctx context.Context, ts *types.TipSet) error {
log.Warn("deal activation reverted; TODO: actually handle this!")
// TODO: Just go back to DealSealing?
return nil
}
matchEvent := func(msg *types.Message) (bool, error) {
if msg.To != deal.Proposal.Provider {
return false, nil
}
if msg.Method != actors.MAMethods.ProveCommitSector {
return false, nil
}
var params actors.SectorProveCommitInfo
if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil {
return false, err
}
var found bool
for _, dealID := range params.DealIDs {
if dealID == deal.DealID {
found = true
break
}
}
return found, nil
}
if err := c.events.Called(checkFunc, called, revert, 3, build.SealRandomnessLookbackLimit, matchEvent); err != nil {
return nil, xerrors.Errorf("failed to set up called handler")
}
return nil, nil
}
-170
View File
@@ -1,170 +0,0 @@
package deals
import (
"bytes"
"context"
"runtime"
"github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files"
unixfile "github.com/ipfs/go-unixfs/file"
"github.com/ipld/go-ipld-prime"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/datatransfer"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/filecoin-project/lotus/lib/statestore"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
func (c *Client) failDeal(id cid.Cid, cerr error) {
if cerr == nil {
_, f, l, _ := runtime.Caller(1)
cerr = xerrors.Errorf("unknown error (fail called at %s:%d)", f, l)
}
s, ok := c.conns[id]
if ok {
_ = s.Reset()
delete(c.conns, id)
}
// TODO: store in some sort of audit log
log.Errorf("deal %s failed: %+v", id, cerr)
}
func (c *Client) commP(ctx context.Context, data cid.Cid) ([]byte, uint64, error) {
root, err := c.dag.Get(ctx, data)
if err != nil {
log.Errorf("failed to get file root for deal: %s", err)
return nil, 0, err
}
n, err := unixfile.NewUnixfsFile(ctx, c.dag, root)
if err != nil {
log.Errorf("cannot open unixfs file: %s", err)
return nil, 0, err
}
uf, ok := n.(files.File)
if !ok {
// TODO: we probably got directory, how should we handle this in unixfs mode?
return nil, 0, xerrors.New("unsupported unixfs type")
}
s, err := uf.Size()
if err != nil {
return nil, 0, err
}
pr, psize := padreader.New(uf, uint64(s))
commp, err := sectorbuilder.GeneratePieceCommitment(pr, psize)
if err != nil {
return nil, 0, xerrors.Errorf("generating CommP: %w", err)
}
return commp[:], psize, nil
}
func (c *Client) readStorageDealResp(deal ClientDeal) (*Response, error) {
s, ok := c.conns[deal.ProposalCid]
if !ok {
// TODO: Try to re-establish the connection using query protocol
return nil, xerrors.Errorf("no connection to miner")
}
var resp SignedResponse
if err := cborutil.ReadCborRPC(s, &resp); err != nil {
log.Errorw("failed to read Response message", "error", err)
return nil, err
}
if err := resp.Verify(deal.MinerWorker); err != nil {
return nil, xerrors.Errorf("verifying response signature failed", err)
}
if resp.Response.Proposal != deal.ProposalCid {
return nil, xerrors.Errorf("miner responded to a wrong proposal: %s != %s", resp.Response.Proposal, deal.ProposalCid)
}
return &resp.Response, nil
}
func (c *Client) disconnect(deal ClientDeal) error {
s, ok := c.conns[deal.ProposalCid]
if !ok {
return nil
}
err := s.Close()
delete(c.conns, deal.ProposalCid)
return err
}
var _ datatransfer.RequestValidator = &ClientRequestValidator{}
// ClientRequestValidator validates data transfer requests for the client
// in a storage market
type ClientRequestValidator struct {
deals *statestore.StateStore
}
// NewClientRequestValidator returns a new client request validator for the
// given datastore
func NewClientRequestValidator(deals dtypes.ClientDealStore) *ClientRequestValidator {
crv := &ClientRequestValidator{
deals: deals,
}
return crv
}
// ValidatePush validates a push request received from the peer that will send data
// Will always error because clients should not accept push requests from a provider
// in a storage deal (i.e. send data to client).
func (c *ClientRequestValidator) ValidatePush(
sender peer.ID,
voucher datatransfer.Voucher,
baseCid cid.Cid,
Selector ipld.Node) error {
return ErrNoPushAccepted
}
// ValidatePull validates a pull request received from the peer that will receive data
// Will succeed only if:
// - voucher has correct type
// - voucher references an active deal
// - referenced deal matches the receiver (miner)
// - referenced deal matches the given base CID
// - referenced deal is in an acceptable state
func (c *ClientRequestValidator) ValidatePull(
receiver peer.ID,
voucher datatransfer.Voucher,
baseCid cid.Cid,
Selector ipld.Node) error {
dealVoucher, ok := voucher.(*StorageDataTransferVoucher)
if !ok {
return xerrors.Errorf("voucher type %s: %w", voucher.Identifier(), ErrWrongVoucherType)
}
var deal ClientDeal
err := c.deals.Get(dealVoucher.Proposal, &deal)
if err != nil {
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
}
if deal.Miner != receiver {
return xerrors.Errorf("Deal Peer %s, Data Transfer Peer %s: %w", deal.Miner.String(), receiver.String(), ErrWrongPeer)
}
if !bytes.Equal(deal.Proposal.PieceRef, baseCid.Bytes()) {
return xerrors.Errorf("Deal Payload CID %s, Data Transfer CID %s: %w", string(deal.Proposal.PieceRef), baseCid.String(), ErrWrongPiece)
}
for _, state := range DataTransferStates {
if deal.State == state {
return nil
}
}
return xerrors.Errorf("Deal State %s: %w", deal.State, ErrInacceptableDealState)
}
-294
View File
@@ -1,294 +0,0 @@
package deals
import (
"context"
"errors"
"sync"
cid "github.com/ipfs/go-cid"
datastore "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/datatransfer"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/statestore"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/storage"
"github.com/filecoin-project/lotus/storage/sectorblocks"
)
var ProviderDsPrefix = "/deals/provider"
type MinerDeal struct {
Client peer.ID
Proposal actors.StorageDealProposal
ProposalCid cid.Cid
State api.DealState
Ref cid.Cid
DealID uint64
SectorID uint64 // Set when State >= DealStaged
s inet.Stream
}
type Provider struct {
pricePerByteBlock types.BigInt // how much we want for storing one byte for one block
minPieceSize uint64
ask *types.SignedStorageAsk
askLk sync.Mutex
secb *sectorblocks.SectorBlocks
sminer *storage.Miner
full api.FullNode
// TODO: This will go away once storage market module + CAR
// is implemented
dag dtypes.StagingDAG
// dataTransfer is the manager of data transfers used by this storage provider
dataTransfer dtypes.ProviderDataTransfer
deals *statestore.StateStore
ds dtypes.MetadataDS
conns map[cid.Cid]inet.Stream
actor address.Address
incoming chan MinerDeal
updated chan minerDealUpdate
stop chan struct{}
stopped chan struct{}
}
type minerDealUpdate struct {
newState api.DealState
id cid.Cid
err error
mut func(*MinerDeal)
}
var (
// ErrDataTransferFailed means a data transfer for a deal failed
ErrDataTransferFailed = errors.New("deal data transfer failed")
)
func NewProvider(ds dtypes.MetadataDS, sminer *storage.Miner, secb *sectorblocks.SectorBlocks, dag dtypes.StagingDAG, dataTransfer dtypes.ProviderDataTransfer, fullNode api.FullNode) (*Provider, error) {
addr, err := ds.Get(datastore.NewKey("miner-address"))
if err != nil {
return nil, err
}
minerAddress, err := address.NewFromBytes(addr)
if err != nil {
return nil, err
}
h := &Provider{
sminer: sminer,
dag: dag,
dataTransfer: dataTransfer,
full: fullNode,
secb: secb,
pricePerByteBlock: types.NewInt(3), // TODO: allow setting
minPieceSize: 256, // TODO: allow setting (BUT KEEP MIN 256! (because of how we fill sectors up))
conns: map[cid.Cid]inet.Stream{},
incoming: make(chan MinerDeal),
updated: make(chan minerDealUpdate),
stop: make(chan struct{}),
stopped: make(chan struct{}),
actor: minerAddress,
deals: statestore.New(namespace.Wrap(ds, datastore.NewKey(ProviderDsPrefix))),
ds: ds,
}
if err := h.tryLoadAsk(); err != nil {
return nil, err
}
if h.ask == nil {
// TODO: we should be fine with this state, and just say it means 'not actively accepting deals'
// for now... lets just set a price
if err := h.SetPrice(types.NewInt(500_000_000), 1000000); err != nil {
return nil, xerrors.Errorf("failed setting a default price: %w", err)
}
}
// register a data transfer event handler -- this will move deals from
// accepted to staged
h.dataTransfer.SubscribeToEvents(h.onDataTransferEvent)
return h, nil
}
func (p *Provider) Run(ctx context.Context) {
// TODO: restore state
go func() {
defer log.Warn("quitting deal provider loop")
defer close(p.stopped)
for {
select {
case deal := <-p.incoming: // DealAccepted
p.onIncoming(deal)
case update := <-p.updated: // DealStaged
p.onUpdated(ctx, update)
case <-p.stop:
return
}
}
}()
}
func (p *Provider) onIncoming(deal MinerDeal) {
log.Info("incoming deal")
p.conns[deal.ProposalCid] = deal.s
if err := p.deals.Begin(deal.ProposalCid, &deal); err != nil {
// This can happen when client re-sends proposal
p.failDeal(deal.ProposalCid, err)
log.Errorf("deal tracking failed: %s", err)
return
}
go func() {
p.updated <- minerDealUpdate{
newState: api.DealAccepted,
id: deal.ProposalCid,
err: nil,
}
}()
}
func (p *Provider) onUpdated(ctx context.Context, update minerDealUpdate) {
log.Infof("Deal %s updated state to %s", update.id, api.DealStates[update.newState])
if update.err != nil {
log.Errorf("deal %s (newSt: %d) failed: %+v", update.id, update.newState, update.err)
p.failDeal(update.id, update.err)
return
}
var deal MinerDeal
err := p.deals.Mutate(update.id, func(d *MinerDeal) error {
d.State = update.newState
if update.mut != nil {
update.mut(d)
}
deal = *d
return nil
})
if err != nil {
p.failDeal(update.id, err)
return
}
switch update.newState {
case api.DealAccepted:
p.handle(ctx, deal, p.accept, api.DealNoUpdate)
case api.DealStaged:
p.handle(ctx, deal, p.staged, api.DealSealing)
case api.DealSealing:
p.handle(ctx, deal, p.sealing, api.DealComplete)
case api.DealComplete:
p.handle(ctx, deal, p.complete, api.DealNoUpdate)
}
}
// onDataTransferEvent is the function called when an event occurs in a data
// transfer -- it reads the voucher to verify this even occurred in a storage
// market deal, then, based on the data transfer event that occurred, it generates
// and update message for the deal -- either moving to staged for a completion
// event or moving to error if a data transfer error occurs
func (p *Provider) onDataTransferEvent(event datatransfer.Event, channelState datatransfer.ChannelState) {
voucher, ok := channelState.Voucher().(*StorageDataTransferVoucher)
// if this event is for a transfer not related to storage, ignore
if !ok {
return
}
// data transfer events for opening and progress do not affect deal state
var next api.DealState
var err error
var mut func(*MinerDeal)
switch event {
case datatransfer.Complete:
next = api.DealStaged
mut = func(deal *MinerDeal) {
deal.DealID = voucher.DealID
}
case datatransfer.Error:
next = api.DealFailed
err = ErrDataTransferFailed
default:
// the only events we care about are complete and error
return
}
select {
case p.updated <- minerDealUpdate{
newState: next,
id: voucher.Proposal,
err: err,
mut: mut,
}:
case <-p.stop:
}
}
func (p *Provider) newDeal(s inet.Stream, proposal Proposal) (MinerDeal, error) {
proposalNd, err := cborutil.AsIpld(proposal.DealProposal)
if err != nil {
return MinerDeal{}, err
}
return MinerDeal{
Client: s.Conn().RemotePeer(),
Proposal: *proposal.DealProposal,
ProposalCid: proposalNd.Cid(),
State: api.DealUnknown,
Ref: proposal.Piece,
s: s,
}, nil
}
func (p *Provider) HandleStream(s inet.Stream) {
log.Info("Handling storage deal proposal!")
proposal, err := p.readProposal(s)
if err != nil {
log.Error(err)
s.Close()
return
}
deal, err := p.newDeal(s, proposal)
if err != nil {
log.Errorf("%+v", err)
s.Close()
return
}
p.incoming <- deal
}
func (p *Provider) Stop() {
close(p.stop)
<-p.stopped
}
-160
View File
@@ -1,160 +0,0 @@
package deals
import (
"bytes"
"context"
"time"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
datastore "github.com/ipfs/go-datastore"
inet "github.com/libp2p/go-libp2p-core/network"
"golang.org/x/xerrors"
)
func (p *Provider) SetPrice(price types.BigInt, ttlsecs int64) error {
p.askLk.Lock()
defer p.askLk.Unlock()
var seqno uint64
if p.ask != nil {
seqno = p.ask.Ask.SeqNo + 1
}
now := time.Now().Unix()
ask := &types.StorageAsk{
Price: price,
Timestamp: uint64(now),
Expiry: uint64(now + ttlsecs),
Miner: p.actor,
SeqNo: seqno,
MinPieceSize: p.minPieceSize,
}
ssa, err := p.signAsk(ask)
if err != nil {
return err
}
return p.saveAsk(ssa)
}
func (p *Provider) getAsk(m address.Address) *types.SignedStorageAsk {
p.askLk.Lock()
defer p.askLk.Unlock()
if m != p.actor {
return nil
}
return p.ask
}
func (p *Provider) HandleAskStream(s inet.Stream) {
defer s.Close()
var ar AskRequest
if err := cborutil.ReadCborRPC(s, &ar); err != nil {
log.Errorf("failed to read AskRequest from incoming stream: %s", err)
return
}
resp := p.processAskRequest(&ar)
if err := cborutil.WriteCborRPC(s, resp); err != nil {
log.Errorf("failed to write ask response: %s", err)
return
}
}
func (p *Provider) processAskRequest(ar *AskRequest) *AskResponse {
return &AskResponse{
Ask: p.getAsk(ar.Miner),
}
}
var bestAskKey = datastore.NewKey("latest-ask")
func (p *Provider) tryLoadAsk() error {
p.askLk.Lock()
defer p.askLk.Unlock()
err := p.loadAsk()
if err != nil {
if xerrors.Is(err, datastore.ErrNotFound) {
log.Warn("no previous ask found, miner will not accept deals until a price is set")
return nil
}
return err
}
return nil
}
func (p *Provider) loadAsk() error {
askb, err := p.ds.Get(datastore.NewKey("latest-ask"))
if err != nil {
return xerrors.Errorf("failed to load most recent ask from disk: %w", err)
}
var ssa types.SignedStorageAsk
if err := cborutil.ReadCborRPC(bytes.NewReader(askb), &ssa); err != nil {
return err
}
p.ask = &ssa
return nil
}
func (p *Provider) signAsk(a *types.StorageAsk) (*types.SignedStorageAsk, error) {
b, err := cborutil.Dump(a)
if err != nil {
return nil, err
}
worker, err := p.getWorker(p.actor)
if err != nil {
return nil, xerrors.Errorf("failed to get worker to sign ask: %w", err)
}
sig, err := p.full.WalletSign(context.TODO(), worker, b)
if err != nil {
return nil, err
}
return &types.SignedStorageAsk{
Ask: a,
Signature: sig,
}, nil
}
func (p *Provider) saveAsk(a *types.SignedStorageAsk) error {
b, err := cborutil.Dump(a)
if err != nil {
return err
}
if err := p.ds.Put(bestAskKey, b); err != nil {
return err
}
p.ask = a
return nil
}
func (c *Client) checkAskSignature(ask *types.SignedStorageAsk) error {
tss := c.sm.ChainStore().GetHeaviestTipSet().ParentState()
w, err := stmgr.GetMinerWorkerRaw(context.TODO(), c.sm, tss, ask.Ask.Miner)
if err != nil {
return xerrors.Errorf("failed to get worker for miner in ask", err)
}
sigb, err := cborutil.Dump(ask.Ask)
if err != nil {
return xerrors.Errorf("failed to re-serialize ask")
}
return ask.Signature.Verify(w, sigb)
}
-215
View File
@@ -1,215 +0,0 @@
package deals
import (
"bytes"
"context"
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
"github.com/ipld/go-ipld-prime/traversal/selector"
"github.com/ipld/go-ipld-prime/traversal/selector/builder"
unixfile "github.com/ipfs/go-unixfs/file"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/padreader"
"github.com/filecoin-project/lotus/storage/sectorblocks"
)
type providerHandlerFunc func(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error)
func (p *Provider) handle(ctx context.Context, deal MinerDeal, cb providerHandlerFunc, next api.DealState) {
go func() {
mut, err := cb(ctx, deal)
if err == nil && next == api.DealNoUpdate {
return
}
select {
case p.updated <- minerDealUpdate{
newState: next,
id: deal.ProposalCid,
err: err,
mut: mut,
}:
case <-p.stop:
}
}()
}
// ACCEPTED
func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
head, err := p.full.ChainHead(ctx)
if err != nil {
return nil, err
}
if head.Height() >= deal.Proposal.ProposalExpiration {
return nil, xerrors.Errorf("deal proposal already expired")
}
// TODO: check StorageCollateral
minPrice := types.BigDiv(types.BigMul(p.ask.Ask.Price, types.NewInt(deal.Proposal.PieceSize)), types.NewInt(1<<30))
if deal.Proposal.StoragePricePerEpoch.LessThan(minPrice) {
return nil, xerrors.Errorf("storage price per epoch less than asking price: %s < %s", deal.Proposal.StoragePricePerEpoch, minPrice)
}
if deal.Proposal.PieceSize < p.ask.Ask.MinPieceSize {
return nil, xerrors.Errorf("piece size less than minimum required size: %d < %d", deal.Proposal.PieceSize, p.ask.Ask.MinPieceSize)
}
// check market funds
clientMarketBalance, err := p.full.StateMarketBalance(ctx, deal.Proposal.Client, nil)
if err != nil {
return nil, xerrors.Errorf("getting client market balance failed: %w", err)
}
// This doesn't guarantee that the client won't withdraw / lock those funds
// but it's a decent first filter
if clientMarketBalance.Available.LessThan(deal.Proposal.TotalStoragePrice()) {
return nil, xerrors.New("clientMarketBalance.Available too small")
}
waddr, err := p.full.StateMinerWorker(ctx, deal.Proposal.Provider, nil)
if err != nil {
return nil, err
}
// TODO: check StorageCollateral (may be too large (or too small))
if err := p.full.MarketEnsureAvailable(ctx, waddr, deal.Proposal.StorageCollateral); err != nil {
return nil, err
}
log.Info("publishing deal")
params, err := actors.SerializeParams(&actors.PublishStorageDealsParams{
Deals: []actors.StorageDealProposal{deal.Proposal},
})
if err != nil {
return nil, xerrors.Errorf("serializing PublishStorageDeals params failed: ", err)
}
// TODO: We may want this to happen after fetching data
smsg, err := p.full.MpoolPushMessage(ctx, &types.Message{
To: actors.StorageMarketAddress,
From: waddr,
Value: types.NewInt(0),
GasPrice: types.NewInt(0),
GasLimit: types.NewInt(1000000),
Method: actors.SMAMethods.PublishStorageDeals,
Params: params,
})
if err != nil {
return nil, err
}
r, err := p.full.StateWaitMsg(ctx, smsg.Cid())
if err != nil {
return nil, err
}
if r.Receipt.ExitCode != 0 {
return nil, xerrors.Errorf("publishing deal failed: exit %d", r.Receipt.ExitCode)
}
var resp actors.PublishStorageDealResponse
if err := resp.UnmarshalCBOR(bytes.NewReader(r.Receipt.Return)); err != nil {
return nil, err
}
if len(resp.DealIDs) != 1 {
return nil, xerrors.Errorf("got unexpected number of DealIDs from SMA")
}
log.Infof("fetching data for a deal %d", resp.DealIDs[0])
err = p.sendSignedResponse(&Response{
State: api.DealAccepted,
Proposal: deal.ProposalCid,
StorageDealSubmission: smsg,
})
if err != nil {
return nil, err
}
if err := p.disconnect(deal); err != nil {
log.Warnf("closing client connection: %+v", err)
}
ssb := builder.NewSelectorSpecBuilder(ipldfree.NodeBuilder())
// this is the selector for "get the whole DAG"
// TODO: support storage deals with custom payload selectors
allSelector := ssb.ExploreRecursive(selector.RecursionLimitNone(),
ssb.ExploreAll(ssb.ExploreRecursiveEdge())).Node()
// initiate a pull data transfer. This will complete asynchronously and the
// completion of the data transfer will trigger a change in deal state
// (see onDataTransferEvent)
_, err = p.dataTransfer.OpenPullDataChannel(ctx,
deal.Client,
&StorageDataTransferVoucher{Proposal: deal.ProposalCid, DealID: resp.DealIDs[0]},
deal.Ref,
allSelector,
)
if err != nil {
return nil, xerrors.Errorf("failed to open pull data channel: %w", err)
}
return nil, nil
}
// STAGED
func (p *Provider) staged(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
root, err := p.dag.Get(ctx, deal.Ref)
if err != nil {
return nil, xerrors.Errorf("failed to get file root for deal: %s", err)
}
// TODO: abstract this away into ReadSizeCloser + implement different modes
n, err := unixfile.NewUnixfsFile(ctx, p.dag, root)
if err != nil {
return nil, xerrors.Errorf("cannot open unixfs file: %s", err)
}
uf, ok := n.(sectorblocks.UnixfsReader)
if !ok {
// we probably got directory, unsupported for now
return nil, xerrors.Errorf("unsupported unixfs file type")
}
// TODO: uf.Size() is user input, not trusted
// This won't be useful / here after we migrate to putting CARs into sectors
size, err := uf.Size()
if err != nil {
return nil, xerrors.Errorf("getting unixfs file size: %w", err)
}
if padreader.PaddedSize(uint64(size)) != deal.Proposal.PieceSize {
return nil, xerrors.Errorf("deal.Proposal.PieceSize didn't match padded unixfs file size")
}
sectorID, err := p.secb.AddUnixfsPiece(ctx, uf, deal.DealID)
if err != nil {
return nil, xerrors.Errorf("AddPiece failed: %s", err)
}
log.Warnf("New Sector: %d (deal %d)", sectorID, deal.DealID)
return func(deal *MinerDeal) {
deal.SectorID = sectorID
}, nil
}
// SEALING
func (p *Provider) sealing(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
// TODO: consider waiting for seal to happen
return nil, nil
}
func (p *Provider) complete(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) {
// TODO: observe sector lifecycle, status, expiration..
return nil, nil
}
-198
View File
@@ -1,198 +0,0 @@
package deals
import (
"bytes"
"context"
"runtime"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/datatransfer"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/ipld/go-ipld-prime"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/statestore"
"github.com/ipfs/go-cid"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
)
func (p *Provider) failDeal(id cid.Cid, cerr error) {
if err := p.deals.End(id); err != nil {
log.Warnf("deals.End: %s", err)
}
if cerr == nil {
_, f, l, _ := runtime.Caller(1)
cerr = xerrors.Errorf("unknown error (fail called at %s:%d)", f, l)
}
log.Warnf("deal %s failed: %s", id, cerr)
err := p.sendSignedResponse(&Response{
State: api.DealFailed,
Message: cerr.Error(),
Proposal: id,
})
s, ok := p.conns[id]
if ok {
_ = s.Reset()
delete(p.conns, id)
}
if err != nil {
log.Warnf("notifying client about deal failure: %s", err)
}
}
func (p *Provider) readProposal(s inet.Stream) (proposal Proposal, err error) {
if err := cborutil.ReadCborRPC(s, &proposal); err != nil {
log.Errorw("failed to read proposal message", "error", err)
return proposal, err
}
if err := proposal.DealProposal.Verify(); err != nil {
return proposal, xerrors.Errorf("verifying StorageDealProposal: %w", err)
}
if proposal.DealProposal.Provider != p.actor {
log.Errorf("proposal with wrong ProviderAddress: %s", proposal.DealProposal.Provider)
return proposal, err
}
return
}
func (p *Provider) sendSignedResponse(resp *Response) error {
s, ok := p.conns[resp.Proposal]
if !ok {
return xerrors.New("couldn't send response: not connected")
}
msg, err := cborutil.Dump(resp)
if err != nil {
return xerrors.Errorf("serializing response: %w", err)
}
worker, err := p.getWorker(p.actor)
if err != nil {
return err
}
sig, err := p.full.WalletSign(context.TODO(), worker, msg)
if err != nil {
return xerrors.Errorf("failed to sign response message: %w", err)
}
signedResponse := &SignedResponse{
Response: *resp,
Signature: sig,
}
err = cborutil.WriteCborRPC(s, signedResponse)
if err != nil {
// Assume client disconnected
s.Close()
delete(p.conns, resp.Proposal)
}
return err
}
func (p *Provider) disconnect(deal MinerDeal) error {
s, ok := p.conns[deal.ProposalCid]
if !ok {
return nil
}
err := s.Close()
delete(p.conns, deal.ProposalCid)
return err
}
func (p *Provider) getWorker(miner address.Address) (address.Address, error) {
getworker := &types.Message{
To: miner,
From: miner,
Method: actors.MAMethods.GetWorkerAddr,
}
r, err := p.full.StateCall(context.TODO(), getworker, nil)
if err != nil {
return address.Undef, xerrors.Errorf("getting worker address: %w", err)
}
if r.ExitCode != 0 {
return address.Undef, xerrors.Errorf("getWorker call failed: %d", r.ExitCode)
}
return address.NewFromBytes(r.Return)
}
var _ datatransfer.RequestValidator = &ProviderRequestValidator{}
// ProviderRequestValidator validates data transfer requests for the provider
// in a storage market
type ProviderRequestValidator struct {
deals *statestore.StateStore
}
// NewProviderRequestValidator returns a new client request validator for the
// given datastore
func NewProviderRequestValidator(deals dtypes.ProviderDealStore) *ProviderRequestValidator {
return &ProviderRequestValidator{
deals: deals,
}
}
// ValidatePush validates a push request received from the peer that will send data
// Will succeed only if:
// - voucher has correct type
// - voucher references an active deal
// - referenced deal matches the client
// - referenced deal matches the given base CID
// - referenced deal is in an acceptable state
func (m *ProviderRequestValidator) ValidatePush(
sender peer.ID,
voucher datatransfer.Voucher,
baseCid cid.Cid,
Selector ipld.Node) error {
dealVoucher, ok := voucher.(*StorageDataTransferVoucher)
if !ok {
return xerrors.Errorf("voucher type %s: %w", voucher.Identifier(), ErrWrongVoucherType)
}
var deal MinerDeal
err := m.deals.Get(dealVoucher.Proposal, &deal)
if err != nil {
return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal)
}
if deal.Client != sender {
return xerrors.Errorf("Deal Peer %s, Data Transfer Peer %s: %w", deal.Client.String(), sender.String(), ErrWrongPeer)
}
if !bytes.Equal(deal.Proposal.PieceRef, baseCid.Bytes()) {
return xerrors.Errorf("Deal Payload CID %s, Data Transfer CID %s: %w", string(deal.Proposal.PieceRef), baseCid.String(), ErrWrongPiece)
}
for _, state := range DataTransferStates {
if deal.State == state {
return nil
}
}
return xerrors.Errorf("Deal State %s: %w", deal.State, ErrInacceptableDealState)
}
// ValidatePull validates a pull request received from the peer that will receive data.
// Will always error because providers should not accept pull requests from a client
// in a storage deal (i.e. send data to client).
func (m *ProviderRequestValidator) ValidatePull(
receiver peer.ID,
voucher datatransfer.Voucher,
baseCid cid.Cid,
Selector ipld.Node) error {
return ErrNoPullAccepted
}
-291
View File
@@ -1,291 +0,0 @@
package deals_test
import (
"fmt"
"math/rand"
"testing"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace"
dss "github.com/ipfs/go-datastore/sync"
blocksutil "github.com/ipfs/go-ipfs-blocksutil"
"github.com/libp2p/go-libp2p-core/peer"
xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/deals"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/filecoin-project/lotus/lib/statestore"
)
var blockGenerator = blocksutil.NewBlockGenerator()
type wrongDTType struct {
}
func (wrongDTType) ToBytes() ([]byte, error) {
return []byte{}, nil
}
func (wrongDTType) FromBytes([]byte) error {
return fmt.Errorf("not implemented")
}
func (wrongDTType) Identifier() string {
return "WrongDTTYPE"
}
func uniqueStorageDealProposal() (actors.StorageDealProposal, error) {
clientAddr, err := address.NewIDAddress(uint64(rand.Int()))
if err != nil {
return actors.StorageDealProposal{}, err
}
providerAddr, err := address.NewIDAddress(uint64(rand.Int()))
if err != nil {
return actors.StorageDealProposal{}, err
}
return actors.StorageDealProposal{
PieceRef: blockGenerator.Next().Cid().Bytes(),
Client: clientAddr,
Provider: providerAddr,
ProposerSignature: &types.Signature{
Data: []byte("foo bar cat dog"),
Type: types.KTBLS,
},
}, nil
}
func newClientDeal(minerID peer.ID, state api.DealState) (deals.ClientDeal, error) {
newProposal, err := uniqueStorageDealProposal()
if err != nil {
return deals.ClientDeal{}, err
}
proposalNd, err := cborutil.AsIpld(&newProposal)
if err != nil {
return deals.ClientDeal{}, err
}
minerAddr, err := address.NewIDAddress(uint64(rand.Int()))
if err != nil {
return deals.ClientDeal{}, err
}
return deals.ClientDeal{
Proposal: newProposal,
ProposalCid: proposalNd.Cid(),
Miner: minerID,
MinerWorker: minerAddr,
State: state,
}, nil
}
func newMinerDeal(clientID peer.ID, state api.DealState) (deals.MinerDeal, error) {
newProposal, err := uniqueStorageDealProposal()
if err != nil {
return deals.MinerDeal{}, err
}
proposalNd, err := cborutil.AsIpld(&newProposal)
if err != nil {
return deals.MinerDeal{}, err
}
ref, err := cid.Cast(newProposal.PieceRef)
if err != nil {
return deals.MinerDeal{}, err
}
return deals.MinerDeal{
Proposal: newProposal,
ProposalCid: proposalNd.Cid(),
Client: clientID,
State: state,
Ref: ref,
}, nil
}
func TestClientRequestValidation(t *testing.T) {
ds := dss.MutexWrap(datastore.NewMapDatastore())
state := statestore.New(namespace.Wrap(ds, datastore.NewKey("/deals/client")))
crv := deals.NewClientRequestValidator(state)
minerID := peer.ID("fakepeerid")
block := blockGenerator.Next()
t.Run("ValidatePush fails", func(t *testing.T) {
if !xerrors.Is(crv.ValidatePush(minerID, wrongDTType{}, block.Cid(), nil), deals.ErrNoPushAccepted) {
t.Fatal("Push should fail for the client request validator for storage deals")
}
})
t.Run("ValidatePull fails deal not found", func(t *testing.T) {
proposal, err := uniqueStorageDealProposal()
if err != nil {
t.Fatal("error creating proposal")
}
proposalNd, err := cborutil.AsIpld(&proposal)
if err != nil {
t.Fatal("error serializing proposal")
}
pieceRef, err := cid.Cast(proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(crv.ValidatePull(minerID, &deals.StorageDataTransferVoucher{proposalNd.Cid(), 1}, pieceRef, nil), deals.ErrNoDeal) {
t.Fatal("Pull should fail if there is no deal stored")
}
})
t.Run("ValidatePull fails wrong client", func(t *testing.T) {
otherMiner := peer.ID("otherminer")
clientDeal, err := newClientDeal(otherMiner, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(clientDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(crv.ValidatePull(minerID, &deals.StorageDataTransferVoucher{clientDeal.ProposalCid, 1}, pieceRef, nil), deals.ErrWrongPeer) {
t.Fatal("Pull should fail if miner address is incorrect")
}
})
t.Run("ValidatePull fails wrong piece ref", func(t *testing.T) {
clientDeal, err := newClientDeal(minerID, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil {
t.Fatal("deal tracking failed")
}
if !xerrors.Is(crv.ValidatePull(minerID, &deals.StorageDataTransferVoucher{clientDeal.ProposalCid, 1}, blockGenerator.Next().Cid(), nil), deals.ErrWrongPiece) {
t.Fatal("Pull should fail if piece ref is incorrect")
}
})
t.Run("ValidatePull fails wrong deal state", func(t *testing.T) {
clientDeal, err := newClientDeal(minerID, api.DealComplete)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(clientDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(crv.ValidatePull(minerID, &deals.StorageDataTransferVoucher{clientDeal.ProposalCid, 1}, pieceRef, nil), deals.ErrInacceptableDealState) {
t.Fatal("Pull should fail if deal is in a state that cannot be data transferred")
}
})
t.Run("ValidatePull succeeds", func(t *testing.T) {
clientDeal, err := newClientDeal(minerID, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(clientDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if crv.ValidatePull(minerID, &deals.StorageDataTransferVoucher{clientDeal.ProposalCid, 1}, pieceRef, nil) != nil {
t.Fatal("Pull should should succeed when all parameters are correct")
}
})
}
func TestProviderRequestValidation(t *testing.T) {
ds := dss.MutexWrap(datastore.NewMapDatastore())
state := statestore.New(namespace.Wrap(ds, datastore.NewKey("/deals/client")))
mrv := deals.NewProviderRequestValidator(state)
clientID := peer.ID("fakepeerid")
block := blockGenerator.Next()
t.Run("ValidatePull fails", func(t *testing.T) {
if !xerrors.Is(mrv.ValidatePull(clientID, wrongDTType{}, block.Cid(), nil), deals.ErrNoPullAccepted) {
t.Fatal("Pull should fail for the provider request validator for storage deals")
}
})
t.Run("ValidatePush fails deal not found", func(t *testing.T) {
proposal, err := uniqueStorageDealProposal()
if err != nil {
t.Fatal("error creating proposal")
}
proposalNd, err := cborutil.AsIpld(&proposal)
if err != nil {
t.Fatal("error serializing proposal")
}
pieceRef, err := cid.Cast(proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(mrv.ValidatePush(clientID, &deals.StorageDataTransferVoucher{proposalNd.Cid(), 1}, pieceRef, nil), deals.ErrNoDeal) {
t.Fatal("Push should fail if there is no deal stored")
}
})
t.Run("ValidatePush fails wrong miner", func(t *testing.T) {
otherClient := peer.ID("otherclient")
minerDeal, err := newMinerDeal(otherClient, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(minerDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(mrv.ValidatePush(clientID, &deals.StorageDataTransferVoucher{minerDeal.ProposalCid, 1}, pieceRef, nil), deals.ErrWrongPeer) {
t.Fatal("Push should fail if miner address is incorrect")
}
})
t.Run("ValidatePush fails wrong piece ref", func(t *testing.T) {
minerDeal, err := newMinerDeal(clientID, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil {
t.Fatal("deal tracking failed")
}
if !xerrors.Is(mrv.ValidatePush(clientID, &deals.StorageDataTransferVoucher{minerDeal.ProposalCid, 1}, blockGenerator.Next().Cid(), nil), deals.ErrWrongPiece) {
t.Fatal("Push should fail if piece ref is incorrect")
}
})
t.Run("ValidatePush fails wrong deal state", func(t *testing.T) {
minerDeal, err := newMinerDeal(clientID, api.DealComplete)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(minerDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if !xerrors.Is(mrv.ValidatePush(clientID, &deals.StorageDataTransferVoucher{minerDeal.ProposalCid, 1}, pieceRef, nil), deals.ErrInacceptableDealState) {
t.Fatal("Push should fail if deal is in a state that cannot be data transferred")
}
})
t.Run("ValidatePush succeeds", func(t *testing.T) {
minerDeal, err := newMinerDeal(clientID, api.DealAccepted)
if err != nil {
t.Fatal("error creating client deal")
}
if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil {
t.Fatal("deal tracking failed")
}
pieceRef, err := cid.Cast(minerDeal.Proposal.PieceRef)
if err != nil {
t.Fatal("unable to construct piece cid")
}
if mrv.ValidatePush(clientID, &deals.StorageDataTransferVoucher{minerDeal.ProposalCid, 1}, pieceRef, nil) != nil {
t.Fatal("Push should should succeed when all parameters are correct")
}
})
}
-114
View File
@@ -1,114 +0,0 @@
package deals
import (
"bytes"
"errors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/cborutil"
"github.com/ipfs/go-cid"
)
var (
// ErrWrongVoucherType means the voucher was not the correct type can validate against
ErrWrongVoucherType = errors.New("cannot validate voucher type.")
// ErrNoPushAccepted just means clients do not accept pushes for storage deals
ErrNoPushAccepted = errors.New("client should not receive data for a storage deal.")
// ErrNoPullAccepted just means providers do not accept pulls for storage deals
ErrNoPullAccepted = errors.New("provider should not send data for a storage deal.")
// ErrNoDeal means no active deal was found for this vouchers proposal cid
ErrNoDeal = errors.New("no deal found for this proposal.")
// ErrWrongPeer means that the other peer for this data transfer request does not match
// the other peer for the deal
ErrWrongPeer = errors.New("data Transfer peer id and Deal peer id do not match.")
// ErrWrongPiece means that the pieceref for this data transfer request does not match
// the one specified in the deal
ErrWrongPiece = errors.New("base CID for deal does not match CID for piece.")
// ErrInacceptableDealState means the deal for this transfer is not in a deal state
// where transfer can be performed
ErrInacceptableDealState = errors.New("deal is not a in a state where deals are accepted.")
// DataTransferStates are the states in which it would make sense to actually start a data transfer
DataTransferStates = []api.DealState{api.DealAccepted, api.DealUnknown}
)
const DealProtocolID = "/fil/storage/mk/1.0.1"
const AskProtocolID = "/fil/storage/ask/1.0.1"
type Proposal struct {
DealProposal *actors.StorageDealProposal
Piece cid.Cid // Used for retrieving from the client
}
type Response struct {
State api.DealState
// DealProposalRejected
Message string
Proposal cid.Cid
// DealAccepted
StorageDealSubmission *types.SignedMessage
}
// TODO: Do we actually need this to be signed?
type SignedResponse struct {
Response Response
Signature *types.Signature
}
func (r *SignedResponse) Verify(addr address.Address) error {
b, err := cborutil.Dump(&r.Response)
if err != nil {
return err
}
return r.Signature.Verify(addr, b)
}
type AskRequest struct {
Miner address.Address
}
type AskResponse struct {
Ask *types.SignedStorageAsk
}
// StorageDataTransferVoucher is the voucher type for data transfers
// used by the storage market
type StorageDataTransferVoucher struct {
Proposal cid.Cid
DealID uint64
}
// ToBytes converts the StorageDataTransferVoucher to raw bytes
func (dv *StorageDataTransferVoucher) ToBytes() ([]byte, error) {
var buf bytes.Buffer
err := dv.MarshalCBOR(&buf)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// FromBytes converts the StorageDataTransferVoucher to raw bytes
func (dv *StorageDataTransferVoucher) FromBytes(raw []byte) error {
r := bytes.NewReader(raw)
return dv.UnmarshalCBOR(r)
}
// Identifier is the unique string identifier for a StorageDataTransferVoucher
func (dv *StorageDataTransferVoucher) Identifier() string {
return "StorageDataTransferVoucher"
}
+26 -17
View File
@@ -5,21 +5,22 @@ import (
"sync"
"time"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
)
var log = logging.Logger("events")
// `curH`-`ts.Height` = `confidence`
type HeightHandler func(ctx context.Context, ts *types.TipSet, curH uint64) error
// HeightHandler `curH`-`ts.Height` = `confidence`
type HeightHandler func(ctx context.Context, ts *types.TipSet, curH abi.ChainEpoch) error
type RevertHandler func(ctx context.Context, ts *types.TipSet) error
type heightHandler struct {
@@ -30,17 +31,18 @@ type heightHandler struct {
revert RevertHandler
}
type eventApi interface {
ChainNotify(context.Context) (<-chan []*store.HeadChange, error)
type eventAPI interface {
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet) (*types.TipSet, error)
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error)
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) // optional / for CalledMsg
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) // optional / for CalledMsg
}
type Events struct {
api eventApi
api eventAPI
tsc *tipSetCache
lk sync.Mutex
@@ -52,7 +54,7 @@ type Events struct {
calledEvents
}
func NewEvents(ctx context.Context, api eventApi) *Events {
func NewEvents(ctx context.Context, api eventAPI) *Events {
gcConfidence := 2 * build.ForkLengthThreshold
tsc := newTSCache(gcConfidence, api.ChainGetTipSetByHeight)
@@ -65,11 +67,11 @@ func NewEvents(ctx context.Context, api eventApi) *Events {
heightEvents: heightEvents{
tsc: tsc,
ctx: ctx,
gcConfidence: uint64(gcConfidence),
gcConfidence: gcConfidence,
heightTriggers: map[uint64]*heightHandler{},
htTriggerHeights: map[uint64][]uint64{},
htHeights: map[uint64][]uint64{},
htTriggerHeights: map[abi.ChainEpoch][]uint64{},
htHeights: map[abi.ChainEpoch][]uint64{},
},
calledEvents: calledEvents{
@@ -80,9 +82,9 @@ func NewEvents(ctx context.Context, api eventApi) *Events {
confQueue: map[triggerH]map[msgH][]*queuedEvent{},
revertQueue: map[msgH][]triggerH{},
triggers: map[triggerId]*callHandler{},
matchers: map[triggerId][]MatchFunc{},
timeouts: map[uint64]map[triggerId]int{},
triggers: map[triggerID]*callHandler{},
matchers: map[triggerID][]MatchFunc{},
timeouts: map[abi.ChainEpoch]map[triggerID]int{},
},
}
@@ -141,6 +143,8 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error {
}
e.readyOnce.Do(func() {
e.at = cur[0].Val.Height()
e.ready.Done()
})
@@ -160,6 +164,11 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error {
if err := e.headChange(rev, app); err != nil {
log.Warnf("headChange failed: %s", err)
}
// sync with fake chainstore (for tests)
if fcs, ok := e.api.(interface{ notifDone() }); ok {
fcs.notifDone()
}
}
return nil
+53 -43
View File
@@ -5,27 +5,28 @@ import (
"math"
"sync"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
)
const NoTimeout = math.MaxUint64
const NoTimeout = math.MaxInt64
type triggerId = uint64
type triggerID = uint64
// msgH is the block height at which a message was present / event has happened
type msgH = uint64
type msgH = abi.ChainEpoch
// triggerH is the block height at which the listener will be notified about the
// message (msgH+confidence)
type triggerH = uint64
type triggerH = abi.ChainEpoch
// CalledHandler arguments:
// `ts` is the tipset, in which the `msg` is included.
// `curH`-`ts.Height` = `confidence`
type CalledHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (more bool, err error)
type CalledHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)
// CheckFunc is used for atomicity guarantees. If the condition the callbacks
// wait for has already happened in tipset `ts`
@@ -39,7 +40,7 @@ type MatchFunc func(msg *types.Message) (bool, error)
type callHandler struct {
confidence int
timeout uint64
timeout abi.ChainEpoch
disabled bool // TODO: GC after gcConfidence reached
@@ -48,26 +49,28 @@ type callHandler struct {
}
type queuedEvent struct {
trigger triggerId
trigger triggerID
h uint64
h abi.ChainEpoch
msg *types.Message
called bool
}
type calledEvents struct {
cs eventApi
cs eventAPI
tsc *tipSetCache
ctx context.Context
gcConfidence uint64
at abi.ChainEpoch
lk sync.Mutex
ctr triggerId
ctr triggerID
triggers map[triggerId]*callHandler
matchers map[triggerId][]MatchFunc
triggers map[triggerID]*callHandler
matchers map[triggerID][]MatchFunc
// maps block heights to events
// [triggerH][msgH][event]
@@ -76,21 +79,23 @@ type calledEvents struct {
// [msgH][triggerH]
revertQueue map[msgH][]triggerH
// [timeoutH+confidence][triggerId]{calls}
timeouts map[uint64]map[triggerId]int
// [timeoutH+confidence][triggerID]{calls}
timeouts map[abi.ChainEpoch]map[triggerID]int
}
func (e *calledEvents) headChangeCalled(rev, app []*types.TipSet) error {
for _, ts := range rev {
e.handleReverts(ts)
e.at = ts.Height()
}
for _, ts := range app {
// called triggers
e.checkNewCalls(ts)
e.applyWithConfidence(ts)
e.applyTimeouts(ts)
for ; e.at <= ts.Height(); e.at++ {
e.applyWithConfidence(ts, e.at)
e.applyTimeouts(ts)
}
}
return nil
@@ -121,7 +126,13 @@ func (e *calledEvents) handleReverts(ts *types.TipSet) {
}
func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
e.messagesForTs(ts, func(msg *types.Message) {
pts, err := e.cs.ChainGetTipSet(e.ctx, ts.Parents()) // we actually care about messages in the parent tipset here
if err != nil {
log.Errorf("getting parent tipset in checkNewCalls: %s", err)
return
}
e.messagesForTs(pts, func(msg *types.Message) {
// TODO: provide receipts
for tid, matchFns := range e.matchers {
@@ -129,7 +140,7 @@ func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
for _, matchFn := range matchFns {
ok, err := matchFn(msg)
if err != nil {
log.Warnf("event matcher failed: %s")
log.Errorf("event matcher failed: %s", err)
continue
}
matched = ok
@@ -147,22 +158,21 @@ func (e *calledEvents) checkNewCalls(ts *types.TipSet) {
})
}
func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message, ts *types.TipSet) {
trigger := e.triggers[triggerId]
func (e *calledEvents) queueForConfidence(trigID uint64, msg *types.Message, ts *types.TipSet) {
trigger := e.triggers[trigID]
// messages are not applied in the tipset they are included in
appliedH := ts.Height() + 1
appliedH := ts.Height()
triggerH := appliedH + uint64(trigger.confidence)
triggerH := appliedH + abi.ChainEpoch(trigger.confidence)
byOrigH, ok := e.confQueue[triggerH]
if !ok {
byOrigH = map[uint64][]*queuedEvent{}
byOrigH = map[abi.ChainEpoch][]*queuedEvent{}
e.confQueue[triggerH] = byOrigH
}
byOrigH[appliedH] = append(byOrigH[appliedH], &queuedEvent{
trigger: triggerId,
trigger: trigID,
h: appliedH,
msg: msg,
})
@@ -170,8 +180,8 @@ func (e *calledEvents) queueForConfidence(triggerId uint64, msg *types.Message,
e.revertQueue[appliedH] = append(e.revertQueue[appliedH], triggerH)
}
func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
byOrigH, ok := e.confQueue[ts.Height()]
func (e *calledEvents) applyWithConfidence(ts *types.TipSet, height abi.ChainEpoch) {
byOrigH, ok := e.confQueue[height]
if !ok {
return // no triggers at thin height
}
@@ -179,7 +189,7 @@ func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
for origH, events := range byOrigH {
triggerTs, err := e.tsc.get(origH)
if err != nil {
log.Errorf("events: applyWithConfidence didn't find tipset for event; wanted %d; current %d", origH, ts.Height())
log.Errorf("events: applyWithConfidence didn't find tipset for event; wanted %d; current %d", origH, height)
}
for _, event := range events {
@@ -192,15 +202,15 @@ func (e *calledEvents) applyWithConfidence(ts *types.TipSet) {
continue
}
rec, err := e.cs.StateGetReceipt(e.ctx, event.msg.Cid(), ts)
rec, err := e.cs.StateGetReceipt(e.ctx, event.msg.Cid(), ts.Key())
if err != nil {
log.Error(err)
return
}
more, err := trigger.handle(event.msg, rec, triggerTs, ts.Height())
more, err := trigger.handle(event.msg, rec, triggerTs, height)
if err != nil {
log.Errorf("chain trigger (call %s.%d() @H %d, called @ %d) failed: %s", event.msg.To, event.msg.Method, origH, ts.Height(), err)
log.Errorf("chain trigger (call %s.%d() @H %d, called @ %d) failed: %s", event.msg.To, event.msg.Method, origH, height, err)
continue // don't revert failed calls
}
@@ -222,18 +232,18 @@ func (e *calledEvents) applyTimeouts(ts *types.TipSet) {
return // nothing to do
}
for triggerId, calls := range triggers {
for triggerID, calls := range triggers {
if calls > 0 {
continue // don't timeout if the method was called
}
trigger := e.triggers[triggerId]
trigger := e.triggers[triggerID]
if trigger.disabled {
continue
}
timeoutTs, err := e.tsc.get(ts.Height() - uint64(trigger.confidence))
timeoutTs, err := e.tsc.get(ts.Height() - abi.ChainEpoch(trigger.confidence))
if err != nil {
log.Errorf("events: applyTimeouts didn't find tipset for event; wanted %d; current %d", ts.Height()-uint64(trigger.confidence), ts.Height())
log.Errorf("events: applyTimeouts didn't find tipset for event; wanted %d; current %d", ts.Height()-abi.ChainEpoch(trigger.confidence), ts.Height())
}
more, err := trigger.handle(nil, nil, timeoutTs, ts.Height())
@@ -304,7 +314,7 @@ func (e *calledEvents) messagesForTs(ts *types.TipSet, consume func(*types.Messa
// containing the message. The tipset passed as the argument is the tipset
// that is being dropped. Note that the message dropped may be re-applied
// in a different tipset in small amount of time.
func (e *calledEvents) Called(check CheckFunc, hnd CalledHandler, rev RevertHandler, confidence int, timeout uint64, mf MatchFunc) error {
func (e *calledEvents) Called(check CheckFunc, hnd CalledHandler, rev RevertHandler, confidence int, timeout abi.ChainEpoch, mf MatchFunc) error {
e.lk.Lock()
defer e.lk.Unlock()
@@ -322,7 +332,7 @@ func (e *calledEvents) Called(check CheckFunc, hnd CalledHandler, rev RevertHand
e.triggers[id] = &callHandler{
confidence: confidence,
timeout: timeout + uint64(confidence),
timeout: timeout + abi.ChainEpoch(confidence),
disabled: !more,
@@ -333,15 +343,15 @@ func (e *calledEvents) Called(check CheckFunc, hnd CalledHandler, rev RevertHand
e.matchers[id] = append(e.matchers[id], mf)
if timeout != NoTimeout {
if e.timeouts[timeout+uint64(confidence)] == nil {
e.timeouts[timeout+uint64(confidence)] = map[uint64]int{}
if e.timeouts[timeout+abi.ChainEpoch(confidence)] == nil {
e.timeouts[timeout+abi.ChainEpoch(confidence)] = map[uint64]int{}
}
e.timeouts[timeout+uint64(confidence)][id] = 0
e.timeouts[timeout+abi.ChainEpoch(confidence)][id] = 0
}
return nil
}
func (e *calledEvents) CalledMsg(ctx context.Context, hnd CalledHandler, rev RevertHandler, confidence int, timeout uint64, msg store.ChainMsg) error {
func (e *calledEvents) CalledMsg(ctx context.Context, hnd CalledHandler, rev RevertHandler, confidence int, timeout abi.ChainEpoch, msg types.ChainMsg) error {
return e.Called(e.CheckMsg(ctx, msg, hnd), hnd, rev, confidence, timeout, e.MatchMsg(msg.VMMessage()))
}
+13 -12
View File
@@ -4,6 +4,7 @@ import (
"context"
"sync"
"github.com/filecoin-project/specs-actors/actors/abi"
"go.opencensus.io/trace"
"github.com/filecoin-project/lotus/chain/types"
@@ -12,14 +13,14 @@ import (
type heightEvents struct {
lk sync.Mutex
tsc *tipSetCache
gcConfidence uint64
gcConfidence abi.ChainEpoch
ctr triggerId
ctr triggerID
heightTriggers map[triggerId]*heightHandler
heightTriggers map[triggerID]*heightHandler
htTriggerHeights map[triggerH][]triggerId
htHeights map[msgH][]triggerId
htTriggerHeights map[triggerH][]triggerID
htHeights map[msgH][]triggerID
ctx context.Context
}
@@ -35,7 +36,7 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
// TODO: log error if h below gcconfidence
// revert height-based triggers
revert := func(h uint64, ts *types.TipSet) {
revert := func(h abi.ChainEpoch, ts *types.TipSet) {
for _, tid := range e.htHeights[h] {
ctx, span := trace.StartSpan(ctx, "events.HeightRevert")
@@ -80,7 +81,7 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
// height triggers
apply := func(h uint64, ts *types.TipSet) error {
apply := func(h abi.ChainEpoch, ts *types.TipSet) error {
for _, tid := range e.htTriggerHeights[h] {
hnd := e.heightTriggers[tid]
if hnd.called {
@@ -88,7 +89,7 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
}
hnd.called = true
triggerH := h - uint64(hnd.confidence)
triggerH := h - abi.ChainEpoch(hnd.confidence)
incTs, err := e.tsc.getNonNull(triggerH)
if err != nil {
@@ -139,13 +140,13 @@ func (e *heightEvents) headChangeAt(rev, app []*types.TipSet) error {
// specified height, `RevertHandler` will be called.
//
// ts passed to handlers is the tipset at the specified, or above, if lower tipsets were null
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h uint64) error {
func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence int, h abi.ChainEpoch) error {
e.lk.Lock() // Tricky locking, check your locks if you modify this function!
bestH := e.tsc.best().Height()
if bestH >= h+uint64(confidence) {
if bestH >= h+abi.ChainEpoch(confidence) {
ts, err := e.tsc.getNonNull(h)
if err != nil {
log.Warnf("events.ChainAt: calling HandleFunc with nil tipset, not found in cache: %s", err)
@@ -168,11 +169,11 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence
defer e.lk.Unlock()
if bestH >= h+uint64(confidence)+e.gcConfidence {
if bestH >= h+abi.ChainEpoch(confidence)+e.gcConfidence {
return nil
}
triggerAt := h + uint64(confidence)
triggerAt := h + abi.ChainEpoch(confidence)
id := e.ctr
e.ctr++
+261 -75
View File
@@ -3,18 +3,20 @@ package events
import (
"context"
"fmt"
"sync"
"testing"
"time"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/store"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multihash"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
)
@@ -31,28 +33,36 @@ type fakeMsg struct {
type fakeCS struct {
t *testing.T
h uint64
h abi.ChainEpoch
tsc *tipSetCache
msgs map[cid.Cid]fakeMsg
blkMsgs map[cid.Cid]cid.Cid
sync sync.Mutex
tipsets map[types.TipSetKey]*types.TipSet
sub func(rev, app []*types.TipSet)
}
func (fcs *fakeCS) StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) {
func (fcs *fakeCS) ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) {
return fcs.tipsets[key], nil
}
func (fcs *fakeCS) StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) {
return nil, nil
}
func (fcs *fakeCS) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) {
func (fcs *fakeCS) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {
panic("Not Implemented")
}
func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) {
panic("Not Implemented")
}
func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
func (fcs *fakeCS) makeTs(t *testing.T, parents []cid.Cid, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet {
a, _ := address.NewFromString("t00")
b, _ := address.NewFromString("t02")
var ts, err = types.NewTipSet([]*types.BlockHeader{
@@ -60,50 +70,59 @@ func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
Height: h,
Miner: a,
Parents: parents,
Ticket: &types.Ticket{VRFProof: []byte{byte(h % 2)}},
ParentStateRoot: dummyCid,
Messages: msgcid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: types.KTBLS},
BLSAggregate: types.Signature{Type: types.KTBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS},
},
{
Height: h,
Miner: b,
Parents: parents,
Ticket: &types.Ticket{VRFProof: []byte{byte((h + 1) % 2)}},
ParentStateRoot: dummyCid,
Messages: msgcid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: types.KTBLS},
BLSAggregate: types.Signature{Type: types.KTBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS},
},
})
if fcs.tipsets == nil {
fcs.tipsets = map[types.TipSetKey]*types.TipSet{}
}
fcs.tipsets[ts.Key()] = ts
require.NoError(t, err)
return ts
}
func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*store.HeadChange, error) {
out := make(chan []*store.HeadChange, 1)
out <- []*store.HeadChange{{Type: store.HCCurrent, Val: fcs.tsc.best()}}
func (fcs *fakeCS) ChainNotify(context.Context) (<-chan []*api.HeadChange, error) {
out := make(chan []*api.HeadChange, 1)
out <- []*api.HeadChange{{Type: store.HCCurrent, Val: fcs.tsc.best()}}
fcs.sub = func(rev, app []*types.TipSet) {
notif := make([]*store.HeadChange, len(rev)+len(app))
notif := make([]*api.HeadChange, len(rev)+len(app))
for i, r := range rev {
notif[i] = &store.HeadChange{
notif[i] = &api.HeadChange{
Type: store.HCRevert,
Val: r,
}
}
for i, r := range app {
notif[i+len(rev)] = &store.HeadChange{
notif[i+len(rev)] = &api.HeadChange{
Type: store.HCApply,
Val: r,
}
@@ -177,7 +196,7 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
continue
}
ts := makeTs(fcs.t, fcs.h, mc)
ts := fcs.makeTs(fcs.t, fcs.tsc.best().Key().Cids(), fcs.h, mc)
require.NoError(fcs.t, fcs.tsc.add(ts))
if hasMsgs {
@@ -187,11 +206,19 @@ func (fcs *fakeCS) advance(rev, app int, msgs map[int]cid.Cid, nulls ...int) { /
apps = append(apps, ts)
}
fcs.sync.Lock()
fcs.sub(revs, apps)
time.Sleep(100 * time.Millisecond) // TODO: :c
fcs.sync.Lock()
fcs.sync.Unlock() //nolint:staticcheck
}
var _ eventApi = &fakeCS{}
func (fcs *fakeCS) notifDone() {
fcs.sync.Unlock()
}
var _ eventAPI = &fakeCS{}
func TestAt(t *testing.T) {
fcs := &fakeCS{
@@ -199,14 +226,14 @@ func TestAt(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 5, int(ts.Height()))
require.Equal(t, 8, int(curH))
applied = true
@@ -264,14 +291,14 @@ func TestAtDoubleTrigger(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 5, int(ts.Height()))
require.Equal(t, 8, int(curH))
applied = true
@@ -306,15 +333,15 @@ func TestAtNullTrigger(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
require.Equal(t, uint64(6), ts.Height())
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, abi.ChainEpoch(6), ts.Height())
require.Equal(t, 8, int(curH))
applied = true
return nil
@@ -340,14 +367,14 @@ func TestAtNullConf(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 5, int(ts.Height()))
require.Equal(t, 8, int(curH))
applied = true
@@ -379,7 +406,7 @@ func TestAtStart(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -388,7 +415,7 @@ func TestAtStart(t *testing.T) {
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 5, int(ts.Height()))
require.Equal(t, 8, int(curH))
applied = true
@@ -413,7 +440,7 @@ func TestAtStartConfidence(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -422,7 +449,7 @@ func TestAtStartConfidence(t *testing.T) {
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 5, int(ts.Height()))
require.Equal(t, 11, int(curH))
applied = true
@@ -443,15 +470,15 @@ func TestAtChained(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 10, int(ts.Height()))
applied = true
return nil
@@ -477,7 +504,7 @@ func TestAtChainedConfidence(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -486,8 +513,8 @@ func TestAtChainedConfidence(t *testing.T) {
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
require.Equal(t, 10, int(ts.Height()))
applied = true
return nil
@@ -511,7 +538,7 @@ func TestAtChainedConfidenceNull(t *testing.T) {
h: 1,
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -520,7 +547,7 @@ func TestAtChainedConfidenceNull(t *testing.T) {
var applied bool
var reverted bool
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
applied = true
require.Equal(t, 6, int(ts.Height()))
return nil
@@ -534,7 +561,7 @@ func TestAtChainedConfidenceNull(t *testing.T) {
require.Equal(t, false, reverted)
}
func matchAddrMethod(to address.Address, m uint64) func(msg *types.Message) (bool, error) {
func matchAddrMethod(to address.Address, m abi.MethodNum) func(msg *types.Message) (bool, error) {
return func(msg *types.Message) (bool, error) {
return to == msg.To && m == msg.Method, nil
}
@@ -549,7 +576,7 @@ func TestCalled(t *testing.T) {
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -560,11 +587,11 @@ func TestCalled(t *testing.T) {
var applied, reverted bool
var appliedMsg *types.Message
var appliedTs *types.TipSet
var appliedH uint64
var appliedH abi.ChainEpoch
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return false, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
require.Equal(t, false, applied)
applied = true
appliedMsg = msg
@@ -610,12 +637,12 @@ func TestCalled(t *testing.T) {
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
require.Equal(t, uint64(7), appliedTs.Height())
require.Equal(t, abi.ChainEpoch(7), appliedTs.Height())
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
require.Equal(t, uint64(10), appliedH)
require.Equal(t, abi.ChainEpoch(10), appliedH)
require.Equal(t, t0123, appliedMsg.To)
require.Equal(t, uint64(1), appliedMsg.Nonce)
require.Equal(t, uint64(5), appliedMsg.Method)
require.Equal(t, abi.MethodNum(5), appliedMsg.Method)
// revert some blocks, keep the message
@@ -625,7 +652,7 @@ func TestCalled(t *testing.T) {
// revert the message
fcs.advance(2, 1, nil) // H=7, we reverted ts with the msg
fcs.advance(2, 1, nil) // H=7, we reverted ts with the msg execution, but not the msg itself
require.Equal(t, false, applied)
require.Equal(t, true, reverted)
@@ -639,24 +666,31 @@ func TestCalled(t *testing.T) {
},
})
fcs.advance(0, 5, map[int]cid.Cid{ // (confidence=3)
fcs.advance(0, 3, map[int]cid.Cid{ // (n2msg confidence=1)
0: n2msg,
})
require.Equal(t, true, applied) // msg from H=7, which had reverted execution
require.Equal(t, false, reverted)
require.Equal(t, abi.ChainEpoch(10), appliedH)
applied = false
fcs.advance(0, 2, nil) // (confidence=3)
require.Equal(t, true, applied)
require.Equal(t, false, reverted)
applied = false
require.Equal(t, uint64(9), appliedTs.Height())
require.Equal(t, abi.ChainEpoch(9), appliedTs.Height())
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
require.Equal(t, uint64(12), appliedH)
require.Equal(t, abi.ChainEpoch(12), appliedH)
require.Equal(t, t0123, appliedMsg.To)
require.Equal(t, uint64(2), appliedMsg.Nonce)
require.Equal(t, uint64(5), appliedMsg.Method)
require.Equal(t, abi.MethodNum(5), appliedMsg.Method)
// revert and apply at different height
fcs.advance(4, 6, map[int]cid.Cid{ // (confidence=3)
fcs.advance(8, 6, map[int]cid.Cid{ // (confidence=3)
1: n2msg,
})
@@ -668,12 +702,12 @@ func TestCalled(t *testing.T) {
reverted = false
applied = false
require.Equal(t, uint64(11), appliedTs.Height())
require.Equal(t, abi.ChainEpoch(7), appliedTs.Height())
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
require.Equal(t, uint64(14), appliedH)
require.Equal(t, abi.ChainEpoch(10), appliedH)
require.Equal(t, t0123, appliedMsg.To)
require.Equal(t, uint64(2), appliedMsg.Nonce)
require.Equal(t, uint64(5), appliedMsg.Method)
require.Equal(t, abi.MethodNum(5), appliedMsg.Method)
// call method again
@@ -694,7 +728,7 @@ func TestCalled(t *testing.T) {
}),
})
fcs.advance(1, 4, nil) // H=19, but message reverted
fcs.advance(2, 5, nil) // H=19, but message reverted
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
@@ -754,7 +788,7 @@ func TestCalledTimeout(t *testing.T) {
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -765,11 +799,11 @@ func TestCalledTimeout(t *testing.T) {
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return false, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
called = true
require.Nil(t, msg)
require.Equal(t, uint64(20), ts.Height())
require.Equal(t, uint64(23), curH)
require.Equal(t, abi.ChainEpoch(20), ts.Height())
require.Equal(t, abi.ChainEpoch(23), curH)
return false, nil
}, func(_ context.Context, ts *types.TipSet) error {
t.Fatal("revert on timeout")
@@ -794,17 +828,17 @@ func TestCalledTimeout(t *testing.T) {
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events = NewEvents(context.Background(), fcs)
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return true, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
called = true
require.Nil(t, msg)
require.Equal(t, uint64(20), ts.Height())
require.Equal(t, uint64(23), curH)
require.Equal(t, abi.ChainEpoch(20), ts.Height())
require.Equal(t, abi.ChainEpoch(23), curH)
return false, nil
}, func(_ context.Context, ts *types.TipSet) error {
t.Fatal("revert on timeout")
@@ -828,7 +862,7 @@ func TestCalledOrder(t *testing.T) {
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(makeTs(t, 1, dummyCid)))
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
@@ -839,14 +873,14 @@ func TestCalledOrder(t *testing.T) {
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return false, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
switch at {
case 0:
require.Equal(t, uint64(1), msg.Nonce)
require.Equal(t, uint64(4), ts.Height())
require.Equal(t, abi.ChainEpoch(4), ts.Height())
case 1:
require.Equal(t, uint64(2), msg.Nonce)
require.Equal(t, uint64(5), ts.Height())
require.Equal(t, abi.ChainEpoch(5), ts.Height())
default:
t.Fatal("apply should only get called twice, at: ", at)
}
@@ -855,9 +889,9 @@ func TestCalledOrder(t *testing.T) {
}, func(_ context.Context, ts *types.TipSet) error {
switch at {
case 2:
require.Equal(t, uint64(5), ts.Height())
require.Equal(t, abi.ChainEpoch(5), ts.Height())
case 3:
require.Equal(t, uint64(4), ts.Height())
require.Equal(t, abi.ChainEpoch(4), ts.Height())
default:
t.Fatal("revert should only get called twice, at: ", at)
}
@@ -881,3 +915,155 @@ func TestCalledOrder(t *testing.T) {
fcs.advance(9, 1, nil)
}
func TestCalledNull(t *testing.T) {
fcs := &fakeCS{
t: t,
h: 1,
msgs: map[cid.Cid]fakeMsg{},
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
t0123, err := address.NewFromString("t0123")
require.NoError(t, err)
more := true
var applied, reverted bool
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return false, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
require.Equal(t, false, applied)
applied = true
return more, nil
}, func(_ context.Context, ts *types.TipSet) error {
reverted = true
return nil
}, 3, 20, matchAddrMethod(t0123, 5))
require.NoError(t, err)
// create few blocks to make sure nothing get's randomly called
fcs.advance(0, 4, nil) // H=5
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create blocks with message (but below confidence threshold)
fcs.advance(0, 3, map[int]cid.Cid{ // msg at H=6; H=8 (confidence=2)
0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{
{To: t0123, From: t0123, Method: 5, Nonce: 1},
},
}),
})
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create additional blocks so we are above confidence threshold, but with null tipset at the height
// of application
fcs.advance(0, 3, nil, 10) // H=11 (confidence=3, apply)
require.Equal(t, true, applied)
require.Equal(t, false, reverted)
applied = false
fcs.advance(5, 1, nil, 10)
require.Equal(t, false, applied)
require.Equal(t, true, reverted)
}
func TestRemoveTriggersOnMessage(t *testing.T) {
fcs := &fakeCS{
t: t,
h: 1,
msgs: map[cid.Cid]fakeMsg{},
blkMsgs: map[cid.Cid]cid.Cid{},
tsc: newTSCache(2*build.ForkLengthThreshold, nil),
}
require.NoError(t, fcs.tsc.add(fcs.makeTs(t, nil, 1, dummyCid)))
events := NewEvents(context.Background(), fcs)
t0123, err := address.NewFromString("t0123")
require.NoError(t, err)
more := true
var applied, reverted bool
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
return false, true, nil
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
require.Equal(t, false, applied)
fmt.Println(msg == nil)
fmt.Println(curH)
applied = true
return more, nil
}, func(_ context.Context, ts *types.TipSet) error {
reverted = true
return nil
}, 3, 20, matchAddrMethod(t0123, 5))
require.NoError(t, err)
// create few blocks to make sure nothing get's randomly called
fcs.advance(0, 4, nil) // H=5
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create blocks with message (but below confidence threshold)
fcs.advance(0, 3, map[int]cid.Cid{ // msg occurs at H=5, applied at H=6; H=8 (confidence=2)
0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{
{To: t0123, From: t0123, Method: 5, Nonce: 1},
},
}),
})
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// revert applied TS & message TS
fcs.advance(3, 1, nil) // H=6 (tipset message applied in reverted, AND message reverted)
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create additional blocks so we are above confidence threshold, but message not applied
// as it was reverted
fcs.advance(0, 5, nil) // H=11 (confidence=3, apply)
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create blocks with message again (but below confidence threshold)
fcs.advance(0, 3, map[int]cid.Cid{ // msg occurs at H=12, applied at H=13; H=15 (confidence=2)
0: fcs.fakeMsgs(fakeMsg{
bmsgs: []*types.Message{
{To: t0123, From: t0123, Method: 5, Nonce: 2},
},
}),
})
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// revert applied height TS, but don't remove message trigger
fcs.advance(2, 1, nil) // H=13 (tipset message applied in reverted, by tipset with message not reverted)
require.Equal(t, false, applied)
require.Equal(t, false, reverted)
// create additional blocks so we are above confidence threshold
fcs.advance(0, 4, nil) // H=18 (confidence=3, apply)
require.Equal(t, true, applied)
require.Equal(t, false, reverted)
}
+7 -6
View File
@@ -3,12 +3,13 @@ package events
import (
"context"
"github.com/filecoin-project/specs-actors/actors/abi"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/types"
)
type tsByHFunc func(context.Context, uint64, *types.TipSet) (*types.TipSet, error)
type tsByHFunc func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
// tipSetCache implements a simple ring-buffer cache to keep track of recent
// tipsets
@@ -20,7 +21,7 @@ type tipSetCache struct {
storage tsByHFunc
}
func newTSCache(cap int, storage tsByHFunc) *tipSetCache {
func newTSCache(cap abi.ChainEpoch, storage tsByHFunc) *tipSetCache {
return &tipSetCache{
cache: make([]*types.TipSet, cap),
start: 0,
@@ -77,7 +78,7 @@ func (tsc *tipSetCache) revert(ts *types.TipSet) error {
return nil
}
func (tsc *tipSetCache) getNonNull(height uint64) (*types.TipSet, error) {
func (tsc *tipSetCache) getNonNull(height abi.ChainEpoch) (*types.TipSet, error) {
for {
ts, err := tsc.get(height)
if err != nil {
@@ -90,10 +91,10 @@ func (tsc *tipSetCache) getNonNull(height uint64) (*types.TipSet, error) {
}
}
func (tsc *tipSetCache) get(height uint64) (*types.TipSet, error) {
func (tsc *tipSetCache) get(height abi.ChainEpoch) (*types.TipSet, error) {
if tsc.len == 0 {
log.Warnf("tipSetCache.get: cache is empty, requesting from storage (h=%d)", height)
return tsc.storage(context.TODO(), height, nil)
return tsc.storage(context.TODO(), height, types.EmptyTSK)
}
headH := tsc.cache[tsc.start].Height()
@@ -113,7 +114,7 @@ func (tsc *tipSetCache) get(height uint64) (*types.TipSet, error) {
if height < tail.Height() {
log.Warnf("tipSetCache.get: requested tipset not in cache, requesting from storage (h=%d; tail=%d)", height, tail.Height())
return tsc.storage(context.TODO(), height, tail)
return tsc.storage(context.TODO(), height, tail.Key())
}
return tsc.cache[normalModulo(tsc.start-int(headH-height), clen)], nil
+11 -9
View File
@@ -4,19 +4,21 @@ import (
"context"
"testing"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types"
)
func TestTsCache(t *testing.T) {
tsc := newTSCache(50, func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) {
t.Fatal("storage call")
return &types.TipSet{}, nil
})
h := uint64(75)
h := abi.ChainEpoch(75)
a, _ := address.NewFromString("t00")
@@ -27,8 +29,8 @@ func TestTsCache(t *testing.T) {
ParentStateRoot: dummyCid,
Messages: dummyCid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: types.KTBLS},
BLSAggregate: types.Signature{Type: types.KTBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS},
}})
if err != nil {
t.Fatal(err)
@@ -54,12 +56,12 @@ func TestTsCache(t *testing.T) {
}
func TestTsCacheNulls(t *testing.T) {
tsc := newTSCache(50, func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error) {
t.Fatal("storage call")
return &types.TipSet{}, nil
})
h := uint64(75)
h := abi.ChainEpoch(75)
a, _ := address.NewFromString("t00")
add := func() {
@@ -69,8 +71,8 @@ func TestTsCacheNulls(t *testing.T) {
ParentStateRoot: dummyCid,
Messages: dummyCid,
ParentMessageReceipts: dummyCid,
BlockSig: &types.Signature{Type: types.KTBLS},
BLSAggregate: types.Signature{Type: types.KTBLS},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS},
}})
if err != nil {
t.Fatal(err)
+4 -5
View File
@@ -5,15 +5,14 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
)
func (e *calledEvents) CheckMsg(ctx context.Context, smsg store.ChainMsg, hnd CalledHandler) CheckFunc {
func (e *calledEvents) CheckMsg(ctx context.Context, smsg types.ChainMsg, hnd CalledHandler) CheckFunc {
msg := smsg.VMMessage()
return func(ts *types.TipSet) (done bool, more bool, err error) {
fa, err := e.cs.StateGetActor(ctx, msg.From, ts)
fa, err := e.cs.StateGetActor(ctx, msg.From, ts.Key())
if err != nil {
return false, true, err
}
@@ -23,7 +22,7 @@ func (e *calledEvents) CheckMsg(ctx context.Context, smsg store.ChainMsg, hnd Ca
return false, true, nil
}
rec, err := e.cs.StateGetReceipt(ctx, smsg.VMMessage().Cid(), ts)
rec, err := e.cs.StateGetReceipt(ctx, smsg.VMMessage().Cid(), ts.Key())
if err != nil {
return false, true, xerrors.Errorf("getting receipt in CheckMsg: %w", err)
}
@@ -37,7 +36,7 @@ func (e *calledEvents) CheckMsg(ctx context.Context, smsg store.ChainMsg, hnd Ca
func (e *calledEvents) MatchMsg(inmsg *types.Message) MatchFunc {
return func(msg *types.Message) (bool, error) {
if msg.From == inmsg.From && msg.Nonce == inmsg.Nonce && !inmsg.Equals(msg) {
return false, xerrors.Errorf("matching msg %s from %s, nonce %d: got duplicate origin/nonce msg %s", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce)
return false, xerrors.Errorf("matching msg %s from %s, nonce %d: got duplicate origin/nonce msg %d", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce)
}
return inmsg.Equals(msg), nil
+245 -263
View File
@@ -3,38 +3,42 @@ package gen
import (
"bytes"
"context"
"crypto/sha256"
"encoding/binary"
"fmt"
"io/ioutil"
"sync/atomic"
"time"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/abi"
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/crypto"
block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-blockservice"
"github.com/ipfs/go-car"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
offline "github.com/ipfs/go-ipfs-exchange-offline"
format "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2"
"github.com/ipfs/go-merkledag"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/ipld/go-car"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/address"
"github.com/filecoin-project/lotus/chain/beacon"
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/lib/sectorbuilder"
"github.com/filecoin-project/lotus/lib/sigs"
"github.com/filecoin-project/lotus/node/repo"
block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
logging "github.com/ipfs/go-log"
"github.com/filecoin-project/sector-storage/ffiwrapper"
)
var log = logging.Logger("gen")
@@ -48,16 +52,20 @@ type ChainGen struct {
cs *store.ChainStore
beacon beacon.RandomBeacon
sm *stmgr.StateManager
genesis *types.BlockHeader
CurTipset *store.FullTipSet
Timestamper func(*types.TipSet, uint64) uint64
Timestamper func(*types.TipSet, abi.ChainEpoch) uint64
GetMessages func(*ChainGen) ([]*types.SignedMessage, error)
w *wallet.Wallet
eppProvs map[address.Address]ElectionPoStProver
eppProvs map[address.Address]WinningPoStProver
Miners []address.Address
receivers []address.Address
banker address.Address
@@ -80,7 +88,11 @@ func (m mybs) Get(c cid.Cid) (block.Block, error) {
return b, nil
}
func NewGenerator() (*ChainGen, error) {
func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
saminer.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
abi.RegisteredProof_StackedDRG2KiBSeal: {},
}
mr := repo.NewMemory(nil)
lr, err := mr.Lock(repo.StorageMiner)
if err != nil {
@@ -92,7 +104,7 @@ func NewGenerator() (*ChainGen, error) {
return nil, xerrors.Errorf("failed to get metadata datastore: %w", err)
}
bds, err := lr.Datastore("/blocks")
bds, err := lr.Datastore("/chain")
if err != nil {
return nil, xerrors.Errorf("failed to get blocks datastore: %w", err)
}
@@ -109,77 +121,86 @@ func NewGenerator() (*ChainGen, error) {
return nil, xerrors.Errorf("creating memrepo wallet failed: %w", err)
}
banker, err := w.GenerateKey(types.KTSecp256k1)
banker, err := w.GenerateKey(crypto.SigTypeSecp256k1)
if err != nil {
return nil, xerrors.Errorf("failed to generate banker key: %w", err)
}
receievers := make([]address.Address, msgsPerBlock)
for r := range receievers {
receievers[r], err = w.GenerateKey(types.KTBLS)
receievers[r], err = w.GenerateKey(crypto.SigTypeBLS)
if err != nil {
return nil, xerrors.Errorf("failed to generate receiver key: %w", err)
}
}
maddr1, err := address.NewFromString("t0300")
if err != nil {
return nil, err
}
maddr1 := genesis2.MinerAddress(0)
m1temp, err := ioutil.TempDir("", "preseal")
if err != nil {
return nil, err
}
genm1, err := seed.PreSeal(maddr1, 1024, 0, 1, m1temp, []byte("some randomness"))
genm1, k1, err := seed.PreSeal(maddr1, abi.RegisteredProof_StackedDRG2KiBPoSt, 0, numSectors, m1temp, []byte("some randomness"), nil)
if err != nil {
return nil, err
}
maddr2, err := address.NewFromString("t0301")
if err != nil {
return nil, err
}
maddr2 := genesis2.MinerAddress(1)
m2temp, err := ioutil.TempDir("", "preseal")
if err != nil {
return nil, err
}
genm2, err := seed.PreSeal(maddr2, 1024, 0, 1, m2temp, []byte("some randomness"))
genm2, k2, err := seed.PreSeal(maddr2, abi.RegisteredProof_StackedDRG2KiBPoSt, 0, numSectors, m2temp, []byte("some randomness"), nil)
if err != nil {
return nil, err
}
mk1, err := w.Import(&genm1.Key)
mk1, err := w.Import(k1)
if err != nil {
return nil, err
}
mk2, err := w.Import(&genm2.Key)
mk2, err := w.Import(k2)
if err != nil {
return nil, err
}
minercfg := &GenMinerCfg{
PeerIDs: []peer.ID{"peerID1", "peerID2"},
PreSeals: map[string]genesis.GenesisMiner{
maddr1.String(): *genm1,
maddr2.String(): *genm2,
sys := vm.Syscalls(&genFakeVerifier{})
tpl := genesis.Template{
Accounts: []genesis.Actor{
{
Type: genesis.TAccount,
Balance: types.FromFil(40000),
Meta: (&genesis.AccountMeta{Owner: mk1}).ActorMeta(),
},
{
Type: genesis.TAccount,
Balance: types.FromFil(40000),
Meta: (&genesis.AccountMeta{Owner: mk2}).ActorMeta(),
},
{
Type: genesis.TAccount,
Balance: types.FromFil(50000),
Meta: (&genesis.AccountMeta{Owner: banker}).ActorMeta(),
},
},
MinerAddrs: []address.Address{maddr1, maddr2},
Miners: []genesis.Miner{
*genm1,
*genm2,
},
NetworkName: "",
Timestamp: uint64(time.Now().Add(-500 * build.BlockDelay * time.Second).Unix()),
}
genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{
mk1: types.FromFil(40000),
mk2: types.FromFil(40000),
banker: types.FromFil(50000),
}, minercfg, 100000)
genb, err := genesis2.MakeGenesisBlock(context.TODO(), bs, sys, tpl)
if err != nil {
return nil, xerrors.Errorf("make genesis block failed: %w", err)
}
cs := store.NewChainStore(bs, ds)
cs := store.NewChainStore(bs, ds, sys)
genfb := &types.FullBlock{Header: genb.Genesis}
gents := store.NewFullTipSet([]*types.FullBlock{genfb})
@@ -188,29 +209,35 @@ func NewGenerator() (*ChainGen, error) {
return nil, xerrors.Errorf("set genesis failed: %w", err)
}
if len(minercfg.MinerAddrs) == 0 {
return nil, xerrors.Errorf("MakeGenesisBlock failed to set miner address")
}
mgen := make(map[address.Address]ElectionPoStProver)
for _, m := range minercfg.MinerAddrs {
mgen[m] = &eppProvider{}
mgen := make(map[address.Address]WinningPoStProver)
for i := range tpl.Miners {
mgen[genesis2.MinerAddress(uint64(i))] = &wppProvider{}
}
sm := stmgr.NewStateManager(cs)
miners := []address.Address{maddr1, maddr2}
beac := beacon.NewMockBeacon(time.Second)
//beac, err := drand.NewDrandBeacon(tpl.Timestamp, build.BlockDelay)
//if err != nil {
//return nil, xerrors.Errorf("creating drand beacon: %w", err)
//}
gen := &ChainGen{
bs: bs,
cs: cs,
sm: sm,
msgsPerBlock: msgsPerBlock,
genesis: genb.Genesis,
beacon: beac,
w: w,
Miners: minercfg.MinerAddrs,
eppProvs: mgen,
banker: banker,
receivers: receievers,
GetMessages: getRandomMessages,
Miners: miners,
eppProvs: mgen,
banker: banker,
receivers: receievers,
CurTipset: gents,
@@ -221,6 +248,18 @@ func NewGenerator() (*ChainGen, error) {
return gen, nil
}
func NewGenerator() (*ChainGen, error) {
return NewGeneratorWithSectors(1)
}
func (cg *ChainGen) SetStateManager(sm *stmgr.StateManager) {
cg.sm = sm
}
func (cg *ChainGen) ChainStore() *store.ChainStore {
return cg.cs
}
func (cg *ChainGen) Genesis() *types.BlockHeader {
return cg.genesis
}
@@ -232,46 +271,76 @@ func (cg *ChainGen) GenesisCar() ([]byte, error) {
out := new(bytes.Buffer)
if err := car.WriteCar(context.TODO(), dserv, []cid.Cid{cg.Genesis().Cid()}, out); err != nil {
if err := car.WriteCarWithWalker(context.TODO(), dserv, []cid.Cid{cg.Genesis().Cid()}, out, CarWalkFunc); err != nil {
return nil, xerrors.Errorf("genesis car write car failed: %w", err)
}
return out.Bytes(), nil
}
func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m address.Address, round int64) (*types.EPostProof, *types.Ticket, error) {
func CarWalkFunc(nd format.Node) (out []*format.Link, err error) {
for _, link := range nd.Links() {
if link.Cid.Prefix().MhType == uint64(commcid.FC_SEALED_V1) || link.Cid.Prefix().MhType == uint64(commcid.FC_UNSEALED_V1) {
continue
}
out = append(out, link)
}
lastTicket := pts.MinTicket()
return out, nil
}
func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m address.Address, round abi.ChainEpoch) ([]types.BeaconEntry, *types.ElectionProof, *types.Ticket, error) {
mc := &mca{w: cg.w, sm: cg.sm, pv: ffiwrapper.ProofVerifier, bcn: cg.beacon}
mbi, err := mc.MinerGetBaseInfo(ctx, m, round, pts.Key())
if err != nil {
return nil, nil, nil, xerrors.Errorf("get miner base info: %w", err)
}
prev := mbi.PrevBeaconEntry
entries, err := beacon.BeaconEntriesForBlock(ctx, cg.beacon, round, prev)
if err != nil {
return nil, nil, nil, xerrors.Errorf("get beacon entries for block: %w", err)
}
rbase := prev
if len(entries) > 0 {
rbase = entries[len(entries)-1]
}
eproof, err := IsRoundWinner(ctx, pts, round, m, rbase, mbi, mc)
if err != nil {
return nil, nil, nil, xerrors.Errorf("checking round winner failed: %w", err)
}
buf := new(bytes.Buffer)
if err := m.MarshalCBOR(buf); err != nil {
return nil, nil, nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
}
if len(entries) == 0 {
buf.Write(pts.MinTicket().VRFProof)
}
ticketRand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes())
if err != nil {
return nil, nil, nil, err
}
st := pts.ParentState()
worker, err := stmgr.GetMinerWorkerRaw(ctx, cg.sm, st, m)
if err != nil {
return nil, nil, xerrors.Errorf("get miner worker: %w", err)
return nil, nil, nil, xerrors.Errorf("get miner worker: %w", err)
}
vrfout, err := ComputeVRF(ctx, cg.w.Sign, worker, m, DSepTicket, lastTicket.VRFProof)
vrfout, err := ComputeVRF(ctx, cg.w.Sign, worker, ticketRand)
if err != nil {
return nil, nil, xerrors.Errorf("compute VRF: %w", err)
return nil, nil, nil, xerrors.Errorf("compute VRF: %w", err)
}
tick := &types.Ticket{
VRFProof: vrfout,
}
eproofin, err := IsRoundWinner(ctx, pts, round, m, cg.eppProvs[m], &mca{w: cg.w, sm: cg.sm})
if err != nil {
return nil, nil, xerrors.Errorf("checking round winner failed: %w", err)
}
if eproofin == nil {
return nil, tick, nil
}
eproof, err := ComputeProof(ctx, cg.eppProvs[m], eproofin)
if err != nil {
return nil, nil, xerrors.Errorf("computing proof: %w", err)
}
return eproof, tick, nil
return entries, eproof, &types.Ticket{VRFProof: vrfout}, nil
}
type MinedTipSet struct {
@@ -292,20 +361,26 @@ func (cg *ChainGen) NextTipSet() (*MinedTipSet, error) {
func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Address) (*MinedTipSet, error) {
var blks []*types.FullBlock
msgs, err := cg.getRandomMessages()
msgs, err := cg.GetMessages(cg)
if err != nil {
return nil, xerrors.Errorf("get random messages: %w", err)
}
for round := int64(base.Height() + 1); len(blks) == 0; round++ {
for round := base.Height() + 1; len(blks) == 0; round++ {
for _, m := range miners {
proof, t, err := cg.nextBlockProof(context.TODO(), base, m, round)
bvals, et, ticket, err := cg.nextBlockProof(context.TODO(), base, m, round)
if err != nil {
return nil, xerrors.Errorf("next block proof: %w", err)
}
if proof != nil {
fblk, err := cg.makeBlock(base, m, proof, t, uint64(round), msgs)
if et != nil {
// TODO: maybe think about passing in more real parameters to this?
wpost, err := cg.eppProvs[m].ComputeProof(context.TODO(), nil, nil)
if err != nil {
return nil, err
}
fblk, err := cg.makeBlock(base, m, ticket, et, bvals, round, wpost, msgs)
if err != nil {
return nil, xerrors.Errorf("making a block for next tipset failed: %w", err)
}
@@ -327,16 +402,28 @@ func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Ad
}, nil
}
func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, eproof *types.EPostProof, ticket *types.Ticket, height uint64, msgs []*types.SignedMessage) (*types.FullBlock, error) {
func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket,
eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch,
wpost []abi.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {
var ts uint64
if cg.Timestamper != nil {
ts = cg.Timestamper(parents, height-parents.Height())
} else {
ts = parents.MinTimestamp() + ((height - parents.Height()) * build.BlockDelay)
ts = parents.MinTimestamp() + uint64((height-parents.Height())*build.BlockDelay)
}
fblk, err := MinerCreateBlock(context.TODO(), cg.sm, cg.w, m, parents, ticket, eproof, msgs, height, ts)
fblk, err := MinerCreateBlock(context.TODO(), cg.sm, cg.w, &api.BlockTemplate{
Miner: m,
Parents: parents.Key(),
Ticket: vrfticket,
Eproof: eticket,
BeaconValues: bvals,
Messages: msgs,
Epoch: height,
Timestamp: ts,
WinningPoStProof: wpost,
})
if err != nil {
return nil, err
}
@@ -344,7 +431,7 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, eproof *
return fblk, err
}
// This function is awkward. It's used to deal with messages made when
// ResyncBankerNonce is used for dealing with messages made when
// simulating forks
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
act, err := cg.sm.GetActor(cg.banker, ts)
@@ -356,7 +443,15 @@ func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
return nil
}
func (cg *ChainGen) getRandomMessages() ([]*types.SignedMessage, error) {
func (cg *ChainGen) Banker() address.Address {
return cg.banker
}
func (cg *ChainGen) Wallet() *wallet.Wallet {
return cg.w
}
func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) {
msgs := make([]*types.SignedMessage, cg.msgsPerBlock)
for m := range msgs {
msg := types.Message{
@@ -369,7 +464,7 @@ func (cg *ChainGen) getRandomMessages() ([]*types.SignedMessage, error) {
Method: 0,
GasLimit: types.NewInt(10000),
GasLimit: 10000,
GasPrice: types.NewInt(0),
}
@@ -395,240 +490,127 @@ func (cg *ChainGen) YieldRepo() (repo.Repo, error) {
}
type MiningCheckAPI interface {
ChainGetRandomness(context.Context, types.TipSetKey, int64) ([]byte, error)
ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
StateMinerPower(context.Context, address.Address, *types.TipSet) (api.MinerPower, error)
MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*api.MiningBaseInfo, error)
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
StateMinerSectorSize(context.Context, address.Address, *types.TipSet) (uint64, error)
StateMinerProvingSet(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error)
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
}
type mca struct {
w *wallet.Wallet
sm *stmgr.StateManager
w *wallet.Wallet
sm *stmgr.StateManager
pv ffiwrapper.Verifier
bcn beacon.RandomBeacon
}
func (mca mca) ChainGetRandomness(ctx context.Context, pts types.TipSetKey, lb int64) ([]byte, error) {
return mca.sm.ChainStore().GetRandomness(ctx, pts.Cids(), int64(lb))
}
func (mca mca) StateMinerPower(ctx context.Context, maddr address.Address, ts *types.TipSet) (api.MinerPower, error) {
mpow, tpow, err := stmgr.GetPower(ctx, mca.sm, ts, maddr)
func (mca mca) ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
pts, err := mca.sm.ChainStore().LoadTipSet(tsk)
if err != nil {
return api.MinerPower{}, err
return nil, xerrors.Errorf("loading tipset key: %w", err)
}
return api.MinerPower{
MinerPower: mpow,
TotalPower: tpow,
}, err
return mca.sm.ChainStore().GetRandomness(ctx, pts.Cids(), personalization, randEpoch, entropy)
}
func (mca mca) StateMinerWorker(ctx context.Context, maddr address.Address, ts *types.TipSet) (address.Address, error) {
return stmgr.GetMinerWorkerRaw(ctx, mca.sm, ts.ParentState(), maddr)
func (mca mca) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) {
return stmgr.MinerGetBaseInfo(ctx, mca.sm, mca.bcn, tsk, epoch, maddr, mca.pv)
}
func (mca mca) StateMinerSectorSize(ctx context.Context, maddr address.Address, ts *types.TipSet) (uint64, error) {
return stmgr.GetMinerSectorSize(ctx, mca.sm, ts, maddr)
}
func (mca mca) StateMinerProvingSet(ctx context.Context, maddr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) {
return stmgr.GetMinerProvingSet(ctx, mca.sm, ts, maddr)
}
func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*types.Signature, error) {
func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*crypto.Signature, error) {
return mca.w.Sign(ctx, a, v)
}
type ElectionPoStProver interface {
GenerateCandidates(context.Context, sectorbuilder.SortedPublicSectorInfo, []byte) ([]sectorbuilder.EPostCandidate, error)
ComputeProof(context.Context, sectorbuilder.SortedPublicSectorInfo, []byte, []sectorbuilder.EPostCandidate) ([]byte, error)
type WinningPoStProver interface {
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
ComputeProof(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]abi.PoStProof, error)
}
type eppProvider struct{}
type wppProvider struct{}
func (epp *eppProvider) GenerateCandidates(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte) ([]sectorbuilder.EPostCandidate, error) {
return []sectorbuilder.EPostCandidate{
{
SectorID: 1,
PartialTicket: [32]byte{},
Ticket: [32]byte{},
SectorChallengeIndex: 1,
},
}, nil
func (wpp *wppProvider) GenerateCandidates(ctx context.Context, _ abi.PoStRandomness, _ uint64) ([]uint64, error) {
return []uint64{0}, nil
}
func (epp *eppProvider) ComputeProof(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte, winners []sectorbuilder.EPostCandidate) ([]byte, error) {
return []byte("valid proof"), nil
func (wpp *wppProvider) ComputeProof(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]abi.PoStProof, error) {
return []abi.PoStProof{{
ProofBytes: []byte("valid proof"),
}}, nil
}
type ProofInput struct {
sectors sectorbuilder.SortedPublicSectorInfo
hvrf []byte
winners []sectorbuilder.EPostCandidate
vrfout []byte
}
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner address.Address, epp ElectionPoStProver, a MiningCheckAPI) (*ProofInput, error) {
r, err := a.ChainGetRandomness(ctx, ts.Key(), round-build.EcRandomnessLookback)
if err != nil {
return nil, xerrors.Errorf("chain get randomness: %w", err)
buf := new(bytes.Buffer)
if err := miner.MarshalCBOR(buf); err != nil {
return nil, xerrors.Errorf("failed to cbor marshal address: %w")
}
mworker, err := a.StateMinerWorker(ctx, miner, ts)
electionRand, err := store.DrawRandomness(brand.Data, crypto.DomainSeparationTag_ElectionProofProduction, round, buf.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to get miner worker: %w", err)
return nil, xerrors.Errorf("failed to draw randomness: %w", err)
}
vrfout, err := ComputeVRF(ctx, a.WalletSign, mworker, miner, DSepElectionPost, r)
vrfout, err := ComputeVRF(ctx, a.WalletSign, mbi.WorkerKey, electionRand)
if err != nil {
return nil, xerrors.Errorf("failed to compute VRF: %w", err)
}
pset, err := a.StateMinerProvingSet(ctx, miner, ts)
if err != nil {
return nil, xerrors.Errorf("failed to load proving set for miner: %w", err)
}
if len(pset) == 0 {
// TODO: wire in real power
if !types.IsTicketWinner(vrfout, mbi.MinerPower, mbi.NetworkPower) {
return nil, nil
}
var sinfos []ffi.PublicSectorInfo
for _, s := range pset {
var commRa [32]byte
copy(commRa[:], s.CommR)
sinfos = append(sinfos, ffi.PublicSectorInfo{
SectorID: s.SectorID,
CommR: commRa,
})
}
sectors := sectorbuilder.NewSortedPublicSectorInfo(sinfos)
hvrf := sha256.Sum256(vrfout)
candidates, err := epp.GenerateCandidates(ctx, sectors, hvrf[:])
if err != nil {
return nil, xerrors.Errorf("failed to generate electionPoSt candidates: %w", err)
}
pow, err := a.StateMinerPower(ctx, miner, ts)
if err != nil {
return nil, xerrors.Errorf("failed to check power: %w", err)
}
ssize, err := a.StateMinerSectorSize(ctx, miner, ts)
if err != nil {
return nil, xerrors.Errorf("failed to look up miners sector size: %w", err)
}
var winners []sectorbuilder.EPostCandidate
for _, c := range candidates {
if types.IsTicketWinner(c.PartialTicket[:], ssize, uint64(len(sinfos)), pow.TotalPower) {
winners = append(winners, c)
}
}
// no winners, sad
if len(winners) == 0 {
return nil, nil
}
return &ProofInput{
sectors: sectors,
hvrf: hvrf[:],
winners: winners,
vrfout: vrfout,
}, nil
return &types.ElectionProof{VRFProof: vrfout}, nil
}
func ComputeProof(ctx context.Context, epp ElectionPoStProver, pi *ProofInput) (*types.EPostProof, error) {
proof, err := epp.ComputeProof(ctx, pi.sectors, pi.hvrf, pi.winners)
if err != nil {
return nil, xerrors.Errorf("failed to compute snark for election proof: %w", err)
}
type SignFunc func(context.Context, address.Address, []byte) (*crypto.Signature, error)
ept := types.EPostProof{
Proof: proof,
PostRand: pi.vrfout,
}
for _, win := range pi.winners {
part := make([]byte, 32)
copy(part, win.PartialTicket[:])
ept.Candidates = append(ept.Candidates, types.EPostTicket{
Partial: part,
SectorID: win.SectorID,
ChallengeIndex: win.SectorChallengeIndex,
})
}
return &ept, nil
}
type SignFunc func(context.Context, address.Address, []byte) (*types.Signature, error)
const (
DSepTicket = 1
DSepElectionPost = 2
)
func hashVRFBase(personalization uint64, miner address.Address, input []byte) ([]byte, error) {
if miner.Protocol() != address.ID {
return nil, xerrors.Errorf("miner address for compute VRF must be an ID address")
}
var persbuf [8]byte
binary.LittleEndian.PutUint64(persbuf[:], personalization)
h := sha256.New()
h.Write(persbuf[:])
h.Write([]byte{0})
h.Write(input)
h.Write([]byte{0})
h.Write(miner.Bytes())
return h.Sum(nil), nil
}
func VerifyVRF(ctx context.Context, worker, miner address.Address, p uint64, input, vrfproof []byte) error {
func VerifyVRF(ctx context.Context, worker address.Address, vrfBase, vrfproof []byte) error {
_, span := trace.StartSpan(ctx, "VerifyVRF")
defer span.End()
vrfBase, err := hashVRFBase(p, miner, input)
if err != nil {
return xerrors.Errorf("computing vrf base failed: %w", err)
}
sig := &types.Signature{
Type: types.KTBLS,
sig := &crypto.Signature{
Type: crypto.SigTypeBLS,
Data: vrfproof,
}
if err := sig.Verify(worker, vrfBase); err != nil {
if err := sigs.Verify(sig, worker, vrfBase); err != nil {
return xerrors.Errorf("vrf was invalid: %w", err)
}
return nil
}
func ComputeVRF(ctx context.Context, sign SignFunc, worker, miner address.Address, p uint64, input []byte) ([]byte, error) {
sigInput, err := hashVRFBase(p, miner, input)
if err != nil {
return nil, err
}
func ComputeVRF(ctx context.Context, sign SignFunc, worker address.Address, sigInput []byte) ([]byte, error) {
sig, err := sign(ctx, worker, sigInput)
if err != nil {
return nil, err
}
if sig.Type != types.KTBLS {
if sig.Type != crypto.SigTypeBLS {
return nil, fmt.Errorf("miner worker address was not a BLS key")
}
return sig.Data, nil
}
type genFakeVerifier struct{}
var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)
func (m genFakeVerifier) VerifySeal(svi abi.SealVerifyInfo) (bool, error) {
return true, nil
}
func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info abi.WinningPoStVerifyInfo) (bool, error) {
panic("not supported")
}
func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info abi.WindowPoStVerifyInfo) (bool, error) {
panic("not supported")
}
func (m genFakeVerifier) GenerateWinningPoStSectorChallenge(ctx context.Context, proof abi.RegisteredProof, id abi.ActorID, randomness abi.PoStRandomness, u uint64) ([]uint64, error) {
panic("not supported")
}
+23 -12
View File
@@ -3,18 +3,28 @@ package gen
import (
"testing"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
)
func init() {
build.SectorSizes = []uint64{1024}
build.MinimumMinerPower = 1024
miner.SupportedProofTypes = map[abi.RegisteredProof]struct{}{
abi.RegisteredProof_StackedDRG2KiBSeal: {},
}
power.ConsensusMinerMinPower = big.NewInt(2048)
verifreg.MinVerifiedDealSize = big.NewInt(256)
}
func testGeneration(t testing.TB, n int, msgs int) {
g, err := NewGenerator()
func testGeneration(t testing.TB, n int, msgs int, sectors int) {
g, err := NewGeneratorWithSectors(sectors)
if err != nil {
t.Fatal(err)
t.Fatalf("%+v", err)
}
g.msgsPerBlock = msgs
@@ -22,30 +32,31 @@ func testGeneration(t testing.TB, n int, msgs int) {
for i := 0; i < n; i++ {
mts, err := g.NextTipSet()
if err != nil {
t.Fatalf("error at H:%d, %s", i, err)
t.Fatalf("error at H:%d, %+v", i, err)
}
_ = mts
}
}
func TestChainGeneration(t *testing.T) {
testGeneration(t, 10, 20)
testGeneration(t, 10, 20, 1)
testGeneration(t, 10, 20, 25)
}
func BenchmarkChainGeneration(b *testing.B) {
b.Run("0-messages", func(b *testing.B) {
testGeneration(b, b.N, 0)
testGeneration(b, b.N, 0, 1)
})
b.Run("10-messages", func(b *testing.B) {
testGeneration(b, b.N, 10)
testGeneration(b, b.N, 10, 1)
})
b.Run("100-messages", func(b *testing.B) {
testGeneration(b, b.N, 100)
testGeneration(b, b.N, 100, 1)
})
b.Run("1000-messages", func(b *testing.B) {
testGeneration(b, b.N, 1000)
testGeneration(b, b.N, 1000, 1)
})
}
+370
View File
@@ -0,0 +1,370 @@
package genesis
import (
"context"
"encoding/json"
"github.com/filecoin-project/go-amt-ipld/v2"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/genesis"
)
const AccountStart = 100
const MinerStart = 1000
const MaxAccounts = MinerStart - AccountStart
var log = logging.Logger("genesis")
type GenesisBootstrap struct {
Genesis *types.BlockHeader
}
/*
From a list of parameters, create a genesis block / initial state
The process:
- Bootstrap state (MakeInitialStateTree)
- Create empty state
- Create system actor
- Make init actor
- Create accounts mappings
- Set NextID to MinerStart
- Setup Reward (1.4B fil)
- Setup Cron
- Create empty power actor
- Create empty market
- Create verified registry
- Setup burnt fund address
- Initialize account / msig balances
- Instantiate early vm with genesis syscalls
- Create miners
- Each:
- power.CreateMiner, set msg value to PowerBalance
- market.AddFunds with correct value
- market.PublishDeals for related sectors
- Set precommits
- Commit presealed sectors
Data Types:
PreSeal :{
CommR CID
CommD CID
SectorID SectorNumber
Deal market.DealProposal # Start at 0, self-deal!
}
Genesis: {
Accounts: [ # non-miner, non-singleton actors, max len = MaxAccounts
{
Type: "account" / "multisig",
Value: "attofil",
[Meta: {msig settings, account key..}]
},...
],
Miners: [
{
Owner, Worker Addr # ID
MarketBalance, PowerBalance TokenAmount
SectorSize uint64
PreSeals []PreSeal
},...
],
}
*/
func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template genesis.Template) (*state.StateTree, error) {
// Create empty state tree
cst := cbor.NewCborStore(bs)
_, err := cst.Put(context.TODO(), []struct{}{})
if err != nil {
return nil, xerrors.Errorf("putting empty object: %w", err)
}
state, err := state.NewStateTree(cst)
if err != nil {
return nil, xerrors.Errorf("making new state tree: %w", err)
}
emptyobject, err := cst.Put(context.TODO(), []struct{}{})
if err != nil {
return nil, xerrors.Errorf("failed putting empty object: %w", err)
}
// Create system actor
sysact, err := SetupSystemActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup init actor: %w", err)
}
if err := state.SetActor(builtin.SystemActorAddr, sysact); err != nil {
return nil, xerrors.Errorf("set init actor: %w", err)
}
// Create init actor
initact, err := SetupInitActor(bs, template.NetworkName, template.Accounts)
if err != nil {
return nil, xerrors.Errorf("setup init actor: %w", err)
}
if err := state.SetActor(builtin.InitActorAddr, initact); err != nil {
return nil, xerrors.Errorf("set init actor: %w", err)
}
// Setup reward
rewact, err := SetupRewardActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup init actor: %w", err)
}
err = state.SetActor(builtin.RewardActorAddr, rewact)
if err != nil {
return nil, xerrors.Errorf("set network account actor: %w", err)
}
// Setup cron
cronact, err := SetupCronActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup cron actor: %w", err)
}
if err := state.SetActor(builtin.CronActorAddr, cronact); err != nil {
return nil, xerrors.Errorf("set cron actor: %w", err)
}
// Create empty power actor
spact, err := SetupStoragePowerActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup storage market actor: %w", err)
}
if err := state.SetActor(builtin.StoragePowerActorAddr, spact); err != nil {
return nil, xerrors.Errorf("set storage market actor: %w", err)
}
// Create empty market actor
marketact, err := SetupStorageMarketActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup storage market actor: %w", err)
}
if err := state.SetActor(builtin.StorageMarketActorAddr, marketact); err != nil {
return nil, xerrors.Errorf("set market actor: %w", err)
}
// Create verified registry
verifact, err := SetupVerifiedRegistryActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup storage market actor: %w", err)
}
if err := state.SetActor(builtin.VerifiedRegistryActorAddr, verifact); err != nil {
return nil, xerrors.Errorf("set market actor: %w", err)
}
// Setup burnt-funds
err = state.SetActor(builtin.BurntFundsActorAddr, &types.Actor{
Code: builtin.AccountActorCodeID,
Balance: types.NewInt(0),
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("set burnt funds account actor: %w", err)
}
// Create accounts
for id, info := range template.Accounts {
if info.Type != genesis.TAccount {
return nil, xerrors.New("unsupported account type") // TODO: msigs
}
ida, err := address.NewIDAddress(uint64(AccountStart + id))
if err != nil {
return nil, err
}
var ainfo genesis.AccountMeta
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
}
st, err := cst.Put(ctx, &account.State{Address: ainfo.Owner})
if err != nil {
return nil, err
}
err = state.SetActor(ida, &types.Actor{
Code: builtin.AccountActorCodeID,
Balance: info.Balance,
Head: st,
})
if err != nil {
return nil, xerrors.Errorf("setting account from actmap: %w", err)
}
}
vregroot, err := address.NewIDAddress(80)
if err != nil {
return nil, err
}
vrst, err := cst.Put(ctx, &account.State{Address: RootVerifierAddr})
if err != nil {
return nil, err
}
err = state.SetActor(vregroot, &types.Actor{
Code: builtin.AccountActorCodeID,
Balance: types.NewInt(0),
Head: vrst,
})
if err != nil {
return nil, xerrors.Errorf("setting account from actmap: %w", err)
}
return state, nil
}
func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template) (cid.Cid, error) {
verifNeeds := make(map[address.Address]abi.PaddedPieceSize)
var sum abi.PaddedPieceSize
for _, m := range template.Miners {
for _, s := range m.Sectors {
amt := s.Deal.PieceSize
verifNeeds[s.Deal.Client] += amt
sum += amt
}
}
verifier, err := address.NewIDAddress(80)
if err != nil {
return cid.Undef, err
}
vm, err := vm.NewVM(stateroot, 0, &fakeRand{}, cs.Blockstore(), &fakedSigSyscalls{cs.VMSys()})
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
}
_, err = doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, RootVerifierAddr, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifier, mustEnc(&verifreg.AddVerifierParams{
Address: verifier,
Allowance: abi.NewStoragePower(int64(sum)), // eh, close enough
}))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to failed to create verifier: %w", err)
}
for c, amt := range verifNeeds {
_, err := doExecValue(ctx, vm, builtin.VerifiedRegistryActorAddr, verifier, types.NewInt(0), builtin.MethodsVerifiedRegistry.AddVerifiedClient, mustEnc(&verifreg.AddVerifiedClientParams{
Address: c,
Allowance: abi.NewStoragePower(int64(amt)),
}))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to add verified client: %w", err)
}
}
return vm.Flush(ctx)
}
func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Syscalls, template genesis.Template) (*GenesisBootstrap, error) {
st, err := MakeInitialStateTree(ctx, bs, template)
if err != nil {
return nil, xerrors.Errorf("make initial state tree failed: %w", err)
}
stateroot, err := st.Flush(ctx)
if err != nil {
return nil, xerrors.Errorf("flush state tree failed: %w", err)
}
// temp chainstore
cs := store.NewChainStore(bs, datastore.NewMapDatastore(), sys)
// Verify PreSealed Data
stateroot, err = VerifyPreSealedData(ctx, cs, stateroot, template)
if err != nil {
return nil, xerrors.Errorf("failed to verify presealed data: %w", err)
}
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners)
if err != nil {
return nil, xerrors.Errorf("setup storage miners failed: %w", err)
}
cst := cbor.NewCborStore(bs)
emptyroot, err := amt.FromArray(ctx, cst, nil)
if err != nil {
return nil, xerrors.Errorf("amt build failed: %w", err)
}
mm := &types.MsgMeta{
BlsMessages: emptyroot,
SecpkMessages: emptyroot,
}
mmb, err := mm.ToStorageBlock()
if err != nil {
return nil, xerrors.Errorf("serializing msgmeta failed: %w", err)
}
if err := bs.Put(mmb); err != nil {
return nil, xerrors.Errorf("putting msgmeta block to blockstore: %w", err)
}
log.Infof("Empty Genesis root: %s", emptyroot)
genesisticket := &types.Ticket{
VRFProof: []byte("vrf proof0000000vrf proof0000000"),
}
b := &types.BlockHeader{
Miner: builtin.SystemActorAddr,
Ticket: genesisticket,
Parents: []cid.Cid{},
Height: 0,
ParentWeight: types.NewInt(0),
ParentStateRoot: stateroot,
Messages: mmb.Cid(),
ParentMessageReceipts: emptyroot,
BLSAggregate: nil,
BlockSig: nil,
Timestamp: template.Timestamp,
ElectionProof: new(types.ElectionProof),
BeaconEntries: []types.BeaconEntry{
{
Round: 0,
Data: make([]byte, 32),
},
},
}
sb, err := b.ToStorageBlock()
if err != nil {
return nil, xerrors.Errorf("serializing block header failed: %w", err)
}
if err := bs.Put(sb); err != nil {
return nil, xerrors.Errorf("putting header to blockstore: %w", err)
}
return &GenesisBootstrap{
Genesis: b,
}, nil
}
+260
View File
@@ -0,0 +1,260 @@
package genesis
import (
"bytes"
"context"
"fmt"
"math/rand"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/sector-storage/ffiwrapper"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/genesis"
)
func MinerAddress(genesisIndex uint64) address.Address {
maddr, err := address.NewIDAddress(MinerStart + genesisIndex)
if err != nil {
panic(err)
}
return maddr
}
type fakedSigSyscalls struct {
runtime.Syscalls
}
func (fss *fakedSigSyscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error {
return nil
}
func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, miners []genesis.Miner) (cid.Cid, error) {
vm, err := vm.NewVM(sroot, 0, &fakeRand{}, cs.Blockstore(), &fakedSigSyscalls{cs.VMSys()})
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
}
if len(miners) == 0 {
return cid.Undef, xerrors.New("no genesis miners")
}
for i, m := range miners {
// Create miner through power actor
i := i
m := m
spt, err := ffiwrapper.SealProofTypeFromSectorSize(m.SectorSize)
if err != nil {
return cid.Undef, err
}
var maddr address.Address
{
constructorParams := &power.CreateMinerParams{
Owner: m.Worker,
Worker: m.Worker,
Peer: []byte(m.PeerId),
SealProofType: spt,
}
params := mustEnc(constructorParams)
rval, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
var ma power.CreateMinerReturn
if err := ma.UnmarshalCBOR(bytes.NewReader(rval)); err != nil {
return cid.Undef, xerrors.Errorf("unmarshaling CreateMinerReturn: %w", err)
}
expma := MinerAddress(uint64(i))
if ma.IDAddress != expma {
return cid.Undef, xerrors.Errorf("miner assigned wrong address: %s != %s", ma.IDAddress, expma)
}
maddr = ma.IDAddress
}
// Add market funds
{
params := mustEnc(&maddr)
_, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
{
params := mustEnc(&m.Worker)
_, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.AddBalance, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
// Publish preseal deals
var dealIDs []abi.DealID
{
publish := func(params *market.PublishStorageDealsParams) error {
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
if err != nil {
return xerrors.Errorf("failed to create genesis miner: %w", err)
}
var ids market.PublishStorageDealsReturn
if err := ids.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
return xerrors.Errorf("unmarsahling publishStorageDeals result: %w", err)
}
dealIDs = append(dealIDs, ids.IDs...)
return nil
}
params := &market.PublishStorageDealsParams{}
for _, preseal := range m.Sectors {
preseal.Deal.VerifiedDeal = true
params.Deals = append(params.Deals, market.ClientDealProposal{
Proposal: preseal.Deal,
ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup?
})
if len(params.Deals) == cbg.MaxLength {
if err := publish(params); err != nil {
return cid.Undef, err
}
params = &market.PublishStorageDealsParams{}
}
}
if len(params.Deals) > 0 {
if err := publish(params); err != nil {
return cid.Undef, err
}
}
}
// Commit sectors
for pi, preseal := range m.Sectors {
preseal := preseal
// TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file)
// check deals, get dealWeight
var dealWeight market.VerifyDealsOnSectorProveCommitReturn
{
params := &market.VerifyDealsOnSectorProveCommitParams{
DealIDs: []abi.DealID{dealIDs[pi]},
SectorExpiry: preseal.Deal.EndEpoch,
}
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, maddr, big.Zero(), builtin.MethodsMarket.VerifyDealsOnSectorProveCommit, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to verify preseal deals miner: %w", err)
}
if err := dealWeight.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
return cid.Undef, xerrors.Errorf("unmarshaling market onProveCommit result: %w", err)
}
}
// update power claims
{
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
weight := &power.SectorStorageWeightDesc{
SectorSize: m.SectorSize,
Duration: preseal.Deal.Duration(),
DealWeight: dealWeight.DealWeight,
VerifiedDealWeight: dealWeight.VerifiedDealWeight,
}
qapower := power.QAPowerForWeight(weight)
err := st.AddToClaim(&state.AdtStore{cst}, maddr, types.NewInt(uint64(weight.SectorSize)), qapower)
if err != nil {
return xerrors.Errorf("add to claim: %w", err)
}
fmt.Println("Added weight to claim: ", st.TotalRawBytePower, st.TotalQualityAdjPower)
return nil
})
if err != nil {
return cid.Undef, xerrors.Errorf("register power claim in power actor: %w", err)
}
}
// Put sectors to miner sector sets
{
newSectorInfo := &miner.SectorOnChainInfo{
Info: miner.SectorPreCommitInfo{
RegisteredProof: preseal.ProofType,
SectorNumber: preseal.SectorID,
SealedCID: preseal.CommR,
SealRandEpoch: 0,
DealIDs: []abi.DealID{dealIDs[pi]},
Expiration: preseal.Deal.EndEpoch,
},
ActivationEpoch: 0,
DealWeight: dealWeight.DealWeight,
VerifiedDealWeight: dealWeight.VerifiedDealWeight,
}
err = vm.MutateState(ctx, maddr, func(cst cbor.IpldStore, st *miner.State) error {
store := &state.AdtStore{cst}
if err = st.PutSector(store, newSectorInfo); err != nil {
return xerrors.Errorf("failed to put sector: %v", err)
}
if err := st.AddNewSectors(newSectorInfo.Info.SectorNumber); err != nil {
return xerrors.Errorf("failed to add NewSector: %w", err)
}
return nil
})
if err != nil {
return cid.Cid{}, xerrors.Errorf("put to sset: %w", err)
}
}
}
}
// TODO: to avoid division by zero, we set the initial power actor power to 1, this adjusts that back down so the accounting is accurate.
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
st.TotalQualityAdjPower = big.Sub(st.TotalQualityAdjPower, big.NewInt(1))
return nil
})
c, err := vm.Flush(ctx)
if err != nil {
return cid.Undef, xerrors.Errorf("flushing vm: %w", err)
}
return c, nil
}
// TODO: copied from actors test harness, deduplicate or remove from here
type fakeRand struct{}
func (fr *fakeRand) GetRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) ([]byte, error) {
out := make([]byte, 32)
_, _ = rand.New(rand.NewSource(int64(randEpoch))).Read(out)
return out, nil
}
+29
View File
@@ -0,0 +1,29 @@
package genesis
import (
"context"
"github.com/filecoin-project/specs-actors/actors/builtin/system"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/builtin"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
)
func SetupSystemActor(bs bstore.Blockstore) (*types.Actor, error) {
var st system.State
cst := cbor.NewCborStore(bs)
statecid, err := cst.Put(context.TODO(), &st)
if err != nil {
return nil, err
}
act := &types.Actor{
Code: builtin.SystemActorCodeID,
Head: statecid,
}
return act, nil
}

Some files were not shown because too many files have changed in this diff Show More