Skip to content

Conversation

@riemannulus
Copy link
Contributor

  • Introduced a new file eth_genesis.go to handle Ethereum genesis file creation.
  • Implemented GenerateEthereumGenesis function to generate a genesis file based on Cosmos chain ID.
  • Updated printInfo struct to include Ethereum genesis path and chain ID.
  • Modified InitCmd to generate the Ethereum genesis file during initialization.

This addition enhances the integration of Ethereum functionalities within the Mitosis chain, allowing for seamless genesis file generation.

@riemannulus riemannulus self-assigned this Jul 8, 2025
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

❌ Patch coverage is 68.30986% with 45 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/mitosisd/cmd/init.go 7.69% 36 Missing ⚠️
cmd/mitosisd/cmd/eth_genesis.go 91.26% 5 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

- Introduced a new file `eth_genesis.go` to handle Ethereum genesis file creation.
- Implemented `GenerateEthereumGenesis` function to generate a genesis file based on Cosmos chain ID.
- Updated `printInfo` struct to include Ethereum genesis path and chain ID.
- Modified `InitCmd` to generate the Ethereum genesis file during initialization.

This addition enhances the integration of Ethereum functionalities within the Mitosis chain, allowing for seamless genesis file generation.
- Introduced new test file `eth_genesis_test.go` to validate the functionality of Ethereum genesis file generation.
- Implemented tests for `GetEthChainIDFromCosmosChainID` and `GenerateEthereumGenesis` functions, ensuring correct chain ID mapping and genesis file structure.
- Added integration tests in `init_test.go` to verify the interaction between initialization commands and Ethereum genesis creation.

These tests enhance the reliability of Ethereum integration within the Mitosis chain by ensuring proper functionality and error handling.
@riemannulus riemannulus force-pushed the feat/mitosisd/init-eth-genesis branch from 7f147c3 to 6fb667f Compare July 31, 2025 17:42
…file creation

- Changed directory permissions from 0755 to 0750 in the `GenerateEthereumGenesis` function to enhance security by restricting access to the owner and group only.
- This adjustment ensures that the generated directory for the Ethereum genesis file is more secure, aligning with best practices for file permissions.
- Added a rule to ignore temporary files in the `.golangci.yml` configuration to streamline linting processes.
- Updated the `Makefile` to specify the directories for the linter command, ensuring comprehensive linting across the project.
- Refactored test files and source code for consistent formatting, including whitespace adjustments and the introduction of a constant for the default funded address in `eth_genesis.go`.
- Enhanced directory permission settings in `init_test.go` and `eth_genesis.go` to follow best practices for file security.
@riemannulus riemannulus marked this pull request as ready for review July 31, 2025 18:10
Copilot AI review requested due to automatic review settings July 31, 2025 18:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces Ethereum genesis file generation functionality to the Mitosis daemon initialization process. The changes enable automatic creation of Ethereum genesis files alongside Cosmos genesis files during chain initialization.

  • Adds Ethereum genesis file generation with chain-specific configurations
  • Updates initialization command to create both Cosmos and Ethereum genesis files
  • Includes comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/mitosisd/cmd/eth_genesis.go Implements Ethereum genesis file generation with chain config and funded accounts
cmd/mitosisd/cmd/init.go Updates initialization process to generate Ethereum genesis and display path info
cmd/mitosisd/cmd/eth_genesis_test.go Comprehensive tests for Ethereum genesis generation functionality
cmd/mitosisd/cmd/init_test.go Integration tests for updated initialization process with Ethereum support
Makefile Updates linter scope to include specific directories
.golangci.yml Excludes temporary files directory from linting
Comments suppressed due to low confidence (1)

cmd/mitosisd/cmd/init.go:51

  • The function name 'newPrintInfoWithEth' is inconsistent with Go naming conventions. Consider renaming to 'newPrintInfo' since this appears to be replacing the original function, or use a more descriptive name like 'newPrintInfoWithEthGenesis'.
func newPrintInfoWithEth(moniker, chainID, nodeID, genTxsDir string, appMessage json.RawMessage, ethGenesisPath string, ethChainID string) printInfo {

…b schedule and customization options

- Updated `eth_genesis.go` to include a new `BlobSchedule` struct for managing blob configurations related to network upgrades.
- Modified the `GenerateEthereumGenesisWithOptions` function to accept custom options for gas limit, funded address, and initial balance, improving flexibility in genesis file generation.
- Adjusted test cases in `eth_genesis_test.go` and `init_test.go` to reflect changes in default values and validate the new blob schedule parameters.
- Ensured the default funded address is now configurable, enhancing usability for different deployment scenarios.
@riemannulus
Copy link
Contributor Author

riemannulus commented Jul 31, 2025

Usage

> mitosisd init test-node \
  --chain-id test-chain-123 \
  --eth-chain-id 124859 \
  --eth-gas-limit 25000000 \
  --eth-funded-address 0x1234567890123456789012345678901234567890 \
  --eth-initial-balance 500000000000000000000000000 \
  --home /tmp/test-mitosis

Output

> /tmp/test-mitosis/config/eth_genesis.json | jq .

{
  "config": {
    "chainId": 124859,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "londonBlock": 0,
    "terminalTotalDifficulty": 0,
    "shanghaiTime": 0,
    "cancunTime": 0,
    "pragueTime": 0,
    "blobSchedule": {
      "cancun": {
        "target": 3,
        "max": 6,
        "baseFeeUpdateFraction": 3338477
      },
      "prague": {
        "target": 6,
        "max": 9,
        "baseFeeUpdateFraction": 5007716
      }
    }
  },
  "nonce": "0",
  "timestamp": "0",
  "extraData": "0x",
  "gasLimit": "25000000",
  "difficulty": "0",
  "mixHash": "",
  "coinbase": "",
  "alloc": {
    "0x1234567890123456789012345678901234567890": {
      "balance": "500000000000000000000000000"
    }
  }
}

@riemannulus riemannulus merged commit 5ccb4cb into main Jul 31, 2025
10 checks passed
@riemannulus riemannulus deleted the feat/mitosisd/init-eth-genesis branch July 31, 2025 19:09
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