Cartesi RISC-V Solidity Emulator – Cartesi-RISC-V固体仿真器区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Cartesi RISC-V Solidity Emulator – Cartesi-RISC-V固体仿真器区块链毕设代写 是一篇很好的国外资料

⚠️ The Cartesi team keeps working internally on the next version of this repository, following its regular development roadmap. Whenever there’s a new version ready or important fix, these are published to the public source tree as new releases.

Cartesi RISC-V Solidity Emulator

The Cartesi RISC-V Solidity Emulator is the on-chain host implementation of the Cartesi Machine Specification. The libraries and contracts are written in Solidity, the migration script is written in Javascript (with the help of Truffle), and the testing scripts are written in Python.

For Cartesi’s design to work, this implementation must have the exact transition function as the off-chain Cartesi RISC-V Emulator, meaning that if given the same initial state (s[i]) both implementation’s step functions should reach a bit by bit consistent state s[i + 1].

Since the cost of storing a full Cartesi Machine state within the blockchain is prohibitive, all machine states are represented in the blockchain as cryptographic hashes. The contents of those states and memory represented by those hashes are only known off-chain.

Cartesi uses Merkle tree operations and properties to ensure that the blockchain has the ability to correctly verify a state transition without having full state-access. However, the RISC-V Solidity emulator abstracts these operations away and acts as if it knows the full contents of a machine state – it uses the Memory Manager interface to fetch or write any necessary words to memory.

Memory Manager

The memory manager contract is consumed by the RISC-V Solidity emulator as if the entire state content was available – since the off and on-chain emulators match down to the order in which accesses are logged. When a dispute arises, Alice sends her off-chain state access log referent to the disagreement step to the MemoryManager contract, which will guide the execution of a Step (i.e state transition function).

The MemoryManager contract offers the RISC-V Solidity emulator a very simple interface that consists of:

  • read – reads a word in a specific address.
  • write – writes a word in a specific address.
  • finishReplayPhase – signals that the Step has completed.

It also makes sure that all accesses performed by the Step function match the ones provided by Alice and are consistent with the Merkle proofs provided by her. If that is not the case, Alice loses the dispute.

The real Memory Manager contract can be found at Arbitration DLib. In the present repo we have a MockMemoryManager, that still offers the same interface and makes sure all the proofs are consistent – but it doesn’t comply with the Verification Game requirements. It should not be used in production, it doesn’t include security measures, it doesn’t provide access control and so on. The MockMemoryManager is meant to be used for testing purposes, so that the state transition function can be tested without the need to play a full mock verification game.

Step function

Step is the previously mentioned state transition function, it is meant to take the machine from state s[i] to state[i + 1], using the memory manager as an assistant. The step function receives a MemoryManager index – which should have been populated with the access log generated by the emulator off-chain and returns an Exit code signaling the result of its execution.

The Step execution usually consists of the following steps:

  • Check if machine is halted.
  • If not, raise the highest priority interrupt (if there is any to be raised).
  • Fetch instruction.
  • If Fetch was successful, tries to execute that instruction.
  • If Execute was successful updates the number of retired instructions.
  • Updated the mcycle.
  • End Step.

During a Step execution, every necessary read or write (be it to memory, registers etc) is processed and verified by the MemoryManager at the index provided in the function call.

Memory Interactor

The Memory Interactor contract is the middleman between the Step and the Memory Manager contracts. It’s constructor must receive Memory Manager’s address in order to operate on the correct deployed version. The Memory Interactor is responible for correcting the endianess of the information available in Memory Manager. The endianess swap is necessary because RiscV treats its memory as little-endian while EVM uses big-endian order. The contract is also used to help step take care of partial reads and writes to memory, since Memory Manager only knows how to deal with entire words(64 bits).

Getting Started

Install

Install dependencies and build:

yarn 

Having a node listening to 8545, you can deploy using:

yarn deploy 

Run tests

Run step tests with docker:

docker build . -t cartesi/step-test -f Dockerfile.step  docker run cartesi/step-test 

Run ram tests with docker:

docker build . -t cartesi/ram-test -f Dockerfile.ram  docker run cartesi/ram-test 

Build main test docker image with aleth:

docker build . -t cartesi/test 

Run step test with docker + aleth:

docker run cartesi/test 

Run sequence test with all files:

docker run -v <hostpath>:/usr/src/app/proofs/ --entrypoint ./machine-test cartesi/test sequence --network Istanbul --contracts-config sequence_contracts.json 

Run sequence test with standard input:

cat <jsonfile> | docker run -i --entrypoint ./machine-test cartesi/test sequence --network Istanbul --contracts-config sequence_contracts.json --cin 

Contributing

Thank you for your interest in Cartesi! Head over to our Contributing Guidelines for instructions on how to sign our Contributors Agreement and get started with Cartesi!

Please note we have a Code of Conduct, please follow it in all your interactions with the project.

Authors

  • Felipe Argento

License

The machine-solidity-step repository and all contributions are licensed under APACHE 2.0. Please review our LICENSE file.

We use cookies and similar technologies (“cookies”) to provide and secure our websites, as well as to analyze the usage of our websites, in order to offer you a great user experience. To learn more about our use of cookies see our Privacy Statement.

Select Accept all to consent to this use, Reject all to decline this use, or More info to control your cookie preferences. You can always update your selection by clicking Cookie Preferences at the bottom of the page.


在⚠️ Cartesi团队按照常规的开发路线图,继续在内部开发这个存储库的下一个版本。每当有一个新版本准备就绪或重要的修复程序时,它们都会作为新版本发布到公共源代码树中。

分析cookies

Cartesi RISC-V Solidity仿真器是Cartesi机器规范的链上主机实现。库和契约是用Solidity编写的,迁移脚本是用Javascript编写的(在Truffle的帮助下),测试脚本是用Python编写的。

为了使Cartesi的设计工作,该实现必须具有与链外Cartesi RISC-V仿真器相同的转换函数,这意味着如果给定相同的初始状态(s[i]),则两个实现的阶跃函数都应达到逐位一致的状态s[i+1]。

由于在区块链blockchain中存储完整的Cartesi机器状态的成本过高,因此所有机器状态都在区块链blockchain中表示为加密哈希。只有那些存储链外的哈希值和内容才是已知的。

Cartesi使用Merkle树操作和属性来确保区块链blockchain能够正确验证状态转换,而无需完全访问状态。然而,RISC-V Solidity仿真器将这些操作抽象化,就像知道机器状态的全部内容一样——它使用内存管理器接口来获取或写入任何必要的单词到内存中。

Memory Manager

内存管理器契约被RISC-V Solidity仿真器使用,就好像整个状态内容都可用一样—因为链外和链上仿真器根据访问记录的顺序匹配。当发生争议时,Alice将其链外状态访问日志referent发送到MemoryManager契约,后者将指导步骤的执行(即状态转换函数)。

MemoryManager合同为RISC-V Solidity仿真器提供了一个非常简单的接口,包括:

  • 读取-读取特定地址中的单词。
  • 写-在特定地址中写入一个单词。
  • 结束播放阶段-表示步骤已完成。

它还确保Step函数执行的所有访问都与Alice提供的访问匹配,并且与她提供的Merkle证明一致。如果不是这样,爱丽丝就输了。

可在仲裁DLib中找到real Memory Manager合同。在目前的回购中,我们有一个MockMemoryManager,它仍然提供相同的接口,并确保所有的证明都是一致的,但它不符合验证游戏的要求。不应该在生产中使用它,所以不应该包括它的安全措施。MockMemoryManager用于测试目的,因此可以测试状态转换函数,而无需玩完整的模拟验证游戏。

Step function

步骤是前面提到的状态转换函数,它是指将机器从状态s[i]切换到状态[i+1],使用内存管理器作为助手。step函数接收一个MemoryManager索引,该索引应该使用由链外模拟器生成的访问日志填充,并返回一个退出代码,指示其执行结果。

步骤执行通常包括以下步骤:

  • 检查机器是否停止。
  • 否则,引发最高优先级中断(如果有任何中断将被触发)。
  • 获取指令。
  • 如果获取成功,则尝试执行该指令。
  • 如果Execute成功,则更新失效的指令数。
  • 更新了mcycle。
  • 结束步骤。

在步骤执行过程中,每个必要的读或写(无论是对内存、寄存器等)都由MemoryManager在函数调用中提供的索引处进行处理和验证。

Memory Interactor

内存交互器契约是步骤和内存管理器契约之间的中间人。它的构造函数必须接收内存管理器的地址才能在正确的部署版本上操作。内存交互器负责纠正内存管理器中可用信息的结尾。endianess交换是必要的,因为RiscV将其内存视为小endian,而EVM使用big-endian顺序。契约还用于帮助step处理对内存的部分读写,因为内存管理器只知道如何处理整个字(64位)。

Getting Started

Install

安装依赖项并构建:

yarn 

让一个节点监听8545,可以使用:

yarn deploy 

Run tests

使用docker运行步骤测试:

docker build . -t cartesi/step-test -f Dockerfile.step  docker run cartesi/step-test 

使用docker运行ram测试:

docker build . -t cartesi/ram-test -f Dockerfile.ram  docker run cartesi/ram-test 

使用aleth构建主测试docker映像:

docker build . -t cartesi/test 

使用docker+aleth运行步骤测试:

docker run cartesi/test 

使用所有文件运行序列测试:

docker run -v <hostpath>:/usr/src/app/proofs/ --entrypoint ./machine-test cartesi/test sequence --network Istanbul --contracts-config sequence_contracts.json 

运行序列测试标准输入:

cat <jsonfile> | docker run -i --entrypoint ./machine-test cartesi/test sequence --network Istanbul --contracts-config sequence_contracts.json --cin 

Contributing

感谢您对Cartesi感兴趣!请参阅我们的贡献指南,了解如何签署我们的贡献者协议并开始使用Cartesi!

请注意,我们有行为准则,请在您与项目的所有互动中遵守该准则。

Authors

  • 费利佩·阿根托

License

machine solidity step存储库和所有贡献都是在apache2.0下授权的。请查看我们的许可证文件。

我们使用Cookie和类似技术(“Cookie”)来提供和保护我们的网站,并分析我们网站的使用情况,以便为您提供出色的用户体验。要了解更多有关cookies使用的信息,请参阅我们的隐私声明。

选择“全部接受”以同意此使用,选择“全部拒绝”以拒绝此使用,或选择“更多信息”以控制cookie首选项。您可以随时通过单击页面底部的Cookie首选项来更新您的选择。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/17769.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Cartesi RISC-V Solidity Emulator – Cartesi-RISC-V固体仿真器区块链毕设代写

提供最优质的资源集合

立即查看 了解详情