Skip to content

Include currently active EVM version in admin_nodeInfo response#7127

Merged
macfarla merged 3 commits intobesu-eth:mainfrom
matthew1001:nodeinfo-evm
Jun 4, 2024
Merged

Include currently active EVM version in admin_nodeInfo response#7127
macfarla merged 3 commits intobesu-eth:mainfrom
matthew1001:nodeinfo-evm

Conversation

@matthew1001
Copy link
Copy Markdown
Contributor

@matthew1001 matthew1001 commented May 21, 2024

PR description

Adds a new field activeFork to the response body of admin_nodeInfo JSON/RPC requests.

The JSON/RPC call already returns the fork configuration but that requires the caller to make multiple calls and compare chain heights and/or timestamps to infer the currently active fork. The new field makes it possible to determine accurately in a single call.

The value is whatever getName() returns for the active ProtocolSpec. This means it is sentence cased (upper-case first letter) but a caller would be expected to use a case-insensitive string compare so I'm not inclined to upper or lower case the string.

Example output with the shanghai fork EVM enabled:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "enode": "enode://beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf3960bb7f41bc6f0d574c4d0c6baa2324c7279045405ef8a240906bc13d3145ccc14@127.0.0.1:30303",
        "listenAddr": "127.0.0.1:30303",
        "activeFork": "Shanghai",    <<-- NEW FIELD
        "ip": "127.0.0.1",
        "name": "besu/v24.5-develop-4753b28/osx-aarch_64/openjdk-java-17",
        "id": "beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf3960bb7f41bc6f0d574c4d0c6baa2324c7279045405ef8a240906bc13d3145ccc14",
        "ports": {
            "discovery": 30303,
            "listener": 30303
        },
        "protocols": {
            "eth": {
                "config": {
                    "chainId": 1337,
                    "berlinBlock": 0,
                    "londonBlock": 0,
                    "shanghaiTime": 1716294470,
                    "qbft": {
                        "epochLength": 30000,
                        "blockPeriodSeconds": 2,
                        "requestTimeoutSeconds": 4
                    },
                    "zeroBaseFee": true
                },
                "difficulty": 62,
                "genesis": "0xf1b9d4b087f35660b73ef0ad56d0f241009c422459500f0a1e8f421ffbe5c29c",
                "head": "0x67ed5c441d3a2eba53c97b8f3b88ccb217ac17084ad0ed722fe894963a49ba6f",
                "network": 1337
            }
        }
    }
}

I've tested the call before and after a fork to check that the value of activeFork changes as soon as the new fork is enabled.

Fixed Issue(s)

Fixes #7064

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
@matthew1001 matthew1001 changed the title Include currently active EVM version in node info response Include currently active EVM version in admin_nodeInfo response May 21, 2024
Copy link
Copy Markdown
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a changelog entry and there's a stray println, otherwise LGTM

final Map<String, Object> response = new HashMap<>();
final Map<String, Integer> ports = new HashMap<>();

System.out.println("MRW: Returning node info");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debugging

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah, thanks, will remove now and add the changelog entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both now sorted @macfarla

matthew1001 and others added 2 commits June 3, 2024 10:03
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
@macfarla macfarla merged commit bd32e2c into besu-eth:main Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No JSON/RPC endpoint exists to determine which EVM version a permissioned chain is using

2 participants