Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat-block-finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
bysomeone committed May 7, 2024
2 parents 25b1b0c + ca0c2c6 commit bf2d521
Show file tree
Hide file tree
Showing 30 changed files with 164 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 'oldstable'
go-version: '1.20'
- run: |
go env
make build
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
changelog

<a name="1.68.2"></a>
## [1.68.2](https://github.com/33cn/chain33/compare/v1.68.1...v1.68.2) (2024-04-12)


### Bug Fixes

* add format eth address fork ([ee8af86](https://github.com/33cn/chain33/commit/ee8af86))

<a name="1.68.1"></a>
## [1.68.1](https://github.com/33cn/chain33/compare/v1.68.0...v1.68.1) (2023-09-12)

Expand Down
2 changes: 1 addition & 1 deletion account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func TestAccountKey(t *testing.T) {

acc := NewCoinsAccount(types.NewChain33Config(types.GetDefaultCfgstring()))
addr := "0x6c0d7BE0d2C8350042890a77393158181716b0d6"
addr1 := address.ToLower(addr)
addr1 := address.FormatEthAddress(addr)
accKey := acc.accountReadKey(addr)
require.Equal(t, accKey, acc.AccountKey(addr))
require.Equal(t, accKey, acc.AccountKey(addr1))
Expand Down
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
3 changes: 2 additions & 1 deletion cmd/chain33/chain33.fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ ForkCacheDriver=2580000
ForkTicketFundAddrV1=3350000
ForkRootHash=4500000
ForkFormatAddressKey=0
ForkEthAddressFormat=0
ForkCheckEthTxSort=0
ForkProxyExec=0

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

Expand Down
2 changes: 2 additions & 0 deletions cmd/chain33/chain33.system.fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ ForkCacheDriver=2580000
ForkTicketFundAddrV1=3350000
ForkRootHash=4500000
ForkFormatAddressKey=0
ForkEthAddressFormat=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
7 changes: 5 additions & 2 deletions common/address/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import (
// ForkFormatAddressKey 地址key格式化分叉名称,主要针对eth地址
const ForkFormatAddressKey = "ForkFormatAddressKey"

// ForkEthAddressFormat eth地址统一格式化
const ForkEthAddressFormat = "ForkEthAddressFormat"

// IsEthAddress verifies whether a string can represent
// a valid hex-encoded eth address
func IsEthAddress(addr string) bool {
return common.IsHexAddress(addr)
}

// ToLower to lower case string
func ToLower(addr string) string {
// FormatEthAddress eth地址格式化
func FormatEthAddress(addr string) string {
return strings.ToLower(addr)
}

Expand Down
2 changes: 1 addition & 1 deletion common/address/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestFormatAddrKey(t *testing.T) {
addrKey1 := fmt.Sprintf("%s:%s", "addrKey:", FormatAddrKey(addr1))
addrKey2 := fmt.Sprintf("%s:%s", "addrKey:", FormatAddrKey(addr2))

expect := fmt.Sprintf("%s:%s", "addrKey:", string(FormatAddrKey(ToLower(addr1))))
expect := fmt.Sprintf("%s:%s", "addrKey:", string(FormatAddrKey(FormatEthAddress(addr1))))

require.Equal(t, expect, addrKey1)
require.Equal(t, expect, addrKey2)
Expand Down
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package version

//Version chain33 version
var Version = "1.68.1"
var Version = "1.68.2"

//var version key
var (
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 @@ -1395,7 +1395,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 @@ -1413,7 +1413,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 @@ -1449,7 +1449,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 @@ -1461,7 +1461,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 @@ -1515,7 +1515,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 @@ -1528,7 +1528,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 @@ -1618,14 +1618,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 @@ -1635,7 +1640,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 @@ -1649,7 +1654,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 @@ -1663,7 +1668,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 @@ -1674,7 +1679,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 @@ -1687,7 +1692,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
Loading

0 comments on commit bf2d521

Please sign in to comment.