Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/v10/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v10/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -277,8 +277,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
2 changes: 1 addition & 1 deletion builtin/v11/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v11/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -277,8 +277,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
2 changes: 1 addition & 1 deletion builtin/v12/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v12/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -284,8 +284,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
2 changes: 1 addition & 1 deletion builtin/v13/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v13/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -284,8 +284,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
2 changes: 1 addition & 1 deletion builtin/v14/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v14/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -284,8 +284,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
2 changes: 1 addition & 1 deletion builtin/v15/miner/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
acc.Addf("error loading vesting funds: %v", err)
} else {
quant := st.QuantSpecEveryDeadline()
for _, entry := range funds.Funds {
for _, entry := range funds {
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
vestingSum = big.Add(vestingSum, entry.Amount)

Expand Down
8 changes: 4 additions & 4 deletions builtin/v15/miner/miner_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
}

// LoadVestingFunds loads the vesting funds table from the store
func (st *State) LoadVestingFunds(store adt.Store) (*VestingFunds, error) {
func (st *State) LoadVestingFunds(store adt.Store) ([]VestingFund, error) {
var funds VestingFunds
if err := store.Get(store.Context(), st.VestingFunds, &funds); err != nil {
return nil, xerrors.Errorf("failed to load vesting funds (%s): %w", st.VestingFunds, err)
}

return &funds, nil
return funds.Funds, nil
}

// CheckVestedFunds returns the amount of vested funds that have vested before the provided epoch.
Expand All @@ -284,8 +284,8 @@ func (st *State) CheckVestedFunds(store adt.Store, currEpoch abi.ChainEpoch) (ab

amountVested := abi.NewTokenAmount(0)

for i := range vestingFunds.Funds {
vf := vestingFunds.Funds[i]
for i := range vestingFunds {
vf := vestingFunds[i]
epoch := vf.Epoch
amount := vf.Amount

Expand Down
1 change: 1 addition & 0 deletions builtin/v16/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func main() {
miner.SectorPreCommitInfo{},
miner.SectorOnChainInfo{},
miner.WorkerKeyChange{},
miner.VestingFundsTail{},
miner.VestingFunds{},
miner.VestingFund{},
miner.WindowedPoSt{},
Expand Down
31 changes: 30 additions & 1 deletion builtin/v16/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

miner15 "github.com/filecoin-project/go-state-types/builtin/v15/miner"
miner16 "github.com/filecoin-project/go-state-types/builtin/v16/miner"
adt16 "github.com/filecoin-project/go-state-types/builtin/v16/util/adt"
"github.com/filecoin-project/go-state-types/migration"
)

Expand All @@ -28,12 +29,14 @@ func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
return nil, xerrors.Errorf("failed to load miner state for %s: %w", in.Address, err)
}

adtStore := adt16.WrapStore(ctx, store)

// Create the new state (v16) with VestingFunds set to nil.
outState := miner16.State{
Info: inState.Info,
PreCommitDeposits: inState.PreCommitDeposits,
LockedFunds: inState.LockedFunds,
VestingFunds: inState.VestingFunds,
VestingFunds: nil,
FeeDebt: inState.FeeDebt,
InitialPledge: inState.InitialPledge,
PreCommittedSectors: inState.PreCommittedSectors,
Expand All @@ -47,6 +50,32 @@ func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
DeadlineCronActive: inState.DeadlineCronActive,
}

oldVestingFunds, err := inState.LoadVestingFunds(adtStore)
if err != nil {
return nil, xerrors.Errorf("failed to load vesting funds for %s: %w", in.Address, err)
}

newVestingFunds := make([]miner16.VestingFund, len(oldVestingFunds))
for i, oldVestingFund := range oldVestingFunds {
newVestingFunds[i] = miner16.VestingFund{
Epoch: oldVestingFund.Epoch,
Amount: oldVestingFund.Amount,
}
}

if len(newVestingFunds) > 0 {
head := newVestingFunds[0]
tail := newVestingFunds[1:]
tailCid, err := store.Put(ctx, &miner16.VestingFundsTail{Funds: tail})
if err != nil {
return nil, xerrors.Errorf("failed to persist vesting funds tail for %s: %w", in.Address, err)
}
outState.VestingFunds = &miner16.VestingFunds{
Head: head,
Tail: tailCid,
}
}

// Store the new state.
newHead, err := store.Put(ctx, &outState)
if err != nil {
Expand Down
Loading
Loading