-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add funds that have left FilReserve to circ supply #4160
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1171,14 +1171,27 @@ func (sm *StateManager) GetFilVested(ctx context.Context, height abi.ChainEpoch, | |
} | ||
} | ||
|
||
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch | ||
vf = big.Add(vf, sm.preIgnitionGenInfos.genesisPledge) | ||
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch | ||
vf = big.Add(vf, sm.preIgnitionGenInfos.genesisMarketFunds) | ||
// After UpgradeActorsV2Height these funds are accounted for in GetFilReserveDisbursed | ||
if height <= build.UpgradeActorsV2Height { | ||
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch | ||
vf = big.Add(vf, sm.preIgnitionGenInfos.genesisPledge) | ||
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch | ||
vf = big.Add(vf, sm.preIgnitionGenInfos.genesisMarketFunds) | ||
} | ||
|
||
return vf, nil | ||
} | ||
|
||
func GetFilReserveDisbursed(ctx context.Context, st *state.StateTree) (abi.TokenAmount, error) { | ||
ract, err := st.GetActor(builtin.ReserveAddress) | ||
if err != nil { | ||
return big.Zero(), xerrors.Errorf("failed to get reserve actor: %w", err) | ||
} | ||
|
||
// If money enters the reserve actor, this could lead to a negative term | ||
return big.Sub(big.NewFromGo(build.InitialFilReserved), ract.Balance), nil | ||
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. It is unclear which variable (there are two of the same name) 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. Yeah, it's using the right one (the other one will be used for testground). |
||
} | ||
|
||
func GetFilMined(ctx context.Context, st *state.StateTree) (abi.TokenAmount, error) { | ||
ractor, err := st.GetActor(reward.Address) | ||
if err != nil { | ||
|
@@ -1266,6 +1279,14 @@ func (sm *StateManager) GetCirculatingSupplyDetailed(ctx context.Context, height | |
return api.CirculatingSupply{}, xerrors.Errorf("failed to calculate filVested: %w", err) | ||
} | ||
|
||
filReserveDisbursed := big.Zero() | ||
if height > build.UpgradeActorsV2Height { | ||
filReserveDisbursed, err = GetFilReserveDisbursed(ctx, st) | ||
if err != nil { | ||
return api.CirculatingSupply{}, xerrors.Errorf("failed to calculate filReserveDisbursed: %w", err) | ||
} | ||
} | ||
|
||
filMined, err := GetFilMined(ctx, st) | ||
if err != nil { | ||
return api.CirculatingSupply{}, xerrors.Errorf("failed to calculate filMined: %w", err) | ||
|
@@ -1282,6 +1303,7 @@ func (sm *StateManager) GetCirculatingSupplyDetailed(ctx context.Context, height | |
} | ||
|
||
ret := types.BigAdd(filVested, filMined) | ||
ret = types.BigAdd(ret, filReserveDisbursed) | ||
ret = types.BigSub(ret, filBurnt) | ||
ret = types.BigSub(ret, filLocked) | ||
|
||
|
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.
Why do we not need to add genesisPledge after Ignition epoch?
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.
I might be wrong, but I assumed that these funds will now be accounted for in "what's missing from FilReserve", since that's where they came from originally? Is that not the case?