Documentation ¶
Index ¶
- Constants
- Variables
- func Create(evm EVMEnvironment, caller common.Address, code []byte, gas uint64, ...) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
- func Create2(evm EVMEnvironment, caller common.Address, code []byte, gas uint64, ...) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error)
- func DelegateCiphertextHandlesInArgs(env EVMEnvironment, args []byte) (verified map[common.Hash]*depthSet)
- func FheLibRequiredGas(environment EVMEnvironment, input []byte) uint64
- func FheLibRun(environment EVMEnvironment, caller common.Address, addr common.Address, ...) (ret []byte, err error)
- func GetTypeOfPersistedCiphertext(env EVMEnvironment, contractAddress common.Address, handle common.Hash) *tfhe.FheUintType
- func GetTypeOfVerifiedCiphertext(env EVMEnvironment, ciphertextHash common.Hash) *tfhe.FheUintType
- func InitFhevm(accessibleState EVMEnvironment)
- func OpReturn(pc *uint64, env EVMEnvironment, scope ScopeContext) []byte
- func OpSelfdestruct(pc *uint64, env EVMEnvironment, scope ScopeContext) (beneficiary uint256.Int, balance *big.Int)
- func OpSload(pc *uint64, env EVMEnvironment, scope ScopeContext) ([]byte, error)
- func OpSstore(pc *uint64, env EVMEnvironment, scope ScopeContext) ([]byte, error)
- func RegisterErrors(outOfGasError error, codeStoreOutOfGasError error, depthError error, ...)
- func RemoveVerifiedCipherextsAtCurrentDepth(env EVMEnvironment)
- func RestoreVerifiedDepths(env EVMEnvironment, verified map[common.Hash]*depthSet)
- func SetProtectedStorageAddrCallerAddr(addr []byte)
- func TxDataFractionalGas(originalGas uint64) (fractionalGas uint64)
- type Contract
- type DefaultLogger
- type EVMEnvironment
- type FheLibMethod
- func (fheLibMethod *FheLibMethod) Name() string
- func (fheLibMethod *FheLibMethod) RequiredGas(environment EVMEnvironment, input []byte) uint64
- func (fheLibMethod *FheLibMethod) Run(environment EVMEnvironment, caller common.Address, addr common.Address, ...) ([]byte, error)
- func (fheLibMethod *FheLibMethod) Signature() uint32
- type FhevmData
- type FhevmParams
- type GasCosts
- type Logger
- type Memory
- type ScopeContext
- type Stack
Constants ¶
const AdjustFHEGas uint64 = 10000
const ColdSloadCostEIP2929 uint64 = 2100
const EvmNetSstoreInitGas uint64 = 20000
Base gas costs of existing EVM operations. Used for setting gas costs relative to them. These constants are used just for readability.
const GetNonExistentCiphertextGas uint64 = 1000
const SloadFheUint4Gas = ColdSloadCostEIP2929 + 100
const SstoreFheUint4Gas = EvmNetSstoreInitGas + 1000
Base costs of fhEVM SSTORE and SLOAD operations. TODO: We don't take whether the slot is cold or warm into consideration.
Variables ¶
var ( ErrOutOfGas error ErrCodeStoreOutOfGas error ErrDepth error ErrInsufficientBalance error ErrContractAddressCollision error ErrExecutionReverted error ErrMaxInitCodeSizeExceeded error ErrMaxCodeSizeExceeded error ErrInvalidJump error ErrWriteProtection error ErrReturnDataOutOfBounds error ErrGasUintOverflow error ErrInvalidCode error ErrNonceUintOverflow error ErrAddrProhibited error ErrInvalidCoinbase error ErrSenderAddressNotAllowListed error )
List of EVM execution errors needed by the fhEVM
var TxDataFractionalGasFactor uint64 = 4
Functions ¶
func DelegateCiphertextHandlesInArgs ¶
func DelegateCiphertextHandlesInArgs(env EVMEnvironment, args []byte) (verified map[common.Hash]*depthSet)
If there are ciphertext handles in the arguments to a call, delegate them to the callee. Return a map from ciphertext hash -> depthSet before delegation.
func FheLibRequiredGas ¶
func FheLibRequiredGas(environment EVMEnvironment, input []byte) uint64
func GetTypeOfPersistedCiphertext ¶ added in v0.2.1
func GetTypeOfPersistedCiphertext(env EVMEnvironment, contractAddress common.Address, handle common.Hash) *tfhe.FheUintType
Returns the type of the persisted ciphertext for `handle` in protected storage or nil if `handle`doesn't point to a persisted ciphertext.
func GetTypeOfVerifiedCiphertext ¶ added in v0.2.1
func GetTypeOfVerifiedCiphertext(env EVMEnvironment, ciphertextHash common.Hash) *tfhe.FheUintType
Returns the type of the verified ciphertext for `ciphertextHash` or nil if it doesn't exist or not verified at current depth.
func InitFhevm ¶
func InitFhevm(accessibleState EVMEnvironment)
func OpReturn ¶
func OpReturn(pc *uint64, env EVMEnvironment, scope ScopeContext) []byte
func OpSelfdestruct ¶
func OpSelfdestruct(pc *uint64, env EVMEnvironment, scope ScopeContext) (beneficiary uint256.Int, balance *big.Int)
func OpSload ¶
func OpSload(pc *uint64, env EVMEnvironment, scope ScopeContext) ([]byte, error)
This function is a modified copy from https://github.com/ethereum/go-ethereum
func OpSstore ¶
func OpSstore(pc *uint64, env EVMEnvironment, scope ScopeContext) ([]byte, error)
func RegisterErrors ¶
func RegisterErrors( outOfGasError error, codeStoreOutOfGasError error, depthError error, insufficientBalanceError error, contractAddressCollisionError error, executionRevertedError error, maxInitCodeSizeExceededError error, maxCodeSizeExceededError error, invalidJumpError error, writeProtectionError error, returnDataOutOfBoundsError error, gasUintOverflowError error, invalidCodeError error, nonceUintOverflowError error, addrProhibitedError error, invalidCoinbaseError error, senderAddressNotAllowListedError error)
Register package errors with other custom errors.
This is useful in cases where returned errors need to be recognized by the framework using fhevm-go, without much code changes in the framework.
func RemoveVerifiedCipherextsAtCurrentDepth ¶
func RemoveVerifiedCipherextsAtCurrentDepth(env EVMEnvironment)
func RestoreVerifiedDepths ¶
func RestoreVerifiedDepths(env EVMEnvironment, verified map[common.Hash]*depthSet)
func SetProtectedStorageAddrCallerAddr ¶
func SetProtectedStorageAddrCallerAddr(addr []byte)
Set the addr to be used as caller when creating protected storage contracts
func TxDataFractionalGas ¶
Types ¶
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
A default Logger implementation that logs to stdout.
func (*DefaultLogger) Debug ¶
func (l *DefaultLogger) Debug(msg string, keyvals ...interface{})
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(msg string, keyvals ...interface{})
func (*DefaultLogger) Info ¶
func (l *DefaultLogger) Info(msg string, keyvals ...interface{})
type EVMEnvironment ¶
type EVMEnvironment interface { // StateDB related functions GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) GetNonce(common.Address) uint64 AddBalance(common.Address, *big.Int) GetBalance(common.Address) *big.Int Suicide(common.Address) bool // EVM call stack depth GetDepth() int // EVM Logger GetLogger() Logger // TODO: clarify meaning of the following IsCommitting() bool IsEthCall() bool IsReadOnly() bool CreateContract(caller common.Address, code []byte, gas uint64, value *big.Int, address common.Address) ([]byte, common.Address, uint64, error) CreateContract2(caller common.Address, code []byte, codeHash common.Hash, gas uint64, value *big.Int, address common.Address) ([]byte, common.Address, uint64, error) FhevmData() *FhevmData FhevmParams() *FhevmParams // This should return the context used for OpenTelemetry in the current EVM. // It should be considered the root context for every op that runs in the EVM, and all spans created from this context // would be child spans for what has been already created using the context. // Implementations returning nil would disable OpenTelemetry on the fhEVM OtelContext() context.Context }
type FheLibMethod ¶
type FheLibMethod struct {
// contains filtered or unexported fields
}
A method available in the fhelib precompile that can run and estimate gas
func GetFheLibMethod ¶
func GetFheLibMethod(signature uint32) (fheLibMethod *FheLibMethod, found bool)
func (*FheLibMethod) Name ¶
func (fheLibMethod *FheLibMethod) Name() string
func (*FheLibMethod) RequiredGas ¶
func (fheLibMethod *FheLibMethod) RequiredGas(environment EVMEnvironment, input []byte) uint64
func (*FheLibMethod) Signature ¶
func (fheLibMethod *FheLibMethod) Signature() uint32
Return the computed signature by concatenating the name and the arg types of the method
type FhevmData ¶
type FhevmData struct {
// contains filtered or unexported fields
}
func NewFhevmData ¶
func NewFhevmData() FhevmData
type FhevmParams ¶
func DefaultFhevmParams ¶
func DefaultFhevmParams() FhevmParams
type GasCosts ¶
type GasCosts struct { FheCast uint64 FhePubKey uint64 FheAddSub map[tfhe.FheUintType]uint64 FheDecrypt map[tfhe.FheUintType]uint64 FheBitwiseOp map[tfhe.FheUintType]uint64 FheMul map[tfhe.FheUintType]uint64 FheScalarMul map[tfhe.FheUintType]uint64 FheScalarDiv map[tfhe.FheUintType]uint64 FheScalarRem map[tfhe.FheUintType]uint64 FheShift map[tfhe.FheUintType]uint64 FheScalarShift map[tfhe.FheUintType]uint64 FheEq map[tfhe.FheUintType]uint64 FheArrayEqBigArrayFactor uint64 // TODO: either rename or come up with a better solution FheLe map[tfhe.FheUintType]uint64 FheMinMax map[tfhe.FheUintType]uint64 FheScalarMinMax map[tfhe.FheUintType]uint64 FheNot map[tfhe.FheUintType]uint64 FheNeg map[tfhe.FheUintType]uint64 FheReencrypt map[tfhe.FheUintType]uint64 FheTrivialEncrypt map[tfhe.FheUintType]uint64 FheRand map[tfhe.FheUintType]uint64 FheIfThenElse map[tfhe.FheUintType]uint64 FheVerify map[tfhe.FheUintType]uint64 FheGetCiphertext map[tfhe.FheUintType]uint64 ProtectedStorageSstoreGas map[tfhe.FheUintType]uint64 ProtectedStorageSloadGas map[tfhe.FheUintType]uint64 }
func DefaultGasCosts ¶
func DefaultGasCosts() GasCosts
type Logger ¶
type Logger interface { Debug(msg string, keyvals ...interface{}) Info(msg string, keyvals ...interface{}) Error(msg string, keyvals ...interface{}) }
A Logger interface for the EVM.
func NewDefaultLogger ¶
func NewDefaultLogger() Logger
type ScopeContext ¶
Source Files ¶
- contract.go
- errors.go
- evm.go
- fhelib.go
- instructions.go
- interface.go
- interpreter.go
- memory.go
- operators_arithmetic.go
- operators_arithmetic_gas.go
- operators_bit.go
- operators_bit_gas.go
- operators_comparison.go
- operators_comparison_gas.go
- operators_crypto.go
- operators_crypto_gas.go
- operators_rand.go
- operators_rand_gas.go
- otel.go
- params.go
- precompiles.go
- protected_storage.go
- stack.go