Make MpoolPushMessage message wait for the first message to be done
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
ae1ae58dd7
commit
ed2778f785
@ -29,12 +29,12 @@ func ComputeGasOverestimationBurn(gasUsed, gasLimit int64) (int64, int64) {
|
||||
return 0, gasLimit
|
||||
}
|
||||
|
||||
// over = gasLimit/gasUsed - 1 - 0.3
|
||||
// over = gasLimit/gasUsed - 1 - 0.1
|
||||
// over = min(over, 1)
|
||||
// gasToBurn = (gasLimit - gasUsed) * over
|
||||
|
||||
// so to factor out division from `over`
|
||||
// over*gasUsed = min(gasLimit - (13*gasUsed)/10, gasUsed)
|
||||
// over*gasUsed = min(gasLimit - (11*gasUsed)/10, gasUsed)
|
||||
// gasToBurn = ((gasLimit - gasUsed)*over*gasUsed) / gasUsed
|
||||
over := gasLimit - (gasOveruseNum*gasUsed)/gasOveruseDenom
|
||||
if over < 0 {
|
||||
|
@ -153,6 +153,7 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
|
||||
for _, m := range pending {
|
||||
priorMsgs = append(priorMsgs, m)
|
||||
}
|
||||
log.Warnf("added %d prior msgs")
|
||||
|
||||
res, err := a.Stmgr.CallWithGas(ctx, &msg, priorMsgs, ts)
|
||||
if err != nil {
|
||||
|
@ -2,6 +2,7 @@ package full
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"go.uber.org/fx"
|
||||
@ -23,6 +24,11 @@ type MpoolAPI struct {
|
||||
Chain *store.ChainStore
|
||||
|
||||
Mpool *messagepool.MessagePool
|
||||
|
||||
PushLocks struct {
|
||||
m map[address.Address]chan struct{}
|
||||
sync.Mutex
|
||||
} `name:"verymuchunique" optional:"true"`
|
||||
}
|
||||
|
||||
func (a *MpoolAPI) MpoolGetConfig(context.Context) (*types.MpoolConfig, error) {
|
||||
@ -105,9 +111,25 @@ func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (ci
|
||||
return a.Mpool.Push(smsg)
|
||||
}
|
||||
|
||||
// GasMargin sets by how much should gas used be increased over test execution
|
||||
|
||||
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) {
|
||||
{
|
||||
a.PushLocks.Lock()
|
||||
if a.PushLocks.m == nil {
|
||||
a.PushLocks.m = make(map[address.Address]chan struct{})
|
||||
}
|
||||
lk, ok := a.PushLocks.m[msg.From]
|
||||
if !ok {
|
||||
lk = make(chan struct{}, 1)
|
||||
a.PushLocks.m[msg.From] = lk
|
||||
}
|
||||
a.PushLocks.Unlock()
|
||||
|
||||
lk <- struct{}{}
|
||||
defer func() {
|
||||
<-lk
|
||||
}()
|
||||
}
|
||||
|
||||
if msg.Nonce != 0 {
|
||||
return nil, xerrors.Errorf("MpoolPushMessage expects message nonce to be 0, was %d", msg.Nonce)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user