public ResultWrapper <FeeHistoryResults> GetFeeHistory(long blockCount, BlockParameter newestBlock, double[]?rewardPercentiles = null)
        {
            ResultWrapper <FeeHistoryResults> initialCheckResult = Validate(ref blockCount, newestBlock, rewardPercentiles);

            if (initialCheckResult.Result.ResultType == ResultType.Failure)
            {
                return(initialCheckResult);
            }

            Block?block = _blockFinder.FindBlock(newestBlock);

            if (block is null)
            {
                return(ResultWrapper <FeeHistoryResults> .Fail("newestBlock: Block is not available", ErrorCodes.ResourceUnavailable));
            }

            long            oldestBlockNumber = block !.Number;
            Stack <UInt256> baseFeePerGas     = new((int)(blockCount + 1));

            baseFeePerGas.Push(BaseFeeCalculator.Calculate(block !.Header, _specProvider.GetSpec(block !.Number + 1)));
            Stack <double> gasUsedRatio = new Stack <double>((int)blockCount);

            Stack <UInt256[]>?rewards = rewardPercentiles is null || rewardPercentiles.Any() is false ? null : new Stack <UInt256[]>((int)blockCount);

            while (block is not null && blockCount > 0)
            {
                oldestBlockNumber = block.Number;
                baseFeePerGas.Push(block.BaseFeePerGas);
                gasUsedRatio.Push(block.GasUsed / (double)block.GasLimit);
                if (rewards is not null)
                {
                    List <UInt256> rewardsInBlock = CalculateRewardsPercentiles(block, rewardPercentiles);
                    if (rewardsInBlock is not null)
                    {
                        rewards.Push(rewardsInBlock.ToArray());
                    }
                }

                blockCount--;
                block = _blockFinder.FindParent(block, BlockTreeLookupOptions.RequireCanonical);
            }

            FeeHistoryResults feeHistoryResults = new(oldestBlockNumber, baseFeePerGas.ToArray(), gasUsedRatio.ToArray(), rewards?.ToArray());

            return(ResultWrapper <FeeHistoryResults> .Success(feeHistoryResults));
        }