Skip to content

Comments

Backports: fix(op-deployer): fix inspect and state types to respect unmarshalling the state.json (#14889)#14921

Closed
yashvardhan-kukreja wants to merge 1 commit intobackports/op-deployer/v0.0.13from
fixes/op-deployer-v0.0.13-blockref-parsing-from-state
Closed

Backports: fix(op-deployer): fix inspect and state types to respect unmarshalling the state.json (#14889)#14921
yashvardhan-kukreja wants to merge 1 commit intobackports/op-deployer/v0.0.13from
fixes/op-deployer-v0.0.13-blockref-parsing-from-state

Conversation

@yashvardhan-kukreja
Copy link
Contributor

@yashvardhan-kukreja yashvardhan-kukreja commented Mar 18, 2025

Description

Backports the fix in op-deployer related to parsing and unmarshalling the state.json's startBlock section correctly to eth.BlockRef through an intermediate serializable type.

Source: #14889

Tests

Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestBlockRef_Deserialize$ github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state

ok  	github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state	0.630s

Some manual testing by modifying the rollup.go to

func RollupCLI(cliCtx *cli.Context) error {
	cfg, err := readConfig(cliCtx)
	if err != nil {
		return err
	}

	globalState, err := pipeline.ReadState(cfg.Workdir)
	if err != nil {
		return fmt.Errorf("failed to read intent: %w", err)
	}

	chainIntent, err := globalState.Chain(cfg.ChainID)
	if err != nil {
		return fmt.Errorf("failed to get chain intent: %w", err)
	}

	fmt.Println(chainIntent.StartBlock)
	return nil
}

With state.json

"startBlock": {
        "hash": "0xd84d7e6e3de812c7e0305d52971dc7488acaa2b2611ecc5e222e6bfc350d1940",
        "parentHash": "0xbfbf7e85c93e031b97fad589175d509631672c62f76c4b12280614cce4031ff9",
        "number": "0x727172",
        "timestamp": "0x67884564"
      }

Parsed output is

❯ ./bin/op-deployer inspect rollup --workdir=/Users/ykukreja/OPLabs/Projects/optimism/op-deployer/foo --outfile=$(pwd)/foo/prestate-from-genesis.json 11155111100000
L1BlockRef{Hash:0xd84d7e6e3de812c7e0305d52971dc7488acaa2b2611ecc5e222e6bfc350d1940,Number:7500146,ParentHash:0xbfbf7e85c93e031b97fad589175d509631672c62f76c4b12280614cce4031ff9,Time:1736983908}

With state.json

"startBlock": {
        "hash": "0xd84d7e6e3de812c7e0305d52971dc7488acaa2b2611ecc5e222e6bfc350d1940",
        "parentHash": "0xbfbf7e85c93e031b97fad589175d509631672c62f76c4b12280614cce4031ff9",
        "number": "foo",
        "timestamp": "0x67884564"
      }

Parsed output is

❯ ./bin/op-deployer inspect rollup --workdir=/Users/ykukreja/OPLabs/Projects/optimism/op-deployer/foo --outfile=$(pwd)/foo/prestate-from-genesis.json 11155111100000
Application failed: failed to read intent: failed to read state file: failed to decode file "/Users/ykukreja/OPLabs/Projects/optimism/op-deployer/foo/state.json": failed to decode JSON: json: cannot unmarshal hex string without 0x prefix into Go struct field L1BlockRefJSON.opChainDeployments.startBlock.number of type hexutil.Uint64

Additional context

Metadata

…g the state.json (#14889)

* fix(op-deployer): fix inspect and state types to respect unmarshalling the state.json

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>

* fix: add custom marshaller to eth.BlockRef

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>

* nit

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>

* chore: remove the custom serializer from blockref

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>

* chore: add unit tests for BlockRef's Serialize and Deserialise

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>

* clean up test

* put marshaler inside start block

* Revert "put marshaler inside start block"

This reverts commit 46b5eaf.

* Revert "clean up test"

This reverts commit e196859.

* Revert "chore: add unit tests for BlockRef's Serialize and Deserialise"

This reverts commit d85ce6a.

* Revert "chore: remove the custom serializer from blockref"

This reverts commit 3dd0834.

* Revert "fix: add custom marshaller to eth.BlockRef"

This reverts commit fb4ff4a.

* unit tests

---------

Signed-off-by: Yashvardhan Kukreja <yashvardhan@oplabs.co>
Co-authored-by: Matthew Slipper <me@matthewslipper.com>
@yashvardhan-kukreja yashvardhan-kukreja requested a review from a team as a code owner March 18, 2025 13:57
@yashvardhan-kukreja yashvardhan-kukreja requested review from sebastianst and removed request for a team March 18, 2025 13:57
@yashvardhan-kukreja yashvardhan-kukreja changed the title fix(op-deployer): fix inspect and state types to respect unmarshalling the state.json (#14889) Backports: fix(op-deployer): fix inspect and state types to respect unmarshalling the state.json (#14889) Mar 18, 2025
@opgitgovernance opgitgovernance added the S-stale Status: Will be closed unless there is activity label Apr 1, 2025
@opgitgovernance
Copy link
Contributor

This pr has been automatically marked as stale and will be closed in 5 days if no updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-stale Status: Will be closed unless there is activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants