曾用名为call_id,即将重命名为call_text。 call_context用于:告知EVM proof,which is the correct context the memory, storage and stack operations should be applied inside,如:
- 1)During a call, stack和memory context变了,而storage context保持未变。
- 2)During a
call_data_copy
,会根据calling contract 调整the source memory context。 - 3)During a
return_data_copy
,会根据最后返回的call_context调整the source memory context。(This is not tracked inside the call_context but is good to note)
call_context用于track the correct call context that the memory, storage and stack ops are applied to。
2. call_context内容call_context中包含的元素有:
struct CallContext {
msg_sender: EthAddress
gas_available: u256
gas_used_before_this_call: u256
// tells us if this transaction will throw or revert in the future
is_persistant: bool
is_static_call: bool
// a count of the number of storage updates that need to be undone.
revert_todo: u256
// This is the global counter minimum global counter that needs to be reverted.
gc_to_revert_to: u256
call_depth: u256
}
impl Commitable for CallContext {
fn commit(){
return (
msg_sender +
gas_available * r +
gas_used_before_this_call * r**2 +
is_persistant * r**3 +
is_static_call * r**4 +
revert_todo * r**5 +
gc_to_revert_to * r**6 +
call_depth * r**7
)
}
}
即call_context为a random linear combination of:
- 1)msg.sender
- 2)gas_available
- 3)gas_used_before_this_call
- 4)is_persistant:为binary flag,用于标记该交易未来是否将revert或throw。
- 5)is_static_call
- 6)revert_todo:为计数器,表示undone对应所需的storage updates数。
- 7)gc_to_revert_to:为revert所需的最小global counter。
- 8)call_depth
其中 r = h a s h ( m s g . s e n d e r . . . c a l l _ d e p t h ) r=hash(msg.sender...call\_depth) r=hash(msg.sender...call_depth),相应的call_context commitment值表示为: C o m ( c a l l _ c o n t e x t ) = m s g . s e n d e r + g a s _ a v a i l a b l e ∗ r . . . + c a l l _ d e p t h ∗ r 7 Com(call\_context)=msg.sender+gas\_available * r ...+ call\_depth*r^7 Com(call_context)=msg.sender+gas_available∗r...+call_depth∗r7
3. 其它相关条款 3.1 Reverts/throws若Reverts/throws,需做如下动作:
- 1)Find how far back we need to revert:
- 2)revert all storage operations until that point
- 3)若为
REVERT
op,其为一种特殊的错误场景,除以上2个动作外,还需额外refund left gas。而其它错误场景会consume all left gas。
当is_persist = 1
时,正常进行storage updates操作即可。 当is_persist = 0
时,进行storage updates操作时,需做好revert every storage we do的准备。需要对每次storage update进行计数。我们根据职能合约中的定义执行所有storage updates。当遇到revert操作时,需undo all these updates。
通常会强制Prover展示在gc
和gc_to_revert_to
之间发生的todo_revert
storage writes。 为了简化,在storage write bus mapping中会包含 写入前的值 和 写入后的值。当revert时,当gc
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?