From 2bbd1fbbb610645650bc439abb2984f8c38ded61 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Feb 2023 10:59:20 -0800 Subject: [PATCH] fix: stmgr: check message validity before invoking vm Otherwise we may, e.g., try to estimate gas on a message to an f4 address before the nv18 migration. I'm _not_ checking the "prior messages" here as this is just a sanity check. --- chain/stmgr/call.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index ea2758705fa..e6b742255ff 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -107,6 +107,14 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr } } + // This isn't strictly necessary, but the underlying VM will assume that the message is + // valid and may not return helpful debugging information. Checking here makes message + // validity issues easier to debug. + nv := sm.GetNetworkVersion(ctx, ts.Height()) + if err := msg.ValidForBlockInclusion(0, nv); err != nil { + return nil, xerrors.Errorf("message not valid for network version %d: %w", nv, err) + } + // Unless executing on a specific state cid, apply all the messages from the current tipset // first. Unfortunately, we can't just execute the tipset, because that will run cron. We // don't want to apply miner messages after cron runs in a given epoch.