Comments (5)
Thanks for the report!
Could you let us know exactly the error you are getting? Is is the last assertion that fails or is there some other error message?
from foundry-zksync.
It's just the assertion that doesn't pass, no error message. I think test1
and test2
should either both pass, or both fail. Thanks.
from foundry-zksync.
Hey @0xBrian, I investigated the issue. Thanks for the reproducible example, it was really helpful!
I actually tried fetching the source and luckily the contract was verified on the explorer so I could take a look at how it worked, and noticed that the DIGEST
is computed using a few items from the contract state, but also the msg.sender
.
Unfortunately, the answer to your issue is rather bland: prank
simply doesn't set the msg.sender
for nested calls!
So, in test2
, the msg.sender
would end up being the address where Blah
was deployed, and not MINER
, as it would be in the test1
.
I hope this helps!
from foundry-zksync.
OK, thank you for investigating. We figured it was something like that. But does it work this way in normal Foundry, or is it something related to the changes required for ZKSync? To me it seems like this behavior would prevent anyone from writing realistic tests.
from foundry-zksync.
Yes, that's intended foundry behaviour, we can also see this in the test suite here.
What we do require for ZKSync is that any contract running inside zkVM isn't able to use cheatcodes (in this case Blah
), but you can work around that by disabling zkVM before the call to the external contract, run your cheatcodes there, and re-enable zkVM afterwards.
For example:
vm.zkVm(false);
blah.doit(...);
and inside doit
:
vm.zkVm(true); //here or after prank is fine either way
// the important part is that `doit` isn't run inside zkVM
vm.prank(MINER);
...
As far as realistic test, I'm not sure I understand what you mean. If instead of Blah
you had another contract, on chain, which handled the calls to MINING_CONTRACT_ADDRESS
somehow, shouldn't you be calling tha contract instead then? And if instead it was some other kind of program off chain, wouldn't that basically be Test1
?
You can always create other functions in the Test1
contract to group functionality, and as long as it's not prefixed with test
(or a few others like invariant
) then it won't be executed as a standalone test.
I'll go ahead and close the issue since we clarified it's intended behaviour, but if you have any more questions you can just comment here on the issue and I'll still reply :)
from foundry-zksync.
Related Issues (20)
- Broken link to inlinable libraries
- cannot deploy with `forge create` HOT 7
- Forge create panics with impractical error message when passing wrong contract source HOT 2
- Unable to run `forge test` without --zksync flag HOT 1
- `forge-std` >=1.8.0 not supported HOT 1
- Deploy transaction simulation fails when deploying via create2 HOT 2
- Unable to specify custom zksolc compiler HOT 2
- Code hash not known error when trying to deploy factory contract HOT 3
- Got an error Unknown version provided if solc = "0.8.25" is defined in foundry.toml. HOT 2
- forge build fails with `Broken pipe` HOT 5
- Setting up 1 EVM fails HOT 11
- When I ran forge command with zksync flag, solc consumed a huge memory in large project HOT 3
- Test failures when running on regular EVM HOT 2
- Unable to deploy contract with big factory deps on zkSync Era mainnet HOT 9
- "./install-foundry-zksync" not working HOT 20
- `forge coverage --via-ir` fails with stack too deep HOT 1
- Reading value that was deleted in a mapping causes panic HOT 4
- Getting an error when running ./install-foundry-zksync HOT 10
- Unable to deploy using create2 factory HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foundry-zksync.