当前位置: 首页 > 编程日记 > 正文

ethereumjs/ethereumjs-vm-2-API文档

https://github.com/ethereumjs/ethereumjs-vm/blob/master/docs/index.md

vm.runBlockchain

Processes blocks and adds them to the blockchain

处理区块并将其添加到区块链中

Parameters输入参数

  • blockchain Blockchain A blockchain that to process 一个处理的区块链
  • cb Function the callback function 回调函数

VM

VM Class, new VM(opts) creates a new VM object

VM类,VM(opts)将创建一个VM对象,运行起来实现的感觉与ganache相似

Parameters输入参数

  • opts Object
    • opts.stateManager StateManager a StateManager instance to use as the state store (Beta API) 用于状态存储的StateManager实例(还在实验阶段)其实这个就是区块上的state merkle-patricia树,用于存储区块上的所有账户的信息
    • opts.state Trie a merkle-patricia-tree instance for the state tree (ignored if stateManager is passed) 用于状态树的一个merkle-patricia树(如果上面的stateManager已经传递,这个就可以忽略)
    • opts.blockchain Blockchain a blockchain object for storing/retrieving blocks (ignored if stateManager is passed) 为了存储/检索区块的区块链对象(如果上面的stateManager已经传递,这个就可以忽略
    • opts.chain (String | Number) the chain the VM operates on [default: 'mainnet']  VM操作在那个链上(默认是mainnet链)
    • opts.hardfork String hardfork rules to be used [default: 'byzantium', supported: 'byzantium',  'constantinople' (will throw on unsupported)]    使用的硬分支规则(默认是byzantium',还支持'byzantium',  'constantinople',如果输入的是不支持的将抛出错误)  
    • opts.activatePrecompiles Boolean create entries in the state tree for the precompiled contracts 为了预编译合约在状态树上创建条目,其实就是在state merkle-patricia树上手动添加一些账户的信息,就跟ganache一样,一开始就有可用的账户
    • opts.allowUnlimitedContractSize Boolean allows unlimited contract sizes while debugging. By setting this to true, the check for contract size limit of 24KB (see EIP-170) is bypassed. (default: false; ONLY set to true during debugging) 当调试时,允许不限制的合约大小。通过将其设置为true,来忽视合约大小设置为24KB的检查(细节看本博客ethereum/EIPs-170 Contract code size limit)。(默认为false,只在调试时设置为true)
    • opts.emitFreeLogs Boolean Changes the behavior of the LOG opcode, the gas cost of the opcode becomes zero and calling it using STATICCALL won't throw. (default: false; ONLY set to true during debugging) 改变日志操作吗的行为,gas开销的操作码变为0,使用STATICCALL操作码调用它将抛出错误(默认为false,只有在调试时设置为true)

vm.runBlock

Processes the block running all of the transactions it contains and updating the miner's account

处理区块,运行其中的所有交易并更新矿工账户

Parameters输入参数

  • opts
    • opts.block Block the Block to process 处理的区块
    • opts.generate Boolean [gen=false] whether to generate the stateRoot, if false runBlock will check the stateRoot of the block against the Trie 是否生成stateRoot,如果设置为false,runBlock将会靠着前缀树来查看区块的stateRoot
  • cb runBlock~callback callback 回调函数

runBlock~callback

Callback for runBlock method

runBlock的回调

Type: Function

Parameters输入参数

  • error Error an error that may have happened or null  发生的错误或null
  • results Object
    • results.receipts Array the receipts from the transactions in the block 区块中来自交易的receipt
    • results.results Array 返回结果

vm.runTx

Process a transaction. Run the vm. Transfers eth. Checks balances.

处理交易。运行虚拟机。交易eth。查看余额。

Parameters输入参数

  • opts
    • opts.tx Transaction a Transaction to run 运行的交易
    • opts.skipNonce Boolean skips the nonce check  跳过nonce检查
    • opts.skipBalance Boolean skips the balance check  跳过余额检查
    • opts.block Block the block to which the tx belongs, if no block is given a default one is created  交易属于的区块,如果没有,则创建一个默认块
  • cb runTx~callback the callback 回调函数

runTx~callback

Callback for runTx method

runTx方法的回调

Type: Function

Parameters输入参数

  • error Error an error that may have happened or null  发生的错误或null
  • results Object
    • results.amountSpent BN the amount of ether used by this transaction as a bignum  被这个交易使用的ether的数量,BN格式
    • results.gasUsed BN the amount of gas as a bignum used by the transaction  被这个交易使用的gas,BN格式
    • results.gasRefund BN the amount of gas as a bignum that was refunded during the transaction (i.e. gasUsed = totalGasConsumed - gasRefund)  在交易中被退还的gas,BN格式(使用的gas = 总使用的gas - 退还的gas)
  • vm VM contains the results from running the code, if any, as described in vm.runCode(params, cb)  虚拟机,如果存在,包含通过运行代码得到的结果,就像vm.runCode(params, cb)所说

vm.runCode

Runs EVM code

运行以太坊虚拟机代码

Parameters输入参数

  • opts Object
    • opts.account Account the Account that the executing code belongs to. If omitted an empty account will be used 执行的代码属于的账户。如果省略则使用空账户
    • opts.address Buffer the address of the account that is executing this code. The address should be a Buffer of bytes. Defaults to 0 执行这个代码的账户的地址。地址应该是字节的buffer格式。默认为0
    • opts.block Block the Block the tx belongs to. If omitted a blank block will be used 这个交易属于的区块。如果省略则使用一个黑块
    • opts.caller Buffer the address that ran this code. The address should be a Buffer of 20bits. Defaults to 0 运行这个代码的地址。这个地址应该为20bits的buffer格式,默认为0
    • opts.code Buffer the EVM code to run given as a Buffer 以buffer格式给出的用来运行的以太坊虚拟机的代码
    • opts.data Buffer the input data 输入的数据
    • opts.gasLimit Buffer the gas limit for the code 这个代码使用的gas的限制
    • opts.origin Buffer the address where the call originated from. The address should be a Buffer of 20bits. Defaults to 0 这个调用起源的地址。这个地址应该为20bits的buffer格式,默认为0
    • opts.value Buffer the value in ether that is being sent to opt.address. Defaults to 0 被送给opt.address的ether。默认为0
  • cb runCode~callback callback 回调函数

runCode~callback

Callback for runCode method

runCode方法的回调

Type: Function

Parameters输入参数

  • error Error an error that may have happened or null  发生的错误或null
  • results Object
    • results.gas BN the amount of gas left 剩下的gas数量
    • results.gasUsed BN the amount of gas as a bignum the code used to run  以bignum格式给出的这个代码用来运行的gas数量
    • results.gasRefund BN a bignum containing the amount of gas to refund from deleting storage values从删除的存储值中得到包含退还的gas的数量的大数
    • results.selfdestruct Object an Object with keys for accounts that have selfdestructed and values for balance transfer recipient accounts 包含自我毁灭的账户密钥和转移接收账户余额的值的对象
    • results.logs Array an Array of logs that the contract emitted 合约发出的日志数组
    • results.exception Number 0 if the contract encountered an exception, 1 otherwise 如果合约遇到了异常则为0,否则为1
    • results.exceptionError String a String describing the exception if there was one 如果有异常则用来描述异常的字符串
    • results.return Buffer a Buffer containing the value that was returned by the contract 包含被合约返回的值的buffer

Event: beforeBlock

The beforeBlock event  beforeBlock事件

Type: Object

Properties属性

  • block Block emits the block that is about to be processed 发出关于将要被处理的区块

Event: afterBlock

The afterBlock event afterBlock事件

Type: Object

Properties属性

  • result Object emits the results of processing a block 发出处理的区块的结果

Event: beforeTx

The beforeTx event

Type: Object

Properties

  • tx Transaction emits the Transaction that is about to be processed 发出将要被处理的交易

Event: afterTx

The afterTx event

Type: Object

Properties

  • result Object result of the transaction 交易的结果

Event: step

The step event for trace output追踪输出的step事件

Type: Object

Properties

  • pc Number representing the program counter  代表项目的计数
  • opcode String the next opcode to be ran  下一个运行的操作码
  • gasLeft BN amount of gasLeft  剩下的gas数量
  • stack Array an Array of Buffers containing the stack  包含堆栈的Buffers数组
  • account Account the Account which owns the code running  拥有运行代码的账户
  • address Buffer the address of the account  账户的地址
  • depth Number the current number of calls deep the contract is   合约所在的目前的调用深度数
  • memory Buffer the memory of the VM as a buffer 虚拟机的内存
  • stateManager StateManager a StateManager instance (Beta API)  一个StateManager实例

转载于:https://www.cnblogs.com/wanghui-garcia/p/10082906.html

相关文章:

qt 拖拽 修改大小(二)

最近项目需要实现windows下橡皮筋的效果,所以对此做了一些了解,特此记录。 首先windows系统是支持橡皮筋效果的,需要使用win32方 法:SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, showFullWindow, NULL, 0);showFullWindow是一个…

互联网大厂技术面试内幕@霞落满天

很多求职者往往并非因为技术不好,而是没有掌握面试的技巧导致不能把握机会,本课程的目的就是本课程先通过比较真实的好简历和不好的简历让大家明白自己的简历有哪些问题,事实上简历是大厂的敲门砖,非常重要,很多人得不…

【数据结构】顺序表的应用(1)(C语言)

问题: 1.将顺序表(a1,a2,…,an)重新排列以a1为界的两部分:a1前面的值均比a1小,a1后面的值均比a1大(这里假设数据元素的类型具有可比性,不妨设为整型)。 头文件与该头文件一样:【数据结构】顺序…

比特币寒冬中,你更应该关注企业区块链!

公众对区块链的认识也许限于比特币或以太坊,但很多却不知道 Hyperledger(超级账本)。Hyperledger Fabric,是由 IBM 带头发起的一个联盟链项目,2015 年末移交给 Linux 基金会,成为开源项目。Linux 基金会孵化…

JVM XMX设置多大比较好,Docke容器里该怎么设置JVM呢@无界编程

XMX是JVM的最大堆内存大小,XMS是JVM的初始堆内存大小。 不管是工作还是面试经常遇到一个问题就是XMX到底设置多大比较好? 网上的答案大多是说XMX和XMS设置为一样大,但是没有说到底XMX设置多大比较好。 如果设置为和操作系统一样大内存会怎么样? 这篇文章就带你搞清楚这…

【数据结构】顺序表的应用(2)(C语言)

问题: 2.有顺序表A和B,其元素均按从小到大的升序排列,编写一个算法,将它们合并成一个顺序表C,要求C的元素也按从小到大的升序排列。 头文件与该头文件一样:【数据结构】顺序表的实现(C语言&am…

OWA登录页面显示为英文而不是中文

-----提供AD\Exchange\Lync\Sharepoint\CRM\SC\O365等微软产品实施及外包,QQ:185426445.电话18666943750故障描述:WIN10操作系统使用IE登录OWA的时候,界面语言为英文,WIN10操作系统为中文系统,区域语言都是设置为中文&…

java B2B2C springmvc mybatis多租户电子商城系统-Spring Cloud Feign

1、什么是Feign? 愿意了解源码的朋友直接企鹅求求:二一四七七七五六三三 Feign 的英文表意为“假装,伪装,变形”, 是一个http请求调用的轻量级框架,可以以Java接口注解的方式调用Http请求,而不用…

【数据结构】顺序表的应用(3)(C语言)

问题: 已知一个顺序表中的各节点值是从大到小有序的,设计一个算法,插入一个值为x的节点,使顺序表中的节点仍然是从小到大有序的。 头文件与该头文件一样:【数据结构】顺序表的实现(C语言) #i…

从源码和内核角度分析redis和nginx以及java NIO可以支持多大的并发

有人询问我网上一篇关于“redis为什么单线程这么快”的文章,我建议他不要看了,因为redis是单进程不是单线程,后面的意见不用看了,文章质量肯定不会很好,他也说了自己看了很久源码似乎还是有些云里雾里,所以我就给他分析了为什么redis这么快,这篇主要讲epoll的实现。 从…

背景图片等比缩放的写法background-size简写法

1、背景图片或图标也可像img一样给其宽高就能指定其缩放大小了。 比如一个实际宽高36*28的图标,要缩小一半引用进来的写法就是: background:rgba(0, 0, 0, 0) url("../images/report_icon2x.png") no-repeat scroll left center / 18px 14px; …

深入了解以太坊

正在看这篇文章的你,应该是一名被区块链技术所吸引的开发者或者极客。我相信你已经理解了区块链的技术原理,并急切地想要搞清楚这项技术将为你和你的开发技术栈带来怎样的影响。 如果你需要更基础的区块链技术介绍,可以阅读比特币和以太坊的白…

Netty和JDK源码来看Netty的NIO和JDK的NIO有什么不同

JDK底层提供了NIO实现,在Linux环境会调用内核epoll。 但是Netty通过JNI的方式提供了Native Socket Transport,为什么Netty要自己搞一套NIO呢? 这篇文章带你从jdk的源码和Netty的源码角度来分析为什么Netty要这么做。 JDK源码:openjdk-8u40 Netty源码:netty-4.1 1.先看J…

【数据结构】单链表的实现(C语言)

单链表是线性表链式储存的一种形式,其中的结点一般含有两个域,一个是存放数据信息的info域,另一个是指向该结点后继结点存放地址的指针next域。一个单链表必须要有一个首指针指向链表中的第一个结点。 单链表要掌握以下几种操作:…

《理解 OpenStack + Ceph》---来自-[爱.知识]-推荐

企业IT技术分享(2016-06-29)来自(QQ群:企业私有云平台实战 454544014-推荐)!理解 OpenStack Ceph (1):Ceph OpenStack 集群部署和配置http://www.cnblogs.com/sammyliu…

windows10 安装 mysql8.0.12 详解

【1】下载安装包 官网下载地址:https://downloads.mysql.com/archives/community/ 如下图所示: 下载完成,安装包为mysql-8.0.12-winx64.zip 【2】安装准备 (1)安装路径。拷贝安装包到任意路径,然后解压缩。…

IDEA常用和实用配置以及各种必要插件

主要是收集IDEA常用和不常用配置陆续更新 ------------------------ 启动项目配置 建议使用idea2021.1.3以上版本: ------------------------ maven没有设置自动导包,导致引用不到第三方依赖。 可以点maven的刷新按钮即可。 idea 设置gradle自动更…

linux 调试利器gdb, strace, pstack, pstree, lsof

1)如何使用stracepstack利器分析程序性能?http://www.cnblogs.com/bangerlee/archive/2012/04/30/2476190.html此文有详细介绍怎么用strace和pstack2)Linux下多线程查看工具(pstree、ps、pstack)?http://blog.csdn.net/yfkiss/article/details/67293643)使用strace,lstrace,t…

【数据结构】单链表的应用(C语言)

1、设计一个算法,求一个单链表中的节点数 2、设计一个算法,在一个单链表中值为y的结点前插入一个值为x的结点(值为x的新结点为成为值为y的结点前驱结点) 3、设计一个算法,判断单链表中各结点是否有序 4、设计一个算…

物联网设备僵尸网络趋势分析

物联网(IoT)僵尸网络作者正在适应更安全的物联网设备的转变,这已经将***者的注意力转移到利用物联网设备的漏洞上。由于物联网设备安全性仍处于起步阶段,因此发现命令注入等基本漏洞并不少见。2018年11月,NetScout的As…

Redis6安装配置集群cluster以及集群宕机注意事项

Redis6的cluster模型推荐3主3从 先准备3台服务器,每个上面部署2个redis,服务器配置2核2G: 下面在每台服务器安装redis6,每台机器只要安装一次即可,然后分别配置2个端口的conf文件,分别起来即可&#xff1a…

【数据结构】循环单链表的实现(C语言)

循环单链表应掌握以下基本操作: 1、建立一个空的循环单链表。 2、获得循环单链表的最后一个结点的位置。 3、输出循环单链表中各结点的值。 4、在循环单链表中查找值为x的结点。 5、在循环单链表中第i个结点后插入值为x的新结点。 6、在循环单链表中删除值为x…

DTRACE 专家

http://dtrace.org/blogs/bmc/ https://github.com/bcantrill http://www.tudou.com/programs/view/Q6fHZFgZww4 http://dtrace.org/blogs/ahl/2012/04/24/btrace-dtrace-for-java-ish/ JAVA https://github.com/chrisa https://github.com/ahrens

统一客服消息返回错误:{errcode:43004,errmsg:require subscribe hint: [9Vv08633952]}

2019独角兽企业重金招聘Python工程师标准>>> 公众号或者小程序发送客服消息错误: {"errcode":43004,"errmsg":"require subscribe hint: [9Vv08633952]"} 场景:小程序使用公众号的服务消息,推送消息…

sublime Text 开发工具

简介描述 Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。,具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text …

【数据结构】双链表的实现(C语言)

双链表中的结点包括3个域,一个是存放数据信息的info域,另两个是指阵域,这里用llink和rlink表示,llink指向它的前驱结点,rlink指向它的后继结点。 双链表要掌握以下基本操作: 1、创建一个空的双链表。 2、…

ShardingSphere-Proxy分库分表以及多租户安装使用

需求:你提供SAAS服务,你有你有2个租户(商户),各自的数据进各自的库,而你不希望你的微服务java里默认配置多个租户数据源,数据连接池太多,而且后面动态增加也不方便,诸如此类很多问题。 方案&am…

jenkins自动化部署工具

jenkins自动化测试 & 持续集成 知识点: 1。下载地址:jenkins.io download: 转载于:https://www.cnblogs.com/kaixinyufeng/p/10123419.html

android 图片水印处理 文字倾斜处理

方法一: 获取一个textview 从textview中获取bitmap,将bitmap 通过matrix进行角度变换,然后将原图和此bitmap合并; 方法二: 将原图获取bitmap后,得到canvas,将canvas进行角度变换,…

Centos下MySQL安装与配置

一、mysql简介说到数据库,我们大多想到的是关系型数据库,比如mysql、oracle、sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱不得不首先推荐的是mysql数据库了,而…