Merge branch 'release/v1.20.0' into asr/merge-release-into-master
This commit is contained in:
@@ -80,7 +80,7 @@ func (e *EthModuleDummy) EthGetBalance(ctx context.Context, address ethtypes.Eth
|
||||
return ethtypes.EthBigIntZero, ErrModuleDisabled
|
||||
}
|
||||
|
||||
func (e *EthModuleDummy) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
|
||||
func (e *EthModuleDummy) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error) {
|
||||
return ethtypes.EthFeeHistory{}, ErrModuleDisabled
|
||||
}
|
||||
|
||||
|
||||
+33
-30
@@ -57,7 +57,7 @@ type EthModuleAPI interface {
|
||||
EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error)
|
||||
EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error)
|
||||
EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error)
|
||||
EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlk string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error)
|
||||
EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error)
|
||||
EthChainId(ctx context.Context) (ethtypes.EthUint64, error)
|
||||
NetVersion(ctx context.Context) (string, error)
|
||||
NetListening(ctx context.Context) (bool, error)
|
||||
@@ -581,35 +581,30 @@ func (a *EthModule) EthChainId(ctx context.Context) (ethtypes.EthUint64, error)
|
||||
return ethtypes.EthUint64(build.Eip155ChainId), nil
|
||||
}
|
||||
|
||||
func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint64, newestBlkNum string, rewardPercentiles []float64) (ethtypes.EthFeeHistory, error) {
|
||||
if blkCount > 1024 {
|
||||
func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error) {
|
||||
params, err := jsonrpc.DecodeParams[ethtypes.EthFeeHistoryParams](p)
|
||||
if err != nil {
|
||||
return ethtypes.EthFeeHistory{}, xerrors.Errorf("decoding params: %w", err)
|
||||
}
|
||||
if params.BlkCount > 1024 {
|
||||
return ethtypes.EthFeeHistory{}, fmt.Errorf("block count should be smaller than 1024")
|
||||
}
|
||||
|
||||
newestBlkHeight := uint64(a.Chain.GetHeaviestTipSet().Height())
|
||||
|
||||
// TODO https://github.com/filecoin-project/ref-fvm/issues/1016
|
||||
var blkNum ethtypes.EthUint64
|
||||
err := blkNum.UnmarshalJSON([]byte(`"` + newestBlkNum + `"`))
|
||||
if err == nil && uint64(blkNum) < newestBlkHeight {
|
||||
newestBlkHeight = uint64(blkNum)
|
||||
}
|
||||
|
||||
// Deal with the case that the chain is shorter than the number of
|
||||
// requested blocks.
|
||||
oldestBlkHeight := uint64(1)
|
||||
if uint64(blkCount) <= newestBlkHeight {
|
||||
oldestBlkHeight = newestBlkHeight - uint64(blkCount) + 1
|
||||
}
|
||||
|
||||
ts, err := a.Chain.GetTipsetByHeight(ctx, abi.ChainEpoch(newestBlkHeight), nil, false)
|
||||
ts, err := a.parseBlkParam(ctx, params.NewestBlkNum)
|
||||
if err != nil {
|
||||
return ethtypes.EthFeeHistory{}, fmt.Errorf("cannot load find block height: %v", newestBlkHeight)
|
||||
return ethtypes.EthFeeHistory{}, fmt.Errorf("bad block parameter %s: %s", params.NewestBlkNum, err)
|
||||
}
|
||||
|
||||
// FIXME: baseFeePerGas should include the next block after the newest of the returned range, because this
|
||||
// can be inferred from the newest block. we use the newest block's baseFeePerGas for now but need to fix it
|
||||
// In other words, due to deferred execution, we might not be returning the most useful value here for the client.
|
||||
// Deal with the case that the chain is shorter than the number of requested blocks.
|
||||
oldestBlkHeight := uint64(1)
|
||||
if abi.ChainEpoch(params.BlkCount) <= ts.Height() {
|
||||
oldestBlkHeight = uint64(ts.Height()) - uint64(params.BlkCount) + 1
|
||||
}
|
||||
|
||||
// NOTE: baseFeePerGas should include the next block after the newest of the returned range,
|
||||
// because the next base fee can be inferred from the messages in the newest block.
|
||||
// However, this is NOT the case in Filecoin due to deferred execution, so the best
|
||||
// we can do is duplicate the last value.
|
||||
baseFeeArray := []ethtypes.EthBigInt{ethtypes.EthBigInt(ts.Blocks()[0].ParentBaseFee)}
|
||||
gasUsedRatioArray := []float64{}
|
||||
|
||||
@@ -633,7 +628,6 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint
|
||||
}
|
||||
|
||||
// Reverse the arrays; we collected them newest to oldest; the client expects oldest to newest.
|
||||
|
||||
for i, j := 0, len(baseFeeArray)-1; i < j; i, j = i+1, j-1 {
|
||||
baseFeeArray[i], baseFeeArray[j] = baseFeeArray[j], baseFeeArray[i]
|
||||
}
|
||||
@@ -641,11 +635,21 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, blkCount ethtypes.EthUint
|
||||
gasUsedRatioArray[i], gasUsedRatioArray[j] = gasUsedRatioArray[j], gasUsedRatioArray[i]
|
||||
}
|
||||
|
||||
return ethtypes.EthFeeHistory{
|
||||
ret := ethtypes.EthFeeHistory{
|
||||
OldestBlock: ethtypes.EthUint64(oldestBlkHeight),
|
||||
BaseFeePerGas: baseFeeArray,
|
||||
GasUsedRatio: gasUsedRatioArray,
|
||||
}, nil
|
||||
}
|
||||
if params.RewardPercentiles != nil {
|
||||
// TODO: Populate reward percentiles
|
||||
// https://github.com/filecoin-project/lotus/issues/10236
|
||||
// We need to calculate the requested percentiles of effective gas premium
|
||||
// based on the newest block (I presume it's the newest, we need to dig in
|
||||
// as it's underspecified). Effective means we're clamped at the gas_fee_cap - base_fee.
|
||||
reward := make([][]ethtypes.EthBigInt, 0)
|
||||
ret.Reward = &reward
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (a *EthModule) NetVersion(ctx context.Context) (string, error) {
|
||||
@@ -761,10 +765,9 @@ func (a *EthModule) ethCallToFilecoinMessage(ctx context.Context, tx ethtypes.Et
|
||||
return nil, fmt.Errorf("failed to encode tx input into a cbor byte-string")
|
||||
}
|
||||
params = buf.Bytes()
|
||||
method = builtintypes.MethodsEVM.InvokeContract
|
||||
} else {
|
||||
method = builtintypes.MethodSend
|
||||
}
|
||||
|
||||
method = builtintypes.MethodsEVM.InvokeContract
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
|
||||
Reference in New Issue
Block a user