Compare commits

...
Author SHA1 Message Date
Travis Person 098cc3c804 Butterfly genesis 2020-07-19 17:46:36 +00:00
Travis Person 13670d5a2b New butterfly network info 2020-07-19 17:25:23 +00:00
Łukasz Magiera db92b99ec1 Merge pull request #2473 from filecoin-project/drand/testnet
Use drand testnet
2020-07-19 18:30:10 +02:00
Jakub Sztandera 15ae22c680 Use drand testnet
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-19 17:32:41 +02:00
Łukasz Magiera c4ded2fc07 Merge pull request #2469 from filecoin-project/fix/miner-info
fix miner info
2020-07-18 21:23:10 +02:00
Łukasz Magiera 65f509db40 Merge pull request #2468 from filecoin-project/fix/initial-pledge-api
fix StateMinerInitialPledgeCollateral
2020-07-18 21:22:38 +02:00
Łukasz Magiera 0c8b451a00 fix miner info 2020-07-18 14:54:21 +02:00
Łukasz Magiera 780a892eb4 fix StateMinerInitialPledgeCollateral 2020-07-18 12:31:32 +02:00
Łukasz Magiera 1a1bd38495 Merge remote-tracking branch 'origin/master' into next 2020-07-18 00:43:08 +02:00
Łukasz Magiera 3383e6adc0 Merge pull request #2461 from filecoin-project/feat/win-sched-storage
Update sector-storage with window based scheduler
2020-07-18 00:39:59 +02:00
Łukasz Magiera d266c665b0 Update sector-storage with windowed scheduler 2020-07-18 00:38:02 +02:00
Łukasz Magiera e02b40f04f Merge pull request #2460 from filecoin-project/feat/specs-actors-v0.8ish
Feat/specs actors v0.8ish
2020-07-18 00:36:13 +02:00
Łukasz Magiera 76ff938e00 Update chain-val 2020-07-18 00:27:17 +02:00
Łukasz Magiera a06e685cfc Merge pull request #2450 from filecoin-project/feat/seed-msig-work
Feat/seed msig work
2020-07-18 00:21:45 +02:00
Łukasz Magiera 6cd1240fa2 Merge pull request #2459 from filecoin-project/feat/single-multi-ds
Use single multi ds
2020-07-18 00:18:32 +02:00
Łukasz Magiera 0ded061037 Get math to work 2020-07-18 00:15:21 +02:00
whyrusleeping 665b873c96 more permissive parsing, also don't set useless actor addr 2020-07-17 14:27:56 -07:00
Łukasz Magiera 956f4d5e14 update specs-actors more 2020-07-17 22:58:04 +02:00
Jakub Sztandera 0f5e56289e Update stores list when deleting
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-17 22:44:16 +02:00
Jakub Sztandera f2ebeaa7e4 Fix lint
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-17 22:29:39 +02:00
Jakub Sztandera cc1d23a94c Use single multi ds
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-17 22:14:37 +02:00
Łukasz Magiera 6ff99315a1 Merge pull request #2457 from filecoin-project/fix/master-merge
Fix chainwatch merge conflicts
2020-07-17 22:12:37 +02:00
Mike Greenberg 7e46fc1d8f fix: Comment out affected Actor interactions from API shift 2020-07-17 15:19:05 -04:00
Mike Greenberg d30e120608 Merge branch 'master' into fix/master-merge
* master:
  fix(chainwatch): Parallel reward persistence; Tighten rpc logging
  fix(chainwatch): Remove --front switch
  feat(chainwatch): Add miner index on top_miners_by_base_reward view
  fix(chainwatch): Backoff processor when no work exists to process
  fix(log): Move metrics and stage updates to debug; Add --log-level switch
  fix(chainwatch): Correct index name on state_height view
  feat(chainwatch): Capture base_block_reward per epoch; Top miner by reward view
  SwapSigner API methods
  refactor: remove unused code
  refactor: wire up new processor and syncer
  refactor: implement processor and syncer

 Conflicts:
        Makefile
        cmd/lotus-chainwatch/storage.go
        cmd/lotus-chainwatch/sync.go
2020-07-17 15:18:33 -04:00
Jakub Sztandera 1b5797be9d Merge pull request #2456 from filecoin-project/feat/increase-cron-gas
Increase cron gas
2020-07-17 20:11:21 +02:00
Jakub Sztandera b6f3513173 Increase gas limit for CallRaw
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-17 19:54:39 +02:00
Jakub Sztandera aafafce083 Increase cron gas
Make gas check overflow safe
2020-07-17 19:49:55 +02:00
Łukasz Magiera 441c70750c Merge pull request #2413 from filecoin-project/feat/actors-miner-refactor
Consume miner actor refactor
2020-07-17 19:33:07 +02:00
Łukasz Magiera de271fe729 build: Bump API version 2020-07-17 18:30:50 +02:00
Łukasz Magiera 4e1e9ecf3e Address review 2020-07-17 18:23:19 +02:00
Łukasz Magiera 4b74aa5768 wdpost: Correctly prove 0 sectors 2020-07-17 16:47:16 +02:00
Łukasz Magiera 56d13534b4 ProvingSet -> ActiveSectors 2020-07-17 16:26:48 +02:00
Łukasz Magiera bbc2657023 Fix StateMinerProvingSet 2020-07-17 16:21:00 +02:00
Łukasz Magiera 0a471bb12c Update chain-val 2020-07-17 15:59:03 +02:00
Łukasz Magiera 06acda0ab9 mod tidy, gofmt 2020-07-17 15:18:40 +02:00
Łukasz Magiera cb6767a02b Merge remote-tracking branch 'origin/next' into feat/actors-miner-refactor 2020-07-17 15:18:11 +02:00
Łukasz Magiera b026de2feb Use specs-actors master 2020-07-17 15:03:59 +02:00
whyrusleeping fe4a8dc183 finish integration of multisig genesis accounts 2020-07-16 19:50:13 -07:00
Łukasz Magiera 389d148a60 Merge pull request #2447 from filecoin-project/dep/badger
Update badger
2020-07-17 01:48:57 +02:00
Łukasz Magiera be97a2e4a5 Merge pull request #2428 from ribasushi/chore/pre-update-more-deps
Bump fil-commcid and filecoin-ffi deps
2020-07-17 00:50:13 +02:00
Peter Rabbitson e266f3b955 Bump fil-commcid and filecoin-ffi deps
Propagates correct on-chain commX CIDs
2020-07-17 00:38:42 +02:00
Sami Mäkelä f1b8e1a7b0 skip empty addresses 2020-07-16 15:31:00 -07:00
Sami Mäkelä 6a403df100 csv reader 2020-07-16 15:31:00 -07:00
Sami Mäkelä 38e0dbb236 cleanup 2020-07-16 15:30:59 -07:00
Sami Mäkelä ab5b69c5e4 add it to map 2020-07-16 15:30:59 -07:00
Sami Mäkelä 21b78514f5 working 2020-07-16 15:30:59 -07:00
whyrusleeping fb34d2b9e3 WIP: parse msig accounts file and include it into the genesis template 2020-07-16 15:30:59 -07:00
Jakub Sztandera 2b0492c6d6 Update badger
Replace is needed as badger master's latest tag is v2.0.1

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-17 00:14:51 +02:00
Łukasz Magiera 5dacd51b91 Merge pull request #2444 from filecoin-project/fix/1950
Update sector-storage, fixes #1950
2020-07-16 18:50:29 +02:00
Łukasz Magiera 19f7fd304d Update sector-storage, fixes #1950 2020-07-16 18:30:42 +02:00
Łukasz Magiera 9f4fb428c9 gofmt 2020-07-16 17:24:55 +02:00
Łukasz Magiera bdc8f7a2cb Api getting correct sector expiration info 2020-07-16 17:24:41 +02:00
Łukasz Magiera 5a3ab5c5f0 More actor updates 2020-07-16 14:48:20 +02:00
Łukasz Magiera 6092854ece Merge pull request #2384 from filecoin-project/asr/seal-duration
Add expected seal duration to custom deal logic
2020-07-16 11:34:46 +02:00
Łukasz Magiera 02176ec5f8 Merge pull request #2426 from filecoin-project/feat/block-gas-limit
Add block gas limit verification
2020-07-16 11:30:25 +02:00
Jakub Sztandera 02631155dc Add block gas limit verification
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-16 01:00:03 +02:00
Aayush Rajasekaran a5ef629cef Add expected seal duration to custom deal logic, reject deals that start too early 2020-07-15 17:31:50 -04:00
Łukasz Magiera 9b6afd82aa Merge pull request #2422 from filecoin-project/feat/upgrade-retrieval
Update markets with new retrieval
2020-07-15 23:10:20 +02:00
Łukasz Magiera 4553af505f Merge pull request #2343 from filecoin-project/feat/more-gas
Make virtual gas real
2020-07-15 23:09:17 +02:00
hannahhoward 61f120222f feat(markets): update markets with new retrieval 2020-07-15 14:04:31 -07:00
Jakub Sztandera 610ed0dc13 Change OnIpldGet
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 21:40:49 +02:00
Jakub Sztandera 399c171f03 Update gas limits, update storage-fsm
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 21:21:53 +02:00
Jakub Sztandera 7b14d445b4 Update message gas limits
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 20:01:57 +02:00
Jakub Sztandera 61156afd90 Update chain val
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 20:01:57 +02:00
Jakub Sztandera 347c2ed498 Update chain-val to new gas values
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 20:01:57 +02:00
Jakub Sztandera 4dd6f6400c Make virtual gas real
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 20:01:57 +02:00
Jakub Sztandera c0eb4b39ac Reorg some gas charges
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-15 20:01:56 +02:00
Aayush Rajasekaran 55618f20d4 Merge pull request #2381 from filecoin-project/asr/faq
Add a FAQ
2020-07-15 13:52:23 -04:00
Aayush Rajasekaran d7db55af39 Add a FAQ 2020-07-15 13:48:10 -04:00
Łukasz Magiera c1233291bc Merge remote-tracking branch 'origin/master' into next 2020-07-15 19:47:27 +02:00
Łukasz Magiera 0f2043d874 Merge pull request #2317 from filcloud/issue-2304
fix issue 2304: ux improvements
2020-07-15 19:38:35 +02:00
Łukasz Magiera 068f6a2e83 Merge pull request #2362 from filecoin-project/mock-clock
introduce the ability to mock time.
2020-07-15 18:41:00 +02:00
Łukasz Magiera 1efb8b4cc0 update cbor-gen 2020-07-15 16:54:29 +02:00
Raúl Kripalani a44e80c829 Merge branch 'next' into mock-clock 2020-07-15 15:51:11 +01:00
Raúl Kripalani 86457e5201 fix flaky test (miner#TestMessageFiltering). (#2411) 2020-07-15 15:50:32 +01:00
Łukasz Magiera 59b2908620 Merge pull request #2415 from filecoin-project/feat/test/post/standard-tag
debug: standard PoSt tag
2020-07-15 16:07:21 +02:00
Łukasz Magiera 658681d002 Merge pull request #2412 from filecoin-project/feat/drand-devnet
Update to drand devnet
2020-07-15 12:47:36 +02:00
Łukasz Magiera d41a07161d paychmgr: handle voucher.ChannelAddr 2020-07-15 11:12:03 +02:00
Łukasz Magiera fc13794f5f Update StateMinerProvingDeadline 2020-07-15 11:06:14 +02:00
Lucas Molas 0313ab4e49 debug: standard PoSt tag 2020-07-14 19:22:25 -03:00
Łukasz Magiera bbfa66636d More test fixing 2020-07-14 22:30:25 +02:00
Łukasz Magiera 59e5144122 fix storage-miner cli 2020-07-14 22:14:37 +02:00
Jakub Sztandera 6ecc96d193 Update to drand devnet
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-14 21:16:26 +02:00
Łukasz Magiera 0ccc9f65a6 gofmt 2020-07-14 19:10:37 +02:00
Łukasz Magiera af87b9aa98 Fix widowed PoSt scheduler 2020-07-14 19:10:31 +02:00
Raúl Kripalani 0484496d92 Merge branch 'next' into mock-clock 2020-07-14 18:08:26 +01:00
Raúl Kripalani fbf6596f20 revert to real time for socket/stream deadlines. 2020-07-14 17:42:52 +01:00
Raúl Kripalani 55d88440eb refine block timing log statements. 2020-07-14 17:12:00 +01:00
Łukasz Magiera f53bd6bdba StateSectorPartition api 2020-07-14 14:32:17 +02:00
Łukasz Magiera faebc4c948 WIP Integrating specs-actors with refactored miner state 2020-07-14 13:45:45 +02:00
Łukasz Magiera 55cfebb439 Merge pull request #2405 from keyko-io/fix/hamt-loadnode
Fixing hamt bittreewidth
2020-07-14 12:39:03 +02:00
Sami Mäkelä d388566d5c fixing 2020-07-14 12:54:18 +03:00
Frank 5cc4f8132a reset comment 2020-07-14 10:53:24 +08:00
Łukasz Magiera a778917806 gofmt 2020-07-13 13:35:10 +02:00
Łukasz Magiera 2e4ed57363 Merge remote-tracking branch 'origin/master' into next 2020-07-13 13:34:56 +02:00
Łukasz Magiera 4e987163af Merge pull request #2385 from filecoin-project/feat/fountain-amount
lotus_fountain: add facuet distribution amount flag
2020-07-13 13:16:19 +02:00
Łukasz Magiera 2c87890758 Merge pull request #2354 from filecoin-project/asr/specs-update
specs actors update
2020-07-13 12:50:25 +02:00
Raúl Kripalani 973dbd6a13 Merge branch 'next' into mock-clock 2020-07-13 11:29:53 +01:00
Łukasz Magiera c1048a0353 vm: Separate logger for actors 2020-07-13 12:29:27 +02:00
Łukasz Magiera 896f0c69fc gomod: Use chain-val master 2020-07-13 12:27:35 +02:00
Travis Person f18bef867e lotus_fountain: add facuet distribution amount flag 2020-07-12 21:03:05 +00:00
Aayush Rajasekaran 6504b914ba Update chain-val and storage-fsm to temp commits 2020-07-12 01:15:47 -04:00
Aayush Rajasekaran 7e9f9106c9 Update specs actors 2020-07-12 00:30:42 -04:00
Aayush Rajasekaran 69626272d5 Update with reward state changes 2020-07-12 00:30:42 -04:00
Aayush Rajasekaran eed44d12ba Add log method to Runtime 2020-07-12 00:30:42 -04:00
Aayush Rajasekaran 2a61b241a8 Replace abi.BitFieldUnion with bitfield.MultiMerge 2020-07-12 00:30:42 -04:00
Frank 14ec9a2068 update storage miner and seal worker document 2020-07-11 16:55:13 +08:00
Łukasz Magiera 89a6b6842c Merge remote-tracking branch 'origin/master' into next 2020-07-10 22:24:41 +02:00
Łukasz Magiera 8ce35e30dd Merge remote-tracking branch 'origin/master' into next 2020-07-10 21:50:38 +02:00
Łukasz Magiera 6569cf8e0c Merge pull request #2347 from filecoin-project/ingar/select-retrieval-providers
Add a maxPrice option to the client retrieval CLI
2020-07-10 21:29:12 +02:00
Łukasz Magiera 58769b1d75 Merge pull request #2374 from filecoin-project/fix/voucher-lane-limit
Account for other vouchers when checking balance
2020-07-10 21:28:49 +02:00
Dirk McCormick a12e5884ab fix: add TODO about lane merging 2020-07-10 15:24:13 -04:00
Łukasz Magiera 3fcf7a0344 client: Fix an off-by-10^18 error setting retrieval maxPrice 2020-07-10 21:18:18 +02:00
Łukasz Magiera 8be4375288 Merge pull request #2372 from filecoin-project/fix/ret-keynotfound
Fix retrieval datastore-key-not-found error
2020-07-10 20:32:38 +02:00
Dirk McCormick f07c7377b6 feat: account for other vouchers when calculating voucher validity 2020-07-10 14:06:52 -04:00
Ingar Shu 7929a335c3 Add default max price, fix error messaging 2020-07-10 10:11:15 -07:00
Ingar Shu 5411ebb806 Add maxPrice option to client retrieval
- Use best offer if multiple offers returned
2020-07-10 10:04:54 -07:00
Łukasz Magiera ede57c0b12 Fix retrieval datastore-key-not-found error 2020-07-10 18:33:26 +02:00
Łukasz Magiera 56dd3f40e0 Merge pull request #2361 from filecoin-project/fix/seal-worker-init
Fix seal-worker init
2020-07-10 18:20:01 +02:00
Raúl Kripalani 13de81b3b2 introduce the ability to mock time. 2020-07-10 15:51:45 +01:00
Łukasz Magiera 65648e6469 Fix seal-worker init 2020-07-10 16:13:35 +02:00
Łukasz Magiera 6a6bcd09ee Merge pull request #2346 from filecoin-project/feat/paychmgr-tst
Refactor payment channel manager
2020-07-10 16:12:53 +02:00
Frank 5dfb8c9474 add deprecation support 2020-07-10 20:18:09 +08:00
FrankandAnton Evangelatov 973de3239f Update stats source path
Co-authored-by: Anton Evangelatov <anton.evangelatov@gmail.com>
2020-07-10 10:07:53 +08:00
Dirk McCormick b888385ba1 refactor: lint fixes 2020-07-09 18:49:43 -04:00
Dirk McCormick 6c70ef7c7d refactor: simplify state management 2020-07-09 18:27:39 -04:00
Łukasz Magiera 7c73dbfba9 Merge pull request #2345 from filecoin-project/ingar/add-piece-cid-to-retrieval
Add piece cid to retrieval queries
2020-07-09 23:25:00 +02:00
Dirk McCormick 1cdb008bd5 fix: lane allocation 2020-07-09 17:20:17 -04:00
Dirk McCormick 770ee8b54d test: payment channel manager voucher and channel info tests 2020-07-09 16:35:43 -04:00
Ingar Shu 4aa30c1a51 Plumb piece cid in miner-specific query functions 2020-07-09 13:14:24 -07:00
Ingar Shu 171ce39e8c Add piece cid to retrieval queries 2020-07-09 13:03:17 -07:00
Łukasz Magiera 18199ff323 Merge pull request #2223 from filecoin-project/feat/miner-msg-select-use-gas-price-is-more-better
miner: Use gas price when selecting messages
2020-07-09 21:53:16 +02:00
Łukasz Magiera 0b5e63b7c3 Merge pull request #2328 from filecoin-project/feat/paychmgr-test
Tests for payment channel manager
2020-07-09 21:51:26 +02:00
Łukasz Magiera c501f55695 Merge pull request #2344 from filecoin-project/fix/sectorstorage-osx
Fix osx build
2020-07-09 20:54:56 +02:00
Łukasz Magiera c3b208869a Fix osx build 2020-07-09 20:49:59 +02:00
Frank ce0f9922ee Update lotus-seal-worker to lotus-worker 2020-07-09 11:04:45 +08:00
Frank b2f94e4239 update lotusstorage 2020-07-09 10:20:25 +08:00
Frank 5b9baba900 fix issue 2304: ux improvements 2020-07-09 10:20:25 +08:00
Dirk McCormick 9a45ffd459 test: add basic paychmgr store test 2020-07-08 17:34:44 -04:00
Łukasz Magiera 7d841dbfa8 Merge pull request #2286 from filecoin-project/feat/client-multi-bstore
Multiple client blockstores
2020-07-08 23:21:22 +02:00
Łukasz Magiera cc09c5b6d9 client: Don't use filestore for local improts 2020-07-08 23:13:14 +02:00
Łukasz Magiera 5a117d8edf gofmt 2020-07-08 23:05:54 +02:00
Łukasz Magiera 802f16c542 client: Reenable nocopy on import 2020-07-08 23:05:43 +02:00
Łukasz Magiera 66237415c5 Merge remote-tracking branch 'origin/next' into feat/client-multi-bstore 2020-07-08 22:48:47 +02:00
Łukasz Magiera 5ca1be567d Merge pull request #2323 from filecoin-project/feat/fastretrieval
Support fast-retrieval deals
2020-07-08 21:54:46 +02:00
Łukasz Magiera b1bd8a4394 Use sector-storage next branch 2020-07-08 21:53:50 +02:00
Łukasz Magiera 2c00b92325 Merge remote-tracking branch 'origin/master' into next 2020-07-08 21:47:05 +02:00
Łukasz Magiera 15f19adc6e Merge pull request #2315 from filecoin-project/feat/upgrade-markets-0.4.0
Upgrade markets with fast retrieval support
2020-07-08 21:12:35 +02:00
Łukasz Magiera 16690fc1d4 Merge pull request #2325 from filecoin-project/feat/upgrade-markets-0.4.0-fix
Adjust OnDealExpiredOrSlashed timeout to deal expiry
2020-07-08 21:10:58 +02:00
Dirk McCormick c9b4dab1e1 fix: adjust OnDealExpiredOrSlashed timeout to deal expiry 2020-07-08 15:03:16 -04:00
Łukasz Magiera 99796220f9 Support fast-retrieval deals 2020-07-08 20:42:07 +02:00
Łukasz Magiera 8e0d33a1fd Updates for sectors-storge next 2020-07-08 17:23:27 +02:00
Aayush Rajasekaran 56a892e5f9 Merge pull request #2246 from TroyWind/fit-multiple-piece-into-a-sector
a sector contains multiple deals(pieces), the state of deals incorrect
2020-07-08 11:21:41 -04:00
Łukasz Magiera 2b9c05d395 Merge remote-tracking branch 'origin/next' into feat/upgrade-markets-0.4.0 2020-07-08 15:53:55 +02:00
Łukasz Magiera d16de56280 gofmt 2020-07-08 14:35:53 +02:00
Łukasz Magiera b049c5a7d1 Merge remote-tracking branch 'origin/master' into next 2020-07-08 14:35:40 +02:00
Łukasz Magiera ba0f7d703e Set lower polling interval for deal client 2020-07-08 12:52:37 +02:00
hannahhoward aff1d02046 feat(markets): use tagged go-fil-markets 2020-07-08 02:12:18 -07:00
hannahhoward 124de31055 fix(markets): revert storage fsm changes 2020-07-08 02:05:15 -07:00
hannahhoward 24e3a4218b feat(markets): upgrade to latest
upgrade to latest markets with fast retrieval, underlying data transfer upgrade
2020-07-08 01:35:50 -07:00
Hannah Howard fe73c9fb71 Merge pull request #2240 from filecoin-project/feat/api-verif-cap
StateAPI for Verified Data Cap
2020-07-08 01:02:18 -07:00
Łukasz Magiera c97af35176 Merge pull request #2285 from filecoin-project/asr/timer
Update storage-FSM, add API to set sector seal delay
2020-07-07 21:43:14 +02:00
Aayush Rajasekaran 411c82ae8f Update storage-FSM, add API to set sector seal delay 2020-07-07 15:23:23 -04:00
Dirk McCormick 7842016228 fix: lint fixes 2020-07-07 13:42:11 -04:00
dirkmcandŁukasz Magiera 2808c91280 docs: StateVerifiedClientStatus
Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
2020-07-07 13:35:03 -04:00
dirkmcandŁukasz Magiera fbedff79ab remove unused var
Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com>
2020-07-07 13:34:44 -04:00
Dirk McCormick f7e9f78ee3 fix: go fmt 2020-07-07 11:04:25 -04:00
Dirk McCormick ea3defe357 fix: update StateVerifiedClientStatus signature 2020-07-07 10:57:10 -04:00
Dirk McCormick 1ea11a748d fix: go fmt 2020-07-07 10:01:08 -04:00
Dirk McCormick c86e864d55 fix: use nil return from StateVerifiedClientStatus for not-found 2020-07-07 09:59:14 -04:00
Łukasz Magiera 55f089d997 client: Unbreak retrieval 2020-07-07 14:35:02 +02:00
Łukasz Magiera d370e0ae2d Go is hard 2020-07-07 13:48:13 +02:00
Łukasz Magiera 18fc3337ff client: API/Command to drop imports 2020-07-07 13:45:02 +02:00
Łukasz Magiera 7175b1dd65 gofmt 2020-07-07 11:38:22 +02:00
Łukasz Magiera 24ed43d541 client: Fix import labeling 2020-07-07 11:38:09 +02:00
Łukasz Magiera f59eb94d92 client: Set correct dag builder params 2020-07-07 11:14:13 +02:00
Łukasz Magiera 47f0898ce9 Wire up client import manager 2020-07-07 10:52:19 +02:00
Łukasz Magiera 8942967223 Client Import manager 2020-07-07 10:52:04 +02:00
Łukasz Magiera 4ad57fe2d5 Merge pull request #2289 from filecoin-project/asr/consensus-fault
VerifyConsensusFault should return an error if no fault is found
2020-07-07 09:29:10 +02:00
Aayush Rajasekaran ad980b4966 VerifyConsensusFault should return an error if no fault is found 2020-07-07 01:29:16 -04:00
Łukasz Magiera 92e4507cf7 fsrepo: multi-datastores 2020-07-06 23:03:04 +02:00
Łukasz Magiera e7aec53631 Merge remote-tracking branch 'origin/master' into next 2020-07-06 23:02:24 +02:00
Łukasz Magiera 40113933b4 gofmt 2020-07-06 22:47:39 +02:00
Dirk McCormick 0c8e6b822c fix: better error message for not found verfied client 2020-07-06 12:56:54 -04:00
Łukasz Magiera 4b44e4e73a fix ccupgrade test after master merge 2020-07-06 12:09:09 +02:00
Łukasz Magiera 4b0ae7ef9a Merge remote-tracking branch 'origin/master' into next 2020-07-06 11:38:19 +02:00
Łukasz Magiera ee30b6e888 Merge pull request #2260 from filecoin-project/asr/cli-seal
Add CLI command to manually start sealing a sector
2020-07-06 11:16:10 +02:00
Aayush Rajasekaran 9a182bb247 i guess i'll tidy up go mod while i'm at it 2020-07-03 17:36:17 -04:00
Aayush Rajasekaran 45fdcaea45 Add CLI command to manually start sealing a sector 2020-07-03 17:05:59 -04:00
Łukasz Magiera 655d6f6720 Merge remote-tracking branch 'origin/master' into next 2020-07-03 17:03:09 +02:00
Jakub Sztandera 9936439608 Merge remote-tracking branch 'origin/master' into next
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-07-03 14:56:06 +02:00
刘林欣 ff4d9ecc77 fit in cases where a sector contains multiple deals, the state of each deal is correct 2020-07-03 09:20:47 +08:00
Dirk McCormick 8489fb258a fix: return NotFoundErr from StateVerifiedClientStatus() if addr not found 2020-07-02 14:49:08 -04:00
Dirk McCormick 2c7aa318c1 feat: state API for verified client data cap 2020-07-02 12:10:11 -04:00
Łukasz Magiera 055a8efe10 Merge pull request #2220 from filecoin-project/feat/cc-upgrade
CC upgrade
2020-07-02 01:22:14 +02:00
Łukasz Magiera 746669046a Use fsm next branch 2020-07-02 00:45:16 +02:00
Łukasz Magiera 0770b77336 Merge remote-tracking branch 'origin/next' into feat/cc-upgrade 2020-07-01 21:10:56 +02:00
Łukasz Magiera 4346f7d59d Merge pull request #2215 from filecoin-project/feat/specs-actors-v0.7.1
specs actors v0.7.1
2020-07-01 21:08:22 +02:00
Łukasz Magiera 70cac6ce08 miner: Use gas price when selecting messages 2020-07-01 20:35:19 +02:00
Aayush Rajasekaran 135ff85356 Fix params_testground to match specs-actors upgrade 2020-07-01 14:21:42 -04:00
Aayush Rajasekaran 7b0b1b5977 Update chain-validation 2020-07-01 13:00:42 -04:00
Łukasz Magiera 5946aa7a3a Merge remote-tracking branch 'origin/master' into next 2020-07-01 17:32:27 +02:00
Jakub Sztandera 53d239aa8f Merge pull request #2213 from filecoin-project/fix/next-testground
next: Fix testground build
2020-07-01 17:30:01 +02:00
Łukasz Magiera 82e2cd4746 Basic CC Upgrade support 2020-07-01 17:01:06 +02:00
Łukasz Magiera 5b73b48dc8 Fix tests post actor update 2020-07-01 14:04:37 +02:00
Łukasz Magiera a359df93c9 chainwatch: Fix getting miner info 2020-07-01 13:50:50 +02:00
Łukasz Magiera 4c422c2d50 specs-actors v0.7.1 2020-07-01 13:47:40 +02:00
Łukasz Magiera 1b0d87cafd Merge pull request #2198 from filecoin-project/feat/cli-fast-retrieval
CLI: add --fast retrieval flag to lotus client deal
2020-07-01 12:31:16 +02:00
Dirk McCormick 5c63581bd5 feat: add fast-retrieval flag to lotus client deal 2020-07-01 12:27:55 +02:00
Łukasz Magiera e89eb56a44 Merge pull request #2199 from filecoin-project/feat/cli-verif-client
CLI: add --verified-deal flag to lotus client deal
2020-07-01 12:26:16 +02:00
Dirk McCormick 00d18ca479 fix: change default for lotus client deal --verified-deal to false 2020-07-01 12:23:40 +02:00
Dirk McCormick 46f07faead feat: add verified-deal flag to lotus client deal 2020-07-01 12:23:40 +02:00
Łukasz Magiera 44de824fe3 next: Fix testground build 2020-07-01 12:20:32 +02:00
Łukasz Magiera f48681a61d Merge pull request #2195 from filecoin-project/feat/update-markets-0.3.2
Markets update 0.3.2
2020-07-01 12:19:14 +02:00
Łukasz Magiera f6b17a7f3c Fix storageadapter build post-rebase 2020-07-01 12:06:29 +02:00
hannahhoward 92bb5bd915 fix(lint): fix lint errors 2020-07-01 12:06:29 +02:00
hannahhoward be29f3bd99 feat(markets): update to markets v0.3.2
Update to markets v0.3.2, which neccesitates merging master & adding one more node function
2020-07-01 12:06:29 +02:00
Dirk McCormick a03d8b3c3f fix: simplify OnDealExpiredOrSlashed() 2020-07-01 12:06:29 +02:00
Dirk McCormick f8725ac3bd feat: add OnDealExpiredOrSlashed() to ClientNodeAdapter 2020-07-01 12:06:29 +02:00
Dirk McCormick a3abff768c fix: dont register state change if deal is not present in from and to states 2020-07-01 12:06:29 +02:00
Dirk McCormick 1fd1c2edbd feat: allow nil deal state change (deal removed) 2020-07-01 12:06:29 +02:00
Łukasz Magiera 131928ee53 chainwatch: Fix build 2020-07-01 12:05:50 +02:00
Łukasz Magiera 1761823efe Merge remote-tracking branch 'origin/master' into next 2020-07-01 11:39:21 +02:00
Łukasz Magiera cfdbc2312d Merge branch 'master' into next 2020-07-01 11:22:57 +02:00
Łukasz Magiera 472cf20b81 Merge pull request #2149 from filecoin-project/feat/specs-actors-v0.7.0
Specs actors v0.7.0
2020-06-30 16:09:03 +02:00
Łukasz Magiera 936ead016e Bump genesis funds for node_tests 2020-06-30 15:24:30 +02:00
Łukasz Magiera 24529bf35d Merge branch 'next' into feat/specs-actors-v0.7.0 2020-06-29 22:45:50 +02:00
Łukasz Magiera 2bab5d1ddd Merge remote-tracking branch 'origin/master' into next 2020-06-29 17:45:58 +02:00
Aayush Rajasekaran 1f57d9462c Don't return nil interfaces from runtime.Send() 2020-06-29 01:13:45 -04:00
Aayush Rajasekaran 73e973c29b Update chain-val, using temp commits 2020-06-26 14:28:33 -04:00
Aayush Rajasekaran 8e7ac226b0 Include WinCount when awarding block rewards 2020-06-26 14:27:49 -04:00
Łukasz Magiera 5d6fcbeccf Change initial pledge calc to PrecommitInfo 2020-06-26 18:00:50 +02:00
Łukasz Magiera 24f4c96fc3 apitest: auto-start sealing precoss 2020-06-26 17:28:05 +02:00
Łukasz Magiera 6893dbb657 api: MsigCrate required param is now uint64 2020-06-26 15:52:22 +02:00
Łukasz Magiera edd7151184 Fix StateMinerInitialPledgeCollateral 2020-06-26 15:49:39 +02:00
Łukasz Magiera b8f1264e71 genesis: Update process comment 2020-06-26 15:23:52 +02:00
Łukasz Magiera a7c372efff storage-fsm updates for sector packing 2020-06-26 15:13:18 +02:00
Łukasz Magiera a6d1323eba Update specs-actors to v0.7.0; More correct genesis sector import 2020-06-26 15:08:12 +02:00
Łukasz Magiera 8f585713fa Update storage, FSM 2020-06-26 13:11:34 +02:00
Łukasz Magiera d27ff60ae2 Merge remote-tracking branch 'origin/master' into next 2020-06-26 13:08:37 +02:00
Łukasz Magiera 2db86111b2 Merge pull request #2084 from filecoin-project/feat/poiss-sortition
Initial implementation of Poisson Sortition
2020-06-26 12:26:35 +02:00
Jakub Sztandera 4895c895aa Change WinCount to int64, wire it to BlockMessage
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-24 19:51:22 +02:00
Jakub Sztandera 88352c74fc Address @Magik6k CR
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-24 17:11:26 +02:00
Jakub Sztandera 36d5880a30 Remove TestElectionExp
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-24 15:25:23 +02:00
Jakub Sztandera 19ed695811 Fix TestInteropBH
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 20:37:35 +02:00
Jakub Sztandera 1f967c6f63 Fix debug_advance
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 20:37:35 +02:00
Jakub Sztandera 2165728088 Fix TestDealMining
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 20:09:58 +02:00
Jakub Sztandera 156a14eeeb Integrate Poisson Sortition into chain sync
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:59:44 +02:00
Jakub Sztandera 97088e3109 Add golden test for exp function
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:33:10 +02:00
Jakub Sztandera 2b597fb780 Add tests for lambda
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:02 +02:00
Jakub Sztandera efeaa9b6ad Fix lint warnings
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:02 +02:00
Jakub Sztandera d7f710806b Implement golden tests for Poisson distribution
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:02 +02:00
Jakub Sztandera d92362f96e Add comments about algorithm
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:02 +02:00
Jakub Sztandera 8fea872345 Refactor poisson to struct for easier testing
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:02 +02:00
Jakub Sztandera 84c0b50aa1 Rename fxToD
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:01 +02:00
Jakub Sztandera f523b17a35 Improve performance of ComputeWinCount
As it turns out `big.Int#Mul` doesn't like it when you reuse input as
output.

```
name         old time/op    new time/op    delta
WinCounts-8    4.56µs ± 1%    3.90µs ± 2%  -14.44%  (p=0.000 n=9+10)

name         old alloc/op   new alloc/op   delta
WinCounts-8    3.50kB ± 0%    1.15kB ± 0%  -67.23%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
WinCounts-8      45.0 ± 0%      24.0 ± 0%  -46.67%  (p=0.000 n=10+10)
```

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:01 +02:00
Jakub Sztandera ee5639aad9 Initial implementation of Poisson Sortition
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-06-23 16:24:01 +02:00
208 changed files with 6405 additions and 2457 deletions
+6 -6
View File
@@ -93,10 +93,10 @@ jobs:
- store_artifacts:
path: lotus
- store_artifacts:
path: lotus-storage-miner
path: lotus-miner
- store_artifacts:
path: lotus-seal-worker
- run: mkdir linux && mv lotus lotus-storage-miner lotus-seal-worker linux/
path: lotus-worker
- run: mkdir linux && mv lotus lotus-miner lotus-worker linux/
- persist_to_workspace:
root: "."
paths:
@@ -223,10 +223,10 @@ jobs:
- store_artifacts:
path: lotus
- store_artifacts:
path: lotus-storage-miner
path: lotus-miner
- store_artifacts:
path: lotus-seal-worker
- run: mkdir darwin && mv lotus lotus-storage-miner lotus-seal-worker darwin/
path: lotus-worker
- run: mkdir darwin && mv lotus lotus-miner lotus-worker darwin/
- persist_to_workspace:
root: "."
paths:
+4 -4
View File
@@ -19,15 +19,15 @@ Including what commands you ran, and a description of your setup, is very helpfu
**Sectors list**
The output of `./lotus-storage-miner sectors list`.
The output of `./lotus-miner sectors list`.
**Sectors status**
The output of `./lotus-storage-miner sectors status --log <sectorId>` for the failed sector(s).
The output of `./lotus-miner sectors status --log <sectorId>` for the failed sector(s).
**Lotus storage miner logs**
**Lotus miner logs**
Please go through the logs of your storage miner, and include screenshots of any error-like messages you find.
Please go through the logs of your miner, and include screenshots of any error-like messages you find.
**Version**
+9 -8
View File
@@ -1,19 +1,21 @@
/lotus
/lotus-storage-miner
/lotus-seal-worker
/lotus-miner
/lotus-worker
/lotus-seed
/lotus-health
/lotus-chainwatch
/lotus-shed
/pond
/townhall
/fountain
/stats
/bench
/lotus-pond
/lotus-townhall
/lotus-fountain
/lotus-stats
/lotus-bench
/bench.json
/lotuspond/front/node_modules
/lotuspond/front/build
/cmd/lotus-townhall/townhall/node_modules
/cmd/lotus-townhall/townhall/build
/cmd/lotus-townhall/townhall/package-lock.json
extern/filecoin-ffi/rust/target
**/*.a
**/*.pc
@@ -24,7 +26,6 @@ build/paramfetch.sh
/vendor
/blocks.dot
/blocks.svg
/chainwatch
/chainwatch.db
/bundle
/darwin
+60 -61
View File
@@ -58,10 +58,10 @@ deps: $(BUILD_DEPS)
.PHONY: deps
debug: GOFLAGS+=-tags=debug
debug: lotus lotus-storage-miner lotus-seal-worker lotus-seed
debug: lotus lotus-miner lotus-worker lotus-seed
2k: GOFLAGS+=-tags=2k
2k: lotus lotus-storage-miner lotus-seal-worker lotus-seed
2k: lotus lotus-miner lotus-worker lotus-seed
lotus: $(BUILD_DEPS)
rm -f lotus
@@ -71,19 +71,19 @@ lotus: $(BUILD_DEPS)
.PHONY: lotus
BINS+=lotus
lotus-storage-miner: $(BUILD_DEPS)
rm -f lotus-storage-miner
go build $(GOFLAGS) -o lotus-storage-miner ./cmd/lotus-storage-miner
go run github.com/GeertJohan/go.rice/rice append --exec lotus-storage-miner -i ./build
.PHONY: lotus-storage-miner
BINS+=lotus-storage-miner
lotus-miner: $(BUILD_DEPS)
rm -f lotus-miner
go build $(GOFLAGS) -o lotus-miner ./cmd/lotus-storage-miner
go run github.com/GeertJohan/go.rice/rice append --exec lotus-miner -i ./build
.PHONY: lotus-miner
BINS+=lotus-miner
lotus-seal-worker: $(BUILD_DEPS)
rm -f lotus-seal-worker
go build $(GOFLAGS) -o lotus-seal-worker ./cmd/lotus-seal-worker
go run github.com/GeertJohan/go.rice/rice append --exec lotus-seal-worker -i ./build
.PHONY: lotus-seal-worker
BINS+=lotus-seal-worker
lotus-worker: $(BUILD_DEPS)
rm -f lotus-worker
go build $(GOFLAGS) -o lotus-worker ./cmd/lotus-seal-worker
go run github.com/GeertJohan/go.rice/rice append --exec lotus-worker -i ./build
.PHONY: lotus-worker
BINS+=lotus-worker
lotus-shed: $(BUILD_DEPS)
rm -f lotus-shed
@@ -92,7 +92,7 @@ lotus-shed: $(BUILD_DEPS)
.PHONY: lotus-shed
BINS+=lotus-shed
build: lotus lotus-storage-miner lotus-seal-worker
build: lotus lotus-miner lotus-worker
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
@@ -100,8 +100,8 @@ an existing lotus binary in your PATH. This may cause problems if you don't run
install:
install -C ./lotus /usr/local/bin/lotus
install -C ./lotus-storage-miner /usr/local/bin/lotus-storage-miner
install -C ./lotus-seal-worker /usr/local/bin/lotus-seal-worker
install -C ./lotus-miner /usr/local/bin/lotus-miner
install -C ./lotus-worker /usr/local/bin/lotus-worker
install-services: install
mkdir -p /usr/local/lib/systemd/system
@@ -115,7 +115,7 @@ install-services: install
clean-services:
rm -f /usr/local/lib/systemd/system/lotus-daemon.service
rm -f /usr/local/lib/systemd/system/lotus-miner.service
rm -f /usr/local/lib/systemd/system/chainwatch.service
rm -f /usr/local/lib/systemd/system/lotus-chainwatch.service
systemctl daemon-reload
# TOOLS
@@ -134,65 +134,64 @@ benchmarks:
@curl -X POST 'http://benchmark.kittyhawk.wtf/benchmark' -d '@bench.json' -u "${benchmark_http_cred}"
.PHONY: benchmarks
pond: 2k
go build -o pond ./lotuspond
lotus-pond: 2k
go build -o lotus-pond ./lotuspond
(cd lotuspond/front && npm i && CI=false npm run build)
.PHONY: pond
BINS+=pond
.PHONY: lotus-pond
BINS+=lotus-pond
townhall:
rm -f townhall
go build -o townhall ./cmd/lotus-townhall
lotus-townhall:
rm -f lotus-townhall
go build -o lotus-townhall ./cmd/lotus-townhall
(cd ./cmd/lotus-townhall/townhall && npm i && npm run build)
go run github.com/GeertJohan/go.rice/rice append --exec townhall -i ./cmd/lotus-townhall -i ./build
.PHONY: townhall
BINS+=townhall
go run github.com/GeertJohan/go.rice/rice append --exec lotus-townhall -i ./cmd/lotus-townhall -i ./build
.PHONY: lotus-townhall
BINS+=lotus-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 -i ./build
.PHONY: fountain
BINS+=fountain
lotus-fountain:
rm -f lotus-fountain
go build -o lotus-fountain ./cmd/lotus-fountain
go run github.com/GeertJohan/go.rice/rice append --exec lotus-fountain -i ./cmd/lotus-fountain -i ./build
.PHONY: lotus-fountain
BINS+=lotus-fountain
chainwatch:
rm -f chainwatch
go build -o chainwatch ./cmd/lotus-chainwatch
.PHONY: chainwatch
BINS+=chainwatch
lotus-chainwatch:
rm -f lotus-chainwatch
go build -o lotus-chainwatch ./cmd/lotus-chainwatch
.PHONY: lotus-chainwatch
BINS+=lotus-chainwatch
install-chainwatch-service: chainwatch
install -C ./chainwatch /usr/local/bin/chainwatch
install -C -m 0644 ./scripts/chainwatch.service /usr/local/lib/systemd/system/chainwatch.service
mkdir -p /etc/lotus
install -C ./lotus-chainwatch /usr/local/bin/lotus-chainwatch
install -C -m 0644 ./scripts/lotus-chainwatch.service /usr/local/lib/systemd/system/lotus-chainwatch.service
systemctl daemon-reload
@echo
@echo "chainwatch installed. Don't forget to 'systemctl enable chainwatch' for it to be enabled on startup."
bench:
rm -f bench
go build -o bench ./cmd/lotus-bench
go run github.com/GeertJohan/go.rice/rice append --exec bench -i ./build
.PHONY: bench
BINS+=bench
lotus-bench:
rm -f lotus-bench
go build -o lotus-bench ./cmd/lotus-bench
go run github.com/GeertJohan/go.rice/rice append --exec lotus-bench -i ./build
.PHONY: lotus-bench
BINS+=lotus-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
lotus-stats:
rm -f lotus-stats
go build -o lotus-stats ./cmd/lotus-stats
go run github.com/GeertJohan/go.rice/rice append --exec lotus-stats -i ./build
.PHONY: lotus-stats
BINS+=lotus-stats
health:
lotus-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
.PHONY: lotus-health
BINS+=lotus-health
testground:
go build -tags testground -o /dev/null ./cmd/lotus
.PHONY: testground
BINS+=testground
@@ -202,15 +201,15 @@ buildall: $(BINS)
completions:
./scripts/make-completions.sh lotus
./scripts/make-completions.sh lotus-storage-miner
./scripts/make-completions.sh lotus-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/bash-completion/lotus-miner /usr/share/bash-completion/completions/lotus-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
install -C ./scripts/zsh-completion/lotus-miner /usr/local/share/zsh/site-functions/_lotus-miner
clean:
rm -rf $(CLEAN) $(BINS)
+56 -17
View File
@@ -5,7 +5,6 @@ import (
"time"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-filestore"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/go-address"
@@ -16,6 +15,7 @@ import (
"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/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/lotus/chain/types"
@@ -189,7 +189,9 @@ type FullNode interface {
// retrieval markets as a client
// ClientImport imports file under the specified path into filestore.
ClientImport(ctx context.Context, ref FileRef) (cid.Cid, error)
ClientImport(ctx context.Context, ref FileRef) (*ImportRes, error)
// ClientRemoveImport removes file import
ClientRemoveImport(ctx context.Context, importID int) error
// ClientStartDeal proposes a deal with a miner.
ClientStartDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error)
// ClientGetDealInfo returns the latest information about a given deal.
@@ -199,9 +201,9 @@ type FullNode interface {
// ClientHasLocal indicates whether a certain CID is locally stored.
ClientHasLocal(ctx context.Context, root cid.Cid) (bool, error)
// ClientFindData identifies peers that have a certain file, and returns QueryOffers (one per peer).
ClientFindData(ctx context.Context, root cid.Cid) ([]QueryOffer, error)
ClientFindData(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]QueryOffer, error)
// ClientMinerQueryOffer returns a QueryOffer for the specific miner and file.
ClientMinerQueryOffer(ctx context.Context, root cid.Cid, miner address.Address) (QueryOffer, error)
ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (QueryOffer, error)
// ClientRetrieve initiates the retrieval of a file, as specified in the order.
ClientRetrieve(ctx context.Context, order RetrievalOrder, ref *FileRef) error
// ClientQueryAsk returns a signed StorageAsk from the specified miner.
@@ -241,8 +243,8 @@ type FullNode interface {
// If the filterOut boolean is set to true, any sectors in the filter are excluded.
// If false, only those sectors in the filter are included.
StateMinerSectors(context.Context, address.Address, *abi.BitField, bool, types.TipSetKey) ([]*ChainSectorInfo, error)
// StateMinerProvingSet returns info about those sectors that a given miner is actively proving.
StateMinerProvingSet(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
// StateMinerActiveSectors returns info about sectors that a given miner is actively proving.
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
// and returns the deadline-related calculations.
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
@@ -251,7 +253,9 @@ type FullNode interface {
// StateMinerInfo returns info about the indicated miner
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (MinerInfo, error)
// StateMinerDeadlines returns all the proving deadlines for the given miner
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error)
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error)
// StateMinerPartitions loads miner partitions for the specified miner/deadline
StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]*miner.Partition, error)
// StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
// StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset
@@ -259,13 +263,19 @@ type FullNode interface {
// StateMinerRecoveries returns a bitfield indicating the recovering sectors of the given miner
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
// StateMinerInitialPledgeCollateral returns the initial pledge collateral for the specified miner's sector
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
// StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
// StateSectorGetInfo returns the on-chain info for the specified miner's sector
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
// expiration epoch
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
// StateSectorExpiration returns epoch at which given sector will expire
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*SectorExpiration, error)
// StateSectorPartition finds deadline/partition with the specified sector
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*SectorLocation, error)
StatePledgeCollateral(context.Context, types.TipSetKey) (types.BigInt, error)
// StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed
StateSearchMsg(context.Context, cid.Cid) (*MsgLookup, error)
@@ -298,6 +308,10 @@ type FullNode interface {
// StateCompute is a flexible command that applies the given messages on the given tipset.
// The messages are run as though the VM were at the provided height.
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*ComputeStateOutput, error)
// StateVerifiedClientStatus returns the data cap for the given address.
// Returns nil if there is no entry in the data cap table for the
// address.
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*verifreg.DataCap, error)
// MethodGroup: Msig
// The Msig methods are used to interact with multisig wallets on the
@@ -308,7 +322,7 @@ type FullNode interface {
// MsigCreate creates a multisig wallet
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
//<initial balance>, <sender address of the create msg>, <gas price>
MsigCreate(context.Context, int64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
MsigCreate(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
// MsigPropose proposes a multisig message
// It takes the following params: <multisig address>, <recipient address>, <value to transfer>,
// <sender address of the propose msg>, <method to call in the proposed message>, <params to include in the proposed message>
@@ -360,15 +374,35 @@ type FileRef struct {
}
type MinerSectors struct {
Sset uint64
Pset uint64
Sectors uint64
Active uint64
}
type SectorExpiration struct {
OnTime abi.ChainEpoch
// non-zero if sector is faulty, epoch at which it will be permanently
// removed if it doesn't recover
Early abi.ChainEpoch
}
type SectorLocation struct {
Deadline uint64
Partition uint64
}
type ImportRes struct {
Root cid.Cid
ImportID int
}
type Import struct {
Status filestore.Status
Key cid.Cid
Key int
Err string
Root *cid.Cid
Source string
FilePath string
Size uint64
}
type DealInfo struct {
@@ -456,7 +490,8 @@ type MinerPower struct {
type QueryOffer struct {
Err string
Root cid.Cid
Root cid.Cid
Piece *cid.Cid
Size uint64
MinPrice types.BigInt
@@ -469,6 +504,7 @@ type QueryOffer struct {
func (o *QueryOffer) Order(client address.Address) RetrievalOrder {
return RetrievalOrder{
Root: o.Root,
Piece: o.Piece,
Size: o.Size,
Total: o.MinPrice,
PaymentInterval: o.PaymentInterval,
@@ -492,8 +528,9 @@ type MarketDeal struct {
type RetrievalOrder struct {
// TODO: make this less unixfs specific
Root cid.Cid
Size uint64
Root cid.Cid
Piece *cid.Cid
Size uint64
// TODO: support offset
Total types.BigInt
PaymentInterval uint64
@@ -523,6 +560,8 @@ type StartDealParams struct {
EpochPrice types.BigInt
MinBlocksDuration uint64
DealStartEpoch abi.ChainEpoch
FastRetrieval bool
VerifiedDeal bool
}
type IpldObject struct {
+17 -1
View File
@@ -3,12 +3,14 @@ package api
import (
"bytes"
"context"
"time"
"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/fsutil"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/sector-storage/storiface"
"github.com/filecoin-project/specs-actors/actors/abi"
@@ -35,12 +37,26 @@ type StorageMiner interface {
SectorsRefs(context.Context) (map[string][]SealedRef, error)
// SectorStartSealing can be called on sectors in Empty or WaitDeals states
// to trigger sealing early
SectorStartSealing(context.Context, abi.SectorNumber) error
// SectorSetSealDelay sets the time that a newly-created sector
// waits for more deals before it starts sealing
SectorSetSealDelay(context.Context, time.Duration) error
// SectorGetSealDelay gets the time that a newly-created sector
// waits for more deals before it starts sealing
SectorGetSealDelay(context.Context) (time.Duration, error)
// SectorSetExpectedSealDuration sets the expected time for a sector to seal
SectorSetExpectedSealDuration(context.Context, time.Duration) error
// SectorGetExpectedSealDuration gets the expected time for a sector to seal
SectorGetExpectedSealDuration(context.Context) (time.Duration, error)
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
SectorRemove(context.Context, abi.SectorNumber) error
SectorMarkForUpgrade(ctx context.Context, id abi.SectorNumber) 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)
StorageStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error)
// WorkerConnect tells the node to connect to workers RPC
WorkerConnect(context.Context, string) error
+94 -37
View File
@@ -3,6 +3,7 @@ package apistruct
import (
"context"
"io"
"time"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/network"
@@ -11,7 +12,7 @@ import (
"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/fsutil"
"github.com/filecoin-project/sector-storage/sealtasks"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/sector-storage/storiface"
@@ -19,6 +20,7 @@ import (
"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/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-storage/storage"
@@ -109,33 +111,37 @@ type FullNodeStruct struct {
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
WalletDelete func(context.Context, address.Address) error `perm:"write"`
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"`
ClientMinerQueryOffer func(ctx context.Context, root cid.Cid, miner address.Address) (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"`
ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"`
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
ClientRemoveImport func(ctx context.Context, importID int) error `perm:"admin"`
ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"`
ClientFindData func(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) `perm:"read"`
ClientMinerQueryOffer func(ctx context.Context, miner address.Address, root cid.Cid, piece *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"`
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"`
StateMinerActiveSectors 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) (api.MinerInfo, error) `perm:"read"`
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error) `perm:"read"`
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) ([]*miner.Deadline, error) `perm:"read"`
StateMinerPartitions func(context.Context, address.Address, uint64, types.TipSetKey) ([]*miner.Partition, 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"`
StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, 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"`
StateSectorExpiration func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorExpiration, error) `perm:"read"`
StateSectorPartition func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorLocation, 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"`
@@ -156,9 +162,10 @@ type FullNodeStruct struct {
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"`
StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*verifreg.DataCap, error) `perm:"read"`
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
MsigCreate func(context.Context, int64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, 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, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
@@ -205,19 +212,25 @@ type StorageMinerStruct struct {
PledgeSector func(context.Context) 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"`
SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"`
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"`
SectorStartSealing func(context.Context, abi.SectorNumber) error `perm:"write"`
SectorSetSealDelay func(context.Context, time.Duration) error `perm:"write"`
SectorGetSealDelay func(context.Context) (time.Duration, error) `perm:"read"`
SectorSetExpectedSealDuration func(context.Context, time.Duration) error `perm:"write"`
SectorGetExpectedSealDuration func(context.Context) (time.Duration, error) `perm:"read"`
SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"admin"`
SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"`
SectorMarkForUpgrade func(ctx context.Context, id abi.SectorNumber) error `perm:"admin"`
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, 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"`
StorageStat func(context.Context, stores.ID) (fsutil.FsStat, error) `perm:"admin"`
StorageAttach func(context.Context, stores.StorageInfo, fsutil.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"`
@@ -341,7 +354,11 @@ func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, e
return c.Internal.ClientListImports(ctx)
}
func (c *FullNodeStruct) ClientImport(ctx context.Context, ref api.FileRef) (cid.Cid, error) {
func (c *FullNodeStruct) ClientRemoveImport(ctx context.Context, importID int) error {
return c.Internal.ClientRemoveImport(ctx, importID)
}
func (c *FullNodeStruct) ClientImport(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) {
return c.Internal.ClientImport(ctx, ref)
}
@@ -349,12 +366,12 @@ func (c *FullNodeStruct) ClientHasLocal(ctx context.Context, root cid.Cid) (bool
return c.Internal.ClientHasLocal(ctx, root)
}
func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) {
return c.Internal.ClientFindData(ctx, root)
func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid, piece *cid.Cid) ([]api.QueryOffer, error) {
return c.Internal.ClientFindData(ctx, root, piece)
}
func (c *FullNodeStruct) ClientMinerQueryOffer(ctx context.Context, root cid.Cid, miner address.Address) (api.QueryOffer, error) {
return c.Internal.ClientMinerQueryOffer(ctx, root, miner)
func (c *FullNodeStruct) ClientMinerQueryOffer(ctx context.Context, miner address.Address, root cid.Cid, piece *cid.Cid) (api.QueryOffer, error) {
return c.Internal.ClientMinerQueryOffer(ctx, miner, root, piece)
}
func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) {
@@ -567,8 +584,8 @@ func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Add
return c.Internal.StateMinerSectors(ctx, addr, filter, filterOut, tsk)
}
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) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
}
func (c *FullNodeStruct) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*miner.DeadlineInfo, error) {
@@ -583,10 +600,14 @@ func (c *FullNodeStruct) StateMinerInfo(ctx context.Context, actor address.Addre
return c.Internal.StateMinerInfo(ctx, actor, tsk)
}
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) (*miner.Deadlines, error) {
func (c *FullNodeStruct) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]*miner.Deadline, error) {
return c.Internal.StateMinerDeadlines(ctx, m, tsk)
}
func (c *FullNodeStruct) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tsk types.TipSetKey) ([]*miner.Partition, error) {
return c.Internal.StateMinerPartitions(ctx, m, dlIdx, tsk)
}
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*abi.BitField, error) {
return c.Internal.StateMinerFaults(ctx, actor, tsk)
}
@@ -599,8 +620,8 @@ func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
}
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) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, pci, tsk)
}
func (c *FullNodeStruct) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
@@ -615,6 +636,14 @@ func (c *FullNodeStruct) StateSectorGetInfo(ctx context.Context, maddr address.A
return c.Internal.StateSectorGetInfo(ctx, maddr, n, tsk)
}
func (c *FullNodeStruct) StateSectorExpiration(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*api.SectorExpiration, error) {
return c.Internal.StateSectorExpiration(ctx, maddr, n, tsk)
}
func (c *FullNodeStruct) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*api.SectorLocation, error) {
return c.Internal.StateSectorPartition(ctx, maddr, sectorNumber, tok)
}
func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error) {
return c.Internal.StateCall(ctx, msg, tsk)
}
@@ -691,11 +720,15 @@ func (c *FullNodeStruct) StateCompute(ctx context.Context, height abi.ChainEpoch
return c.Internal.StateCompute(ctx, height, msgs, tsk)
}
func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*verifreg.DataCap, error) {
return c.Internal.StateVerifiedClientStatus(ctx, addr, 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, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
return c.Internal.MsigCreate(ctx, req, addrs, duration, val, src, gp)
}
@@ -807,6 +840,26 @@ func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]api.
return c.Internal.SectorsRefs(ctx)
}
func (c *StorageMinerStruct) SectorStartSealing(ctx context.Context, number abi.SectorNumber) error {
return c.Internal.SectorStartSealing(ctx, number)
}
func (c *StorageMinerStruct) SectorSetSealDelay(ctx context.Context, delay time.Duration) error {
return c.Internal.SectorSetSealDelay(ctx, delay)
}
func (c *StorageMinerStruct) SectorGetSealDelay(ctx context.Context) (time.Duration, error) {
return c.Internal.SectorGetSealDelay(ctx)
}
func (c *StorageMinerStruct) SectorSetExpectedSealDuration(ctx context.Context, delay time.Duration) error {
return c.Internal.SectorSetExpectedSealDuration(ctx, delay)
}
func (c *StorageMinerStruct) SectorGetExpectedSealDuration(ctx context.Context) (time.Duration, error) {
return c.Internal.SectorGetExpectedSealDuration(ctx)
}
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
return c.Internal.SectorsUpdate(ctx, id, state)
}
@@ -815,6 +868,10 @@ func (c *StorageMinerStruct) SectorRemove(ctx context.Context, number abi.Sector
return c.Internal.SectorRemove(ctx, number)
}
func (c *StorageMinerStruct) SectorMarkForUpgrade(ctx context.Context, number abi.SectorNumber) error {
return c.Internal.SectorMarkForUpgrade(ctx, number)
}
func (c *StorageMinerStruct) WorkerConnect(ctx context.Context, url string) error {
return c.Internal.WorkerConnect(ctx, url)
}
@@ -823,7 +880,7 @@ func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (map[uint64]storif
return c.Internal.WorkerStats(ctx)
}
func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.StorageInfo, st stores.FsStat) error {
func (c *StorageMinerStruct) StorageAttach(ctx context.Context, si stores.StorageInfo, st fsutil.FsStat) error {
return c.Internal.StorageAttach(ctx, si, st)
}
@@ -847,7 +904,7 @@ func (c *StorageMinerStruct) StorageLocal(ctx context.Context) (map[stores.ID]st
return c.Internal.StorageLocal(ctx)
}
func (c *StorageMinerStruct) StorageStat(ctx context.Context, id stores.ID) (stores.FsStat, error) {
func (c *StorageMinerStruct) StorageStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error) {
return c.Internal.StorageStat(ctx, id)
}
+10
View File
@@ -91,6 +91,8 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
}
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
*t = PaymentInfo{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -256,6 +258,8 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error {
}
func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
*t = SealedRef{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -378,6 +382,8 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
}
func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
*t = SealedRefs{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -505,6 +511,8 @@ func (t *SealTicket) MarshalCBOR(w io.Writer) error {
}
func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
*t = SealTicket{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -647,6 +655,8 @@ func (t *SealSeed) MarshalCBOR(w io.Writer) error {
}
func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
*t = SealSeed{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
+1 -1
View File
@@ -34,7 +34,7 @@ func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonr
return &res, closer, err
}
// NewStorageMinerRPC creates a new http jsonrpc client for storage miner
// NewStorageMinerRPC creates a new http jsonrpc client for miner
func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMiner, jsonrpc.ClientCloser, error) {
var res apistruct.StorageMinerStruct
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
+99
View File
@@ -0,0 +1,99 @@
package test
import (
"context"
"fmt"
"os"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl"
)
func TestCCUpgrade(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)
}
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
mine := int64(1)
done := make(chan struct{})
go func() {
defer close(done)
for atomic.LoadInt64(&mine) == 1 {
time.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool, error) {}); err != nil {
t.Error(err)
}
}
}()
maddr, err := miner.ActorAddress(ctx)
if err != nil {
t.Fatal(err)
}
CC := abi.SectorNumber(GenesisPreseals + 1)
Upgraded := CC + 1
pledgeSectors(t, ctx, miner, 1)
sl, err := miner.SectorsList(ctx)
if err != nil {
t.Fatal(err)
}
if len(sl) != 1 {
t.Fatal("expected 1 sector")
}
if sl[0] != CC {
t.Fatal("bad")
}
{
si, err := client.StateSectorGetInfo(ctx, maddr, CC, types.EmptyTSK)
require.NoError(t, err)
require.Less(t, 50000, int(si.Expiration))
}
if err := miner.SectorMarkForUpgrade(ctx, sl[0]); err != nil {
t.Fatal(err)
}
makeDeal(t, ctx, 6, client, miner, false, false)
// Validate upgrade
{
exp, err := client.StateSectorExpiration(ctx, maddr, CC, types.EmptyTSK)
require.NoError(t, err)
require.Greater(t, 50000, int(exp.OnTime))
}
{
exp, err := client.StateSectorExpiration(ctx, maddr, Upgraded, types.EmptyTSK)
require.NoError(t, err)
require.Less(t, 50000, int(exp.OnTime))
}
fmt.Println("shutting down mining")
atomic.AddInt64(&mine, -1)
<-done
}
+35 -13
View File
@@ -12,8 +12,9 @@ import (
"testing"
"time"
"github.com/ipfs/go-cid"
"github.com/stretchr/testify/require"
"github.com/ipfs/go-cid"
files "github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log/v2"
"github.com/ipld/go-car"
@@ -21,6 +22,7 @@ import (
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
sealing "github.com/filecoin-project/storage-fsm"
dag "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test"
unixfile "github.com/ipfs/go-unixfs/file"
@@ -35,7 +37,7 @@ func init() {
build.InsecurePoStValidation = true
}
func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport bool) {
func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport, fastRet bool) {
_ = os.Setenv("BELLMAN_NO_GPU", "1")
ctx := context.Background()
@@ -65,7 +67,7 @@ func TestDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration, carExport
}
}()
makeDeal(t, ctx, 6, client, miner, carExport)
makeDeal(t, ctx, 6, client, miner, carExport, fastRet)
atomic.AddInt64(&mine, -1)
fmt.Println("shutting down mining")
@@ -103,15 +105,15 @@ func TestDoubleDealFlow(t *testing.T, b APIBuilder, blocktime time.Duration) {
}
}()
makeDeal(t, ctx, 6, client, miner, false)
makeDeal(t, ctx, 7, client, miner, false)
makeDeal(t, ctx, 6, client, miner, false, false)
makeDeal(t, ctx, 7, client, miner, false, false)
atomic.AddInt64(&mine, -1)
fmt.Println("shutting down mining")
<-done
}
func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNodeAPI, miner TestStorageNode, carExport bool) {
func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNodeAPI, miner TestStorageNode, carExport, fastRet bool) {
data := make([]byte, 1600)
rand.New(rand.NewSource(int64(rseed))).Read(data)
@@ -123,18 +125,20 @@ func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNod
fmt.Println("FILE CID: ", fcid)
deal := startDeal(t, ctx, miner, client, fcid)
deal := startDeal(t, ctx, miner, client, fcid, fastRet)
// 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)
waitDealSealed(t, ctx, miner, client, deal)
// Retrieval
info, err := client.ClientGetDealInfo(ctx, *deal)
require.NoError(t, err)
testRetrieval(t, ctx, err, client, fcid, carExport, data)
testRetrieval(t, ctx, err, client, fcid, &info.PieceCID, carExport, data)
}
func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client *impl.FullNodeAPI, fcid cid.Cid) *cid.Cid {
func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client *impl.FullNodeAPI, fcid cid.Cid, fastRet bool) *cid.Cid {
maddr, err := miner.ActorAddress(ctx)
if err != nil {
t.Fatal(err)
@@ -150,6 +154,7 @@ func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client
Miner: maddr,
EpochPrice: types.NewInt(1000000),
MinBlocksDuration: 100,
FastRetrieval: fastRet,
})
if err != nil {
t.Fatalf("%+v", err)
@@ -157,7 +162,7 @@ func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client
return deal
}
func waitDealSealed(t *testing.T, ctx context.Context, client *impl.FullNodeAPI, deal *cid.Cid) {
func waitDealSealed(t *testing.T, ctx context.Context, miner TestStorageNode, client *impl.FullNodeAPI, deal *cid.Cid) {
loop:
for {
di, err := client.ClientGetDealInfo(ctx, *deal)
@@ -165,6 +170,8 @@ loop:
t.Fatal(err)
}
switch di.State {
case storagemarket.StorageDealSealing:
startSealingWaiting(t, ctx, miner)
case storagemarket.StorageDealProposalRejected:
t.Fatal("deal rejected")
case storagemarket.StorageDealFailing:
@@ -180,8 +187,23 @@ loop:
}
}
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)
func startSealingWaiting(t *testing.T, ctx context.Context, miner TestStorageNode) {
snums, err := miner.SectorsList(ctx)
require.NoError(t, err)
for _, snum := range snums {
si, err := miner.SectorsStatus(ctx, snum)
require.NoError(t, err)
t.Logf("Sector state: %s", si.State)
if si.State == api.SectorState(sealing.WaitDeals) {
require.NoError(t, miner.SectorStartSealing(ctx, snum))
}
}
}
func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.FullNodeAPI, fcid cid.Cid, piece *cid.Cid, carExport bool, data []byte) {
offers, err := client.ClientFindData(ctx, fcid, piece)
if err != nil {
t.Fatal(err)
}
+7 -3
View File
@@ -89,7 +89,7 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
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
{Full: 0, Preseal: 0}, // TODO: Add support for miners on non-first full node
})
client := n[0].FullNode.(*impl.FullNodeAPI)
provider := sn[1]
@@ -154,6 +154,10 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
expect += <-wait
time.Sleep(blocktime)
if expect == 0 {
// null block
continue
}
for {
n := 0
@@ -185,12 +189,12 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
}
}()
deal := startDeal(t, ctx, provider, client, fcid)
deal := startDeal(t, ctx, provider, client, fcid, false)
// 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)
waitDealSealed(t, ctx, provider, client, deal)
<-minedTwo
+9 -7
View File
@@ -4,6 +4,8 @@ import (
"context"
"fmt"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"os"
"strings"
"testing"
@@ -35,14 +37,14 @@ func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSect
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
build.Clock.Sleep(time.Second)
mine := true
done := make(chan struct{})
go func() {
defer close(done)
for mine {
time.Sleep(blocktime)
build.Clock.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool, error) {}); err != nil {
t.Error(err)
}
@@ -69,7 +71,7 @@ func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n i
break
}
time.Sleep(100 * time.Millisecond)
build.Clock.Sleep(100 * time.Millisecond)
}
fmt.Printf("All sectors is fsm\n")
@@ -94,7 +96,7 @@ func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n i
}
}
time.Sleep(100 * time.Millisecond)
build.Clock.Sleep(100 * time.Millisecond)
fmt.Printf("WaitSeal: %d\n", len(s))
}
}
@@ -115,14 +117,14 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
build.Clock.Sleep(time.Second)
mine := true
done := make(chan struct{})
go func() {
defer close(done)
for mine {
time.Sleep(blocktime)
build.Clock.Sleep(blocktime)
if err := sn[0].MineOne(ctx, func(bool, error) {}); err != nil {
t.Error(err)
}
@@ -150,7 +152,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
if head.Height()%100 == 0 {
fmt.Printf("@%d\n", head.Height())
}
time.Sleep(blocktime)
build.Clock.Sleep(blocktime)
}
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
+1 -1
View File
@@ -55,7 +55,7 @@ type MinerInfo struct {
WindowPoStPartitionSectors uint64
}
func NewApiMinerInfo(info miner.MinerInfo) MinerInfo {
func NewApiMinerInfo(info *miner.MinerInfo) MinerInfo {
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
+2 -12
View File
@@ -1,12 +1,2 @@
/dns4/bootstrap-0-sin.fil-test.net/tcp/1347/p2p/12D3KooWPdUquftaQvoQEtEdsRBAhwD6jopbF2oweVTzR59VbHEd
/ip4/86.109.15.57/tcp/1347/p2p/12D3KooWPdUquftaQvoQEtEdsRBAhwD6jopbF2oweVTzR59VbHEd
/dns4/bootstrap-0-dfw.fil-test.net/tcp/1347/p2p/12D3KooWQSCkHCzosEyrh8FgYfLejKgEPM5VB6qWzZE3yDAuXn8d
/ip4/139.178.84.45/tcp/1347/p2p/12D3KooWQSCkHCzosEyrh8FgYfLejKgEPM5VB6qWzZE3yDAuXn8d
/dns4/bootstrap-0-fra.fil-test.net/tcp/1347/p2p/12D3KooWEXN2eQmoyqnNjde9PBAQfQLHN67jcEdWU6JougWrgXJK
/ip4/136.144.49.17/tcp/1347/p2p/12D3KooWEXN2eQmoyqnNjde9PBAQfQLHN67jcEdWU6JougWrgXJK
/dns4/bootstrap-1-sin.fil-test.net/tcp/1347/p2p/12D3KooWLmJkZd33mJhjg5RrpJ6NFep9SNLXWc4uVngV4TXKwzYw
/ip4/86.109.15.123/tcp/1347/p2p/12D3KooWLmJkZd33mJhjg5RrpJ6NFep9SNLXWc4uVngV4TXKwzYw
/dns4/bootstrap-1-dfw.fil-test.net/tcp/1347/p2p/12D3KooWGXLHjiz6pTRu7x2pkgTVCoxcCiVxcNLpMnWcJ3JiNEy5
/ip4/139.178.86.3/tcp/1347/p2p/12D3KooWGXLHjiz6pTRu7x2pkgTVCoxcCiVxcNLpMnWcJ3JiNEy5
/dns4/bootstrap-1-fra.fil-test.net/tcp/1347/p2p/12D3KooW9szZmKttS9A1FafH3Zc2pxKwwmvCWCGKkRP4KmbhhC4R
/ip4/136.144.49.131/tcp/1347/p2p/12D3KooW9szZmKttS9A1FafH3Zc2pxKwwmvCWCGKkRP4KmbhhC4R
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWMaNaA4TNaUdEkeaHTSc3fpYuFYGdrN1vbGVi7oJEjdoy
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWPAU1G5PGrCYb8nzHHzxrHD37tP2tXQ3pA9LStGSgsCee
+10
View File
@@ -0,0 +1,10 @@
package build
import "github.com/raulk/clock"
// Clock is the global clock for the system. In standard builds,
// we use a real-time clock, which maps to the `time` package.
//
// Tests that need control of time can replace this variable with
// clock.NewMock().
var Clock = clock.New()
Binary file not shown.
+4 -4
View File
@@ -30,7 +30,7 @@ const ForkLengthThreshold = Finality
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
// Epochs
const Finality = miner.ChainFinalityish
const Finality = miner.ChainFinality
const MessageConfidence = uint64(5)
// constants for Weight calculation
@@ -62,7 +62,7 @@ const WinningPoStSectorSetLookback = abi.ChainEpoch(10)
// Devnet settings
const TotalFilecoin = uint64(2_000_000_000)
const MiningRewardTotal = uint64(1_400_000_000)
const MiningRewardTotal = uint64(1_900_000_000)
const FilecoinPrecision = uint64(1_000_000_000_000_000_000)
@@ -91,7 +91,7 @@ const VerifSigCacheSize = 32000
// TODO: If this is gonna stay, it should move to specs-actors
const BlockMessageLimit = 512
const BlockGasLimit = 100_000_000_000
const BlockGasLimit = 7_500_000_000
var DrandConfig = dtypes.DrandConfig{
Servers: []string{
@@ -99,5 +99,5 @@ var DrandConfig = dtypes.DrandConfig{
"https://pl-us.testnet.drand.sh",
"https://pl-sin.testnet.drand.sh",
},
ChainInfoJSON: `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"138a324aa6540f93d0dad002aa89454b1bec2b6e948682cde6bd4db40f4b7c9b"}`,
ChainInfoJSON: `{"public_key":"922a2e93828ff83345bae533f5172669a26c02dc76d6bf59c80892e12ab1455c229211886f35bb56af6d5bea981024df","period":25,"genesis_time":1590445175,"hash":"84b2234fb34e835dccd048255d7ad3194b81af7d978c3bf157e3469592ae4e02","groupHash":"4dd408e5fdff9323c76a9b6f087ba8fdc5a6da907bd9217d9d10f2287d081957"}`,
}
+1 -1
View File
@@ -29,7 +29,7 @@ var (
AllowableClockDriftSecs = uint64(1)
Finality = miner.ChainFinalityish
Finality = miner.ChainFinality
ForkLengthThreshold = Finality
SlashablePowerDelay = 20
+4 -3
View File
@@ -13,10 +13,11 @@ import (
)
func init() {
power.ConsensusMinerMinPower = big.NewInt(1024 << 30)
power.ConsensusMinerMinPower = big.NewInt(1024 << 20)
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg32GiBV1: {},
abi.RegisteredSealProof_StackedDrg64GiBV1: {},
abi.RegisteredSealProof_StackedDrg512MiBV1: {},
abi.RegisteredSealProof_StackedDrg32GiBV1: {},
abi.RegisteredSealProof_StackedDrg64GiBV1: {},
}
}
+1 -1
View File
@@ -53,7 +53,7 @@ func (ve Version) EqMajorMinor(v2 Version) bool {
}
// APIVersion is a semver version of the rpc api exposed
var APIVersion Version = newVer(0, 6, 0)
var APIVersion Version = newVer(0, 8, 0)
//nolint:varcheck,deadcode
const (
+5 -4
View File
@@ -2,12 +2,13 @@ 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"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
)
var log = logging.Logger("beacon")
@@ -52,7 +53,7 @@ func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.B
}
func BeaconEntriesForBlock(ctx context.Context, beacon RandomBeacon, round abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) {
start := time.Now()
start := build.Clock.Now()
maxRound := beacon.MaxBeaconRoundForEpoch(round, prev)
if maxRound == prev.Round {
@@ -81,7 +82,7 @@ func BeaconEntriesForBlock(ctx context.Context, beacon RandomBeacon, round abi.C
}
}
log.Debugw("fetching beacon entries", "took", time.Since(start), "numEntries", len(out))
log.Debugw("fetching beacon entries", "took", build.Clock.Since(start), "numEntries", len(out))
reverse(out)
return out, nil
}
+3 -2
View File
@@ -21,6 +21,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@@ -131,7 +132,7 @@ func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Re
}
go func() {
start := time.Now()
start := build.Clock.Now()
log.Infow("start fetching randomness", "round", round)
resp, err := db.client.Get(ctx, round)
@@ -142,7 +143,7 @@ func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Re
br.Entry.Round = resp.Round()
br.Entry.Data = resp.Signature()
}
log.Infow("done fetching randomness", "round", round, "took", time.Since(start))
log.Infow("done fetching randomness", "round", round, "took", build.Clock.Since(start))
out <- br
close(out)
}()
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"sync"
"time"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/hashicorp/golang-lru"
peer "github.com/libp2p/go-libp2p-core/peer"
@@ -37,14 +38,14 @@ func (brt *blockReceiptTracker) Add(p peer.ID, ts *types.TipSet) {
if !ok {
pset := &peerSet{
peers: map[peer.ID]time.Time{
p: time.Now(),
p: build.Clock.Now(),
},
}
brt.cache.Add(ts.Key(), pset)
return
}
val.(*peerSet).peers[p] = time.Now()
val.(*peerSet).peers[p] = build.Clock.Now()
}
func (brt *blockReceiptTracker) GetPeers(ts *types.TipSet) []peer.ID {
+1 -1
View File
@@ -126,7 +126,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
}
writeDeadline := 60 * time.Second
_ = s.SetDeadline(time.Now().Add(writeDeadline))
_ = s.SetDeadline(time.Now().Add(writeDeadline)) // always use real time for socket/stream deadlines.
if err := cborutil.WriteCborRPC(s, resp); err != nil {
log.Warnw("failed to write back response for handle stream", "err", err, "peer", s.Conn().RemotePeer())
return
+11 -10
View File
@@ -21,6 +21,7 @@ import (
"golang.org/x/xerrors"
cborutil "github.com/filecoin-project/go-cbor-util"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
incrt "github.com/filecoin-project/lotus/lib/increadtimeout"
@@ -91,7 +92,7 @@ func (bs *BlockSync) GetBlocks(ctx context.Context, tsk types.TipSetKey, count i
// randomize the first few peers so we don't always pick the same peer
shufflePrefix(peers)
start := time.Now()
start := build.Clock.Now()
var oerr error
for _, p := range peers {
@@ -117,7 +118,7 @@ func (bs *BlockSync) GetBlocks(ctx context.Context, tsk types.TipSetKey, count i
if err != nil {
return nil, xerrors.Errorf("success response from peer failed to process: %w", err)
}
bs.syncPeers.logGlobalSuccess(time.Since(start))
bs.syncPeers.logGlobalSuccess(build.Clock.Since(start))
bs.host.ConnManager().TagPeer(p, "bsync", 25)
return resp, nil
}
@@ -197,7 +198,7 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun
}
var err error
start := time.Now()
start := build.Clock.Now()
for _, p := range peers {
res, rerr := bs.sendRequestToPeer(ctx, p, req)
@@ -208,7 +209,7 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun
}
if res.Status == StatusOK {
bs.syncPeers.logGlobalSuccess(time.Since(start))
bs.syncPeers.logGlobalSuccess(build.Clock.Since(start))
return res.Chain, nil
}
@@ -284,17 +285,17 @@ func (bs *BlockSync) fetchBlocksBlockSync(ctx context.Context, p peer.ID, req *B
ctx, span := trace.StartSpan(ctx, "blockSyncFetch")
defer span.End()
start := time.Now()
start := build.Clock.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.SetWriteDeadline(time.Now().Add(5 * time.Second))
_ = s.SetWriteDeadline(time.Now().Add(5 * time.Second)) // always use real time for socket/stream deadlines.
if err := cborutil.WriteCborRPC(s, req); err != nil {
_ = s.SetWriteDeadline(time.Time{})
bs.syncPeers.logFailure(p, time.Since(start))
bs.syncPeers.logFailure(p, build.Clock.Since(start))
return nil, err
}
_ = s.SetWriteDeadline(time.Time{})
@@ -302,7 +303,7 @@ func (bs *BlockSync) fetchBlocksBlockSync(ctx context.Context, p peer.ID, req *B
var res BlockSyncResponse
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))
bs.syncPeers.logFailure(p, build.Clock.Since(start))
return nil, err
}
@@ -314,7 +315,7 @@ func (bs *BlockSync) fetchBlocksBlockSync(ctx context.Context, p peer.ID, req *B
)
}
bs.syncPeers.logSuccess(p, time.Since(start))
bs.syncPeers.logSuccess(p, build.Clock.Since(start))
return &res, nil
}
@@ -475,7 +476,7 @@ func (bpt *bsPeerTracker) addPeer(p peer.ID) {
return
}
bpt.peers[p] = &peerStats{
firstSeen: time.Now(),
firstSeen: build.Clock.Now(),
}
}
+7 -1
View File
@@ -7,7 +7,7 @@ import (
"io"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
@@ -57,6 +57,8 @@ func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error {
}
func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error {
*t = BlockSyncRequest{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -179,6 +181,8 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error {
}
func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error {
*t = BlockSyncResponse{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -354,6 +358,8 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error {
}
func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error {
*t = BSTipSet{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
+1 -1
View File
@@ -99,7 +99,7 @@ func (e *Events) listenHeadChanges(ctx context.Context) {
log.Warnf("not restarting listenHeadChanges: context error: %s", ctx.Err())
return
}
time.Sleep(time.Second)
build.Clock.Sleep(time.Second)
log.Info("restarting listenHeadChanges")
}
}
+7 -3
View File
@@ -485,13 +485,15 @@ func (me *messageEvents) checkNewCalls(ts *types.TipSet) (map[triggerID]eventDat
for tid, matchFns := range me.matchers {
var matched bool
var once bool
for _, matchFn := range matchFns {
ok, err := matchFn(msg)
matchOne, ok, err := matchFn(msg)
if err != nil {
log.Errorf("event matcher failed: %s", err)
continue
}
matched = ok
once = matchOne
if matched {
break
@@ -500,7 +502,9 @@ func (me *messageEvents) checkNewCalls(ts *types.TipSet) (map[triggerID]eventDat
if matched {
res[tid] = msg
break
if once {
break
}
}
}
})
@@ -548,7 +552,7 @@ func (me *messageEvents) messagesForTs(ts *types.TipSet, consume func(*types.Mes
// `curH`-`ts.Height` = `confidence`
type MsgHandler func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error)
type MsgMatchFunc func(msg *types.Message) (bool, error)
type MsgMatchFunc func(msg *types.Message) (matchOnce bool, matched bool, err error)
// Called registers a callback which is triggered when a specified method is
// called on an actor, or a timeout is reached.
+3 -3
View File
@@ -561,9 +561,9 @@ func TestAtChainedConfidenceNull(t *testing.T) {
require.Equal(t, false, reverted)
}
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
func matchAddrMethod(to address.Address, m abi.MethodNum) func(msg *types.Message) (matchOnce bool, matched bool, err error) {
return func(msg *types.Message) (matchOnce bool, matched bool, err error) {
return true, to == msg.To && m == msg.Method, nil
}
}
+10 -5
View File
@@ -279,17 +279,22 @@ func (sp *StatePredicates) DealStateChangedForIDs(dealIds []abi.DealID) DiffAdtA
var oldDealPtr, newDealPtr *market.DealState
var oldDeal, newDeal market.DealState
_, err := oldDealStateArray.Get(uint64(dealID), &oldDeal)
// If the deal has been removed, we just set it to nil
found, err := oldDealStateArray.Get(uint64(dealID), &oldDeal)
if err != nil {
return false, nil, err
}
oldDealPtr = &oldDeal
if found {
oldDealPtr = &oldDeal
}
_, err = newDealStateArray.Get(uint64(dealID), &newDeal)
found, err = newDealStateArray.Get(uint64(dealID), &newDeal)
if err != nil {
return false, nil, err
}
newDealPtr = &newDeal
if found {
newDealPtr = &newDeal
}
if oldDeal != newDeal {
changedDeals[dealID] = DealStateChange{dealID, oldDealPtr, newDealPtr}
@@ -354,7 +359,7 @@ func (m *MinerSectorChanges) Modify(key uint64, from, to *typegen.Deferred) erro
return err
}
if siFrom.Info.Expiration != siTo.Info.Expiration {
if siFrom.Expiration != siTo.Expiration {
m.Extended = append(m.Extended, SectorExtensions{
From: *siFrom,
To: *siTo,
+39 -19
View File
@@ -122,11 +122,9 @@ func TestMarketPredicates(t *testing.T) {
LastUpdatedEpoch: 3,
SlashEpoch: 0,
}
newDeal2 := &market.DealState{
SectorStartEpoch: 4,
LastUpdatedEpoch: 6,
SlashEpoch: 6,
}
// deal 2 removed
// added
newDeal3 := &market.DealState{
SectorStartEpoch: 1,
@@ -135,7 +133,7 @@ func TestMarketPredicates(t *testing.T) {
}
newDeals := map[abi.DealID]*market.DealState{
abi.DealID(1): newDeal1,
abi.DealID(2): newDeal2,
// deal 2 was removed
abi.DealID(3): newDeal3,
}
@@ -197,10 +195,17 @@ func TestMarketPredicates(t *testing.T) {
t.Fatal("Unexpected change to LastUpdatedEpoch")
}
deal2 := changedDealIDs[abi.DealID(2)]
if deal2.From.SlashEpoch != 0 || deal2.To.SlashEpoch != 6 {
t.Fatal("Unexpected change to SlashEpoch")
if deal2.From.LastUpdatedEpoch != 5 || deal2.To != nil {
t.Fatal("Expected To to be nil")
}
// Diff with non-existent deal.
noDeal := []abi.DealID{4}
diffNoDealFn := preds.OnStorageMarketActorChanged(preds.OnDealStateChanged(preds.DealStateChangedForIDs(noDeal)))
changed, _, err = diffNoDealFn(ctx, oldState.Key(), newState.Key())
require.NoError(t, err)
require.False(t, changed)
// Test that OnActorStateChanged does not call the callback if the state has not changed
mockAddr, err := address.NewFromString("t01")
require.NoError(t, err)
@@ -241,16 +246,14 @@ func TestMarketPredicates(t *testing.T) {
require.Equal(t, abi.DealID(3), changedDeals.Added[0].ID)
require.Equal(t, *newDeal3, changedDeals.Added[0].Deal)
require.Len(t, changedDeals.Removed, 0)
require.Len(t, changedDeals.Removed, 1)
require.Len(t, changedDeals.Modified, 2)
require.Len(t, changedDeals.Modified, 1)
require.Equal(t, abi.DealID(1), changedDeals.Modified[0].ID)
require.Equal(t, newDeal1, changedDeals.Modified[0].To)
require.Equal(t, oldDeal1, changedDeals.Modified[0].From)
require.Equal(t, abi.DealID(2), changedDeals.Modified[1].ID)
require.Equal(t, oldDeal2, changedDeals.Modified[1].From)
require.Equal(t, newDeal2, changedDeals.Modified[1].To)
require.Equal(t, abi.DealID(2), changedDeals.Removed[0].ID)
})
t.Run("deal proposal array predicate", func(t *testing.T) {
@@ -301,7 +304,7 @@ func TestMinerSectorChange(t *testing.T) {
// 2 same
// 3 added
si1Ext := si1
si1Ext.Info.Expiration++
si1Ext.Expiration++
newMinerC := createMinerState(ctx, t, store, owner, worker, []miner.SectorOnChainInfo{si1Ext, si2, si3})
minerAddr := nextIDAddrF()
@@ -433,11 +436,22 @@ func createEmptyMinerState(ctx context.Context, t *testing.T, store *cbornode.Ba
emptyMap, err := store.Put(context.TODO(), hamt.NewNode(store, hamt.UseTreeBitWidth(5)))
require.NoError(t, err)
emptyDeadlines := miner.ConstructDeadlines()
emptyDeadline, err := store.Put(context.TODO(), &miner.Deadline{
Partitions: emptyArrayCid,
ExpirationsEpochs: emptyArrayCid,
PostSubmissions: abi.NewBitField(),
EarlyTerminations: abi.NewBitField(),
LiveSectors: 0,
})
require.NoError(t, err)
emptyDeadlines := miner.ConstructDeadlines(emptyDeadline)
emptyDeadlinesCid, err := store.Put(context.Background(), emptyDeadlines)
require.NoError(t, err)
state, err := miner.ConstructState(emptyArrayCid, emptyMap, emptyDeadlinesCid, owner, worker, abi.PeerID{'1'}, nil, abi.RegisteredSealProof_StackedDrg64GiBV1, 0)
minerInfo := emptyMap
state, err := miner.ConstructState(minerInfo, 123, emptyArrayCid, emptyMap, emptyDeadlinesCid)
require.NoError(t, err)
return state
@@ -447,7 +461,7 @@ func createSectorsAMT(ctx context.Context, t *testing.T, store *cbornode.BasicIp
root := amt.NewAMT(store)
for _, sector := range sectors {
sector := sector
err := root.Set(ctx, uint64(sector.Info.SectorNumber), &sector)
err := root.Set(ctx, uint64(sector.SectorNumber), &sector)
require.NoError(t, err)
}
rootCid, err := root.Flush(ctx)
@@ -459,10 +473,16 @@ func createSectorsAMT(ctx context.Context, t *testing.T, store *cbornode.BasicIp
func newSectorOnChainInfo(sectorNo abi.SectorNumber, sealed cid.Cid, weight big.Int, activation, expiration abi.ChainEpoch) miner.SectorOnChainInfo {
info := newSectorPreCommitInfo(sectorNo, sealed, expiration)
return miner.SectorOnChainInfo{
Info: *info,
ActivationEpoch: activation,
SectorNumber: info.SectorNumber,
SealProof: info.SealProof,
SealedCID: info.SealedCID,
DealIDs: info.DealIDs,
Expiration: info.Expiration,
Activation: activation,
DealWeight: weight,
VerifiedDealWeight: weight,
InitialPledge: big.Zero(),
}
}
+3 -3
View File
@@ -34,11 +34,11 @@ func (me *messageEvents) CheckMsg(ctx context.Context, smsg types.ChainMsg, hnd
}
func (me *messageEvents) MatchMsg(inmsg *types.Message) MsgMatchFunc {
return func(msg *types.Message) (bool, error) {
return func(msg *types.Message) (matchOnce bool, matched bool, err 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 %d", inmsg.Cid(), inmsg.From, inmsg.Nonce, msg.Nonce)
return true, 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
return true, inmsg.Equals(msg), nil
}
}
+12 -10
View File
@@ -9,7 +9,6 @@ import (
"time"
"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"
@@ -177,12 +176,12 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
Accounts: []genesis.Actor{
{
Type: genesis.TAccount,
Balance: types.FromFil(40000),
Balance: types.FromFil(20_000_000),
Meta: (&genesis.AccountMeta{Owner: mk1}).ActorMeta(),
},
{
Type: genesis.TAccount,
Balance: types.FromFil(40000),
Balance: types.FromFil(20_000_000),
Meta: (&genesis.AccountMeta{Owner: mk2}).ActorMeta(),
},
{
@@ -196,7 +195,7 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
*genm2,
},
NetworkName: "",
Timestamp: uint64(time.Now().Add(-500 * time.Duration(build.BlockDelaySecs) * time.Second).Unix()),
Timestamp: uint64(build.Clock.Now().Add(-500 * time.Duration(build.BlockDelaySecs) * time.Second).Unix()),
}
genb, err := genesis2.MakeGenesisBlock(context.TODO(), bs, sys, tpl)
@@ -284,7 +283,7 @@ func (cg *ChainGen) GenesisCar() ([]byte, 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) {
if link.Cid.Prefix().Codec == cid.FilCommitmentSealed || link.Cid.Prefix().Codec == cid.FilCommitmentUnsealed {
continue
}
out = append(out, link)
@@ -438,7 +437,8 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticke
// 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)
var act types.Actor
err := cg.sm.WithParentState(ts, cg.sm.WithActor(cg.banker, stmgr.GetActor(&act)))
if err != nil {
return err
}
@@ -468,7 +468,7 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) {
Method: 0,
GasLimit: 10000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(0),
}
@@ -558,12 +558,14 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
return nil, xerrors.Errorf("failed to compute VRF: %w", err)
}
// TODO: wire in real power
if !types.IsTicketWinner(vrfout, mbi.MinerPower, mbi.NetworkPower) {
ep := &types.ElectionProof{VRFProof: vrfout}
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
ep.WinCount = j
if j < 1 {
return nil, nil
}
return &types.ElectionProof{VRFProof: vrfout}, nil
return ep, nil
}
type SignFunc func(context.Context, address.Address, []byte) (*crypto.Signature, error)
+68 -22
View File
@@ -8,8 +8,10 @@ import (
"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/multisig"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
bstore "github.com/ipfs/go-ipfs-blockstore"
@@ -59,8 +61,14 @@ The process:
- power.CreateMiner, set msg value to PowerBalance
- market.AddFunds with correct value
- market.PublishDeals for related sectors
- Set precommits
- Commit presealed sectors
- Set network power in the power actor to what we'll have after genesis creation
- For each precommitted sector
- Get deal weight
- Calculate QA Power
- Remove fake power from the power actor
- Calculate pledge
- Precommit
- Confirm valid
Data Types:
@@ -189,8 +197,8 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
// Create accounts
for id, info := range template.Accounts {
if info.Type != genesis.TAccount {
return nil, xerrors.New("unsupported account type") // TODO: msigs
if info.Type != genesis.TAccount && info.Type != genesis.TMultisig {
return nil, xerrors.New("unsupported account type")
}
ida, err := address.NewIDAddress(uint64(AccountStart + id))
@@ -198,24 +206,57 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
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)
// var newAddress address.Address
if (info.Type == genesis.TAccount) {
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)
}
} else if (info.Type == genesis.TMultisig) {
var ainfo genesis.MultisigMeta
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
}
pending, err := adt.MakeEmptyMap(adt.WrapStore(ctx, cst)).Root()
if err != nil {
return nil, xerrors.Errorf("failed to create empty map: %v", err)
}
st, err := cst.Put(ctx, &multisig.State{
Signers: ainfo.Signers,
NumApprovalsThreshold: uint64(ainfo.Threshold),
StartEpoch: abi.ChainEpoch(ainfo.VestingStart),
UnlockDuration: abi.ChainEpoch(ainfo.VestingDuration),
PendingTxns: pending,
InitialBalance: info.Balance,
})
if err != nil {
return nil, err
}
err = state.SetActor(ida, &types.Actor{
Code: builtin.MultisigActorCodeID,
Balance: info.Balance,
Head: st,
})
if err != nil {
return nil, xerrors.Errorf("setting account from actmap: %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)
@@ -281,7 +322,12 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot ci
}
}
return vm.Flush(ctx)
st, err := vm.Flush(ctx)
if err != nil {
return cid.Cid{}, xerrors.Errorf("vm flush: %w", err)
}
return st, nil
}
func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Syscalls, template genesis.Template) (*GenesisBootstrap, error) {
@@ -306,7 +352,7 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners)
if err != nil {
return nil, xerrors.Errorf("setup storage miners failed: %w", err)
return nil, xerrors.Errorf("setup miners failed: %w", err)
}
cst := cbor.NewCborStore(bs)
+174 -81
View File
@@ -19,10 +19,10 @@ import (
"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/builtin/reward"
"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"
@@ -56,6 +56,14 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return cid.Undef, xerrors.New("no genesis miners")
}
minerInfos := make([]struct {
maddr address.Address
presealExp abi.ChainEpoch
dealIDs []abi.DealID
}, len(miners))
for i, m := range miners {
// Create miner through power actor
i := i
@@ -66,7 +74,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return cid.Undef, err
}
var maddr address.Address
{
constructorParams := &power.CreateMinerParams{
Owner: m.Worker,
@@ -90,13 +97,20 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
if ma.IDAddress != expma {
return cid.Undef, xerrors.Errorf("miner assigned wrong address: %s != %s", ma.IDAddress, expma)
}
maddr = ma.IDAddress
minerInfos[i].maddr = ma.IDAddress
err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner.State) error {
maxPeriods := miner.MaxSectorExpirationExtension / miner.WPoStProvingPeriod
minerInfos[i].presealExp = (maxPeriods-1)*miner.WPoStProvingPeriod + st.ProvingPeriodStart - 1
return nil
})
}
// Add market funds
{
params := mustEnc(&maddr)
params := mustEnc(&minerInfos[i].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)
@@ -112,7 +126,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
// 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)
@@ -126,7 +139,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return xerrors.Errorf("unmarsahling publishStorageDeals result: %w", err)
}
dealIDs = append(dealIDs, ids.IDs...)
minerInfos[i].dealIDs = append(minerInfos[i].dealIDs, ids.IDs...)
return nil
}
@@ -153,99 +166,117 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
}
}
}
}
// 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)
// adjust total network power for equal pledge per sector
rawPow, qaPow := big.NewInt(0), big.NewInt(0)
{
for i, m := range miners {
for pi := range m.Sectors {
rawPow = types.BigAdd(rawPow, types.NewInt(uint64(m.SectorSize)))
// 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))
dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp)
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{
SealProof: 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,
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
}
err = vm.MutateState(ctx, maddr, func(cst cbor.IpldStore, st *miner.State) error {
store := &state.AdtStore{cst}
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
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)
}
qaPow = types.BigAdd(qaPow, sectorWeight)
}
}
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
st.TotalQualityAdjPower = qaPow
st.TotalRawBytePower = rawPow
st.ThisEpochQualityAdjPower = qaPow
st.ThisEpochRawBytePower = rawPow
return nil
})
if err != nil {
return cid.Undef, xerrors.Errorf("mutating state: %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.
for i, m := range miners {
// Commit sectors
{
for pi, preseal := range m.Sectors {
params := &miner.SectorPreCommitInfo{
SealProof: preseal.ProofType,
SectorNumber: preseal.SectorID,
SealedCID: preseal.CommR,
SealRandEpoch: -1,
DealIDs: []abi.DealID{minerInfos[i].dealIDs[pi]},
Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally!
}
dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp)
if err != nil {
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
}
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
// we've added fake power for this sector above, remove it now
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
st.TotalQualityAdjPower = types.BigSub(st.TotalQualityAdjPower, sectorWeight)
st.TotalRawBytePower = types.BigSub(st.TotalRawBytePower, types.NewInt(uint64(m.SectorSize)))
return nil
})
if err != nil {
return cid.Undef, xerrors.Errorf("removing fake power: %w", err)
}
epochReward, err := currentEpochBlockReward(ctx, vm, minerInfos[i].maddr)
if err != nil {
return cid.Undef, xerrors.Errorf("getting current epoch reward: %w", err)
}
tpow, err := currentTotalPower(ctx, vm, minerInfos[i].maddr)
if err != nil {
return cid.Undef, xerrors.Errorf("getting current total power: %w", err)
}
pledge := miner.InitialPledgeForPower(sectorWeight, tpow.QualityAdjPower, epochReward.ThisEpochBaselinePower, tpow.PledgeCollateral, epochReward.ThisEpochReward, circSupply(ctx, vm, minerInfos[i].maddr))
fmt.Println(types.FIL(pledge))
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, m.Worker, pledge, builtin.MethodsMiner.PreCommitSector, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
}
// Commit one-by-one, otherwise pledge math tends to explode
confirmParams := &builtin.ConfirmSectorProofsParams{
Sectors: []abi.SectorNumber{preseal.SectorID},
}
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, builtin.StoragePowerActorAddr, big.Zero(), builtin.MethodsMiner.ConfirmSectorProofsValid, mustEnc(confirmParams))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
}
}
}
}
// Sanity-check total network power
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
st.TotalQualityAdjPower = big.Sub(st.TotalQualityAdjPower, big.NewInt(1))
if !st.TotalRawBytePower.Equals(rawPow) {
return xerrors.Errorf("st.TotalRawBytePower doesn't match previously calculated rawPow")
}
if !st.TotalQualityAdjPower.Equals(qaPow) {
return xerrors.Errorf("st.TotalQualityAdjPower doesn't match previously calculated qaPow")
}
return nil
})
if err != nil {
return cid.Undef, xerrors.Errorf("mutating state: %w", err)
}
// TODO: Should we re-ConstructState for the reward actor using rawPow as currRealizedPower here?
c, err := vm.Flush(ctx)
if err != nil {
return cid.Undef, xerrors.Errorf("flushing vm: %w", err)
@@ -261,3 +292,65 @@ func (fr *fakeRand) GetRandomness(ctx context.Context, personalization crypto.Do
_, _ = rand.New(rand.NewSource(int64(randEpoch))).Read(out)
return out, nil
}
func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*power.CurrentTotalPowerReturn, error) {
pwret, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, maddr, big.Zero(), builtin.MethodsPower.CurrentTotalPower, nil)
if err != nil {
return nil, err
}
var pwr power.CurrentTotalPowerReturn
if err := pwr.UnmarshalCBOR(bytes.NewReader(pwret)); err != nil {
return nil, err
}
return &pwr, nil
}
func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch) (market.VerifyDealsForActivationReturn, error) {
params := &market.VerifyDealsForActivationParams{
DealIDs: dealIDs,
SectorStart: sectorStart,
SectorExpiry: sectorExpiry,
}
var dealWeights market.VerifyDealsForActivationReturn
ret, err := doExecValue(ctx, vm,
builtin.StorageMarketActorAddr,
maddr,
abi.NewTokenAmount(0),
builtin.MethodsMarket.VerifyDealsForActivation,
mustEnc(params),
)
if err != nil {
return market.VerifyDealsForActivationReturn{}, err
}
if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
return market.VerifyDealsForActivationReturn{}, err
}
return dealWeights, nil
}
func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address) (*reward.ThisEpochRewardReturn, error) {
rwret, err := doExecValue(ctx, vm, builtin.RewardActorAddr, maddr, big.Zero(), builtin.MethodsReward.ThisEpochReward, nil)
if err != nil {
return nil, err
}
var epochReward reward.ThisEpochRewardReturn
if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
return nil, err
}
return &epochReward, nil
}
func circSupply(ctx context.Context, vmi *vm.VM, maddr address.Address) abi.TokenAmount {
unsafeVM := &vm.UnsafeVM{VM: vmi}
rt := unsafeVM.MakeRuntime(ctx, &types.Message{
GasLimit: 1_000_000_000,
From: maddr,
}, maddr, 0, 0, 0)
return rt.TotalFilCircSupply()
}
+4
View File
@@ -30,6 +30,10 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
amap := hamt.NewNode(cst, hamt.UseTreeBitWidth(5)) // TODO: use spec adt map
for i, a := range initialActors {
if a.Type == genesis.TMultisig {
continue
}
if a.Type != genesis.TAccount {
return nil, xerrors.Errorf("unsupported account type: %s", a.Type) // TODO: Support msig (skip here)
}
+4 -2
View File
@@ -2,6 +2,7 @@ package genesis
import (
"context"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
@@ -14,8 +15,9 @@ import (
func SetupRewardActor(bs bstore.Blockstore) (*types.Actor, error) {
cst := cbor.NewCborStore(bs)
st := reward.ConstructState()
st.LastPerEpochReward = types.FromFil(100)
z := big.Zero()
st := reward.ConstructState(z)
st.ThisEpochReward = types.FromFil(100)
hcid, err := cst.Put(context.TODO(), st)
if err != nil {
+11 -8
View File
@@ -23,14 +23,17 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
}
sms := &power.State{
TotalRawBytePower: big.NewInt(0),
TotalQualityAdjPower: big.NewInt(1), // TODO: has to be 1 initially to avoid div by zero. Kinda annoying, should find a way to fix
TotalPledgeCollateral: big.NewInt(0),
MinerCount: 0,
CronEventQueue: emptyhamt,
LastEpochTick: 0,
Claims: emptyhamt,
NumMinersMeetingMinPower: 0,
TotalRawBytePower: big.NewInt(0),
TotalBytesCommitted: big.NewInt(0),
TotalQualityAdjPower: big.NewInt(0),
TotalQABytesCommitted: big.NewInt(0),
TotalPledgeCollateral: big.NewInt(0),
MinerCount: 0,
MinerAboveMinPowerCount: 0,
CronEventQueue: emptyhamt,
FirstCronEpoch: 0,
Claims: emptyhamt,
ProofValidationBatch: nil,
}
stcid, err := cst.Put(ctx, sms)
+1 -1
View File
@@ -70,7 +70,7 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add
From: wallet,
Value: toAdd,
GasPrice: types.NewInt(0),
GasLimit: 1000000,
GasLimit: 100_000_000,
Method: builtin.MethodsMarket.AddBalance,
Params: params,
})
+7 -3
View File
@@ -23,12 +23,15 @@ import (
"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/stmgr"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sigs"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/raulk/clock"
)
var log = logging.Logger("messagepool")
@@ -66,7 +69,7 @@ type MessagePool struct {
lk sync.Mutex
closer chan struct{}
repubTk *time.Ticker
repubTk *clock.Ticker
localAddrs map[address.Address]struct{}
@@ -162,7 +165,8 @@ func (mpp *mpoolProvider) PubSubPublish(k string, v []byte) error {
}
func (mpp *mpoolProvider) StateGetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
return mpp.sm.GetActor(addr, ts)
var act types.Actor
return &act, mpp.sm.WithParentState(ts, mpp.sm.WithActor(addr, stmgr.GetActor(&act)))
}
func (mpp *mpoolProvider) StateAccountKey(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
@@ -187,7 +191,7 @@ func New(api Provider, ds dtypes.MetadataDS, netName dtypes.NetworkName) (*Messa
mp := &MessagePool{
closer: make(chan struct{}),
repubTk: time.NewTicker(time.Duration(build.BlockDelaySecs) * 10 * time.Second),
repubTk: build.Clock.Ticker(time.Duration(build.BlockDelaySecs) * 10 * time.Second),
localAddrs: make(map[address.Address]struct{}),
pending: make(map[address.Address]*msgSet),
minGasPrice: types.NewInt(0),
+3 -3
View File
@@ -3,7 +3,6 @@ package metrics
import (
"context"
"encoding/json"
"time"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/ipfs/go-cid"
@@ -11,6 +10,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
"go.uber.org/fx"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/node/modules/helpers"
@@ -89,7 +89,7 @@ func sendHeadNotifs(ctx context.Context, ps *pubsub.PubSub, topic string, chain
}
// using unix nano time makes very sure we pick a nonce higher than previous restart
nonce := uint64(time.Now().UnixNano())
nonce := uint64(build.Clock.Now().UnixNano())
for {
select {
@@ -107,7 +107,7 @@ func sendHeadNotifs(ctx context.Context, ps *pubsub.PubSub, topic string, chain
Height: n.Val.Height(),
Weight: w,
NodeName: nickname,
Time: uint64(time.Now().UnixNano() / 1000_000),
Time: uint64(build.Clock.Now().UnixNano() / 1000_000),
Nonce: nonce,
}
+2 -1
View File
@@ -10,6 +10,7 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
@@ -25,7 +26,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
}
if msg.GasLimit == 0 {
msg.GasLimit = 10000000000
msg.GasLimit = build.BlockGasLimit
}
if msg.GasPrice == types.EmptyInt {
msg.GasPrice = types.NewInt(0)
+2 -2
View File
@@ -179,7 +179,7 @@ func TestForkHeightTriggers(t *testing.T) {
To: builtin.InitActorAddr,
Method: builtin.MethodsInit.Exec,
Params: enc,
GasLimit: 10000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(0),
}
sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes())
@@ -206,7 +206,7 @@ func TestForkHeightTriggers(t *testing.T) {
Method: 2,
Params: nil,
Nonce: nonce,
GasLimit: 10000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(0),
}
nonce++
+155
View File
@@ -0,0 +1,155 @@
package stmgr
import (
"context"
"reflect"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/util/adt"
)
type StateTreeCB func(state *state.StateTree) error
func (sm *StateManager) WithParentStateTsk(tsk types.TipSetKey, cb StateTreeCB) error {
ts, err := sm.cs.GetTipSetFromKey(tsk)
if err != nil {
return xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
cst := cbor.NewCborStore(sm.cs.Blockstore())
state, err := state.LoadStateTree(cst, sm.parentState(ts))
if err != nil {
return xerrors.Errorf("load state tree: %w", err)
}
return cb(state)
}
func (sm *StateManager) WithParentState(ts *types.TipSet, cb StateTreeCB) error {
cst := cbor.NewCborStore(sm.cs.Blockstore())
state, err := state.LoadStateTree(cst, sm.parentState(ts))
if err != nil {
return xerrors.Errorf("load state tree: %w", err)
}
return cb(state)
}
func (sm *StateManager) WithStateTree(st cid.Cid, cb StateTreeCB) error {
cst := cbor.NewCborStore(sm.cs.Blockstore())
state, err := state.LoadStateTree(cst, st)
if err != nil {
return xerrors.Errorf("load state tree: %w", err)
}
return cb(state)
}
type ActorCB func(act *types.Actor) error
func GetActor(out *types.Actor) ActorCB {
return func(act *types.Actor) error {
*out = *act
return nil
}
}
func (sm *StateManager) WithActor(addr address.Address, cb ActorCB) StateTreeCB {
return func(state *state.StateTree) error {
act, err := state.GetActor(addr)
if err != nil {
return xerrors.Errorf("get actor: %w", err)
}
return cb(act)
}
}
// WithActorState usage:
// Option 1: WithActorState(ctx, idAddr, func(store adt.Store, st *ActorStateType) error {...})
// Option 2: WithActorState(ctx, idAddr, actorStatePtr)
func (sm *StateManager) WithActorState(ctx context.Context, out interface{}) ActorCB {
return func(act *types.Actor) error {
store := sm.cs.Store(ctx)
outCallback := reflect.TypeOf(out).Kind() == reflect.Func
var st reflect.Value
if outCallback {
st = reflect.New(reflect.TypeOf(out).In(1).Elem())
} else {
st = reflect.ValueOf(out)
}
if err := store.Get(ctx, act.Head, st.Interface()); err != nil {
return xerrors.Errorf("read actor head: %w", err)
}
if outCallback {
out := reflect.ValueOf(out).Call([]reflect.Value{reflect.ValueOf(store), st})
if !out[0].IsNil() && out[0].Interface().(error) != nil {
return out[0].Interface().(error)
}
}
return nil
}
}
type DeadlinesCB func(store adt.Store, deadlines *miner.Deadlines) error
func (sm *StateManager) WithDeadlines(cb DeadlinesCB) func(store adt.Store, mas *miner.State) error {
return func(store adt.Store, mas *miner.State) error {
deadlines, err := mas.LoadDeadlines(store)
if err != nil {
return err
}
return cb(store, deadlines)
}
}
type DeadlineCB func(store adt.Store, idx uint64, deadline *miner.Deadline) error
func (sm *StateManager) WithDeadline(idx uint64, cb DeadlineCB) DeadlinesCB {
return func(store adt.Store, deadlines *miner.Deadlines) error {
d, err := deadlines.LoadDeadline(store, idx)
if err != nil {
return err
}
return cb(store, idx, d)
}
}
func (sm *StateManager) WithEachDeadline(cb DeadlineCB) DeadlinesCB {
return func(store adt.Store, deadlines *miner.Deadlines) error {
return deadlines.ForEach(store, func(dlIdx uint64, dl *miner.Deadline) error {
return cb(store, dlIdx, dl)
})
}
}
type PartitionCB func(store adt.Store, idx uint64, partition *miner.Partition) error
func (sm *StateManager) WithEachPartition(cb PartitionCB) DeadlineCB {
return func(store adt.Store, idx uint64, deadline *miner.Deadline) error {
parts, err := deadline.PartitionsArray(store)
if err != nil {
return err
}
var partition miner.Partition
return parts.ForEach(&partition, func(i int64) error {
p := partition
return cb(store, uint64(i), &p)
})
}
}
+9 -70
View File
@@ -8,6 +8,7 @@ import (
"github.com/filecoin-project/go-address"
amt "github.com/filecoin-project/go-amt-ipld/v2"
"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/state"
"github.com/filecoin-project/lotus/chain/store"
@@ -143,7 +144,7 @@ type BlockMessages struct {
Miner address.Address
BlsMessages []types.ChainMsg
SecpkMessages []types.ChainMsg
TicketCount int64
WinCount int64
}
type ExecCallback func(cid.Cid, *types.Message, *vm.ApplyRet) error
@@ -187,6 +188,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
Miner: b.Miner,
Penalty: penalty,
GasReward: gasReward,
WinCount: b.WinCount,
})
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("failed to serialize award params: %w", err)
@@ -235,7 +237,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
Nonce: ca.Nonce,
Value: types.NewInt(0),
GasPrice: types.NewInt(0),
GasLimit: 1 << 30, // Make super sure this is never too little
GasLimit: build.BlockGasLimit * 10, // Make super sure this is never too little
Method: builtin.MethodsCron.EpochTick,
Params: nil,
}
@@ -311,7 +313,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
Miner: b.Miner,
BlsMessages: make([]types.ChainMsg, 0, len(bms)),
SecpkMessages: make([]types.ChainMsg, 0, len(sms)),
TicketCount: 1, //int64(len(b.EPostProof.Proofs)), // TODO fix this
WinCount: b.ElectionProof.WinCount,
}
for _, m := range bms {
@@ -336,74 +338,10 @@ func (sm *StateManager) parentState(ts *types.TipSet) cid.Cid {
return ts.ParentState()
}
func (sm *StateManager) GetActor(addr address.Address, ts *types.TipSet) (*types.Actor, error) {
cst := cbor.NewCborStore(sm.cs.Blockstore())
state, err := state.LoadStateTree(cst, sm.parentState(ts))
if err != nil {
return nil, xerrors.Errorf("load state tree: %w", err)
}
return state.GetActor(addr)
}
func (sm *StateManager) getActorRaw(addr address.Address, st cid.Cid) (*types.Actor, error) {
cst := cbor.NewCborStore(sm.cs.Blockstore())
state, err := state.LoadStateTree(cst, st)
if err != nil {
return nil, xerrors.Errorf("load state tree: %w", err)
}
return state.GetActor(addr)
}
func (sm *StateManager) GetBalance(addr address.Address, ts *types.TipSet) (types.BigInt, error) {
act, err := sm.GetActor(addr, ts)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
return types.NewInt(0), nil
}
return types.EmptyInt, xerrors.Errorf("get actor: %w", err)
}
return act.Balance, nil
}
func (sm *StateManager) ChainStore() *store.ChainStore {
return sm.cs
}
func (sm *StateManager) LoadActorState(ctx context.Context, a address.Address, out interface{}, ts *types.TipSet) (*types.Actor, error) {
act, err := sm.GetActor(a, ts)
if err != nil {
return nil, err
}
cst := cbor.NewCborStore(sm.cs.Blockstore())
if err := cst.Get(ctx, act.Head, out); err != nil {
var r cbg.Deferred
_ = cst.Get(ctx, act.Head, &r)
log.Errorw("bad actor head", "error", err, "raw", r.Raw, "address", a)
return nil, err
}
return act, nil
}
func (sm *StateManager) LoadActorStateRaw(ctx context.Context, a address.Address, out interface{}, st cid.Cid) (*types.Actor, error) {
act, err := sm.getActorRaw(a, st)
if err != nil {
return nil, err
}
cst := cbor.NewCborStore(sm.cs.Blockstore())
if err := cst.Get(ctx, act.Head, out); err != nil {
return nil, err
}
return act, nil
}
// ResolveToKeyAddress is similar to `vm.ResolveToKeyAddr` but does not allow `Actor` type of addresses.
// Uses the `TipSet` `ts` to generate the VM state.
func (sm *StateManager) ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
@@ -635,7 +573,8 @@ func (sm *StateManager) searchBackForMsg(ctx context.Context, from *types.TipSet
default:
}
act, err := sm.GetActor(m.VMMessage().From, cur)
var act types.Actor
err := sm.WithParentState(cur, sm.WithActor(m.VMMessage().From, GetActor(&act)))
if err != nil {
return nil, nil, err
}
@@ -758,7 +697,7 @@ func (sm *StateManager) MarketBalance(ctx context.Context, addr address.Address,
return api.MarketBalance{}, err
}
if ehas {
out.Escrow, err = et.Get(addr)
out.Escrow, _, err = et.Get(addr)
if err != nil {
return api.MarketBalance{}, xerrors.Errorf("getting escrow balance: %w", err)
}
@@ -775,7 +714,7 @@ func (sm *StateManager) MarketBalance(ctx context.Context, addr address.Address,
return api.MarketBalance{}, err
}
if lhas {
out.Locked, err = lt.Get(addr)
out.Locked, _, err = lt.Get(addr)
if err != nil {
return api.MarketBalance{}, xerrors.Errorf("getting locked balance: %w", err)
}
+116 -109
View File
@@ -17,6 +17,7 @@ import (
"github.com/filecoin-project/go-bitfield"
"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/account"
"github.com/filecoin-project/specs-actors/actors/builtin/cron"
@@ -43,14 +44,38 @@ import (
func GetNetworkName(ctx context.Context, sm *StateManager, st cid.Cid) (dtypes.NetworkName, error) {
var state init_.State
_, err := sm.LoadActorStateRaw(ctx, builtin.InitActorAddr, &state, st)
err := sm.WithStateTree(st, sm.WithActor(builtin.InitActorAddr, sm.WithActorState(ctx, &state)))
if err != nil {
return "", xerrors.Errorf("(get sset) failed to load init actor state: %w", err)
return "", err
}
return dtypes.NetworkName(state.NetworkName), nil
}
func (sm *StateManager) LoadActorState(ctx context.Context, addr address.Address, out interface{}, ts *types.TipSet) (*types.Actor, error) {
var a *types.Actor
if err := sm.WithParentState(ts, sm.WithActor(addr, func(act *types.Actor) error {
a = act
return sm.WithActorState(ctx, out)(act)
})); err != nil {
return nil, err
}
return a, nil
}
func (sm *StateManager) LoadActorStateRaw(ctx context.Context, addr address.Address, out interface{}, st cid.Cid) (*types.Actor, error) {
var a *types.Actor
if err := sm.WithStateTree(st, sm.WithActor(addr, func(act *types.Actor) error {
a = act
return sm.WithActorState(ctx, out)(act)
})); err != nil {
return nil, err
}
return a, nil
}
func GetMinerWorkerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr address.Address) (address.Address, error) {
var mas miner.State
_, err := sm.LoadActorStateRaw(ctx, maddr, &mas, st)
@@ -64,7 +89,12 @@ func GetMinerWorkerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr
return address.Undef, xerrors.Errorf("load state tree: %w", err)
}
return vm.ResolveToKeyAddr(state, cst, mas.Info.Worker)
info, err := mas.GetInfo(sm.cs.Store(ctx))
if err != nil {
return address.Address{}, err
}
return vm.ResolveToKeyAddr(state, cst, info.Worker)
}
func GetPower(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (power.Claim, power.Claim, error) {
@@ -99,35 +129,6 @@ func GetPowerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr addres
}, nil
}
func SectorSetSizes(ctx context.Context, sm *StateManager, maddr address.Address, ts *types.TipSet) (api.MinerSectors, error) {
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return api.MinerSectors{}, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
}
notProving, err := abi.BitFieldUnion(mas.Faults, mas.Recoveries)
if err != nil {
return api.MinerSectors{}, err
}
npc, err := notProving.Count()
if err != nil {
return api.MinerSectors{}, err
}
blks := cbor.NewCborStore(sm.ChainStore().Blockstore())
ss, err := amt.LoadAMT(ctx, blks, mas.Sectors)
if err != nil {
return api.MinerSectors{}, err
}
return api.MinerSectors{
Sset: ss.Count,
Pset: ss.Count - npc,
}, nil
}
func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (miner.SectorPreCommitOnChainInfo, error) {
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
@@ -175,31 +176,51 @@ func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet,
}
func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]abi.SectorInfo, error) {
var mas miner.State
_, err := sm.LoadActorStateRaw(ctx, maddr, &mas, st)
var partsProving []*abi.BitField
var mas *miner.State
var info *miner.MinerInfo
err := sm.WithStateTree(st, sm.WithActor(maddr, sm.WithActorState(ctx, func(store adt.Store, mst *miner.State) error {
var err error
mas = mst
info, err = mas.GetInfo(store)
if err != nil {
return xerrors.Errorf("getting miner info: %w", err)
}
deadlines, err := mas.LoadDeadlines(store)
if err != nil {
return xerrors.Errorf("loading deadlines: %w", err)
}
return deadlines.ForEach(store, func(dlIdx uint64, deadline *miner.Deadline) error {
partitions, err := deadline.PartitionsArray(store)
if err != nil {
return xerrors.Errorf("getting partition array: %w", err)
}
var partition miner.Partition
return partitions.ForEach(&partition, func(partIdx int64) error {
p, err := bitfield.SubtractBitField(partition.Sectors, partition.Faults)
if err != nil {
return xerrors.Errorf("subtract faults from partition sectors: %w", err)
}
partsProving = append(partsProving, p)
return nil
})
})
})))
if err != nil {
return nil, xerrors.Errorf("(get sectors) failed to load miner actor state: %w", err)
return nil, err
}
cst := cbor.NewCborStore(sm.cs.Blockstore())
var deadlines miner.Deadlines
if err := cst.Get(ctx, mas.Deadlines, &deadlines); err != nil {
return nil, xerrors.Errorf("failed to load deadlines: %w", err)
}
notProving, err := abi.BitFieldUnion(mas.Faults, mas.Recoveries)
provingSectors, err := bitfield.MultiMerge(partsProving...)
if err != nil {
return nil, xerrors.Errorf("failed to union faults and recoveries: %w", err)
}
allSectors, err := bitfield.MultiMerge(append(deadlines.Due[:], mas.NewSectors)...)
if err != nil {
return nil, xerrors.Errorf("merging deadline bitfields failed: %w", err)
}
provingSectors, err := bitfield.SubtractBitField(allSectors, notProving)
if err != nil {
return nil, xerrors.Errorf("failed to subtract non-proving sectors from set: %w", err)
return nil, xerrors.Errorf("merge partition proving sets: %w", err)
}
numProvSect, err := provingSectors.Count()
@@ -212,7 +233,7 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
return nil, nil
}
spt, err := ffiwrapper.SealProofTypeFromSectorSize(mas.Info.SectorSize)
spt, err := ffiwrapper.SealProofTypeFromSectorSize(info.SectorSize)
if err != nil {
return nil, xerrors.Errorf("getting seal proof type: %w", err)
}
@@ -237,7 +258,7 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
return nil, xerrors.Errorf("failed to enumerate all sector IDs: %w", err)
}
sectorAmt, err := amt.LoadAMT(ctx, cst, mas.Sectors)
sectorAmt, err := amt.LoadAMT(ctx, sm.cs.Store(ctx), mas.Sectors)
if err != nil {
return nil, xerrors.Errorf("failed to load sectors amt: %w", err)
}
@@ -253,22 +274,22 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
out[i] = abi.SectorInfo{
SealProof: spt,
SectorNumber: sinfo.Info.SectorNumber,
SealedCID: sinfo.Info.SealedCID,
SectorNumber: sinfo.SectorNumber,
SealedCID: sinfo.SealedCID,
}
}
return out, nil
}
func StateMinerInfo(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (miner.MinerInfo, error) {
func StateMinerInfo(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*miner.MinerInfo, error) {
var mas miner.State
_, err := sm.LoadActorStateRaw(ctx, maddr, &mas, ts.ParentState())
if err != nil {
return miner.MinerInfo{}, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
return nil, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
}
return mas.Info, nil
return mas.GetInfo(sm.cs.Store(ctx))
}
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error) {
@@ -302,36 +323,6 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
return false, nil
}
func GetMinerDeadlines(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*miner.Deadlines, error) {
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
}
return mas.LoadDeadlines(sm.cs.Store(ctx))
}
func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*abi.BitField, error) {
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get faults) failed to load miner actor state: %w", err)
}
return mas.Faults, nil
}
func GetMinerRecoveries(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*abi.BitField, error) {
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get recoveries) failed to load miner actor state: %w", err)
}
return mas.Recoveries, nil
}
func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
var state market.State
if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil {
@@ -473,20 +464,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
return root, trace, nil
}
func GetProvingSetRaw(ctx context.Context, sm *StateManager, mas miner.State) ([]*api.ChainSectorInfo, error) {
notProving, err := abi.BitFieldUnion(mas.Faults, mas.Recoveries)
if err != nil {
return nil, err
}
provset, err := LoadSectorsFromSet(ctx, sm.cs.Blockstore(), mas.Sectors, notProving, true)
if err != nil {
return nil, xerrors.Errorf("failed to get proving set: %w", err)
}
return provset, nil
}
func GetLookbackTipSetForRound(ctx context.Context, sm *StateManager, ts *types.TipSet, round abi.ChainEpoch) (*types.TipSet, error) {
var lbr abi.ChainEpoch
if round > build.WinningPoStSectorSetLookback {
@@ -570,7 +547,12 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcn beacon.RandomBe
return nil, xerrors.Errorf("failed to get power: %w", err)
}
worker, err := sm.ResolveToKeyAddress(ctx, mas.GetWorker(), ts)
info, err := mas.GetInfo(sm.cs.Store(ctx))
if err != nil {
return nil, err
}
worker, err := sm.ResolveToKeyAddress(ctx, info.Worker, ts)
if err != nil {
return nil, xerrors.Errorf("resolving worker address: %w", err)
}
@@ -580,12 +562,37 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcn beacon.RandomBe
NetworkPower: tpow.QualityAdjPower,
Sectors: sectors,
WorkerKey: worker,
SectorSize: mas.Info.SectorSize,
SectorSize: info.SectorSize,
PrevBeaconEntry: *prev,
BeaconEntries: entries,
}, nil
}
func (sm *StateManager) CirculatingSupply(ctx context.Context, ts *types.TipSet) (abi.TokenAmount, error) {
if ts == nil {
ts = sm.cs.GetHeaviestTipSet()
}
st, _, err := sm.TipSetState(ctx, ts)
if err != nil {
return big.Zero(), err
}
r := store.NewChainRand(sm.cs, ts.Cids(), ts.Height())
vmi, err := vm.NewVM(st, ts.Height(), r, sm.cs.Blockstore(), sm.cs.VMSys())
if err != nil {
return big.Zero(), err
}
unsafeVM := &vm.UnsafeVM{VM: vmi}
rt := unsafeVM.MakeRuntime(ctx, &types.Message{
GasLimit: 1_000_000_000,
From: builtin.SystemActorAddr,
}, builtin.SystemActorAddr, 0, 0, 0)
return rt.TotalFilCircSupply(), nil
}
type methodMeta struct {
Name string
@@ -634,9 +641,9 @@ func init() {
}
func GetReturnType(ctx context.Context, sm *StateManager, to address.Address, method abi.MethodNum, ts *types.TipSet) (cbg.CBORUnmarshaler, error) {
act, err := sm.GetActor(to, ts)
if err != nil {
return nil, err
var act types.Actor
if err := sm.WithParentState(ts, sm.WithActor(to, GetActor(&act))); err != nil {
return nil, xerrors.Errorf("getting actor: %w", err)
}
m := MethodsMap[act.Code][method]
+17 -32
View File
@@ -5,6 +5,7 @@ import (
"context"
"encoding/binary"
"encoding/json"
"github.com/filecoin-project/lotus/lib/adtutil"
"io"
"os"
"sync"
@@ -894,27 +895,7 @@ func (cs *ChainStore) Blockstore() bstore.Blockstore {
}
func ActorStore(ctx context.Context, bs blockstore.Blockstore) adt.Store {
return &astore{
cst: cbor.NewCborStore(bs),
ctx: ctx,
}
}
type astore struct {
cst cbor.IpldStore
ctx context.Context
}
func (a *astore) Context() context.Context {
return a.ctx
}
func (a *astore) Get(ctx context.Context, c cid.Cid, out interface{}) error {
return a.cst.Get(ctx, c, out)
}
func (a *astore) Put(ctx context.Context, v interface{}) (cid.Cid, error) {
return a.cst.Put(ctx, v)
return adtutil.NewStore(ctx, cbor.NewCborStore(bs))
}
func (cs *ChainStore) Store(ctx context.Context) adt.Store {
@@ -1046,21 +1027,25 @@ func recurseLinks(bs blockstore.Blockstore, root cid.Cid, in []cid.Cid) ([]cid.C
return nil, xerrors.Errorf("recurse links get (%s) failed: %w", root, err)
}
top, err := cbg.ScanForLinks(bytes.NewReader(data.RawData()))
var rerr error
err = cbg.ScanForLinks(bytes.NewReader(data.RawData()), func(c cid.Cid) {
if rerr != nil {
// No error return on ScanForLinks :(
return
}
in = append(in, c)
var err error
in, err = recurseLinks(bs, c, in)
if err != nil {
rerr = err
}
})
if err != nil {
return nil, xerrors.Errorf("scanning for links failed: %w", err)
}
in = append(in, top...)
for _, c := range top {
var err error
in, err = recurseLinks(bs, c, in)
if err != nil {
return nil, err
}
}
return in, nil
return in, rerr
}
func (cs *ChainStore) Export(ctx context.Context, ts *types.TipSet, w io.Writer) error {
+14 -6
View File
@@ -21,11 +21,11 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
if ts == nil {
return types.NewInt(0), nil
}
// >>> w[r] <<< + wFunction(totalPowerAtTipset(ts)) * 2^8 + (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
// >>> w[r] <<< + wFunction(totalPowerAtTipset(ts)) * 2^8 + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
var out = new(big.Int).Set(ts.Blocks()[0].ParentWeight.Int)
// >>> wFunction(totalPowerAtTipset(ts)) * 2^8 <<< + (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
// >>> wFunction(totalPowerAtTipset(ts)) * 2^8 <<< + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
tpow := big2.Zero()
{
@@ -57,11 +57,19 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
out.Add(out, big.NewInt(log2P<<8))
// (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
// (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
eWeight := big.NewInt((log2P * int64(len(ts.Blocks())) * build.WRatioNum) << 8)
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch*build.WRatioDen)))
out.Add(out, eWeight)
totalJ := int64(0)
for _, b := range ts.Blocks() {
totalJ += b.ElectionProof.WinCount
}
eWeight := big.NewInt((log2P * build.WRatioNum))
eWeight = eWeight.Lsh(eWeight, 8)
eWeight = eWeight.Mul(eWeight, new(big.Int).SetInt64(totalJ))
eWeight = eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch*build.WRatioDen)))
out = out.Add(out, eWeight)
return types.BigInt{Int: out}, nil
}
+19 -7
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/filecoin-project/lotus/lib/adtutil"
"sync"
"time"
@@ -60,7 +61,7 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha
src := msg.GetFrom()
go func() {
start := time.Now()
start := build.Clock.Now()
log.Debug("about to fetch messages for block from pubsub")
bmsgs, err := s.Bsync.FetchMessagesByCids(context.TODO(), blk.BlsMessages)
if err != nil {
@@ -74,9 +75,9 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, s *cha
return
}
took := time.Since(start)
took := build.Clock.Since(start)
log.Infow("new block over pubsub", "cid", blk.Header.Cid(), "source", msg.GetFrom(), "msgfetch", took)
if delay := time.Now().Unix() - int64(blk.Header.Timestamp); delay > 5 {
if delay := build.Clock.Now().Unix() - int64(blk.Header.Timestamp); delay > 5 {
log.Warnf("Received block with large delay %d from miner %s", delay, blk.Header.Miner)
}
@@ -141,9 +142,9 @@ func (bv *BlockValidator) flagPeer(p peer.ID) {
func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult {
// track validation time
begin := time.Now()
begin := build.Clock.Now()
defer func() {
log.Debugf("block validation time: %s", time.Since(begin))
log.Debugf("block validation time: %s", build.Clock.Since(begin))
}()
stats.Record(ctx, metrics.BlockReceived.M(1))
@@ -210,6 +211,12 @@ func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub
return pubsub.ValidationReject
}
if blk.Header.ElectionProof.WinCount < 1 {
log.Errorf("block is not claiming to be winning")
recordFailure("not_winning")
return pubsub.ValidationReject
}
// it's a good block! make sure we've only seen it once
if bv.recvBlocks.add(blk.Header.Cid()) > 0 {
// TODO: once these changes propagate to the network, we can consider
@@ -226,7 +233,7 @@ func (bv *BlockValidator) Validate(ctx context.Context, pid peer.ID, msg *pubsub
func (bv *BlockValidator) isChainNearSynced() bool {
ts := bv.chain.GetHeaviestTipSet()
timestamp := ts.MinTimestamp()
now := time.Now().UnixNano()
now := build.Clock.Now().UnixNano()
cutoff := uint64(now) - uint64(6*time.Hour)
return timestamp > cutoff
}
@@ -311,7 +318,12 @@ func (bv *BlockValidator) getMinerWorkerKey(ctx context.Context, msg *types.Bloc
return address.Undef, err
}
worker := mst.Info.Worker
info, err := mst.GetInfo(adtutil.NewStore(ctx, cst))
if err != nil {
return address.Undef, err
}
worker := info.Worker
key, err = bv.stmgr.ResolveToKeyAddress(ctx, worker, ts)
if err != nil {
return address.Undef, err
+24 -11
View File
@@ -620,7 +620,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
return nil
}
validationStart := time.Now()
validationStart := build.Clock.Now()
defer func() {
dur := time.Since(validationStart)
durMilli := dur.Seconds() * float64(1000)
@@ -632,7 +632,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
defer span.End()
if build.InsecurePoStValidation {
log.Warn("insecure test validation is enabled, if you see this outside of a test, it is a severe bug!")
log.Warn("[INSECURE-POST-VALIDATION] if you see this outside of a test, it is a severe bug!")
}
if err := blockSanityChecks(b.Header); err != nil {
@@ -665,12 +665,12 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
// fast checks first
now := uint64(time.Now().Unix())
now := uint64(build.Clock.Now().Unix())
if h.Timestamp > now+build.AllowableClockDriftSecs {
return xerrors.Errorf("block was from the future (now=%d, blk=%d): %w", now, h.Timestamp, ErrTemporal)
}
if h.Timestamp > now {
log.Warn("Got block from the future, but within threshold", h.Timestamp, time.Now().Unix())
log.Warn("Got block from the future, but within threshold", h.Timestamp, build.Clock.Now().Unix())
}
if h.Timestamp < baseTs.MinTimestamp()+(build.BlockDelaySecs*uint64(h.Height-baseTs.Height())) {
@@ -725,6 +725,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
}
winnerCheck := async.Err(func() error {
if h.ElectionProof.WinCount < 1 {
return xerrors.Errorf("block is not claiming to be a winner")
}
rBeacon := *prevBeacon
if len(h.BeaconEntries) != 0 {
rBeacon = h.BeaconEntries[len(h.BeaconEntries)-1]
@@ -734,7 +738,6 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
return xerrors.Errorf("failed to marshal miner address to cbor: %w", err)
}
//TODO: DST from spec actors when it is there
vrfBase, err := store.DrawRandomness(rBeacon.Data, crypto.DomainSeparationTag_ElectionProofProduction, h.Height, buf.Bytes())
if err != nil {
return xerrors.Errorf("could not draw randomness: %w", err)
@@ -758,8 +761,9 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
return xerrors.Errorf("failed getting power: %w", err)
}
if !types.IsTicketWinner(h.ElectionProof.VRFProof, mpow.QualityAdjPower, tpow.QualityAdjPower) {
return xerrors.Errorf("miner created a block but was not a winner")
j := h.ElectionProof.ComputeWinCount(mpow.QualityAdjPower, tpow.QualityAdjPower)
if h.ElectionProof.WinCount != j {
return xerrors.Errorf("miner claims wrong number of wins: miner: %d, computed: %d", h.ElectionProof.WinCount, j)
}
return nil
@@ -859,13 +863,13 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
func (syncer *Syncer) VerifyWinningPoStProof(ctx context.Context, h *types.BlockHeader, prevBeacon types.BeaconEntry, lbst cid.Cid, waddr address.Address) error {
if build.InsecurePoStValidation {
if len(h.WinPoStProof) == 0 {
return xerrors.Errorf("[TESTING] No winning post proof given")
return xerrors.Errorf("[INSECURE-POST-VALIDATION] No winning post proof given")
}
if string(h.WinPoStProof[0].ProofBytes) == "valid proof" {
return nil
}
return xerrors.Errorf("[TESTING] winning post was invalid")
return xerrors.Errorf("[INSECURE-POST-VALIDATION] winning post was invalid")
}
buf := new(bytes.Buffer)
@@ -946,15 +950,24 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock
return xerrors.Errorf("failed to load base state tree: %w", err)
}
pl := vm.PricelistByEpoch(baseTs.Height())
var sumGasLimit int64
checkMsg := func(msg types.ChainMsg) error {
m := msg.VMMessage()
// Phase 1: syntactic validation, as defined in the spec
minGas := vm.PricelistByEpoch(baseTs.Height()).OnChainMessage(msg.ChainLength())
minGas := pl.OnChainMessage(msg.ChainLength())
if err := m.ValidForBlockInclusion(minGas.Total()); err != nil {
return err
}
// ValidForBlockInclusion checks if any single message does not exceed BlockGasLimit
// So below is overflow safe
sumGasLimit += m.GasLimit
if sumGasLimit > build.BlockGasLimit {
return xerrors.Errorf("block gas limit exceeded")
}
// Phase 2: (Partial) semantic validation:
// the sender exists and is an account actor, and the nonces make sense
if _, ok := nonces[m.From]; !ok {
@@ -1531,6 +1544,6 @@ func (syncer *Syncer) IsEpochBeyondCurrMax(epoch abi.ChainEpoch) bool {
return false
}
now := uint64(time.Now().Unix())
now := uint64(build.Clock.Now().Unix())
return epoch > (abi.ChainEpoch((now-g.Timestamp)/build.BlockDelaySecs) + MaxHeightDrift)
}
+4 -3
View File
@@ -8,6 +8,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
)
@@ -48,7 +49,7 @@ func (ss *SyncerState) SetStage(v api.SyncStateStage) {
defer ss.lk.Unlock()
ss.Stage = v
if v == api.StageSyncComplete {
ss.End = time.Now()
ss.End = build.Clock.Now()
}
}
@@ -64,7 +65,7 @@ func (ss *SyncerState) Init(base, target *types.TipSet) {
ss.Stage = api.StageHeaders
ss.Height = 0
ss.Message = ""
ss.Start = time.Now()
ss.Start = build.Clock.Now()
ss.End = time.Time{}
}
@@ -87,7 +88,7 @@ func (ss *SyncerState) Error(err error) {
defer ss.lk.Unlock()
ss.Message = err.Error()
ss.Stage = api.StageSyncErrored
ss.End = time.Now()
ss.End = build.Clock.Now()
}
func (ss *SyncerState) Snapshot() SyncerState {
+1 -1
View File
@@ -82,7 +82,7 @@ func TestSizeStrUnitsSymmetry(t *testing.T) {
s := rand.NewSource(time.Now().UnixNano())
r := rand.New(s)
for i := 0; i < 1000000; i++ {
for i := 0; i < 10000; i++ {
n := r.Uint64()
l := strings.ReplaceAll(units.BytesSize(float64(n)), " ", "")
r := strings.ReplaceAll(SizeStr(NewInt(n)), " ", "")
-4
View File
@@ -23,10 +23,6 @@ type Ticket struct {
VRFProof []byte
}
type ElectionProof struct {
VRFProof []byte
}
type BeaconEntry struct {
Round uint64
Data []byte
+3 -4
View File
@@ -4,11 +4,11 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/stretchr/testify/require"
"reflect"
"testing"
cid "github.com/ipfs/go-cid"
"github.com/stretchr/testify/require"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
@@ -86,7 +86,7 @@ func TestInteropBH(t *testing.T) {
bh := &BlockHeader{
Miner: newAddr,
Ticket: &Ticket{[]byte{0x01, 0x02, 0x03}},
ElectionProof: &ElectionProof{[]byte{0x0a, 0x0b}},
ElectionProof: &ElectionProof{0, []byte{0x0a, 0x0b}},
BeaconEntries: []BeaconEntry{
{
Round: 5,
@@ -116,8 +116,7 @@ func TestInteropBH(t *testing.T) {
t.Fatal(err)
}
// acquired from go-filecoin
gfc := "8f5501d04cb15021bf6bd003073d79e2238d4e61f1ad22814301020381420a0b818205410c818200410781d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc430003e802d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc410001f603"
gfc := "8f5501d04cb15021bf6bd003073d79e2238d4e61f1ad2281430102038200420a0b818205410c818200410781d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc430003e802d82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619ccd82a5827000171a0e402202f84fef0d7cc2d7f9f00d22445f7bf7539fdd685fd9f284aa37f3822b57619cc410001f603"
require.Equal(t, gfc, hex.EncodeToString(bhsb))
}
+61 -3
View File
@@ -9,7 +9,7 @@ import (
"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"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
@@ -146,6 +146,8 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error {
}
func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error {
*t = BlockHeader{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -470,6 +472,8 @@ func (t *Ticket) MarshalCBOR(w io.Writer) error {
}
func (t *Ticket) UnmarshalCBOR(r io.Reader) error {
*t = Ticket{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -505,7 +509,7 @@ func (t *Ticket) UnmarshalCBOR(r io.Reader) error {
return nil
}
var lengthBufElectionProof = []byte{129}
var lengthBufElectionProof = []byte{130}
func (t *ElectionProof) MarshalCBOR(w io.Writer) error {
if t == nil {
@@ -518,6 +522,17 @@ func (t *ElectionProof) MarshalCBOR(w io.Writer) error {
scratch := make([]byte, 9)
// t.WinCount (int64) (int64)
if t.WinCount >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WinCount)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.WinCount-1)); err != nil {
return err
}
}
// t.VRFProof ([]uint8) (slice)
if len(t.VRFProof) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.VRFProof was too long")
@@ -534,6 +549,8 @@ func (t *ElectionProof) MarshalCBOR(w io.Writer) error {
}
func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error {
*t = ElectionProof{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -545,10 +562,35 @@ func (t *ElectionProof) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input should be of type array")
}
if extra != 1 {
if extra != 2 {
return fmt.Errorf("cbor input had wrong number of fields")
}
// t.WinCount (int64) (int64)
{
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.WinCount = int64(extraI)
}
// t.VRFProof ([]uint8) (slice)
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
@@ -652,6 +694,8 @@ func (t *Message) MarshalCBOR(w io.Writer) error {
}
func (t *Message) UnmarshalCBOR(r io.Reader) error {
*t = Message{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -825,6 +869,8 @@ func (t *SignedMessage) MarshalCBOR(w io.Writer) error {
}
func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error {
*t = SignedMessage{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -890,6 +936,8 @@ func (t *MsgMeta) MarshalCBOR(w io.Writer) error {
}
func (t *MsgMeta) UnmarshalCBOR(r io.Reader) error {
*t = MsgMeta{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -971,6 +1019,8 @@ func (t *Actor) MarshalCBOR(w io.Writer) error {
}
func (t *Actor) UnmarshalCBOR(r io.Reader) error {
*t = Actor{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -1087,6 +1137,8 @@ func (t *MessageReceipt) MarshalCBOR(w io.Writer) error {
}
func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error {
*t = MessageReceipt{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -1221,6 +1273,8 @@ func (t *BlockMsg) MarshalCBOR(w io.Writer) error {
}
func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error {
*t = BlockMsg{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -1371,6 +1425,8 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error {
}
func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error {
*t = ExpTipSet{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
@@ -1506,6 +1562,8 @@ func (t *BeaconEntry) MarshalCBOR(w io.Writer) error {
}
func (t *BeaconEntry) UnmarshalCBOR(r io.Reader) error {
*t = BeaconEntry{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
+205
View File
@@ -0,0 +1,205 @@
package types
import (
"math/big"
"github.com/filecoin-project/lotus/build"
"github.com/minio/blake2b-simd"
)
type ElectionProof struct {
WinCount int64
VRFProof []byte
}
const precision = 256
var (
expNumCoef []*big.Int
expDenoCoef []*big.Int
)
func init() {
parse := func(coefs []string) []*big.Int {
out := make([]*big.Int, len(coefs))
for i, coef := range coefs {
c, ok := new(big.Int).SetString(coef, 10)
if !ok {
panic("could not parse exp paramemter")
}
// << 256 (Q.0 to Q.256), >> 128 to transform integer params to coefficients
c = c.Lsh(c, precision-128)
out[i] = c
}
return out
}
// parameters are in integer format,
// coefficients are *2^-128 of that
num := []string{
"-648770010757830093818553637600",
"67469480939593786226847644286976",
"-3197587544499098424029388939001856",
"89244641121992890118377641805348864",
"-1579656163641440567800982336819953664",
"17685496037279256458459817590917169152",
"-115682590513835356866803355398940131328",
"340282366920938463463374607431768211456",
}
expNumCoef = parse(num)
deno := []string{
"1225524182432722209606361",
"114095592300906098243859450",
"5665570424063336070530214243",
"194450132448609991765137938448",
"5068267641632683791026134915072",
"104716890604972796896895427629056",
"1748338658439454459487681798864896",
"23704654329841312470660182937960448",
"259380097567996910282699886670381056",
"2250336698853390384720606936038375424",
"14978272436876548034486263159246028800",
"72144088983913131323343765784380833792",
"224599776407103106596571252037123047424",
"340282366920938463463374607431768211456",
}
expDenoCoef = parse(deno)
}
// expneg accepts x in Q.256 format and computes e^-x.
// It is most precise within [0, 1.725) range, where error is less than 3.4e-30.
// Over the [0, 5) range its error is less than 4.6e-15.
// Output is in Q.256 format.
func expneg(x *big.Int) *big.Int {
// exp is approximated by rational function
// polynomials of the rational function are evaluated using Horner's method
num := polyval(expNumCoef, x) // Q.256
deno := polyval(expDenoCoef, x) // Q.256
num = num.Lsh(num, precision) // Q.512
return num.Div(num, deno) // Q.512 / Q.256 => Q.256
}
// polyval evaluates a polynomial given by coefficients `p` in Q.256 format
// at point `x` in Q.256 format. Output is in Q.256.
// Coefficients should be ordered from the highest order coefficient to the lowest.
func polyval(p []*big.Int, x *big.Int) *big.Int {
// evaluation using Horner's method
res := new(big.Int).Set(p[0]) // Q.256
tmp := new(big.Int) // big.Int.Mul doesn't like when input is reused as output
for _, c := range p[1:] {
tmp = tmp.Mul(res, x) // Q.256 * Q.256 => Q.512
res = res.Rsh(tmp, precision) // Q.512 >> 256 => Q.256
res = res.Add(res, c)
}
return res
}
// computes lambda in Q.256
func lambda(power, totalPower *big.Int) *big.Int {
lam := new(big.Int).Mul(power, blocksPerEpoch.Int) // Q.0
lam = lam.Lsh(lam, precision) // Q.256
lam = lam.Div(lam /* Q.256 */, totalPower /* Q.0 */) // Q.256
return lam
}
var MaxWinCount = 3 * int64(build.BlocksPerEpoch)
type poiss struct {
lam *big.Int
pmf *big.Int
icdf *big.Int
tmp *big.Int // temporary variable for optimization
k uint64
}
// newPoiss starts poisson inverted CDF
// lambda is in Q.256 format
// returns (instance, `1-poisscdf(0, lambda)`)
// CDF value returend is reused when calling `next`
func newPoiss(lambda *big.Int) (*poiss, *big.Int) {
// pmf(k) = (lambda^k)*(e^lambda) / k!
// k = 0 here, so it simplifies to just e^-lambda
elam := expneg(lambda) // Q.256
pmf := new(big.Int).Set(elam)
// icdf(k) = 1 - ∑ᵏᵢ₌₀ pmf(i)
// icdf(0) = 1 - pmf(0)
icdf := big.NewInt(1)
icdf = icdf.Lsh(icdf, precision) // Q.256
icdf = icdf.Sub(icdf, pmf) // Q.256
k := uint64(0)
p := &poiss{
lam: lambda,
pmf: pmf,
tmp: elam,
icdf: icdf,
k: k,
}
return p, icdf
}
// next computes `k++, 1-poisscdf(k, lam)`
// return is in Q.256 format
func (p *poiss) next() *big.Int {
// incrementally compute next pmf and icdf
// pmf(k) = (lambda^k)*(e^lambda) / k!
// so pmf(k) = pmf(k-1) * lambda / k
p.k++
p.tmp.SetUint64(p.k) // Q.0
// calculate pmf for k
p.pmf = p.pmf.Div(p.pmf, p.tmp) // Q.256 / Q.0 => Q.256
// we are using `tmp` as target for multiplication as using an input as output
// for Int.Mul causes allocations
p.tmp = p.tmp.Mul(p.pmf, p.lam) // Q.256 * Q.256 => Q.512
p.pmf = p.pmf.Rsh(p.tmp, precision) // Q.512 >> 256 => Q.256
// calculate output
// icdf(k) = icdf(k-1) - pmf(k)
p.icdf = p.icdf.Sub(p.icdf, p.pmf) // Q.256
return p.icdf
}
// ComputeWinCount uses VRFProof to compute number of wins
// The algorithm is based on Algorand's Sortition with Binomial distribution
// replaced by Poisson distribution.
func (ep *ElectionProof) ComputeWinCount(power BigInt, totalPower BigInt) int64 {
h := blake2b.Sum256(ep.VRFProof)
lhs := BigFromBytes(h[:]).Int // 256bits, assume Q.256 so [0, 1)
// We are calculating upside-down CDF of Poisson distribution with
// rate λ=power*E/totalPower
// Steps:
// 1. calculate λ=power*E/totalPower
// 2. calculate elam = exp(-λ)
// 3. Check how many times we win:
// j = 0
// pmf = elam
// rhs = 1 - pmf
// for h(vrf) < rhs: j++; pmf = pmf * lam / j; rhs = rhs - pmf
lam := lambda(power.Int, totalPower.Int) // Q.256
p, rhs := newPoiss(lam)
var j int64
for lhs.Cmp(rhs) < 0 && j < MaxWinCount {
rhs = p.next()
j++
}
return j
}
+145
View File
@@ -0,0 +1,145 @@
package types
import (
"bytes"
"fmt"
"math/big"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/xorcare/golden"
)
func TestPoissonFunction(t *testing.T) {
tests := []struct {
lambdaBase uint64
lambdaShift uint
}{
{10, 10}, // 0.0097
{209714, 20}, // 0.19999885
{1036915, 20}, // 0.9888792038
{1706, 10}, // 1.6660
{2, 0}, // 2
{5242879, 20}, //4.9999990
{5, 0}, // 5
}
for _, test := range tests {
test := test
t.Run(fmt.Sprintf("lam-%d-%d", test.lambdaBase, test.lambdaShift), func(t *testing.T) {
b := &bytes.Buffer{}
b.WriteString("icdf\n")
lam := new(big.Int).SetUint64(test.lambdaBase)
lam = lam.Lsh(lam, precision-test.lambdaShift)
p, icdf := newPoiss(lam)
b.WriteString(icdf.String())
b.WriteRune('\n')
for i := 0; i < 15; i++ {
b.WriteString(p.next().String())
b.WriteRune('\n')
}
golden.Assert(t, []byte(b.String()))
})
}
}
func TestLambdaFunction(t *testing.T) {
tests := []struct {
power string
totalPower string
target float64
}{
{"10", "100", .1 * 5.},
{"1024", "2048", 0.5 * 5.},
{"2000000000000000", "100000000000000000", 0.02 * 5.},
}
for _, test := range tests {
test := test
t.Run(fmt.Sprintf("%s-%s", test.power, test.totalPower), func(t *testing.T) {
pow, ok := new(big.Int).SetString(test.power, 10)
assert.True(t, ok)
total, ok := new(big.Int).SetString(test.totalPower, 10)
assert.True(t, ok)
lam := lambda(pow, total)
assert.Equal(t, test.target, q256ToF(lam))
golden.Assert(t, []byte(lam.String()))
})
}
}
func TestExpFunction(t *testing.T) {
const N = 256
step := big.NewInt(5)
step = step.Lsh(step, 256) // Q.256
step = step.Div(step, big.NewInt(N-1))
x := big.NewInt(0)
b := &bytes.Buffer{}
b.WriteString("x, y\n")
for i := 0; i < N; i++ {
y := expneg(x)
fmt.Fprintf(b, "%s,%s\n", x, y)
x = x.Add(x, step)
}
golden.Assert(t, b.Bytes())
}
func q256ToF(x *big.Int) float64 {
deno := big.NewInt(1)
deno = deno.Lsh(deno, 256)
rat := new(big.Rat).SetFrac(x, deno)
f, _ := rat.Float64()
return f
}
func TestElectionLam(t *testing.T) {
p := big.NewInt(64)
tot := big.NewInt(128)
lam := lambda(p, tot)
target := 64. * 5. / 128.
if q256ToF(lam) != target {
t.Fatalf("wrong lambda: %f, should be: %f", q256ToF(lam), target)
}
}
var Res int64
func BenchmarkWinCounts(b *testing.B) {
totalPower := NewInt(100)
power := NewInt(100)
ep := &ElectionProof{VRFProof: nil}
var res int64
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
ep.VRFProof = []byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24), byte(i >> 32)}
j := ep.ComputeWinCount(power, totalPower)
res += j
}
Res += res
}
func TestWinCounts(t *testing.T) {
t.SkipNow()
totalPower := NewInt(100)
power := NewInt(30)
f, _ := os.Create("output.wins")
fmt.Fprintf(f, "wins\n")
ep := &ElectionProof{VRFProof: nil}
for i := uint64(0); i < 1000000; i++ {
i := i + 1000000
ep.VRFProof = []byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24), byte(i >> 32)}
j := ep.ComputeWinCount(power, totalPower)
fmt.Fprintf(f, "%d\n", j)
}
}
+257
View File
@@ -0,0 +1,257 @@
x, y
0,115792089237316195423570985008687907853269984665640564039457584007913129639936
2270433122300317557324921274680155055946470287561579687048187921723786855685,113543770489016942962237377411819033281128847358465443152965692667674515268459
4540866244600635114649842549360310111892940575123159374096375843447573711370,111339107030360092669625707586928312989271150877369072427721155459215537208890
6811299366900952671974763824040465167839410862684739061144563765171360567055,109177251212712547631698034978205369781807498766451007885527881500477232021682
9081732489201270229299685098720620223785881150246318748192751686895147422740,107057371846115774238270822835274977319670170085938012474442950429894883628816
11352165611501587786624606373400775279732351437807898435240939608618934278425,104978653879710027736182386389791146063108246474333192437116903221506365793784
13622598733801905343949527648080930335678821725369478122289127530342721134110,102940298088363735750708779071187005425195044826988440514290336074628648838684
15893031856102222901274448922761085391625292012931057809337315452066507989795,100941520765387555093691898043462296359944447036680097792913901290457279892923
18163464978402540458599370197441240447571762300492637496385503373790294845480,98981553421214956610998073555828635758296463224923810238433739306701915887016
20433898100702858015924291472121395503518232588054217183433691295514081701165,97059642487933486831615191223039105587754475193940197594806835165639555904556
22704331223003175573249212746801550559464702875615796870481879217237868556850,95175049029553104647921939291264669504212075519331704270982994731418832879574
24974764345303493130574134021481705615411173163177376557530067138961655412535,93327048457900197046298852001610623840008858609979636336358094295509875743050
27245197467603810687899055296161860671357643450738956244578255060685442268220,91514930254028040867379060937212497464993417057199803702713818093495592131219
29515630589904128245223976570842015727304113738300535931626442982409229123905,89737997695036598537471612414728492361735134837457880776578397164411259714034
31786063712204445802548897845522170783250584025862115618674630904133015979590,87995567586196615492499061341239298336716207707733388009305962491415997438251
34056496834504763359873819120202325839197054313423695305722818825856802835275,86286969998275026412807199079440137158468693464163642116594809068619896392941
36326929956805080917198740394882480895143524600985274992771006747580589690960,84611548009960677185535234025783667242734659094160158991843756961639811974930
38597363079105398474523661669562635951089994888546854679819194669304376546645,82968657455291330479761642121918798999912566007436555574905312488221049770642
40867796201405716031848582944242791007036465176108434366867382591028163402330,81357666675984845712317087407692885985045766475399018683682465654293317561467
43138229323706033589173504218922946062982935463670014053915570512751950258015,79777956278579309738294730369672998880873563557913118175337099978291132200541
45408662446006351146498425493603101118929405751231593740963758434475737113700,78228918896288743544848199105491032646200262796326433813989850094529077282776
47679095568306668703823346768283256174875876038793173428011946356199523969385,76709958955482823270730386397827358293917115388940737122493792142598409249118
49949528690606986261148268042963411230822346326354753115060134277923310825070,75220492446700831714270851931718222334181221472926734650894450187207587804959
52219961812907303818473189317643566286768816613916332802108322199647097680755,73759946700111799812659669164881767734266809389910877226542646506513000978489
54490394935207621375798110592323721342715286901477912489156510121370884536440,72327760165334507045772504425420867449416167380982855532448913178137554210923
56760828057507938933123031867003876398661757189039492176204698043094671392125,70923382195532685995592428750934431740132395987623204573329785474158712116147
59031261179808256490447953141684031454608227476601071863252885964818458247810,69546272835702420022053453330708655397369524375477499739230911030535808540657
61301694302108574047772874416364186510554697764162651550301073886542245103495,68195902615070334829829990481057773300819373544625447529491837404705895284329
63572127424408891605097795691044341566501168051724231237349261808266031959180,66871752343522765217935231891690355471651496064655471661919663456330328641288
65842560546709209162422716965724496622447638339285810924397449729989818814865,65573312911987628132646843093927406319425698793733957333572673848799954239855
68112993669009526719747638240404651678394108626847390611445637651713605670550,64300085096692252880128256597394188085029084300287019159255155536716536636582
70383426791309844277072559515084806734340578914408970298493825573437392526235,63051579367221909582465988028351521656270181701866074076641181901174457665557
72653859913610161834397480789764961790287049201970549985542013495161179381920,61827315698305238252660159775306665170268657207834096298284442133031571582783
74924293035910479391722402064445116846233519489532129672590201416884966237605,60626823385254213782224025259478780989246898268785251219150451819890211607196
77194726158210796949047323339125271902179989777093709359638389338608753093290,59449640862987687230396859494036983576366375788559345059199710577555290424321
79465159280511114506372244613805426958126460064655289046686577260332539948975,58295315528568921616783939661658889268848452171972763039788768615558483626267
81735592402811432063697165888485582014072930352216868733734765182056326804660,57163403567188891479248718554448273836403260979137552976694337187145017476501
84006025525111749621022087163165737070019400639778448420782953103780113660345,56053469781528440285551018178364674618486430618035927413379628478874266581878
86276458647412067178347008437845892125965870927340028107831141025503900516030,54965087424433688889920273781092319643978134551542030239286748341146003208614
88546891769712384735671929712526047181912341214901607794879328947227687371715,53897838034840362103953324191045652555242797708181047223345801682385818568835
90817324892012702292996850987206202237858811502463187481927516868951474227400,52851311276883949594712447365930530107052884187291818795931120263968492084774
93087758014313019850321772261886357293805281790024767168975704790675261083085,51825104782133842211941756402475821837684219892038783449941692633646927028868
95358191136613337407646693536566512349751752077586346856023892712399047938770,50818823994890785951863832476942579771969130641977742986737254850253840075592
97628624258913654964971614811246667405698222365147926543072080634122834794455,49832082020488173548864433257316990617151231489408392527154422207621203727615
99899057381213972522296536085926822461644692652709506230120268555846621650140,48864499476538848601355411822273410550321020146722594189563317351144555102308
102169490503514290079621457360606977517591162940271085917168456477570408505825,47915704347070229628266128780655102907390977725210624641985610920484495320871
104439923625814607636946378635287132573537633227832665604216644399294195361510,46985331839491671953371264029121450743887309752499067780940162596021543960818
106710356748114925194271299909967287629484103515394245291264832321017982217195,46073024244339074252983177578294403714924665379395655719184742489399140111119
108980789870415242751596221184647442685430573802955824978313020242741769072880,45178430797742804397094652011443390009353450908460410593202993111115176300509
111251222992715560308921142459327597741377044090517404665361208164465555928565,44301207546566066275398443059622984529245531090835413454138285364317904357889
113521656115015877866246063734007752797323514378078984352409396086189342784250,43441017216161856030307536334277824451020867870703344545581645152489753618625
115792089237316195423570985008687907853269984665640564039457584007913129639935,42597529080697662913911602080197270017224605406643086589378214572018159359656
118062522359616512980895906283368062909216454953202143726505771929636916495620,41770418835998057231823154500906296232954940017107200954896529163626836852806
120332955481916830538220827558048217965162925240763723413553959851360703351305,40959368474856275913667539524102962047053738936489506227266772182693729839202
122603388604217148095545748832728373021109395528325303100602147773084490206990,40164066164766865529760099118055626254866338159841829407810028308443332329921
124873821726517465652870670107408528077055865815886882787650335694808277062675,39384206128032373421270623986368325593061645265273820139765067969067422649415
127144254848817783210195591382088683133002336103448462474698523616532063918360,38619488524197990384791697485732970600503064875453399931120765038045198401265
129414687971118100767520512656768838188948806391010042161746711538255850774045,37869619334768943402646797366590078932213917335501796767692394741802326454228
131685121093418418324845433931448993244895276678571621848794899459979637629730,37134310250166314581624891999905972285593140562157169782497980837053288139911
133955554215718735882170355206129148300841746966133201535843087381703424485415,36413278558877823092557676422579316779501436559193491643756131394023796062011
136225987338019053439495276480809303356788217253694781222891275303427211341100,35706247038760950822158313374858241516488865748339595127547394046982094249410
138496420460319370996820197755489458412734687541256360909939463225150998196785,35012943850456619981286410714734531636271581473914516202135729910546566402779
140766853582619688554145119030169613468681157828817940596987651146874785052470,34333102432872442378462629116615524982524168457316936505909372845805604900401
143037286704920006111470040304849768524627628116379520284035839068598571908155,33666461400695355776019567288676251030810566791286359575983902200864972469996
145307719827220323668794961579529923580574098403941099971084026990322358763840,33012764443894243004677309675463059806544657868579375264515822376830510918451
147578152949520641226119882854210078636520568691502679658132214912046145619525,32371760229173894620565861867718452819385944209047587245952825283707541232161
149848586071820958783444804128890233692467038979064259345180402833769932475210,31743202303342426140951325851524709564919796135818066107980273521807047228205
152119019194121276340769725403570388748413509266625839032228590755493719330895,31126848998554996579614932864397941484844825641744252641191173459915093805187
154389452316421593898094646678250543804359979554187418719276778677217506186580,30522463339397396402839881838375473280428264227964104623768547140174704396628
156659885438721911455419567952930698860306449841748998406324966598941293042265,29929812951773780419644078230146692062203486832083285970050129935848796157421
158930318561022229012744489227610853916252920129310578093373154520665079897950,29348669973563514777235550444240282773251884769510008252819331832439494645079
161200751683322546570069410502291008972199390416872157780421342442388866753635,28778810967012787421358795112757003059950944596369120909715112149169964220370
163471184805622864127394331776971164028145860704433737467469530364112653609320,28220016832827298362763401072714572174637391915333615996330037256359689152007
165741617927923181684719253051651319084092330991995317154517718285836440465005,27672072725933000121901983367925347694111025283271589335038719296229849510185
168012051050223499242044174326331474140038801279556896841565906207560227320690,27134767972872500055614403280459447260039099989714465645168626995212978266528
170282484172523816799369095601011629195985271567118476528614094129284014176375,26607895990805365148558542391218752327077936735384764869356894955189244136002
172552917294824134356694016875691784251931741854680056215662282051007801032060,26091254208081186520295830628576992670321075391182679321065607327265313932322
174823350417124451914018938150371939307878212142241635902710469972731587887745,25584643986354865593328765236833491064966760582438881050282097633879965205565
177093783539424769471343859425052094363824682429803215589758657894455374743430,25087870544214176820510595839294024971107825899184642127021233999936247081507
179364216661725087028668780699732249419771152717364795276806845816179161599115,24600742882290243310082706540466488496131563143845631581983311961047083061256
181634649784025404585993701974412404475717623004926374963855033737902948454800,24123073709822131836694888705209306323992339748006300420231840208502026712055
183905082906325722143318623249092559531664093292487954650903221659626735310485,23654679372647332806338881400061315566868133427664662629105489367609937695646
186175516028626039700643544523772714587610563580049534337951409581350522166170,23195379782590438967131080837393236404679360225477050241221440433306491390529
188445949150926357257968465798452869643557033867611114024999597503074309021855,22744998348222874237097258296963376819397584603868543116623643157984253142510
190716382273226674815293387073133024699503504155172693712047785424798095877540,22303361906967051161228844170125488556352938430940411562982254002868044311034
192986815395526992372618308347813179755449974442734273399095973346521882733225,21870300658518852415771961233241780589753603014109439052609181643134330131200
195257248517827309929943229622493334811396444730295853086144161268245669588910,21445648099562838646716735757033316057251336889853858375428467187815522927837
197527681640127627487268150897173489867342915017857432773192349189969456444595,21029240959755081956656390289742251499446416407847034496990361844628688581109
199798114762427945044593072171853644923289385305419012460240537111693243300280,20620919138949011730680161329173099008306763464882403634448661640684501661866
202068547884728262601917993446533799979235855592980592147288725033417030155965,20220525645640137405137620676980023532901299004381393279093890751532452054423
204338981007028580159242914721213955035182325880542171834336912955140817011650,19827906536605981416712487046651644994469849037549721389552871270682788176368
206609414129328897716567835995894110091128796168103751521385100876864603867335,19442910857718015103451661807495877546362994006807802531582187045985408388323
208879847251629215273892757270574265147075266455665331208433288798588390723020,19065390585902840940891643898043637774181614198870274451246241331546097600612
211150280373929532831217678545254420203021736743226910895481476720312177578705,18695200572230306358460705740514292808692490977651168538902708783481421680348
213420713496229850388542599819934575258968207030788490582529664642035964434390,18332198486106667663798285266862799262530724876828607112610697476363307765699
215691146618530167945867521094614730314914677318350070269577852563759751290075,17976244760551347472111336927386090359808454572176186089250363261529225698797
217961579740830485503192442369294885370861147605911649956626040485483538145760,17627202538536245657534631830721579840416279034844169182844082749512022955880
220232012863130803060517363643975040426807617893473229643674228407207325001445,17284937620366972373860132250248373607831381821348510576523341628979456457899
222502445985431120617842284918655195482754088181034809330722416328931111857130,16949318412085772290021286893087219332537721900597190962614965688689436470898
224772879107731438175167206193335350538700558468596389017770604250654898712815,16620215874876302005383259706474512944760516297587146250989332554945114509504
227043312230031755732492127468015505594647028756157968704818792172378685568500,16297503475450807802230954908656139014943597886328184429574709348911081384486
229313745352332073289817048742695660650593499043719548391866980094102472424185,15981057137400628605961920332938849374838761847812884031059653371884698227732
231584178474632390847141970017375815706539969331281128078915168015826259279870,15670755193491319402603874616100339746216923922257041729716527735529769853650
233854611596932708404466891292055970762486439618842707765963355937550046135555,15366478338884053550790009737665512422829259009202431332168817628656130747976
236125044719233025961791812566736125818432909906404287453011543859273832991240,15068109585265318560877642552077774766432262308314225827173090425609387180236
238395477841533343519116733841416280874379380193965867140059731780997619846925,14775534215867269134414164114591717654313758765518045957328319974951247947864
240665910963833661076441655116096435930325850481527446827107919702721406702610,14488639741361443696906809527925407527798326175077538816130520515576676432536
242936344086133978633766576390776590986272320769089026514156107624445193558295,14207315856608886447500721787929418266891341269962575206208292606790558927738
245206777208434296191091497665456746042218791056650606201204295546168980413980,13931454398250046219817842121237250069017319717552215812396900410729316780042
247477210330734613748416418940136901098165261344212185888252483467892767269665,13660949303118146325455249570700165024364040604752663984462703166489664742339
249747643453034931305741340214817056154111731631773765575300671389616554125350,13395696567460036159625482974163434950873419335747629798807509358843043114747
252018076575335248863066261489497211210058201919335345262348859311340340981035,13135594206948845808872493016734991140070074672980170698797842470835657746355
254288509697635566420391182764177366266004672206896924949397047233064127836720,12880542217473069333080972366140272174677497922483630681691757178031836728636
256558942819935883977716104038857521321951142494458504636445235154787914692405,12630442536687000915161971042648362535726831652623366360951945091372138829073
258829375942236201535041025313537676377897612782020084323493423076511701548090,12385199006307740796619289137869014505391917569864233277491827537392271272526
261099809064536519092365946588217831433844083069581664010541610998235488403775,12144717335144274958225939593470301902208893969091913127900701796820969916276
263370242186836836649690867862897986489790553357143243697589798919959275259460,11908905062844413972629474569782724684547574705479145661987238841262047512889
265640675309137154207015789137578141545737023644704823384637986841683062115145,11677671524345652458077781103683012746985203951843087585351200546458450234583
267911108431437471764340710412258296601683493932266403071686174763406848970830,11450927815016281205730420816822769656276856651451425159655410140798486590368
270181541553737789321665631686938451657629964219827982758734362685130635826515,11228586756473349441251594323339849390046255944661352162796836657552528120100
272451974676038106878990552961618606713576434507389562445782550606854422682200,11010562863064334916605775798811477728189133603960442457397758272811779333449
274722407798338424436315474236298761769522904794951142132830738528578209537885,10796772308999634710251182117797466377054234368136632046647040836884880709149
276992840920638741993640395510978916825469375082512721819878926450301996393570,10587132896123239841361951569073852197393979276538146129343090522801499481360
279263274042939059550965316785659071881415845370074301506927114372025783249255,10381564022309202172514611506897394878877748812065679452742065418299049556809
281533707165239377108290238060339226937362315657635881193975302293749570104940,10179986650471742679787468858482358928499942961441493648347660820939932354037
283804140287539694665615159335019381993308785945197460881023490215473356960625,9982323278177086101950544601003257424140532557067992549916807460469069141662
286074573409840012222940080609699537049255256232759040568071678137197143816310,9788497907845338332079968817743865213174453409259845129758908478094549262272
288345006532140329780265001884379692105201726520320620255119866058920930671995,9598436017530949774464402361919053565881937627109257874972510208401009770963
290615439654440647337589923159059847161148196807882199942168053980644717527680,9412064532270530344304969563638312480198627803597895883581869229790285361030
292885872776740964894914844433740002217094667095443779629216241902368504383365,9229311795986999922973693773512111376663242782368889508055395732551288322377
295156305899041282452239765708420157273041137383005359316264429824092291239050,9050107543939271981357133004643947981886610395815063538792001543567721697353
297426739021341600009564686983100312328987607670566939003312617745816078094735,8874382875706877830311960657026508969290082662731915199950324279800475201683
299697172143641917566889608257780467384934077958128518690360805667539864950420,8702070228699144631140925089885492819072907992531772224458410703022324971560
301967605265942235124214529532460622440880548245690098377408993589263651806105,8533103352178741979338410836757093105256375792397040329065630149508413086135
304238038388242552681539450807140777496827018533251678064457181510987438661790,8367417281789609639196736794874998402544481231388500060346139012236641543825
306508471510542870238864372081820932552773488820813257751505369432711225517475,8204948314579472931243763439936896182045474760835882712220942160049717189792
308778904632843187796189293356501087608719959108374837438553557354435012373160,8045633984507342433459354572450622071501444572221358150888492135726910593613
311049337755143505353514214631181242664666429395936417125601745276158799228845,7889413038426581123905040544325858121069927256074308557819634343914244175953
313319770877443822910839135905861397720612899683497996812649933197882586084530,7736225412534304938490539495998345262722685569683811485718517851478118074806
315590203999744140468164057180541552776559369971059576499698121119606372940215,7586012209278062013393244296606783131019725342345569324815264018948034488407
317860637122044458025488978455221707832505840258621156186746309041330159795900,7438715674710911696077991529315597910182131547815478256768516102178053147428
320131070244344775582813899729901862888452310546182735873794496963053946651585,7294279176286196809531497726711149751773109079006438039328871808860505208647
322401503366645093140138821004582017944398780833744315560842684884777733507270,7152647181083471707513356405012353952405611456310792512957976292047901188617
324671936488945410697463742279262173000345251121305895247890872806501520362955,7013765234457214429330978163948031181884804665874684563234080173204818792192
326942369611245728254788663553942328056291721408867474934939060728225307218640,6877579939100113814604817973991912882261222190269087624747098477473070920910
329212802733546045812113584828622483112238191696429054621987248649949094074325,6744038934512881834200618407209402738374726406854013386327229734819886355209
331483235855846363369438506103302638168184661983990634309035436571672880930010,6613090876872697694251640706911864470257281520044099539344107417605448847522
333753668978146680926763427377982793224131132271552213996083624493396667785695,6484685419292543536070441670407899002441885350144223913319492393155843996609
336024102100446998484088348652662948280077602559113793683131812415120454641380,6358773192463841844684321602472961808036370534710746466420213566001948927453
338294535222747316041413269927343103336024072846675373370180000336844241497065,6235305785674952050504565665502249112334426989789636398933745643420892537805
340564968345047633598738191202023258391970543134236953057228188258568028352750,6114235728198228318918503273647009044057809740115762935228605445446011541536
342835401467347951156063112476703413447917013421798532744276376180291815208435,5995516471038482226936505302234614253048545365172641788639745380038847011850
345105834589648268713388033751383568503863483709360112431324564102015602064120,5879102369035832978915788636227029754149990028304128445154065521569679896299
347376267711948586270712955026063723559809953996921692118372752023739388919805,5764948663316064068243885471976803898564123312018636117461200936317441104963
349646700834248903828037876300743878615756424284483271805420939945463175775490,5653011464081738901084106683312765416762298565331902697873676865978153014007
351917133956549221385362797575424033671702894572044851492469127867186962631175,5543247733737458913233334532284737157076797625887278020789776292123991283042
354187567078849538942687718850104188727649364859606431179517315788910749486860,5435615270342776182191625059155814516167449877265043810529451526313401440000
356458000201149856500012640124784343783595835147168010866565503710634536342545,5330072691386398513087911834712869898427723411257226595273064182550426763859
358728433323450174057337561399464498839542305434729590553613691632358323198230,5226579417875448507582021006206716342354483979921442218144570774799799153756
360998866445750491614662482674144653895488775722291170240661879554082110053915,5125095658733659256765209168041122238133229257032719961413509211200048248333
363269299568050809171987403948824808951435246009852749927710067475805896909600,5025582395502508078982293698284693835284469532255851267477746214208169030829
365539732690351126729312325223504964007381716297414329614758255397529683765285,4928001367339406197066635979466804208185522234029567523625554767402211661565
367810165812651444286637246498185119063328186584975909301806443319253470620970,4832315056307176461496499130904489365080602372384889128573871476885084197963
370080598934951761843962167772865274119274656872537488988854631240977257476655,4738486672949163220359850565587517062963871431792713253071282139856533845449
372351032057252079401287089047545429175221127160099068675902819162701044332340,4646480142144428256814095536419820031461458638508982355406532908762559366752
374621465179552396958612010322225584231167597447660648362951007084424831188025,4556260089237594402171008726677813775125098076724227743627974892272588327070
376891898301852714515936931596905739287114067735222228049999195006148618043710,4467791826438004029228927006814200361630588836617618519025510750743109199997
379162331424153032073261852871585894343060538022783807737047382927872404899395,4381041339482963176613798998129770586400722046177381492207741626501677387270
381432764546453349630586774146266049399007008310345387424095570849596191755080,4295975274559943590489358236239541053798654812625189402565013609912762502063
383703197668753667187911695420946204454953478597906967111143758771319978610765,4212560925482714534092886286689429135772883215331118745250144375204860994258
385973630791053984745236616695626359510899948885468546798191946693043765466450,4130766221116473846427146968171682243610648632762217464220432443306744076356
388244063913354302302561537970306514566846419173030126485240134614767552322135,4050559713047143466628204822445172093558799258185730849489440714923595198306
390514497035654619859886459244986669622792889460591706172288322536491339177820,3971910563490088516841239430057423861561699540314803552309386818215754652836
392784930157954937417211380519666824678739359748153285859336510458215126033505,3894788533433611089965680791375046317061917745510095607652825551910399528715
395055363280255254974536301794346979734685830035714865546384698379938912889190,3819163971012660154769745087149569914465567827492977553371176365210754983049
397325796402555572531861223069027134790632300323276445233432886301662699744875,3745007800108287504328254434609249402710340257581916107575424870725436120735
399596229524855890089186144343707289846578770610838024920481074223386486600560,3672291509168466468538116483953888412415082359790291319830667248103068617726
401866662647156207646511065618387444902525240898399604607529262145110273456245,3600987140245975220983870041875004895679551495743211205866825798183240723922
404137095769456525203835986893067599958471711185961184294577450066834060311930,3531067278249129967384164433549615728055232151532910541204821495878913836970
406407528891756842761160908167747755014418181473522763981625637988557847167615,3462505040401235139336450269559039606157745830970264242579700439549733102016
408677962014057160318485829442427910070364651761084343668673825910281634023300,3395274065904697964555996096535291493010779102468849709076001181212499029926
410948395136357477875810750717108065126311122048645923355722013832005420878985,3329348505805833474130146144622500207015802447060544079287034222519730000801
413218828258657795433135671991788220182257592336207503042770201753729207734670,3264703013056463168733957305768762048671220120100675556528510459350361442934
415489261380958112990460593266468375238204062623769082729818389675452994590355,3201312732768486228946010278262122858837369338972372870253840600423809756146
417759694503258430547785514541148530294150532911330662416866577597176781446040,3139153292657676348854251985374092135837494969951169782173776159644176534423
420030127625558748105110435815828685350097003198892242103914765518900568301725,3078200793673030025577310098607138197203259951148621910059374341071023253667
422300560747859065662435357090508840406043473486453821790962953440624355157410,3018431800808063478119054352864365216599069977484266467250325895140520117178
424570993870159383219760278365188995461989943774015401478011141362348142013095,2959823334090525324552359078463176696893036195521598690559604864862321028159
426841426992459700777085199639869150517936414061576981165059329284071928868780,2902352859747060743788555836574429934024784962979281619588506007014730754443
429111860114760018334410120914549305573882884349138560852107517205795715724465,2845998281539430113506217335511024116647561786738955796723957128032460028562
431382293237060335891735042189229460629829354636700140539155705127519502580150,2790737932268951075048841664512779579965827455433050874470612581492493796612
433652726359360653449059963463909615685775824924261720226203893049243289435835,2736550565445897654615705160581380392035754504074875922703396122219838983601
435923159481660971006384884738589770741722295211823299913252080970967076291520,2683415347120653492731207292836793547250299699949146040965909097366506826314
438193592603961288563709806013269925797668765499384879600300268892690863147205,2631311847873478425170175781779819578108906286445566029098739049466961949804
440464025726261606121034727287950080853615235786946459287348456814414650002890,2580220034959808642151093783793953402129918191024990104539947286476194870361
442734458848561923678359648562630235909561706074508038974396644736138436858575,2530120264608070452133030819123365918858694576649021314235932359705643943273
445004891970862241235684569837310390965508176362069618661444832657862223714260,2480993274467046314956915988152178555256121842686531405628524104350927660746
447275325093162558793009491111990546021454646649631198348493020579586010569945,2432820176199889308902969867700028980919093407680036321083074765251991144298
449545758215462876350334412386670701077401116937192778035541208501309797425630,2385582448221938579601135652712703469128873722647430092259396421200608174744
451816191337763193907659333661350856133347587224754357722589396423033584281315,2339261928579543607308487238103279986560541266662742536344201858542715699027
454086624460063511464984254936031011189294057512315937409637584344757371137000,2293840807967159344114184788286120867801944082584440628149280631165005320951
456357057582363829022309176210711166245240527799877517096685772266481157992685,2249301622880027434993188844156208157845130306302793141117411709623435670173
458627490704664146579634097485391321301186998087439096783733960188204944848370,2205627248899810866744487578412286757829514684708503434368069205255340039839
460897923826964464136959018760071476357133468375000676470782148109928731704055,2162800894110600506761016035372877280458113909309651595222790899580498073682
463168356949264781694283940034751631413079938662562256157830336031652518559740,2120806092642762118940557002260420725877403403643132375546681834433562628493
465438790071565099251608861309431786469026408950123835844878523953376305415425,2079626698342141596131901285086838588831365589656553686857278748333033108659
467709223193865416808933782584111941524972879237685415531926711875100092271110,2039246878562194346216395910444043784690021169116503952080024996424232086889
469979656316165734366258703858792096580919349525246995218974899796823879126795,1999651108076652030782767922491430088269301331012688651267426380085596201366
472250089438466051923583625133472251636865819812808574906023087718547665982480,1960824163110386199534010054524334089541753293394021687030939529972846447262
474520522560766369480908546408152406692812290100370154593071275640271452838165,1922751115486173807887555445320207063113604718628558999245364537712059659787
476790955683066687038233467682832561748758760387931734280119463561995239693850,1885417326885114167166377133451693487795698974827428621915772121522296322640
479061388805367004595558388957512716804705230675493313967167651483719026549535,1848808443218490573462190057395600374688639714455162176619470154537224426642
481331821927667322152883310232192871860651700963054893654215839405442813405220,1812910389108912709483102199711379114048329569523931425832014763952606023142
483602255049967639710208231506873026916598171250616473341264027327166600260905,1777709362478617929951137999560857523114698493464640463314567998578763375930
485872688172267957267533152781553181972544641538178053028312215248890387116590,1743191829242850741544443083382012278950030439838258806090307410195511152367
488143121294568274824858074056233337028491111825739632715360403170614173972275,1709344518106280188825408838548340945706907890570414138312511052040629403114
490413554416868592382182995330913492084437582113301212402408591092337960827960,1676154415460454473592585178001481888630499860343530369736761941087841137938
492683987539168909939507916605593647140384052400862792089456779014061747683645,1643608760380330981872631688029464454202113613160652114812004614315882448607
494954420661469227496832837880273802196330522688424371776504966935785534539330,1611695039717957985264493988118541627646396847164138227584506579980006189593
497224853783769545054157759154953957252276992975985951463553154857509321395015,1580400983291421636207279946257561145576531467125488184028701658324803392105
499495286906069862611482680429634112308223463263547531150601342779233108250700,1549714559167208504327370397252359435900676480118217197526808984667322295656
501765720028370180168807601704314267364169933551109110837649530700956895106385,1519623969034169817411698521182954716530148741935550434876916238707975489825
504036153150670497726132522978994422420116403838670690524697718622680681962070,1490117643667308789561999136522296289524839311469606144758176235295035574077
506306586272970815283457444253674577476062874126232270211745906544404468817755,1461184238479646954250162028027864509672389242493414237027164373310873876617
508577019395271132840782365528354732532009344413793849898794094466128255673440,1432812629160459284595696582392048709701342884089101780789506016757983545698
510847452517571450398107286803034887587955814701355429585842282387852042529125,1404991907398201090242984454401886460001256486743771644647644675643019397120
513117885639871767955432208077715042643902284988917009272890470309575829384810,1377711376686482242495906258989351428318340736703325118283502743772525420186
515388318762172085512757129352395197699848755276478588959938658231299616240495,1350960548211476209390117246928289328516166528957389393408566548846213309144
517658751884472403070082050627075352755795225564040168646986846153023403096180,1324729136819182692425165292411394327407511934209655077877674460464300121300
519929185006772720627406971901755507811741695851601748334035034074747189951865,1299007057060993358777871916475898081725576133192311731321945268374304875079
522199618129073038184731893176435662867688166139163328021083221996470976807550,1273784419316040268779271406014391437821438711132700913654395176336120357812
524470051251373355742056814451115817923634636426724907708131409918194763663235,1249051525988836119835059106151604655038913776255529646900786453845629450261
526740484373673673299381735725795972979581106714286487395179597839918550518920,1224798867780744376154319639656429438292590596449478554800662259883398133550
529010917495973990856706657000476128035527577001848067082227785761642337374605,1201017120033845739753282342628997286268151802300216872136210819143441303664
531281350618274308414031578275156283091474047289409646769275973683366124230290,1177697139145795253133868286972489045105718361046528878527448066379668652133
533551783740574625971356499549836438147420517576971226456324161605089911085975,1154829959054291618502821225483149900650534431243083949245642604820923646588
535822216862874943528681420824516593203366987864532806143372349526813697941660,1132406787789807082890425327211328755183700827007270235992079331829362643852
538092649985175261086006342099196748259313458152094385830420537448537484797345,1110419004095252483338613492946986193747814242216914544087253927761374702549
540363083107475578643331263373876903315259928439655965517468725370261271653030,1088858154111277781547261772857694251337802353360681665028106984738120501199
542633516229775896200656184648557058371206398727217545204516913291985058508715,1067715948125933652889320598100629627595490376276215626206049496855639908739
544903949352076213757981105923237213427152869014779124891565101213708845364400,1046984257387444440232701363407888596891997329416358164537461237895052190493
547174382474376531315306027197917368483099339302340704578613289135432632220085,1026655110978867048053673500561104502292891906760695382551282292885769647385
549444815596676848872630948472597523539045809589902284265661477057156419075770,1006720692753434146222353671415953866113533147281398201361542821926894368710
551715248718977166429955869747277678594992279877463863952709664978880205931455,987173338329403384733958131783829533009147622988398599380784122106977308530
553985681841277483987280791021957833650938750165025443639757852900603992787140,968005532143257199520483988560220733582298517120243540446994347402239110174
556256114963577801544605712296637988706885220452587023326806040822327779642825,949209904560120224102845604039392059367322323910424009332173176480678795959
558526548085878119101930633571318143762831690740148603013854228744051566498510,930779229040283320858879764591061717606873826779909083197312274038703255036
560796981208178436659255554845998298818778161027710182700902416665775353354195,912706419360744817546225148870963828076628869100719699856881194145713586169
563067414330478754216580476120678453874724631315271762387950604587499140209880,894984526890700687724824577161411173596658532863246109848772040565011872478
565337847452779071773905397395358608930671101602833342074998792509222927065565,877606737919936156004596577686776039865420267809390448859339117903023609116
567608280575079389331230318670038763986617571890394921762046980430946713921250,860566371039091548574664590528726362251021703804112434559419129682978794632
569878713697379706888555239944718919042564042177956501449095168352670500776935,843856874570795154071557033366442926236979708804975971538286570121216914411
572149146819680024445880161219399074098510512465518081136143356274394287632620,827471824050675417183296315424741971779066957250062452852260880325027656529
574419579941980342003205082494079229154456982753079660823191544196118074488305,811404919757283964983682303379036253598800697102332643556476037720459831748
576690013064280659560530003768759384210403453040641240510239732117841861343990,795649984289979771219745127738174910086802387263030261900019674061458963150
578960446186580977117854925043439539266349923328202820197287920039565648199675,780200960193843203865524721501305631184795994974723658032277935470179306730
+1
View File
@@ -0,0 +1 @@
57896044618658097711785492504343953926634992332820282019728792003956564819968
@@ -0,0 +1 @@
289480223093290488558927462521719769633174961664101410098643960019782824099840
@@ -0,0 +1 @@
11579208923731619542357098500868790785326998466564056403945758400791312963993
@@ -0,0 +1,17 @@
icdf
1125278653883954157340515998824199281259686237023612910954531537010133365568
5485581780123676224984074899749002236148166431650497590243915223971292577
17842170241691453912141677461647358103546946338181118738604570718548080
43538699106868068808561503680708109912117284430088557923220935824303
85008817354919776986513548953593326094752560579206896166859206326
138328508214407784218646352510285887677303021571444942144212932
192946940473264032619492808002293590266469557064324916486706
235498963868775663540157747991701194152938740691242898919
255504995002156513848360474242833468958493714151012216
249505772801580009049072856702435230216536441494110
232834101038081471620316286291642591265760137159
11533551765583311484083562200606025547302501012
11353456917542541496993529059255898133794641608
11353321629946357024346977051186975261639061786
11353321535577219060847642123725989684858819334
11353321535515780819985988910882590605707269697
@@ -0,0 +1,17 @@
icdf
72718197862321603787957847055188249408647877796280116987586082825356498974798
30123322455004902866096392147720313525979066051167804713805891738863284666878
9062729215708086547397523150443475826195010851218953471088727298493148732956
2120601657722952965249404258310617497861606438105371150448777320082300909521
404370264674629622846679825118378024155401061236248117877372450081489268106
64941157977031699837280219244596630364570458903895153606060064374226923144
8998760514291795062091202215054973561658841304177095664084807386711484044
1095864305518189121413406860322570887693509822868614985675874891701983877
118988091690998292615838041961723734187855286032350465668217096980526413
11653361409102593830837021393444274321721937984503223867724441309766994
1039253147016500070761515827557061937775360855994320103804816785188376
85064880905559492020902336338153555957806293407638915883403930221828
6433469833589351070633969345898155559842007456615136652210720692299
452164666340411064711833496915674079929092772106312520794348036629
29679788379529243880483477334855509673275091060271619731000625321
1827354397264548824373139406487609602015834650190678153972930556
@@ -0,0 +1,17 @@
icdf
93907545465879218275260347624273708225148723352890415890955745471328115138024
57447553596668785643406883388130520172829512611140657354486862128150346836988
27076095525930017054568011324233899656590951319429188573619716140132147265911
10209654292635635800479757502291310268341281539592025246744927385067352842651
3184715634432458451975226003210729824895496226017269232182332263939291493510
843984120585852874524302031056145794325474791455055607017530061469667926785
194034907919461416983404196340045475941285897027461784665454449911533518447
39345544525367691179167072173518251727638261160626536209449847049064587000
7131182470884793691126479665205819536661348710819293305892247868965466268
1167890189531948301087715470416213490892402026859749426392544722128541359
174396377814374645286335419995210764907848995332895729280582459579342738
23925812935985027317838050852967276757134553590636105055350959232313899
3035286920153916620063269622769735189335169019323041991528942663951986
358060554242868329017312833503133182524340437692927389149107908421231
39467628723598770945019147503633808666969235107758896427288845018926
4082242594961149456000070139366495398696105445630156285138889148853
+17
View File
@@ -0,0 +1,17 @@
icdf
100121334043824876020967110392587568107053060743383522309741056272383359786578
68779823656842237215759361160386888614619212898869438850308000801323820079862
37438313269859598410551611928186209122185365054355355390874945330264280373146
16543973011871172540413112440052422793896133158012633084586241682891253902002
6096802882876959605343862695985529629751517209841271931441889859204740666430
1917934831279274431316162798358772364093670830572727470184149129730135372202
524978814080046039973596165816519942207722037483212649764902219905266940794
126991380594552213875719985090162107383165239457636986787974531383875960392
27494522223178757351250939908572648677026039951243071043742609253528215292
5384109251762433679146707645997213408995106727599978656135515446784271938
962026657479168944725861193482126355388920082871360178614096685435483268
158011640336757174831161838479383254733249783829793182701111456099339874
24009137479688546515378612645592737957304733989532016715613917876649310
3393367809370296005258116363471119991774726321799529640921988919312302
448257856467688789526616894596603139556153797837745773108856211121302
55576529414007827429083632080000892593677461309507924067105183362502
@@ -0,0 +1,17 @@
icdf
20989436322611254574979389012727393136091537312055593688180077279147576363096
2029014232696520721523332453453803636238058967796600089005757967894658844577
132982872945592560215194824292206599698851338836977427578620974467337246296
6581505574095040906286115477587166321018484661524779791358182693980706360
261473369241451189291715224208035992983406808190620756138506410631265448
8673527587881831627652027122245179992541421812500366598395022980519170
246914417172755020716947338861248744263385116558896234139925344965714
6155418508705151241339695503211918565434455355693098789916851059631
136477982954924943101944815709613669983383501630000081908122878386
2724514397229876659600187515561464490237868059330199615762951760
49460332945698577716770256622916953121860884014393828193908634
823264627479642334265449493920662550930201158945634649498769
12651460568281449375957051928671501418597070452648092732548
180560129118157986659345179422379755776654969450793746138
2405427973892505908363489341734991530618943133521671600
30045550760659097055494870911555042207154242485930695
+17
View File
@@ -0,0 +1,17 @@
icdf
115011888277122352219705460287186602222085188670665840381425306072442950421456
111110883476153136200377836679680074066161208695792222091263916395092054329056
101358371473730096152058777660913753676351258758608176365860442201714814098056
85104184803025029404860345962969886360001342196634766823521318546086080379726
64786451464643695970862306340540052214563946494168004895597413976550163231816
44468718126262362536864266718110218069126550791701242967673509407014246083906
27537273677611251341865900366085356281262054372978941361070255599067648460651
15443384785717600488295638686067597861358842645320154499210788593391507301186
7884704228284068704814225136056498848919335315533412710548621714843919076521
3685437251932106602880106497161443842008497910096333939069640115650814507266
1585803763756125551913047177713916338553079207377794553330149316054262222641
631424905494315983291656577965040200618797978869367559812198952601283911451
233767047885228663032743828069675143146180800324189645846386301162542948456
80821718035579693702392770417611659502866500883736602013381435224565655001
26198385946419347512981678399017558201682822512146229215879697389573764486
7990608583365898783177981059486191101288263054949438283379118111243134316
@@ -0,0 +1,17 @@
icdf
115011887533064380050215202002871794783671664388541274939039184893270600703151
111110879755863630144777547269452207577572562543679248972859798819416242535921
101358362173007217989878395557465593373392010546833825352856759707561945139525
85104169301821710755220628061805234978705652326202881500299286939503312327242
64786432088141395502693562453332343133008530920262028792733819517798429528997
44468698749761909885846743680008378684637277300179598543979674797636862943384
27537257530529080605729671834720742022613060678716434560927439906969908575619
15443373252088578337713549627194971124753642243467082552611819728291522561946
7884697019766617162458477655388623015603913245952633503615157778326861227793
3685433247200570820185174890022164698361097802621279879954268046011715772231
1585801761390548420193995297013958176769177427873274589439743405082427147382
631423995328231141553650878972791975288890578033071631113620389859816342901
233766668649395912353875000216328335294367462954196928187468994385755448892
80821572175657684536655650469711580587115741420816601432036447172153463116
26198333853594769407667441209847842642730676168975225661522405972966431948
7990591219092428810606628986022697269060757693982546042792694706871429282
+1 -1
View File
@@ -19,7 +19,7 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) {
Method: 1235126,
Value: types.NewInt(123123),
GasPrice: types.NewInt(1234),
GasLimit: 9992969384,
GasLimit: 100_000_000,
Nonce: 123123,
},
}
+3 -2
View File
@@ -2,6 +2,7 @@ package validation
import (
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/abi"
@@ -72,8 +73,8 @@ func (a *Applier) ApplyTipSetMessages(epoch abi.ChainEpoch, blocks []vtypes.Bloc
var bms []stmgr.BlockMessages
for _, b := range blocks {
bm := stmgr.BlockMessages{
Miner: b.Miner,
TicketCount: 1,
Miner: b.Miner,
WinCount: 1,
}
for _, m := range b.BLSMessages {
+33 -28
View File
@@ -65,7 +65,7 @@ type Pricelist interface {
OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge
// OnIpldGet returns the gas used for storing an object
OnIpldGet(dataSize int) GasCharge
OnIpldGet() GasCharge
// OnIpldPut returns the gas used for storing an object
OnIpldPut(dataSize int) GasCharge
@@ -84,30 +84,35 @@ type Pricelist interface {
var prices = map[abi.ChainEpoch]Pricelist{
abi.ChainEpoch(0): &pricelistV0{
onChainMessageBase: 0,
onChainMessagePerByte: 2,
onChainReturnValuePerByte: 8,
sendBase: 5,
sendTransferFunds: 5,
sendInvokeMethod: 10,
ipldGetBase: 10,
ipldGetPerByte: 1,
ipldPutBase: 20,
ipldPutPerByte: 2,
createActorBase: 40, // IPLD put + 20
createActorExtra: 500,
deleteActor: -500, // -createActorExtra
// Dragons: this cost is not persistable, create a LinearCost{a,b} struct that has a `.Cost(x) -> ax + b`
verifySignature: map[crypto.SigType]func(int64) int64{
crypto.SigTypeBLS: func(x int64) int64 { return 3*x + 2 },
crypto.SigTypeSecp256k1: func(x int64) int64 { return 3*x + 2 },
onChainMessageComputeBase: 137137,
onChainMessageStorageBase: 0, // TODO gas
onChainMessageStoragePerByte: 2, // TODO gas
onChainReturnValuePerByte: 8, // TODO gas
sendBase: 97236,
sendTransferFunds: 96812,
sendTransferOnlyPremium: 347806,
sendInvokeMethod: -3110,
ipldGetBase: 417230,
ipldPutBase: 396100,
ipldPutPerByte: 2, // TODO gas
createActorCompute: 750011,
createActorStorage: 500, // TODO gas
deleteActor: -500, // -createActorStorage
verifySignature: map[crypto.SigType]int64{
crypto.SigTypeBLS: 219946580,
crypto.SigTypeSecp256k1: 6726720,
},
hashingBase: 5,
hashingPerByte: 2,
computeUnsealedSectorCidBase: 100,
verifySealBase: 2000,
verifyPostBase: 700,
verifyConsensusFault: 10,
hashingBase: 110685,
computeUnsealedSectorCidBase: 431890,
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
verifyPostBase: 2621447835,
verifyConsensusFault: 495422,
},
}
@@ -198,14 +203,14 @@ func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte
}
func (ps pricedSyscalls) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) {
var gasChargeSum GasCharge
gasChargeSum.Name = "BatchVerifySeals"
count := int64(0)
for _, svis := range inp {
count += int64(len(svis))
}
gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(129778623*count+716683250, 0)
ps.chargeGas(gasChargeSum) // TODO: this is only called by the cron actor. Should we even charge gas?
gasChargeSum := newGasCharge("BatchVerifySeals", 0, 0)
gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(15075005*count+899741502, 0)
ps.chargeGas(gasChargeSum) // real gas charged by actors
defer ps.chargeGas(gasOnActorExec)
return ps.under.BatchVerifySeals(inp)
+34 -46
View File
@@ -20,8 +20,9 @@ type pricelistV0 struct {
// Together, these account for the cost of message propagation and validation,
// up to but excluding any actual processing by the VM.
// This is the cost a block producer burns when including an invalid message.
onChainMessageBase int64
onChainMessagePerByte int64
onChainMessageComputeBase int64
onChainMessageStorageBase int64
onChainMessageStoragePerByte int64
// Gas cost charged to the originator of a non-nil return value produced
// by an on-chain message is given by:
@@ -41,15 +42,17 @@ type pricelistV0 struct {
// already accounted for).
sendTransferFunds int64
// Gsa cost charged, in addition to SendBase, if message only transfers funds.
sendTransferOnlyPremium int64
// Gas cost charged, in addition to SendBase, if a message invokes
// a method on the receiver.
// Accounts for the cost of loading receiver code and method dispatch.
sendInvokeMethod int64
// Gas cost (Base + len*PerByte) for any Get operation to the IPLD store
// Gas cost for any Get operation to the IPLD store
// in the runtime VM context.
ipldGetBase int64
ipldGetPerByte int64
ipldGetBase int64
// Gas cost (Base + len*PerByte) for any Put operation to the IPLD store
// in the runtime VM context.
@@ -64,18 +67,17 @@ type pricelistV0 struct {
//
// Note: this costs assume that the extra will be partially or totally refunded while
// the base is covering for the put.
createActorBase int64
createActorExtra int64
createActorCompute int64
createActorStorage int64
// Gas cost for deleting an actor.
//
// Note: this partially refunds the create cost to incentivise the deletion of the actors.
deleteActor int64
verifySignature map[crypto.SigType]func(len int64) int64
verifySignature map[crypto.SigType]int64
hashingBase int64
hashingPerByte int64
hashingBase int64
computeUnsealedSectorCidBase int64
verifySealBase int64
@@ -87,57 +89,51 @@ var _ Pricelist = (*pricelistV0)(nil)
// OnChainMessage returns the gas used for storing a message of a given size in the chain.
func (pl *pricelistV0) OnChainMessage(msgSize int) GasCharge {
return newGasCharge("OnChainMessage", 0, pl.onChainMessageBase+pl.onChainMessagePerByte*int64(msgSize)).WithVirtual(77302, 0)
return newGasCharge("OnChainMessage", pl.onChainMessageComputeBase,
pl.onChainMessageStorageBase+pl.onChainMessageStoragePerByte*int64(msgSize))
}
// OnChainReturnValue returns the gas used for storing the response of a message in the chain.
func (pl *pricelistV0) OnChainReturnValue(dataSize int) GasCharge {
return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte).WithVirtual(107294, 0)
return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte)
}
// OnMethodInvocation returns the gas used when invoking a method.
func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge {
ret := pl.sendBase
extra := ""
virtGas := int64(1072944)
if value != abi.NewTokenAmount(0) {
// TODO: fix this, it is comparing pointers instead of values
// see vv
ret += pl.sendTransferFunds
}
if big.Cmp(value, abi.NewTokenAmount(0)) != 0 {
virtGas += 497495
ret += pl.sendTransferFunds
if methodNum == builtin.MethodSend {
// transfer only
virtGas += 973940
ret += pl.sendTransferOnlyPremium
}
extra += "t"
}
if methodNum != builtin.MethodSend {
ret += pl.sendInvokeMethod
extra += "i"
// running actors is cheaper becase we hand over to actors
virtGas += -295779
ret += pl.sendInvokeMethod
}
return newGasCharge("OnMethodInvocation", ret, 0).WithVirtual(virtGas, 0).WithExtra(extra)
return newGasCharge("OnMethodInvocation", ret, 0).WithExtra(extra)
}
// OnIpldGet returns the gas used for storing an object
func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
return newGasCharge("OnIpldGet", pl.ipldGetBase+int64(dataSize)*pl.ipldGetPerByte, 0).
WithExtra(dataSize).WithVirtual(433685, 0)
func (pl *pricelistV0) OnIpldGet() GasCharge {
return newGasCharge("OnIpldGet", pl.ipldGetBase, 0)
}
// OnIpldPut returns the gas used for storing an object
func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge {
return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte).
WithExtra(dataSize).WithVirtual(88970, 0)
WithExtra(dataSize)
}
// OnCreateActor returns the gas used for creating an actor
func (pl *pricelistV0) OnCreateActor() GasCharge {
return newGasCharge("OnCreateActor", pl.createActorBase, pl.createActorExtra).WithVirtual(65636, 0)
return newGasCharge("OnCreateActor", pl.createActorCompute, pl.createActorStorage)
}
// OnDeleteActor returns the gas used for deleting an actor
@@ -148,50 +144,42 @@ func (pl *pricelistV0) OnDeleteActor() GasCharge {
// OnVerifySignature
func (pl *pricelistV0) OnVerifySignature(sigType crypto.SigType, planTextSize int) (GasCharge, error) {
costFn, ok := pl.verifySignature[sigType]
cost, ok := pl.verifySignature[sigType]
if !ok {
return GasCharge{}, fmt.Errorf("cost function for signature type %d not supported", sigType)
}
sigName, _ := sigType.Name()
virtGas := int64(0)
switch sigType {
case crypto.SigTypeBLS:
virtGas = 220138570
case crypto.SigTypeSecp256k1:
virtGas = 7053730
}
return newGasCharge("OnVerifySignature", costFn(int64(planTextSize)), 0).
sigName, _ := sigType.Name()
return newGasCharge("OnVerifySignature", cost, 0).
WithExtra(map[string]interface{}{
"type": sigName,
"size": planTextSize,
}).WithVirtual(virtGas, 0), nil
}), nil
}
// OnHashing
func (pl *pricelistV0) OnHashing(dataSize int) GasCharge {
return newGasCharge("OnHashing", pl.hashingBase+int64(dataSize)*pl.hashingPerByte, 0).WithExtra(dataSize).WithVirtual(77300, 0)
return newGasCharge("OnHashing", pl.hashingBase, 0).WithExtra(dataSize)
}
// OnComputeUnsealedSectorCid
func (pl *pricelistV0) OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge {
// TODO: this needs more cost tunning, check with @lotus
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0).WithVirtual(382370, 0)
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0)
}
// OnVerifySeal
func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge {
// TODO: this needs more cost tunning, check with @lotus
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0).WithVirtual(199954003, 0)
// this is not used
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0)
}
// OnVerifyPost
func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge {
// TODO: this needs more cost tunning, check with @lotus
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithVirtual(2629471704, 0).WithExtra(len(info.ChallengedSectors))
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithExtra(len(info.ChallengedSectors))
}
// OnVerifyConsensusFault
func (pl *pricelistV0) OnVerifyConsensusFault() GasCharge {
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0).WithVirtual(551935, 0)
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0)
}
+4 -4
View File
@@ -30,6 +30,10 @@ var EmptyObjectCid cid.Cid
// TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses.
func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aerrors.ActorError) {
if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil {
return nil, err
}
addrID, err := rt.state.RegisterNewAddress(addr)
if err != nil {
return nil, aerrors.Escalate(err, "registering actor address")
@@ -50,10 +54,6 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer
}
// call constructor on account
if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil {
return nil, err
}
_, aerr = rt.internalSend(builtin.SystemActorAddr, addrID, builtin.MethodsAccount.Constructor, big.Zero(), p)
if aerr != nil {
return nil, aerrors.Wrap(aerr, "failed to invoke account constructor")
+18 -5
View File
@@ -366,15 +366,14 @@ func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMars
panic(err)
}
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
return nil, err.RetCode()
return &dumbWrapperType{nil}, err.RetCode()
}
_ = rt.chargeGasSafe(gasOnActorExec)
return &dumbWrapperType{ret}, 0
}
func (rt *Runtime) internalSend(from, to address.Address, method abi.MethodNum, value types.BigInt, params []byte) ([]byte, aerrors.ActorError) {
start := time.Now()
start := build.Clock.Now()
ctx, span := trace.StartSpan(rt.ctx, "vmc.Send")
defer span.End()
if span.IsRecordingEvents() {
@@ -528,7 +527,7 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError
var callers [10]uintptr
cout := gruntime.Callers(2+skip, callers[:])
now := time.Now()
now := build.Clock.Now()
if rt.lastGasCharge != nil {
rt.lastGasCharge.TimeTaken = now.Sub(rt.lastGasChargeTime)
}
@@ -551,7 +550,8 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError
rt.lastGasChargeTime = now
rt.lastGasCharge = &gasTrace
if rt.gasUsed+toUse > rt.gasAvailable {
// overflow safe
if rt.gasUsed > rt.gasAvailable-toUse {
rt.gasUsed = rt.gasAvailable
return aerrors.Newf(exitcode.SysErrOutOfGas, "not enough gas: used=%d, available=%d",
rt.gasUsed, rt.gasAvailable)
@@ -578,3 +578,16 @@ func (rt *Runtime) abortIfAlreadyValidated() {
}
rt.callerValidated = true
}
func (rt *Runtime) Log(level vmr.LogLevel, msg string, args ...interface{}) {
switch level {
case vmr.DEBUG:
actorLog.Debugf(msg, args)
case vmr.INFO:
actorLog.Infof(msg, args)
case vmr.WARN:
actorLog.Warnf(msg, args)
case vmr.ERROR:
actorLog.Errorf(msg, args)
}
}
+8 -2
View File
@@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/adtutil"
"github.com/filecoin-project/lotus/lib/sigs"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
@@ -145,7 +146,7 @@ func (ss *syscallShim) VerifyConsensusFault(a, b, extra []byte) (*runtime.Consen
// (3) return if no consensus fault by now
if consensusFault == nil {
return consensusFault, nil
return nil, xerrors.Errorf("no consensus fault detected")
}
// else
@@ -179,8 +180,13 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
return err
}
info, err := mas.GetInfo(adtutil.NewStore(ss.ctx, ss.cst))
if err != nil {
return err
}
// and use to get resolved workerKey
waddr, err := ResolveToKeyAddr(ss.cstate, ss.cst, mas.Info.Worker)
waddr, err := ResolveToKeyAddr(ss.cstate, ss.cst, info.Worker)
if err != nil {
return err
}
+52 -29
View File
@@ -20,7 +20,6 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
@@ -28,6 +27,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/types"
@@ -35,6 +35,7 @@ import (
)
var log = logging.Logger("vm")
var actorLog = logging.Logger("actors")
var gasOnActorExec = newGasCharge("OnActorExec", 0, 0)
// ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`.
@@ -69,12 +70,12 @@ type gasChargingBlocks struct {
}
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0))
bs.chargeGas(bs.pricelist.OnIpldGet())
blk, err := bs.under.Get(c)
if err != nil {
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
}
bs.chargeGas(bs.pricelist.OnIpldGet(len(blk.RawData())))
bs.chargeGas(newGasCharge("OnIpldGetEnd", 0, 0).WithExtra(len(blk.RawData())))
bs.chargeGas(gasOnActorExec)
return blk, nil
@@ -130,6 +131,14 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
return rt
}
type UnsafeVM struct {
VM *VM
}
func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, nac uint64) *Runtime {
return vm.VM.makeRuntime(ctx, msg, origin, originNonce, usedGas, nac)
}
type VM struct {
cstate *state.StateTree
base cid.Cid
@@ -201,7 +210,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
parent.lastGasCharge = rt.lastGasCharge
}()
}
if gasCharge != nil {
if err := rt.chargeGasSafe(*gasCharge); err != nil {
// this should never happen
@@ -210,10 +218,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
}
ret, err := func() ([]byte, aerrors.ActorError) {
if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil {
return nil, aerrors.Wrap(aerr, "not enough gas for method invocation")
}
_ = rt.chargeGasSafe(newGasCharge("OnGetActor", 0, 0))
toActor, err := st.GetActor(msg.To)
if err != nil {
if xerrors.Is(err, init_.ErrAddressNotFound) {
@@ -227,6 +232,11 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
}
}
if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil {
return nil, aerrors.Wrap(aerr, "not enough gas for method invocation")
}
defer rt.chargeGasSafe(newGasCharge("OnMethodInvocationDone", 0, 0))
if types.BigCmp(msg.Value, types.NewInt(0)) != 0 {
if err := vm.transfer(msg.From, msg.To, msg.Value); err != nil {
return nil, aerrors.Wrap(err, "failed to transfer funds")
@@ -237,7 +247,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
var ret []byte
_ = rt.chargeGasSafe(gasOnActorExec)
ret, err := vm.Invoke(toActor, rt, msg.Method, msg.Params)
_ = rt.chargeGasSafe(newGasCharge("OnActorExecDone", 0, 0))
return ret, err
}
return nil, nil
@@ -277,7 +286,7 @@ func checkMessage(msg *types.Message) error {
}
func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
start := time.Now()
start := build.Clock.Now()
ret, actorErr, rt := vm.send(ctx, msg, nil, nil, start)
rt.finilizeGasTracing()
return &ApplyRet{
@@ -294,7 +303,7 @@ func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*Ap
}
func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) {
start := time.Now()
start := build.Clock.Now()
ctx, span := trace.StartSpan(ctx, "vm.ApplyMessage")
defer span.End()
msg := cmsg.VMMessage()
@@ -431,6 +440,9 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
return nil, xerrors.Errorf("revert state failed: %w", err)
}
}
rt.finilizeGasTracing()
gasUsed = rt.gasUsed
if gasUsed < 0 {
gasUsed = 0
@@ -450,8 +462,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
return nil, xerrors.Errorf("gas handling math is wrong")
}
rt.finilizeGasTracing()
return &ApplyRet{
MessageReceipt: types.MessageReceipt{
ExitCode: errcode,
@@ -524,12 +534,16 @@ func (vm *VM) MutateState(ctx context.Context, addr address.Address, fn interfac
return nil
}
func linksForObj(blk block.Block) ([]cid.Cid, error) {
func linksForObj(blk block.Block, cb func(cid.Cid)) error {
switch blk.Cid().Prefix().Codec {
case cid.DagCBOR:
return cbg.ScanForLinks(bytes.NewReader(blk.RawData()))
err := cbg.ScanForLinks(bytes.NewReader(blk.RawData()), cb)
if err != nil {
return xerrors.Errorf("cbg.ScanForLinks: %w", err)
}
return nil
default:
return nil, xerrors.Errorf("vm flush copy method only supports dag cbor")
return xerrors.Errorf("vm flush copy method only supports dag cbor")
}
}
@@ -547,7 +561,7 @@ func Copy(from, to blockstore.Blockstore, root cid.Cid) error {
}
if err := copyRec(from, to, root, batchCp); err != nil {
return err
return xerrors.Errorf("copyRec: %w", err)
}
if len(batch) > 0 {
@@ -570,31 +584,40 @@ func copyRec(from, to blockstore.Blockstore, root cid.Cid, cp func(block.Block)
return xerrors.Errorf("get %s failed: %w", root, err)
}
links, err := linksForObj(blk)
if err != nil {
return err
}
var lerr error
err = linksForObj(blk, func(link cid.Cid) {
if lerr != nil {
// Theres no erorr return on linksForObj callback :(
return
}
for _, link := range links {
if link.Prefix().MhType == mh.IDENTITY || link.Prefix().MhType == uint64(commcid.FC_SEALED_V1) || link.Prefix().MhType == uint64(commcid.FC_UNSEALED_V1) {
continue
if link.Prefix().MhType == mh.IDENTITY || link.Prefix().Codec == cid.FilCommitmentSealed || link.Prefix().Codec == cid.FilCommitmentUnsealed {
return
}
has, err := to.Has(link)
if err != nil {
return err
lerr = xerrors.Errorf("has: %w", err)
return
}
if has {
continue
return
}
if err := copyRec(from, to, link, cp); err != nil {
return err
lerr = err
return
}
})
if err != nil {
return xerrors.Errorf("linksForObj (%x): %w", blk.RawData(), err)
}
if lerr != nil {
return lerr
}
if err := cp(blk); err != nil {
return err
return xerrors.Errorf("copy: %w", err)
}
return nil
}
@@ -675,7 +698,7 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt) aerrors.Actor
}
if err := deductFunds(f, amt); err != nil {
return aerrors.Newf(exitcode.SysErrInsufficientFunds, "transfer failed when deducting funds: %s", err)
return aerrors.Newf(exitcode.SysErrInsufficientFunds, "transfer failed when deducting funds (%s): %s", types.FIL(amt), err)
}
depositFunds(t, amt)
+4
View File
@@ -2,6 +2,7 @@ package cli
import (
"fmt"
"os"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
@@ -126,6 +127,9 @@ var authApiInfoToken = &cli.Command{
}
envVar := envForRepo(t)
if _, ok := os.LookupEnv(envForRepo(t)); !ok {
envVar = envForRepoDeprecation(t)
}
// TODO: Log in audit log when it is implemented
+1 -1
View File
@@ -935,7 +935,7 @@ var slashConsensusFault = &cli.Command{
From: def,
Value: types.NewInt(0),
GasPrice: types.NewInt(1),
GasLimit: 10000000,
GasLimit: 100_000_000,
Method: builtin.MethodsMiner.ReportConsensusFault,
Params: enc,
}
+150 -5
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"strconv"
"text/tabwriter"
@@ -55,6 +56,7 @@ var clientCmd = &cli.Command{
Usage: "Make deals, store data, retrieve data",
Subcommands: []*cli.Command{
clientImportCmd,
clientDropCmd,
clientCommPCmd,
clientLocalCmd,
clientDealCmd,
@@ -75,6 +77,11 @@ var clientImportCmd = &cli.Command{
Name: "car",
Usage: "import from a car file instead of a regular file",
},
&cli.BoolFlag{
Name: "quiet",
Aliases: []string{"q"},
Usage: "Output root CID only",
},
&CidBaseFlag,
},
Action: func(cctx *cli.Context) error {
@@ -108,7 +115,46 @@ var clientImportCmd = &cli.Command{
return err
}
fmt.Println(encoder.Encode(c))
if !cctx.Bool("quiet") {
fmt.Printf("Import %d, Root ", c.ImportID)
}
fmt.Println(encoder.Encode(c.Root))
return nil
},
}
var clientDropCmd = &cli.Command{
Name: "drop",
Usage: "Remove import",
ArgsUsage: "[import ID...]",
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
return xerrors.Errorf("no imports specified")
}
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)
var ids []int
for i, s := range cctx.Args().Slice() {
id, err := strconv.ParseInt(s, 10, 0)
if err != nil {
return xerrors.Errorf("parsing %d-th import ID: %w", i, err)
}
ids = append(ids, int(id))
}
for _, id := range ids {
if err := api.ClientRemoveImport(ctx, id); err != nil {
return xerrors.Errorf("removing import %d: %w", id, err)
}
}
return nil
},
@@ -208,8 +254,20 @@ var clientLocalCmd = &cli.Command{
return err
}
sort.Slice(list, func(i, j int) bool {
return list[i].Key < list[j].Key
})
for _, v := range list {
fmt.Printf("%s %s %s %s\n", encoder.Encode(v.Key), v.FilePath, types.SizeStr(types.NewInt(v.Size)), v.Status)
cidStr := "<nil>"
if v.Root != nil {
cidStr = encoder.Encode(*v.Root)
}
fmt.Printf("%d: %s @%s (%s)\n", v.Key, cidStr, v.FilePath, v.Source)
if v.Err != "" {
fmt.Printf("\terror: %s\n", v.Err)
}
}
return nil
},
@@ -237,6 +295,16 @@ var clientDealCmd = &cli.Command{
Usage: "specify the epoch that the deal should start at",
Value: -1,
},
&cli.BoolFlag{
Name: "fast-retrieval",
Usage: "indicates that data should be available for fast retrieval",
Value: true,
},
&cli.BoolFlag{
Name: "verified-deal",
Usage: "indicate that the deal counts towards verified client total",
Value: false,
},
&CidBaseFlag,
},
Action: func(cctx *cli.Context) error {
@@ -311,6 +379,27 @@ var clientDealCmd = &cli.Command{
ref.TransferType = storagemarket.TTManual
}
// Check if the address is a verified client
dcap, err := api.StateVerifiedClientStatus(ctx, a, types.EmptyTSK)
if err != nil {
return err
}
isVerified := dcap != nil
// If the user has explicitly set the --verified-deal flag
if cctx.IsSet("verified-deal") {
// If --verified-deal is true, but the address is not a verified
// client, return an error
verifiedDealParam := cctx.Bool("verified-deal")
if verifiedDealParam && !isVerified {
return xerrors.Errorf("address %s does not have verified client status", a)
}
// Override the default
isVerified = verifiedDealParam
}
proposal, err := api.ClientStartDeal(ctx, &lapi.StartDealParams{
Data: ref,
Wallet: a,
@@ -318,6 +407,8 @@ var clientDealCmd = &cli.Command{
EpochPrice: types.BigInt(price),
MinBlocksDuration: uint64(dur),
DealStartEpoch: abi.ChainEpoch(cctx.Int64("start-epoch")),
FastRetrieval: cctx.Bool("fast-retrieval"),
VerifiedDeal: isVerified,
})
if err != nil {
return err
@@ -338,6 +429,12 @@ var clientFindCmd = &cli.Command{
Name: "find",
Usage: "find data in the network",
ArgsUsage: "[dataCid]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "pieceCid",
Usage: "require data to be retrieved from a specific Piece CID",
},
},
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
fmt.Println("Usage: find [CID]")
@@ -367,7 +464,16 @@ var clientFindCmd = &cli.Command{
fmt.Println("LOCAL")
}
offers, err := api.ClientFindData(ctx, file)
var pieceCid *cid.Cid
if cctx.String("pieceCid") != "" {
parsed, err := cid.Parse(cctx.String("pieceCid"))
if err != nil {
return err
}
pieceCid = &parsed
}
offers, err := api.ClientFindData(ctx, file, pieceCid)
if err != nil {
return err
}
@@ -384,6 +490,8 @@ var clientFindCmd = &cli.Command{
},
}
const DefaultMaxRetrievePrice = 1
var clientRetrieveCmd = &cli.Command{
Name: "retrieve",
Usage: "retrieve data from network",
@@ -401,6 +509,14 @@ var clientRetrieveCmd = &cli.Command{
Name: "miner",
Usage: "miner address for retrieval, if not present it'll use local discovery",
},
&cli.StringFlag{
Name: "maxPrice",
Usage: fmt.Sprintf("maximum price the client is willing to consider (default: %d FIL)", DefaultMaxRetrievePrice),
},
&cli.StringFlag{
Name: "pieceCid",
Usage: "require data to be retrieved from a specific Piece CID",
},
},
Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 {
@@ -442,10 +558,24 @@ var clientRetrieveCmd = &cli.Command{
return nil
}*/ // TODO: fix
var pieceCid *cid.Cid
if cctx.String("pieceCid") != "" {
parsed, err := cid.Parse(cctx.String("pieceCid"))
if err != nil {
return err
}
pieceCid = &parsed
}
var offer api.QueryOffer
minerStrAddr := cctx.String("miner")
if minerStrAddr == "" { // Local discovery
offers, err := fapi.ClientFindData(ctx, file)
offers, err := fapi.ClientFindData(ctx, file, pieceCid)
// sort by price low to high
sort.Slice(offers, func(i, j int) bool {
return offers[i].MinPrice.LessThan(offers[j].MinPrice)
})
if err != nil {
return err
}
@@ -461,7 +591,7 @@ var clientRetrieveCmd = &cli.Command{
if err != nil {
return err
}
offer, err = fapi.ClientMinerQueryOffer(ctx, file, minerAddr)
offer, err = fapi.ClientMinerQueryOffer(ctx, minerAddr, file, pieceCid)
if err != nil {
return err
}
@@ -470,6 +600,21 @@ var clientRetrieveCmd = &cli.Command{
return fmt.Errorf("The received offer errored: %s", offer.Err)
}
maxPrice := types.FromFil(DefaultMaxRetrievePrice)
if cctx.String("maxPrice") != "" {
maxPriceFil, err := types.ParseFIL(cctx.String("maxPrice"))
if err != nil {
return xerrors.Errorf("parsing maxPrice: %w", err)
}
maxPrice = types.BigInt(maxPriceFil)
}
if offer.MinPrice.GreaterThan(maxPrice) {
return xerrors.Errorf("failed to find offer satisfying maxPrice: %s", maxPrice)
}
ref := &lapi.FileRef{
Path: cctx.Args().Get(1),
IsCAR: cctx.Bool("car"),
+26 -4
View File
@@ -72,13 +72,25 @@ func flagForRepo(t repo.RepoType) string {
case repo.FullNode:
return "repo"
case repo.StorageMiner:
return "storagerepo"
return "miner-repo"
default:
panic(fmt.Sprintf("Unknown repo type: %v", t))
}
}
func envForRepo(t repo.RepoType) string {
switch t {
case repo.FullNode:
return "FULLNODE_API_INFO"
case repo.StorageMiner:
return "MINER_API_INFO"
default:
panic(fmt.Sprintf("Unknown repo type: %v", t))
}
}
// TODO remove after deprecation period
func envForRepoDeprecation(t repo.RepoType) string {
switch t {
case repo.FullNode:
return "FULLNODE_API_INFO"
@@ -90,14 +102,24 @@ func envForRepo(t repo.RepoType) string {
}
func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) {
if env, ok := os.LookupEnv(envForRepo(t)); ok {
envKey := envForRepo(t)
env, ok := os.LookupEnv(envKey)
if !ok {
// TODO remove after deprecation period
envKey = envForRepoDeprecation(t)
env, ok = os.LookupEnv(envKey)
if ok {
log.Warnf("Use deprecation env(%s) value, please use env(%s) instead.", envKey, envForRepo(t))
}
}
if ok {
sp := strings.SplitN(env, ":", 2)
if len(sp) != 2 {
log.Warnf("invalid env(%s) value, missing token or address", envForRepo(t))
log.Warnf("invalid env(%s) value, missing token or address", envKey)
} else {
ma, err := multiaddr.NewMultiaddr(sp[1])
if err != nil {
return APIInfo{}, xerrors.Errorf("could not parse multiaddr from env(%s): %w", envForRepo(t), err)
return APIInfo{}, xerrors.Errorf("could not parse multiaddr from env(%s): %w", envKey, err)
}
return APIInfo{
Addr: ma,
+12 -4
View File
@@ -6,12 +6,13 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"github.com/filecoin-project/specs-actors/actors/abi"
"os"
"sort"
"strconv"
"text/tabwriter"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/go-address"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
@@ -113,9 +114,9 @@ var msigCreateCmd = &cli.Command{
intVal := types.BigInt(filval)
required := cctx.Int64("required")
required := cctx.Uint64("required")
if required == 0 {
required = int64(len(addrs))
required = uint64(len(addrs))
}
d := abi.ChainEpoch(cctx.Uint64("duration"))
@@ -184,12 +185,19 @@ var msigInspectCmd = &cli.Command{
return err
}
head, err := api.ChainHead(ctx)
if err != nil {
return err
}
var mstate samsig.State
if err := mstate.UnmarshalCBOR(bytes.NewReader(obj)); err != nil {
return err
}
fmt.Printf("Balance: %sfil\n", types.FIL(act.Balance))
locked := mstate.AmountLocked(head.Height() - mstate.StartEpoch)
fmt.Printf("Balance: %s\n", types.FIL(act.Balance))
fmt.Printf("Spendable: %s\n", types.FIL(types.BigSub(act.Balance, locked)))
fmt.Printf("Threshold: %d / %d\n", mstate.NumApprovalsThreshold, len(mstate.Signers))
fmt.Println("Signers:")
for _, s := range mstate.Signers {
+1 -1
View File
@@ -77,7 +77,7 @@ var sendCmd = &cli.Command{
From: fromAddr,
To: toAddr,
Value: types.BigInt(val),
GasLimit: 10000,
GasLimit: 100_000_000,
GasPrice: gp,
}
+7 -7
View File
@@ -49,7 +49,7 @@ var stateCmd = &cli.Command{
Subcommands: []*cli.Command{
statePowerCmd,
stateSectorsCmd,
stateProvingSetCmd,
stateActiveSectorsCmd,
statePledgeCollateralCmd,
stateListActorsCmd,
stateListMinersCmd,
@@ -234,16 +234,16 @@ var stateSectorsCmd = &cli.Command{
}
for _, s := range sectors {
fmt.Printf("%d: %x\n", s.Info.Info.SectorNumber, s.Info.Info.SealedCID)
fmt.Printf("%d: %x\n", s.Info.SectorNumber, s.Info.SealedCID)
}
return nil
},
}
var stateProvingSetCmd = &cli.Command{
Name: "proving",
Usage: "Query the proving set of a miner",
var stateActiveSectorsCmd = &cli.Command{
Name: "active-sectors",
Usage: "Query the active sector set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
@@ -268,13 +268,13 @@ var stateProvingSetCmd = &cli.Command{
return err
}
sectors, err := api.StateMinerProvingSet(ctx, maddr, ts.Key())
sectors, err := api.StateMinerActiveSectors(ctx, maddr, ts.Key())
if err != nil {
return err
}
for _, s := range sectors {
fmt.Printf("%d: %x\n", s.Info.Info.SectorNumber, s.Info.Info.SealedCID)
fmt.Printf("%d: %x\n", s.Info.SectorNumber, s.Info.SealedCID)
}
return nil
+1 -1
View File
@@ -195,7 +195,7 @@ func SyncWait(ctx context.Context, napi api.FullNode) error {
case <-ctx.Done():
fmt.Println("\nExit by user")
return nil
case <-time.After(1 * time.Second):
case <-build.Clock.After(1 * time.Second):
}
}
}
+3 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
@@ -68,7 +69,7 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre
sendSet = append(sendSet, naddr)
}
tick := time.NewTicker(time.Second / time.Duration(rate))
tick := build.Clock.Ticker(time.Second / time.Duration(rate))
for {
select {
case <-tick.C:
@@ -76,7 +77,7 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre
From: from,
To: sendSet[rand.Intn(20)],
Value: types.NewInt(1),
GasLimit: 100000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(0),
}
+9 -6
View File
@@ -405,16 +405,19 @@ func getExtras(ex interface{}) (*string, *float64) {
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
for i, gc := range et.GasCharges {
name := gc.Name
if name == "OnIpldGetStart" {
if name == "OnIpldGetEnd" {
continue
}
tt := float64(gc.TimeTaken.Nanoseconds())
if name == "OnIpldGet" {
prev := et.GasCharges[i-1]
if prev.Name != "OnIpldGetStart" {
log.Warn("OnIpldGet without OnIpldGetStart")
next := &types.GasTrace{}
if i+1 < len(et.GasCharges) {
next = et.GasCharges[i+1]
}
tt += float64(prev.TimeTaken.Nanoseconds())
if next.Name != "OnIpldGetEnd" {
log.Warn("OnIpldGet without OnIpldGetEnd")
}
tt += float64(next.TimeTaken.Nanoseconds())
}
eType, eSize := getExtras(gc.Extra)
if eType != nil {
@@ -604,7 +607,7 @@ var importAnalyzeCmd = &cli.Command{
timeInActors := actorExec.timeTaken.Mean() * actorExec.timeTaken.n
fmt.Printf("Avarage time per epoch in actors: %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100)
}
if actorExecDone, ok := charges["OnActorExecDone"]; ok {
if actorExecDone, ok := charges["OnMethodInvocationDone"]; ok {
timeInActors := actorExecDone.timeTaken.Mean() * actorExecDone.timeTaken.n
fmt.Printf("Avarage time per epoch in OnActorExecDone %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100)
}
+1 -1
View File
@@ -612,7 +612,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par
if !skipunseal {
log.Infof("[%d] Unsealing sector", i)
{
p, done, err := sbfs.AcquireSector(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, stores.FTUnsealed, stores.FTNone, true)
p, done, err := sbfs.AcquireSector(context.TODO(), abi.SectorID{Miner: mid, Number: 1}, stores.FTUnsealed, stores.FTNone, stores.PathSealing)
if err != nil {
return xerrors.Errorf("acquire unsealed sector for removing: %w", err)
}
+129 -119
View File
@@ -5,16 +5,19 @@ import (
"context"
"fmt"
"strings"
//"strings"
"sync"
"time"
"github.com/filecoin-project/go-address"
//"github.com/filecoin-project/lotus/chain/events/state"
"github.com/filecoin-project/lotus/chain/events/state"
"github.com/filecoin-project/specs-actors/actors/abi"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
"github.com/libp2p/go-libp2p-core/peer"
//"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
@@ -287,32 +290,33 @@ func (p *Processor) storeMinersActorState(miners []minerActorInfo) error {
if err != nil {
return err
}
for _, m := range miners {
var pid string
if len(m.state.Info.PeerId) != 0 {
peerid, err := peer.IDFromBytes(m.state.Info.PeerId)
if err != nil {
// this should "never happen", but if it does we should still store info about the miner.
log.Warnw("failed to decode peerID", "peerID (bytes)", m.state.Info.PeerId, "miner", m.common.addr, "tipset", m.common.tsKey.String())
} else {
pid = peerid.String()
}
}
if _, err := stmt.Exec(
m.common.addr.String(),
m.state.Info.Owner.String(),
m.state.Info.Worker.String(),
pid,
m.state.Info.SectorSize.ShortString(),
m.state.PreCommitDeposits.String(),
m.state.LockedFunds.String(),
m.state.NextDeadlineToProcessFaults,
); err != nil {
log.Errorw("failed to store miner state", "state", m.state, "info", m.state.Info, "error", err)
return xerrors.Errorf("failed to store miner state: %w", err)
}
// TODO: Consume new Actor API
//for _, m := range miners {
//var pid string
//if len(m.state.Info.PeerId) != 0 {
//peerid, err := peer.IDFromBytes(m.state.Info.PeerId)
//if err != nil {
//// this should "never happen", but if it does we should still store info about the miner.
//log.Warnw("failed to decode peerID", "peerID (bytes)", m.state.Info.PeerId, "miner", m.common.addr, "tipset", m.common.tsKey.String())
//} else {
//pid = peerid.String()
//}
//}
//if _, err := stmt.Exec(
//m.common.addr.String(),
//m.state.Info.Owner.String(),
//m.state.Info.Worker.String(),
//pid,
//m.state.Info.SectorSize.ShortString(),
//m.state.PreCommitDeposits.String(),
//m.state.LockedFunds.String(),
//m.state.NextDeadlineToProcessFaults,
//); err != nil {
//log.Errorw("failed to store miner state", "state", m.state, "info", m.state.Info, "error", err)
//return xerrors.Errorf("failed to store miner state: %w", err)
//}
}
//}
if err := stmt.Close(); err != nil {
return err
}
@@ -404,12 +408,17 @@ func (p *Processor) storeMinersSectorState(ctx context.Context, miners []minerAc
if _, err := stmt.Exec(
m.common.addr.String(),
uint64(sector.ID),
int64(sector.Info.ActivationEpoch),
int64(sector.Info.Info.Expiration),
// TODO: Consume new Actor API
//int64(sector.Info.ActivationEpoch),
0,
//int64(sector.Info.Info.Expiration),
0,
sector.Info.DealWeight.String(),
sector.Info.VerifiedDealWeight.String(),
sector.Info.Info.SealedCID.String(),
int64(sector.Info.Info.SealRandEpoch),
//sector.Info.Info.SealedCID.String(),
"",
//int64(sector.Info.Info.SealRandEpoch),
0,
); err != nil {
return err
}
@@ -603,7 +612,7 @@ func (p *Processor) updateMinersSectors(ctx context.Context, miners []minerActor
log.Debugw("Updated Miners Sectors", "duration", time.Since(start).String())
}()
pred := state.NewStatePredicates(p.node)
//pred := state.NewStatePredicates(p.node)
eventTx, err := p.db.Begin()
if err != nil {
@@ -630,99 +639,100 @@ func (p *Processor) updateMinersSectors(ctx context.Context, miners []minerActor
updateWg.Done()
}()
minerGrp, ctx := errgroup.WithContext(ctx)
complete := 0
for _, m := range miners {
m := m
if m.common.tsKey == p.genesisTs.Key() {
genSectors, err := p.node.StateMinerSectors(ctx, m.common.addr, nil, true, p.genesisTs.Key())
if err != nil {
return err
}
for _, sector := range genSectors {
if _, err := eventStmt.Exec(sector.ID, "COMMIT", m.common.addr.String(), m.common.stateroot.String()); err != nil {
return err
}
}
complete++
continue
}
minerGrp.Go(func() error {
// special case genesis miners
sectorDiffFn := pred.OnMinerActorChange(m.common.addr, pred.OnMinerSectorChange())
changed, val, err := sectorDiffFn(ctx, m.common.parentTsKey, m.common.tsKey)
if err != nil {
if strings.Contains(err.Error(), "address not found") {
return nil
}
log.Errorw("error getting miner sector diff", "miner", m.common.addr, "error", err)
return err
}
if !changed {
complete++
return nil
}
changes, ok := val.(*state.MinerSectorChanges)
if !ok {
log.Fatalw("Developer Error")
}
log.Debugw("sector changes for miner", "miner", m.common.addr.String(), "Added", len(changes.Added), "Extended", len(changes.Extended), "Removed", len(changes.Removed), "oldState", m.common.parentTsKey, "newState", m.common.tsKey)
// TODO: Resolve Actor interface shift
//minerGrp, ctx := errgroup.WithContext(ctx)
//complete := 0
//for _, m := range miners {
// m := m
// if m.common.tsKey == p.genesisTs.Key() {
// genSectors, err := p.node.StateMinerSectors(ctx, m.common.addr, nil, true, p.genesisTs.Key())
// if err != nil {
// return err
// }
// for _, sector := range genSectors {
// if _, err := eventStmt.Exec(sector.ID, "COMMIT", m.common.addr.String(), m.common.stateroot.String()); err != nil {
// return err
// }
// }
// complete++
// continue
// }
// minerGrp.Go(func() error {
// // special case genesis miners
// sectorDiffFn := pred.OnMinerActorChange(m.common.addr, pred.OnMinerSectorChange())
// changed, val, err := sectorDiffFn(ctx, m.common.parentTsKey, m.common.tsKey)
// if err != nil {
// if strings.Contains(err.Error(), "address not found") {
// return nil
// }
// log.Errorw("error getting miner sector diff", "miner", m.common.addr, "error", err)
// return err
// }
// if !changed {
// complete++
// return nil
// }
// changes, ok := val.(*state.MinerSectorChanges)
// if !ok {
// log.Fatalw("Developer Error")
// }
// log.Debugw("sector changes for miner", "miner", m.common.addr.String(), "Added", len(changes.Added), "Extended", len(changes.Extended), "Removed", len(changes.Removed), "oldState", m.common.parentTsKey, "newState", m.common.tsKey)
for _, extended := range changes.Extended {
if _, err := eventStmt.Exec(extended.To.Info.SectorNumber, "EXTENDED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
return err
}
sectorUpdatesCh <- sectorUpdate{
terminationEpoch: 0,
terminated: false,
expirationEpoch: extended.To.Info.Expiration,
sectorID: extended.From.Info.SectorNumber,
minerID: m.common.addr,
}
//for _, extended := range changes.Extended {
//if _, err := eventStmt.Exec(extended.To.Info.SectorNumber, "EXTENDED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
//return err
//}
//sectorUpdatesCh <- sectorUpdate{
//terminationEpoch: 0,
//terminated: false,
//expirationEpoch: extended.To.Info.Expiration,
//sectorID: extended.From.Info.SectorNumber,
//minerID: m.common.addr,
//}
log.Debugw("sector extended", "miner", m.common.addr.String(), "sector", extended.To.Info.SectorNumber, "old", extended.To.Info.Expiration, "new", extended.From.Info.Expiration)
}
curTs, err := p.node.ChainGetTipSet(ctx, m.common.tsKey)
if err != nil {
return err
}
//log.Debugw("sector extended", "miner", m.common.addr.String(), "sector", extended.To.Info.SectorNumber, "old", extended.To.Info.Expiration, "new", extended.From.Info.Expiration)
//}
//curTs, err := p.node.ChainGetTipSet(ctx, m.common.tsKey)
//if err != nil {
//return err
//}
for _, removed := range changes.Removed {
log.Debugw("removed", "miner", m.common.addr)
// decide if they were terminated or extended
if removed.Info.Expiration > curTs.Height() {
if _, err := eventStmt.Exec(removed.Info.SectorNumber, "TERMINATED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
return err
}
log.Debugw("sector terminated", "miner", m.common.addr.String(), "sector", removed.Info.SectorNumber, "old", "sectorExpiration", removed.Info.Expiration, "terminationEpoch", curTs.Height())
sectorUpdatesCh <- sectorUpdate{
terminationEpoch: curTs.Height(),
terminated: true,
expirationEpoch: removed.Info.Expiration,
sectorID: removed.Info.SectorNumber,
minerID: m.common.addr,
}
//for _, removed := range changes.Removed {
//log.Debugw("removed", "miner", m.common.addr)
//// decide if they were terminated or extended
//if removed.Info.Expiration > curTs.Height() {
//if _, err := eventStmt.Exec(removed.Info.SectorNumber, "TERMINATED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
//return err
//}
//log.Debugw("sector terminated", "miner", m.common.addr.String(), "sector", removed.Info.SectorNumber, "old", "sectorExpiration", removed.Info.Expiration, "terminationEpoch", curTs.Height())
//sectorUpdatesCh <- sectorUpdate{
//terminationEpoch: curTs.Height(),
//terminated: true,
//expirationEpoch: removed.Info.Expiration,
//sectorID: removed.Info.SectorNumber,
//minerID: m.common.addr,
//}
}
if _, err := eventStmt.Exec(removed.Info.SectorNumber, "EXPIRED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
return err
}
log.Debugw("sector removed", "miner", m.common.addr.String(), "sector", removed.Info.SectorNumber, "old", "sectorExpiration", removed.Info.Expiration, "currEpoch", curTs.Height())
}
//}
//if _, err := eventStmt.Exec(removed.Info.SectorNumber, "EXPIRED", m.common.addr.String(), m.common.stateroot.String()); err != nil {
//return err
//}
//log.Debugw("sector removed", "miner", m.common.addr.String(), "sector", removed.Info.SectorNumber, "old", "sectorExpiration", removed.Info.Expiration, "currEpoch", curTs.Height())
//}
for _, added := range changes.Added {
if _, err := eventStmt.Exec(added.Info.SectorNumber, "COMMIT", m.common.addr.String(), m.common.stateroot.String()); err != nil {
return err
}
}
complete++
log.Debugw("Update Done", "complete", complete, "added", len(changes.Added), "removed", len(changes.Removed), "modified", len(changes.Extended))
return nil
})
}
if err := minerGrp.Wait(); err != nil {
return err
}
// for _, added := range changes.Added {
// if _, err := eventStmt.Exec(added.Info.SectorNumber, "COMMIT", m.common.addr.String(), m.common.stateroot.String()); err != nil {
// return err
// }
// }
// complete++
// log.Debugw("Update Done", "complete", complete, "added", len(changes.Added), "removed", len(changes.Removed), "modified", len(changes.Extended))
// return nil
// })
//}
//if err := minerGrp.Wait(); err != nil {
// return err
//}
close(sectorUpdatesCh)
// wait for the update channel to be drained
updateWg.Wait()
+5 -2
View File
@@ -118,8 +118,11 @@ func (p *Processor) processRewardActors(ctx context.Context, rewardTips ActorTip
return nil, xerrors.Errorf("unmarshal state (@ %s): %w", rw.common.stateroot.String(), err)
}
rw.baseBlockReward = rewardActorState.LastPerEpochReward
rw.baselinePower = rewardActorState.BaselinePower
// TODO: Resolve Actor API shift
//rw.baseBlockReward = rewardActorState.LastPerEpochReward
//rw.baselinePower = rewardActorState.BaselinePower
rw.baseBlockReward = big.Zero()
rw.baselinePower = big.Zero()
out = append(out, rw)
}
}
+23 -13
View File
@@ -37,8 +37,6 @@ import (
var log = logging.Logger("main")
var sendPerRequest, _ = types.ParseFIL("50")
var supportedSectors struct {
SectorSizes []struct {
Name string
@@ -114,8 +112,18 @@ var runCmd = &cli.Command{
&cli.StringFlag{
Name: "from",
},
&cli.StringFlag{
Name: "amount",
EnvVars: []string{"LOTUS_FOUNTAIN_AMOUNT"},
Value: "50",
},
},
Action: func(cctx *cli.Context) error {
sendPerRequest, err := types.ParseFIL(cctx.String("amount"))
if err != nil {
return err
}
nodeApi, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
@@ -141,9 +149,10 @@ var runCmd = &cli.Command{
}
h := &handler{
ctx: ctx,
api: nodeApi,
from: from,
ctx: ctx,
api: nodeApi,
from: from,
sendPerRequest: sendPerRequest,
limiter: NewLimiter(LimiterConfig{
TotalRate: time.Second,
TotalBurst: 256,
@@ -185,7 +194,8 @@ type handler struct {
ctx context.Context
api api.FullNode
from address.Address
from address.Address
sendPerRequest types.FIL
limiter *Limiter
minerLimiter *Limiter
@@ -266,12 +276,12 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
}
smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{
Value: types.BigInt(sendPerRequest),
Value: types.BigInt(h.sendPerRequest),
From: h.from,
To: to,
GasPrice: types.NewInt(0),
GasLimit: 10000,
GasLimit: 100_000_000,
})
if err != nil {
w.WriteHeader(400)
@@ -340,12 +350,12 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
}
smsg, err := h.api.MpoolPushMessage(h.ctx, &types.Message{
Value: types.BigInt(sendPerRequest),
Value: types.BigInt(h.sendPerRequest),
From: h.from,
To: owner,
GasPrice: types.NewInt(0),
GasLimit: 10000,
GasLimit: 100_000_000,
})
if err != nil {
w.WriteHeader(400)
@@ -381,7 +391,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
Method: builtin.MethodsPower.CreateMiner,
Params: params,
GasLimit: 10000000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(0),
}
@@ -414,7 +424,7 @@ func (h *handler) msgwait(w http.ResponseWriter, r *http.Request) {
if mw.Receipt.ExitCode != 0 {
w.WriteHeader(400)
w.Write([]byte(xerrors.Errorf("create storage miner failed: exit code %d", mw.Receipt.ExitCode).Error()))
w.Write([]byte(xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode).Error()))
return
}
w.WriteHeader(200)
@@ -437,7 +447,7 @@ func (h *handler) msgwaitaddr(w http.ResponseWriter, r *http.Request) {
if mw.Receipt.ExitCode != 0 {
w.WriteHeader(400)
w.Write([]byte(xerrors.Errorf("create storage miner failed: exit code %d", mw.Receipt.ExitCode).Error()))
w.Write([]byte(xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode).Error()))
return
}
w.WriteHeader(200)
+3 -3
View File
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Creating Storage Miner - Lotus Fountain</title>
<title>Creating Miner - Lotus Fountain</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div class="Index">
<div class="Index-nodes">
<div class="Index-node">
[CREATING STORAGE MINER]
[CREATING MINER]
</div>
<div class="Index-node" id="formnd">
<form id="f" action='/mkminer' method='POST'>
@@ -26,7 +26,7 @@
<b>Waiting for transaction on chain..</b>
</div>
<div class="Index-node">
<span>When creating storage miner, DO NOT REFRESH THE PAGE, wait for it to load. This can take more than 5min.</span>
<span>When creating miner, DO NOT REFRESH THE PAGE, wait for it to load. This can take more than 5min.</span>
</div>
<div class="Index-node">
<span>If you don't have an owner/worker address, you can create it by following <a target="_blank" href="https://docs.lotu.sh/en+mining#get-started-22083">these instructions</a>.</span>
+5 -5
View File
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Creating Storage Miner (wait) - Lotus Fountain</title>
<title>Creating Miner (wait) - Lotus Fountain</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div class="Index">
<div class="Index-nodes">
<div class="Index-node">
[CREATING STORAGE MINER]
[CREATING MINER]
</div>
<div class="Index-node">
Gas Funds:&nbsp;&nbsp;&nbsp;<span id="fcid"></span> - <span id="fstate">WAIT</span>
@@ -17,12 +17,12 @@
Miner Actor:&nbsp;<span id="mcid"></span> - <span id="mstate">WAIT</span>
</div>
<div class="Index-node" style="display: none" id="fwait">
New storage miners address is: <b id="actaddr">t</b>
New miners address is: <b id="actaddr">t</b>
</div>
<div class="Index-node" style="display: none" id="mwait">
<div style="padding-bottom: 1em">To initialize the storage miner run the following command:</div>
<div style="padding-bottom: 1em">To initialize the miner run the following command:</div>
<div style="overflow-x: visible; white-space: nowrap; background: #353500">
<code>lotus-storage-miner init --actor=<span id="actaddr2">t</span> --owner=<span id="owner">t3</span></code>
<code>lotus-miner init --actor=<span id="actaddr2">t</span> --owner=<span id="owner">t3</span></code>
</div>
</div>
</div>
+18 -11
View File
@@ -36,7 +36,10 @@ import (
var log = logging.Logger("main")
const FlagStorageRepo = "workerrepo"
const FlagWorkerRepo = "worker-repo"
// TODO remove after deprecation period
const FlagWorkerRepoDeprecation = "workerrepo"
func main() {
lotuslog.SetupLogLevels()
@@ -48,19 +51,23 @@ func main() {
}
app := &cli.App{
Name: "lotus-seal-worker",
Usage: "Remote storage miner worker",
Name: "lotus-worker",
Usage: "Remote miner worker",
Version: build.UserVersion(),
Flags: []cli.Flag{
&cli.StringFlag{
Name: FlagStorageRepo,
EnvVars: []string{"WORKER_PATH"},
Name: FlagWorkerRepo,
Aliases: []string{FlagWorkerRepoDeprecation},
EnvVars: []string{"LOTUS_WORKER_PATH", "WORKER_PATH"},
Value: "~/.lotusworker", // TODO: Consider XDG_DATA_HOME
Usage: fmt.Sprintf("Specify worker repo path. flag %s and env WORKER_PATH are DEPRECATION, will REMOVE SOON", FlagWorkerRepoDeprecation),
},
&cli.StringFlag{
Name: "storagerepo",
EnvVars: []string{"LOTUS_STORAGE_PATH"},
Value: "~/.lotusstorage", // TODO: Consider XDG_DATA_HOME
Name: "miner-repo",
Aliases: []string{"storagerepo"},
EnvVars: []string{"LOTUS_MINER_PATH", "LOTUS_STORAGE_PATH"},
Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME
Usage: fmt.Sprintf("Specify miner repo path. flag storagerepo and env LOTUS_STORAGE_PATH are DEPRECATION, will REMOVE SOON"),
},
&cli.BoolFlag{
Name: "enable-gpu-proving",
@@ -143,7 +150,7 @@ var runCmd = &cli.Command{
return err
}
if v.APIVersion != build.APIVersion {
return xerrors.Errorf("lotus-storage-miner API version doesn't match: local: ", api.Version{APIVersion: build.APIVersion})
return xerrors.Errorf("lotus-miner API version doesn't match: local: ", api.Version{APIVersion: build.APIVersion})
}
log.Infof("Remote version %s", v)
@@ -186,7 +193,7 @@ var runCmd = &cli.Command{
// Open repo
repoPath := cctx.String(FlagStorageRepo)
repoPath := cctx.String(FlagWorkerRepo)
r, err := repo.NewFS(repoPath)
if err != nil {
return err
@@ -236,7 +243,7 @@ var runCmd = &cli.Command{
{
// init datastore for r.Exists
_, err := lr.Datastore("/")
_, err := lr.Datastore("/metadata")
if err != nil {
return err
}
+158
View File
@@ -1,8 +1,13 @@
package main
import (
"encoding/csv"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
"github.com/google/uuid"
"github.com/mitchellh/go-homedir"
@@ -10,10 +15,12 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/lotus/build"
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/genesis"
)
@@ -23,6 +30,7 @@ var genesisCmd = &cli.Command{
Subcommands: []*cli.Command{
genesisNewCmd,
genesisAddMinerCmd,
genesisAddMsigsCmd,
},
}
@@ -141,3 +149,153 @@ var genesisAddMinerCmd = &cli.Command{
return nil
},
}
type GenAccountEntry struct {
Version int
ID string
Amount types.FIL
VestingMonths int
CustodianID int
M int
N int
Addresses []address.Address
Type string
Sig1 string
Sig2 string
}
var genesisAddMsigsCmd = &cli.Command{
Name: "add-msigs",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 2 {
return fmt.Errorf("must specify template file and csv file with accounts")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
csvf, err := homedir.Expand(cctx.Args().Get(1))
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
entries, err := parseMultisigCsv(csvf)
if err != nil {
return xerrors.Errorf("parsing multisig csv file: %w", err)
}
for i, e := range entries {
if len(e.Addresses) != e.N {
return fmt.Errorf("entry %d had mismatch between 'N' and number of addresses", i)
}
msig := &genesis.MultisigMeta{
Signers: e.Addresses,
Threshold: e.M,
VestingDuration: monthsToBlocks(e.VestingMonths),
VestingStart: 0,
}
act := genesis.Actor{
Type: genesis.TMultisig,
Balance: abi.TokenAmount(e.Amount),
Meta: msig.ActorMeta(),
}
template.Accounts = append(template.Accounts, act)
}
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}
func monthsToBlocks(nmonths int) int {
days := uint64((365 * nmonths) / 12)
return int(days * 24 * 60 * 60 / build.BlockDelaySecs)
}
func parseMultisigCsv(csvf string) ([]GenAccountEntry, error) {
fileReader, err := os.Open(csvf)
if err != nil {
return nil, xerrors.Errorf("read multisig csv: %w", err)
}
r := csv.NewReader(fileReader)
records, err := r.ReadAll()
if err != nil {
return nil, xerrors.Errorf("read multisig csv: %w", err)
}
var entries []GenAccountEntry
for i, e := range records[1:] {
var addrs []address.Address
addrStrs := strings.Split(strings.TrimSpace(e[7]), ":")
for j, a := range addrStrs {
addr, err := address.NewFromString(a)
if err != nil {
return nil, xerrors.Errorf("failed to parse address %d in row %d (%q): %w", j, i, a, err)
}
addrs = append(addrs, addr)
}
balance, err := types.ParseFIL(strings.TrimSpace(e[2]))
if err != nil {
return nil, xerrors.Errorf("failed to parse account balance: %w", err)
}
vesting, err := strconv.Atoi(strings.TrimSpace(e[3]))
if err != nil {
return nil, xerrors.Errorf("failed to parse vesting duration for record %d: %w", i, err)
}
custodianID, err := strconv.Atoi(strings.TrimSpace(e[4]))
if err != nil {
return nil, xerrors.Errorf("failed to parse custodianID in record %d: %w", i, err)
}
threshold, err := strconv.Atoi(strings.TrimSpace(e[5]))
if err != nil {
return nil, xerrors.Errorf("failed to parse multisigM in record %d: %w", i, err)
}
num, err := strconv.Atoi(strings.TrimSpace(e[6]))
if err != nil {
return nil, xerrors.Errorf("Number of addresses be integer: %w", err)
}
if e[0] != "1" {
return nil, xerrors.Errorf("record version must be 1")
}
entries = append(entries, GenAccountEntry{
Version: 1,
ID: e[1],
Amount: balance,
CustodianID: custodianID,
VestingMonths: vesting,
M: threshold,
N: num,
Type: e[8],
Sig1: e[9],
Sig2: e[10],
Addresses: addrs,
})
}
return entries, nil
}
+3 -2
View File
@@ -186,7 +186,7 @@ func presealSector(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, sid abi.Sector
}
func presealSectorFake(sbfs *basicfs.Provider, sid abi.SectorID, spt abi.RegisteredSealProof, ssize abi.SectorSize) (*genesis.PreSeal, error) {
paths, done, err := sbfs.AcquireSector(context.TODO(), sid, 0, stores.FTSealed|stores.FTCache, true)
paths, done, err := sbfs.AcquireSector(context.TODO(), sid, 0, stores.FTSealed|stores.FTCache, stores.PathSealing)
if err != nil {
return nil, xerrors.Errorf("acquire unsealed sector: %w", err)
}
@@ -251,12 +251,13 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner,
}
func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error {
for _, sector := range m.Sectors {
for i, sector := range m.Sectors {
proposal := &market.DealProposal{
PieceCID: sector.CommD,
PieceSize: abi.PaddedPieceSize(ssize),
Client: k.Address,
Provider: maddr,
Label: fmt.Sprintf("%d", i),
StartEpoch: 0,
EndEpoch: 9001,
StoragePricePerEpoch: big.Zero(),
+1 -1
View File
@@ -89,7 +89,7 @@ var noncefix = &cli.Command{
From: addr,
To: addr,
Value: types.NewInt(1),
GasLimit: 10000,
GasLimit: 100_000_000,
GasPrice: types.NewInt(1),
Nonce: i,
}
+8 -24
View File
@@ -4,11 +4,10 @@ import (
"bytes"
"fmt"
"github.com/filecoin-project/lotus/build"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/build"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
@@ -77,7 +76,7 @@ var verifRegAddVerifierCmd = &cli.Command{
From: fromk,
Method: builtin.MethodsVerifiedRegistry.AddVerifier,
GasPrice: types.NewInt(1),
GasLimit: 300000,
GasLimit: 100_000_000,
Params: params,
}
@@ -153,7 +152,7 @@ var verifRegVerifyClientCmd = &cli.Command{
From: fromk,
Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient,
GasPrice: types.NewInt(1),
GasLimit: 300000,
GasLimit: 100_000_000,
Params: params,
}
@@ -301,30 +300,15 @@ var verifRegCheckClientCmd = &cli.Command{
defer closer()
ctx := lcli.ReqContext(cctx)
act, err := api.StateGetActor(ctx, builtin.VerifiedRegistryActorAddr, types.EmptyTSK)
dcap, err := api.StateVerifiedClientStatus(ctx, caddr, types.EmptyTSK)
if err != nil {
return err
}
apibs := apibstore.NewAPIBlockstore(api)
cst := cbor.NewCborStore(apibs)
var st verifreg.State
if err := cst.Get(ctx, act.Head, &st); err != nil {
return err
if dcap == nil {
return xerrors.Errorf("client %s is not a verified client", err)
}
vh, err := hamt.LoadNode(ctx, cst, st.VerifiedClients, hamt.UseTreeBitWidth(5))
if err != nil {
return err
}
var dcap verifreg.DataCap
if err := vh.Find(ctx, string(caddr.Bytes()), &dcap); err != nil {
return xerrors.Errorf("failed to lookup address: %w", err)
}
fmt.Println(dcap)
fmt.Println(*dcap)
return nil
},
+6 -6
View File
@@ -23,7 +23,7 @@ import (
var infoCmd = &cli.Command{
Name: "info",
Usage: "Print storage miner info",
Usage: "Print miner info",
Flags: []cli.Flag{
&cli.BoolFlag{Name: "color"},
},
@@ -106,16 +106,16 @@ var infoCmd = &cli.Command{
return xerrors.Errorf("counting faults: %w", err)
}
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(uint64(mi.SectorSize)))))
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sectors), types.NewInt(uint64(mi.SectorSize)))))
if nfaults == 0 {
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))))
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Active), types.NewInt(uint64(mi.SectorSize)))))
} else {
var faultyPercentage float64
if secCounts.Sset != 0 {
faultyPercentage = float64(10000*nfaults/secCounts.Sset) / 100.
if secCounts.Sectors != 0 {
faultyPercentage = float64(10000*nfaults/secCounts.Sectors) / 100.
}
fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n",
types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))),
types.SizeStr(types.BigMul(types.NewInt(secCounts.Sectors), types.NewInt(uint64(mi.SectorSize)))),
types.SizeStr(types.BigMul(types.NewInt(nfaults), types.NewInt(uint64(mi.SectorSize)))),
faultyPercentage)
}
+14 -14
View File
@@ -50,7 +50,7 @@ import (
var initCmd = &cli.Command{
Name: "init",
Usage: "Initialize a lotus storage miner repo",
Usage: "Initialize a lotus miner repo",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "actor",
@@ -107,7 +107,7 @@ var initCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
log.Info("Initializing lotus storage miner")
log.Info("Initializing lotus miner")
sectorSizeInt, err := units.RAMInBytes(cctx.String("sector-size"))
if err != nil {
@@ -151,7 +151,7 @@ var initCmd = &cli.Command{
log.Info("Checking if repo exists")
repoPath := cctx.String(FlagStorageRepo)
repoPath := cctx.String(FlagMinerRepo)
r, err := repo.NewFS(repoPath)
if err != nil {
return err
@@ -162,7 +162,7 @@ var initCmd = &cli.Command{
return err
}
if ok {
return xerrors.Errorf("repo at '%s' is already initialized", cctx.String(FlagStorageRepo))
return xerrors.Errorf("repo at '%s' is already initialized", cctx.String(FlagMinerRepo))
}
log.Info("Checking full node version")
@@ -236,7 +236,7 @@ var initCmd = &cli.Command{
}
if err := storageMinerInit(ctx, cctx, api, r, ssize, gasPrice); err != nil {
log.Errorf("Failed to initialize lotus-storage-miner: %+v", err)
log.Errorf("Failed to initialize lotus-miner: %+v", err)
path, err := homedir.Expand(repoPath)
if err != nil {
return err
@@ -249,7 +249,7 @@ var initCmd = &cli.Command{
}
// TODO: Point to setting storage price, maybe do it interactively or something
log.Info("Storage miner successfully created, you can now start it with 'lotus-storage-miner run'")
log.Info("Miner successfully created, you can now start it with 'lotus-miner run'")
return nil
},
@@ -454,11 +454,11 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
cerr := configureStorageMiner(ctx, api, a, peerid, gasPrice)
if err := m.Stop(ctx); err != nil {
log.Error("failed to shut down storage miner: ", err)
log.Error("failed to shut down miner: ", err)
}
if cerr != nil {
return xerrors.Errorf("failed to configure storage miner: %w", cerr)
return xerrors.Errorf("failed to configure miner: %w", cerr)
}
}
@@ -492,7 +492,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
}
if err := configureStorageMiner(ctx, api, a, peerid, gasPrice); err != nil {
return xerrors.Errorf("failed to configure storage miner: %w", err)
return xerrors.Errorf("failed to configure miner: %w", err)
}
addr = a
@@ -505,7 +505,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
addr = a
}
log.Infof("Created new storage miner: %s", addr)
log.Infof("Created new miner: %s", addr)
if err := mds.Put(datastore.NewKey("miner-address"), addr.Bytes()); err != nil {
return err
}
@@ -557,7 +557,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
Params: enc,
Value: types.NewInt(0),
GasPrice: gasPrice,
GasLimit: 99999999,
GasLimit: 100_000_000,
}
smsg, err := api.MpoolPushMessage(ctx, msg)
@@ -636,7 +636,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
Method: builtin.MethodsPower.CreateMiner,
Params: params,
GasLimit: 10000000,
GasLimit: 100_000_000,
GasPrice: gasPrice,
}
@@ -654,7 +654,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
}
if mw.Receipt.ExitCode != 0 {
return address.Undef, xerrors.Errorf("create storage miner failed: exit code %d", mw.Receipt.ExitCode)
return address.Undef, xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode)
}
var retval power.CreateMinerReturn
@@ -662,6 +662,6 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
return address.Undef, err
}
log.Infof("New storage miners address is: %s (%s)", retval.IDAddress, retval.RobustAddress)
log.Infof("New miners address is: %s (%s)", retval.IDAddress, retval.RobustAddress)
return retval.IDAddress, nil
}

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