From b84030b3bdf19b953cbf330710453d20f3f3abfd Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 21 Jul 2020 03:41:18 +0200 Subject: [PATCH] Fix nonce setting in gas estimation Signed-off-by: Jakub Sztandera --- chain/stmgr/call.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 893db33a8..29c97c3d8 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -106,6 +106,17 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, ts ) } + vmi, err := vm.NewVM(state, ts.Height(), r, sm.cs.Blockstore(), sm.cs.VMSys()) + if err != nil { + return nil, xerrors.Errorf("failed to set up vm: %w", err) + } + fromActor, err := vmi.StateTree().GetActor(msg.From) + if err != nil { + return nil, xerrors.Errorf("call raw get actor: %s", err) + } + + msg.Nonce = fromActor.Nonce + fromKey, err := sm.ResolveToKeyAddress(ctx, msg.From, ts) if err != nil { return nil, xerrors.Errorf("could not resolve key: %w", err) @@ -127,18 +138,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, ts } - vmi, err := vm.NewVM(state, ts.Height(), r, sm.cs.Blockstore(), sm.cs.VMSys()) - if err != nil { - return nil, xerrors.Errorf("failed to set up vm: %w", err) - } - - fromActor, err := vmi.StateTree().GetActor(msg.From) - if err != nil { - return nil, xerrors.Errorf("call raw get actor: %s", err) - } - - msg.Nonce = fromActor.Nonce - ret, err := vmi.ApplyMessage(ctx, msgApply) if err != nil { return nil, xerrors.Errorf("apply message failed: %w", err)