Skip to content

Conversation

@dbrajovic
Copy link
Contributor

@dbrajovic dbrajovic commented Jun 30, 2025

Checked out from tag: v1.58.0-evm-precompiles-comet1-rc2

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive support for Ethereum Virtual Machine (EVM) transaction types, logs, events, error handling, and storage within the platform.
    • Added Go bindings for interacting with Ethereum-compatible smart contracts, including bank, exchange, and staking modules.
    • Enhanced Makefile with new targets for extracting protobuf message names and running linter checks.
    • Expanded ERC20 module support with codec registration and interface integration.
  • Improvements

    • Upgraded linter configurations and workflows for improved code quality and maintainability.
    • Refined configuration, validation, and permissioning for EVM parameters and chain settings.
  • Bug Fixes

    • Minor corrections to Tendermint RPC client initialization and method receiver styles for improved reliability and consistency.
  • Chores

    • Updated dependencies and streamlined repository management in build scripts.

aarmoa and others added 27 commits April 16, 2025 16:33
* feat: removed the deprecated pre-commit repo pre-commit-golang. Added new CI step to run golangci-lint using the github action

* fix: added skip directories into the golanci lint config

* fix: fixed lint errors

* fix: fixed lint errors

* feat: updated proto definitions for the chain upgrade v1.15

* fix: synced go.mod dependecnies with Injective core

* fix: fixed lint errors

* fix: fixed lint errors

* feat: updated all proto definitions for v1.15 chain upgrade. Added an example for the new GetEipBaseFee request in txfees module

* feat: updated all examples to query gas price from the chain instead of using the default value

* Feat/sync with master v1.56.2 (#298)

* (fix) Applied the fixes for EIP712 JSON unmarshalling to the master branch

* fix: update pre-commit/action from v2.0.2 to v3.0.1 to ry to solve the pre-commit validation workflow error

* fix: Added configuration in .golangci.yml file to exclude some dirs

* fix: updated the oracle stream prices script to send the oracle type always in lowercase

* fix: updated the oracle stream prices script to send the oracle type always in lowercase

* fix: Added quantization in the functions that convert notional values to chain format

* fix/fix_manual_tx_generation (#296)

* fix: fixed the manual TX generation and signing to receive the gas price

* fix: solve issues in pre-commit workflow caused by using deprecated components

* fix: solve issues in pre-commit workflow caused by using deprecated components

* feat: updated proto definitions for the chain upgrade v1.15

* (fix) Applied the fixes for EIP712 JSON unmarshalling to the master branch

* fix: updated the oracle stream prices script to send the oracle type always in lowercase

* fix: updated the oracle stream prices script to send the oracle type always in lowercase

* fix: synced go.mod dependecnies with Injective core

* fix: fixed lint errors

* fix: fixed lint errors

* feat: updated all proto definitions for v1.15 chain upgrade. Added an example for the new GetEipBaseFee request in txfees module

* feat: updated all examples to query gas price from the chain instead of using the default value

* fix: fix function parameter type

* feat: updated proto definition to v1.15.0-beta.2 and v1.14.48 for Indexer

* fix: update ofac.json file

* Improve error messaging and enhance documentation in eip712_cosmos.go (#240)

This PR improves error handling and enhances documentation in the
eip712_cosmos.go file to provide clearer messages and more detailed
explanations.

Signed-off-by: Hwangjae Lee <meetrick@gmail.com>
Co-authored-by: Abel Armoa <30988000+aarmoa@users.noreply.github.com>

* fix: fixed array creatin in a unit test (#299)

* fix: updated chain version to v1.15 and indexer version to v1.15.6

* fix: removed explicit inclusion of txfees response in the context initialization (not required)

---------

Signed-off-by: Hwangjae Lee <meetrick@gmail.com>
Co-authored-by: Hwangjae Lee <meetrick@gmail.com>
… endpoint (the /websocket destination is added internally now)
…w reduce margin ratio for derivative markets
…d examples for the new queries and messages.
…s (with fully qualified name) every time the proto definitions are updated
@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

This update introduces extensive new functionality and refactoring related to Ethereum Virtual Machine (EVM) support and Ethereum transaction handling within a Cosmos SDK-based environment. It adds new Go packages and files for EVM types, transaction formats, events, error handling, and precompiled contract bindings. The update also revises linter configurations, Makefile targets, and workflow dependencies. Minor stylistic and receiver changes are applied to existing crypto and RPC code.

Changes

Files / Groups Change Summary
.github/workflows/golangci-lint.yml, .golangci.yml Updated linter workflow to newer action versions; upgraded and reorganized linter configuration, removed and refined enabled linters, migrated to v2 config format.
Makefile Updated branch targets for repo clones, expanded type copying, added extract-message-names and lint-all targets, and improved protobuf message extraction.
auth_vote/authz_vote.go Simplified Tendermint RPC client initialization by removing explicit websocket path argument.
chain/crypto/ethsecp256k1/ethsecp256k1.go, chain/crypto/hd/algorithm.go Changed method receivers to unnamed; updated comments to reference "Injective" instead of "Ethermint".
chain/crypto/hd/hd_path.go Introduced utilities for Ethereum HD wallet path iteration and constants for BIP44 coin type and path.
chain/erc20/types/codec.go Added codec registration and interface setup for ERC20 module message types.
chain/evm/precompiles/bank/.abigen.go, chain/evm/precompiles/exchange/.abigen.go, chain/evm/precompiles/staking/*.abigen.go Added auto-generated Go bindings for multiple Ethereum smart contracts (ERC20, BankModule, MintBurnBankERC20, ExchangeModule, StakingModule), enabling deployment, interaction, and event handling.
chain/evm/types/access_list.go, chain/evm/types/access_list_tx.go, chain/evm/types/dynamic_fee_tx.go, chain/evm/types/legacy_tx.go Introduced types and conversion logic for Ethereum Access List, Dynamic Fee, and Legacy transactions, including validation, signature handling, and conversion to/from go-ethereum types.
chain/evm/types/chain_config.go, chain/evm/types/params.go Added EVM chain configuration and parameter management, including validation, conversion, and permissioning logic.
chain/evm/types/codec.go Implemented codec registration for Ethereum transaction types and utility functions for protobuf interface packing/unpacking.
chain/evm/types/errors.go Introduced comprehensive error handling framework for EVM execution, including VM error interfaces, revert reason extraction, and JSON-RPC error compatibility.
chain/evm/types/events.go Added event and attribute key constants for EVM module event handling and metrics.
chain/evm/types/eth.go Introduced EthereumTx wrapper for transaction marshaling, validation, and size calculation.
chain/evm/types/key.go Defined module and store key constants and utility functions for EVM state and object storage key construction.
chain/evm/types/logs.go Added types and functions for transaction log handling, validation, and conversion to/from Ethereum native logs.
chain/evm/types/msg.go Defined MsgEthereumTx and related message types for Ethereum transaction handling, signing, and integration with Cosmos SDK message workflows.
chain/evm/types/storage.go Added types for deterministic EVM account storage representation and validation.
chain/evm/types/tx.go Added transaction priority calculation and response helpers for execution failure and revert reason extraction.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CosmosSDK
    participant EVMModule
    participant EthereumTx
    participant GoEthereum
    participant ContractBinding

    User->>CosmosSDK: Submit MsgEthereumTx
    CosmosSDK->>EVMModule: Route message
    EVMModule->>EthereumTx: Convert to go-ethereum TxData
    EthereumTx->>GoEthereum: Validate and sign transaction
    EVMModule->>ContractBinding: (Optional) Interact with precompiled contract
    EVMModule-->>CosmosSDK: Return MsgEthereumTxResponse (with logs/errors)
    CosmosSDK-->>User: Deliver transaction result
Loading

Poem

In the warren, code grows anew,
EVM hops in—so much to do!
Contracts, logs, and errors bloom,
With keys and codecs, there's no room for gloom.
Linting is crisp, the Makefile's a treat—
This rabbit's code garden is now quite complete!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@dbrajovic dbrajovic changed the base branch from master to v1.58.x-evm-comet1 June 30, 2025 16:51
Copy link

@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: 17

♻️ Duplicate comments (1)
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)

32-36: Duplicate type definition detected

The CosmosCoin struct is identically defined here and in the staking module binding. This creates a duplicate type definition that could cause compatibility issues when both modules are used together.

This is the same issue identified in the staking module. Consider consolidating shared types into a common package to avoid type conflicts and maintain consistency across modules.

🧹 Nitpick comments (12)
chain/evm/types/tx.go (1)

16-29: Consider edge case handling and documentation improvements.

The function has good overflow protection, but there are a few considerations:

  1. The function always returns math.MaxInt64 when priorityBig doesn't fit in int64, which might not be the intended behavior for very high gas prices.
  2. The function comment mentions "priority reduction global variable" but the actual variable name is DefaultPriorityReduction.

Consider this improvement for better edge case handling:

 func GetTxPriority(msg *MsgEthereumTx) (priority int64) {
-	// calculate priority based on gas price
+	// Calculate priority based on gas price using DefaultPriorityReduction
 	gasPrice := msg.AsTransaction().GasPrice()
 
-	priority = math.MaxInt64
+	// Default to max priority for edge cases
 	priorityBig := new(big.Int).Quo(gasPrice, DefaultPriorityReduction.BigInt())
 
-	// safety check
+	// Safety check to prevent overflow
 	if priorityBig.IsInt64() {
 		priority = priorityBig.Int64()
+	} else {
+		priority = math.MaxInt64
 	}
 
 	return priority
 }
Makefile (1)

156-165: Robust message extraction logic with minor improvement suggestion.

The extract-message-names target is well-implemented with proper error handling and informative output. The regex pattern correctly filters out Response messages.

Consider adding error handling for the jq command:

 extract-message-names:
 	@echo "Extracting message names from tx.pb.go files..."
 	@mkdir -p injective_data
 	@find ./chain -name "tx.pb.go" -exec grep -h "proto\.RegisterType" {} \; | \
 		sed -n 's/.*proto\.RegisterType([^"]*"\([^"]*\)".*/\1/p' | \
 		grep -v 'Response$$' | \
 		sort -u | \
-		jq -R -s 'split("\n")[:-1]' > injective_data/chain_messages_list.json
+		jq -R -s 'split("\n")[:-1]' > injective_data/chain_messages_list.json || { echo "Error: jq failed"; exit 1; }
chain/evm/types/storage.go (1)

32-40: Consider performance optimization for String method.

The current string concatenation approach could be inefficient for large storage collections due to repeated string allocations.

Consider using strings.Builder for better performance:

 // String implements the stringer interface
 func (s Storage) String() string {
-	var str string
+	var builder strings.Builder
 	for _, state := range s {
-		str += fmt.Sprintf("%s\n", state.String())
+		builder.WriteString(state.String())
+		builder.WriteByte('\n')
 	}
 
-	return str
+	return builder.String()
 }
chain/evm/types/eth.go (1)

66-84: Comprehensive validation with minor improvement opportunity.

The validation logic correctly checks gas parameters and costs. However, consider enhancing readability by extracting the validation error pattern.

Consider extracting a helper function to reduce duplication:

+func validateInt256(value *big.Int, errType error, fieldName string) error {
+	if !types.IsValidInt256(value) {
+		return errorsmod.Wrap(errType, fmt.Sprintf("%s out of bound", fieldName))
+	}
+	return nil
+}

func (tx EthereumTx) Validate() error {
	// prevent txs with 0 gas to fill up the mempool
	if tx.Gas() == 0 {
		return errorsmod.Wrap(ErrInvalidGasLimit, "gas limit must not be zero")
	}
-	if !types.IsValidInt256(tx.GasPrice()) {
-		return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
-	}
-	if !types.IsValidInt256(tx.GasFeeCap()) {
-		return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
-	}
-	if !types.IsValidInt256(tx.GasTipCap()) {
-		return errorsmod.Wrap(ErrInvalidGasPrice, "out of bound")
-	}
-	if !types.IsValidInt256(tx.Cost()) {
-		return errorsmod.Wrap(ErrInvalidGasFee, "out of bound")
-	}
+	if err := validateInt256(tx.GasPrice(), ErrInvalidGasPrice, "gas price"); err != nil {
+		return err
+	}
+	if err := validateInt256(tx.GasFeeCap(), ErrInvalidGasPrice, "gas fee cap"); err != nil {
+		return err
+	}
+	if err := validateInt256(tx.GasTipCap(), ErrInvalidGasPrice, "gas tip cap"); err != nil {
+		return err
+	}
+	if err := validateInt256(tx.Cost(), ErrInvalidGasFee, "cost"); err != nil {
+		return err
+	}
	return nil
}
chain/evm/types/logs.go (1)

131-140: Optimize bloom filter calculation for better performance.

The current implementation could be more efficient by avoiding repeated slice iterations.

Consider optimizing the bloom filter calculation:

func LogsBloom(logs []*ethtypes.Log) []byte {
	var bin ethtypes.Bloom
	for _, log := range logs {
		bin.Add(log.Address.Bytes())
-		for _, b := range log.Topics {
-			bin.Add(b[:])
-		}
+		for _, topic := range log.Topics {
+			bin.Add(topic[:])
+		}
	}
	return bin[:]
}

While the current implementation is correct, the variable name b could be more descriptive as topic for better readability.

chain/evm/types/codec.go (1)

14-22: Consider deprecation warning for AminoCdc.

The comment indicates that AminoCodec is deprecated, but the nolint directive suppresses the warning. Consider adding a TODO comment for future migration.

Add a migration note:

	// AminoCdc is a amino codec created to support amino JSON compatible msgs.
+	// TODO: Migrate away from AminoCodec once legacy support is no longer needed
	AminoCdc = codec.NewAminoCodec(amino) //nolint:staticcheck // AminoCodec is deprecated
chain/evm/types/chain_config.go (1)

160-174: Fix inconsistent field names in error messages.

The error wrapping uses inconsistent casing for field names.

-		return errorsmod.Wrap(err, "GrayGlacierBlock")
+		return errorsmod.Wrap(err, "grayGlacierBlock")
 	}
 	if err := ValidateBlock(cc.MergeNetsplitBlock); err != nil {
-		return errorsmod.Wrap(err, "MergeNetsplitBlock")
+		return errorsmod.Wrap(err, "mergeNetsplitBlock")
 	}
 	if err := ValidateTime(cc.ShanghaiTime); err != nil {
-		return errorsmod.Wrap(err, "ShanghaiTime")
+		return errorsmod.Wrap(err, "shanghaiTime")
 	}
 	if err := ValidateTime(cc.CancunTime); err != nil {
-		return errorsmod.Wrap(err, "CancunTime")
+		return errorsmod.Wrap(err, "cancunTime")
 	}
 	if err := ValidateTime(cc.PragueTime); err != nil {
-		return errorsmod.Wrap(err, "PragueTime")
+		return errorsmod.Wrap(err, "pragueTime")
chain/evm/types/params.go (2)

14-27: Consider security implications of default settings.

The defaults have potential security implications:

  1. DefaultAllowUnprotectedTxs = true allows replay attacks on transactions without EIP-155 protection
  2. The denomination "inj" is Injective-specific and might not be appropriate for other deployments

106-114: Optimize address comparison.

The function creates new address objects on each iteration. Consider pre-computing normalized addresses.

Store normalized addresses in a map during validation for O(1) lookup:

// Add to Params struct:
authorizedDeployersMap map[string]struct{}

// In validation, populate the map
// Then in IsAuthorisedDeployer:
func (p Params) IsAuthorisedDeployer(addr ethcommon.Address) bool {
    _, exists := p.authorizedDeployersMap[addr.Hex()]
    return exists
}
chain/evm/types/msg.go (2)

178-180: Implement GetMsgsV2 or document why it's not implemented.

The method returns "not implemented" error. If this is intentional, add a comment explaining why.

Would you like me to help implement this method or add appropriate documentation?


373-375: Consider migrating from Amino to Protobuf encoding.

The method uses AminoCdc which is deprecated in favor of Protobuf encoding.

chain/evm/precompiles/staking/i_staking_module.abigen.go (1)

32-36: Consider consolidating shared type definitions

The CosmosCoin struct is identically defined in both the staking and exchange module bindings. This duplication could lead to type compatibility issues when using both modules together.

Consider moving shared types like CosmosCoin to a common package that both modules can import, such as:

// In a shared types package
package types

type CosmosCoin struct {
    Amount *big.Int
    Denom  string
}

Then import and reference it in both bindings rather than redefining it.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 680fe94 and 370ebb7.

⛔ Files ignored due to path filters (42)
  • chain/auction/types/query.pb.go is excluded by !**/*.pb.go
  • chain/auction/types/tx.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/erc20.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/events.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/genesis.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/params.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/query.pb.go is excluded by !**/*.pb.go
  • chain/erc20/types/tx.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/access_tuple.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/chain_config.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/events.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/genesis.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/log.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/params.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/query.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/state.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/trace_config.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/transaction_logs.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/tx.pb.go is excluded by !**/*.pb.go
  • chain/evm/types/tx_result.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/authz.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/exchange.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/genesis.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/query.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/tx.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/authz.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/events.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/exchange.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/genesis.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/market.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/order.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/orderbook.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/proposal.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/query.pb.go is excluded by !**/*.pb.go
  • chain/exchange/types/v2/tx.pb.go is excluded by !**/*.pb.go
  • chain/peggy/types/genesis.pb.go is excluded by !**/*.pb.go
  • chain/peggy/types/msgs.pb.go is excluded by !**/*.pb.go
  • chain/peggy/types/rate_limit.pb.go is excluded by !**/*.pb.go
  • chain/stream/types/query.pb.go is excluded by !**/*.pb.go
  • chain/stream/types/v2/query.pb.go is excluded by !**/*.pb.go
  • chain/txfees/types/txfees.pb.go is excluded by !**/*.pb.go
  • chain/types/indexer.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (28)
  • .github/workflows/golangci-lint.yml (1 hunks)
  • .golangci.yml (1 hunks)
  • Makefile (5 hunks)
  • auth_vote/authz_vote.go (1 hunks)
  • chain/crypto/ethsecp256k1/ethsecp256k1.go (2 hunks)
  • chain/crypto/hd/algorithm.go (3 hunks)
  • chain/crypto/hd/hd_path.go (1 hunks)
  • chain/erc20/types/codec.go (1 hunks)
  • chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go (1 hunks)
  • chain/evm/precompiles/bank/i_bank_module.abigen.go (1 hunks)
  • chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1 hunks)
  • chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1 hunks)
  • chain/evm/precompiles/staking/i_staking_module.abigen.go (1 hunks)
  • chain/evm/types/access_list.go (1 hunks)
  • chain/evm/types/access_list_tx.go (1 hunks)
  • chain/evm/types/chain_config.go (1 hunks)
  • chain/evm/types/codec.go (1 hunks)
  • chain/evm/types/dynamic_fee_tx.go (1 hunks)
  • chain/evm/types/errors.go (1 hunks)
  • chain/evm/types/eth.go (1 hunks)
  • chain/evm/types/events.go (1 hunks)
  • chain/evm/types/key.go (1 hunks)
  • chain/evm/types/legacy_tx.go (1 hunks)
  • chain/evm/types/logs.go (1 hunks)
  • chain/evm/types/msg.go (1 hunks)
  • chain/evm/types/params.go (1 hunks)
  • chain/evm/types/storage.go (1 hunks)
  • chain/evm/types/tx.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (12)
chain/crypto/ethsecp256k1/ethsecp256k1.go (1)
chain/crypto/ethsecp256k1/keys.pb.go (6)
  • PrivKey (75-77)
  • PrivKey (81-81)
  • PrivKey (82-84)
  • PubKey (30-32)
  • PubKey (35-35)
  • PubKey (36-38)
chain/evm/types/events.go (1)
chain/evm/types/msg.go (1)
  • TypeMsgEthereumTx (40-40)
chain/evm/types/tx.go (2)
chain/evm/types/utils.go (1)
  • DefaultPriorityReduction (23-23)
chain/evm/types/errors.go (1)
  • ErrExecutionReverted (49-49)
chain/evm/types/eth.go (3)
chain/evm/types/msg.go (1)
  • NewTx (48-53)
chain/types/int.go (1)
  • IsValidInt256 (59-61)
chain/evm/types/errors.go (1)
  • ErrInvalidGasFee (85-85)
chain/evm/types/logs.go (2)
chain/types/validation.go (1)
  • IsEmptyHash (12-14)
chain/evm/types/utils.go (1)
  • HexAddress (236-241)
chain/evm/types/chain_config.go (2)
chain/evm/types/chain_config.pb.go (9)
  • ChainConfig (29-85)
  • ChainConfig (89-89)
  • ChainConfig (90-92)
  • BlobScheduleConfig (141-146)
  • BlobScheduleConfig (150-150)
  • BlobScheduleConfig (151-153)
  • BlobConfig (209-213)
  • BlobConfig (217-217)
  • BlobConfig (218-220)
chain/evm/types/errors.go (1)
  • ErrInvalidChainConfig (55-55)
chain/evm/types/dynamic_fee_tx.go (5)
chain/types/int.go (2)
  • SafeNewIntFromBigInt (43-48)
  • IsValidInt256 (59-61)
chain/evm/types/access_list.go (2)
  • AccessList (10-10)
  • NewAccessList (14-34)
chain/evm/types/errors.go (2)
  • ErrInvalidGasCap (97-97)
  • ErrInvalidGasFee (85-85)
typeddata/typed_data.go (1)
  • ErrInvalidChainID (1285-1285)
chain/evm/types/utils.go (1)
  • EffectiveGasPrice (227-233)
chain/evm/precompiles/bank/i_bank_module.abigen.go (1)
ethereum/util/contract.go (2)
  • BoundContract (27-35)
  • Contract (15-23)
chain/evm/types/access_list_tx.go (4)
chain/types/int.go (2)
  • SafeNewIntFromBigInt (43-48)
  • IsValidInt256 (59-61)
chain/evm/types/access_list.go (2)
  • AccessList (10-10)
  • NewAccessList (14-34)
chain/evm/types/errors.go (1)
  • ErrInvalidGasFee (85-85)
typeddata/typed_data.go (1)
  • ErrInvalidChainID (1285-1285)
chain/evm/precompiles/staking/i_staking_module.abigen.go (2)
ethereum/util/contract.go (2)
  • BoundContract (27-35)
  • Contract (15-23)
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)
  • CosmosCoin (33-36)
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1)
ethereum/util/contract.go (2)
  • BoundContract (27-35)
  • Contract (15-23)
chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go (1)
ethereum/util/contract.go (2)
  • BoundContract (27-35)
  • Contract (15-23)
🪛 checkmake (0.2.2)
Makefile

[warning] 217-217: Missing required phony target "all"

(minphony)


[warning] 217-217: Missing required phony target "clean"

(minphony)


[warning] 217-217: Missing required phony target "test"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint
  • GitHub Check: run-tests
🔇 Additional comments (45)
auth_vote/authz_vote.go (2)

17-17: LGTM - Appropriate linter disable for example code.

The revive disable comment is appropriate for example/demo scripts where function length may exceed typical standards.


20-20: Check rpchttp.New Websocket Defaults

It appears rpchttp.New now only takes the RPC address (no explicit "/websocket" path). Please verify:

  • The import for rpchttp (e.g. github.com/cometbft/cometbft/rpc/client/http) is updated to the version where New accepts a single argument.
  • That New(network.TmEndpoint) still uses the correct default websocket endpoint under the hood.
  • Websocket-based calls (subscriptions/streams) continue to function as expected.
.github/workflows/golangci-lint.yml (3)

16-16: LGTM - Standard action version update.

Upgrading from actions/checkout@v3 to @v4 is a standard maintenance update.


22-22: LGTM - Action version update.

Upgrading from golangci/golangci-lint-action@v6 to @v8 brings latest improvements and bug fixes.


25-25: golangci-lint version v2.1.6 is valid

  • Version v2.1.6 was released on May 4, 2025 and exists in the official GitHub releases.
  • Although the latest available is v2.2.0 (June 28, 2025), pinning to v2.1.6 is acceptable for reproducible builds.
chain/crypto/ethsecp256k1/ethsecp256k1.go (2)

76-78: LGTM - Improved method receiver style.

Using an unnamed receiver is appropriate here since the receiver variable is not used in the method body. This follows Go best practices.


156-158: LGTM - Consistent receiver style improvement.

The unnamed receiver change is consistent with the PrivKey.Type() method and follows Go conventions for unused receivers.

chain/crypto/hd/algorithm.go (4)

23-24: LGTM - Updated project references.

The comment update from "Ethermint" to "Injective" correctly reflects the project context.


27-28: LGTM - Consistent comment update.

The Ledger algorithm comment update maintains consistency with the previous change.


52-54: LGTM - Improved receiver style.

Using an unnamed receiver is appropriate since the receiver isn't used in the method body.


97-104: LGTM - Consistent receiver improvement.

The unnamed receiver change follows the same style improvement pattern as the Name() method.

chain/evm/types/access_list.go (1)

14-34: LGTM - Well-structured conversion function.

The NewAccessList function correctly handles nil input and properly converts between ethereum core and protobuf-compatible formats.

chain/evm/types/tx.go (1)

47-52: Revert detection is consistent – no change required
Both NewVMErrorWithRet (in chain/evm/types/errors.go) and the Revert method (in chain/evm/types/tx.go) use the same constant vm.ErrExecutionReverted.Error(), so the string comparison is safe and will remain in sync.

chain/evm/types/events.go (1)

3-24: Well-structured event constants.

The event constants are well-organized and follow consistent naming patterns. Good practice using TypeMsgEthereumTx from the relevant code snippet to maintain consistency across the module.

chain/evm/types/storage.go (1)

15-30: Robust validation logic with good duplicate detection.

The validation implementation correctly handles duplicate keys and delegates to individual state validation. The error wrapping provides good context for debugging.

.golangci.yml (1)

1-67: Well-structured linter configuration upgrade.

The upgrade to version 2 format with restructured settings is a good improvement. The detailed revive configuration with cognitive complexity limits and line length constraints will help maintain code quality. The exclusions for generated code and common false positives are appropriate.

chain/evm/types/eth.go (1)

20-25: LGTM: Nil safety handled correctly.

The nil check prevents potential panics when accessing the underlying Transaction fields.

chain/crypto/hd/hd_path.go (2)

7-13: LGTM: Correct Ethereum constants and clear documentation.

The EIP-84 reference and BIP44 path usage are correctly implemented. The coin type 60 is the official Ethereum coin type.


21-32: Well-structured path iterator with proper error handling.

The function correctly parses the derivation path and provides appropriate iterator types based on the ledgerIter flag. Error propagation from ParseDerivationPath is handled correctly.

chain/erc20/types/codec.go (2)

15-19: Standard message registration pattern implemented correctly.

The codec registration follows Cosmos SDK conventions and includes all necessary message types.


35-42: Complete initialization sequence with proper codec registration.

The initialization properly registers codecs and seals the Amino codec to prevent further modifications.

chain/evm/types/logs.go (3)

29-47: Thorough validation with good error messaging.

The validation logic correctly checks for empty hashes, nil logs, and transaction hash consistency. The error messages are descriptive and helpful for debugging.


91-100: Efficient log conversion with proper capacity allocation.

The function correctly pre-allocates the slice capacity and handles empty input gracefully.


118-129: HexAddress usage is intentional and consistent

The custom HexAddress in chain/evm/types/utils.go omits the EIP-55 checksum for performance in state-machine contexts and is used uniformly in the EVM types (e.g. logs.go, msg.go). In contrast, user-facing code and examples rely on common.Address.Hex() for checksummed output. No inconsistencies detected—no changes required.

chain/evm/types/codec.go (2)

64-76: Robust packing function with proper error handling.

The function correctly validates the input type and provides meaningful error messages. The type assertion and Any packing logic are implemented correctly.


80-91: Unpacking function handles edge cases well.

The function properly checks for nil input and validates the cached value type. The error handling is consistent with the packing function.

chain/evm/types/params.go (1)

170-174: Use normalized address representation for duplicate detection.

Using raw bytes as map key could miss duplicates with different case representations.

-	if _, found := authorisedAddresses[string(addr.Bytes())]; found {
+	if _, found := authorisedAddresses[addr.Hex()]; found {
 		return fmt.Errorf("duplicate authorised address: %s", addrStr)
 	}
-	authorisedAddresses[string(addr.Bytes())] = struct{}{}
+	authorisedAddresses[addr.Hex()] = struct{}{}

Likely an incorrect or invalid review comment.

chain/evm/types/dynamic_fee_tx.go (2)

16-59: LGTM! Well-structured constructor with proper error handling.

The constructor correctly converts from go-ethereum transaction types with safe integer conversions to prevent overflow issues.


269-271: LGTM! Correct EIP-1559 effective gas price calculation.

The method properly delegates to the utility function that implements the EIP-1559 formula: min(baseFee + tip, feeCap).

chain/evm/types/errors.go (2)

16-40: LGTM! Well-organized error code constants.

Good practice reserving code 1 for internal errors and marking code 3 as JSON-RPC compliant for execution reverted errors.


226-256: LGTM! Robust VMError implementation with proper nil handling.

The implementation correctly handles both ErrExecutionReverted and other VM errors, with appropriate JSON encoding for ABCIInfo integration.

chain/evm/precompiles/bank/i_bank_module.abigen.go (1)

1-3: Auto-generated code looks standard.

This file follows the expected abigen patterns for Ethereum contract bindings.

chain/evm/types/legacy_tx.go (1)

204-217: LGTM! Correct implementation for legacy transactions.

The effective price methods correctly return the same values as their base counterparts since legacy transactions don't use dynamic pricing.

chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1)

1-3: Auto-generated code follows standard patterns.

This abigen-generated binding for MintBurnBankERC20 contract looks correct.

chain/evm/precompiles/staking/i_staking_module.abigen.go (1)

1-317: LGTM - Standard abigen-generated binding

This auto-generated Go binding follows the expected patterns and structure for Ethereum contract interactions. The code correctly implements the standard abigen interface with proper separation of concerns (caller, transactor, filterer) and session variants.

chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)

1-926: LGTM - Comprehensive auto-generated exchange binding

This auto-generated binding provides comprehensive coverage of the exchange contract functionality with proper type safety and method variants. The extensive struct definitions and method implementations follow abigen best practices.

chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go (9)

1-30: Generated code follows proper abigen patterns.

The header, package declaration, and imports are correctly structured according to go-ethereum binding generation standards. The "DO NOT EDIT" warning and reference imports to suppress errors are appropriate patterns for generated code.


32-44: Metadata appears complete and well-structured.

The metadata includes a comprehensive ABI with all standard ERC20 functions, events, and error types. The deprecated variables provide appropriate backward compatibility while maintaining the standard abigen pattern.


46-61: Deployment function follows correct abigen patterns.

The deployment function properly handles ABI parsing, includes comprehensive error handling, and correctly initializes all binding components (Caller, Transactor, Filterer). The function signature matches the contract constructor requirements.


63-120: Type definitions provide comprehensive interaction patterns.

The struct definitions cover all standard go-ethereum binding patterns: embedded caller/transactor/filterer in the main contract type, session types for convenience, and raw types for low-level access. This provides appropriate flexibility for different interaction patterns.


122-165: Constructor functions provide complete binding options.

The constructor functions cover all standard binding patterns with proper error handling. The use of a helper function for the actual binding operation follows good DRY principles while providing specialized constructors for different use cases.


167-203: Raw methods provide proper low-level contract access.

The raw interaction methods correctly delegate to the underlying BoundContract and follow standard go-ethereum patterns for Call, Transfer, and Transact operations. The method signatures and error handling are consistent with the binding framework.


205-389: View method bindings provide complete ERC20 read functionality.

All standard ERC20 view functions are properly implemented with appropriate variants for different usage patterns. The type conversions and error handling follow correct go-ethereum binding patterns, providing reliable access to contract state.


391-452: Transaction method bindings provide complete ERC20 write functionality.

All standard ERC20 transaction functions are properly implemented with appropriate variants. The use of TransactOpts and return of transaction objects follows correct patterns for paid contract interactions.


454-760: Event handling provides comprehensive log processing capabilities.

The event handling implementation covers all standard patterns for Ethereum event processing: filtering, watching, parsing, and iteration. The subscription management properly handles errors, completion, and termination scenarios. Both Approval and Transfer events are fully supported with consistent patterns.

Comment on lines +38 to +55
func (al AccessList) ToEthAccessList() *ethtypes.AccessList {
var ethAccessList ethtypes.AccessList

for _, tuple := range al {
storageKeys := make([]common.Hash, len(tuple.StorageKeys))

for i := range tuple.StorageKeys {
storageKeys[i] = common.HexToHash(tuple.StorageKeys[i])
}

ethAccessList = append(ethAccessList, ethtypes.AccessTuple{
Address: common.HexToAddress(tuple.Address),
StorageKeys: storageKeys,
})
}

return &ethAccessList
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for invalid hex conversions.

The ToEthAccessList function performs hex string conversions that could fail with invalid input. Consider adding validation or error handling.

-func (al AccessList) ToEthAccessList() *ethtypes.AccessList {
+func (al AccessList) ToEthAccessList() (*ethtypes.AccessList, error) {
 	var ethAccessList ethtypes.AccessList

 	for _, tuple := range al {
 		storageKeys := make([]common.Hash, len(tuple.StorageKeys))

 		for i := range tuple.StorageKeys {
+			if !common.IsHexAddress(tuple.StorageKeys[i]) {
+				return nil, fmt.Errorf("invalid hex string for storage key: %s", tuple.StorageKeys[i])
+			}
 			storageKeys[i] = common.HexToHash(tuple.StorageKeys[i])
 		}

+		if !common.IsHexAddress(tuple.Address) {
+			return nil, fmt.Errorf("invalid hex address: %s", tuple.Address)
+		}
 		ethAccessList = append(ethAccessList, ethtypes.AccessTuple{
 			Address:     common.HexToAddress(tuple.Address),
 			StorageKeys: storageKeys,
 		})
 	}

-	return &ethAccessList
+	return &ethAccessList, nil
 }

You'll also need to import fmt and update all callers to handle the returned error.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In chain/evm/types/access_list.go around lines 38 to 55, the ToEthAccessList
function converts hex strings to hashes and addresses without error handling,
which can cause silent failures on invalid input. Modify the function to return
an error along with the AccessList pointer. Add validation for each hex string
conversion using appropriate parsing functions that return errors, and if any
conversion fails, return the error immediately. Update the function signature to
include an error return value and ensure all callers handle this error. Also,
import the "fmt" package to format error messages.

lint-all:
golangci-lint run --timeout=15m -v

.PHONY: copy-exchange-client tests coverage lint lint-last-commit lint-master lint-all extract-message-names
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Address missing .PHONY targets.

The static analysis correctly identifies missing standard .PHONY targets that improve Makefile reliability.

Add the missing .PHONY targets:

-.PHONY: copy-exchange-client tests coverage lint lint-last-commit lint-master lint-all extract-message-names
+.PHONY: all clean test copy-exchange-client tests coverage lint lint-last-commit lint-master lint-all extract-message-names

You'll also need to define the missing targets:

+all: copy-exchange-client copy-chain-types
+
+clean:
+	rm -rf chain exchange proto injective_data
+
+test: tests
+
 copy-exchange-client: clone-injective-indexer
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.PHONY: copy-exchange-client tests coverage lint lint-last-commit lint-master lint-all extract-message-names
.PHONY: all clean test copy-exchange-client tests coverage lint lint-last-commit lint-master lint-all extract-message-names
all: copy-exchange-client copy-chain-types
clean:
<tab>rm -rf chain exchange proto injective_data
test: tests
copy-exchange-client: clone-injective-indexer
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 217-217: Missing required phony target "all"

(minphony)


[warning] 217-217: Missing required phony target "clean"

(minphony)


[warning] 217-217: Missing required phony target "test"

(minphony)

🤖 Prompt for AI Agents
In the Makefile at line 217, the .PHONY declaration is missing some standard
targets which can cause issues with Makefile reliability. Add all missing
standard .PHONY targets to the list on line 217 to ensure they are treated as
phony targets. Additionally, define the corresponding missing targets in the
Makefile to avoid errors when these targets are invoked.

Comment on lines +39 to +48
func (tx *EthereumTx) Unmarshal(dst []byte) error {
if len(dst) == 0 {
tx.Transaction = nil
return nil
}
if tx.Transaction == nil {
tx.Transaction = new(ethtypes.Transaction)
}
return tx.UnmarshalBinary(dst)
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Potential memory issue with nil Transaction initialization.

The current implementation creates a new Transaction on line 45 but doesn't handle the case where UnmarshalBinary might fail after creating the new Transaction instance.

Consider improving error handling:

func (tx *EthereumTx) Unmarshal(dst []byte) error {
	if len(dst) == 0 {
		tx.Transaction = nil
		return nil
	}
-	if tx.Transaction == nil {
-		tx.Transaction = new(ethtypes.Transaction)
-	}
-	return tx.UnmarshalBinary(dst)
+	
+	// Create a temporary transaction to avoid corrupting the current state on error
+	tempTx := new(ethtypes.Transaction)
+	if err := tempTx.UnmarshalBinary(dst); err != nil {
+		return err
+	}
+	
+	tx.Transaction = tempTx
+	return nil
}
🤖 Prompt for AI Agents
In chain/evm/types/eth.go around lines 39 to 48, the method initializes
tx.Transaction with a new instance before calling UnmarshalBinary, but if
UnmarshalBinary fails, the partially initialized Transaction remains,
potentially causing memory issues. Modify the code to call UnmarshalBinary first
on a temporary variable or handle the error immediately after UnmarshalBinary,
and only assign the new Transaction to tx.Transaction if unmarshaling succeeds,
ensuring no partially initialized state persists.

Comment on lines +36 to +59
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgEthereumTx{},
)
registry.RegisterImplementations(
(*tx.TxExtensionOptionI)(nil),
&ExtensionOptionsEthereumTx{},
)
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgEthereumTx{},
&MsgUpdateParams{},
)
registry.RegisterInterface(
"injective.evm.v1.TxData",
(*TxData)(nil),
&DynamicFeeTx{},
&AccessListTx{},
&LegacyTx{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Duplicate MsgEthereumTx registration detected.

The MsgEthereumTx type is registered twice in the same interface registry, which is unnecessary and could lead to confusion.

Remove the duplicate registration:

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
	registry.RegisterImplementations(
		(*sdk.Msg)(nil),
		&MsgEthereumTx{},
	)
	registry.RegisterImplementations(
		(*tx.TxExtensionOptionI)(nil),
		&ExtensionOptionsEthereumTx{},
	)
	registry.RegisterImplementations(
		(*sdk.Msg)(nil),
-		&MsgEthereumTx{},
		&MsgUpdateParams{},
	)
	// ... rest of the function
}
🤖 Prompt for AI Agents
In chain/evm/types/codec.go between lines 36 and 59, the MsgEthereumTx type is
registered twice under the sdk.Msg interface. Remove the first registry call
that registers MsgEthereumTx alone, keeping only the later registration where
MsgEthereumTx and MsgUpdateParams are registered together to avoid duplicate
registrations.

Comment on lines +65 to +70
func ObjectGasUsedKey(txIndex int) []byte {
var key [1 + 8]byte
key[0] = prefixObjectGasUsed
binary.BigEndian.PutUint64(key[1:], uint64(txIndex))
return key[:]
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for negative index values.

The function converts int to uint64 without checking for negative values. This could lead to unexpected behavior if negative indices are passed.

Add validation:

 func ObjectGasUsedKey(txIndex int) []byte {
+	if txIndex < 0 {
+		panic("txIndex cannot be negative")
+	}
 	var key [1 + 8]byte
 	key[0] = prefixObjectGasUsed
 	binary.BigEndian.PutUint64(key[1:], uint64(txIndex))
 	return key[:]
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func ObjectGasUsedKey(txIndex int) []byte {
var key [1 + 8]byte
key[0] = prefixObjectGasUsed
binary.BigEndian.PutUint64(key[1:], uint64(txIndex))
return key[:]
}
func ObjectGasUsedKey(txIndex int) []byte {
if txIndex < 0 {
panic("txIndex cannot be negative")
}
var key [1 + 8]byte
key[0] = prefixObjectGasUsed
binary.BigEndian.PutUint64(key[1:], uint64(txIndex))
return key[:]
}
🤖 Prompt for AI Agents
In chain/evm/types/key.go around lines 65 to 70, the function ObjectGasUsedKey
converts an int txIndex to uint64 without checking for negative values, which
can cause unexpected behavior. Add validation at the start of the function to
check if txIndex is negative; if so, handle it appropriately, such as returning
an error or a nil slice, or panicking, depending on the function's usage
context. This prevents invalid negative indices from being processed.

tx := msg.AsTransaction()
txHash := ethSigner.Hash(tx)

sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes(), signing.SignMode_SIGN_MODE_TEXTUAL)
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the use of SIGN_MODE_TEXTUAL for Ethereum transactions.

Using SIGN_MODE_TEXTUAL for Ethereum transaction signing seems unusual. Ethereum typically uses ECDSA signatures.


🏁 Script executed:

#!/bin/bash
# Check how signing modes are used elsewhere in the codebase
rg -A 5 "SignByAddress.*SIGN_MODE" --type go

Length of output: 2281


Use SIGN_MODE_DIRECT for Ethereum transaction signing

The EVM module should use raw ECDSA signing (SIGN_MODE_DIRECT) rather than the textual mode. All other SignByAddress calls (including tests) use SIGN_MODE_DIRECT, so switch this to maintain consistency and produce a valid Ethereum signature.

• File: chain/evm/types/msg.go
Line: 231

- sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes(), signing.SignMode_SIGN_MODE_TEXTUAL)
+ sig, _, err := keyringSigner.SignByAddress(from, txHash.Bytes(), signing.SignMode_SIGN_MODE_DIRECT)
🤖 Prompt for AI Agents
In chain/evm/types/msg.go at line 231, the SignByAddress call uses
SIGN_MODE_TEXTUAL, but it should use SIGN_MODE_DIRECT for Ethereum transaction
signing to ensure consistency and validity. Change the signing mode argument
from signing.SignMode_SIGN_MODE_TEXTUAL to signing.SignMode_SIGN_MODE_DIRECT in
the SignByAddress call.

Comment on lines +270 to +277
// fallback to legacy format
txData, err := UnpackTxData(msg.Data)
if err != nil {
return nil
}
msg.Raw = NewEthereumTx(txData.AsEthereumData())
return msg.Raw.Transaction
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle error from UnpackTxData properly.

The error from UnpackTxData is ignored, which could hide issues and cause the function to return nil.

Consider logging the error or panicking:

 	txData, err := UnpackTxData(msg.Data)
 	if err != nil {
-		return nil
+		panic(fmt.Sprintf("failed to unpack legacy tx data: %v", err))
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// fallback to legacy format
txData, err := UnpackTxData(msg.Data)
if err != nil {
return nil
}
msg.Raw = NewEthereumTx(txData.AsEthereumData())
return msg.Raw.Transaction
}
// fallback to legacy format
txData, err := UnpackTxData(msg.Data)
if err != nil {
panic(fmt.Sprintf("failed to unpack legacy tx data: %v", err))
}
msg.Raw = NewEthereumTx(txData.AsEthereumData())
return msg.Raw.Transaction
}
🤖 Prompt for AI Agents
In chain/evm/types/msg.go around lines 270 to 277, the error returned from
UnpackTxData is currently ignored, causing the function to return nil silently.
Modify the code to properly handle this error by either logging the error with
relevant context or panicking to avoid hiding the issue. This ensures that any
problems during UnpackTxData are visible and can be addressed promptly.

Comment on lines +177 to +180
if chainID != nil {
chainIDInt := sdkmath.NewIntFromBigInt(chainID)
tx.ChainID = &chainIDInt
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for chain ID bounds.

The chain ID is converted without checking if it fits within valid bounds.

 	if chainID != nil {
+		if !types.IsValidInt256(chainID) {
+			panic("chain ID out of bounds")
+		}
 		chainIDInt := sdkmath.NewIntFromBigInt(chainID)
 		tx.ChainID = &chainIDInt
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if chainID != nil {
chainIDInt := sdkmath.NewIntFromBigInt(chainID)
tx.ChainID = &chainIDInt
}
if chainID != nil {
if !types.IsValidInt256(chainID) {
panic("chain ID out of bounds")
}
chainIDInt := sdkmath.NewIntFromBigInt(chainID)
tx.ChainID = &chainIDInt
}
🤖 Prompt for AI Agents
In chain/evm/types/access_list_tx.go around lines 177 to 180, the chain ID is
converted to an integer without validating if it falls within acceptable bounds.
Add validation logic to check that the chain ID is within the valid range before
assigning it to tx.ChainID. If the chain ID is out of bounds, handle the error
appropriately to prevent invalid values from being set.

Comment on lines +248 to +253
if tx.GetChainID() == nil {
return errorsmod.Wrap(
errortypes.ErrInvalidChainID,
"chain ID must be present on AccessList txs",
)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the error message - this is DynamicFeeTx, not AccessListTx.

The error message incorrectly refers to AccessList transactions.

-			"chain ID must be present on AccessList txs",
+			"chain ID must be present on DynamicFee txs",
🤖 Prompt for AI Agents
In chain/evm/types/dynamic_fee_tx.go around lines 248 to 253, the error message
incorrectly mentions "AccessList txs" instead of "DynamicFeeTx". Update the
error message string to correctly refer to "DynamicFeeTx" to accurately reflect
the transaction type.

Comment on lines +123 to +125
// AsEthereumData returns an AccessListTx transaction tx from the proto-formatted
// TxData defined on the Cosmos EVM.
func (tx *LegacyTx) AsEthereumData() ethtypes.TxData {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the incorrect comment - this returns LegacyTx, not AccessListTx.

-// AsEthereumData returns an AccessListTx transaction tx from the proto-formatted
+// AsEthereumData returns a LegacyTx transaction tx from the proto-formatted
// TxData defined on the Cosmos EVM.
🤖 Prompt for AI Agents
In chain/evm/types/legacy_tx.go around lines 123 to 125, the comment incorrectly
states that the function returns an AccessListTx transaction, but it actually
returns a LegacyTx. Update the comment to accurately describe that the function
returns a LegacyTx transaction from the proto-formatted TxData defined on the
Cosmos EVM.

@maxim-inj
Copy link
Collaborator

@dbrajovic
This is not the correct tag to stage the changes against.
Should be based on latest rc from there https://github.com/InjectiveLabs/sdk-go/releases
v1.58.0-rc5 And the branch is simply dev https://github.com/InjectiveLabs/sdk-go/tree/dev

@maxim-inj maxim-inj deleted the branch v1.58.x-evm-comet1 June 30, 2025 18:21
@maxim-inj maxim-inj closed this Jun 30, 2025
@dbrajovic dbrajovic deleted the proto/peggy-ratelimit branch July 1, 2025 12:03
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.

4 participants