Merge pull request from filecoin-project/asr/drop-genesis-marketfund

feat: stmgr: speed up calculation of genesis circ supply
This commit is contained in:
Aayush Rajasekaran 2023-03-23 17:34:17 -04:00 committed by GitHub
commit 2cd3a052e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 14 deletions

View File

@ -131,8 +131,7 @@ type StateManager struct {
postIgnitionVesting []msig0.State postIgnitionVesting []msig0.State
postCalicoVesting []msig0.State postCalicoVesting []msig0.State
genesisPledge abi.TokenAmount genesisPledge abi.TokenAmount
genesisMarketFunds abi.TokenAmount
tsExec Executor tsExec Executor
tsExecMonitor ExecMonitor tsExecMonitor ExecMonitor

View File

@ -51,17 +51,13 @@ func (sm *StateManager) setupGenesisVestingSchedule(ctx context.Context) error {
return xerrors.Errorf("loading state tree: %w", err) return xerrors.Errorf("loading state tree: %w", err)
} }
gmf, err := getFilMarketLocked(ctx, sTree)
if err != nil {
return xerrors.Errorf("setting up genesis market funds: %w", err)
}
gp, err := getFilPowerLocked(ctx, sTree) gp, err := getFilPowerLocked(ctx, sTree)
if err != nil { if err != nil {
return xerrors.Errorf("setting up genesis pledge: %w", err) return xerrors.Errorf("setting up genesis pledge: %w", err)
} }
sm.genesisMarketFunds = gmf sm.genesisMsigLk.Lock()
defer sm.genesisMsigLk.Unlock()
sm.genesisPledge = gp sm.genesisPledge = gp
totalsByEpoch := make(map[abi.ChainEpoch]abi.TokenAmount) totalsByEpoch := make(map[abi.ChainEpoch]abi.TokenAmount)
@ -128,6 +124,8 @@ func (sm *StateManager) setupPostIgnitionVesting(ctx context.Context) error {
totalsByEpoch[sixYears] = big.NewInt(100_000_000) totalsByEpoch[sixYears] = big.NewInt(100_000_000)
totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(300_000_000)) totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(300_000_000))
sm.genesisMsigLk.Lock()
defer sm.genesisMsigLk.Unlock()
sm.postIgnitionVesting = make([]msig0.State, 0, len(totalsByEpoch)) sm.postIgnitionVesting = make([]msig0.State, 0, len(totalsByEpoch))
for k, v := range totalsByEpoch { for k, v := range totalsByEpoch {
ns := msig0.State{ ns := msig0.State{
@ -178,6 +176,9 @@ func (sm *StateManager) setupPostCalicoVesting(ctx context.Context) error {
totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(300_000_000)) totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(300_000_000))
totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(9_805_053)) totalsByEpoch[sixYears] = big.Add(totalsByEpoch[sixYears], big.NewInt(9_805_053))
sm.genesisMsigLk.Lock()
defer sm.genesisMsigLk.Unlock()
sm.postCalicoVesting = make([]msig0.State, 0, len(totalsByEpoch)) sm.postCalicoVesting = make([]msig0.State, 0, len(totalsByEpoch))
for k, v := range totalsByEpoch { for k, v := range totalsByEpoch {
ns := msig0.State{ ns := msig0.State{
@ -198,21 +199,20 @@ func (sm *StateManager) setupPostCalicoVesting(ctx context.Context) error {
func (sm *StateManager) GetFilVested(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error) { func (sm *StateManager) GetFilVested(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error) {
vf := big.Zero() vf := big.Zero()
sm.genesisMsigLk.Lock()
defer sm.genesisMsigLk.Unlock()
// TODO: combine all this? // TODO: combine all this?
if sm.preIgnitionVesting == nil || sm.genesisPledge.IsZero() || sm.genesisMarketFunds.IsZero() { if sm.preIgnitionVesting == nil || sm.genesisPledge.IsZero() {
err := sm.setupGenesisVestingSchedule(ctx) err := sm.setupGenesisVestingSchedule(ctx)
if err != nil { if err != nil {
return vf, xerrors.Errorf("failed to setup pre-ignition vesting schedule: %w", err) return vf, xerrors.Errorf("failed to setup pre-ignition vesting schedule: %w", err)
} }
} }
if sm.postIgnitionVesting == nil { if sm.postIgnitionVesting == nil {
err := sm.setupPostIgnitionVesting(ctx) err := sm.setupPostIgnitionVesting(ctx)
if err != nil { if err != nil {
return vf, xerrors.Errorf("failed to setup post-ignition vesting schedule: %w", err) return vf, xerrors.Errorf("failed to setup post-ignition vesting schedule: %w", err)
} }
} }
if sm.postCalicoVesting == nil { if sm.postCalicoVesting == nil {
err := sm.setupPostCalicoVesting(ctx) err := sm.setupPostCalicoVesting(ctx)
@ -246,8 +246,6 @@ func (sm *StateManager) GetFilVested(ctx context.Context, height abi.ChainEpoch)
if height <= build.UpgradeAssemblyHeight { if height <= build.UpgradeAssemblyHeight {
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch // continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch
vf = big.Add(vf, sm.genesisPledge) vf = big.Add(vf, sm.genesisPledge)
// continue to use preIgnitionGenInfos, nothing changed at the Ignition epoch
vf = big.Add(vf, sm.genesisMarketFunds)
} }
return vf, nil return vf, nil