Skip to content

Commit a570164

Browse files
authored
Parity trie solidity implementation (2/3) (#162)
* init node header * change directory structure to fix compilation issues * node header * init nodecodec * nodecodec progress * nodecodec progress * nodebuilder and fixes Signed-off-by: nadeemb53 <[email protected]> * nodebuilder completion, bytes to uint8 array * foundry x hardhat directory structure * updated gitignore * fix: lib visibility * forge install: forge-std * added forge-std as submodule * scale codec scope * scale codec little endian to int, compact to int decoding * pr review fixes * remove decodeHash implementation Signed-off-by: nadeemb53 <[email protected]>
1 parent ca553f0 commit a570164

29 files changed

+23983
-15288
lines changed

.gitignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ result
6666
lean-setup/
6767

6868
# hardhat
69-
artifacts
70-
cache
71-
typechain-types
69+
artifacts/
70+
cache_hardhat/
71+
typechain-types/
72+
73+
# foundry
74+
cache/
75+
out/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "contracts/ethereum/lib/forge-std"]
2+
path = contracts/ethereum/lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

contracts/ethereum/.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

contracts/ethereum/README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
## EVM-IBC
1+
# <h1 align="center"> EVM IBC </h1>
22

3-
```shell
3+
### Getting Started
4+
5+
- Use Foundry:
6+
7+
```bash
8+
forge install
9+
forge test
10+
```
11+
12+
- Use Hardhat:
13+
14+
```bash
15+
npm install
416
npx hardhat test
5-
REPORT_GAS=true npx hardhat test
617
```
18+
19+
### Notes
20+
21+
Whenever you install new libraries using Foundry, make sure to update your `remappings.txt` file by running `forge remappings > remappings.txt`. This is required because we use `hardhat-preprocessor` and the `remappings.txt` file to allow Hardhat to resolve libraries you install with Foundry.

contracts/ethereum/contracts/trie-db/core/Codec.sol

-11
This file was deleted.

contracts/ethereum/contracts/trie-db/core/Node.sol

-65
This file was deleted.

contracts/ethereum/contracts/trie-db/interfaces/ITrie.sol

-65
This file was deleted.

contracts/ethereum/foundry.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[profile.default]
2+
src = 'src'
3+
out = 'out'
4+
libs = ['lib']
5+
6+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

contracts/ethereum/hardhat.config.ts

+37-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
1-
import { HardhatUserConfig } from "hardhat/config";
2-
import "@nomicfoundation/hardhat-toolbox";
1+
import fs from "fs";
2+
import "@nomiclabs/hardhat-waffle";
3+
import "@typechain/hardhat";
4+
import "hardhat-preprocessor";
5+
import { HardhatUserConfig, task } from "hardhat/config";
6+
7+
import example from "./tasks/example";
8+
9+
function getRemappings() {
10+
return fs
11+
.readFileSync("remappings.txt", "utf8")
12+
.split("\n")
13+
.filter(Boolean)
14+
.map((line) => line.trim().split("="));
15+
}
16+
17+
task("example", "Example task").setAction(example);
318

419
const config: HardhatUserConfig = {
520
solidity: {
621
version: "0.8.17",
722
settings: {
823
optimizer: {
924
enabled: true,
10-
runs: 1000,
25+
runs: 200,
1126
},
1227
},
1328
},
29+
paths: {
30+
sources: "./src", // Use ./src rather than ./contracts as Hardhat expects
31+
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
32+
},
33+
// This fully resolves paths for imports in the ./lib directory for Hardhat
34+
preprocess: {
35+
eachLine: (hre) => ({
36+
transform: (line: string) => {
37+
if (line.match(/^\s*import /i)) {
38+
getRemappings().forEach(([find, replace]) => {
39+
if (line.match(find)) {
40+
line = line.replace(find, replace);
41+
}
42+
});
43+
}
44+
return line;
45+
},
46+
}),
47+
},
1448
};
1549

1650
export default config;

contracts/ethereum/lib/forge-std

Submodule forge-std added at eb980e1

0 commit comments

Comments
 (0)