{"id":13756905,"url":"https://github.com/citahub/cita-vm","last_synced_at":"2025-05-13T16:30:51.575Z","repository":{"id":41830438,"uuid":"156328858","full_name":"citahub/cita-vm","owner":"citahub","description":"CITA VM","archived":false,"fork":false,"pushed_at":"2024-05-05T19:07:16.000Z","size":598,"stargazers_count":50,"open_issues_count":4,"forks_count":27,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-06T12:58:57.855Z","etag":null,"topics":["cita","evm","rust","vm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/citahub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-06T05:07:24.000Z","updated_at":"2023-10-01T08:07:57.000Z","dependencies_parsed_at":"2024-04-07T04:24:01.474Z","dependency_job_id":"aa7f4208-1a66-451e-9efc-2f96f9333981","html_url":"https://github.com/citahub/cita-vm","commit_stats":null,"previous_names":["cryptape/cita-vm"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citahub%2Fcita-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citahub%2Fcita-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citahub%2Fcita-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citahub%2Fcita-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/citahub","download_url":"https://codeload.github.com/citahub/cita-vm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253981685,"owners_count":21994317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cita","evm","rust","vm"],"created_at":"2024-08-03T11:00:56.952Z","updated_at":"2025-05-13T16:30:49.342Z","avatar_url":"https://github.com/citahub.png","language":"Rust","funding_links":[],"categories":["Virtual Machines"],"sub_categories":[],"readme":"# cita-vm\n\n[![Build Status](https://travis-ci.org/cryptape/cita-vm.svg?branch=master)](https://travis-ci.org/cryptape/cita-vm)\n\nFast EVM implementation for CITA. Tuned for high performance, up to 5x faster than parity. Based entirely on the [Ethereum Yellow Paper(Version: 2d0661f 2018-11-08)](https://github.com/ethereum/yellowpaper/tree/2d0661fc4924b6095042cba1681cb18e27f9e378).\n\n```\n[dependencies]\ncita-vm = \"0.3.3\"\n```\n\n- [Example](#Example)\n- [Performance comparison with parity and geth](#Performance-comparison-with-parity-and-geth)\n- [Tests](#Tests)\n- [Licences](#Licences)\n\n# Example\n\nLet us begin with the most basic example. First, we initialize a database in memory:\n\n```rs\nlet db = Arc::new(cita_vm::state::MemoryDB::new(false));\n```\n\nAnd, wrap this db as a `WorldState`\n\n```rs\nlet mut state = cita_vm::state::State::new(db).unwrap();\n```\n\nCreate some accounts in `WorldState`, one of them stores the [SimpleStorage](./examples/storage_example/simplestorage.sol) code.\n\n```rs\nlet code = \"6080604052600436106049576000357c0100000000000000000000000000000\\\n            000000000000000000000000000900463ffffffff16806360fe47b114604e57\\\n            80636d4ce63c146078575b600080fd5b348015605957600080fd5b506076600\\\n            4803603810190808035906020019092919050505060a0565b005b3480156083\\\n            57600080fd5b50608a60aa565b6040518082815260200191505060405180910\\\n            390f35b8060008190555050565b600080549050905600a165627a7a72305820\\\n            99c66a25d59f0aa78f7ebc40748fa1d1fbc335d8d780f284841b30e0365acd9\\\n            60029\";\nstate.new_contract(\n    \u0026Address::from_str(\"0xBd770416a3345F91E4B34576cb804a576fa48EB1\").unwrap(),\n    U256::from(10),\n    U256::from(1),\n    hex::decode(code).unwrap(),\n);\nstate.new_contract(\n    \u0026Address::from_str(\"0x1000000000000000000000000000000000000000\").unwrap(),\n    U256::from(1000000000000000u64),\n    U256::from(1),\n    vec![],\n);\n```\n\nSend a transaction to call `SimpleStorage.set(42)`\n\n```rs\nlet block_data_provider: Arc\u003ccita_vm::BlockDataProvider\u003e =\n        Arc::new(cita_vm::BlockDataProviderMock::default());\nlet state_data_provider = Arc::new(RefCell::new(state));\nlet context = cita_vm::evm::Context::default();\nlet config = cita_vm::Config {\n    block_gas_limit: 8000000,\n};\n\nlet tx = cita_vm::Transaction {\n    from: Address::from_str(\"0x1000000000000000000000000000000000000000\").unwrap(),\n    to: Some(Address::from(\"0xBd770416a3345F91E4B34576cb804a576fa48EB1\")),\n    value: U256::from(0),\n    nonce: U256::from(1),\n    gas_limit: 80000,\n    gas_price: U256::from(1),\n    input: hex::decode(\n        \"60fe47b1000000000000000000000000000000000000000000000000000000000000002a\",\n    )\n    .unwrap(),\n};\nlet r = cita_vm::exec(\n    block_data_provider.clone(),\n    state_data_provider.clone(),\n    context.clone(),\n    config.clone(),\n    tx,\n)\n.unwrap();\n```\n\nSend a transaction to call `SimpleStorage.get()`\n\n```rs\nlet tx = cita_vm::Transaction {\n    from: Address::from_str(\"0x1000000000000000000000000000000000000000\").unwrap(),\n    to: Some(Address::from_str(\"0xBd770416a3345F91E4B34576cb804a576fa48EB1\").unwrap()),\n    value: U256::from(0),\n    nonce: U256::from(2),\n    gas_limit: 80000,\n    gas_price: U256::from(1),\n    input: hex::decode(\"6d4ce63c\").unwrap(),\n};\nlet r = cita_vm::exec(\n    block_data_provider.clone(),\n    state_data_provider.clone(),\n    context.clone(),\n    config.clone(),\n    tx,\n)\n.unwrap();\nprintln!(\"return={:?}\", r); // 42 is outputed\n```\n\nFull code could be found [here](./examples/simplestorage.rs). You could run it by\n\n```\n$ cargo run --example simplestorage\n```\n\n# Performance comparison with parity and geth\n\nIn short, cita-vm is the fastest EVM. Below are [benchmark](https://github.com/ethereum/tests/tree/develop/VMTests/vmPerformance) results on **Intel(R) Xeon(R) CPU E5-26xx v3**.\n\n![img](./docs/benchmark_sep1.png)\n\n![img](./docs/benchmark_sep2.png)\n\n# Tests\n\n```sh\n$ make testdata\n$ cargo test\n```\n\n# Licences\n\nApache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitahub%2Fcita-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitahub%2Fcita-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitahub%2Fcita-vm/lists"}