From 7803a2f7ef1e518623d92250caf04145d20c0ad3 Mon Sep 17 00:00:00 2001 From: Jitendra Bhurat Date: Fri, 30 Nov 2018 13:42:31 -0500 Subject: [PATCH] Setting the private state to public state if contract address is not present in the private state --- eth/api_backend.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/eth/api_backend.go b/eth/api_backend.go index 2a601d4b6..67b9fb83b 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -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 {