Include currently active EVM version in `admin_nodeInfo` response (#7127)

* Include currently active EVM version in node info response

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* Remove println, add changelog entry

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

---------

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
pull/7172/head
Matt Whitehead 6 months ago committed by GitHub
parent 6f3650fc51
commit bd32e2c6e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfo.java
  3. 9
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/AdminJsonRpcMethods.java
  4. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
  5. 18
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/AdminNodeInfoTest.java

@ -6,6 +6,7 @@
### Additions and Improvements
- Add two counters to DefaultBlockchain in order to be able to calculate TPS and Mgas/s [#7105](https://github.com/hyperledger/besu/pull/7105)
- `admin_nodeInfo` JSON/RPC call returns the currently active EVM version [#7127](https://github.com/hyperledger/besu/pull/7127)
### Bug fixes
- Make `eth_gasPrice` aware of the base fee market [#7102](https://github.com/hyperledger/besu/pull/7102)

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSucces
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.ChainHead;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.nat.NatService;
import org.hyperledger.besu.nat.core.domain.NatPortMapping;
@ -47,6 +48,7 @@ public class AdminNodeInfo implements JsonRpcMethod {
private final P2PNetwork peerNetwork;
private final BlockchainQueries blockchainQueries;
private final NatService natService;
private final ProtocolSchedule protocolSchedule;
public AdminNodeInfo(
final String clientVersion,
@ -54,13 +56,15 @@ public class AdminNodeInfo implements JsonRpcMethod {
final GenesisConfigOptions genesisConfigOptions,
final P2PNetwork peerNetwork,
final BlockchainQueries blockchainQueries,
final NatService natService) {
final NatService natService,
final ProtocolSchedule protocolSchedule) {
this.peerNetwork = peerNetwork;
this.clientVersion = clientVersion;
this.genesisConfigOptions = genesisConfigOptions;
this.blockchainQueries = blockchainQueries;
this.networkId = networkId;
this.natService = natService;
this.protocolSchedule = protocolSchedule;
}
@Override
@ -126,6 +130,9 @@ public class AdminNodeInfo implements JsonRpcMethod {
"network",
networkId)));
response.put(
"activeFork", protocolSchedule.getByBlockHeader(chainHead.getBlockHeader()).getName());
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), response);
}

@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.PluginsReloadConfiguration;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration;
import org.hyperledger.besu.nat.NatService;
@ -48,6 +49,7 @@ public class AdminJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final Map<String, BesuPlugin> namedPlugins;
private final EthPeers ethPeers;
private final Optional<EnodeDnsConfiguration> enodeDnsConfiguration;
private final ProtocolSchedule protocolSchedule;
public AdminJsonRpcMethods(
final String clientVersion,
@ -58,7 +60,8 @@ public class AdminJsonRpcMethods extends ApiGroupJsonRpcMethods {
final Map<String, BesuPlugin> namedPlugins,
final NatService natService,
final EthPeers ethPeers,
final Optional<EnodeDnsConfiguration> enodeDnsConfiguration) {
final Optional<EnodeDnsConfiguration> enodeDnsConfiguration,
final ProtocolSchedule protocolSchedule) {
this.clientVersion = clientVersion;
this.networkId = networkId;
this.genesisConfigOptions = genesisConfigOptions;
@ -68,6 +71,7 @@ public class AdminJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.natService = natService;
this.ethPeers = ethPeers;
this.enodeDnsConfiguration = enodeDnsConfiguration;
this.protocolSchedule = protocolSchedule;
}
@Override
@ -86,7 +90,8 @@ public class AdminJsonRpcMethods extends ApiGroupJsonRpcMethods {
genesisConfigOptions,
p2pNetwork,
blockchainQueries,
natService),
natService,
protocolSchedule),
new AdminPeers(ethPeers),
new AdminChangeLogLevel(),
new AdminGenerateLogBloomCache(blockchainQueries),

@ -97,7 +97,8 @@ public class JsonRpcMethodsFactory {
namedPlugins,
natService,
ethPeers,
enodeDnsConfiguration),
enodeDnsConfiguration,
protocolSchedule),
new DebugJsonRpcMethods(
blockchainQueries,
protocolContext,

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
@ -33,6 +34,8 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.ChainHead;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer;
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
@ -67,6 +70,8 @@ public class AdminNodeInfoTest {
@Mock private BlockchainQueries blockchainQueries;
@Mock private NatService natService;
@Mock private BlockHeader blockHeader;
@Mock private ProtocolSchedule protocolSchedule;
@Mock private ProtocolSpec protocolSpec;
private AdminNodeInfo method;
@ -93,6 +98,8 @@ public class AdminNodeInfoTest {
when(blockchainQueries.getBlockHashByNumber(anyLong())).thenReturn(Optional.of(Hash.EMPTY));
when(blockchain.getChainHead()).thenReturn(testChainHead);
when(natService.queryExternalIPAddress(anyString())).thenReturn("1.2.3.4");
when(protocolSpec.getName()).thenReturn("London");
when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec);
method =
new AdminNodeInfo(
"testnet/1.0/this/that",
@ -100,7 +107,8 @@ public class AdminNodeInfoTest {
genesisConfigOptions,
p2pNetwork,
blockchainQueries,
natService);
natService,
protocolSchedule);
}
@Test
@ -110,6 +118,7 @@ public class AdminNodeInfoTest {
final JsonRpcRequestContext request = adminNodeInfo();
final Map<String, Object> expected = new HashMap<>();
expected.put("activeFork", "London");
expected.put(
"enode",
"enode://0f1b319e32017c3fcb221841f0f978701b4e9513fe6a567a2db43d43381a9c7e3dfe7cae13cbc2f56943400bacaf9082576ab087cd51983b17d729ae796f6807@1.2.3.4:30303?discport=7890");
@ -161,6 +170,7 @@ public class AdminNodeInfoTest {
final JsonRpcRequestContext request = adminNodeInfo();
final Map<String, Object> expected = new HashMap<>();
expected.put("activeFork", "London");
expected.put(
"enode",
"enode://0f1b319e32017c3fcb221841f0f978701b4e9513fe6a567a2db43d43381a9c7e3dfe7cae13cbc2f56943400bacaf9082576ab087cd51983b17d729ae796f6807@3.4.5.6:8081?discport=8080");
@ -207,6 +217,7 @@ public class AdminNodeInfoTest {
final JsonRpcRequestContext request = adminNodeInfo();
final Map<String, Object> expected = new HashMap<>();
expected.put("activeFork", "London");
expected.put(
"enode",
"enode://0f1b319e32017c3fcb221841f0f978701b4e9513fe6a567a2db43d43381a9c7e3dfe7cae13cbc2f56943400bacaf9082576ab087cd51983b17d729ae796f6807@1.2.3.4:0");
@ -253,6 +264,7 @@ public class AdminNodeInfoTest {
final JsonRpcRequestContext request = adminNodeInfo();
final Map<String, Object> expected = new HashMap<>();
expected.put("activeFork", "London");
expected.put(
"enode",
"enode://0f1b319e32017c3fcb221841f0f978701b4e9513fe6a567a2db43d43381a9c7e3dfe7cae13cbc2f56943400bacaf9082576ab087cd51983b17d729ae796f6807@1.2.3.4:0?discport=7890");
@ -299,6 +311,7 @@ public class AdminNodeInfoTest {
final JsonRpcRequestContext request = adminNodeInfo();
final Map<String, Object> expected = new HashMap<>();
expected.put("activeFork", "London");
expected.put(
"enode",
"enode://0f1b319e32017c3fcb221841f0f978701b4e9513fe6a567a2db43d43381a9c7e3dfe7cae13cbc2f56943400bacaf9082576ab087cd51983b17d729ae796f6807@1.2.3.4:7890?discport=0");
@ -387,7 +400,8 @@ public class AdminNodeInfoTest {
genesisClassicConfigOptions,
p2pNetwork,
blockchainQueries,
natService);
natService,
protocolSchedule);
final JsonRpcRequestContext request = adminNodeInfo();

Loading…
Cancel
Save