对于EVM虚拟机,觉得可以从两方面进行抽象,实现拓展;
-
VM层进行抽象,从根本上来说,EVM只对外暴漏了两个方法调用
Call
、Create
.type VM interface{ Create(caller types.ContractRef, code []byte, gas uint64, val sdk.Int) (ret []byte, contractAddr sdk.AccAddress, gasLeft uint64, err error) Call(caller types.ContractRef, toAddr sdk.AccAddress, input []byte, gas uint64, val sdk.Int) (ret []byte, gasLeft uint64, err error) }
-
解释器层抽象,解释器的功能比较单纯,给定合约和输入,得到输出。
type Interpreter interface { Run(contract *Contract, input []byte, static bool) ([]byte, error) }
网友评论