diff --git a/chain/consensus/compute_state.go b/chain/consensus/compute_state.go index d0f669a10..041b6fb03 100644 --- a/chain/consensus/compute_state.go +++ b/chain/consensus/compute_state.go @@ -200,16 +200,12 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, processedMsgs[m.Cid()] = struct{}{} } - params, err := actors.SerializeParams(&reward.AwardBlockRewardParams{ + params := &reward.AwardBlockRewardParams{ Miner: b.Miner, Penalty: penalty, GasReward: gasReward, WinCount: b.WinCount, - }) - if err != nil { - return cid.Undef, cid.Undef, xerrors.Errorf("failed to serialize award params: %w", err) } - rErr := t.reward(ctx, vmi, em, epoch, ts, params) if rErr != nil { return cid.Undef, cid.Undef, xerrors.Errorf("error applying reward: %w", err) diff --git a/chain/consensus/filcns/filecoin.go b/chain/consensus/filcns/filecoin.go index 543dc5c68..2e3baa4db 100644 --- a/chain/consensus/filcns/filecoin.go +++ b/chain/consensus/filcns/filecoin.go @@ -21,6 +21,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -59,7 +60,11 @@ type FilecoinEC struct { const MaxHeightDrift = 5 var RewardFunc = func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonitor, - epoch abi.ChainEpoch, ts *types.TipSet, params []byte) error { + epoch abi.ChainEpoch, ts *types.TipSet, params *reward.AwardBlockRewardParams) error { + ser, err := actors.SerializeParams(params) + if err != nil { + return xerrors.Errorf("failed to serialize award params: %w", err) + } rwMsg := &types.Message{ From: builtin.SystemActorAddr, To: reward.Address, @@ -69,7 +74,7 @@ var RewardFunc = func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonito GasPremium: types.NewInt(0), GasLimit: 1 << 30, Method: reward.Methods.AwardBlockReward, - Params: params, + Params: ser, } ret, actErr := vmi.ApplyImplicitMessage(ctx, rwMsg) if actErr != nil { diff --git a/chain/consensus/iface.go b/chain/consensus/iface.go index 58adfe03e..10c3ead74 100644 --- a/chain/consensus/iface.go +++ b/chain/consensus/iface.go @@ -10,6 +10,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" @@ -47,7 +48,7 @@ type Consensus interface { // // Each consensus implementation can set their own reward function. type RewardFunc func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonitor, - epoch abi.ChainEpoch, ts *types.TipSet, params []byte) error + epoch abi.ChainEpoch, ts *types.TipSet, params *reward.AwardBlockRewardParams) error // ValidateBlockPubsub implements the common checks performed by all consensus implementations // when a block is received through the pubsub channel.