Skip to content

Commit

Permalink
Merge branch 'v3.19.0' into develop-to-3.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev authored May 17, 2024
2 parents 1b54222 + 932e183 commit 9d1d3cd
Show file tree
Hide file tree
Showing 124 changed files with 3,145 additions and 1,593 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: skalenetwork/skale-ci-integration_tests
ref: v3.18.0
ref: master
submodules: recursive
- name: Set up Node
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.18.1
3.19.0
2 changes: 1 addition & 1 deletion libconsensus
Submodule libconsensus updated 52 files
+4 −1 .github/workflows/build.yml
+6 −0 .github/workflows/dockerimage.yml
+3 −0 .idea/misc.xml
+51 −41 .idea/workspace.xml
+3 −2 Consensust.cpp
+72 −11 chains/Schain.cpp
+17 −4 chains/Schain.h
+7 −2 chains/SchainGettersSetters.cpp
+9 −5 crypto/CryptoManager.cpp
+21 −0 datastructures/BooleanProposalVector.cpp
+2 −0 datastructures/BooleanProposalVector.h
+1 −1 datastructures/CommittedBlockList.cpp
+10 −0 db/BlockProposalDB.cpp
+441 −0 docs/consensus-spec.md
+124 −0 monitoring/OptimizerAgent.cpp
+48 −0 monitoring/OptimizerAgent.h
+0 −2 network/Network.cpp
+18 −15 node/ConsensusEngine.cpp
+1 −1 node/ConsensusEngine.h
+10 −1 node/Node.cpp
+75 −61 pendingqueue/PendingTransactionsAgent.cpp
+17 −16 pendingqueue/TestMessageGeneratorAgent.cpp
+6 −0 pendingqueue/TestMessageGeneratorAgent.h
+135 −71 protocols/blockconsensus/BlockConsensusAgent.cpp
+11 −0 protocols/blockconsensus/BlockConsensusAgent.h
+3 −1 test/11_out_of_16/node1/Node.json
+3 −1 test/11_out_of_16/node10/Node.json
+3 −1 test/11_out_of_16/node11/Node.json
+3 −1 test/11_out_of_16/node2/Node.json
+3 −1 test/11_out_of_16/node3/Node.json
+3 −1 test/11_out_of_16/node4/Node.json
+3 −1 test/11_out_of_16/node5/Node.json
+3 −1 test/11_out_of_16/node6/Node.json
+3 −1 test/11_out_of_16/node7/Node.json
+3 −1 test/11_out_of_16/node8/Node.json
+3 −1 test/11_out_of_16/node9/Node.json
+3 −1 test/sixteennodes/node01/Node.json
+3 −1 test/sixteennodes/node02/Node.json
+3 −1 test/sixteennodes/node03/Node.json
+3 −1 test/sixteennodes/node04/Node.json
+3 −1 test/sixteennodes/node05/Node.json
+3 −1 test/sixteennodes/node06/Node.json
+3 −1 test/sixteennodes/node07/Node.json
+3 −1 test/sixteennodes/node08/Node.json
+3 −1 test/sixteennodes/node09/Node.json
+3 −1 test/sixteennodes/node10/Node.json
+3 −1 test/sixteennodes/node11/Node.json
+3 −1 test/sixteennodes/node12/Node.json
+3 −1 test/sixteennodes/node13/Node.json
+3 −1 test/sixteennodes/node14/Node.json
+3 −1 test/sixteennodes/node15/Node.json
+2 −1 test/sixteennodes/node16/Node.json
6 changes: 4 additions & 2 deletions libdevcore/JsonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ std::string dev::jsonTypeAsString( json_spirit::Value_type _type ) {
}

void dev::requireJsonFields( json_spirit::mObject const& _o, std::string const& _config,
std::map< std::string, JsonFieldOptions > const& _validationMap ) {
std::map< std::string, JsonFieldOptions > const& _validationMap,
std::function< bool( const std::string& ) > _callbackForUnexpected ) {
// check for unexpected fiedls
for ( auto const& field : _o ) {
if ( !_validationMap.count( field.first ) ) {
// _callbackForUnexpected allows to accept ertain unexpected fields
if ( !_validationMap.count( field.first ) && !_callbackForUnexpected( field.first ) ) {
std::string const comment =
"Unexpected field '" + field.first + "' in config: " + _config;
cerror << comment << "\n"
Expand Down
8 changes: 6 additions & 2 deletions libdevcore/JsonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ using JsonFieldOptions = std::pair< JsonTypeSet, JsonFieldPresence >;
@param _validationMap a map with json objects that would be checked. "objName" -> {js::str_type,
jsonField::Required}
*/
void requireJsonFields( json_spirit::mObject const& _o, std::string const& _configName,
std::map< std::string, JsonFieldOptions > const& _validationMap );
void requireJsonFields(
json_spirit::mObject const& _o, std::string const& _configName,
std::map< std::string, JsonFieldOptions > const& _validationMap,
std::function< bool( const std::string& ) > _callbackForUnexpected = []( const std::string& ) {
return false;
} );
} // namespace dev
2 changes: 1 addition & 1 deletion libdevcore/LevelDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <leveldb/write_batch.h>
#include <boost/filesystem.hpp>

#include "shared_mutex"
#include <secp256k1_sha256.h>
#include <shared_mutex>

namespace dev::db {
class LevelDB : public DatabaseFace {
Expand Down
12 changes: 0 additions & 12 deletions libethashseal/Ethash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,6 @@ void Ethash::verify( Strictness _s, BlockHeader const& _bi, BlockHeader const& _
}
}

void Ethash::verifyTransaction( ImportRequirements::value _ir, TransactionBase const& _t,
BlockHeader const& _header, u256 const& _startGasUsed ) const {
SealEngineFace::verifyTransaction( _ir, _t, _header, _startGasUsed );

if ( _ir & ImportRequirements::TransactionSignatures ) {
if ( _header.number() >= chainParams().EIP158ForkBlock ) {
uint64_t chainID = chainParams().chainID;
_t.checkChainId( chainID, chainParams().skaleDisableChainIdCheck );
} // if
}
}

u256 Ethash::childGasLimit( BlockHeader const& _bi, u256 const& _gasFloorTarget ) const {
u256 gasFloorTarget = _gasFloorTarget == Invalid256 ? 3141562 : _gasFloorTarget;
u256 gasLimit = _bi.gasLimit();
Expand Down
2 changes: 0 additions & 2 deletions libethashseal/Ethash.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class Ethash : public SealEngineBase {
StringHashMap jsInfo( BlockHeader const& _bi ) const override;
void verify( Strictness _s, BlockHeader const& _bi, BlockHeader const& _parent,
bytesConstRef _block ) const override;
void verifyTransaction( ImportRequirements::value _ir, TransactionBase const& _t,
BlockHeader const& _header, u256 const& _startGasUsed ) const override;
void populateFromParent( BlockHeader& _bi, BlockHeader const& _parent ) const override;

strings sealers() const override;
Expand Down
83 changes: 47 additions & 36 deletions libethcore/ChainOperationParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/

#include "ChainOperationParams.h"

#include <libethereum/SchainPatch.h>

#include <libdevcore/CommonData.h>
#include <libdevcore/Log.h>

Expand All @@ -42,6 +45,14 @@ PrecompiledContract::PrecompiledContract( unsigned _base, unsigned _word,
},
_exec, _startingBlock, _allowedAddresses ) {}

time_t SChain::getPatchTimestamp( SchainPatchEnum _patchEnum ) const {
assert( _patchEnum < SchainPatchEnum::PatchesCount );
if ( _patchEnum < SchainPatchEnum::PatchesCount )
return _patchTimestamps[static_cast< size_t >( _patchEnum )];
else
return 0;
}

ChainOperationParams::ChainOperationParams()
: m_blockReward( "0x4563918244F40000" ),
minGasLimit( 0x1388 ),
Expand All @@ -52,43 +63,33 @@ ChainOperationParams::ChainOperationParams()
difficultyBoundDivisor( 0x0800 ),
durationLimit( 0x0d ) {}

EVMSchedule const& ChainOperationParams::scheduleForBlockNumber( u256 const& _blockNumber ) const {
if ( _blockNumber >= skaleUnlimitedForkBlock )
return SkaleSchedule_Unlimited;
else if ( _blockNumber >= skale1024ForkBlock )
return SkaleSchedule_1024k;
else if ( _blockNumber >= skale512ForkBlock )
return SkaleSchedule_512k;
else if ( _blockNumber >= skale256ForkBlock )
return SkaleSchedule_256k;
else if ( _blockNumber >= skale128ForkBlock )
return SkaleSchedule_128k;
else if ( _blockNumber >= skale64ForkBlock )
return SkaleSchedule_64k;
else if ( _blockNumber >= skale32ForkBlock )
return SkaleSchedule_32k;
else if ( _blockNumber >= skale16ForkBlock )
return SkaleSchedule_16k;
else if ( _blockNumber >= experimentalForkBlock )
return ExperimentalSchedule;
else if ( _blockNumber >= istanbulForkBlock )
return IstanbulSchedule;
else if ( _blockNumber >= constantinopleFixForkBlock )
return ConstantinopleFixSchedule;
else if ( _blockNumber >= constantinopleForkBlock )
return ConstantinopleSchedule;
else if ( _blockNumber >= eWASMForkBlock )
return EWASMSchedule;
else if ( _blockNumber >= byzantiumForkBlock )
return ByzantiumSchedule;
else if ( _blockNumber >= EIP158ForkBlock )
return EIP158Schedule;
else if ( _blockNumber >= EIP150ForkBlock )
return EIP150Schedule;
else if ( _blockNumber >= homesteadForkBlock )
return HomesteadSchedule;
EVMSchedule const ChainOperationParams::makeEvmSchedule(
time_t _committedBlockTimestamp, u256 const& _workingBlockNumber ) const {
EVMSchedule result;

// 1 decide by block number
if ( _workingBlockNumber >= experimentalForkBlock )
result = ExperimentalSchedule;
else if ( _workingBlockNumber >= istanbulForkBlock )
result = IstanbulSchedule;
else if ( _workingBlockNumber >= constantinopleFixForkBlock )
result = ConstantinopleFixSchedule;
else if ( _workingBlockNumber >= constantinopleForkBlock )
result = ConstantinopleSchedule;
else if ( _workingBlockNumber >= byzantiumForkBlock )
result = ByzantiumSchedule;
else if ( _workingBlockNumber >= EIP158ForkBlock )
result = EIP158Schedule;
else if ( _workingBlockNumber >= EIP150ForkBlock )
result = EIP150Schedule;
else
return FrontierSchedule;
result = HomesteadSchedule;

// 2 based on previous - decide by timestamp
if ( PushZeroPatch::isEnabledWhen( _committedBlockTimestamp ) )
result = PushZeroPatch::makeSchedule( result );

return result;
}

u256 ChainOperationParams::blockReward( EVMSchedule const& _schedule ) const {
Expand All @@ -98,6 +99,16 @@ u256 ChainOperationParams::blockReward( EVMSchedule const& _schedule ) const {
return m_blockReward;
}

u256 ChainOperationParams::blockReward(
time_t _committedBlockTimestamp, u256 const& _workingBlockNumber ) const {
EVMSchedule const& schedule{ makeEvmSchedule( _committedBlockTimestamp, _workingBlockNumber ) };
return blockReward( schedule );
}

void ChainOperationParams::setBlockReward( u256 const& _newBlockReward ) {
m_blockReward = _newBlockReward;
}

time_t ChainOperationParams::getPatchTimestamp( SchainPatchEnum _patchEnum ) const {
return sChain.getPatchTimestamp( _patchEnum );
}
45 changes: 33 additions & 12 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <libdevcore/Common.h>
#include <libethereum/Precompiled.h>
#include <libethereum/SchainPatchEnum.h>

#include "libethcore/Common.h"
#include "libethcore/EVMSchedule.h"
Expand Down Expand Up @@ -89,6 +90,7 @@ struct NodeInfo {
bool syncNode;
bool archiveMode;
bool syncFromCatchup;
bool testSignatures;

NodeInfo( std::string _name = "TestNode", u256 _id = 1, std::string _ip = "127.0.0.11",
uint16_t _port = 11111, std::string _ip6 = "::1", uint16_t _port6 = 11111,
Expand All @@ -106,7 +108,8 @@ struct NodeInfo {
"11559732032986387107991004021392285783925812861821192530917403151452391805634",
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
"4082367875863433681332203403145435568316851327593401208105741076214120093531" },
bool _syncNode = false, bool _archiveMode = false, bool _syncFromCatchup = false ) {
bool _syncNode = false, bool _archiveMode = false, bool _syncFromCatchup = false,
bool _testSignatures = true ) {
name = _name;
id = _id;
ip = _ip;
Expand All @@ -121,6 +124,7 @@ struct NodeInfo {
syncNode = _syncNode;
archiveMode = _archiveMode;
syncFromCatchup = _syncFromCatchup;
testSignatures = _testSignatures;
}
};

Expand Down Expand Up @@ -173,16 +177,12 @@ struct SChain {
int emptyBlockIntervalMs = -1;
int64_t levelDBReopenIntervalMs = -1;
size_t t = 1;
time_t revertableFSPatchTimestamp = 0;
time_t contractStoragePatchTimestamp = 0;
time_t contractStorageZeroValuePatchTimestamp = 0;
time_t verifyDaSigsPatchTimestamp = 0;
time_t storageDestructionPatchTimestamp = 0;
time_t powCheckPatchTimestamp = 0;
time_t precompiledConfigPatchTimestamp = 0;
time_t pushZeroPatchTimestamp = 0;
time_t skipInvalidTransactionsPatchTimestamp = 0;
time_t correctForkInPowPatchTimestamp = 0;

// key is patch name
// public - for tests, don't access it directly
std::vector< time_t > _patchTimestamps =
std::vector< time_t >( static_cast< int >( SchainPatchEnum::PatchesCount ) );
time_t getPatchTimestamp( SchainPatchEnum _patchEnum ) const;

SChain() {
name = "TestChain";
Expand Down Expand Up @@ -210,8 +210,10 @@ struct ChainOperationParams {
u256 m_blockReward;

public:
EVMSchedule const& scheduleForBlockNumber( u256 const& _blockNumber ) const;
EVMSchedule const makeEvmSchedule(
time_t _committedBlockTimestamp, u256 const& _workingBlockNumber ) const;
u256 blockReward( EVMSchedule const& _schedule ) const;
u256 blockReward( time_t _committedBlockTimestamp, u256 const& _workingBlockNumber ) const;
void setBlockReward( u256 const& _newBlockReward );
u256 maximumExtraDataSize = 1024;
u256 accountStartNonce = 0;
Expand Down Expand Up @@ -257,6 +259,25 @@ struct ChainOperationParams {
u256 externalGasDifficulty = ~u256( 0 );
typedef std::vector< std::string > vecAdminOrigins_t;
vecAdminOrigins_t vecAdminOrigins; // wildcard based folters for IP addresses
int getLogsBlocksLimit = -1;

time_t getPatchTimestamp( SchainPatchEnum _patchEnum ) const;

bool isPrecompiled( Address const& _a, u256 const& _blockNumber ) const {
return precompiled.count( _a ) != 0 && _blockNumber >= precompiled.at( _a ).startingBlock();
}
bigint costOfPrecompiled(
Address const& _a, bytesConstRef _in, u256 const& _blockNumber ) const {
return precompiled.at( _a ).cost( _in, *this, _blockNumber );
}
std::pair< bool, bytes > executePrecompiled(
Address const& _a, bytesConstRef _in, u256 const& ) const {
return precompiled.at( _a ).execute( _in );
}
bool precompiledExecutionAllowedFrom(
Address const& _a, Address const& _from, bool _readOnly ) const {
return precompiled.at( _a ).executionAllowedFrom( _from, _readOnly );
}
};

} // namespace eth
Expand Down
17 changes: 17 additions & 0 deletions libethcore/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,26 @@ std::string formatBalance( bigint const& _b ) {
}

bytes isAddressWhitelistedCallData( Address const& _deployer ) {
// Generating calldata for isAddressWhitelisted contract call:
// 13f44d1 - selector of isAddressWhitelisted function
// 000000000000000000000000 - 12-byte offset for sender address
// _deployer - 20-byte sender address

return fromHex( "13f44d10000000000000000000000000" + _deployer.hex() );
}

bytes isDeploymentAllowedCallData( Address const& _origin, Address const& _deployer ) {
// Generating calldata for isDeploymentAllowed contract call:
// d0f557f4 - selector of isDeploymentAllowed function
// 000000000000000000000000 - 12-byte offset for origin address
// _origin - 20-byte origin address
// 000000000000000000000000 - 12-byte offset for sender address
// _deployer - 20-byte sender address

return fromHex( "d0f557f4000000000000000000000000" + _origin.hex() +
"000000000000000000000000" + _deployer.hex() );
}

bytes getMultitransactionCallData() {
return fromHex( "0xbad0396e" );
}
Expand Down
5 changes: 4 additions & 1 deletion libethcore/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ extern const bytes c_blockhashContractCode;
/// Address of the special contract for deployment control
extern const Address c_configControllerContractAddress;

/// Formatting call data for deployment control contract
/// Generating call data for deployment control contract
bytes isAddressWhitelistedCallData( Address const& _deployer );

/// Generating calldata for deployment control contract, considering tx origin
bytes isDeploymentAllowedCallData( Address const& _origin, Address const& _deployer );

/// Formatting call data for multitransaction contract
bytes getMultitransactionCallData();

Expand Down
Loading

0 comments on commit 9d1d3cd

Please sign in to comment.