Lock before setting up genesis msigs
This commit is contained in:
parent
0b1d80d3e3
commit
890f56ac38
@ -49,13 +49,13 @@ var (
|
|||||||
TicketRandomnessLookback = abi.ChainEpoch(1)
|
TicketRandomnessLookback = abi.ChainEpoch(1)
|
||||||
WinningPoStSectorSetLookback = abi.ChainEpoch(10)
|
WinningPoStSectorSetLookback = abi.ChainEpoch(10)
|
||||||
|
|
||||||
TotalFilecoin uint64 = 2_000_000_000
|
FilBase uint64 = 2_000_000_000
|
||||||
MiningRewardTotal uint64 = 1_400_000_000
|
FilAllocStorageMining uint64 = 1_400_000_000
|
||||||
|
|
||||||
FilecoinPrecision uint64 = 1_000_000_000_000_000_000
|
FilecoinPrecision uint64 = 1_000_000_000_000_000_000
|
||||||
|
|
||||||
InitialRewardBalance = func() *big.Int {
|
InitialRewardBalance = func() *big.Int {
|
||||||
v := big.NewInt(int64(MiningRewardTotal))
|
v := big.NewInt(int64(FilAllocStorageMining))
|
||||||
v = v.Mul(v, big.NewInt(int64(FilecoinPrecision)))
|
v = v.Mul(v, big.NewInt(int64(FilecoinPrecision)))
|
||||||
return v
|
return v
|
||||||
}()
|
}()
|
||||||
|
@ -36,11 +36,12 @@ var log = logging.Logger("statemgr")
|
|||||||
type StateManager struct {
|
type StateManager struct {
|
||||||
cs *store.ChainStore
|
cs *store.ChainStore
|
||||||
|
|
||||||
stCache map[string][]cid.Cid
|
stCache map[string][]cid.Cid
|
||||||
compWait map[string]chan struct{}
|
compWait map[string]chan struct{}
|
||||||
stlk sync.Mutex
|
stlk sync.Mutex
|
||||||
newVM func(cid.Cid, abi.ChainEpoch, vm.Rand, blockstore.Blockstore, vm.SyscallBuilder, vm.VestedCalculator) (*vm.VM, error)
|
genesisMsigLk sync.Mutex
|
||||||
genesisMsigs []multisig.State
|
newVM func(cid.Cid, abi.ChainEpoch, vm.Rand, blockstore.Blockstore, vm.SyscallBuilder, vm.VestedCalculator) (*vm.VM, error)
|
||||||
|
genesisMsigs []multisig.State
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStateManager(cs *store.ChainStore) *StateManager {
|
func NewStateManager(cs *store.ChainStore) *StateManager {
|
||||||
@ -852,7 +853,8 @@ func (sm *StateManager) setupGenesisMsigs(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StateManager) GetVestedFunds(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error) {
|
func (sm *StateManager) GetVestedFunds(ctx context.Context, height abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||||
|
sm.genesisMsigLk.Lock()
|
||||||
|
defer sm.genesisMsigLk.Unlock()
|
||||||
if sm.genesisMsigs == nil {
|
if sm.genesisMsigs == nil {
|
||||||
err := sm.setupGenesisMsigs(ctx)
|
err := sm.setupGenesisMsigs(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,6 +73,9 @@ func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filMined := types.BigSub(types.FromFil(build.FilAllocStorageMining), rew.Balance)
|
filMined := types.BigSub(types.FromFil(build.FilAllocStorageMining), rew.Balance)
|
||||||
|
if filMined.LessThan(big.Zero()) {
|
||||||
|
filMined = big.Zero()
|
||||||
|
}
|
||||||
|
|
||||||
burnt, err := rt.state.GetActor(builtin.BurntFundsActorAddr)
|
burnt, err := rt.state.GetActor(builtin.BurntFundsActorAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -109,6 +112,10 @@ func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount {
|
|||||||
ret := types.BigAdd(filVested, filMined)
|
ret := types.BigAdd(filVested, filMined)
|
||||||
ret = types.BigSub(ret, filBurned)
|
ret = types.BigSub(ret, filBurned)
|
||||||
ret = types.BigSub(ret, filLocked)
|
ret = types.BigSub(ret, filLocked)
|
||||||
|
|
||||||
|
if ret.LessThan(big.Zero()) {
|
||||||
|
ret = big.Zero()
|
||||||
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user