Send implicit messages for block rewards, cron ticks, state calls, and genesis setup

This commit is contained in:
Aayush Rajasekaran 2020-03-25 04:46:42 -04:00
parent ad15750be3
commit 490f85e690
4 changed files with 19 additions and 4 deletions

View File

@ -31,7 +31,7 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value
return nil, xerrors.Errorf("doExec failed to get from actor: %w", err)
}
ret, err := vm.ApplyMessage(ctx, &types.Message{
ret, err := vm.ApplyImplicitMessage(ctx, &types.Message{
To: to,
From: from,
Method: method,

View File

@ -52,7 +52,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
msg.Nonce = fromActor.Nonce
// TODO: maybe just use the invoker directly?
ret, err := vmi.ApplyMessage(ctx, msg)
ret, err := vmi.ApplyImplicitMessage(ctx, msg)
if err != nil {
return nil, xerrors.Errorf("apply message failed: %w", err)
}

View File

@ -199,6 +199,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
receipts = append(receipts, &r.MessageReceipt)
gasReward = big.Add(gasReward, big.NewInt(r.GasUsed))
penalty = big.Add(penalty, r.Penalty)
if cb != nil {
if err := cb(cm.Cid(), m, r); err != nil {
@ -233,7 +234,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
Method: builtin.MethodsReward.AwardBlockReward,
Params: params,
}
ret, err := vmi.ApplyMessage(ctx, rwMsg)
ret, err := vmi.ApplyImplicitMessage(ctx, rwMsg)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("failed to apply reward message for miner %s: %w", b.Miner, err)
}
@ -265,7 +266,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
Method: builtin.MethodsCron.EpochTick,
Params: nil,
}
ret, err := vmi.ApplyMessage(ctx, cronMsg)
ret, err := vmi.ApplyImplicitMessage(ctx, cronMsg)
if err != nil {
return cid.Undef, cid.Undef, err
}

View File

@ -261,6 +261,20 @@ func checkMessage(msg *types.Message) error {
return nil
}
func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
ret, actorErr, _ := vm.send(ctx, msg, nil, 0)
return &ApplyRet{
MessageReceipt: types.MessageReceipt{
ExitCode: exitcode.ExitCode(aerrors.RetCode(actorErr)),
Return: ret,
GasUsed: 0,
},
ActorErr: actorErr,
InternalExecutions: nil,
Penalty: types.NewInt(0),
}, actorErr
}
func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
ctx, span := trace.StartSpan(ctx, "vm.ApplyMessage")
defer span.End()