Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/add-historic-custom-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroNazarenko authored Jun 13, 2024
2 parents 44527ec + 38791ff commit 2720745
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion libconsensus
2 changes: 1 addition & 1 deletion libethereum/ClientBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class ClientBase : public Interface {
using Interface::blockInfo; // for another overload
using Interface::transactionHashes;
using Interface::uncle;
using Interface::uncleCount;
using Interface::uncleHashes;

h256 hashFromNumber( BlockNumber _number ) const override;
Expand Down Expand Up @@ -152,7 +153,6 @@ class ClientBase : public Interface {
}
return transactionCount( hashFromNumber( _block ) );
}
using Interface::uncleCount;
unsigned uncleCount( h256 _blockHash ) const override;
unsigned number() const override;
h256s pendingHashes() const override;
Expand Down
5 changes: 2 additions & 3 deletions libskale/broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ void* ZmqBroadcaster::server_socket() const {
val = 60000;
zmq_setsockopt( m_zmq_server_socket, ZMQ_HEARTBEAT_TTL, &val, sizeof( val ) );

// remove limits to prevent txns from being dropped out
val = 0;
val = 16;
zmq_setsockopt( m_zmq_server_socket, ZMQ_SNDHWM, &val, sizeof( val ) );


Expand Down Expand Up @@ -132,7 +131,7 @@ void* ZmqBroadcaster::client_socket() const {
value = 300;
zmq_setsockopt( m_zmq_client_socket, ZMQ_TCP_KEEPALIVE_INTVL, &value, sizeof( value ) );

value = 0;
value = 16;
zmq_setsockopt( m_zmq_client_socket, ZMQ_RCVHWM, &value, sizeof( value ) );

const dev::eth::ChainParams& ch = m_client.chainParams();
Expand Down
9 changes: 4 additions & 5 deletions libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ Json::Value Eth::eth_createAccessList(
return result;
}

Json::Value Eth::eth_feeHistory( const std::string& _blockCount, const std::string& _newestBlock,
Json::Value Eth::eth_feeHistory( dev::u256 _blockCount, const std::string& _newestBlock,
const Json::Value& _rewardPercentiles ) {
try {
if ( !_rewardPercentiles.isArray() )
Expand All @@ -974,8 +974,7 @@ Json::Value Eth::eth_feeHistory( const std::string& _blockCount, const std::stri
}
}

auto blockCount = jsToU256( _blockCount );
if ( blockCount > MAX_BLOCK_RANGE )
if ( _blockCount > MAX_BLOCK_RANGE )
throw std::runtime_error( "Max block range reached. Please try smaller blockCount." );

auto newestBlock = jsToBlockNumber( _newestBlock );
Expand All @@ -984,10 +983,10 @@ Json::Value Eth::eth_feeHistory( const std::string& _blockCount, const std::stri

auto result = Json::Value( Json::objectValue );
dev::u256 oldestBlock;
if ( blockCount > newestBlock )
if ( _blockCount > newestBlock )
oldestBlock = 1;
else
oldestBlock = dev::u256( newestBlock ) - blockCount + 1;
oldestBlock = dev::u256( newestBlock ) - _blockCount + 1;
result["oldestBlock"] = toJS( oldestBlock );

result["baseFeePerGas"] = Json::Value( Json::arrayValue );
Expand Down
2 changes: 1 addition & 1 deletion libweb3jsonrpc/Eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Eth : public dev::rpc::EthFace, public skutils::json_config_file_accessor
virtual Json::Value eth_createAccessList(
const Json::Value& param1, const std::string& param2 ) override;
virtual Json::Value eth_feeHistory(
const std::string& param1, const std::string& param2, const Json::Value& param3 ) override;
dev::u256 param1, const std::string& param2, const Json::Value& param3 ) override;
virtual std::string eth_maxPriorityFeePerGas() override;

void setTransactionDefaults( eth::TransactionSkeleton& _t );
Expand Down
14 changes: 9 additions & 5 deletions libweb3jsonrpc/EthFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "ModularServer.h"

#include <libdevcore/CommonJS.h>
#include <libethereum/TransactionReceipt.h>
#include <libweb3jsonrpc/JsonHelper.h>

Expand Down Expand Up @@ -222,8 +223,7 @@ class EthFace : public ServerInterface< EthFace > {
jsonrpc::JSON_OBJECT, "param2", jsonrpc::JSON_STRING, NULL ),
&dev::rpc::EthFace::eth_createAccessListI );
this->bindAndAddMethod( jsonrpc::Procedure( "eth_feeHistory", jsonrpc::PARAMS_BY_POSITION,
jsonrpc::JSON_OBJECT, "param1", jsonrpc::JSON_STRING, "param2",
jsonrpc::JSON_STRING, "param3", jsonrpc::JSON_ARRAY, NULL ),
jsonrpc::JSON_OBJECT, NULL ),
&dev::rpc::EthFace::eth_feeHistoryI );
this->bindAndAddMethod( jsonrpc::Procedure( "eth_maxPriorityFeePerGas",
jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL ),
Expand Down Expand Up @@ -449,8 +449,12 @@ class EthFace : public ServerInterface< EthFace > {
if ( !request.isArray() || request.size() != 3 )
BOOST_THROW_EXCEPTION(
jsonrpc::JsonRpcException( jsonrpc::Errors::ERROR_RPC_INVALID_PARAMS ) );
response =
this->eth_feeHistory( request[0u].asString(), request[1u].asString(), request[2u] );
if ( !request[0u].isString() && !request[0u].isUInt() )
BOOST_THROW_EXCEPTION(
jsonrpc::JsonRpcException( jsonrpc::Errors::ERROR_RPC_INVALID_PARAMS ) );
auto blockCount = request[0u].isString() ? dev::jsToU256( request[0u].asString() ) :
dev::u256( request[0u].asUInt() );
response = this->eth_feeHistory( blockCount, request[1u].asString(), request[2u] );
}
inline virtual void eth_maxPriorityFeePerGasI(
const Json::Value& request, Json::Value& response ) {
Expand Down Expand Up @@ -525,7 +529,7 @@ class EthFace : public ServerInterface< EthFace > {
virtual Json::Value eth_createAccessList(
const Json::Value& param1, const std::string& param2 ) = 0;
virtual Json::Value eth_feeHistory(
const std::string& param1, const std::string& param2, const Json::Value& param3 ) = 0;
dev::u256 param1, const std::string& param2, const Json::Value& param3 ) = 0;
virtual std::string eth_maxPriorityFeePerGas() = 0;
};

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/libethereum/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace dev::test;
using namespace dev::p2p;
namespace fs = boost::filesystem;

static size_t rand_port = 1024 + rand() % 64000;
static size_t rand_port = ( srand(time(nullptr)), 1024 + rand() % 64000 );

struct FixtureCommon {
const string BTRFS_FILE_PATH = "btrfs.file";
Expand Down
7 changes: 5 additions & 2 deletions test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,12 @@ Json::Value WebThreeStubClient::eth_createAccessList( const Json::Value& param1,
jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString() );
}

Json::Value WebThreeStubClient::eth_feeHistory( const std::string& param1, const std::string& param2, const Json::Value& param3 ) {
Json::Value WebThreeStubClient::eth_feeHistory( const Json::Value& param1, const std::string& param2, const Json::Value& param3 ) {
Json::Value p;
p.append( param1 );
if ( param1.isString() )
p.append( param1.asString() );
if ( param1.isUInt() )
p.append( param1.asUInt() );
p.append( param2 );
p.append( param3 );
Json::Value result = this->CallMethod( "eth_feeHistory", p );
Expand Down
4 changes: 3 additions & 1 deletion test/unittests/libweb3jsonrpc/WebThreeStubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_
#define JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_

#include <any>

#include <jsonrpccpp/client.h>

class WebThreeStubClient : public jsonrpc::Client {
Expand Down Expand Up @@ -98,7 +100,7 @@ class WebThreeStubClient : public jsonrpc::Client {
std::string eth_sendRawTransaction( const std::string& param1 ) noexcept( false );
std::string eth_maxPriorityFeePerGas() noexcept( false );
Json::Value eth_createAccessList( const Json::Value& param1, const std::string& param2 ) noexcept( false );
Json::Value eth_feeHistory( const std::string& param1, const std::string& param2, const Json::Value& param3 ) noexcept( false );
Json::Value eth_feeHistory( const Json::Value& param1, const std::string& param2, const Json::Value& param3 ) noexcept( false );
bool eth_notePassword( const std::string& param1 ) noexcept( false );
bool db_put( const std::string& param1, const std::string& param2,
const std::string& param3 ) noexcept( false );
Expand Down
9 changes: 6 additions & 3 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ JsonRpcFixture( const std::string& _config = "", bool _owner = true,
serverOpts.netOpts_.bindOptsStandard_.cntServers_ = 1;
serverOpts.netOpts_.bindOptsStandard_.strAddrHTTP4_ = chainParams.nodeInfo.ip;
// random port
serverOpts.netOpts_.bindOptsStandard_.nBasePortHTTP4_ = std::rand() % 64000 + 1025;
// +3 because rand() seems to be called effectively simultaneously here and in "static" section - thus giving same port for consensus
serverOpts.netOpts_.bindOptsStandard_.nBasePortHTTP4_ = std::rand() % 64000 + 1025 + 3;
std::cout << "PORT: " << serverOpts.netOpts_.bindOptsStandard_.nBasePortHTTP4_ << std::endl;
skale_server_connector = new SkaleServerOverride( chainParams, client.get(), serverOpts );
rpcServer->addConnector( skale_server_connector );
Expand Down Expand Up @@ -846,7 +847,7 @@ BOOST_AUTO_TEST_CASE( simple_contract ) {
// }
// }

string compiled =
string compiled =
"608060405234801561001057600080fd5b506101ef8061002060003"
"96000f3fe608060405234801561001057600080fd5b506004361061"
"00365760003560e01c8063552410771461003b578063b3de648b146"
Expand Down Expand Up @@ -3226,6 +3227,8 @@ BOOST_AUTO_TEST_CASE( eip1559RpcMethods ) {
BOOST_REQUIRE_EQUAL( feeHistory["reward"][i][j].asString(), toJS( 0 ) );
}
}

BOOST_REQUIRE_NO_THROW( fixture.rpcClient->eth_feeHistory( blockCnt, "latest", percentiles ) );
}

BOOST_AUTO_TEST_CASE( etherbase_generation2 ) {
Expand Down Expand Up @@ -4075,7 +4078,7 @@ BOOST_AUTO_TEST_CASE( cached_filestorage ) {
auto _config = c_genesisConfigString;
Json::Value ret;
Json::Reader().parse( _config, ret );
ret["skaleConfig"]["sChain"]["revertableFSPatchTimestamp"] = 1;
ret["skaleConfig"]["sChain"]["revertableFSPatchTimestamp"] = 1;
Json::FastWriter fastWriter;
std::string config = fastWriter.write( ret );
RestrictedAddressFixture fixture( config );
Expand Down

0 comments on commit 2720745

Please sign in to comment.