From 729c052f6411551b6aa73b58b8c8051b107dcd4a Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Thu, 30 Jul 2020 00:55:37 -0400 Subject: [PATCH 1/5] Update specs-actors, support deal provider collateral bounds --- api/api_full.go | 3 +++ api/apistruct/struct.go | 5 ++++ go.mod | 4 +-- go.sum | 4 +++ markets/storageadapter/client.go | 4 +++ markets/storageadapter/provider.go | 4 +++ node/impl/full/state.go | 39 ++++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 2 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 10388e105..42f0cff27 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -329,6 +329,9 @@ type FullNode interface { // 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) + // StateDealProviderCollateralBounds returns the min and max collateral a storage provider + // can issue. It takes the deal size and verified status as parameters. + StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) // MethodGroup: Msig // The Msig methods are used to interact with multisig wallets on the diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 9aa2a4963..a3824dc7a 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -167,6 +167,7 @@ type FullNodeStruct struct { 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"` + StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) `perm:"read"` MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"` @@ -746,6 +747,10 @@ func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr add return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk) } +func (c *FullNodeStruct) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) { + return c.Internal.StateDealProviderCollateralBounds(ctx, size, verified, tsk) +} + func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.Address, tsk types.TipSetKey) (types.BigInt, error) { return c.Internal.MsigGetAvailableBalance(ctx, a, tsk) } diff --git a/go.mod b/go.mod index 30ce41e35..f0a21a4d5 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/filecoin-project/chain-validation v0.0.6-0.20200728204507-037308fa7af2 github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200716204036-cddc56607e1d github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef - github.com/filecoin-project/go-bitfield v0.1.1 + github.com/filecoin-project/go-bitfield v0.1.2 github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 github.com/filecoin-project/go-data-transfer v0.5.1 @@ -30,7 +30,7 @@ require ( github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25 - github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b + github.com/filecoin-project/specs-actors v0.8.2 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea github.com/filecoin-project/storage-fsm v0.0.0-20200728185042-33f96f051f20 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index d653c940a..b39a6e3f8 100644 --- a/go.sum +++ b/go.sum @@ -235,6 +235,8 @@ github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1 h1: github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= github.com/filecoin-project/go-bitfield v0.1.1 h1:ioLGippGXLS93uBMbpSwVPD7h2Oz1FYq/WPYDfT7W/A= github.com/filecoin-project/go-bitfield v0.1.1/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= +github.com/filecoin-project/go-bitfield v0.1.2 h1:TjLregCoyP1/5lm7WCM0axyV1myIHwbjGa21skuu5tk= +github.com/filecoin-project/go-bitfield v0.1.2/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 h1:av5fw6wmm58FYMgJeoB/lK9XXrgdugYiTqkdxjTy9k8= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMXdBnCiXjfCYx/hLqFxccPoqsSveQFxVLvNxy9bus= @@ -277,6 +279,8 @@ github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6/go github.com/filecoin-project/specs-actors v0.8.1-0.20200720115956-cd051eabf328/go.mod h1:0+CxQ5Jeii3522irTvhKRDpr4GG1bj5Erq3p/d38DzY= github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b h1:Tr34QNdGYMT2ghM6o1H1bMziTw/nWd/B2Um2A3vWp2c= github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b/go.mod h1:U1qnlL3MjJnE6n3MTUUVhlmpJodx+fo26cC0aiL1jeo= +github.com/filecoin-project/specs-actors v0.8.2 h1:fpAPOPqWqmzJCWHpm6P1XDRSpQrxyY5Pzh5H3doYs7Q= +github.com/filecoin-project/specs-actors v0.8.2/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 38c8d5a4e..f5cb43251 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -238,6 +238,10 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return res.IDs[dealIdx], nil } +func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error) { + return c.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) +} + func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealId abi.DealID, cb storagemarket.DealSectorCommittedCallback) error { checkFunc := func(ts *types.TipSet) (done bool, more bool, err error) { sd, err := stmgr.GetStorageDeal(ctx, c.StateManager, dealId, ts) diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 86419df42..cad4e70e5 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -228,6 +228,10 @@ func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context return uint64(best.SectorID), uint64(best.Offset.Unpadded()), uint64(best.Size), nil } +func (n *ProviderNodeAdapter) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error) { + return n.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) +} + func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, cb storagemarket.DealSectorCommittedCallback) error { checkFunc := func(ts *types.TipSet) (done bool, more bool, err error) { sd, err := n.StateMarketStorageDeal(ctx, dealID, ts.Key()) diff --git a/node/impl/full/state.go b/node/impl/full/state.go index f6cc6550d..c4228a90b 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1146,3 +1146,42 @@ func (a *StateAPI) StateVerifiedClientStatus(ctx context.Context, addr address.A return &dcap, nil } + +var dealProviderCollateralNum = types.NewInt(110) +var dealProviderCollateralDen = types.NewInt(100) + +// StateDealProviderCollateralBounds returns the min and max collateral a storage provider +// can issue. It takes the deal size and verified status as parameters. +func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) { + ts, err := a.Chain.GetTipSetFromKey(tsk) + if err != nil { + return big.Zero(), big.Zero(), xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + var powerState power.State + var rewardState reward.State + + err = a.StateManager.WithParentStateTsk(ts.Key(), func(state *state.StateTree) error { + if err := a.StateManager.WithActor(builtin.StoragePowerActorAddr, a.StateManager.WithActorState(ctx, &powerState))(state); err != nil { + return xerrors.Errorf("getting power state: %w", err) + } + + if err := a.StateManager.WithActor(builtin.RewardActorAddr, a.StateManager.WithActorState(ctx, &rewardState))(state); err != nil { + return xerrors.Errorf("getting reward state: %w", err) + } + + return nil + }) + + if err != nil { + return big.Zero(), big.Zero(), xerrors.Errorf("getting power and reward actor states: %w") + } + + circ, err := a.StateManager.CirculatingSupply(ctx, ts) + if err != nil { + return big.Zero(), big.Zero(), xerrors.Errorf("getting total circulating supply: %w") + } + + min, max := market.DealProviderCollateralBounds(size, verified, powerState.ThisEpochQualityAdjPower, rewardState.ThisEpochBaselinePower, circ) + return types.BigDiv(types.BigMul(min, dealProviderCollateralNum), dealProviderCollateralDen), max, nil +} From 4d328cad546da0dd6b1f6c881b7d40037ade362e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 30 Jul 2020 14:31:31 +0200 Subject: [PATCH 2/5] Get things to mostly work --- api/api_full.go | 7 ++++++- api/apistruct/struct.go | 4 ++-- chain/events/state/predicates_test.go | 7 ++++++- go.mod | 6 +++--- go.sum | 20 +++++++++----------- markets/retrievaladapter/provider.go | 8 ++++---- markets/storageadapter/client.go | 7 ++++++- markets/storageadapter/provider.go | 23 ++++++++++++++++------- node/builder.go | 2 ++ node/impl/full/state.go | 13 ++++++++----- node/modules/client.go | 11 +++++++++-- node/modules/storageminer.go | 10 +++++++++- storage/sealing.go | 2 +- storage/sectorblocks/blocks.go | 10 +++++----- 14 files changed, 86 insertions(+), 44 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 42f0cff27..a59982a79 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -331,7 +331,7 @@ type FullNode interface { StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*verifreg.DataCap, error) // StateDealProviderCollateralBounds returns the min and max collateral a storage provider // can issue. It takes the deal size and verified status as parameters. - StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) + StateDealProviderCollateralBounds(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (DealCollateralBounds, error) // MethodGroup: Msig // The Msig methods are used to interact with multisig wallets on the @@ -638,6 +638,11 @@ type ComputeStateOutput struct { Trace []*InvocResult } +type DealCollateralBounds struct { + Min abi.TokenAmount + Max abi.TokenAmount +} + type MiningBaseInfo struct { MinerPower types.BigInt NetworkPower types.BigInt diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index a3824dc7a..68bb9cf75 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -167,7 +167,7 @@ type FullNodeStruct struct { 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"` - StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) `perm:"read"` + StateDealProviderCollateralBounds func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error) `perm:"read"` MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` MsigCreate func(context.Context, uint64, []address.Address, abi.ChainEpoch, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"` @@ -747,7 +747,7 @@ func (c *FullNodeStruct) StateVerifiedClientStatus(ctx context.Context, addr add return c.Internal.StateVerifiedClientStatus(ctx, addr, tsk) } -func (c *FullNodeStruct) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) { +func (c *FullNodeStruct) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error) { return c.Internal.StateDealProviderCollateralBounds(ctx, size, verified, tsk) } diff --git a/chain/events/state/predicates_test.go b/chain/events/state/predicates_test.go index 8168f14d2..a750d270e 100644 --- a/chain/events/state/predicates_test.go +++ b/chain/events/state/predicates_test.go @@ -2,6 +2,7 @@ package state import ( "context" + "github.com/filecoin-project/go-bitfield" "testing" "github.com/stretchr/testify/require" @@ -447,7 +448,11 @@ func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, o minerInfo := emptyMap - state, err := miner.ConstructState(minerInfo, 123, emptyArrayCid, emptyMap, emptyDeadlinesCid) + emptyBitfield := bitfield.NewFromSet(nil) + emptyBitfieldCid, err := store.Put(context.Background(), emptyBitfield) + require.NoError(t, err) + + state, err := miner.ConstructState(minerInfo, 123, emptyBitfieldCid, emptyArrayCid, emptyMap, emptyDeadlinesCid) require.NoError(t, err) return state diff --git a/go.mod b/go.mod index f0a21a4d5..ee26180a5 100644 --- a/go.mod +++ b/go.mod @@ -23,16 +23,16 @@ require ( github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 github.com/filecoin-project/go-data-transfer v0.5.1 github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f - github.com/filecoin-project/go-fil-markets v0.5.2 + github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42 github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 github.com/filecoin-project/go-multistore v0.0.2 github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b - github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25 + github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72 github.com/filecoin-project/specs-actors v0.8.2 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea - github.com/filecoin-project/storage-fsm v0.0.0-20200728185042-33f96f051f20 + github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-kit/kit v0.10.0 github.com/go-ole/go-ole v1.2.4 // indirect diff --git a/go.sum b/go.sum index b39a6e3f8..ac262081d 100644 --- a/go.sum +++ b/go.sum @@ -229,7 +229,6 @@ github.com/filecoin-project/go-amt-ipld/v2 v2.1.0 h1:t6qDiuGYYngDqaLc2ZUvdtAg4UN github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs= github.com/filecoin-project/go-bitfield v0.0.0-20200416002808-b3ee67ec9060/go.mod h1:iodsLxOFZnqKtjj2zkgqzoGNrv6vUqj69AT/J8DKXEw= github.com/filecoin-project/go-bitfield v0.0.1/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= -github.com/filecoin-project/go-bitfield v0.0.2-0.20200518150651-562fdb554b6e/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= github.com/filecoin-project/go-bitfield v0.0.3/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1 h1:xuHlrdznafh7ul5t4xEncnA4qgpQvJZEw+mr98eqHXw= github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= @@ -246,8 +245,8 @@ github.com/filecoin-project/go-data-transfer v0.5.1/go.mod h1:PRs78hp9u8T4G2Jce5 github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5/go.mod h1:JbkIgFF/Z9BDlvrJO1FuKkaWsH673/UdFaiVS6uIHlA= github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f h1:GxJzR3oRIMTPtpZ0b7QF8FKPK6/iPAc7trhlL5k/g+s= github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= -github.com/filecoin-project/go-fil-markets v0.5.2 h1:4xW3JoPnPDKP+f4s/tWLmuYaReGdjetHZT7qgXivdiw= -github.com/filecoin-project/go-fil-markets v0.5.2/go.mod h1:zDhwmUy/AS/xCJOayW7Cedff9SDuSdGIWRnGXBDjcOk= +github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42 h1:TPGmqX/9mUH/BBywG4GtNHqnrRunZLxRgBNrK40XpOs= +github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42/go.mod h1:l0I1+rlKS5fSNj5cKdEj5inLWVsglKZm5fUYROmFgKY= github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 h1:Jc7vkplmZYVuaEcSXGHDwefvZIdoyyaoGDLqSr8Svms= github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24/go.mod h1:j6zV//WXIIY5kky873Q3iIKt/ViOE8rcijovmpxrXzM= github.com/filecoin-project/go-multistore v0.0.2 h1:JZEddnXXt3mMzHi7bi9IH7Yi1NpGLy19J5Lk/xbxBMs= @@ -261,31 +260,30 @@ github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261/g github.com/filecoin-project/go-statemachine v0.0.0-20200226041606-2074af6d51d9/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statemachine v0.0.0-20200714194326-a77c3ae20989 h1:1GjCS3xy/CRIw7Tq0HfzX6Al8mklrszQZ3iIFnjPzHk= github.com/filecoin-project/go-statemachine v0.0.0-20200714194326-a77c3ae20989/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= +github.com/filecoin-project/go-statemachine v0.0.0-20200730031800-c3336614d2a7 h1:KAF3WM/xSnl6G6RHX8vDJthg4+e4PSgBh72//6c6Qvc= +github.com/filecoin-project/go-statemachine v0.0.0-20200730031800-c3336614d2a7/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ= github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8= -github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15 h1:miw6hiusb/MkV1ryoqUKKWnvHhPW00AYtyeCj0L8pqo= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo= -github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25 h1:sTonFkDw3KrIFIJTfIevYXyk+Mu9LbjbOHn/fWoMOMc= -github.com/filecoin-project/sector-storage v0.0.0-20200727112136-9377cb376d25/go.mod h1:f9W29dKqNFm8Su4OddGwkAQOYMKYUR5Fk2oC/JZDjCI= +github.com/filecoin-project/sector-storage v0.0.0-20200730050024-3ee28c3b6d9a/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA= +github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72 h1:XPi90WiPVZFAV42N5YfLtUiqyk+ba/Ap/a7R+Aoe434= +github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72/go.mod h1:oOawOl9Yk+qeytLzzIryjI8iRbqo+qzS6EEeElP4PWA= github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= -github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= github.com/filecoin-project/specs-actors v0.6.1/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6 h1:F+GcBdKPdW/wTv6bMJxG9Zj1dc0UGkO6uNOQmKP/g1o= github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6/go.mod h1:JOMUa7EijvpOO4ofD1yeHNmqohkmmnhTvz/IpB6so4c= -github.com/filecoin-project/specs-actors v0.8.1-0.20200720115956-cd051eabf328/go.mod h1:0+CxQ5Jeii3522irTvhKRDpr4GG1bj5Erq3p/d38DzY= github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b h1:Tr34QNdGYMT2ghM6o1H1bMziTw/nWd/B2Um2A3vWp2c= github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b/go.mod h1:U1qnlL3MjJnE6n3MTUUVhlmpJodx+fo26cC0aiL1jeo= github.com/filecoin-project/specs-actors v0.8.2 h1:fpAPOPqWqmzJCWHpm6P1XDRSpQrxyY5Pzh5H3doYs7Q= github.com/filecoin-project/specs-actors v0.8.2/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= -github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= -github.com/filecoin-project/storage-fsm v0.0.0-20200728185042-33f96f051f20 h1:VK2DdNGNQ1A1QwS4aCqAUeWKrJototfTv7p6qIHvU7o= -github.com/filecoin-project/storage-fsm v0.0.0-20200728185042-33f96f051f20/go.mod h1:1CGbd11KkHuyWPT+xwwCol1zl/jnlpiKD2L4fzKxaiI= +github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 h1:Eg7Ia3iRWKMXpS7bU8ufarQJyGsBor7eGgfrAHfn8HA= +github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4/go.mod h1:1CGbd11KkHuyWPT+xwwCol1zl/jnlpiKD2L4fzKxaiI= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= diff --git a/markets/retrievaladapter/provider.go b/markets/retrievaladapter/provider.go index 6c425ccd8..d8970f0c5 100644 --- a/markets/retrievaladapter/provider.go +++ b/markets/retrievaladapter/provider.go @@ -39,8 +39,8 @@ func (rpn *retrievalProviderNode) GetMinerWorkerAddress(ctx context.Context, min return mi.Worker, err } -func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID uint64, offset uint64, length uint64) (io.ReadCloser, error) { - si, err := rpn.miner.GetSectorInfo(abi.SectorNumber(sectorID)) +func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (io.ReadCloser, error) { + si, err := rpn.miner.GetSectorInfo(sectorID) if err != nil { return nil, err } @@ -52,12 +52,12 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID uin sid := abi.SectorID{ Miner: abi.ActorID(mid), - Number: abi.SectorNumber(sectorID), + Number: sectorID, } r, w := io.Pipe() go func() { - err := rpn.sealer.ReadPiece(ctx, w, sid, storiface.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.TicketValue, *si.CommD) + err := rpn.sealer.ReadPiece(ctx, w, sid, storiface.UnpaddedByteIndex(offset), length, si.TicketValue, *si.CommD) _ = w.CloseWithError(err) }() diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index f5cb43251..27589aaa0 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -239,7 +239,12 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor } func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error) { - return c.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) + bounds, err := c.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) + if err != nil { + return abi.TokenAmount{}, abi.TokenAmount{}, err + } + + return bounds.Min, bounds.Max, nil } func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealId abi.DealID, cb storagemarket.DealSectorCommittedCallback) error { diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index cad4e70e5..e1de4feb0 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -88,8 +88,8 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark return smsg.Cid(), nil } -func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, pieceSize abi.UnpaddedPieceSize, pieceData io.Reader) error { - _, err := n.secb.AddPiece(ctx, pieceSize, pieceData, sealing.DealInfo{ +func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, pieceSize abi.UnpaddedPieceSize, pieceData io.Reader) (*storagemarket.PackingResult, error) { + p, offset, err := n.secb.AddPiece(ctx, pieceSize, pieceData, sealing.DealInfo{ DealID: deal.DealID, DealSchedule: sealing.DealSchedule{ StartEpoch: deal.ClientDealProposal.Proposal.StartEpoch, @@ -98,11 +98,15 @@ func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagema KeepUnsealed: deal.FastRetrieval, }) if err != nil { - return xerrors.Errorf("AddPiece failed: %s", err) + return nil, xerrors.Errorf("AddPiece failed: %s", err) } log.Warnf("New Deal: deal %d", deal.DealID) - return nil + return &storagemarket.PackingResult{ + SectorNumber: p, + Offset: offset, + Size: pieceSize.Padded(), + }, nil } func (n *ProviderNodeAdapter) VerifySignature(ctx context.Context, sig crypto.Signature, addr address.Address, input []byte, encodedTs shared.TipSetToken) (bool, error) { @@ -199,7 +203,7 @@ func (n *ProviderNodeAdapter) GetBalance(ctx context.Context, addr address.Addre return utils.ToSharedBalance(bal), nil } -func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context, dealID abi.DealID, encodedTs shared.TipSetToken) (sectorID uint64, offset uint64, length uint64, err error) { +func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context, dealID abi.DealID, encodedTs shared.TipSetToken) (sectorID abi.SectorNumber, offset abi.PaddedPieceSize, length abi.PaddedPieceSize, err error) { refs, err := n.secb.GetRefs(dealID) if err != nil { return 0, 0, 0, err @@ -225,11 +229,16 @@ func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context if bestSi.State == sealing.UndefinedSectorState { return 0, 0, 0, xerrors.New("no sealed sector found") } - return uint64(best.SectorID), uint64(best.Offset.Unpadded()), uint64(best.Size), nil + return best.SectorID, best.Offset, best.Size.Padded(), nil } func (n *ProviderNodeAdapter) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error) { - return n.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) + bounds, err := n.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK) + if err != nil { + return abi.TokenAmount{}, abi.TokenAmount{}, err + } + + return bounds.Min, bounds.Max, nil } func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, cb storagemarket.DealSectorCommittedCallback) error { diff --git a/node/builder.go b/node/builder.go index eef07fab9..b4f0fa518 100644 --- a/node/builder.go +++ b/node/builder.go @@ -265,6 +265,7 @@ func Online() Option { Override(new(dtypes.ClientDatastore), modules.NewClientDatastore), Override(new(dtypes.ClientDataTransfer), modules.NewClientGraphsyncDataTransfer), Override(new(dtypes.ClientRequestValidator), modules.NewClientRequestValidator), + Override(new(modules.ClientDealFunds), modules.NewClientDealFunds), Override(new(storagemarket.StorageClient), modules.StorageClient), Override(new(storagemarket.StorageClientNode), storageadapter.NewClientNodeAdapter), Override(RegisterClientValidatorKey, modules.RegisterClientValidator), @@ -308,6 +309,7 @@ func Online() Option { Override(new(dtypes.ProviderRequestValidator), modules.NewProviderRequestValidator), Override(new(dtypes.ProviderPieceStore), modules.NewProviderPieceStore), Override(new(*storedask.StoredAsk), modules.NewStorageAsk), + Override(new(modules.ProviderDealFunds), modules.NewProviderDealFunds), Override(new(storagemarket.StorageProvider), modules.StorageProvider), Override(new(storagemarket.StorageProviderNode), storageadapter.NewProviderNodeAdapter), Override(RegisterProviderValidatorKey, modules.RegisterProviderValidator), diff --git a/node/impl/full/state.go b/node/impl/full/state.go index c4228a90b..0951258b7 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1152,10 +1152,10 @@ var dealProviderCollateralDen = types.NewInt(100) // StateDealProviderCollateralBounds returns the min and max collateral a storage provider // can issue. It takes the deal size and verified status as parameters. -func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (abi.TokenAmount, abi.TokenAmount, error) { +func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error) { ts, err := a.Chain.GetTipSetFromKey(tsk) if err != nil { - return big.Zero(), big.Zero(), xerrors.Errorf("loading tipset %s: %w", tsk, err) + return api.DealCollateralBounds{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) } var powerState power.State @@ -1174,14 +1174,17 @@ func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size a }) if err != nil { - return big.Zero(), big.Zero(), xerrors.Errorf("getting power and reward actor states: %w") + return api.DealCollateralBounds{}, xerrors.Errorf("getting power and reward actor states: %w") } circ, err := a.StateManager.CirculatingSupply(ctx, ts) if err != nil { - return big.Zero(), big.Zero(), xerrors.Errorf("getting total circulating supply: %w") + return api.DealCollateralBounds{}, xerrors.Errorf("getting total circulating supply: %w") } min, max := market.DealProviderCollateralBounds(size, verified, powerState.ThisEpochQualityAdjPower, rewardState.ThisEpochBaselinePower, circ) - return types.BigDiv(types.BigMul(min, dealProviderCollateralNum), dealProviderCollateralDen), max, nil + return api.DealCollateralBounds{ + Min: types.BigDiv(types.BigMul(min, dealProviderCollateralNum), dealProviderCollateralDen), + Max: max, + }, nil } diff --git a/node/modules/client.go b/node/modules/client.go index 970466a8f..1bba07672 100644 --- a/node/modules/client.go +++ b/node/modules/client.go @@ -2,6 +2,7 @@ package modules import ( "context" + "github.com/filecoin-project/go-fil-markets/storagemarket/impl/funds" "time" "github.com/filecoin-project/go-multistore" @@ -112,9 +113,15 @@ func NewClientRequestValidator(deals dtypes.ClientDealStore) dtypes.ClientReques return requestvalidation.NewUnifiedRequestValidator(nil, deals) } -func StorageClient(lc fx.Lifecycle, h host.Host, ibs dtypes.ClientBlockstore, mds dtypes.ClientMultiDstore, r repo.LockedRepo, dataTransfer dtypes.ClientDataTransfer, discovery *discovery.Local, deals dtypes.ClientDatastore, scn storagemarket.StorageClientNode) (storagemarket.StorageClient, error) { +type ClientDealFunds funds.DealFunds + +func NewClientDealFunds(ds dtypes.MetadataDS) (ClientDealFunds, error) { + return funds.NewDealFunds(ds, datastore.NewKey("/marketfunds/client")) +} + +func StorageClient(lc fx.Lifecycle, h host.Host, ibs dtypes.ClientBlockstore, mds dtypes.ClientMultiDstore, r repo.LockedRepo, dataTransfer dtypes.ClientDataTransfer, discovery *discovery.Local, deals dtypes.ClientDatastore, scn storagemarket.StorageClientNode, dealFunds ClientDealFunds) (storagemarket.StorageClient, error) { net := smnet.NewFromLibp2pHost(h) - c, err := storageimpl.NewClient(net, ibs, mds, dataTransfer, discovery, deals, scn, storageimpl.DealPollingInterval(time.Second)) + c, err := storageimpl.NewClient(net, ibs, mds, dataTransfer, discovery, deals, scn, dealFunds, storageimpl.DealPollingInterval(time.Second)) if err != nil { return nil, err } diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index b28363eaf..a1ac7c8d2 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/filecoin-project/go-fil-markets/storagemarket/impl/funds" "net/http" "time" @@ -354,6 +355,12 @@ func NewStorageAsk(ctx helpers.MetricsCtx, fapi lapi.FullNode, ds dtypes.Metadat return storedAsk, nil } +type ProviderDealFunds funds.DealFunds + +func NewProviderDealFunds(ds dtypes.MetadataDS) (ProviderDealFunds, error) { + return funds.NewDealFunds(ds, datastore.NewKey("/marketfunds/provider")) +} + func StorageProvider(minerAddress dtypes.MinerAddress, ffiConfig *ffiwrapper.Config, storedAsk *storedask.StoredAsk, @@ -363,6 +370,7 @@ func StorageProvider(minerAddress dtypes.MinerAddress, pieceStore dtypes.ProviderPieceStore, dataTransfer dtypes.ProviderDataTransfer, spn storagemarket.StorageProviderNode, + funds ProviderDealFunds, onlineOk dtypes.ConsiderOnlineStorageDealsConfigFunc, offlineOk dtypes.ConsiderOfflineStorageDealsConfigFunc, blocklistFunc dtypes.StorageDealPieceCidBlocklistConfigFunc, @@ -425,7 +433,7 @@ func StorageProvider(minerAddress dtypes.MinerAddress, return true, "", nil }) - p, err := storageimpl.NewProvider(net, namespace.Wrap(ds, datastore.NewKey("/deals/provider")), store, mds, pieceStore, dataTransfer, spn, address.Address(minerAddress), ffiConfig.SealProofType, storedAsk, opt) + p, err := storageimpl.NewProvider(net, namespace.Wrap(ds, datastore.NewKey("/deals/provider")), store, mds, pieceStore, dataTransfer, spn, address.Address(minerAddress), ffiConfig.SealProofType, storedAsk, funds, opt) if err != nil { return p, err } diff --git a/storage/sealing.go b/storage/sealing.go index 3176017bf..1cbaa075c 100644 --- a/storage/sealing.go +++ b/storage/sealing.go @@ -16,7 +16,7 @@ func (m *Miner) Address() address.Address { return m.sealing.Address() } -func (m *Miner) AddPieceToAnySector(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, uint64, error) { +func (m *Miner) AddPieceToAnySector(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, abi.PaddedPieceSize, error) { return m.sealing.AddPieceToAnySector(ctx, size, r, d) } diff --git a/storage/sectorblocks/blocks.go b/storage/sectorblocks/blocks.go index af4fa52d2..a5d109cb4 100644 --- a/storage/sectorblocks/blocks.go +++ b/storage/sectorblocks/blocks.go @@ -96,18 +96,18 @@ func (st *SectorBlocks) writeRef(dealID abi.DealID, sectorID abi.SectorNumber, o return st.keys.Put(DealIDToDsKey(dealID), newRef) // TODO: batch somehow } -func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, error) { +func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, abi.PaddedPieceSize, error) { sn, offset, err := st.Miner.AddPieceToAnySector(ctx, size, r, d) if err != nil { - return 0, err + return 0, 0, err } - err = st.writeRef(d.DealID, sn, abi.PaddedPieceSize(offset), size) + err = st.writeRef(d.DealID, sn, offset, size) if err != nil { - return 0, xerrors.Errorf("writeRef: %w", err) + return 0, 0, xerrors.Errorf("writeRef: %w", err) } - return sn, nil + return sn, offset, nil } func (st *SectorBlocks) List() (map[uint64][]api.SealedRef, error) { From 0d0fa1e6704c29fcca3290bd6ba1a7c6ec8b16a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 30 Jul 2020 15:22:34 +0200 Subject: [PATCH 3/5] Update specs-actors more --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ee26180a5..63eec73a2 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72 - github.com/filecoin-project/specs-actors v0.8.2 + github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index ac262081d..b179a00fe 100644 --- a/go.sum +++ b/go.sum @@ -280,6 +280,8 @@ github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b h1 github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b/go.mod h1:U1qnlL3MjJnE6n3MTUUVhlmpJodx+fo26cC0aiL1jeo= github.com/filecoin-project/specs-actors v0.8.2 h1:fpAPOPqWqmzJCWHpm6P1XDRSpQrxyY5Pzh5H3doYs7Q= github.com/filecoin-project/specs-actors v0.8.2/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= +github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18 h1:MsmmBsGukA/Tl5SIRb+HPjJ1BcRPZ2yRJrWHBG5/Ia8= +github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 h1:Eg7Ia3iRWKMXpS7bU8ufarQJyGsBor7eGgfrAHfn8HA= From 8daef5aa239c09fbcdd2ca9d40e018b7ec6d74db Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Thu, 30 Jul 2020 16:36:21 -0400 Subject: [PATCH 4/5] Update chain-val and specs-actors some more --- go.mod | 4 ++-- go.sum | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 4bda2637f..2a4560c34 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/drand/drand v1.0.3-0.20200714175734-29705eaf09d4 github.com/drand/kyber v1.1.1 github.com/fatih/color v1.8.0 - github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd + github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012 github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200716204036-cddc56607e1d github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef github.com/filecoin-project/go-bitfield v0.1.2 @@ -30,7 +30,7 @@ require ( github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72 - github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18 + github.com/filecoin-project/specs-actors v0.8.4 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index d9ab9d654..9a222884b 100644 --- a/go.sum +++ b/go.sum @@ -216,14 +216,13 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY= github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8= github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= -github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd h1:XCZ50NipKQGYoyNwmt4QiCqXm72ePHhgzKtxZ5ziTUE= -github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd/go.mod h1:bcpE1fm7OlH1gak8hfSy7+IM/OaT3GW/XFsbDVp4Dfo= +github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012 h1:LktbQAVkBKZr8ZaB8IJApToI+vikN7dTFNc+w2lDGVA= +github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012/go.mod h1:vMsdZhZB0iI9OjIRPF4ku3f/nQGCj5+lzpsSABN+MWY= github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U= github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef/go.mod h1:SrA+pWVoUivqKOfC+ckVYbx41hWz++HxJcrlmHNnebU= github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg= -github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2 h1:jamfsxfK0Q9yCMHt8MPWx7Aa/O9k2Lve8eSc6FILYGQ= github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg= github.com/filecoin-project/go-amt-ipld/v2 v2.1.0 h1:t6qDiuGYYngDqaLc2ZUvdtAg4UNxPeOYaXhBWSNsVaM= github.com/filecoin-project/go-amt-ipld/v2 v2.1.0/go.mod h1:nfFPoGyX0CU9SkXX8EoCcSuHN1XcbN0c6KBh7yvP5fs= @@ -232,8 +231,6 @@ github.com/filecoin-project/go-bitfield v0.0.1/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4G github.com/filecoin-project/go-bitfield v0.0.3/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1 h1:xuHlrdznafh7ul5t4xEncnA4qgpQvJZEw+mr98eqHXw= github.com/filecoin-project/go-bitfield v0.0.4-0.20200703174658-f4a5758051a1/go.mod h1:Ry9/iUlWSyjPUzlAvdnfy4Gtvrq4kWmWDztCU1yEgJY= -github.com/filecoin-project/go-bitfield v0.1.1 h1:ioLGippGXLS93uBMbpSwVPD7h2Oz1FYq/WPYDfT7W/A= -github.com/filecoin-project/go-bitfield v0.1.1/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-bitfield v0.1.2 h1:TjLregCoyP1/5lm7WCM0axyV1myIHwbjGa21skuu5tk= github.com/filecoin-project/go-bitfield v0.1.2/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 h1:av5fw6wmm58FYMgJeoB/lK9XXrgdugYiTqkdxjTy9k8= @@ -274,14 +271,10 @@ github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72/go github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= github.com/filecoin-project/specs-actors v0.6.1/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= -github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6 h1:F+GcBdKPdW/wTv6bMJxG9Zj1dc0UGkO6uNOQmKP/g1o= github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6/go.mod h1:JOMUa7EijvpOO4ofD1yeHNmqohkmmnhTvz/IpB6so4c= -github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b h1:Tr34QNdGYMT2ghM6o1H1bMziTw/nWd/B2Um2A3vWp2c= -github.com/filecoin-project/specs-actors v0.8.1-0.20200728182452-1476088f645b/go.mod h1:U1qnlL3MjJnE6n3MTUUVhlmpJodx+fo26cC0aiL1jeo= -github.com/filecoin-project/specs-actors v0.8.2 h1:fpAPOPqWqmzJCWHpm6P1XDRSpQrxyY5Pzh5H3doYs7Q= github.com/filecoin-project/specs-actors v0.8.2/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= -github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18 h1:MsmmBsGukA/Tl5SIRb+HPjJ1BcRPZ2yRJrWHBG5/Ia8= -github.com/filecoin-project/specs-actors v0.8.3-0.20200730053202-8db2f79c9e18/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= +github.com/filecoin-project/specs-actors v0.8.4 h1:5vHNxPfRMqCYa6J/2feXOz6iKTencCwHjWC0iSx8kxg= +github.com/filecoin-project/specs-actors v0.8.4/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 h1:Eg7Ia3iRWKMXpS7bU8ufarQJyGsBor7eGgfrAHfn8HA= From c881f287ad38230b2908a5212e7e25d70f752ca5 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Fri, 31 Jul 2020 00:22:00 -0400 Subject: [PATCH 5/5] Update specs-actors and chain-val...again --- chain/events/state/predicates_test.go | 11 ++++++----- chain/vm/runtime.go | 6 ++---- go.mod | 6 +++--- go.sum | 12 ++++++------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/chain/events/state/predicates_test.go b/chain/events/state/predicates_test.go index a750d270e..02461c331 100644 --- a/chain/events/state/predicates_test.go +++ b/chain/events/state/predicates_test.go @@ -480,11 +480,12 @@ func newSectorOnChainInfo(sectorNo abi.SectorNumber, sealed cid.Cid, weight big. DealIDs: info.DealIDs, Expiration: info.Expiration, - Activation: activation, - DealWeight: weight, - VerifiedDealWeight: weight, - InitialPledge: big.Zero(), - ExpectedDayReward: big.Zero(), + Activation: activation, + DealWeight: weight, + VerifiedDealWeight: weight, + InitialPledge: big.Zero(), + ExpectedDayReward: big.Zero(), + ExpectedStoragePledge: big.Zero(), } } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index 8b5cfaa27..9985d4a73 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -462,7 +462,7 @@ func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) { ssh.rt.Get(act.Head, obj) } -func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) interface{} { +func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func()) { if obj == nil { ssh.rt.Abortf(exitcode.SysErrorIllegalActor, "Must not pass nil to Transaction()") } @@ -475,15 +475,13 @@ func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) in ssh.rt.Get(baseState, obj) ssh.rt.allowInternal = false - out := f() + f() ssh.rt.allowInternal = true c := ssh.rt.Put(obj) // TODO: handle error below ssh.rt.stateCommit(baseState, c) - - return out } func (rt *Runtime) GetBalance(a address.Address) (types.BigInt, aerrors.ActorError) { diff --git a/go.mod b/go.mod index 2a4560c34..79429fba3 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/drand/drand v1.0.3-0.20200714175734-29705eaf09d4 github.com/drand/kyber v1.1.1 github.com/fatih/color v1.8.0 - github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012 + github.com/filecoin-project/chain-validation v0.0.6-0.20200731041929-da61afa303ef github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200716204036-cddc56607e1d github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef github.com/filecoin-project/go-bitfield v0.1.2 @@ -23,14 +23,14 @@ require ( github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 github.com/filecoin-project/go-data-transfer v0.5.1 github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f - github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42 + github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730194453-26fac2c92927 github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 github.com/filecoin-project/go-multistore v0.0.2 github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200730102003-33dfb9a9cc72 - github.com/filecoin-project/specs-actors v0.8.4 + github.com/filecoin-project/specs-actors v0.8.5-0.20200731041117-72749bc1227e github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index 9a222884b..e7bf4c725 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY= github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8= github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= -github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012 h1:LktbQAVkBKZr8ZaB8IJApToI+vikN7dTFNc+w2lDGVA= -github.com/filecoin-project/chain-validation v0.0.6-0.20200730213252-57733b38e012/go.mod h1:vMsdZhZB0iI9OjIRPF4ku3f/nQGCj5+lzpsSABN+MWY= +github.com/filecoin-project/chain-validation v0.0.6-0.20200731041929-da61afa303ef h1:isZ3yMAr2VV4xQ5lVzIQvu/ZcfpdsoN2CqifgxDIObw= +github.com/filecoin-project/chain-validation v0.0.6-0.20200731041929-da61afa303ef/go.mod h1:pOhbirSuqudj2OYhFjto8r8Md2vVJqnA98o9OUbFZrg= github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U= @@ -242,8 +242,8 @@ github.com/filecoin-project/go-data-transfer v0.5.1/go.mod h1:PRs78hp9u8T4G2Jce5 github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5/go.mod h1:JbkIgFF/Z9BDlvrJO1FuKkaWsH673/UdFaiVS6uIHlA= github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f h1:GxJzR3oRIMTPtpZ0b7QF8FKPK6/iPAc7trhlL5k/g+s= github.com/filecoin-project/go-fil-commcid v0.0.0-20200716160307-8f644712406f/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= -github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42 h1:TPGmqX/9mUH/BBywG4GtNHqnrRunZLxRgBNrK40XpOs= -github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730055800-0acae26d3c42/go.mod h1:l0I1+rlKS5fSNj5cKdEj5inLWVsglKZm5fUYROmFgKY= +github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730194453-26fac2c92927 h1:RQSy3K/hDr82nuivR8JeLH8jEx3UUH/CrKtyTWnDS8A= +github.com/filecoin-project/go-fil-markets v0.5.3-0.20200730194453-26fac2c92927/go.mod h1:l0I1+rlKS5fSNj5cKdEj5inLWVsglKZm5fUYROmFgKY= github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 h1:Jc7vkplmZYVuaEcSXGHDwefvZIdoyyaoGDLqSr8Svms= github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24/go.mod h1:j6zV//WXIIY5kky873Q3iIKt/ViOE8rcijovmpxrXzM= github.com/filecoin-project/go-multistore v0.0.2 h1:JZEddnXXt3mMzHi7bi9IH7Yi1NpGLy19J5Lk/xbxBMs= @@ -273,8 +273,8 @@ github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVl github.com/filecoin-project/specs-actors v0.6.1/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= github.com/filecoin-project/specs-actors v0.7.3-0.20200716231407-60a2ae96d2e6/go.mod h1:JOMUa7EijvpOO4ofD1yeHNmqohkmmnhTvz/IpB6so4c= github.com/filecoin-project/specs-actors v0.8.2/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= -github.com/filecoin-project/specs-actors v0.8.4 h1:5vHNxPfRMqCYa6J/2feXOz6iKTencCwHjWC0iSx8kxg= -github.com/filecoin-project/specs-actors v0.8.4/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= +github.com/filecoin-project/specs-actors v0.8.5-0.20200731041117-72749bc1227e h1:fHlYK4tSzO+qA0wPLplocHn92bhEm5aAtWjqWFToDHQ= +github.com/filecoin-project/specs-actors v0.8.5-0.20200731041117-72749bc1227e/go.mod h1:Q3ACV5kBLvqPaYbthc/J1lGMJ5OwogmD9pzdtPRMdCw= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/storage-fsm v0.0.0-20200730122205-d423ae90d8d4 h1:Eg7Ia3iRWKMXpS7bU8ufarQJyGsBor7eGgfrAHfn8HA=