Skip to content

Commit

Permalink
Allow decimal input of block count for fee history (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanliqun authored Jun 17, 2024
1 parent 01a1f49 commit 749a105
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Conflux-Chain/confura
go 1.22

require (
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240611031507-194d9c3a1028
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240617040104-ac9419006346
github.com/Conflux-Chain/go-conflux-util v0.2.1-0.20240415073045-459b298cdcbd
github.com/Conflux-Chain/web3pay-service v0.0.0-20230609030113-dc3c4d42820a
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Conflux-Chain/go-conflux-sdk v1.0.29/go.mod h1:eUYR736AUkH29rjeiPCLR2XXpH9stG2+NbztAXz1rJw=
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240611031507-194d9c3a1028 h1:NwIyt2EfjBqt2hwjRd9dFGMjmwELvxUjXt/+CYbp9cY=
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240611031507-194d9c3a1028/go.mod h1:Weq8Xz73APS9EVa2GCkc3HNBJKgIAH3vsM2cjQRXJTU=
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240617040104-ac9419006346 h1:Mgx6kfGpQSx+TFy0VTzOhb3a2+XjlWJRFSw6RgfyAOw=
github.com/Conflux-Chain/go-conflux-sdk v1.5.10-0.20240617040104-ac9419006346/go.mod h1:M1T8M7N65AmFFwQo1/kSWLZJr0pRiaWHzyFt1davx6w=
github.com/Conflux-Chain/go-conflux-util v0.0.0-20220907035343-2d1233bccd70/go.mod h1:dcfcQp/A6V0nu9LLqdcg8yv+lSg378JktLtuPUVcm4k=
github.com/Conflux-Chain/go-conflux-util v0.2.1-0.20240415073045-459b298cdcbd h1:zgY7RyJ1Rux70Z0/xf3ZHX+iRruLOApCq/I0ps/DZWk=
github.com/Conflux-Chain/go-conflux-util v0.2.1-0.20240415073045-459b298cdcbd/go.mod h1:8WdtAuUTRWLDPnyUgAqw5WPr6hM+WCp4R857nFc1l04=
Expand Down
2 changes: 1 addition & 1 deletion rpc/cfx_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (api *cfxAPI) GetParamsFromVote(ctx context.Context, epoch *types.Epoch) (p
}

func (api *cfxAPI) GetFeeHistory(
ctx context.Context, blockCount hexutil.Uint64, lastEpoch types.Epoch, rewardPercentiles []float64,
ctx context.Context, blockCount types.HexOrDecimalUint64, lastEpoch types.Epoch, rewardPercentiles []float64,
) (feeHistory *types.FeeHistory, err error) {
if len(rewardPercentiles) > maxNumRewardPercentiles {
return nil, errTooManyRewardPercentiles
Expand Down
8 changes: 1 addition & 7 deletions rpc/cfxbridge/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ func ConvertTx(tx *ethTypes.TransactionDetail, ethNetworkId uint32) *types.Trans
chainId = types.NewBigIntByRaw(tx.ChainID)
}

var acl *types.AccessList
if tx.Accesses != nil {
acl = &types.AccessList{}
acl.FromEthType(&tx.Accesses, ethNetworkId)
}

return &types.Transaction{
TransactionType: DeduceTxnType(tx),
Hash: types.Hash(tx.Hash.Hex()),
Expand All @@ -140,7 +134,7 @@ func ConvertTx(tx *ethTypes.TransactionDetail, ethNetworkId uint32) *types.Trans
EpochHeight: HexBig0,
ChainID: chainId,
Status: ConvertTxStatusNullable(tx.Status),
AccessList: acl,
AccessList: types.ConvertEthAccessListToCfx(tx.Accesses, ethNetworkId),
MaxPriorityFeePerGas: types.NewBigIntByRaw(tx.MaxPriorityFeePerGas),
MaxFeePerGas: types.NewBigIntByRaw(tx.MaxFeePerGas),
V: types.NewBigIntByRaw(tx.V),
Expand Down
4 changes: 2 additions & 2 deletions rpc/cfxbridge/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ func (req *EthCallRequest) ToCallMsg() ethTypes.CallRequest {
msg.Data = hexutil.MustDecode(*req.Data)
}

if req.AccessList != nil {
msg.AccessList = req.AccessList.ToEthType()
if acl := req.AccessList.ToEthType(); acl != nil {
msg.AccessList = &acl
}

return msg
Expand Down
3 changes: 2 additions & 1 deletion rpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Conflux-Chain/confura/util"
"github.com/Conflux-Chain/confura/util/metrics"
vfclient "github.com/Conflux-Chain/confura/virtualfilter/client"
"github.com/Conflux-Chain/go-conflux-sdk/types"
logutil "github.com/Conflux-Chain/go-conflux-util/log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -455,7 +456,7 @@ func (api *ethAPI) GetTransactionByBlockNumberAndIndex(

// FeeHistory returns historical gas information, which could be used for tracking trends over time.
func (api *ethAPI) FeeHistory(
ctx context.Context, blockCount hexutil.Uint64, lastBlock web3Types.BlockNumber, rewardPercentiles []float64,
ctx context.Context, blockCount types.HexOrDecimalUint64, lastBlock web3Types.BlockNumber, rewardPercentiles []float64,
) (val *web3Types.FeeHistory, err error) {
if len(rewardPercentiles) > maxNumRewardPercentiles {
return nil, errTooManyRewardPercentiles
Expand Down
7 changes: 1 addition & 6 deletions rpc/ethbridge/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ func ConvertTx(tx *cfxtypes.Transaction, txExt *store.TransactionExtra) *types.T
nonce = tx.Nonce.ToInt().Uint64()
}

var access gethTypes.AccessList
if tx.AccessList != nil {
access = *tx.AccessList.ToEthType()
}

ethTxn := &types.TransactionDetail{
Type: (*uint64)(tx.TransactionType),
Accesses: access,
Accesses: tx.AccessList.ToEthType(),
BlockHash: tx.BlockHash.ToCommonHash(),
ChainID: big.NewInt(int64(chainId)),
Creates: creates,
Expand Down

0 comments on commit 749a105

Please sign in to comment.