Fix code availability in graphQL (#5523)

* Load code when WS snapshot still available

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

* Handle invalid account address

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
pull/5572/head
Gabriel Fukushima 1 year ago committed by GitHub
parent 4407abd37f
commit 287cfd1f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.log.LogTopic;
import org.hyperledger.besu.evm.tracing.OperationTracer;
@ -144,13 +145,15 @@ public class BlockAdapterBase extends AdapterBase {
public AccountAdapter getAccount(final DataFetchingEnvironment environment) {
final BlockchainQueries query = getBlockchainQueries(environment);
final Address address = environment.getArgument("address");
final long bn = header.getNumber();
return query
.getAndMapWorldState(
bn,
ws -> {
final Address address = environment.getArgument("address");
return Optional.of(new AccountAdapter(ws.get(address)));
Account account = ws.get(address);
if (account != null) account.getCode();
return Optional.of(new AccountAdapter(account));
})
.get();
}

Loading…
Cancel
Save