Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set local C-Chain genesis timestamp to InitiallyActiveTime #3413

Merged
merged 4 commits into from
Sep 26, 2024

Conversation

michaelkaplan13
Copy link
Contributor

Why this should be merged

How this works

Sets the local genesis C-Chain timestamp to the InitiallyActiveTime

How this was tested

Running node with: ./build/avalanchego --sybil-protection-enabled=false --network-id=local
And checking that there is a base fee returned for the genesis block (would previously return a null result):

$ curl --location 'http://127.0.0.1:9650/ext/bc/C/rpc' \
> --header 'Content-Type: application/json' \
> --data '{
>     "jsonrpc": "2.0",
>     "method": "eth_baseFee",
>     "params": [],
>     "id": 1
> }'
{"jsonrpc":"2.0","id":1,"result":"0x34630b8a00"}

@@ -91,6 +91,6 @@
}
}
],
"cChainGenesis": "{\"config\":{\"chainId\":43112,\"homesteadBlock\":0,\"daoForkBlock\":0,\"daoForkSupport\":true,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"apricotPhase1BlockTimestamp\":0,\"apricotPhase2BlockTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC\":{\"balance\":\"0x295BE96E64066972000000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}",
"cChainGenesis": "{\"config\":{\"chainId\":43112,\"homesteadBlock\":0,\"daoForkBlock\":0,\"daoForkSupport\":true,\"eip150Block\":0,\"eip150Hash\":\"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0\",\"eip155Block\":0,\"eip158Block\":0,\"byzantiumBlock\":0,\"constantinopleBlock\":0,\"petersburgBlock\":0,\"istanbulBlock\":0,\"muirGlacierBlock\":0,\"apricotPhase1BlockTimestamp\":0,\"apricotPhase2BlockTimestamp\":0},\"nonce\":\"0x0\",\"timestamp\":\"0x5FCB13D0\",\"extraData\":\"0x00\",\"gasLimit\":\"0x5f5e100\",\"difficulty\":\"0x0\",\"mixHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"coinbase\":\"0x0000000000000000000000000000000000000000\",\"alloc\":{\"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC\":{\"balance\":\"0x295BE96E64066972000000\"}},\"number\":\"0x0\",\"gasUsed\":\"0x0\",\"parentHash\":\"0x0000000000000000000000000000000000000000000000000000000000000000\"}",
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mind explaining how 0x5FCB13D0 is calculated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I should have made that more clear from the start.

It is InitiallyActiveTime.Unix() represented in hexadecimal to be put in the genesis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any ideas for how I could better document that or make it less error prone? The embedded JSON makes it a bit harder to do.

Copy link
Contributor

@yacovm yacovm Sep 25, 2024

Choose a reason for hiding this comment

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

In retrospect, instead of using:

//go:embed genesis_local.json
localGenesisConfigJSON []byte

We can have just put a Golang object and add an init() function which marshals it into the bytes of localGenesisConfigJSON

Copy link
Contributor

Choose a reason for hiding this comment

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

It is InitiallyActiveTime.Unix() represented in hexadecimal to be put in the genesis

It's possible to add a unit test that asserts it is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to leave it with the //go:embed approach for now to limit the changes for fixing this issue, but added a unit test that will break if the InitiallyActiveTime is ever changes.

@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 25, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 26, 2024
Merged via the queue into master with commit 6e68a14 Sep 26, 2024
22 checks passed
@StephenButtolph StephenButtolph deleted the local-genesis-timestamp branch September 26, 2024 01:47
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.

eth_baseFee returns null on v1.11.11
3 participants