Fix nonce setting in gas estimation

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-07-21 03:41:18 +02:00 committed by Travis Person
parent 20291f8f26
commit b84030b3bd

View File

@ -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) fromKey, err := sm.ResolveToKeyAddress(ctx, msg.From, ts)
if err != nil { if err != nil {
return nil, xerrors.Errorf("could not resolve key: %w", err) 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) ret, err := vmi.ApplyMessage(ctx, msgApply)
if err != nil { if err != nil {
return nil, xerrors.Errorf("apply message failed: %w", err) return nil, xerrors.Errorf("apply message failed: %w", err)