Skip to content

Commit

Permalink
Parity trie solidity implementation (2/3) (#162)
Browse files Browse the repository at this point in the history
* 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 <nadeemb53@gmail.com>

* 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 <nadeemb53@gmail.com>
  • Loading branch information
nadeemb53 authored Jan 9, 2023
1 parent ca553f0 commit a570164
Show file tree
Hide file tree
Showing 29 changed files with 23,983 additions and 15,288 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ result
lean-setup/

# hardhat
artifacts
cache
typechain-types
artifacts/
cache_hardhat/
typechain-types/

# foundry
cache/
out/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contracts/ethereum/lib/forge-std"]
path = contracts/ethereum/lib/forge-std
url = https://github.com/foundry-rs/forge-std
3 changes: 3 additions & 0 deletions contracts/ethereum/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
21 changes: 18 additions & 3 deletions contracts/ethereum/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
## EVM-IBC
# <h1 align="center"> EVM IBC </h1>

```shell
### Getting Started

- Use Foundry:

```bash
forge install
forge test
```

- Use Hardhat:

```bash
npm install
npx hardhat test
REPORT_GAS=true npx hardhat test
```

### Notes

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.
11 changes: 0 additions & 11 deletions contracts/ethereum/contracts/trie-db/core/Codec.sol

This file was deleted.

65 changes: 0 additions & 65 deletions contracts/ethereum/contracts/trie-db/core/Node.sol

This file was deleted.

65 changes: 0 additions & 65 deletions contracts/ethereum/contracts/trie-db/interfaces/ITrie.sol

This file was deleted.

6 changes: 6 additions & 0 deletions contracts/ethereum/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[profile.default]
src = 'src'
out = 'out'
libs = ['lib']

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
40 changes: 37 additions & 3 deletions contracts/ethereum/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import fs from "fs";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-preprocessor";
import { HardhatUserConfig, task } from "hardhat/config";

import example from "./tasks/example";

function getRemappings() {
return fs
.readFileSync("remappings.txt", "utf8")
.split("\n")
.filter(Boolean)
.map((line) => line.trim().split("="));
}

task("example", "Example task").setAction(example);

const config: HardhatUserConfig = {
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 1000,
runs: 200,
},
},
},
paths: {
sources: "./src", // Use ./src rather than ./contracts as Hardhat expects
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
},
// This fully resolves paths for imports in the ./lib directory for Hardhat
preprocess: {
eachLine: (hre) => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
getRemappings().forEach(([find, replace]) => {
if (line.match(find)) {
line = line.replace(find, replace);
}
});
}
return line;
},
}),
},
};

export default config;
1 change: 1 addition & 0 deletions contracts/ethereum/lib/forge-std
Submodule forge-std added at eb980e
Loading

0 comments on commit a570164

Please sign in to comment.