Skip to content

Commit 2825e92

Browse files
wliu6vFrostStarBookLawliet-Chanhuyao
authored
Integrate EVM and RPC (#71)
* add evm * fix issue * fix issue * Update eth.go * fix issue * add InitChain and EVM * fix ExecuteTxn issue * fix issue * update InitChain * fix issue * add call func * access yu framework * add message * add Create func and access yu framework * code fmt * add Commit func * add genesis * integration Genesis * add StartUpEvmChain * recover cairoChain * fix issue for CR * fix state * fix issue:set default EthStateConfig * implement evm rpc * fix initChainConfig issue * fix GetCurrentBlock() * fix log.print * fix init NewEthState failed: missing trie node error * load evmconfig from config file * fix Solidity commit failed on Block(295), error: missing trie node * fix issue * fix * implement CreateContract call * fix evm parameter bug * fix merge issue * fix merge issue * fix: missing default config in evm.LoadEvmConfig * fix bug : missing parameter * fix bug:add gasPrice to config * copy codes from geth * implement sendRawTransaction * rm code * rm createAccount from executeTxn * setNonce * chainConfig * rpc * Integrated Create function * Replace manual RPC parameter parsing with EthApiBackend * fix: failed to parse sender from signedTxRequest * add Genesis Address log * [Test] Add method for testing RPC requests * fix state nil bug * EthState set StateDB init * add EthState GetNonce func * fix bug: evm StateDB nil bug * add devaccount in genesis accounts * setEVM cfg stateDB * ethdb * add SetupGenesisBlock for initchain * fix bug:init NewEthState failed * fix genesis statedb sets * update EVM TxTest * fix: nil pointer for create contract request * add TestCreateContract function * EthAPIBackend.CurrentBlock() * fix: invalid signature error * update log print * update init GethConfig * Update README.md * Update README.md * Update Readme * Update README.md * Update README.md * implement eth_call api * fix bug: Call func issue * fix: missing return value in eth_call response * fix currentStateRoot (#5) * fix currentStateRoot * Revert "fix currentStateRoot" This reverts commit f649a40. * fix currentStateRoot --------- Co-authored-by: Lawliet-Chan <1576710154@qq.com> --------- Co-authored-by: Frost <froststarbook@gmail.com> Co-authored-by: Lawliet-Chan <1576710154@qq.com> Co-authored-by: huyao <huyao1984@gmail.com>
1 parent 11e562a commit 2825e92

19 files changed

+3825
-270
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
**/**/verse_db
55

66
data
7-
itachi
7+
itachi
8+
**/**/verse_db

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ default: build
44

55
build:
66
make -C juno rustdeps
7-
go build -v -o $(PROJECT) ./cmd/node/main.go
7+
go build -v -o $(PROJECT) ./cmd/node/main.go ./cmd/node/testrequest.go
88

99
reset:
10-
@rm -r yu cairo_db
10+
@rm -r yu cairo_db verse_db
1111

1212
clean:
1313
rm -f $(PROJECT)

README.md

+37-116
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,37 @@
1-
# itachi
2-
Welcome to **itachi**, the much easier and more flexible modular stack to build Layer 2 or Layer 3 chains using Cairo and the Starknet technology.
3-
It's open source for everyone to use.
4-
5-
Itachi is built on the [Yu](https://github.com/yu-org/yu) framework which not only makes it modular but also gives developers
6-
a simpler and more user-friendly development experience, just as simple as developing a web backend.
7-
8-
It is specifically easy and helpful if you want to quickly own more of the stack and get more control over your chain.
9-
10-
## Overall Structure
11-
![image](docs/images/itachi_arch.png)
12-
13-
## Cairo Compatible
14-
- cairo-vm: 0.8.3
15-
- cairo-lang: 2.4.0
16-
17-
## Build & Run
18-
### Prerequisites
19-
- rustc 1.74.0 (79e9716c9 2023-11-13)
20-
- go 1.21
21-
22-
### Docker Pull & Run
23-
```shell
24-
docker pull ghcr.io/reddio-com/itachi:latest
25-
docker-compose up
26-
```
27-
28-
### Source code Build & Run
29-
```shell
30-
git submodule init
31-
git submodule update --recursive --checkout
32-
make build
33-
34-
./itachi
35-
```
36-
You can see the running results on your terminal.
37-
![image](docs/images/itachi_running.jpg)
38-
39-
### Reset Chain
40-
Reset Chain will clean all the stored history data locally.
41-
```shell
42-
make reset
43-
```
44-
## Test
45-
### [Starknet.py](https://github.com/software-mansion/starknet.py)
46-
You can use more complete python tests with `starknet.py`: https://github.com/reddio-com/itachi-testing
47-
48-
## 🌐 Connect to Test Endpoint
49-
https://itachi-dev.reddio.com/
50-
51-
## Configs
52-
### Chain Configs
53-
The default config file of Itachi chain is `conf/cairo_cfg.toml`
54-
### Genesis Configs
55-
The genesis configs of Itachi chain is same as Madara. You can learn more details by [docs](docs/genesis.md)
56-
57-
58-
## Starknet RPC
59-
### 0.5.1
60-
- [x] addDeclareTransaction
61-
- [x] addDeployAccountTransaction
62-
- [x] addInvokeTransaction
63-
- [x] call
64-
- [x] estimateFee
65-
- [x] getTransactionReceipt
66-
- [x] getTransactionByHash
67-
- [x] getNonce
68-
- [x] getTransactionStatus
69-
- [x] getClass
70-
- [x] getClassAt
71-
- [x] getClassHashAt
72-
- [ ] blockHashAndNumber
73-
- [ ] getBlockWithTxHashes
74-
- [ ] getBlockWithTxs
75-
- [x] chainId
76-
- [ ] syncing
77-
- [ ] getTransactionByBlockIdAndIndex
78-
- [ ] getBlockTransactionCount
79-
- [ ] estimateMessageFee
80-
- [ ] blockNumber
81-
- [x] specVersion
82-
- [ ] traceTransaction
83-
- [x] simulateTransactions
84-
- [ ] traceBlockTransactions
85-
- [x] getStorageAt
86-
- [ ] getStateUpdate
87-
88-
89-
### 0.6.0
90-
- [x] addDeclareTransaction
91-
- [x] addDeployAccountTransaction
92-
- [x] addInvokeTransaction
93-
- [x] call
94-
- [x] estimateFee
95-
- [x] getTransactionReceipt
96-
- [x] getTransactionByHash
97-
- [x] getNonce
98-
- [x] getTransactionStatus
99-
- [x] getClass
100-
- [x] getClassAt
101-
- [x] getClassHashAt
102-
- [ ] blockHashAndNumber
103-
- [x] getBlockWithTxHashes
104-
- [x] getBlockWithTxs
105-
- [x] chainId
106-
- [ ] syncing
107-
- [ ] getTransactionByBlockIdAndIndex
108-
- [ ] getBlockTransactionCount
109-
- [ ] estimateMessageFee
110-
- [ ] blockNumber
111-
- [x] specVersion
112-
- [ ] traceTransaction
113-
- [x] simulateTransactions
114-
- [ ] traceBlockTransactions
115-
- [x] getStorageAt
116-
- [ ] getStateUpdate
1+
## Verse Chain
2+
3+
Verse builds a modular infrastructure and economic layer for on-chain games with CairoVM and EVM compatibility.
4+
5+
## Verse Chain Technical Brief
6+
7+
Verse leverages the **Itachi** infrastructure to introduce a specialized **Fractal Scaling Solution** for gaming applications.
8+
9+
Through smart contracts and chain-native modules, we enable developers to efficiently utilize functions and tools such as onchain VRF, AA wallets, and zk game general circuit. We also incorporate a few innovative EIPs such as EIP-5564 and EIP-6538 at the chain level, optimizing transaction efficiency and security, to empower game developers with more tool-kits and to enhance user experience.
10+
11+
Significantly, Verse bridges the gap between EVM and CarioVM via our unique parallel-chains structure, by creating chain-native common modules and making both EVM and CarioVM settle in the StarkNet, achieving higher compatibility across different virtual machines.
12+
13+
Verse is set to transition from a single sequencer to a shared validation model with Itachi, marking a significant step toward scalability and decentralization.
14+
15+
![image](docs/images/versechain_arch.jpg)
16+
17+
## Verse Modules
18+
19+
Verse will provide games with contract-based and native blockchain components, significantly reducing development costs. With the introduction of native blockchain modules, games will easily have access to features such as random number generation and anti-MEV capabilities, which are difficult to implement on other blockchains.
20+
21+
**On-chain VRF (Verifiable Random Function):**
22+
23+
Verse provides a necessary source of randomness for games via on-chain VRF, ensuring the fairness and unpredictability of game outcomes. This is particularly important for games that require fair random results, such as online card games and gambling applications. The on-chain VRF secures the generation of random numbers in a cryptographically safe manner, preventing any possibility of manipulation.
24+
25+
**zk Game General Circuits:**
26+
27+
Utilizing Zero-Knowledge Proof (ZKP) technology, the Verse platform can verify the correctness of game states and player actions without revealing any player information. This not only enhances the security of the games but also protects the privacy of the players.
28+
29+
**ZK Governance:**
30+
31+
Zero Knowledge Governance (ZK Governance) offers a comprehensive solution to these challenges by balancing the need for transparency in governance with the privacy of individual voters.
32+
33+
**Anti-Mev:**
34+
35+
FOCG will encounter very serious MEV attack issues. Bots can fully monitor opponents' actions and respond accordingly, gaining a first-mover advantage by manipulating gas fees.
36+
37+
We will address game-related MEV attacks using VerseChain's native modules.

cmd/node/app/app.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"itachi/cairo/config"
66
"itachi/cairo/l1"
77
"itachi/cairo/starknetrpc"
8+
"itachi/evm"
9+
"itachi/evm/ethrpc"
810
"itachi/utils"
911

1012
"github.com/common-nighthawk/go-figure"
1113
"github.com/yu-org/yu/apps/poa"
1214
"github.com/yu-org/yu/core/kernel"
1315
"github.com/yu-org/yu/core/startup"
14-
"itachi/evm"
1516
)
1617

1718
func StartUpChain(poaCfg *poa.PoaConfig, crCfg *config.Config, evmCfg *evm.GethConfig) {
@@ -22,6 +23,7 @@ func StartUpChain(poaCfg *poa.PoaConfig, crCfg *config.Config, evmCfg *evm.GethC
2223
// Starknet RPC server
2324
rpcSrv := starknetrpc.StartUpStarknetRPC(chain, crCfg)
2425

26+
ethrpc.StartupEthRPC(chain, evmCfg)
2527
// Subscribe to L1
2628
l1.StartupL1(chain, crCfg, rpcSrv)
2729

cmd/node/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ func main() {
1313
startup.InitDefaultKernelConfig()
1414
poaCfg := poa.DefaultCfg(0)
1515
cairoCfg := config.LoadCairoCfg("./conf/cairo_cfg.toml")
16-
gethCfg := evm.SetDefaultGethConfig()
16+
gethCfg := evm.LoadEvmConfig("./conf/evm_cfg.toml")
17+
18+
// go TestSendTransaction(gethCfg, true)
1719

1820
app.StartUpChain(poaCfg, cairoCfg, gethCfg)
1921
}

0 commit comments

Comments
 (0)