Skip to content

Commit

Permalink
Merge branch 'master' into feat/fatman13/issue-template
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatman13 committed Jul 13, 2022
2 parents f9be227 + 52c7ad2 commit 9abd13a
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 49 deletions.
15 changes: 14 additions & 1 deletion pkg/messagepool/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math"
stdbig "math/big"
"math/rand"
"sort"

Expand Down Expand Up @@ -312,6 +313,7 @@ func (mp *MessagePool) GasEstimateMessageGas(ctx context.Context, estimateMessag
if estimateMessage == nil || estimateMessage.Msg == nil {
return nil, fmt.Errorf("estimate message is nil")
}
log.Debugf("call GasEstimateMessageGas %v, send spec: %v", estimateMessage.Msg, estimateMessage.Spec)
if estimateMessage.Msg.GasLimit == 0 {
gasLimit, err := mp.GasEstimateGasLimit(ctx, estimateMessage.Msg, types.TipSetKey{})
if err != nil {
Expand All @@ -321,7 +323,6 @@ func (mp *MessagePool) GasEstimateMessageGas(ctx context.Context, estimateMessag
if estimateMessage.Spec != nil && estimateMessage.Spec.GasOverEstimation > 0 {
gasLimitOverestimation = estimateMessage.Spec.GasOverEstimation
}
log.Debugf("call GasEstimateMessageGas %v, spec: %v, config gasLimitOverestimation: %v", estimateMessage.Msg, estimateMessage.Spec, mp.GetConfig().GasLimitOverestimation)
estimateMessage.Msg.GasLimit = int64(float64(gasLimit) * gasLimitOverestimation)
}

Expand All @@ -330,6 +331,12 @@ func (mp *MessagePool) GasEstimateMessageGas(ctx context.Context, estimateMessag
if err != nil {
return nil, fmt.Errorf("estimating gas price: %w", err)
}
if estimateMessage.Spec != nil && estimateMessage.Spec.GasOverPremium > 0 {
olgGasPremium := gasPremium
newGasPremium, _ := new(stdbig.Float).Mul(new(stdbig.Float).SetInt(stdbig.NewInt(gasPremium.Int64())), stdbig.NewFloat(estimateMessage.Spec.GasOverPremium)).Int(nil)
gasPremium = big.NewFromGo(newGasPremium)
log.Debugf("call GasEstimateMessageGas old premium %v, new premium %v, premium ration %f", olgGasPremium, newGasPremium, estimateMessage.Spec.GasOverPremium)
}
estimateMessage.Msg.GasPremium = gasPremium
}

Expand Down Expand Up @@ -398,6 +405,12 @@ func (mp *MessagePool) GasBatchEstimateMessageGas(ctx context.Context, estimateM
})
continue
}
if estimateMessage.Spec != nil && estimateMessage.Spec.GasOverPremium > 0 {
olgGasPremium := gasPremium
newGasPremium, _ := new(stdbig.Float).Mul(new(stdbig.Float).SetInt(stdbig.NewInt(gasPremium.Int64())), stdbig.NewFloat(estimateMessage.Spec.GasOverPremium)).Int(nil)
gasPremium = big.NewFromGo(newGasPremium)
log.Debugf("call GasBatchEstimateMessageGas old premium %v, new premium %v, premium ration %f", olgGasPremium, newGasPremium, estimateMessage.Spec.GasOverPremium)
}
estimateMsg.GasPremium = gasPremium
}

Expand Down
12 changes: 8 additions & 4 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,8 @@ Inputs:
},
"Spec": {
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
}
],
Expand Down Expand Up @@ -1824,7 +1825,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
},
[
{
Expand Down Expand Up @@ -1929,7 +1931,8 @@ Inputs:
],
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -2240,7 +2243,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down
12 changes: 8 additions & 4 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,8 @@ Inputs:
},
"Spec": {
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
}
],
Expand Down Expand Up @@ -1869,7 +1870,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
},
[
{
Expand Down Expand Up @@ -1974,7 +1976,8 @@ Inputs:
],
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -2416,7 +2419,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down
3 changes: 2 additions & 1 deletion venus-shared/api/market/client/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down
3 changes: 2 additions & 1 deletion venus-shared/api/market/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,8 @@ Inputs:
},
{
"MaxFee": "0",
"GasOverEstimation": 12.3
"GasOverEstimation": 12.3,
"GasOverPremium": 12.3
}
]
```
Expand Down
22 changes: 11 additions & 11 deletions venus-shared/api/messager/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ type IMessager interface {
MarkBadMessage(ctx context.Context, id string) error //perm:admin
RecoverFailedMsg(ctx context.Context, addr address.Address) ([]string, error) //perm:admin

GetAddress(ctx context.Context, addr address.Address) (*types.Address, error) //perm:admin
HasAddress(ctx context.Context, addr address.Address) (bool, error) //perm:read
WalletHas(ctx context.Context, addr address.Address) (bool, error) //perm:read
ListAddress(ctx context.Context) ([]*types.Address, error) //perm:admin
UpdateNonce(ctx context.Context, addr address.Address, nonce uint64) error //perm:admin
DeleteAddress(ctx context.Context, addr address.Address) error //perm:admin
ForbiddenAddress(ctx context.Context, addr address.Address) error //perm:admin
ActiveAddress(ctx context.Context, addr address.Address) error //perm:admin
SetSelectMsgNum(ctx context.Context, addr address.Address, num uint64) error //perm:admin
SetFeeParams(ctx context.Context, addr address.Address, gasOverEstimation float64, maxFee, maxFeeCap string) error //perm:admin
ClearUnFillMessage(ctx context.Context, addr address.Address) (int, error) //perm:admin
GetAddress(ctx context.Context, addr address.Address) (*types.Address, error) //perm:admin
HasAddress(ctx context.Context, addr address.Address) (bool, error) //perm:read
WalletHas(ctx context.Context, addr address.Address) (bool, error) //perm:read
ListAddress(ctx context.Context) ([]*types.Address, error) //perm:admin
UpdateNonce(ctx context.Context, addr address.Address, nonce uint64) error //perm:admin
DeleteAddress(ctx context.Context, addr address.Address) error //perm:admin
ForbiddenAddress(ctx context.Context, addr address.Address) error //perm:admin
ActiveAddress(ctx context.Context, addr address.Address) error //perm:admin
SetSelectMsgNum(ctx context.Context, addr address.Address, num uint64) error //perm:admin
SetFeeParams(ctx context.Context, addr address.Address, gasOverEstimation, gasOverPremium float64, maxFee, maxFeeCap string) error //perm:admin
ClearUnFillMessage(ctx context.Context, addr address.Address) (int, error) //perm:admin

GetSharedParams(ctx context.Context) (*types.SharedSpec, error) //perm:admin
SetSharedParams(ctx context.Context, params *types.SharedSpec) error //perm:admin
Expand Down
47 changes: 33 additions & 14 deletions venus-shared/api/messager/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ Inputs:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -181,7 +182,8 @@ Inputs:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -212,6 +214,7 @@ Response:
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0",
"gasOverPremium": 12.3,
"isDeleted": 123,
"createAt": "0001-01-01T00:00:00Z",
"updateAt": "0001-01-01T00:00:00Z"
Expand Down Expand Up @@ -274,7 +277,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -341,7 +345,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -406,7 +411,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -473,7 +479,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -520,6 +527,7 @@ Response:
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0",
"gasOverPremium": 12.3,
"selMsgNum": 42
}
```
Expand Down Expand Up @@ -586,6 +594,7 @@ Response:
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0",
"gasOverPremium": 12.3,
"isDeleted": 123,
"createAt": "0001-01-01T00:00:00Z",
"updateAt": "0001-01-01T00:00:00Z"
Expand Down Expand Up @@ -650,7 +659,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -712,7 +722,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -774,7 +785,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -841,7 +853,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -912,7 +925,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down Expand Up @@ -984,7 +998,8 @@ Inputs:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -1019,7 +1034,8 @@ Inputs:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
}
]
```
Expand Down Expand Up @@ -1147,6 +1163,7 @@ Inputs:
[
"f01234",
12.3,
12.3,
"string value",
"string value"
]
Expand Down Expand Up @@ -1196,6 +1213,7 @@ Inputs:
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0",
"gasOverPremium": 12.3,
"selMsgNum": 42
}
]
Expand Down Expand Up @@ -1312,7 +1330,8 @@ Response:
"expireEpoch": 10101,
"gasOverEstimation": 12.3,
"maxFee": "0",
"maxFeeCap": "0"
"maxFeeCap": "0",
"gasOverPremium": 12.3
},
"WalletName": "test",
"FromUser": "test",
Expand Down
8 changes: 4 additions & 4 deletions venus-shared/api/messager/mock/mock_imessager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9abd13a

Please sign in to comment.