core, core/vm: implemented a generic environment (#3348)
Environment is now a struct (not an interface). This reduces a lot of tech-debt throughout the codebase where a virtual machine environment had to be implemented in order to test or run it. The new environment is suitable to be used en the json tests, core consensus and light client.
This commit is contained in:
		
				
					committed by
					
						 Felix Lange
						Felix Lange
					
				
			
			
				
	
			
			
			
						parent
						
							7f79d249a6
						
					
				
				
					commit
					3fc7c97827
				
			| @@ -106,12 +106,14 @@ func (b *EthApiBackend) GetTd(blockHash common.Hash) *big.Int { | ||||
| 	return b.eth.blockchain.GetTdByHash(blockHash) | ||||
| } | ||||
|  | ||||
| func (b *EthApiBackend) GetVMEnv(ctx context.Context, msg core.Message, state ethapi.State, header *types.Header) (vm.Environment, func() error, error) { | ||||
| func (b *EthApiBackend) GetVMEnv(ctx context.Context, msg core.Message, state ethapi.State, header *types.Header) (*vm.Environment, func() error, error) { | ||||
| 	statedb := state.(EthApiState).state | ||||
| 	from := statedb.GetOrNewStateObject(msg.From()) | ||||
| 	from.SetBalance(common.MaxBig) | ||||
| 	vmError := func() error { return nil } | ||||
| 	return core.NewEnv(statedb, b.eth.chainConfig, b.eth.blockchain, msg, header, vm.Config{}), vmError, nil | ||||
|  | ||||
| 	context := core.NewEVMContext(msg, header, b.eth.BlockChain()) | ||||
| 	return vm.NewEnvironment(context, statedb, b.eth.chainConfig, vm.Config{}), vmError, nil | ||||
| } | ||||
|  | ||||
| func (b *EthApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user