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 {
Message
rt0.Message
rt0.Syscalls
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")
}
vmm.From = resF
resT, _ := rt.ResolveAddress(msg.To)
// may be set to undef if recipient doesn't exist yet
vmm.To = resT
rt.Message = Message{msg: vmm}
if vm.ntwkVersion(ctx, vm.blockHeight) <= network.Version3 {
rt.Message = &vmm
} else {
resT, _ := rt.ResolveAddress(msg.To)
// may be set to undef if recipient doesn't exist yet
vmm.To = resT
rt.Message = &Message{msg: vmm}
}
return rt
}
@ -265,15 +270,19 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
return nil, aerrors.Wrapf(err, "could not create account")
}
toActor = a
nmsg := Message{
msg: types.Message{
To: aid,
From: rt.Message.Caller(),
Value: rt.Message.ValueReceived(),
},
}
if vm.ntwkVersion(ctx, vm.blockHeight) <= network.Version3 {
// Leave the rt.Message as is
} else {
nmsg := Message{
msg: types.Message{
To: aid,
From: rt.Message.Caller(),
Value: rt.Message.ValueReceived(),
},
}
rt.Message = nmsg
rt.Message = &nmsg
}
} else {
return nil, aerrors.Escalate(err, "getting actor")
}