EVM結構.png
對于EVM虛擬機里逆,覺得可以從兩方面進行抽象械念,實現(xiàn)拓展;
-
VM層進行抽象运悲,從根本上來說,EVM只對外暴漏了兩個方法調(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) }