filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.85k stars 1.27k forks source link

Failure to create genesis when using fake sectors from lotus-seed #8535

Closed travisperson closed 2 years ago

travisperson commented 2 years ago

Checklist

Lotus component

Lotus Version

lotus version 1.15.2-dev+debug+git.9b16ee343

Describe the Bug

Failure to create genesis when using fake sectors from lotus-seed.

When using fake sectors every CommP / PieceCID is the same for every sector in the network. This results in an error when generating the genesis for the network. Prior to nv16 we resolved this by setting the deal label to the CommR which was unique to each deal. This is not possible anymore because deal labels are no longer strings but a market.DealLabel which is a byte array internally. This isn't so much an issue, but the structure does not implement a JSON marshaller so it always encodes to a {}.

Logging Information

https://gist.github.com/travisperson/4bd70f660c997bcb8a40f53155c4249d

Repo Steps

See PR https://github.com/filecoin-project/lotus/pull/8536

arajasek commented 2 years ago

Fixed in feat/nv16 (close after confirmation)

travisperson commented 2 years ago

The changes to actors fixed this issue for creating the genesis. However, during initialization of miners there is now an error when making an API request to the daemon.

{"level":"error","ts":"2022-04-22T20:10:39.340Z","logger":"main","caller":"lotus-miner/init.go:275","msg":"Failed to initialize lotus-miner: migrating presealed sector metadata:\n main.storageMinerInit\n /opt/build/cmd/lotus-miner/init.go:546\n - finding storage deal for pre-sealed sector 0:\n main.migratePreSealMeta\n /opt/build/cmd/lotus-miner/init.go:321\n - getting market deals:\n main.findMarketDealID\n /opt/build/cmd/lotus-miner/init.go:410\n - RPC client error: unmarshaling result: failed to unmarshal string: json: cannot unmarshal object into Go value of type string"}

Failed to initialize lotus-miner: migrating presealed sector metadata:
     main.storageMinerInit
         /opt/build/cmd/lotus-miner/init.go:546
   - finding storage deal for pre-sealed sector 0:
     main.migratePreSealMeta
         /opt/build/cmd/lotus-miner/init.go:321
   - getting market deals:
      main.findMarketDealID
         /opt/build/cmd/lotus-miner/init.go:410
   - RPC client error: unmarshaling result: failed to unmarshal string: json: cannot unmarshal object into Go value of type string

This is a call to StateMarketDeals during the miner initilization. https://github.com/filecoin-project/lotus/blob/3eb007776a0a522e0ae707716394255ca10d8fbc/cmd/lotus-miner/init.go#L408-L411

The StateMarketDeals api call returns a map[string]MarketDeal, which is a value, and therefore the Marshal call don't work. https://github.com/filecoin-project/lotus/blob/3eb007776a0a522e0ae707716394255ca10d8fbc/api/api_full.go#L519-L522