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

1700 push zero #1701

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f4ebfc7
Update VERSION
DmytroNazarenko Jul 4, 2023
7154f85
Merge pull request #1576 from skalenetwork/enhancement/new-version
DmytroNazarenko Jul 4, 2023
9777e76
SKALED-1575 Create docker tag N.M.K-latest
dimalit Jul 4, 2023
2a14037
Use versions without "v"-
dimalit Jul 4, 2023
7fbda2b
Special case for stable branch
dimalit Jul 4, 2023
b07f531
docker tag for stability tests
dimalit Jul 5, 2023
7bc3f3d
SKALED-1575 Push latest image
dimalit Jul 5, 2023
8e5b40b
Merge branch 'v3.18.0' into enhancement/SKALED-1575-docker-tag-for-st…
DmytroNazarenko Jul 5, 2023
5b2fa76
SKALED-1575 Push latest image
dimalit Jul 5, 2023
b04a624
Merge branch 'v3.18.0' into develop-to-3.18
olehnikolaiev Sep 12, 2023
5c10eb6
Merge pull request #1646 from skalenetwork/develop-to-3.18
olehnikolaiev Sep 13, 2023
195974f
1619 add content-type to header
olehnikolaiev Sep 13, 2023
b5009cb
Merge pull request #1647 from skalenetwork/bug/1619-content-type-header
olehnikolaiev Sep 14, 2023
a3a46de
1550 reenable cat cycle test
olehnikolaiev Sep 26, 2023
26b8c02
Merge pull request #1671 from skalenetwork/bug/1550-reenable-cat-cycl…
olehnikolaiev Sep 26, 2023
8feadd2
1198 handle params in blockNumber
olehnikolaiev Sep 28, 2023
f10195c
Merge pull request #1677 from skalenetwork/bug/bug-1198-dont-ignore-p…
olehnikolaiev Sep 29, 2023
334e064
1482 update consensus for db usage call fix
olehnikolaiev Oct 3, 2023
4434e51
1482 update consensus
olehnikolaiev Oct 9, 2023
45a4e56
Merge pull request #1685 from skalenetwork/bug/1482-skale-db-usage-call
olehnikolaiev Oct 9, 2023
fed1457
1689 fix microprofile option
olehnikolaiev Oct 10, 2023
c420ff1
Merge branch 'v3.18.0' into bug/1689-microprofile-build
olehnikolaiev Oct 10, 2023
cff2955
Merge pull request #1690 from skalenetwork/bug/1689-microprofile-build
olehnikolaiev Oct 10, 2023
531ffac
Merge branch 'develop' into merge-develop-to-3.18
olehnikolaiev Oct 18, 2023
997aeaa
Merge pull request #1699 from skalenetwork/merge-develop-to-3.18
DmytroNazarenko Oct 18, 2023
cd46989
new op codes
kladkogex Oct 19, 2023
83379f9
1700 push zero
kladkogex Oct 19, 2023
bbd707d
1700 PUSHD
kladkogex Oct 19, 2023
33502b1
1700 add pushd
kladkogex Oct 19, 2023
aad381b
1700 clang format
kladkogex Oct 19, 2023
53f4ecf
1700 clang format
kladkogex Oct 19, 2023
71f75fa
1700 clang format
kladkogex Oct 19, 2023
8f52a83
Merge branch 'v3.18.0' into 1700_push_zero
kladkogex Oct 24, 2023
68978ab
1700 clang format
kladkogex Oct 24, 2023
1a4c7a9
1700 clang format
kladkogex Oct 24, 2023
80c2e44
1700 fix test
kladkogex Oct 24, 2023
4d59da9
#1700 Fast forward consensus
kladkogex Oct 24, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
- name: skaled+load_python+all
run: SKALED_PROVIDER=skaled_providers/binary_from_container ./run_tests.sh skaled+load_python+all

# - name: skaled+load_js+run_angry_cats
# run: SKALED_PROVIDER=skaled_providers/endpoint_by_container ./run_tests.sh skaled+load_js+run_angry_cats
- name: skaled+load_js+run_angry_cats
run: SKALED_PROVIDER=skaled_providers/endpoint_by_container ./run_tests.sh skaled+load_js+run_angry_cats

- name: skaled+internals+test_snapshot_api
run: SKALED_PROVIDER=skaled_providers/binary_from_container ./run_tests.sh skaled+internals+test_snapshot_api
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.17.0
3.18.0
2 changes: 1 addition & 1 deletion libconsensus
5 changes: 3 additions & 2 deletions libdevcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ add_library(devcore ${sources} ${headers})
add_dependencies(devcore secp256k1)

target_compile_options( devcore PRIVATE
-Wno-error=deprecated-copy -Wno-error=unused-result -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=maybe-uninitialized
)
-Wno-error=deprecated-copy -Wno-error=unused-result -Wno-error=unused-parameter
-Wno-error=unused-variable -Wno-error=maybe-uninitialized -Wno-error=class-memaccess
)

# Needed to prevent including system-level boost headers:
target_include_directories(devcore SYSTEM PUBLIC ${Boost_INCLUDE_DIR} PRIVATE ../utils)
Expand Down
1 change: 1 addition & 0 deletions libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ struct SChain {
time_t verifyDaSigsPatchTimestamp = 0;
time_t storageDestructionPatchTimestamp = 0;
time_t powCheckPatchTimestamp = 0;
time_t pushZeroPatchTimestamp = 0;
time_t skipInvalidTransactionsPatchTimestamp = 0;

SChain() {
Expand Down
4 changes: 4 additions & 0 deletions libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ ChainParams ChainParams::loadConfig(
sChainObj.at( "powCheckPatchTimestamp" ).get_int64() :
0;

s.pushZeroPatchTimestamp = sChainObj.count( "pushZeroPatchTimestamp" ) ?
sChainObj.at( "pushZeroPatchTimestamp" ).get_int64() :
0;

s.skipInvalidTransactionsPatchTimestamp =
sChainObj.count( "skipInvalidTransactionsPatchTimestamp" ) ?
sChainObj.at( "skipInvalidTransactionsPatchTimestamp" ).get_int64() :
Expand Down
3 changes: 3 additions & 0 deletions libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <libskale/ContractStorageLimitPatch.h>
#include <libskale/ContractStorageZeroValuePatch.h>
#include <libskale/POWCheckPatch.h>
#include <libskale/PushZeroPatch.h>
#include <libskale/RevertableFSPatch.h>
#include <libskale/SkipInvalidTransactionsPatch.h>
#include <libskale/State.h>
Expand Down Expand Up @@ -163,6 +164,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 );
SkipInvalidTransactionsPatch::setTimestamp(
this->chainParams().sChain.skipInvalidTransactionsPatchTimestamp );
}
Expand Down Expand Up @@ -657,6 +659,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();
SkipInvalidTransactionsPatch::lastBlockTimestamp = blockChain().info().timestamp();

DEV_WRITE_GUARDED( x_working ) {
Expand Down
2 changes: 2 additions & 0 deletions libethereum/ValidationSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
{ "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } },
{ "skipInvalidTransactionsPatchTimestamp",
{ { js::int_type }, JsonFieldPresence::Optional } } } );
Expand Down
4 changes: 4 additions & 0 deletions libevm/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ static const std::map<Instruction, InstructionInfo> 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 } },
Expand Down
1 change: 1 addition & 0 deletions libevm/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions libevm/LegacyVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "LegacyVM.h"
#include "libskale/PushZeroPatch.h"

using namespace std;
using namespace dev;
Expand Down Expand Up @@ -1355,6 +1356,21 @@ 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 ) {
if ( !PushZeroPatch::isEnabled() ) {
throwBadInstruction();
}
ON_OP();
updateIOGas();
m_SPP[0] = 0;
++m_PC;
};
CONTINUE


CASE( PUSH1 ) {
ON_OP();
updateIOGas();
Expand Down
2 changes: 1 addition & 1 deletion libevm/LegacyVMConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ namespace eth {
&&BEGINDATA, \
&&BEGINSUB, \
&&INVALID, \
&&INVALID, \
&&PUSH0, /* EIP-3855 */ \
&&PUSH1, /* 60, */ \
&&PUSH2, \
&&PUSH3, \
Expand Down
1 change: 1 addition & 0 deletions libskale/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(sources
OverlayFS.cpp
StorageDestructionPatch.cpp
POWCheckPatch.cpp
PushZeroPatch.cpp
SkipInvalidTransactionsPatch.cpp
)

Expand Down
11 changes: 11 additions & 0 deletions libskale/PushZeroPatch.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
27 changes: 27 additions & 0 deletions libskale/PushZeroPatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <libethereum/SchainPatch.h>
#include <time.h>

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;
};
1 change: 1 addition & 0 deletions libskutils/src/http_pg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void request_site::onEOM() noexcept {
} else {
std::string strOut = rslt.joOut_.dump();
bldr.header( "content-length", skutils::tools::format( "%zu", strOut.size() ) );
bldr.header( "Content-Type", "application/json" );
bldr.body( strOut );
}
bldr.sendWithEOM();
Expand Down
5 changes: 4 additions & 1 deletion libweb3jsonrpc/Eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ Json::Value Eth::eth_accounts() {
return toJson( m_ethAccounts.allAccounts() );
}

string Eth::eth_blockNumber() {
string Eth::eth_blockNumber( const Json::Value& request ) {
if ( !request.empty() ) {
BOOST_THROW_EXCEPTION( JsonRpcException( Errors::ERROR_RPC_INVALID_PARAMS ) );
}
return toJS( client()->number() );
}

Expand Down
2 changes: 1 addition & 1 deletion libweb3jsonrpc/Eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Eth : public dev::rpc::EthFace, public skutils::json_config_file_accessor
virtual bool eth_mining() override;
virtual std::string eth_gasPrice() override;
virtual Json::Value eth_accounts() override;
virtual std::string eth_blockNumber() override;
virtual std::string eth_blockNumber( const Json::Value& request ) override;
virtual std::string eth_getBalance(
std::string const& _address, std::string const& _blockNumber ) override;
virtual std::string eth_getStorageAt( std::string const& _address, std::string const& _position,
Expand Down
5 changes: 2 additions & 3 deletions libweb3jsonrpc/EthFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ class EthFace : public ServerInterface< EthFace > {
response = this->eth_accounts();
}
inline virtual void eth_blockNumberI( const Json::Value& request, Json::Value& response ) {
( void ) request;
response = this->eth_blockNumber();
response = this->eth_blockNumber( request );
}
inline virtual void eth_getBalanceI( const Json::Value& request, Json::Value& response ) {
response = this->eth_getBalance( request[0u].asString(), request[1u].asString() );
Expand Down Expand Up @@ -432,7 +431,7 @@ class EthFace : public ServerInterface< EthFace > {
virtual bool eth_mining() = 0;
virtual std::string eth_gasPrice() = 0;
virtual Json::Value eth_accounts() = 0;
virtual std::string eth_blockNumber() = 0;
virtual std::string eth_blockNumber( const Json::Value& request ) = 0;
virtual std::string eth_getBalance( const std::string& param1, const std::string& param2 ) = 0;
virtual std::string eth_getStorageAt(
const std::string& param1, const std::string& param2, const std::string& param3 ) = 0;
Expand Down
21 changes: 10 additions & 11 deletions scripts/build_and_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ NAME=schain
REPO_NAME=skalenetwork/$NAME
IMAGE_NAME=$REPO_NAME:$VERSION

LABEL="develop"
if [ $BRANCH = "stable" ]
then
LABEL="stable"
elif [ $BRANCH = "beta" ]
# 3.17.0-develop.22 -> 3.17.0-develop
# 3.17.0-develop.22-hostoric -> 3.17.0-develop
LABEL="${VERSION%.*}"

# 3.17.0 -> 3.17.0
# 3.17.0-historic -> 3.17.0
if [[ "$BRANCH" == "stable" ]]
then
LABEL="beta"
LABEL=${VERSION%-historic}
fi

LATEST_IMAGE_NAME=$REPO_NAME:$LABEL-latest

if [[ $VERSION == *"historic" ]]
Expand Down Expand Up @@ -44,8 +47,4 @@ echo "Built $IMAGE_NAME"
echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin

docker push $IMAGE_NAME || exit $?

if [ $BRANCH = $LABEL ]
then
docker push $LATEST_IMAGE_NAME || exit $?
fi
docker push $LATEST_IMAGE_NAME || exit $?
2 changes: 1 addition & 1 deletion skaled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ int main( int argc, char** argv ) try {
cc::_on_ = false;
cc::_max_value_size_ = 2048;
MicroProfileSetEnableAllGroups( true );
dev::setThreadName( "main" );
BlockHeader::useTimestampHack = false;
srand( time( nullptr ) );
setCLocale();
Expand Down Expand Up @@ -2773,7 +2774,6 @@ int main( int argc, char** argv ) try {
<< cc::debug( "Done, programmatic shutdown via Web3 is disabled" );
}

dev::setThreadName( "main" );
if ( g_client ) {
unsigned int n = g_client->blockChain().details().number;
unsigned int mining = 0;
Expand Down
3 changes: 2 additions & 1 deletion test/historicstate/configs/basic_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":""}
]
Expand Down
15 changes: 15 additions & 0 deletions test/historicstate/hardhat/contracts/Push0.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Push0 {

uint256 public constant ZERO = 0;

function getZero() public {
// 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;
}
}
2 changes: 1 addition & 1 deletion test/historicstate/hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
71 changes: 71 additions & 0 deletions test/historicstate/hardhat/scripts/push0_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const OWNER_ADDRESS: string = "0x907cd0881E50d359bb9Fd120B1A5A143b1C97De6";
const ZERO_ADDRESS: string = "0xO000000000000000000000000000000000000000";
const INITIAL_MINT: bigint = 10000000000000000000000000000000000000000;

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<String> {

const trace = await ethers.provider.send('debug_traceTransaction', [hash, {}]);

console.log(JSON.stringify(trace, null, 4));
return trace;
}

async function deployWriteAndDestroy(): Promise<void> {

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}`);

console.log(`Now testing`);

const transferReceipt = await testContract.getZero()
console.log(`Gas limit ${transferReceipt.gasLimit}`);


}

async function main(): Promise<void> {
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;
});
Loading