Calculate new actor addresses as per updated spec
This commit is contained in:
parent
7b69697439
commit
ef288b8a6c
@ -44,8 +44,7 @@ type Runtime struct {
|
|||||||
originNonce uint64
|
originNonce uint64
|
||||||
|
|
||||||
internalExecutions []*ExecutionResult
|
internalExecutions []*ExecutionResult
|
||||||
// the first internal call has a value of 1 for this field
|
numActorsCreated uint64
|
||||||
internalCallCounter int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Runtime) ResolveAddress(address address.Address) (ret address.Address, ok bool) {
|
func (rs *Runtime) ResolveAddress(address address.Address) (ret address.Address, ok bool) {
|
||||||
@ -166,7 +165,7 @@ func (rt *Runtime) NewActorAddress() address.Address {
|
|||||||
if err := binary.Write(&b, binary.BigEndian, rt.originNonce); err != nil {
|
if err := binary.Write(&b, binary.BigEndian, rt.originNonce); err != nil {
|
||||||
rt.Abortf(exitcode.ErrSerialization, "writing nonce address into a buffer: %v", err)
|
rt.Abortf(exitcode.ErrSerialization, "writing nonce address into a buffer: %v", err)
|
||||||
}
|
}
|
||||||
if err := binary.Write(&b, binary.BigEndian, rt.internalCallCounter); err != nil { // TODO: expose on vm
|
if err := binary.Write(&b, binary.BigEndian, rt.numActorsCreated); err != nil { // TODO: expose on vm
|
||||||
rt.Abortf(exitcode.ErrSerialization, "writing callSeqNum address into a buffer: %v", err)
|
rt.Abortf(exitcode.ErrSerialization, "writing callSeqNum address into a buffer: %v", err)
|
||||||
}
|
}
|
||||||
addr, err := address.NewActorAddress(b.Bytes())
|
addr, err := address.NewActorAddress(b.Bytes())
|
||||||
@ -174,6 +173,7 @@ func (rt *Runtime) NewActorAddress() address.Address {
|
|||||||
rt.Abortf(exitcode.ErrSerialization, "create actor address: %v", err)
|
rt.Abortf(exitcode.ErrSerialization, "create actor address: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rt.incrementNumActorsCreated()
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ func (rt *Runtime) internalSend(to address.Address, method abi.MethodNum, value
|
|||||||
|
|
||||||
if subrt != nil {
|
if subrt != nil {
|
||||||
er.Subcalls = subrt.internalExecutions
|
er.Subcalls = subrt.internalExecutions
|
||||||
rt.internalCallCounter = subrt.internalCallCounter
|
rt.numActorsCreated = subrt.numActorsCreated
|
||||||
}
|
}
|
||||||
rt.internalExecutions = append(rt.internalExecutions, &er)
|
rt.internalExecutions = append(rt.internalExecutions, &er)
|
||||||
return ret, errSend
|
return ret, errSend
|
||||||
@ -438,3 +438,7 @@ func (rt *Runtime) chargeGasSafe(toUse int64) aerrors.ActorError {
|
|||||||
func (rt *Runtime) Pricelist() Pricelist {
|
func (rt *Runtime) Pricelist() Pricelist {
|
||||||
return rt.pricelist
|
return rt.pricelist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rt *Runtime) incrementNumActorsCreated() {
|
||||||
|
rt.numActorsCreated++
|
||||||
|
}
|
||||||
|
@ -115,7 +115,7 @@ func (bs *gasChargingBlocks) Put(blk block.Block) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, icc int64) *Runtime {
|
func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, nac uint64) *Runtime {
|
||||||
rt := &Runtime{
|
rt := &Runtime{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
vm: vm,
|
vm: vm,
|
||||||
@ -125,10 +125,10 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
|
|||||||
originNonce: originNonce,
|
originNonce: originNonce,
|
||||||
height: vm.blockHeight,
|
height: vm.blockHeight,
|
||||||
|
|
||||||
gasUsed: usedGas,
|
gasUsed: usedGas,
|
||||||
gasAvailable: msg.GasLimit,
|
gasAvailable: msg.GasLimit,
|
||||||
internalCallCounter: icc,
|
numActorsCreated: nac,
|
||||||
pricelist: PricelistByEpoch(vm.blockHeight),
|
pricelist: PricelistByEpoch(vm.blockHeight),
|
||||||
}
|
}
|
||||||
rt.cst = &cbor.BasicIpldStore{
|
rt.cst = &cbor.BasicIpldStore{
|
||||||
Blocks: &gasChargingBlocks{rt.ChargeGas, rt.pricelist, vm.cst.Blocks},
|
Blocks: &gasChargingBlocks{rt.ChargeGas, rt.pricelist, vm.cst.Blocks},
|
||||||
@ -216,14 +216,14 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
|||||||
|
|
||||||
origin := msg.From
|
origin := msg.From
|
||||||
on := msg.Nonce
|
on := msg.Nonce
|
||||||
var icc int64 = 0
|
var nac uint64 = 0
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
gasUsed = parent.gasUsed + gasUsed
|
gasUsed = parent.gasUsed + gasUsed
|
||||||
origin = parent.origin
|
origin = parent.origin
|
||||||
on = parent.originNonce
|
on = parent.originNonce
|
||||||
icc = parent.internalCallCounter + 1
|
nac = parent.numActorsCreated
|
||||||
}
|
}
|
||||||
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, icc)
|
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
parent.gasUsed = rt.gasUsed
|
parent.gasUsed = rt.gasUsed
|
||||||
|
Loading…
Reference in New Issue
Block a user