ethereum/EIPs-170 Contract code size limit
| eip | title | author | type | category | status | created | 
|---|---|---|---|---|---|---|
| 
 170 
 | 
 Contract code size limit 
 | 
 Vitalik Buterin 
 | 
 Standards Track 
 | 
 Core 
 | 
 Final 
 | 
 2016-11-04 
 | 
Hard fork
Parameters
FORK_BLKNUM: 2,675,000CHAIN_ID: 1 (main net)
Specification
If block.number >= FORK_BLKNUM, then if contract creation initialization returns data with length of more than 0x6000(2**14 + 2**13) bytes, contract creation fails with an out of gas error.
如果合约的数据大小大于0x6000,那么该合约的创建将会失败
Rationale
Currently, there remains one slight quadratic vulnerability in Ethereum: when a contract is called, even though the call takes a constant amount of gas, the call can trigger O(n) cost in terms of reading the code from disk, preprocessing the code for VM execution, and also adding O(n) data to the Merkle proof for the block's proof-of-validity. At current gas levels, this is acceptable even if suboptimal. At the higher gas levels that could be triggered in the future, possibly very soon due to dynamic gas limit rules, this would become a greater concern—not nearly as serious as recent denial of service attacks, but still inconvenient especially for future light clients verifying proofs of validity or invalidity. The solution is to put a hard cap on the size of an object that can be saved to the blockchain, and do so non-disruptively by setting the cap at a value slightly higher than what is feasible with current gas limits.
目前ethereum仍有一个脆弱点:当一个合约被调用时,即使它使用的是固定的gas值,这个调用仍然会触发O(n)量级的花销在从硬盘中读取代码、对VM执行的代码进行预处理和将O(n)数据添加到Merkle证明中以验证块的有效性上。在目前的gas水平下,这是可以接受的,即使不是最理想的。但是在未来可能被触发的较高的gas水平的情况下,可能很快由于动态气体限制规则而其将成为一个更大的担忧——可能不像最近的拒绝服务攻击那么严重,但仍然不方便,特别是对未来的轻客户端验证有效性或无效的证明。
解决方案是对一个对象的大小设置一个硬盘的上限(在这里既为合约的数据大小不大于0x6000),该上限可以保存到区块链,并通过将上限设置在略高于当前气体限制的可行值的情况下进行非干扰性设置。
References
- EIP-170 issue and discussion: https://github.com/ethereum/EIPs/issues/170
 - pyethereum implementation: https://github.com/ethereum/pyethereum/blob/5217294871283d8dc4fb3ca9d8a78c7d416490e8/ethereum/messages.py#L397
 
该代码实现:
- EIP 170: Contract code size limit - changes the maximum code size that a contract on the blockchain can have. This update prevents an attack scenario where large pieces of account code can be accessed repeatedly at a fixed gas cost. The maximum size has been set to 24576 bytes, which is larger than any currently deployed contract.改变区块链中能够有的最大代码大小.盖更新将防止在设定好的gas开销中,大片账户代码被重复接收的攻击方案,最大的大小设置为字节,这比目前所有被设置的合约都大
 
def create_contract(ext, msg):
log_msg.debug('CONTRACT CREATION') code = msg.data.extract_all() if ext.tx_origin != msg.sender:
ext.increment_nonce(msg.sender) if ext.post_metropolis_hardfork() and msg.sender == null_address:
msg.to = utils.mk_contract_address(msg.sender, )
# msg.to = sha3(msg.sender + code)[:]
else:
nonce = utils.encode_int(ext.get_nonce(msg.sender) - )
msg.to = utils.mk_contract_address(msg.sender, nonce) b = ext.get_balance(msg.to)
if b > :
ext.set_balance(msg.to, b)
ext.set_nonce(msg.to, )
ext.set_code(msg.to, b'')
# ext.reset_storage(msg.to) msg.is_create = True
# assert not ext.get_code(msg.to)
msg.data = vm.CallData([], , )
snapshot = ext.snapshot()
if len(ext.get_code(msg.to)):
log_msg.debug('CREATING CONTRACT ON TOP OF EXISTING CONTRACT')
# return , , b'' ext.set_nonce(msg.to, if ext.post_spurious_dragon_hardfork() else )//
res, gas, dat = _apply_msg(ext, msg, code) log_msg.debug('CONTRACT CREATION FINISHED', res=res, gas=gas, dat=dat if len(dat) < else ("data<%d>" % len(dat))) if res:
if not len(dat):
# ext.set_code(msg.to, b'')
return , gas, msg.to
gcost = len(dat) * opcodes.GCONTRACTBYTE
if gas >= gcost and (len(dat) <= or not ext.post_anti_dos_hardfork())://合约创建钱判断gas的使用,合约的大小等
gas -= gcost
else://否则创建失败
dat = []
log_msg.debug('CONTRACT CREATION FAILED', have=gas, want=gcost, block_number=ext.block_number)
if ext.post_homestead_hardfork():
ext.revert(snapshot)
return , , b''
ext.set_code(msg.to, bytearray_to_bytestr(dat))
log_msg.debug('SETTING CODE', addr=encode_hex(msg.to), lendat=len(dat))
return , gas, msg.to
else:
ext.revert(snapshot)
return , gas, dat
ethereum/EIPs-170 Contract code size limit的更多相关文章
- *** FATAL ERROR L250: CODE SIZE LIMIT IN RESTRICTED VERSION EXCEEDED
		
*** FATAL ERROR L250: CODE SIZE LIMIT IN RESTRICTED VERSION EXCEEDED 在软件已经执行破解仍然出现,是因为工程是破解前建立的,要先执行 ...
 - EVALUation mode running with code size limit:2k keil进行仿真过程中出现的报错
		
EVALUation mode running with code size limit:2k 如果keil软件未破解,会限制程序的存储大小.第一是你的软件没有破解,不能编译2K以上的程序:这种情况下 ...
 - ethereum/EIPs-1271 smart contract
		
https://github.com/PhABC/EIPs/blob/is-valid-signature/EIPS/eip-1271.md Standard Signature Validation ...
 - [转]預防 Android Dex 64k Method Size Limit
		
转载自:http://ingramchen.io/blog/2014/09/prevention-of-android-dex-64k-method-size-limit.html 08 Septem ...
 - ORA-27092: size of file exceeds file size limit of the process
		
停数据库时遇到下述问题: $ ./addbctl.sh stop You are running addbctl.sh version 120.1 Shutting down database UAT ...
 - [Mon Feb 10 15:21:06 2014] [notice] child pid 7101 exit signal File size limit exceeded (25)
		
今天遇到的问题: LAMP的LOG里报如下错误. 然后IE和FIREFOX里显示连接被重置或是无法访问. 但自己建一个正常的PHP测试探针倒可以. 原来是PHP错误日志太多,无法写入LOG导致. [r ...
 - Github 修正上传时“this exceeds GitHub’s file size limit of 100 MB”错误
		
自己的项目的版本控制用的是Git,代码仓库在github托管.项目里用到了IJKMediaFramework 想把代码push到github上,结果出错了,被拒绝,具体信息是: Total 324 ( ...
 - ES部署报错 max file size 和 kibana 报错File size limit exceeded
		
启动失败一 ERROR: [2] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process ...
 - git this exceeds GitHub's file size limit of 100.00 MB
		
git push origin master过程中,出现如下错误 关键词:this exceeds GitHub's file size limit of 100.00 MB 推的时候忽略文件的操作: ...
 
随机推荐
- [Redis]Redis的数据类型
			
存储String字符串,使用get,set命令,一个键最大存储512M 存储Hash哈希,使用HMSET和HGETALL命令,参数:键,值 例如:HMSET user:1 username taosh ...
 - Mac下,(OS系统)IDEA 逆向工程,生成 hibernate 映射文件以及对应的javaBean(类似于eclipse)
			
找了好久,逆向工程生成javabean的,在Macbook的OS系统下使用idea生成. 参考博客:http://m.blog.csdn.net/quan20111992/article/detail ...
 - Jquery/js引入的button的onclik事件只触发一次
			
目标描述 我要实现的是:通过监听button的click事件,从而通过ajax向servlet发送请求获取数据库中的数据,然后返回的页面,并要求局部刷新 一次页面的加载是html直接页面初始化本身的 ...
 - 原生css 中变量的使用
			
前两天看到阮大神的一篇在css中使用变量的文章,整理了一下. 这个重要的 CSS 新功能,所有主要浏览器已经都支持了.本文全面介绍如何使用它,你会发现原生 CSS 从此变得异常强大. 一.变量的声明 ...
 - 【代码笔记】iOS-UIAlertView3秒后消失
			
一,效果图. 二,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the ...
 - 【查找数字x第k为上的数字】
			
#include<stdio.h> #include<math.h> // 求x用10进制表示时的数位长度 int len(int x){ ) ; )+; } // 取x的第k ...
 - AutoCAD.net-错误消息大全
			
case Acad::eOk:lstrcpy(Glb_AcadErrorInfo,_T("正确"));break;case Acad::eNotImplementedYet:lst ...
 - Hive分组取Top N
			
Hive在0.11.0版本开始加入了row_number.rank.dense_rank分析函数,可以查询分组排序后的top值 说明: row_number() over ([partition ...
 - VirtualBox安装Mac OS 10.11——虚拟机安装黑苹果
			
由于需要安装mac环境跑IOS应用,所以在虚拟机装个黑苹果. 一.下载虚拟机安装包,VirtualBox是官网下的最新版: 5.0.6 for Windows hosts x86/amd64 官网 ...
 - org.postgresql.util.PSQLException: 栏位索引超过许可范围:3,栏位数:2。
			
org.postgresql.util.PSQLException: 栏位索引超过许可范围:3,栏位数:2. 今天在写完SQL进行查询的时候,后台一直报错显示上面的信息.看错误完全不知道原因,就重新检 ...