Only resolve origin to pubkey address when creating a new account actor

This commit is contained in:
Aayush Rajasekaran 2020-03-24 04:43:09 -04:00
parent 753e8ff7f5
commit df13cfa52b
2 changed files with 3 additions and 16 deletions

View File

@ -159,7 +159,8 @@ func (rs *Runtime) Store() vmr.Store {
func (rt *Runtime) NewActorAddress() address.Address { func (rt *Runtime) NewActorAddress() address.Address {
var b bytes.Buffer var b bytes.Buffer
if err := rt.origin.MarshalCBOR(&b); err != nil { // todo: spec says cbor; why not just bytes? oa, _ := ResolveToKeyAddr(rt.vm.cstate, rt.vm.cst, rt.origin)
if err := oa.MarshalCBOR(&b); err != nil { // todo: spec says cbor; why not just bytes?
rt.Abortf(exitcode.ErrSerialization, "writing caller address into a buffer: %v", err) rt.Abortf(exitcode.ErrSerialization, "writing caller address into a buffer: %v", err)
} }

View File

@ -66,14 +66,6 @@ type ExecutionResult struct {
// Send allows the current execution context to invoke methods on other actors in the system // Send allows the current execution context to invoke methods on other actors in the system
func ResolveToStableAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) {
if addr == builtin.SystemActorAddr {
return addr, nil
}
return ResolveToKeyAddr(state, cst, addr)
}
// ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`. // ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`.
func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) { func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, aerrors.ActorError) {
if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 { if addr.Protocol() == address.BLS || addr.Protocol() == address.SECP256K1 {
@ -202,7 +194,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
st := vm.cstate st := vm.cstate
gasUsed := gasCharge gasUsed := gasCharge
var origin address.Address origin := msg.From
on := msg.Nonce on := msg.Nonce
var nac uint64 = 0 var nac uint64 = 0
if parent != nil { if parent != nil {
@ -210,12 +202,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
origin = parent.origin origin = parent.origin
on = parent.originNonce on = parent.originNonce
nac = parent.numActorsCreated nac = parent.numActorsCreated
} else {
var aerr aerrors.ActorError
origin, aerr = ResolveToStableAddr(vm.cstate, vm.cst, msg.From)
if aerr != nil {
return nil, aerr, nil
}
} }
rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac) rt := vm.makeRuntime(ctx, msg, origin, on, gasUsed, nac)