Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update maxTxFeeLimit #1320

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/chain33/bityuan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ maxTxFeeRate=10000000
# 单笔交易最大的手续费, 10 coins
maxTxFee=1000000000

[mver.mempool.ForkMaxTxFeeV1]
# 单笔交易最大的手续费, 50 coins
maxTxFee=5000000000

[store]
# 数据文件存储路径
dbPath="datadir/mavltree"
Expand Down
2 changes: 1 addition & 1 deletion cmd/chain33/chain33.fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ForkRootHash=4500000
ForkFormatAddressKey=0
ForkCheckEthTxSort=0
ForkProxyExec=0

ForkMaxTxFeeV1=0
[fork.sub.none]
ForkUseTimeDelay=0

Expand Down
1 change: 1 addition & 0 deletions cmd/chain33/chain33.system.fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ ForkRootHash=4500000
ForkFormatAddressKey=0
ForkCheckEthTxSort=0
ForkProxyExec=0
ForkMaxTxFeeV1=0
4 changes: 4 additions & 0 deletions cmd/chain33/chain33.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ maxTxFee=1000000000
maxTxNumPerAccount=10240
isLevelFee=false

[mver.mempool.ForkMaxTxFeeV1]
# 单笔交易最大的手续费, 50 coins
maxTxFee=5000000000

[mempool.sub.timeline]
poolCacheSize=10240

Expand Down
5 changes: 5 additions & 0 deletions cmd/chain33/chain33.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ maxTxFee=1000000000
# 是否开启阶梯手续费
isLevelFee=false

[mver.mempool.ForkMaxTxFeeV1]
# 单笔交易最大的手续费, 50 coins
maxTxFee=5000000000


[mempool.sub.timeline]
# mempool缓存容量大小,默认10240
poolCacheSize=10240
Expand Down
4 changes: 2 additions & 2 deletions executor/execenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (e *executor) checkTx(tx *types.Transaction, index int) error {
//如果已经过期
return types.ErrTxExpire
}
if err := tx.Check(e.cfg, e.height, e.cfg.GetMinTxFeeRate(), e.cfg.GetMaxTxFee()); err != nil {
if err := tx.Check(e.cfg, e.height, e.cfg.GetMinTxFeeRate(), e.cfg.GetMaxTxFee(e.height)); err != nil {
return err
}
//允许重写的情况
Expand Down Expand Up @@ -191,7 +191,7 @@ func (e *executor) checkTxGroup(txgroup *types.Transactions, index int) error {
//如果已经过期
return types.ErrTxExpire
}
if err := txgroup.Check(e.cfg, e.height, e.cfg.GetMinTxFeeRate(), e.cfg.GetMaxTxFee()); err != nil {
if err := txgroup.Check(e.cfg, e.height, e.cfg.GetMinTxFeeRate(), e.cfg.GetMaxTxFee(e.height)); err != nil {
return err
}
return nil
Expand Down
8 changes: 4 additions & 4 deletions rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

var log = log15.New("module", "rpc_client")

//ChannelClient ...
// ChannelClient ...
type ChannelClient struct {
client.QueueProtocolAPI
accountdb *account.DB
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *ChannelClient) CreateRawTransaction(param *types.CreateTx) ([]byte, err
return types.Encode(tx), nil
}

//ReWriteRawTx rewrite tx
// ReWriteRawTx rewrite tx
func (c *ChannelClient) ReWriteRawTx(param *types.ReWriteRawTx) ([]byte, error) {
types.AssertConfig(c.QueueProtocolAPI)
cfg := c.QueueProtocolAPI.GetConfig()
Expand Down Expand Up @@ -262,7 +262,7 @@ func (c *ChannelClient) CreateNoBalanceTxs(in *types.NoBalanceTxs) (*types.Trans
if err != nil {
return nil, err
}
err = group.Check(cfg, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee())
err = group.Check(cfg, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee(0))
if err != nil {
return nil, err
}
Expand All @@ -281,7 +281,7 @@ func (c *ChannelClient) CreateNoBalanceTxs(in *types.NoBalanceTxs) (*types.Trans
return newtx, nil
}

//DecodeTx decode hextx
// DecodeTx decode hextx
func DecodeTx(hexstr string) (*types.Transaction, error) {
var tx types.Transaction
data, err := common.FromHex(hexstr)
Expand Down
2 changes: 1 addition & 1 deletion rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func TestChannelClient_CreateNoBalanceTransaction(t *testing.T) {
tx, err := client.CreateNoBalanceTxs(params)
assert.NoError(t, err)
gtx, _ := tx.GetTxGroup()
assert.NoError(t, gtx.Check(cfg, 0, fee, cfg.GetMaxTxFee()))
assert.NoError(t, gtx.Check(cfg, 0, fee, cfg.GetMaxTxFee(0)))
assert.NoError(t, err)
params.Expire = "300s"
tx, err = client.CreateNoBalanceTxs(params)
Expand Down
23 changes: 14 additions & 9 deletions rpc/grpchandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (g *Grpc) GetParaTxByHeight(ctx context.Context, in *pb.ReqParaTxByHeight)
return g.cli.GetParaTxByHeight(in)
}

//GetAccount 通过地址标签获取账户地址以及账户余额信息
// GetAccount 通过地址标签获取账户地址以及账户余额信息
func (g *Grpc) GetAccount(ctx context.Context, in *pb.ReqGetAccount) (*pb.WalletAccount, error) {
acc, err := g.cli.ExecWalletFunc("wallet", "WalletGetAccount", in)
if err != nil {
Expand Down Expand Up @@ -597,43 +597,48 @@ func (g *Grpc) SignWalletRecoverTx(ctx context.Context, in *pb.ReqSignWalletReco
// GetChainConfig 获取chain config 参数
func (g *Grpc) GetChainConfig(ctx context.Context, in *pb.ReqNil) (*pb.ChainConfigInfo, error) {
cfg := g.cli.GetConfig()
currentH := int64(0)
lastH, err := g.GetLastHeader(ctx, in)
if err == nil {
currentH = lastH.GetHeight()
}
return &pb.ChainConfigInfo{
Title: cfg.GetTitle(),
CoinExec: cfg.GetCoinExec(),
CoinSymbol: cfg.GetCoinSymbol(),
CoinPrecision: cfg.GetCoinPrecision(),
TokenPrecision: cfg.GetTokenPrecision(),
ChainID: cfg.GetChainID(),
MaxTxFee: cfg.GetMaxTxFee(),
MaxTxFee: cfg.GetMaxTxFee(currentH),
MinTxFeeRate: cfg.GetMinTxFeeRate(),
MaxTxFeeRate: cfg.GetMaxTxFeeRate(),
IsPara: cfg.IsPara(),
DefaultAddressID: address.GetDefaultAddressID(),
}, nil
}

//ConvertExectoAddr 根据执行器的名字创建地址
// ConvertExectoAddr 根据执行器的名字创建地址
func (g *Grpc) ConvertExectoAddr(ctx context.Context, in *pb.ReqString) (*pb.ReplyString, error) {
addr := address.ExecAddress(in.GetData())
return &pb.ReplyString{Data: addr}, nil
}

//GetCoinSymbol get coin symbol
// GetCoinSymbol get coin symbol
func (g *Grpc) GetCoinSymbol(ctx context.Context, in *pb.ReqNil) (*pb.ReplyString, error) {
return &pb.ReplyString{Data: g.cli.GetConfig().GetCoinSymbol()}, nil
}

//GetBlockSequences ...
// GetBlockSequences ...
func (g *Grpc) GetBlockSequences(ctx context.Context, in *pb.ReqBlocks) (*pb.BlockSequences, error) {
return g.cli.GetBlockSequences(in)
}

//AddPushSubscribe ...
// AddPushSubscribe ...
func (g *Grpc) AddPushSubscribe(ctx context.Context, in *pb.PushSubscribeReq) (*pb.ReplySubscribePush, error) {
return g.cli.AddPushSubscribe(in)
}

//ListPushes 列举推送服务
// ListPushes 列举推送服务
func (g *Grpc) ListPushes(ctx context.Context, in *pb.ReqNil) (*pb.PushSubscribes, error) {
resp, err := g.cli.ListPushes()
if err != nil {
Expand All @@ -647,7 +652,7 @@ func (g *Grpc) GetPushSeqLastNum(ctx context.Context, in *pb.ReqString) (*pb.Int
return g.cli.GetPushSeqLastNum(in)
}

//SubEvent 订阅消息推送服务
// SubEvent 订阅消息推送服务
func (g *Grpc) SubEvent(in *pb.ReqSubscribe, resp pb.Chain33_SubEventServer) error {
sub := g.hashTopic(in.Name)
dataChan := make(chan *queue.Message, 128)
Expand Down Expand Up @@ -708,7 +713,7 @@ func (g *Grpc) SubEvent(in *pb.ReqSubscribe, resp pb.Chain33_SubEventServer) err
return err
}

//UnSubEvent 取消订阅
// UnSubEvent 取消订阅
func (g *Grpc) UnSubEvent(ctx context.Context, in *pb.ReqString) (*pb.Reply, error) {
//删除缓存的TopicID
err := g.delSubInfo(in.GetData(), nil)
Expand Down
31 changes: 18 additions & 13 deletions rpc/jrpchandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (c *Chain33) SetLabl(in *types.ReqWalletSetLabel, result *interface{}) erro
return nil
}

//GetAccount getAddress by lable
// GetAccount getAddress by lable
func (c *Chain33) GetAccount(in *types.ReqGetAccount, result *interface{}) error {
reply, err := c.cli.ExecWalletFunc("wallet", "WalletGetAccount", in)
if err != nil {
Expand Down Expand Up @@ -1391,7 +1391,7 @@ func (c *Chain33) NetProtocols(in *types.ReqNil, result *interface{}) error {
return nil
}

//GetSequenceByHash get sequcen by hashes
// GetSequenceByHash get sequcen by hashes
func (c *Chain33) GetSequenceByHash(in rpctypes.ReqHashes, result *interface{}) error {
if len(in.Hashes) != 0 && common.IsHex(in.Hashes[0]) {
var req types.ReqHash
Expand All @@ -1409,7 +1409,7 @@ func (c *Chain33) GetSequenceByHash(in rpctypes.ReqHashes, result *interface{})

}

//GetBlockBySeq get block by seq
// GetBlockBySeq get block by seq
func (c *Chain33) GetBlockBySeq(in *types.Int64, result *interface{}) error {

blockSeq, err := c.cli.GetBlockBySeq(in)
Expand Down Expand Up @@ -1445,7 +1445,7 @@ func convertHeader(header *types.Header, message *rpctypes.Header) {
}
}

//GetParaTxByTitle get paraTx by title
// GetParaTxByTitle get paraTx by title
func (c *Chain33) GetParaTxByTitle(req *types.ReqParaTxByTitle, result *interface{}) error {
paraTxDetails, err := c.cli.GetParaTxByTitle(req)
if err != nil {
Expand All @@ -1457,7 +1457,7 @@ func (c *Chain33) GetParaTxByTitle(req *types.ReqParaTxByTitle, result *interfac
return nil
}

//LoadParaTxByTitle load paratx by title
// LoadParaTxByTitle load paratx by title
func (c *Chain33) LoadParaTxByTitle(req *types.ReqHeightByTitle, result *interface{}) error {

reply, err := c.cli.LoadParaTxByTitle(req)
Expand Down Expand Up @@ -1511,7 +1511,7 @@ func convertParaTxDetails(details *types.ParaTxDetails, message *rpctypes.ParaTx

}

//GetParaTxByHeight get paraTx by block height
// GetParaTxByHeight get paraTx by block height
func (c *Chain33) GetParaTxByHeight(req *types.ReqParaTxByHeight, result *interface{}) error {
paraTxDetails, err := c.cli.GetParaTxByHeight(req)
if err != nil {
Expand All @@ -1524,7 +1524,7 @@ func (c *Chain33) GetParaTxByHeight(req *types.ReqParaTxByHeight, result *interf

}

//QueryChain querychain by chain executor
// QueryChain querychain by chain executor
func (c *Chain33) QueryChain(in rpctypes.ChainExecutor, result *interface{}) error {
var qin = new(types.ChainExecutor)
msg, err := types.QueryFunc.DecodeJSON(in.Driver, in.FuncName, in.Payload)
Expand Down Expand Up @@ -1614,14 +1614,19 @@ func (c *Chain33) SignWalletRecoverTx(req *types.ReqSignWalletRecoverTx, result
// GetChainConfig 获取chain config 参数
func (c *Chain33) GetChainConfig(in *types.ReqNil, result *interface{}) error {
cfg := c.cli.GetConfig()
currentH := int64(0)
lastH, err := c.cli.GetLastHeader()
if err == nil {
currentH = lastH.GetHeight()
}
info := rpctypes.ChainConfigInfo{
Title: cfg.GetTitle(),
CoinExec: cfg.GetCoinExec(),
CoinSymbol: cfg.GetCoinSymbol(),
CoinPrecision: cfg.GetCoinPrecision(),
TokenPrecision: cfg.GetTokenPrecision(),
ChainID: cfg.GetChainID(),
MaxTxFee: cfg.GetMaxTxFee(),
MaxTxFee: cfg.GetMaxTxFee(currentH),
MinTxFeeRate: cfg.GetMinTxFeeRate(),
MaxTxFeeRate: cfg.GetMaxTxFeeRate(),
IsPara: cfg.IsPara(),
Expand All @@ -1631,7 +1636,7 @@ func (c *Chain33) GetChainConfig(in *types.ReqNil, result *interface{}) error {
return nil
}

//AddBlacklist add peer to blacklist ,time deadline:10 years
// AddBlacklist add peer to blacklist ,time deadline:10 years
func (c *Chain33) AddBlacklist(in *types.BlackPeer, result *interface{}) error {
reply, err := c.cli.AddBlacklist(in)
if err != nil {
Expand All @@ -1645,7 +1650,7 @@ func (c *Chain33) AddBlacklist(in *types.BlackPeer, result *interface{}) error {

}

//DelBlacklist delete peer from blacklist
// DelBlacklist delete peer from blacklist
func (c *Chain33) DelBlacklist(in *types.BlackPeer, result *interface{}) error {
reply, err := c.cli.DelBlacklist(in)
if err != nil {
Expand All @@ -1659,7 +1664,7 @@ func (c *Chain33) DelBlacklist(in *types.BlackPeer, result *interface{}) error {

}

//ShowBlacklist show all peers from blacklist
// ShowBlacklist show all peers from blacklist
func (c *Chain33) ShowBlacklist(in *types.ReqNil, result *interface{}) error {
reply, err := c.cli.ShowBlacklist(in)
if err != nil {
Expand All @@ -1670,7 +1675,7 @@ func (c *Chain33) ShowBlacklist(in *types.ReqNil, result *interface{}) error {
return nil
}

//DialPeer dial the specified peer
// DialPeer dial the specified peer
func (c *Chain33) DialPeer(in *types.SetPeer, result *interface{}) error {
reply, err := c.cli.DialPeer(in)
if err != nil {
Expand All @@ -1683,7 +1688,7 @@ func (c *Chain33) DialPeer(in *types.SetPeer, result *interface{}) error {
return nil
}

//ClosePeer close the specified peer
// ClosePeer close the specified peer
func (c *Chain33) ClosePeer(in *types.SetPeer, result *interface{}) error {
reply, err := c.cli.ClosePeer(in)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion rpc/jrpchandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func TestChain33_CreateTxGroup(t *testing.T) {
t.Error("Test createtxgroup failed")
return
}
err = tx.Check(cfg, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee())
err = tx.Check(cfg, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee(0))
assert.Nil(t, err)
}

Expand Down Expand Up @@ -1862,9 +1862,11 @@ func TestChain33_GetChainConfig(t *testing.T) {
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{Height: 0}, nil)
client := newTestChain33(api)
var result interface{}
api.On("GetChainConfig").Return(nil)

err := client.GetChainConfig(&types.ReqNil{}, &result)
assert.Nil(t, err)
}
Expand Down
4 changes: 2 additions & 2 deletions system/dapp/commands/coins.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func addCreateEthTransferFlags(cmd *cobra.Command) {

}

//createTransferEthMode eth 交易构造
// createTransferEthMode eth 交易构造
func createTransferEthMode(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
toAddr, _ := cmd.Flags().GetString("to")
Expand Down Expand Up @@ -327,7 +327,7 @@ func createTxGroup(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stderr, err)
return
}
err = group.CheckWithFork(cfg, true, true, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee())
err = group.CheckWithFork(cfg, true, true, 0, cfg.GetMinTxFeeRate(), cfg.GetMaxTxFee(0))
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
Expand Down
Loading
Loading