From 30723763715df0ae12c736d857c32f2709368591 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:15:42 +0100 Subject: [PATCH] rpc: fix deadlock (#614) --- CHANGELOG.md | 4 ++++ rpc/namespaces/eth/api.go | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 194c5b7f..036987ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [#603](https://github.com/cosmos/ethermint/pull/603) Add state transition params that enable or disable the EVM `Call` and `Create` operations. * (deps) [\#602](https://github.com/cosmos/ethermint/pull/602) Bump tendermint version to [v0.33.9](https://github.com/tendermint/tendermint/releases/tag/v0.33.9) +### Bug Fixes + +* (rpc) [\#613](https://github.com/cosmos/ethermint/issues/613) Fix potential deadlock caused if the keyring `List` returned an error. + ## [v0.3.0] - 2020-11-16 ### API Breaking diff --git a/rpc/namespaces/eth/api.go b/rpc/namespaces/eth/api.go index 71af7b6c..050436fa 100644 --- a/rpc/namespaces/eth/api.go +++ b/rpc/namespaces/eth/api.go @@ -196,6 +196,7 @@ func (api *PublicEthereumAPI) GasPrice() *hexutil.Big { func (api *PublicEthereumAPI) Accounts() ([]common.Address, error) { api.logger.Debug("eth_accounts") api.keyringLock.Lock() + defer api.keyringLock.Unlock() addresses := make([]common.Address, 0) // return [] instead of nil if empty @@ -204,8 +205,6 @@ func (api *PublicEthereumAPI) Accounts() ([]common.Address, error) { return addresses, err } - api.keyringLock.Unlock() - for _, info := range infos { addressBytes := info.GetPubKey().Address().Bytes() addresses = append(addresses, common.BytesToAddress(addressBytes))