Skip to content

Commit

Permalink
Setting the private state to public state if contract address is not …
Browse files Browse the repository at this point in the history
…present in the private state
  • Loading branch information
jbhurat committed Nov 30, 2018
1 parent 8c4aea5 commit 6fc64e4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,19 @@ func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state vm.M
vmError := func() error { return nil }

context := core.NewEVMContext(msg, header, b.eth.BlockChain(), nil)
return vm.NewEVM(context, statedb.state, statedb.privateState, b.eth.chainConfig, vmCfg), vmError, nil

// Set the private state to public state if contract address is not present in the private state
to := common.Address{}
if msg.To() != nil {
to = *msg.To()
}

privateState := statedb.privateState
if !privateState.Exist(to) {
privateState = statedb.state
}

return vm.NewEVM(context, statedb.state, privateState, b.eth.chainConfig, vmCfg), vmError, nil
}

func (b *EthAPIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
Expand Down

0 comments on commit 6fc64e4

Please sign in to comment.