
EVM結(jié)構(gòu).png
對(duì)于EVM虛擬機(jī),覺(jué)得可以從兩方面進(jìn)行抽象,實(shí)現(xiàn)拓展;
-
VM層進(jìn)行抽象,從根本上來(lái)說(shuō),EVM只對(duì)外暴漏了兩個(gè)方法調(diào)用
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) }