ciaranmcveigh5 / ethernaut-x-foundry Goto Github PK
View Code? Open in Web Editor NEWEthernaut puzzles solved with foundry
License: MIT License
Ethernaut puzzles solved with foundry
License: MIT License
Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.
The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.
For your repository, we find that the following event use can be improved:
constructor(address _player)
ERC20('NaughtCoin', '0x0')
public {
player = _player;
INITIAL_SUPPLY = 1000000 * (10**uint256(decimals()));
// _totalSupply = INITIAL_SUPPLY;
// _balances[player] = INITIAL_SUPPLY;
_mint(player, INITIAL_SUPPLY);
emit Transfer(address(0), player, INITIAL_SUPPLY);
}
Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!
When an engineer forks and uses this repo to start solving Ethernaut exercises, all solutions are present in the fork.
Remove the solutions from the main branch but preserve them on a separate branch (perhaps calls solutions
). I think it makes sense to preserve the solutions in case developers get stuck and want to refer to a reference example.
Tests are failing in the latest version of foundry-cli
(v0.1.0). Recommended CLI command is also outdated.
git clone --recursive https://github.com/ciaranmcveigh5/ethernaut-x-foundry.git
forge build
forge test -m Fallback --verbosity 3
➜ forge test -m Fallback --verbosity 3
no files changed, compilation skippped.
Running 1 test for "FallbackTest.json":FallbackTest
[FAIL. Reason: Invalid data] testFallbackHack() (gas: 921345)
Failure: testFallbackHack()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.