Skip to content

Commit

Permalink
Integrate EVM and RPC (#71)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Frost <[email protected]>
Co-authored-by: Lawliet-Chan <[email protected]>
Co-authored-by: huyao <[email protected]>
  • Loading branch information
4 people authored Jun 27, 2024
1 parent 11e562a commit 2825e92
Show file tree
Hide file tree
Showing 19 changed files with 3,825 additions and 270 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
**/**/verse_db

data
itachi
itachi
**/**/verse_db
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ default: build

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

reset:
@rm -r yu cairo_db
@rm -r yu cairo_db verse_db

clean:
rm -f $(PROJECT)
153 changes: 37 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,116 +1,37 @@
# itachi
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.
It's open source for everyone to use.

Itachi is built on the [Yu](https://github.com/yu-org/yu) framework which not only makes it modular but also gives developers
a simpler and more user-friendly development experience, just as simple as developing a web backend.

It is specifically easy and helpful if you want to quickly own more of the stack and get more control over your chain.

## Overall Structure
![image](docs/images/itachi_arch.png)

## Cairo Compatible
- cairo-vm: 0.8.3
- cairo-lang: 2.4.0

## Build & Run
### Prerequisites
- rustc 1.74.0 (79e9716c9 2023-11-13)
- go 1.21

### Docker Pull & Run
```shell
docker pull ghcr.io/reddio-com/itachi:latest
docker-compose up
```

### Source code Build & Run
```shell
git submodule init
git submodule update --recursive --checkout
make build

./itachi
```
You can see the running results on your terminal.
![image](docs/images/itachi_running.jpg)

### Reset Chain
Reset Chain will clean all the stored history data locally.
```shell
make reset
```
## Test
### [Starknet.py](https://github.com/software-mansion/starknet.py)
You can use more complete python tests with `starknet.py`: https://github.com/reddio-com/itachi-testing

## 🌐 Connect to Test Endpoint
https://itachi-dev.reddio.com/

## Configs
### Chain Configs
The default config file of Itachi chain is `conf/cairo_cfg.toml`
### Genesis Configs
The genesis configs of Itachi chain is same as Madara. You can learn more details by [docs](docs/genesis.md)


## Starknet RPC
### 0.5.1
- [x] addDeclareTransaction
- [x] addDeployAccountTransaction
- [x] addInvokeTransaction
- [x] call
- [x] estimateFee
- [x] getTransactionReceipt
- [x] getTransactionByHash
- [x] getNonce
- [x] getTransactionStatus
- [x] getClass
- [x] getClassAt
- [x] getClassHashAt
- [ ] blockHashAndNumber
- [ ] getBlockWithTxHashes
- [ ] getBlockWithTxs
- [x] chainId
- [ ] syncing
- [ ] getTransactionByBlockIdAndIndex
- [ ] getBlockTransactionCount
- [ ] estimateMessageFee
- [ ] blockNumber
- [x] specVersion
- [ ] traceTransaction
- [x] simulateTransactions
- [ ] traceBlockTransactions
- [x] getStorageAt
- [ ] getStateUpdate


### 0.6.0
- [x] addDeclareTransaction
- [x] addDeployAccountTransaction
- [x] addInvokeTransaction
- [x] call
- [x] estimateFee
- [x] getTransactionReceipt
- [x] getTransactionByHash
- [x] getNonce
- [x] getTransactionStatus
- [x] getClass
- [x] getClassAt
- [x] getClassHashAt
- [ ] blockHashAndNumber
- [x] getBlockWithTxHashes
- [x] getBlockWithTxs
- [x] chainId
- [ ] syncing
- [ ] getTransactionByBlockIdAndIndex
- [ ] getBlockTransactionCount
- [ ] estimateMessageFee
- [ ] blockNumber
- [x] specVersion
- [ ] traceTransaction
- [x] simulateTransactions
- [ ] traceBlockTransactions
- [x] getStorageAt
- [ ] getStateUpdate
## Verse Chain

Verse builds a modular infrastructure and economic layer for on-chain games with CairoVM and EVM compatibility.

## Verse Chain Technical Brief

Verse leverages the **Itachi** infrastructure to introduce a specialized **Fractal Scaling Solution** for gaming applications.

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.

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.

Verse is set to transition from a single sequencer to a shared validation model with Itachi, marking a significant step toward scalability and decentralization.

![image](docs/images/versechain_arch.jpg)

## Verse Modules

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.

**On-chain VRF (Verifiable Random Function):**

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.

**zk Game General Circuits:**

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.

**ZK Governance:**

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.

**Anti-Mev:**

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.

We will address game-related MEV attacks using VerseChain's native modules.
4 changes: 3 additions & 1 deletion cmd/node/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"itachi/cairo/config"
"itachi/cairo/l1"
"itachi/cairo/starknetrpc"
"itachi/evm"
"itachi/evm/ethrpc"
"itachi/utils"

"github.com/common-nighthawk/go-figure"
"github.com/yu-org/yu/apps/poa"
"github.com/yu-org/yu/core/kernel"
"github.com/yu-org/yu/core/startup"
"itachi/evm"
)

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

ethrpc.StartupEthRPC(chain, evmCfg)
// Subscribe to L1
l1.StartupL1(chain, crCfg, rpcSrv)

Expand Down
4 changes: 3 additions & 1 deletion cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ func main() {
startup.InitDefaultKernelConfig()
poaCfg := poa.DefaultCfg(0)
cairoCfg := config.LoadCairoCfg("./conf/cairo_cfg.toml")
gethCfg := evm.SetDefaultGethConfig()
gethCfg := evm.LoadEvmConfig("./conf/evm_cfg.toml")

// go TestSendTransaction(gethCfg, true)

app.StartUpChain(poaCfg, cairoCfg, gethCfg)
}
Loading

0 comments on commit 2825e92

Please sign in to comment.