Commit e74637e8 authored by vipwzw's avatar vipwzw

fixbug fee

parent 25edc591
...@@ -219,7 +219,7 @@ func createTxsGroup(txs []*types.Transaction) ([]*types.Transaction, error) { ...@@ -219,7 +219,7 @@ func createTxsGroup(txs []*types.Transaction) ([]*types.Transaction, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -225,7 +225,7 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T ...@@ -225,7 +225,7 @@ func (client *commitMsgClient) getTxsGroup(txsArr *types.Transactions) (*types.T
plog.Error("para CreateTxGroup", "err", err.Error()) plog.Error("para CreateTxGroup", "err", err.Error())
return nil, err return nil, err
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
plog.Error("para CheckTxGroup", "err", err.Error()) plog.Error("para CheckTxGroup", "err", err.Error())
return nil, err return nil, err
......
...@@ -523,7 +523,7 @@ func createTxsGroup(s suite.Suite, txs []*types.Transaction) ([]*types.Transacti ...@@ -523,7 +523,7 @@ func createTxsGroup(s suite.Suite, txs []*types.Transaction) ([]*types.Transacti
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -138,7 +138,7 @@ func (e *executor) checkTx(tx *types.Transaction, index int) error { ...@@ -138,7 +138,7 @@ func (e *executor) checkTx(tx *types.Transaction, index int) error {
//如果已经过期 //如果已经过期
return types.ErrTxExpire return types.ErrTxExpire
} }
if err := tx.Check(e.height, types.GInt("MinFee"), types.GInt("MaxTxFee")); err != nil { if err := tx.Check(e.height, types.GInt("MinFee"), types.GInt("MaxFee")); err != nil {
return err return err
} }
//允许重写的情况 //允许重写的情况
...@@ -166,7 +166,7 @@ func (e *executor) checkTxGroup(txgroup *types.Transactions, index int) error { ...@@ -166,7 +166,7 @@ func (e *executor) checkTxGroup(txgroup *types.Transactions, index int) error {
//如果已经过期 //如果已经过期
return types.ErrTxExpire return types.ErrTxExpire
} }
if err := txgroup.Check(e.height, types.GInt("MinFee"), types.GInt("MaxTxFee")); err != nil { if err := txgroup.Check(e.height, types.GInt("MinFee"), types.GInt("MaxFee")); err != nil {
return err return err
} }
return nil return nil
......
...@@ -129,7 +129,7 @@ func (c *channelClient) CreateNoBalanceTransaction(in *types.NoBalanceTx) (*type ...@@ -129,7 +129,7 @@ func (c *channelClient) CreateNoBalanceTransaction(in *types.NoBalanceTx) (*type
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -456,7 +456,7 @@ func TestChain33_CreateTxGroup(t *testing.T) { ...@@ -456,7 +456,7 @@ func TestChain33_CreateTxGroup(t *testing.T) {
t.Error("Test createtxgroup failed") t.Error("Test createtxgroup failed")
return return
} }
err = tx.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = tx.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
assert.Nil(t, err) assert.Nil(t, err)
} }
......
...@@ -300,7 +300,7 @@ func createTxGroup(cmd *cobra.Command, args []string) { ...@@ -300,7 +300,7 @@ func createTxGroup(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return return
} }
err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxTxFee")) err = group.Check(0, types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
return return
......
...@@ -373,7 +373,7 @@ func (d *DriverBase) GetTxGroup(index int) ([]*types.Transaction, error) { ...@@ -373,7 +373,7 @@ func (d *DriverBase) GetTxGroup(index int) ([]*types.Transaction, error) {
for i := index; i >= 0 && i >= index-c; i-- { for i := index; i >= 0 && i >= index-c; i-- {
if bytes.Equal(d.txs[i].Header, d.txs[i].Hash()) { //find header if bytes.Equal(d.txs[i].Header, d.txs[i].Hash()) { //find header
txgroup := types.Transactions{Txs: d.txs[i : i+c]} txgroup := types.Transactions{Txs: d.txs[i : i+c]}
err := txgroup.Check(d.GetHeight(), types.GInt("MinFee"), types.GInt("MaxTxFee")) err := txgroup.Check(d.GetHeight(), types.GInt("MinFee"), types.GInt("MaxFee"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -200,6 +200,8 @@ type RPC struct { ...@@ -200,6 +200,8 @@ type RPC struct {
type Exec struct { type Exec struct {
// 执行器执行所需最小费用,低于Mempool和Wallet设置的MinFee,在minExecFee = 0 的情况下,isFree = true才会生效 // 执行器执行所需最小费用,低于Mempool和Wallet设置的MinFee,在minExecFee = 0 的情况下,isFree = true才会生效
MinExecFee int64 `protobuf:"varint,1,opt,name=minExecFee" json:"minExecFee,omitempty"` MinExecFee int64 `protobuf:"varint,1,opt,name=minExecFee" json:"minExecFee,omitempty"`
// 执行器执行所需最大费用,这个值必须大于mempool 和 wallet 的值
MaxExecFee int64 `protobuf:"varint,1,opt,name=maxExecFee" json:"maxExecFee,omitempty"`
// 执行器执行是否免费 // 执行器执行是否免费
IsFree bool `protobuf:"varint,2,opt,name=isFree" json:"isFree,omitempty"` IsFree bool `protobuf:"varint,2,opt,name=isFree" json:"isFree,omitempty"`
// 是否开启stat插件 // 是否开启stat插件
......
...@@ -256,8 +256,14 @@ func Init(t string, cfg *Config) { ...@@ -256,8 +256,14 @@ func Init(t string, cfg *Config) {
if cfg.Exec.MinExecFee > cfg.Mempool.MinTxFee || cfg.Mempool.MinTxFee > cfg.Wallet.MinFee { if cfg.Exec.MinExecFee > cfg.Mempool.MinTxFee || cfg.Mempool.MinTxFee > cfg.Wallet.MinFee {
panic("config must meet: wallet.minFee >= mempool.minTxFee >= exec.minExecFee") panic("config must meet: wallet.minFee >= mempool.minTxFee >= exec.minExecFee")
} }
if cfg.Exec.MaxExecFee < cfg.Mempool.MaxTxFee {
panic("config must meet: mempool.maxTxFee <= exec.maxExecFee")
}
setMinFee(cfg.Exec.MinExecFee) setMinFee(cfg.Exec.MinExecFee)
setChainConfig("FixTime", cfg.FixTime) setChainConfig("FixTime", cfg.FixTime)
if cfg.Exec.MaxExecFee > 0 {
setChainConfig("MaxFee", cfg.Exec.MaxExecFee)
}
} }
//local 只用于单元测试 //local 只用于单元测试
if isLocal() { if isLocal() {
...@@ -355,6 +361,7 @@ func setMinFee(fee int64) { ...@@ -355,6 +361,7 @@ func setMinFee(fee int64) {
panic("fee less than zero") panic("fee less than zero")
} }
setChainConfig("MinFee", fee) setChainConfig("MinFee", fee)
setChainConfig("MaxFee", fee*10000)
setChainConfig("MinBalanceTransfer", fee*10) setChainConfig("MinBalanceTransfer", fee*10)
} }
......
...@@ -66,6 +66,7 @@ keyFile="key.pem" ...@@ -66,6 +66,7 @@ keyFile="key.pem"
poolCacheSize=102400 poolCacheSize=102400
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=100 maxTxNumPerAccount=100
maxTxFee=1000000000
[consensus] [consensus]
name="ticket" name="ticket"
...@@ -145,6 +146,7 @@ minerwhitelist=["*"] ...@@ -145,6 +146,7 @@ minerwhitelist=["*"]
[exec] [exec]
isFree=false isFree=false
minExecFee=100000 minExecFee=100000
maxExecFee=1000000000
enableStat=false enableStat=false
enableMVCC=false enableMVCC=false
......
...@@ -65,6 +65,7 @@ grpcFuncWhitelist=["*"] ...@@ -65,6 +65,7 @@ grpcFuncWhitelist=["*"]
poolCacheSize=10240 poolCacheSize=10240
minTxFee=100000 minTxFee=100000
maxTxNumPerAccount=10000 maxTxNumPerAccount=10000
maxTxFee=1000000000
[consensus] [consensus]
name="ticket" name="ticket"
...@@ -119,6 +120,7 @@ minerwhitelist=["*"] ...@@ -119,6 +120,7 @@ minerwhitelist=["*"]
[exec] [exec]
isFree=false isFree=false
minExecFee=100000 minExecFee=100000
maxExecFee=1000000000
enableStat=false enableStat=false
enableMVCC=false enableMVCC=false
alias=["token1:token","token2:token","token3:token"] alias=["token1:token","token2:token","token3:token"]
......
...@@ -34,7 +34,7 @@ func TestCreateGroupTx(t *testing.T) { ...@@ -34,7 +34,7 @@ func TestCreateGroupTx(t *testing.T) {
t.Error(err) t.Error(err)
return return
} }
err = group.Check(0, GInt("MinFee"), GInt("MaxTxFee")) err = group.Check(0, GInt("MinFee"), GInt("MaxFee"))
if err != nil { if err != nil {
for i := 0; i < len(group.Txs); i++ { for i := 0; i < len(group.Txs); i++ {
t.Log(group.Txs[i].JSON()) t.Log(group.Txs[i].JSON())
...@@ -80,7 +80,7 @@ func TestCreateGroupTxWithSize(t *testing.T) { ...@@ -80,7 +80,7 @@ func TestCreateGroupTxWithSize(t *testing.T) {
return return
} }
err = group.Check(0, GInt("MinFee"), GInt("MaxTxFee")) err = group.Check(0, GInt("MinFee"), GInt("MaxFee"))
if err != nil { if err != nil {
for i := 0; i < len(group.Txs); i++ { for i := 0; i < len(group.Txs); i++ {
t.Log(group.Txs[i].JSON()) t.Log(group.Txs[i].JSON())
...@@ -163,7 +163,7 @@ func TestSignGroupTx(t *testing.T) { ...@@ -163,7 +163,7 @@ func TestSignGroupTx(t *testing.T) {
return return
} }
} }
err = group.Check(0, GInt("MinFee"), GInt("MaxTxFee")) err = group.Check(0, GInt("MinFee"), GInt("MaxFee"))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment