Skip to content

Commit

Permalink
chore: fix solidity version and enable optimizer (#1425)
Browse files Browse the repository at this point in the history
<!--- Please provide a general summary of your changes in the title
above -->

<!-- Give an estimate of the time you spent on this PR in terms of work
days.
Did you spend 0.5 days on this PR or rather 2 days?  -->

Time spent on this PR:

## Pull request type

<!-- Please try to limit your pull request to one type,
submit multiple pull requests if needed. -->

Please check the type of change your PR introduces:

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [x] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying,
or link to a relevant issue. -->

Resolves #1419

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

- fix solidity version for DualVMToken, L1/L2 KakarotMessaging contracts
- enable optimizer 
- make sendMessageToL1 non payable to avoid locking ether

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1425)
<!-- Reviewable:end -->
  • Loading branch information
obatirou authored Sep 20, 2024
1 parent cfa8419 commit 221b976
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@ Deployed contract addresses will be stored in
A step by step description of the individual components and how they are
deployed/configured can be found [here](docs/general/kakarot_components.md).

## Slither

To run slither against provided Kakarot solidity contracts, you need to install
slither and run:

```bash
forge build --build-info --force
slither . --foundry-out-directory solidity_contracts/build --ignore-compile --include-paths "DualVmToken.sol|L1KakarotMessaging.sol|L2KakarotMessaging.sol" --checklist > report.md
```

## License

**kakarot** is released under the [MIT](LICENSE).
Expand Down
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test = 'solidity_contracts/tests'
out = 'solidity_contracts/build'
libs = ['solidity_contracts/lib']

optimizer = true
optimizer_runs = 100_000

[rpc_endpoints]
anvil = "http://127.0.0.1:8545"
kakarot = "http://127.0.0.1:3030"
Expand Down
2 changes: 1 addition & 1 deletion solidity_contracts/lib/kakarot-lib
2 changes: 1 addition & 1 deletion solidity_contracts/src/CairoPrecompiles/DualVmToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
pragma solidity 0.8.27;

import {CairoLib} from "kakarot-lib/CairoLib.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
pragma solidity 0.8.27;

import "../starknet/IStarknetMessaging.sol";

Expand Down
4 changes: 2 additions & 2 deletions solidity_contracts/src/L1L2Messaging/L2KakarotMessaging.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
pragma solidity 0.8.27;

import {CairoLib} from "kakarot-lib/CairoLib.sol";

contract L2KakarotMessaging {
/// @notice Sends a message to a contract on L1.
/// @param to The address of the contract on L1 to send the message to.
/// @param data The data to send to the contract on L1.
function sendMessageToL1(address to, bytes calldata data) external payable {
function sendMessageToL1(address to, bytes calldata data) external {
bytes memory payload = abi.encode(to, msg.sender, data);
CairoLib.sendMessageToL1(payload);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library UniswapV2Library {
hex"ff",
factory,
keccak256(abi.encodePacked(token0, token1)),
hex"0f5b822a8dffa6ce589a2c240d78a6a2b38a51835a97ceab40c1f301e46ba30b" // init code hash
hex"f1cfdd2c3c5d1c1326d5ea2b5624ae1ad7c2445c6b96eabc5af1dd53cdf64243" // init code hash
)
)
)
Expand Down

0 comments on commit 221b976

Please sign in to comment.