From 46fd9d5e801473083f4e9e35f9982dac1defb80e Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 8 Aug 2020 22:51:24 +0200 Subject: [PATCH] Quiet down pending messages, fix GasLimit estimation, reduce fee cap Signed-off-by: Jakub Sztandera --- chain/messagepool/selection.go | 8 +++++--- chain/stmgr/call.go | 4 ++-- node/impl/full/mpool.go | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index 4908e2eec..47923fd6f 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -254,12 +254,14 @@ tailLoop: func (mp *MessagePool) getPendingMessages(curTs, ts *types.TipSet) (map[address.Address]map[uint64]*types.SignedMessage, error) { start := time.Now() - defer func() { - log.Infow("get pending messages done", "took", time.Since(start)) - }() result := make(map[address.Address]map[uint64]*types.SignedMessage) haveCids := make(map[cid.Cid]struct{}) + defer func() { + if time.Since(start) > time.Millisecond { + log.Infow("get pending messages done", "took", time.Since(start)) + } + }() // are we in sync? inSync := false diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 286d1dae7..8be4eb4e2 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -108,7 +108,7 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri ts = sm.cs.GetHeaviestTipSet() } - state := ts.ParentState() + state, _, err := sm.TipSetState(ctx, ts) r := store.NewChainRand(sm.cs, ts.Cids(), ts.Height()) @@ -122,7 +122,7 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri vmopt := &vm.VMOpts{ StateBase: state, - Epoch: ts.Height(), + Epoch: ts.Height() + 1, Rand: r, Bstore: sm.cs.Blockstore(), Syscalls: sm.cs.VMSys(), diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index 6c9e65ef6..cf901f77d 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -113,18 +113,28 @@ func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (ci func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) { { + fromA, err := a.Stmgr.ResolveToKeyAddress(ctx, msg.From, nil) + if err != nil { + return nil, xerrors.Errorf("getting key address: %w", err) + } + a.PushLocks.Lock() if a.PushLocks.m == nil { a.PushLocks.m = make(map[address.Address]chan struct{}) } - lk, ok := a.PushLocks.m[msg.From] + lk, ok := a.PushLocks.m[fromA] if !ok { lk = make(chan struct{}, 1) a.PushLocks.m[msg.From] = lk } a.PushLocks.Unlock() - lk <- struct{}{} + select { + case lk <- struct{}{}: + case <-ctx.Done(): + return nil, ctx.Err() + } + defer func() { <-lk }() @@ -150,7 +160,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t } if msg.GasFeeCap == types.EmptyInt || types.BigCmp(msg.GasFeeCap, types.NewInt(0)) == 0 { - feeCap, err := a.GasEstimateFeeCap(ctx, msg, 20, types.EmptyTSK) + feeCap, err := a.GasEstimateFeeCap(ctx, msg, 10, types.EmptyTSK) if err != nil { return nil, xerrors.Errorf("estimating fee cap: %w", err) }