Move rt.Message fixes behind fork logic

This commit is contained in:
Aayush Rajasekaran 2020-10-06 01:25:55 -04:00
parent 757aa1039f
commit d9fad5fad0
2 changed files with 22 additions and 13 deletions

View File

@ -50,7 +50,7 @@ func (m *Message) ValueReceived() abi.TokenAmount {
} }
type Runtime struct { type Runtime struct {
Message rt0.Message
rt0.Syscalls rt0.Syscalls
ctx context.Context ctx context.Context

View File

@ -131,10 +131,15 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
rt.Abortf(exitcode.SysErrInvalidReceiver, "resolve msg.From address failed") rt.Abortf(exitcode.SysErrInvalidReceiver, "resolve msg.From address failed")
} }
vmm.From = resF vmm.From = resF
if vm.ntwkVersion(ctx, vm.blockHeight) <= network.Version3 {
rt.Message = &vmm
} else {
resT, _ := rt.ResolveAddress(msg.To) resT, _ := rt.ResolveAddress(msg.To)
// may be set to undef if recipient doesn't exist yet // may be set to undef if recipient doesn't exist yet
vmm.To = resT vmm.To = resT
rt.Message = Message{msg: vmm} rt.Message = &Message{msg: vmm}
}
return rt return rt
} }
@ -265,6 +270,9 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
return nil, aerrors.Wrapf(err, "could not create account") return nil, aerrors.Wrapf(err, "could not create account")
} }
toActor = a toActor = a
if vm.ntwkVersion(ctx, vm.blockHeight) <= network.Version3 {
// Leave the rt.Message as is
} else {
nmsg := Message{ nmsg := Message{
msg: types.Message{ msg: types.Message{
To: aid, To: aid,
@ -273,7 +281,8 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
}, },
} }
rt.Message = nmsg rt.Message = &nmsg
}
} else { } else {
return nil, aerrors.Escalate(err, "getting actor") return nil, aerrors.Escalate(err, "getting actor")
} }