Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate EVM and RPC #71

Merged
merged 85 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6067105
add evm
FrostStarBook May 8, 2024
be223b6
fix issue
FrostStarBook May 15, 2024
ae6d3be
fix issue
FrostStarBook May 15, 2024
9b6bda7
Update eth.go
FrostStarBook May 20, 2024
794d4f1
fix issue
FrostStarBook May 20, 2024
dd61ebd
add InitChain and EVM
FrostStarBook May 21, 2024
43ca8ab
fix ExecuteTxn issue
FrostStarBook May 22, 2024
4bf8d9b
fix issue
FrostStarBook May 22, 2024
0c03a20
update InitChain
FrostStarBook May 23, 2024
896f04c
fix issue
FrostStarBook May 23, 2024
474388d
add call func
FrostStarBook May 23, 2024
5754a67
access yu framework
FrostStarBook May 23, 2024
b131293
add message
FrostStarBook May 23, 2024
13cef57
add Create func and access yu framework
FrostStarBook May 23, 2024
306bf29
code fmt
FrostStarBook May 23, 2024
55cfaea
add Commit func
FrostStarBook May 24, 2024
fabd55e
add genesis
FrostStarBook May 24, 2024
50213b0
integration Genesis
FrostStarBook May 24, 2024
b037efd
add StartUpEvmChain
FrostStarBook May 24, 2024
fc8450e
recover cairoChain
FrostStarBook May 24, 2024
4a2972e
fix issue for CR
FrostStarBook May 28, 2024
a5d660f
fix state
Lawliet-Chan May 28, 2024
fcf4ec4
fix issue:set default EthStateConfig
FrostStarBook May 29, 2024
497d3f3
implement evm rpc
wliu6v May 30, 2024
e0d50a0
Merge pull request #2 from CheDAOLabs/merge-rpc
wliu6v May 30, 2024
cc45728
fix initChainConfig issue
FrostStarBook May 30, 2024
5d61a18
fix GetCurrentBlock()
Lawliet-Chan May 30, 2024
d7482fa
fix log.print
Lawliet-Chan May 30, 2024
c3a3bef
fix init NewEthState failed: missing trie node error
FrostStarBook May 30, 2024
1f318f2
Merge branch 'sp-evm' into evm-test
FrostStarBook May 30, 2024
156b665
load evmconfig from config file
wliu6v May 30, 2024
44f7bef
fix Solidity commit failed on Block(295), error: missing trie node
FrostStarBook May 30, 2024
31aa1e5
Merge branch 'sp-evm' into evm-test
FrostStarBook May 30, 2024
c060a5d
fix issue
FrostStarBook May 30, 2024
b451ef3
fix
Lawliet-Chan May 30, 2024
c8cf574
implement CreateContract call
wliu6v Jun 6, 2024
5aea43c
fix evm parameter bug
FrostStarBook Jun 11, 2024
e4ef10e
Merge branch 'sp-evm' into evm-test
FrostStarBook Jun 11, 2024
3939fad
Merge branch 'evm' into evm-test
FrostStarBook Jun 11, 2024
04a30fe
fix merge issue
FrostStarBook Jun 11, 2024
734fd6e
fix merge issue
FrostStarBook Jun 11, 2024
1cb8b54
fix: missing default config in evm.LoadEvmConfig
wliu6v Jun 11, 2024
080f219
fix bug : missing parameter
FrostStarBook Jun 12, 2024
9233a3c
Merge branch 'sp-evm' into evm-test
FrostStarBook Jun 12, 2024
28b0723
fix bug:add gasPrice to config
FrostStarBook Jun 12, 2024
2380140
Merge branch 'sp-evm' into evm-test
FrostStarBook Jun 12, 2024
6c20341
copy codes from geth
Lawliet-Chan Jun 12, 2024
ea4804a
implement sendRawTransaction
Lawliet-Chan Jun 13, 2024
b4e9c18
rm code
Lawliet-Chan Jun 13, 2024
a9b3593
rm createAccount from executeTxn
Lawliet-Chan Jun 13, 2024
89fa873
setNonce
Lawliet-Chan Jun 13, 2024
fbd1d37
chainConfig
Lawliet-Chan Jun 13, 2024
dffc097
rpc
Lawliet-Chan Jun 13, 2024
6908f82
Integrated Create function
FrostStarBook Jun 13, 2024
575d13b
Replace manual RPC parameter parsing with EthApiBackend
wliu6v Jun 13, 2024
b70657e
fix: failed to parse sender from signedTxRequest
wliu6v Jun 17, 2024
18d67de
add Genesis Address log
FrostStarBook Jun 17, 2024
459573e
[Test] Add method for testing RPC requests
wliu6v Jun 17, 2024
cee26f5
fix state nil bug
FrostStarBook Jun 17, 2024
b3d2025
EthState set StateDB init
FrostStarBook Jun 17, 2024
adb2e36
add EthState GetNonce func
FrostStarBook Jun 17, 2024
8d0d6c6
fix bug: evm StateDB nil bug
FrostStarBook Jun 17, 2024
14aa490
add devaccount in genesis accounts
wliu6v Jun 17, 2024
1759f78
setEVM cfg stateDB
FrostStarBook Jun 17, 2024
c392239
ethdb
Lawliet-Chan Jun 18, 2024
ab49d60
add SetupGenesisBlock for initchain
FrostStarBook Jun 18, 2024
2675475
fix bug:init NewEthState failed
FrostStarBook Jun 18, 2024
96693d7
fix genesis statedb sets
Lawliet-Chan Jun 19, 2024
e6a324e
update EVM TxTest
FrostStarBook Jun 19, 2024
6ede42f
fix: nil pointer for create contract request
wliu6v Jun 20, 2024
3c3643d
add TestCreateContract function
wliu6v Jun 20, 2024
849543d
EthAPIBackend.CurrentBlock()
Lawliet-Chan Jun 20, 2024
0c88f18
fix: invalid signature error
wliu6v Jun 20, 2024
9cd2780
update log print
FrostStarBook Jun 20, 2024
4ffeab3
update init GethConfig
FrostStarBook Jun 20, 2024
cdac5ff
Update README.md
huyao Jun 20, 2024
32c20c9
Update README.md
huyao Jun 20, 2024
13ad07b
Update Readme
huyao Jun 20, 2024
33cce36
Update README.md
huyao Jun 20, 2024
13aacab
Update README.md
huyao Jun 21, 2024
e0e89e5
implement eth_call api
wliu6v Jun 24, 2024
2116ffb
fix bug: Call func issue
FrostStarBook Jun 25, 2024
b098dbf
fix: missing return value in eth_call response
wliu6v Jun 25, 2024
543c5cb
Merge pull request #3 from VersechainLabs/rpc-call
wliu6v Jun 25, 2024
0782d54
fix currentStateRoot (#5)
wliu6v Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading