-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3.18.0' into bug/SKALED-1623-sigterm-at-exit
- Loading branch information
Showing
16 changed files
with
161 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |