Merge pull request #7811 from filecoin-project/asr/vm-circ
VM: Circ supply should be constant per epoch
This commit is contained in:
commit
927448601c
@ -479,6 +479,10 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca
|
|||||||
verifNeeds := make(map[address.Address]abi.PaddedPieceSize)
|
verifNeeds := make(map[address.Address]abi.PaddedPieceSize)
|
||||||
var sum abi.PaddedPieceSize
|
var sum abi.PaddedPieceSize
|
||||||
|
|
||||||
|
csc := func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error) {
|
||||||
|
return big.Zero(), nil
|
||||||
|
}
|
||||||
|
|
||||||
vmopt := vm.VMOpts{
|
vmopt := vm.VMOpts{
|
||||||
StateBase: stateroot,
|
StateBase: stateroot,
|
||||||
Epoch: 0,
|
Epoch: 0,
|
||||||
@ -486,7 +490,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca
|
|||||||
Bstore: cs.StateBlockstore(),
|
Bstore: cs.StateBlockstore(),
|
||||||
Actors: filcns.NewActorRegistry(),
|
Actors: filcns.NewActorRegistry(),
|
||||||
Syscalls: mkFakedSigSyscalls(sys),
|
Syscalls: mkFakedSigSyscalls(sys),
|
||||||
CircSupplyCalc: nil,
|
CircSupplyCalc: csc,
|
||||||
NtwkVersion: func(_ context.Context, _ abi.ChainEpoch) network.Version {
|
NtwkVersion: func(_ context.Context, _ abi.ChainEpoch) network.Version {
|
||||||
return nv
|
return nv
|
||||||
},
|
},
|
||||||
|
@ -202,9 +202,7 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type VM struct {
|
type VM struct {
|
||||||
cstate *state.StateTree
|
cstate *state.StateTree
|
||||||
// TODO: Is base actually used? Can we delete it?
|
|
||||||
base cid.Cid
|
|
||||||
cst *cbor.BasicIpldStore
|
cst *cbor.BasicIpldStore
|
||||||
buf *blockstore.BufferedBlockstore
|
buf *blockstore.BufferedBlockstore
|
||||||
blockHeight abi.ChainEpoch
|
blockHeight abi.ChainEpoch
|
||||||
@ -214,6 +212,7 @@ type VM struct {
|
|||||||
ntwkVersion NtwkVersionGetter
|
ntwkVersion NtwkVersionGetter
|
||||||
baseFee abi.TokenAmount
|
baseFee abi.TokenAmount
|
||||||
lbStateGet LookbackStateGetter
|
lbStateGet LookbackStateGetter
|
||||||
|
baseCircSupply abi.TokenAmount
|
||||||
|
|
||||||
Syscalls SyscallBuilder
|
Syscalls SyscallBuilder
|
||||||
}
|
}
|
||||||
@ -239,9 +238,13 @@ func NewVM(ctx context.Context, opts *VMOpts) (*VM, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseCirc, err := opts.CircSupplyCalc(ctx, opts.Epoch, state)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &VM{
|
return &VM{
|
||||||
cstate: state,
|
cstate: state,
|
||||||
base: opts.StateBase,
|
|
||||||
cst: cst,
|
cst: cst,
|
||||||
buf: buf,
|
buf: buf,
|
||||||
blockHeight: opts.Epoch,
|
blockHeight: opts.Epoch,
|
||||||
@ -251,6 +254,7 @@ func NewVM(ctx context.Context, opts *VMOpts) (*VM, error) {
|
|||||||
ntwkVersion: opts.NtwkVersion,
|
ntwkVersion: opts.NtwkVersion,
|
||||||
Syscalls: opts.Syscalls,
|
Syscalls: opts.Syscalls,
|
||||||
baseFee: opts.BaseFee,
|
baseFee: opts.BaseFee,
|
||||||
|
baseCircSupply: baseCirc,
|
||||||
lbStateGet: opts.LookbackState,
|
lbStateGet: opts.LookbackState,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -859,7 +863,12 @@ func (vm *VM) GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) network.Ver
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error) {
|
func (vm *VM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error) {
|
||||||
return vm.circSupplyCalc(ctx, vm.blockHeight, vm.cstate)
|
// Before v15, this was recalculated on each invocation as the state tree was mutated
|
||||||
|
if vm.GetNtwkVersion(ctx, vm.blockHeight) <= network.Version14 {
|
||||||
|
return vm.circSupplyCalc(ctx, vm.blockHeight, vm.cstate)
|
||||||
|
}
|
||||||
|
|
||||||
|
return vm.baseCircSupply, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) incrementNonce(addr address.Address) error {
|
func (vm *VM) incrementNonce(addr address.Address) error {
|
||||||
|
@ -153,6 +153,14 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
|
|||||||
results: []*vm.ApplyRet{},
|
results: []*vm.ApplyRet{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) {
|
||||||
|
vmopt.CircSupplyCalc = func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error) {
|
||||||
|
return big.Zero(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return vm.NewVM(ctx, vmopt)
|
||||||
|
})
|
||||||
|
|
||||||
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
|
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
|
||||||
sm,
|
sm,
|
||||||
params.ParentEpoch,
|
params.ParentEpoch,
|
||||||
|
Loading…
Reference in New Issue
Block a user