Merge branch 'main' into zkbesu

# Conflicts:
#	.github/workflows/checks.yml
#	.github/workflows/codeql.yml
#	.github/workflows/release.yml
#	.github/workflows/repolinter.yml
#	.github/workflows/sonarcloud.yml
This commit is contained in:
Fabio Di Fabio
2023-11-23 10:50:12 +01:00
4 changed files with 32 additions and 27 deletions

View File

@@ -7,5 +7,5 @@ jobs:
name: "Gradle Wrapper Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1

View File

@@ -13,6 +13,7 @@
- Update OpenJDK latest Docker image to use Java 21 [#6189](https://github.com/hyperledger/besu/pull/6189)
- Allow a transaction selection plugin to specify custom selection results [#6190](https://github.com/hyperledger/besu/pull/6190)
- Add `rpc-gas-cap` to allow users to set gas limit to the RPC methods used to simulate transactions[#6156](https://github.com/hyperledger/besu/pull/6156)
- Fix the unavailability of `address` field when returning an `Account` entity on GraphQL in case of unreachable world state [#6198](https://github.com/hyperledger/besu/pull/6198)
### Bug fixes
- Fix Docker image name clash between Besu and evmtool [#6194](https://github.com/hyperledger/besu/pull/6194)

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
@@ -63,9 +64,9 @@ public class LogAdapter extends AdapterBase {
blockNumber = bn;
}
final Address logger = logWithMetadata.getLogger();
return query
.getAndMapWorldState(
blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(logWithMetadata.getLogger()))))
.get();
.getAndMapWorldState(blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(logger))))
.orElse(new EmptyAccountAdapter(logger));
}
}

View File

@@ -82,35 +82,36 @@ public class TransactionAdapter extends AdapterBase {
public AccountAdapter getFrom(final DataFetchingEnvironment environment) {
final BlockchainQueries query = getBlockchainQueries(environment);
Long blockNumber = environment.getArgument("block");
if (blockNumber == null) {
blockNumber = transactionWithMetadata.getBlockNumber().orElseGet(query::headBlockNumber);
}
final Long blockNumber =
Optional.<Long>ofNullable(environment.getArgument("block"))
.or(transactionWithMetadata::getBlockNumber)
.orElseGet(query::headBlockNumber);
final Address addr = transactionWithMetadata.getTransaction().getSender();
return query
.getAndMapWorldState(
blockNumber,
mutableWorldState ->
Optional.of(
new AccountAdapter(
mutableWorldState.get(
transactionWithMetadata.getTransaction().getSender()))))
.get();
mutableWorldState -> Optional.of(new AccountAdapter(mutableWorldState.get(addr))))
.orElse(new EmptyAccountAdapter(addr));
}
public Optional<AccountAdapter> getTo(final DataFetchingEnvironment environment) {
final BlockchainQueries query = getBlockchainQueries(environment);
Long blockNumber = environment.getArgument("block");
if (blockNumber == null) {
blockNumber = transactionWithMetadata.getBlockNumber().orElseGet(query::headBlockNumber);
}
final Long blockNumber =
Optional.<Long>ofNullable(environment.getArgument("block"))
.or(transactionWithMetadata::getBlockNumber)
.orElseGet(query::headBlockNumber);
return query.getAndMapWorldState(
blockNumber,
ws ->
transactionWithMetadata
.getTransaction()
.getTo()
.map(address -> new AccountAdapter(address, ws.get(address))));
return transactionWithMetadata
.getTransaction()
.getTo()
.flatMap(
address ->
query
.getAndMapWorldState(
blockNumber,
ws -> Optional.of(new AccountAdapter(address, ws.get(address))))
.or(() -> Optional.of(new EmptyAccountAdapter(address))));
}
public Wei getValue() {
@@ -197,8 +198,10 @@ public class TransactionAdapter extends AdapterBase {
return Optional.empty();
}
final long blockNumber = bn.orElseGet(txBlockNumber::get);
return query.getAndMapWorldState(
blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(addr.get()))));
return query
.getAndMapWorldState(
blockNumber, ws -> Optional.of(new AccountAdapter(ws.get(addr.get()))))
.or(() -> Optional.of(new EmptyAccountAdapter(addr.get())));
}
}
return Optional.empty();