-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package vm | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ava-labs/subnet-evm/params" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
var defaultEVMFactory EvmFactory = &evmFactory{} | ||
|
||
type evmFactory struct{} | ||
|
||
type ChainConfig interface { | ||
IsEIP158(blockNum *big.Int) bool | ||
IsSubnetEVM(timestamp uint64) bool | ||
IsCancun(blockNum *big.Int, timestamp uint64) bool | ||
IsPrecompileEnabled(addr common.Address, timestamp uint64) bool | ||
Rules(blockNum *big.Int, timestamp uint64) params.Rules | ||
} | ||
|
||
type EvmFactory interface { | ||
NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig ChainConfig, config Config) *EVM | ||
} | ||
|
||
func DefaultEVMFactory() EvmFactory { | ||
return defaultEVMFactory | ||
} | ||
|
||
func SetDefaultEVMFactory(factory EvmFactory) { | ||
defaultEVMFactory = factory | ||
} | ||
|
||
func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig ChainConfig, config Config) *EVM { | ||
return DefaultEVMFactory().NewEVM(blockCtx, txCtx, statedb, chainConfig, config) | ||
} |