-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve deal making efficiency & Lotus v1.1.3 update & fixes #705
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2138e69
update things
jsign 848b673
add missing deal
jsign 2086230
fix changed error message
jsign df1acb7
update devnet
jsign fb6a70b
update devnet
jsign ecbce59
revert change
jsign ad04787
remove sector list from miner index
jsign bc520c0
avoid port collisions
jsign 56f25c4
configurable index raw json output bind addr
jsign 1789fff
use random free port
jsign 73ac136
fix
jsign 9bc9df2
lints
jsign b11b943
update devnet to 1.1.3 unnamed
jsign 48032c6
update tags
jsign e2858ff
update to definitive tag
jsign b3c1245
fmt nit
jsign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ func (m *Module) Import(ctx context.Context, data io.Reader, isCAR bool) (cid.Ci | |
// is automatically calculated considering each miner epoch price and piece size. | ||
// The data of dataCid should be already imported to the Filecoin Client or should be | ||
// accessible to it. (e.g: is integrated with an IPFS node). | ||
func (m *Module) Store(ctx context.Context, waddr string, dataCid cid.Cid, pieceSize uint64, dcfgs []deals.StorageDealConfig, minDuration uint64) ([]deals.StoreResult, error) { | ||
func (m *Module) Store(ctx context.Context, waddr string, dataCid cid.Cid, pieceSize abi.PaddedPieceSize, pieceCid cid.Cid, dcfgs []deals.StorageDealConfig, minDuration uint64) ([]deals.StoreResult, error) { | ||
if minDuration < util.MinDealDuration { | ||
return nil, fmt.Errorf("duration %d should be greater or equal to %d", minDuration, util.MinDealDuration) | ||
} | ||
|
@@ -146,9 +146,11 @@ func (m *Module) Store(ctx context.Context, waddr string, dataCid cid.Cid, piece | |
Data: &storagemarket.DataRef{ | ||
TransferType: storagemarket.TTGraphsync, | ||
Root: dataCid, | ||
PieceCid: &pieceCid, | ||
PieceSize: pieceSize.Unpadded(), | ||
}, | ||
MinBlocksDuration: minDuration, | ||
EpochPrice: big.Div(big.Mul(big.NewIntUnsigned(c.EpochPrice), big.NewIntUnsigned(pieceSize)), abi.NewTokenAmount(1<<30)), | ||
EpochPrice: big.Div(big.Mul(big.NewIntUnsigned(c.EpochPrice), big.NewIntUnsigned(uint64(pieceSize))), abi.NewTokenAmount(1<<30)), | ||
Miner: maddr, | ||
Wallet: addr, | ||
FastRetrieval: c.FastRetrieval, | ||
|
@@ -173,18 +175,17 @@ func (m *Module) Store(ctx context.Context, waddr string, dataCid cid.Cid, piece | |
return res, nil | ||
} | ||
|
||
// CalculatePieceSize calculates the data and piece size of a Cid accesible | ||
// by the underlying Lotus node. | ||
func (m *Module) CalculatePieceSize(ctx context.Context, c cid.Cid) (api.DataSize, error) { | ||
// CalculateDealPiece calculates the size and CommP for a data cid. | ||
func (m *Module) CalculateDealPiece(ctx context.Context, c cid.Cid) (api.DataCIDSize, error) { | ||
lapi, cls, err := m.clientBuilder(ctx) | ||
if err != nil { | ||
return api.DataSize{}, fmt.Errorf("creating lotus client: %s", err) | ||
return api.DataCIDSize{}, fmt.Errorf("creating lotus client: %s", err) | ||
} | ||
defer cls() | ||
|
||
dsz, err := lapi.ClientDealSize(ctx, c) | ||
dsz, err := lapi.ClientDealPieceCID(ctx, c) | ||
Comment on lines
-185
to
+186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use a new API that calculates both size and PieceCID. |
||
if err != nil { | ||
return api.DataSize{}, fmt.Errorf("calculating data size: %s", err) | ||
return api.DataCIDSize{}, fmt.Errorf("calculating data size: %s", err) | ||
} | ||
return dsz, nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We delegate to the client to provide
pieceSize
andpieceCid
. This allows Lotus to avoid calculating these values, and just trusting they're correct. This is important for clients such as FFS, which create multiple deals with the same data.