Skip to content

Commit d0d2748

Browse files
authored
fip-0100: update the vesting funds types to the new layout (#353)
I've also changed the `LoadVestingFunds` to return a `[]VestingFund` so we can abstract across the different underlying representations. related to filecoin-project/builtin-actors#1636
1 parent 4dea053 commit d0d2748

File tree

23 files changed

+195
-106
lines changed

23 files changed

+195
-106
lines changed

builtin/v10/miner/invariants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
757757
acc.Addf("error loading vesting funds: %v", err)
758758
} else {
759759
quant := st.QuantSpecEveryDeadline()
760-
for _, entry := range funds.Funds {
760+
for _, entry := range funds {
761761
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
762762
vestingSum = big.Add(vestingSum, entry.Amount)
763763

builtin/v10/miner/miner_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
259259
}
260260

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

268-
return &funds, nil
268+
return funds.Funds, nil
269269
}
270270

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

278278
amountVested := abi.NewTokenAmount(0)
279279

280-
for i := range vestingFunds.Funds {
281-
vf := vestingFunds.Funds[i]
280+
for i := range vestingFunds {
281+
vf := vestingFunds[i]
282282
epoch := vf.Epoch
283283
amount := vf.Amount
284284

builtin/v11/miner/invariants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
757757
acc.Addf("error loading vesting funds: %v", err)
758758
} else {
759759
quant := st.QuantSpecEveryDeadline()
760-
for _, entry := range funds.Funds {
760+
for _, entry := range funds {
761761
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
762762
vestingSum = big.Add(vestingSum, entry.Amount)
763763

builtin/v11/miner/miner_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
259259
}
260260

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

268-
return &funds, nil
268+
return funds.Funds, nil
269269
}
270270

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

278278
amountVested := abi.NewTokenAmount(0)
279279

280-
for i := range vestingFunds.Funds {
281-
vf := vestingFunds.Funds[i]
280+
for i := range vestingFunds {
281+
vf := vestingFunds[i]
282282
epoch := vf.Epoch
283283
amount := vf.Amount
284284

builtin/v12/miner/invariants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
759759
acc.Addf("error loading vesting funds: %v", err)
760760
} else {
761761
quant := st.QuantSpecEveryDeadline()
762-
for _, entry := range funds.Funds {
762+
for _, entry := range funds {
763763
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
764764
vestingSum = big.Add(vestingSum, entry.Amount)
765765

builtin/v12/miner/miner_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
266266
}
267267

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

275-
return &funds, nil
275+
return funds.Funds, nil
276276
}
277277

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

285285
amountVested := abi.NewTokenAmount(0)
286286

287-
for i := range vestingFunds.Funds {
288-
vf := vestingFunds.Funds[i]
287+
for i := range vestingFunds {
288+
vf := vestingFunds[i]
289289
epoch := vf.Epoch
290290
amount := vf.Amount
291291

builtin/v13/miner/invariants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
755755
acc.Addf("error loading vesting funds: %v", err)
756756
} else {
757757
quant := st.QuantSpecEveryDeadline()
758-
for _, entry := range funds.Funds {
758+
for _, entry := range funds {
759759
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
760760
vestingSum = big.Add(vestingSum, entry.Amount)
761761

builtin/v13/miner/miner_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
266266
}
267267

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

275-
return &funds, nil
275+
return funds.Funds, nil
276276
}
277277

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

285285
amountVested := abi.NewTokenAmount(0)
286286

287-
for i := range vestingFunds.Funds {
288-
vf := vestingFunds.Funds[i]
287+
for i := range vestingFunds {
288+
vf := vestingFunds[i]
289289
epoch := vf.Epoch
290290
amount := vf.Amount
291291

builtin/v14/miner/invariants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ func CheckMinerBalances(st *State, store adt.Store, balance abi.TokenAmount, acc
755755
acc.Addf("error loading vesting funds: %v", err)
756756
} else {
757757
quant := st.QuantSpecEveryDeadline()
758-
for _, entry := range funds.Funds {
758+
for _, entry := range funds {
759759
acc.Require(entry.Amount.GreaterThan(big.Zero()), "non-positive amount in miner vesting table entry %v", entry)
760760
vestingSum = big.Add(vestingSum, entry.Amount)
761761

builtin/v14/miner/miner_state.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,13 @@ func (st *State) SaveDeadlines(store adt.Store, deadlines *Deadlines) error {
266266
}
267267

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

275-
return &funds, nil
275+
return funds.Funds, nil
276276
}
277277

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

285285
amountVested := abi.NewTokenAmount(0)
286286

287-
for i := range vestingFunds.Funds {
288-
vf := vestingFunds.Funds[i]
287+
for i := range vestingFunds {
288+
vf := vestingFunds[i]
289289
epoch := vf.Epoch
290290
amount := vf.Amount
291291

0 commit comments

Comments
 (0)