Skip to content

op-chain-ops: unwrap l1 and l2 allocs#10387

Merged
tynes merged 1 commit intodevelopfrom
unwrap-allocs
May 2, 2024
Merged

op-chain-ops: unwrap l1 and l2 allocs#10387
tynes merged 1 commit intodevelopfrom
unwrap-allocs

Conversation

@protolambda
Copy link
Contributor

Description

This turns { "accounts": { ... }} into just {...}, i.e. unwrapping the allocs files, so that the Go genesis tooling matches the default foundry state-dump format. This applies to both L1 and L2.

PSA: when this is merged, anyone running op-e2e or devnet will need to re-run make devnet-allocs, for unwrapped l1 and l2 allocs files.

@protolambda protolambda requested a review from tynes May 2, 2024 21:59
@protolambda protolambda requested a review from a team as a code owner May 2, 2024 21:59
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 2, 2024

Walkthrough

Walkthrough

The recent changes involve a significant refactoring of how forge dumps are handled across various files in the bedrock-devnet and op-chain-ops packages. The updates streamline the process by replacing manual JSON operations with more efficient file movements using shutil.move. Additionally, there are modifications to data types and method calls to align with the new ForgeAllocs structure, enhancing overall system efficiency and consistency.

Changes

Files Change Summary
bedrock-devnet/devnet/__init__.py Refactored handling of forge dumps using shutil.move for L1 and L2 allocations, eliminating redundant read, write, and delete operations.
op-chain-ops/genesis/config.go, op-chain-ops/genesis/layer_one.go, op-chain-ops/genesis/layer_two.go, op-e2e/config/init.go, op-node/cmd/genesis/cmd.go Integrated ForgeAllocs in place of old gstate.Dump and state.Dump types, updated method calls, and adjusted data handling to accommodate new data structures. Outdated imports were removed, and adjustments were made to utilize the new uint256 type for balances.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2838df8 and 45d2f6b.
Files selected for processing (6)
  • bedrock-devnet/devnet/init.py (2 hunks)
  • op-chain-ops/genesis/config.go (3 hunks)
  • op-chain-ops/genesis/layer_one.go (2 hunks)
  • op-chain-ops/genesis/layer_two.go (1 hunks)
  • op-e2e/config/init.go (3 hunks)
  • op-node/cmd/genesis/cmd.go (2 hunks)
Files skipped from review as they are similar to previous changes (5)
  • op-chain-ops/genesis/config.go
  • op-chain-ops/genesis/layer_one.go
  • op-chain-ops/genesis/layer_two.go
  • op-e2e/config/init.go
  • op-node/cmd/genesis/cmd.go
Additional Context Used
Ruff (6)
bedrock-devnet/devnet/__init__.py (6)

7-7: calendar imported but unused; consider removing, adding to __all__, or using a redundant alias


12-12: gzip imported but unused; consider removing, adding to __all__, or using a redundant alias


18-18: devnet.log_setup imported but unused; consider removing, adding to __all__, or using a redundant alias


215-215: Avoid equality comparisons to False; use if not os.path.exists(l2_allocs_path): for false checks


215-215: Avoid equality comparisons to True; use if DEVNET_FPAC: for truth checks


304-304: Local variable e is assigned to but never used


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Out of diff range and nitpick comments (1)
op-chain-ops/genesis/config.go (1)

Line range hint 772-799: Refactor UnmarshalJSON method in ForgeAllocs struct.

The method has been adapted to handle the new JSON structure directly. However, consider using a more efficient way to handle large numbers of allocations, such as parallel processing or optimizing the JSON parsing strategy.

func (d *ForgeAllocs) UnmarshalJSON(b []byte) error {
	type forgeAllocAccount struct {
		Balance hexutil.U256                `json:"balance"`
		Nonce   hexutil.Uint64              `json:"nonce"`
		Code    hexutil.Bytes               `json:"code,omitempty"`
		Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
	}
	var allocs map[common.Address]forgeAllocAccount
	if err := json.Unmarshal(b, &allocs); err != nil {
		return err
	}
	d.Accounts = make(types.GenesisAlloc, len(allocs))
	for addr, acc := range allocs {
		acc := acc
		d.Accounts[addr] = types.Account{
			Code:       acc.Code,
			Storage:    acc.Storage,
			Balance:    (*uint256.Int)(&acc.Balance).ToBig(),
			Nonce:      (uint64)(acc.Nonce),
			PrivateKey: nil,
		}
	}
	return nil
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

@tynes tynes enabled auto-merge May 2, 2024 22:42
@tynes tynes added this pull request to the merge queue May 2, 2024
Merged via the queue into develop with commit 91a6fca May 2, 2024
@tynes tynes deleted the unwrap-allocs branch May 2, 2024 22:59
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.

2 participants