EVMStoreChain is a Cosmos SDK-based blockchain that allows validators to read the state from Ethereum, post the Ethereum state to the Cosmos blockchain as a vote, and query the agreed-upon state.
- Utilize the Cosmos SDK to build a prototype blockchain that can read the state from Ethereum, verify its validity, and store it on your chain.
- The chain should be able to agree upon some Ethereum state. There should be a mechanism that facilitates this agreement. The state itself should be a single storage slot of some address.
- Once some storage value is agreed upon, it should be stored on your blockchain along with the input parameters that were used to query it. Users should be able to read data from your blockchain.
Validators of the Cosmos blockchain should run a script or service that observes the Ethereum blockchain and submits SubmitEthereumState
transactions to the Cosmos blockchain with what they observe. They submit the state observed and the block number the state observed for
Each validator should be responsible for fetching the Ethereum state independently and then submitting a proposal with that state. Even if the Ethereum state changes between the time different validators fetch it, this will not introduce non-determinism into the Cosmos chain. This is because the Cosmos chain does not directly query the Ethereum state during transaction processing. Instead, it relies on the data provided in the validators' proposals, which is deterministic and consistent across all validators.
For validators to be honest and report the correct state , slashing module is used, the EVMStoreChain slash a validator when they submit a vote that does not match the majority decision.
- Go (version 1.19 or higher)
- Cosmos-sdk
- Infura account
Install the Ignite CLI:
curl https://get.ignite.com/cli! | bash
git clone https://github.com/0xsuryansh/EVMStoreChain
There are 2 directories in this repository:
-
EVMStateVoteClient - A Go client to query Ethereum for a state (borrowIndex of Compound's cUSDT token contract), post Ethereum state to the Cosmos blockchain, and query the state based on the block number.
-
EVMStoreChain - Cosmos SDK-based blockchain code.
Run the following command to start the blockchain:
cd EVMStoreChain
ignite chain serve
Navigate to the EVMStateVoteClient directory:
cd EVMStateVoteClient
go mod tidy
export INFURA_URL="YOUR_INFURA_URL"
go run main.go
This client fetches the borrowIndex of the Compound's cUSDT token of the latest block and posts it as a vote to the Cosmos blockchain using the SubmitEthereumState function. You can then query the state with the highest vote.
For validator voting,
EVMStoreChaind tx evmstorechain submit-ethereum-state [blocknumber] [state] --from [account]
For querying
EVMStoreChaind q evmstorechain show-blockstoragestate [blocknumber]