Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/skaled 1583 patch architecture plus 17.2 #1868

Merged
merged 62 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
254c979
SKALED-1583 Experiments with Patch Architecture
dimalit Feb 1, 2024
b58b6b1
SKALED-1583 Get rid of SealEngine
dimalit Feb 2, 2024
d5ac1eb
SKALED-1583 Introduce previous block timestamp parameter in various p…
dimalit Feb 5, 2024
31b663e
SKALED-1583 Draft usage of block timestamp for fork estimation
dimalit Feb 6, 2024
6c1a619
SKALED-1583 Added _lastBlockTimetamp everywhere, builds
dimalit Feb 7, 2024
eb693f7
SKALED-1583 Use Block's m_previousBlock
dimalit Feb 7, 2024
590809c
SKALED-1583 Add latestBlockTimestamp to EnvInfo -> Executive, Block, …
dimalit Feb 7, 2024
4e52e04
SKALED-1583 Remove latestBlockTimestamp from AlethExtVM too
dimalit Feb 7, 2024
8fe5cc9
SKALED-1583 Add and try DEFINE_AMNESIC_PATCH
dimalit Feb 8, 2024
eb0361c
SKALED-1583 Try SkipInvalidTransactionsPatch
dimalit Feb 9, 2024
babeb7a
SKALED-1583 Tests compile
dimalit Feb 14, 2024
40624e4
SKALED-1583 Adapting tests
dimalit Feb 16, 2024
b5df8f5
SKALED-1583 Do all transaction checks in SealEngine, not in Ethash
dimalit Feb 16, 2024
d1e2192
Merge branch 'develop' into enhancement/SKALED-1583-patch-architecture
dimalit Feb 20, 2024
60328c5
SKALED-1583 Fix library dependencies in testeth
dimalit Feb 21, 2024
52b0449
SKALED-1583 Fix SkaleHost tests
dimalit Feb 21, 2024
451fc2e
SKALED-1583 Fix tests
dimalit Feb 21, 2024
2166eff
SKALED-1583 Remove unneeded parameter
dimalit Feb 22, 2024
0f48b2b
SKALED-1583 Remove unused class member
dimalit Feb 22, 2024
ad8350b
SKALED-1583 Universal config of schain patches
dimalit Feb 24, 2024
ff0e82a
SKALED-1583 Fix build
dimalit Feb 26, 2024
413850c
SKALED-1583 Rename latestBlockTimestamp to committedBlockTimestamp
dimalit Feb 26, 2024
c0339d2
SKALED-1583 Use proper patch timestamp names
dimalit Feb 26, 2024
00a09f6
SKALED-1583 Convert some patches to new arch
dimalit Feb 28, 2024
c8e02cf
SKALED-1583 Remove frontier test
dimalit Feb 29, 2024
5361b9a
SKALED-1583 Add Push0 test
dimalit Feb 29, 2024
0c30eac
SKALED-1583 Test for StorageDestructionPatch and combine most patches…
dimalit Mar 1, 2024
e8f7cdd
SKALED-1583 Remove some patch files
dimalit Mar 4, 2024
26ba1d1
Merge branch 'v3.19.0' into enhancement/SKALED-1583-patch-architecture
dimalit Mar 4, 2024
668be42
SKALED-1583 One more patch
dimalit Mar 4, 2024
3260e70
SKALED-1583 Fix tests, but not all
dimalit Mar 4, 2024
82ccc7d
SKALED-1583 Add log and modularize code a little
dimalit Mar 5, 2024
5adcf01
SKALED-1583 Add back patches descriptions
dimalit Mar 5, 2024
5915655
SKALED-1583 Small beautifying and introduction of enum
dimalit Mar 7, 2024
c664283
SKALED-1583 Fix some tests
dimalit Mar 11, 2024
537141d
SKALED-1583 Some prettifying
dimalit Mar 11, 2024
9d92873
SKALED-1583 Remove endl in some palces
dimalit Mar 11, 2024
9bd2542
SKALED-1583 Make some parameters' names more clear
dimalit Mar 12, 2024
3936651
SKALED-1583 Fix buid
dimalit Mar 13, 2024
888c64d
SKALED-1583 Use correct block in eth_call() and eth_estimateGas(). Al…
dimalit Mar 18, 2024
b9d676c
SKALED-1853 Add test for historic and fix estimateGas
dimalit Mar 19, 2024
0a9837d
SKALED-1583 Fix test
dimalit Mar 19, 2024
45d8a50
SKALED-1583 Fix rand in tests
dimalit Mar 19, 2024
7410de4
SKALED-1583 Minor polishing
dimalit Mar 20, 2024
3d9968f
SKALED-1583 Minor changes
dimalit Mar 21, 2024
eb5030c
Merge branch 'v3.19.0' into enhancement/SKALED-1583-patch-architecture
dimalit Apr 3, 2024
08f66ef
IS-833 Add patch for maxStorageForSelfdestruct
dimalit Apr 4, 2024
74f58a4
1583 Fix solidity version in test
kladkogex Apr 4, 2024
a1daeb2
1583 Fix crash because of unknown name
kladkogex Apr 4, 2024
c148a94
1583 Fix crash because of unknown name
kladkogex Apr 4, 2024
051f188
1583 add test
kladkogex Apr 4, 2024
7626eb1
1583 add test
kladkogex Apr 4, 2024
7e36fca
SKALED-1583 Merge v3.17.2
dimalit Apr 5, 2024
5155bfc
Merge branch 'v3.17.2' into enhancement/SKALED-1583-patch-architectur…
dimalit Apr 8, 2024
9b5992b
SKALED-1583 Formatting
dimalit Apr 8, 2024
75dce1f
SKALED-1583 Format
dimalit Apr 8, 2024
583cc06
Merge branch 'develop' into enhancement/SKALED-1583-patch-architectur…
dimalit Apr 9, 2024
4bfa0e2
SKALED-1583 Enable full debug API by flag
dimalit Apr 9, 2024
eea7152
Merge branch 'develop' into enhancement/SKALED-1583-patch-architectur…
dimalit Apr 10, 2024
f813411
Merge remote-tracking branch 'origin/v3.19.0' into enhancement/SKALED…
dimalit Apr 10, 2024
4eb22fc
Rename patches in SchainPatch
DmytroNazarenko Apr 12, 2024
62b56b3
SKALED-1583 Some polishing
dimalit Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.19.0
3.19.0
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 );
}
39 changes: 28 additions & 11 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 @@ -173,16 +174,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 +207,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 +256,24 @@ struct ChainOperationParams {
u256 externalGasDifficulty = ~u256( 0 );
typedef std::vector< std::string > vecAdminOrigins_t;
vecAdminOrigins_t vecAdminOrigins; // wildcard based folters for IP addresses

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
62 changes: 1 addition & 61 deletions libethcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct EVMSchedule {
bool haveExtcodehash = false;
bool haveChainID = false;
bool haveSelfbalance = false;
bool havePush0 = false;
std::array< unsigned, 8 > tierStepGas;
unsigned expGas = 10;
unsigned expByteGas = 10;
Expand Down Expand Up @@ -93,7 +94,6 @@ struct EVMSchedule {
};

static const EVMSchedule DefaultSchedule = EVMSchedule();
static const EVMSchedule FrontierSchedule = EVMSchedule( false, false, 21000 );
static const EVMSchedule HomesteadSchedule = EVMSchedule( true, true, 53000 );

static const EVMSchedule EIP150Schedule = [] {
Expand Down Expand Up @@ -125,12 +125,6 @@ static const EVMSchedule ByzantiumSchedule = [] {
return schedule;
}();

static const EVMSchedule EWASMSchedule = [] {
EVMSchedule schedule = ByzantiumSchedule;
schedule.maxCodeSize = std::numeric_limits< unsigned >::max();
return schedule;
}();

static const EVMSchedule ConstantinopleSchedule = [] {
EVMSchedule schedule = ByzantiumSchedule;
schedule.haveCreate2 = true;
Expand Down Expand Up @@ -174,60 +168,6 @@ static const EVMSchedule ExperimentalSchedule = [] {
return schedule;
}();

static const EVMSchedule SkaleSchedule_base = [] {
EVMSchedule schedule = ConstantinopleSchedule;
return schedule;
}();

static const EVMSchedule SkaleSchedule_16k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 16;
return schedule;
}();

static const EVMSchedule SkaleSchedule_32k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 32;
return schedule;
}();

static const EVMSchedule SkaleSchedule_64k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 64;
return schedule;
}();

static const EVMSchedule SkaleSchedule_128k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 128;
return schedule;
}();

static const EVMSchedule SkaleSchedule_256k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 256;
return schedule;
}();

static const EVMSchedule SkaleSchedule_512k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 512;
return schedule;
}();

static const EVMSchedule SkaleSchedule_1024k = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = 1024 * 1024;
return schedule;
}();

static const EVMSchedule SkaleSchedule_Unlimited = [] {
EVMSchedule schedule = SkaleSchedule_base;
schedule.maxCodeSize = std::numeric_limits< unsigned >::max();
return schedule;
}();


inline EVMSchedule const& latestScheduleForAccountVersion( u256 const& _version ) {
if ( _version == 0 )
return IstanbulSchedule;
Expand Down
Loading
Loading