From 88fa9726ccf9f6a7588a6ba2dc8c9a55e6bd0940 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 14 May 2020 12:44:26 -0700 Subject: [PATCH] use chainmsg type instead of unsigned message for gas price checking --- chain/sync.go | 8 +++++--- miner/miner.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/chain/sync.go b/chain/sync.go index 63d6830f1..23b790a06 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -841,9 +841,11 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock return xerrors.Errorf("failed to load base state tree: %w", err) } - checkMsg := func(m *types.Message) error { + checkMsg := func(msg types.ChainMsg) error { + m := msg.VMMessage() + // Phase 1: syntactic validation, as defined in the spec - minGas := vm.PricelistByEpoch(baseTs.Height()).OnChainMessage(m.ChainLength()) + minGas := vm.PricelistByEpoch(baseTs.Height()).OnChainMessage(msg.ChainLength()) if err := m.ValidForBlockInclusion(minGas); err != nil { return err } @@ -885,7 +887,7 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock var secpkCids []cbg.CBORMarshaler for i, m := range b.SecpkMessages { - if err := checkMsg(&m.Message); err != nil { + if err := checkMsg(m); err != nil { return xerrors.Errorf("block had invalid secpk message at index %d: %w", i, err) } diff --git a/miner/miner.go b/miner/miner.go index 0ac765355..baa530d7f 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -422,7 +422,7 @@ func SelectMessages(ctx context.Context, al ActorLookup, ts *types.TipSet, msgs for _, msg := range msgs { - minGas := vm.PricelistByEpoch(ts.Height()).OnChainMessage(msg.VMMessage().ChainLength()) // TODO: really should be doing just msg.ChainLength() but the sync side of this code doesnt seem to have access to that + minGas := vm.PricelistByEpoch(ts.Height()).OnChainMessage(msg.ChainLength()) // TODO: really should be doing just msg.ChainLength() but the sync side of this code doesnt seem to have access to that if err := msg.VMMessage().ValidForBlockInclusion(minGas); err != nil { log.Warnf("invalid message in message pool: %s", err) continue