From cd4698945f8c0ee6d54b996b4d385cd1f6c03bac Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:56:42 +0100 Subject: [PATCH 01/11] new op codes --- libevm/Instruction.cpp | 4 + libevm/Instruction.h | 1 + libevm/LegacyVM.cpp | 12 +++ libevm/LegacyVMConfig.h | 2 +- .../historicstate/hardhat/contracts/Push0.sol | 15 ++++ .../hardhat/scripts/push0_test.ts | 84 +++++++++++++++++++ 6 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 test/historicstate/hardhat/contracts/Push0.sol create mode 100644 test/historicstate/hardhat/scripts/push0_test.ts diff --git a/libevm/Instruction.cpp b/libevm/Instruction.cpp index 78e8eec2d..bb4f25d20 100644 --- a/libevm/Instruction.cpp +++ b/libevm/Instruction.cpp @@ -86,6 +86,10 @@ static const std::map c_instructionInfo = { Instruction::MSIZE, { "MSIZE", 0, 1, Tier::Base } }, { Instruction::GAS, { "GAS", 0, 1, Tier::Base } }, { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, Tier::Special } }, + // As per EIP-3855 PUSH0 instruction tire is base (2 gas units) + // As all other PUSH instructions, it removes zero elements from stack and + // pushes 1 element to stack + { Instruction::PUSH0, { "PUSH0", 0, 1, Tier::Base } }, { Instruction::PUSH1, { "PUSH1", 0, 1, Tier::VeryLow } }, { Instruction::PUSH2, { "PUSH2", 0, 1, Tier::VeryLow } }, { Instruction::PUSH3, { "PUSH3", 0, 1, Tier::VeryLow } }, diff --git a/libevm/Instruction.h b/libevm/Instruction.h index 573b57107..44c35ad6b 100644 --- a/libevm/Instruction.h +++ b/libevm/Instruction.h @@ -94,6 +94,7 @@ enum class Instruction : uint8_t { GAS, ///< get the amount of available gas JUMPDEST, ///< set a potential jump destination + PUSH0 = 0x5f, // EIP-3855 PUSH1 = 0x60, ///< place 1 byte item on stack PUSH2, ///< place 2 byte item on stack PUSH3, ///< place 3 byte item on stack diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 8a0775112..5f2f0f772 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -1355,6 +1355,18 @@ void LegacyVM::interpretCases() { } CONTINUE + // EIP-3855. Code PUSH0 is similar to PUSH1 but pushes 0 + CASE( PUSH0 ) { + //throwBadInstruction(); + ON_OP(); + updateIOGas(); + ++m_PC; + m_SPP[0] = 0; + ++m_PC; + } + CONTINUE + + CASE( PUSH1 ) { ON_OP(); updateIOGas(); diff --git a/libevm/LegacyVMConfig.h b/libevm/LegacyVMConfig.h index 4b8bde611..9908d712c 100644 --- a/libevm/LegacyVMConfig.h +++ b/libevm/LegacyVMConfig.h @@ -254,7 +254,7 @@ namespace eth { &&BEGINDATA, \ &&BEGINSUB, \ &&INVALID, \ - &&INVALID, \ + &&PUSH0, /* EIP-3855 */ \ &&PUSH1, /* 60, */ \ &&PUSH2, \ &&PUSH3, \ diff --git a/test/historicstate/hardhat/contracts/Push0.sol b/test/historicstate/hardhat/contracts/Push0.sol new file mode 100644 index 000000000..a2ffc4522 --- /dev/null +++ b/test/historicstate/hardhat/contracts/Push0.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.9; + +contract Push0 { + + //uint256 public constant ZERO = 0; + + function getZero() public { + // this trigger compiler using push0 to stack since operations use lots of zeros + // uint256 one = 0; + //one = one + 1 + ZERO; + //uint256 two = one * 0; + //uint256 three = one * ZERO; + } +} \ No newline at end of file diff --git a/test/historicstate/hardhat/scripts/push0_test.ts b/test/historicstate/hardhat/scripts/push0_test.ts new file mode 100644 index 000000000..20c9f700a --- /dev/null +++ b/test/historicstate/hardhat/scripts/push0_test.ts @@ -0,0 +1,84 @@ +const OWNER_ADDRESS: string = "0x907cd0881E50d359bb9Fd120B1A5A143b1C97De6"; +const ZERO_ADDRESS: string = "0xO000000000000000000000000000000000000000"; +const INITIAL_MINT: bigint = 10000000000000000000000000000000000000000n; + +import {ethers} from "hardhat"; + +async function waitUntilNextBlock() { + + const current = await hre.ethers.provider.getBlockNumber(); + let newBlock = current; + console.log(`BLOCK_NUMBER ${current}`); + + while (newBlock == current) { + newBlock = await hre.ethers.provider.getBlockNumber(); + } + + console.log(`BLOCK_NUMBER ${newBlock}`); + + return current; + +} + +function CHECK(result: any): void { + if (!result) { + const message: string = `Check failed ${result}` + console.log(message); + throw message; + } +} + +async function getAndPrintTrace(hash: string): Promise { +// const trace = await ethers.provider.send('debug_traceTransaction', [hash, {"tracer":"prestateTracer", +// "tracerConfig": {"diffMode":true}}]); + +// const trace = await ethers.provider.send('debug_traceTransaction', [hash, {"tracer": "callTracer", +// "tracerConfig": {"withLog":true}}]); + + const trace = await ethers.provider.send('debug_traceTransaction', [hash, {}]); + + + + console.log(JSON.stringify(trace, null, 4)); + return trace; +} + +async function deployWriteAndDestroy(): Promise { + + console.log(`Deploying ...`); + + const Push0Test = await ethers.getContractFactory("Push0"); + const test = await Push0Test.deploy(); + const testContract = await test.deployed(); + + + const deployBn = await ethers.provider.getBlockNumber(); + + const hash = testContract.deployTransaction.hash; + console.log(`Gas limit ${testContract.deployTransaction.gasLimit}`); + console.log(`Contract deployed to ${testContract.address} at block ${deployBn} tx hash ${hash}`); + + + // await waitUntilNextBlock() + + await getAndPrintTrace(hash) + + + console.log(`Now testing`); + + const transferReceipt = await testContract.getZero() + console.log(`Gas limit ${transferReceipt.gasLimit}`); + + +} + +async function main(): Promise { + await deployWriteAndDestroy(); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main().catch((error: any) => { + console.error(error); + process.exitCode = 1; +}); \ No newline at end of file From 83379f9309aa55ce9e7c354e41027096d3bb43fe Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:44:02 +0100 Subject: [PATCH 02/11] 1700 push zero --- libethcore/ChainOperationParams.h | 2 ++ libethereum/ChainParams.cpp | 7 +++++ libethereum/Client.cpp | 3 +++ libethereum/ValidationSchemes.cpp | 2 ++ libevm/LegacyVM.cpp | 10 ++++--- libskale/CMakeLists.txt | 1 + libskale/PushZeroPatch.cpp | 11 ++++++++ libskale/PushZeroPatch.h | 27 +++++++++++++++++++ test/historicstate/configs/basic_config.json | 3 ++- .../historicstate/hardhat/contracts/Push0.sol | 14 +++++----- test/historicstate/hardhat/hardhat.config.js | 2 +- .../hardhat/scripts/push0_test.ts | 2 +- 12 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 libskale/PushZeroPatch.cpp create mode 100644 libskale/PushZeroPatch.h diff --git a/libethcore/ChainOperationParams.h b/libethcore/ChainOperationParams.h index ddab8e679..3fba5e1a7 100644 --- a/libethcore/ChainOperationParams.h +++ b/libethcore/ChainOperationParams.h @@ -175,6 +175,8 @@ struct SChain { time_t verifyDaSigsPatchTimestamp = 0; time_t storageDestructionPatchTimestamp = 0; time_t powCheckPatchTimestamp = 0; + time_t pushZeroPatchTimestamp = 0; + SChain() { name = "TestChain"; diff --git a/libethereum/ChainParams.cpp b/libethereum/ChainParams.cpp index 6b4693a9e..d4d9c6913 100644 --- a/libethereum/ChainParams.cpp +++ b/libethereum/ChainParams.cpp @@ -266,6 +266,13 @@ ChainParams ChainParams::loadConfig( sChainObj.at( "powCheckPatchTimestamp" ).get_int64() : 0; + s.pushZeroPatchTimestamp = + sChainObj.count( "pushZeroPatchTimestamp" ) ? + sChainObj.at( "pushZeroPatchTimestamp" ).get_int64() : + 0; + + + if ( sChainObj.count( "nodeGroups" ) ) { std::vector< NodeGroup > nodeGroups; for ( const auto& nodeGroupConf : sChainObj["nodeGroups"].get_obj() ) { diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 36e651e0c..e00139f2e 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -162,6 +163,7 @@ Client::Client( ChainParams const& _params, int _networkID, RevertableFSPatch::setTimestamp( chainParams().sChain.revertableFSPatchTimestamp ); StorageDestructionPatch::setTimestamp( chainParams().sChain.storageDestructionPatchTimestamp ); POWCheckPatch::setTimestamp( chainParams().sChain.powCheckPatchTimestamp ); + PushZeroPatch::setTimestamp( chainParams().sChain.pushZeroPatchTimestamp ); } @@ -654,6 +656,7 @@ size_t Client::syncTransactions( RevertableFSPatch::lastBlockTimestamp = blockChain().info().timestamp(); StorageDestructionPatch::lastBlockTimestamp = blockChain().info().timestamp(); POWCheckPatch::lastBlockTimestamp = blockChain().info().timestamp(); + PushZeroPatch::lastBlockTimestamp = blockChain().info().timestamp(); DEV_WRITE_GUARDED( x_working ) { diff --git a/libethereum/ValidationSchemes.cpp b/libethereum/ValidationSchemes.cpp index cebb16c8e..ae4fc2068 100644 --- a/libethereum/ValidationSchemes.cpp +++ b/libethereum/ValidationSchemes.cpp @@ -268,6 +268,8 @@ void validateConfigJson( js::mObject const& _obj ) { { "storageDestructionPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, { "powCheckPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, + { "pushZeroPatchTimestamp", + { { js::int_type }, JsonFieldPresence::Optional } }, { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } } } ); js::mArray const& nodes = sChain.at( "nodes" ).get_array(); diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 5f2f0f772..757a02823 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -15,6 +15,7 @@ along with cpp-ethereum. If not, see . */ +#include "libskale/PushZeroPatch.h" #include "LegacyVM.h" using namespace std; @@ -1356,14 +1357,17 @@ void LegacyVM::interpretCases() { CONTINUE // EIP-3855. Code PUSH0 is similar to PUSH1 but pushes 0 + // we need to increment program counter only by one since + // the value is not read from program code as in PUSH1 CASE( PUSH0 ) { - //throwBadInstruction(); + if (!PushZeroPatch::isEnabled()) { + throwBadInstruction(); + } ON_OP(); updateIOGas(); - ++m_PC; m_SPP[0] = 0; ++m_PC; - } + }; CONTINUE diff --git a/libskale/CMakeLists.txt b/libskale/CMakeLists.txt index cad33c885..d83455e63 100644 --- a/libskale/CMakeLists.txt +++ b/libskale/CMakeLists.txt @@ -20,6 +20,7 @@ set(sources OverlayFS.cpp StorageDestructionPatch.cpp POWCheckPatch.cpp + PushZeroPatch.cpp ) set(headers diff --git a/libskale/PushZeroPatch.cpp b/libskale/PushZeroPatch.cpp new file mode 100644 index 000000000..e7ef4f6c1 --- /dev/null +++ b/libskale/PushZeroPatch.cpp @@ -0,0 +1,11 @@ +#include "PushZeroPatch.h" + +time_t PushZeroPatch::pushZeroPatchTimestamp; +time_t PushZeroPatch::lastBlockTimestamp; + +bool PushZeroPatch::isEnabled() { + if ( pushZeroPatchTimestamp == 0 ) { + return false; + } + return pushZeroPatchTimestamp <= lastBlockTimestamp; +} diff --git a/libskale/PushZeroPatch.h b/libskale/PushZeroPatch.h new file mode 100644 index 000000000..6ebab4e9f --- /dev/null +++ b/libskale/PushZeroPatch.h @@ -0,0 +1,27 @@ +#include +#include + +namespace dev { +namespace eth { +class Client; +} +} // namespace dev + +/* + * Context: enable effective storage destruction + */ +class PushZeroPatch : public SchainPatch { +public: + static bool isEnabled(); + + static void setTimestamp( time_t _timeStamp ) { + printInfo( __FILE__, _timeStamp ); + pushZeroPatchTimestamp = _timeStamp; + } + + +private: + friend class dev::eth::Client; + static time_t pushZeroPatchTimestamp; + static time_t lastBlockTimestamp; +}; \ No newline at end of file diff --git a/test/historicstate/configs/basic_config.json b/test/historicstate/configs/basic_config.json index aa5915277..ea3bbf1d6 100644 --- a/test/historicstate/configs/basic_config.json +++ b/test/historicstate/configs/basic_config.json @@ -322,10 +322,11 @@ "sChain": { "schainName": "TestChain", - "schainID": 1, + "schainID": 5, "schainOwner": "0x907cd0881E50d359bb9Fd120B1A5A143b1C97De6", "contractStorageLimit": 10000000000, "emptyBlockIntervalMs": 10000, + "pushZeroPatchTimestamp": 1, "nodes": [ { "nodeID": 1112, "ip": "127.0.0.1", "basePort": 1231, "schainIndex" : 1, "publicKey":""} ] diff --git a/test/historicstate/hardhat/contracts/Push0.sol b/test/historicstate/hardhat/contracts/Push0.sol index a2ffc4522..e09e457b6 100644 --- a/test/historicstate/hardhat/contracts/Push0.sol +++ b/test/historicstate/hardhat/contracts/Push0.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.9; +pragma solidity ^0.8.20; contract Push0 { - //uint256 public constant ZERO = 0; + uint256 public constant ZERO = 0; function getZero() public { - // this trigger compiler using push0 to stack since operations use lots of zeros - // uint256 one = 0; - //one = one + 1 + ZERO; - //uint256 two = one * 0; - //uint256 three = one * ZERO; + // this triggers compiler using push0 to stack since operations use lots of zeros + uint256 one = 0; + one = one + 1 + ZERO; + uint256 two = one * 0; + uint256 three = one * ZERO; } } \ No newline at end of file diff --git a/test/historicstate/hardhat/hardhat.config.js b/test/historicstate/hardhat/hardhat.config.js index d369e02ba..3ff48bfba 100644 --- a/test/historicstate/hardhat/hardhat.config.js +++ b/test/historicstate/hardhat/hardhat.config.js @@ -10,7 +10,7 @@ module.exports = { const INSECURE_PRIVATE_KEY = "bd200f4e7f597f3c2c77fb405ee7fabeb249f63f03f43d5927b4fa0c43cfe85e"; module.exports = { - solidity: "0.8.9", + solidity: "0.8.20", networks: { skaled: { url: `http://localhost:1234`, diff --git a/test/historicstate/hardhat/scripts/push0_test.ts b/test/historicstate/hardhat/scripts/push0_test.ts index 20c9f700a..18446a589 100644 --- a/test/historicstate/hardhat/scripts/push0_test.ts +++ b/test/historicstate/hardhat/scripts/push0_test.ts @@ -61,7 +61,7 @@ async function deployWriteAndDestroy(): Promise { // await waitUntilNextBlock() - await getAndPrintTrace(hash) + //await getAndPrintTrace(hash) console.log(`Now testing`); From bbd707dd80e776e9afd488e64a88ce0e65ed08a2 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:55:46 +0100 Subject: [PATCH 03/11] 1700 PUSHD --- libethereum/ChainParams.cpp | 8 +++----- libethereum/ValidationSchemes.cpp | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libethereum/ChainParams.cpp b/libethereum/ChainParams.cpp index d4d9c6913..a1706b858 100644 --- a/libethereum/ChainParams.cpp +++ b/libethereum/ChainParams.cpp @@ -266,11 +266,9 @@ ChainParams ChainParams::loadConfig( sChainObj.at( "powCheckPatchTimestamp" ).get_int64() : 0; - s.pushZeroPatchTimestamp = - sChainObj.count( "pushZeroPatchTimestamp" ) ? - sChainObj.at( "pushZeroPatchTimestamp" ).get_int64() : - 0; - + s.pushZeroPatchTimestamp = sChainObj.count( "pushZeroPatchTimestamp" ) ? + sChainObj.at( "pushZeroPatchTimestamp" ).get_int64() : + 0; if ( sChainObj.count( "nodeGroups" ) ) { diff --git a/libethereum/ValidationSchemes.cpp b/libethereum/ValidationSchemes.cpp index ae4fc2068..2765ebb59 100644 --- a/libethereum/ValidationSchemes.cpp +++ b/libethereum/ValidationSchemes.cpp @@ -268,8 +268,7 @@ void validateConfigJson( js::mObject const& _obj ) { { "storageDestructionPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, { "powCheckPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, - { "pushZeroPatchTimestamp", - { { js::int_type }, JsonFieldPresence::Optional } }, + { "pushZeroPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } } } ); js::mArray const& nodes = sChain.at( "nodes" ).get_array(); From 33502b101d746c5cfcebd036a9b35f2360c1a657 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:01:26 +0100 Subject: [PATCH 04/11] 1700 add pushd --- libevm/Instruction.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevm/Instruction.h b/libevm/Instruction.h index 44c35ad6b..0dc52bdad 100644 --- a/libevm/Instruction.h +++ b/libevm/Instruction.h @@ -94,7 +94,7 @@ enum class Instruction : uint8_t { GAS, ///< get the amount of available gas JUMPDEST, ///< set a potential jump destination - PUSH0 = 0x5f, // EIP-3855 + PUSH0 = 0x5f, // EIP-3855 PUSH1 = 0x60, ///< place 1 byte item on stack PUSH2, ///< place 2 byte item on stack PUSH3, ///< place 3 byte item on stack From aad381b41f8b4299234e9187cc4f987beff068bc Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:03:30 +0100 Subject: [PATCH 05/11] 1700 clang format --- libevm/LegacyVM.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 757a02823..098e6624f 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -15,8 +15,8 @@ along with cpp-ethereum. If not, see . */ -#include "libskale/PushZeroPatch.h" #include "LegacyVM.h" +#include "libskale/PushZeroPatch.h" using namespace std; using namespace dev; @@ -28,12 +28,12 @@ uint64_t LegacyVM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) / s512( _b ) ); + return ( S ) ( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S )( s512( _a ) % s512( _b ) ); + return ( S ) ( s512( _a ) % s512( _b ) ); } @@ -354,7 +354,7 @@ void LegacyVM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); } NEXT @@ -1083,7 +1083,9 @@ void LegacyVM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { throwBadInstruction(); } + CASE( XSHUFFLE ) { + throwBadInstruction(); + } CONTINUE #endif @@ -1360,7 +1362,7 @@ void LegacyVM::interpretCases() { // we need to increment program counter only by one since // the value is not read from program code as in PUSH1 CASE( PUSH0 ) { - if (!PushZeroPatch::isEnabled()) { + if ( !PushZeroPatch::isEnabled() ) { throwBadInstruction(); } ON_OP(); From 53f4ecf37505f33c42edc941028147526fbb928a Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:06:42 +0100 Subject: [PATCH 06/11] 1700 clang format --- libevm/LegacyVM.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libevm/LegacyVM.cpp b/libevm/LegacyVM.cpp index 098e6624f..a987a3b0c 100644 --- a/libevm/LegacyVM.cpp +++ b/libevm/LegacyVM.cpp @@ -28,12 +28,12 @@ uint64_t LegacyVM::memNeed( u256 const& _offset, u256 const& _size ) { template < class S > S divWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) / s512( _b ) ); + return ( S )( s512( _a ) / s512( _b ) ); } template < class S > S modWorkaround( S const& _a, S const& _b ) { - return ( S ) ( s512( _a ) % s512( _b ) ); + return ( S )( s512( _a ) % s512( _b ) ); } @@ -354,7 +354,7 @@ void LegacyVM::interpretCases() { updateMem( toInt63( m_SP[0] ) + 1 ); updateIOGas(); - m_mem[( unsigned ) m_SP[0]] = ( _byte_ ) ( m_SP[1] & 0xff ); + m_mem[( unsigned ) m_SP[0]] = ( _byte_ )( m_SP[1] & 0xff ); } NEXT @@ -1083,9 +1083,7 @@ void LegacyVM::interpretCases() { CASE( XPUT ) CASE( XGET ) CASE( XSWIZZLE ) - CASE( XSHUFFLE ) { - throwBadInstruction(); - } + CASE( XSHUFFLE ) { throwBadInstruction(); } CONTINUE #endif From 71f75faa2dca55440b1b3d30225a2d548ea1b166 Mon Sep 17 00:00:00 2001 From: kladkogex <13399135+kladkogex@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:09:31 +0100 Subject: [PATCH 07/11] 1700 clang format --- libethereum/Client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index e00139f2e..0cc6b9ca8 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -54,11 +54,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include From 68978ab6cc0e5525ac85a05f6e95280b9e40c6bb Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:43:41 +0100 Subject: [PATCH 08/11] 1700 clang format --- libconsensus | 2 +- libethereum/ValidationSchemes.cpp | 85 ++++++++++++++++--------------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/libconsensus b/libconsensus index ef26c4a02..5a9b85d8f 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit ef26c4a020884f280addd9b54037ee77fe396ecf +Subproject commit 5a9b85d8f171e1ba5f7dfe244cff70e0e39aa5f4 diff --git a/libethereum/ValidationSchemes.cpp b/libethereum/ValidationSchemes.cpp index ff6dca9c3..3a23277f4 100644 --- a/libethereum/ValidationSchemes.cpp +++ b/libethereum/ValidationSchemes.cpp @@ -269,50 +269,53 @@ void validateConfigJson( js::mObject const& _obj ) { { { js::int_type }, JsonFieldPresence::Optional } }, { "powCheckPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, { "pushZeroPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, - { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } } } ); { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } }, - { "skipInvalidTransactionsPatchTimestamp", - { { js::int_type }, JsonFieldPresence::Optional } } } ); + { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } }, + { + "skipInvalidTransactionsPatchTimestamp", { + { js::int_type }, JsonFieldPresence::Optional + } } +} ); - js::mArray const& nodes = sChain.at( "nodes" ).get_array(); - for ( auto const& obj : nodes ) { - const js::mObject node = obj.get_obj(); +js::mArray const& nodes = sChain.at( "nodes" ).get_array(); +for ( auto const& obj : nodes ) { + const js::mObject node = obj.get_obj(); - requireJsonFields( node, "ChainParams::loadConfig::skaleConfig::sChain::nodes", - { { "nodeName", { { js::str_type }, JsonFieldPresence::Optional } }, - { "nodeID", { { js::int_type }, JsonFieldPresence::Required } }, - { "ip", { { js::str_type }, JsonFieldPresence::Required } }, - { "publicIP", { { js::str_type }, JsonFieldPresence::Optional } }, // TODO not used - { "basePort", { { js::int_type }, JsonFieldPresence::Required } }, - { "ip6", { { js::str_type }, JsonFieldPresence::Optional } }, - { "basePort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "info-acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, - { "schainIndex", { { js::int_type }, JsonFieldPresence::Required } }, - { "publicKey", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey0", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey1", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey2", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey3", { { js::str_type }, JsonFieldPresence::Optional } }, - { "owner", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blockAuthor", { { js::str_type }, JsonFieldPresence::Optional } } } ); - } + requireJsonFields( node, "ChainParams::loadConfig::skaleConfig::sChain::nodes", + { { "nodeName", { { js::str_type }, JsonFieldPresence::Optional } }, + { "nodeID", { { js::int_type }, JsonFieldPresence::Required } }, + { "ip", { { js::str_type }, JsonFieldPresence::Required } }, + { "publicIP", { { js::str_type }, JsonFieldPresence::Optional } }, // TODO not used + { "basePort", { { js::int_type }, JsonFieldPresence::Required } }, + { "ip6", { { js::str_type }, JsonFieldPresence::Optional } }, + { "basePort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "info-acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, + { "schainIndex", { { js::int_type }, JsonFieldPresence::Required } }, + { "publicKey", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey0", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey1", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey2", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey3", { { js::str_type }, JsonFieldPresence::Optional } }, + { "owner", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blockAuthor", { { js::str_type }, JsonFieldPresence::Optional } } } ); +} } void validateAccountMaskObj( js::mObject const& _obj ) { From 1a4c7a91215ac77ee4ccd5ab4a956584f2f0d519 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:54:59 +0100 Subject: [PATCH 09/11] 1700 clang format --- libethereum/ValidationSchemes.cpp | 83 +++++++++++++++---------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/libethereum/ValidationSchemes.cpp b/libethereum/ValidationSchemes.cpp index 3a23277f4..fdf83fdeb 100644 --- a/libethereum/ValidationSchemes.cpp +++ b/libethereum/ValidationSchemes.cpp @@ -271,51 +271,48 @@ void validateConfigJson( js::mObject const& _obj ) { { "pushZeroPatchTimestamp", { { js::int_type }, JsonFieldPresence::Optional } }, { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } }, { "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } }, - { - "skipInvalidTransactionsPatchTimestamp", { - { js::int_type }, JsonFieldPresence::Optional - } } -} ); + { "skipInvalidTransactionsPatchTimestamp", + { { js::int_type }, JsonFieldPresence::Optional } } } ); -js::mArray const& nodes = sChain.at( "nodes" ).get_array(); -for ( auto const& obj : nodes ) { - const js::mObject node = obj.get_obj(); + js::mArray const& nodes = sChain.at( "nodes" ).get_array(); + for ( auto const& obj : nodes ) { + const js::mObject node = obj.get_obj(); - requireJsonFields( node, "ChainParams::loadConfig::skaleConfig::sChain::nodes", - { { "nodeName", { { js::str_type }, JsonFieldPresence::Optional } }, - { "nodeID", { { js::int_type }, JsonFieldPresence::Required } }, - { "ip", { { js::str_type }, JsonFieldPresence::Required } }, - { "publicIP", { { js::str_type }, JsonFieldPresence::Optional } }, // TODO not used - { "basePort", { { js::int_type }, JsonFieldPresence::Required } }, - { "ip6", { { js::str_type }, JsonFieldPresence::Optional } }, - { "basePort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "httpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "wssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoHttpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, - { "infoWssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, - { "info-acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, - { "schainIndex", { { js::int_type }, JsonFieldPresence::Required } }, - { "publicKey", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey0", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey1", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey2", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blsPublicKey3", { { js::str_type }, JsonFieldPresence::Optional } }, - { "owner", { { js::str_type }, JsonFieldPresence::Optional } }, - { "blockAuthor", { { js::str_type }, JsonFieldPresence::Optional } } } ); -} + requireJsonFields( node, "ChainParams::loadConfig::skaleConfig::sChain::nodes", + { { "nodeName", { { js::str_type }, JsonFieldPresence::Optional } }, + { "nodeID", { { js::int_type }, JsonFieldPresence::Required } }, + { "ip", { { js::str_type }, JsonFieldPresence::Required } }, + { "publicIP", { { js::str_type }, JsonFieldPresence::Optional } }, // TODO not used + { "basePort", { { js::int_type }, JsonFieldPresence::Required } }, + { "ip6", { { js::str_type }, JsonFieldPresence::Optional } }, + { "basePort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "httpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "wssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoHttpsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWsRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWsRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWssRpcPort", { { js::int_type }, JsonFieldPresence::Optional } }, + { "infoWssRpcPort6", { { js::int_type }, JsonFieldPresence::Optional } }, + { "info-acceptors", { { js::int_type }, JsonFieldPresence::Optional } }, + { "schainIndex", { { js::int_type }, JsonFieldPresence::Required } }, + { "publicKey", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey0", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey1", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey2", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blsPublicKey3", { { js::str_type }, JsonFieldPresence::Optional } }, + { "owner", { { js::str_type }, JsonFieldPresence::Optional } }, + { "blockAuthor", { { js::str_type }, JsonFieldPresence::Optional } } } ); + } } void validateAccountMaskObj( js::mObject const& _obj ) { From 80c2e4439a99cec6c67f50aaefde950591028669 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:58:00 +0100 Subject: [PATCH 10/11] 1700 fix test --- test/historicstate/hardhat/scripts/push0_test.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/test/historicstate/hardhat/scripts/push0_test.ts b/test/historicstate/hardhat/scripts/push0_test.ts index 18446a589..d76a0a934 100644 --- a/test/historicstate/hardhat/scripts/push0_test.ts +++ b/test/historicstate/hardhat/scripts/push0_test.ts @@ -1,6 +1,6 @@ const OWNER_ADDRESS: string = "0x907cd0881E50d359bb9Fd120B1A5A143b1C97De6"; const ZERO_ADDRESS: string = "0xO000000000000000000000000000000000000000"; -const INITIAL_MINT: bigint = 10000000000000000000000000000000000000000n; +const INITIAL_MINT: bigint = 10000000000000000000000000000000000000000; import {ethers} from "hardhat"; @@ -29,16 +29,9 @@ function CHECK(result: any): void { } async function getAndPrintTrace(hash: string): Promise { -// const trace = await ethers.provider.send('debug_traceTransaction', [hash, {"tracer":"prestateTracer", -// "tracerConfig": {"diffMode":true}}]); - -// const trace = await ethers.provider.send('debug_traceTransaction', [hash, {"tracer": "callTracer", -// "tracerConfig": {"withLog":true}}]); const trace = await ethers.provider.send('debug_traceTransaction', [hash, {}]); - - console.log(JSON.stringify(trace, null, 4)); return trace; } @@ -58,12 +51,6 @@ async function deployWriteAndDestroy(): Promise { console.log(`Gas limit ${testContract.deployTransaction.gasLimit}`); console.log(`Contract deployed to ${testContract.address} at block ${deployBn} tx hash ${hash}`); - - // await waitUntilNextBlock() - - //await getAndPrintTrace(hash) - - console.log(`Now testing`); const transferReceipt = await testContract.getZero() From 4d59da961ba27d52be7e11ed11e025ca5a2c60c6 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:09:06 +0100 Subject: [PATCH 11/11] #1700 Fast forward consensus --- libconsensus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libconsensus b/libconsensus index 5a9b85d8f..79d6b7fd6 160000 --- a/libconsensus +++ b/libconsensus @@ -1 +1 @@ -Subproject commit 5a9b85d8f171e1ba5f7dfe244cff70e0e39aa5f4 +Subproject commit 79d6b7fd676e5f52aed5ff626066e810d5219f13