Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
- [\#730](https://github.com/cosmos/evm/pull/730) Fix panic if evm mempool not used.
- [\#733](https://github.com/cosmos/evm/pull/733) Avoid rejecting tx with unsupported extension option for ExtensionOptionDynamicFeeTx.
- [\#736](https://github.com/cosmos/evm/pull/736) Add InitEvmCoinInfo upgrade to avoid panic when denom is not registered.
- Add `stateDB` and `callFromPrecompile` parameters to internal EVM messages.
- Fixed an issue with events missing from final transaction result.

### IMPROVEMENTS

Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ test-rpc-compat-stop:

.PHONY: localnet-start localnet-stop localnet-build-env localnet-build-nodes test-rpc-compat test-rpc-compat-stop

test-system: build-v04 build
test-system: build-v05 build
mkdir -p ./tests/systemtests/binaries/
cp $(BUILDDIR)/evmd ./tests/systemtests/binaries/
cd tests/systemtests/Counter && forge build
$(MAKE) -C tests/systemtests test

build-v04:
mkdir -p ./tests/systemtests/binaries/v0.4
git checkout v0.4.1
build-v05:
mkdir -p ./tests/systemtests/binaries/v0.5
git checkout v0.5.1
make build
cp $(BUILDDIR)/evmd ./tests/systemtests/binaries/v0.4
cp $(BUILDDIR)/evmd ./tests/systemtests/binaries/v0.5
git checkout -

mocks:
Expand Down
143 changes: 44 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,139 +1,84 @@
<img
src="repo_header.svg"
alt="Cosmos EVM - A plug-and-play solution that adds EVM compatibility and customizability to your chain"
/>
# Confidential Security Hotfix

**Please note**: This repo is undergoing changes while the code is being audited and tested. For the time being we will
be making v0.x releases. Some breaking changes might occur. Cosmos Labs will only mark the Cosmos EVM repository as stable with a v1
release after the audit, key stability features and benchmarking are completed.
⚠️ **This repository is confidential.**

**Visit the official documentation for Cosmos EVM**: [evm.cosmos.network](https://evm.cosmos.network/)
This repository contains a **private security hotfix for a critical Cosmos EVM vulnerability** that can lead to **fund loss and chain halts**. The issue is consensus-level, exploitable in practice, and has been locally reproduced.

## What is Cosmos EVM?
Details are intentionally limited during the private disclosure window.
Please **do not share, fork, or discuss publicly** until disclosure.

Cosmos EVM is a plug-and-play solution that adds EVM compatibility and customizability to your Cosmos SDK chain. Cosmos EVM equips Cosmos chains with complete Ethereum capabilities: Solidity smart contracts, Ethereum JSON-RPC, native support for the EVM wallet/token/user experience, and access to the entire Ethereum developer ecosystem. Its precompiles and extensions allow developers to leverage modules like [IBC](https://github.com/cosmos/ibc-go) with EVM and get native ERC-20 support for tokens on Cosmos.
Public disclosure is planned for **March 2nd**.

Cosmos EVM is customizable for your business use case, chain architecture, and performance needs.
Thank you for your continued dedication to maintaining a safe and secure ecosystem.

---

## Integration
## Upgrade Guidance

Cosmos EVM can be integrated into your existing chain
or added during the development of your upcoming chain launch
by importing Cosmos EVM as a go module library.
To reduce the risk of premature disclosure, it is **strongly recommended** that this fix is deployed via **compiled binaries distributed directly to validators**, rather than public source changes, until the disclosure window closes.

### Robust defaults
Upgrades must be performed in a **coordinated fashion**.

Cosmos EVM’s modules come out of the box with defaults that enable rapid VM deployment. Integrating all available modules into a blockchain provides:
### Hotfix Tags

- Exposed JSON-RPC endpoints for connectivity with EVM tooling like wallets such as [MetaMask](https://metamask.io/) and [Rabby](https://rabby.io/), and block explorers like [Blockscout](https://docs.blockscout.com/).
- EVM extensions that allow functionality that is native to Cosmos SDK modules to be accessible from Solidity smart contracts [Solidity](https://docs.soliditylang.org/en/v0.8.26/) smart contracts.
- Use of any IBC asset in the EVM.
The following private tag is provided:

All modules can be controlled by on-chain governance.
- `v0.6.x-papyrus-hotfix`

### Extensive customizability
---

Based on these robust defaults, the feature set is highly customizable:
## Applying the Hotfix

- **Permissioned EVM**- Implement customized access controls to either blacklist or whitelist individual addresses for calling and/or creating smart contracts on the network.
- **EVM Extensions** - Use custom EVM extensions to write custom business logic for your use case.
- **Single Token Representation v2 & ERC-20 Module** - The Single Token Representation v2 and our `x/erc20` module to aligns IBC and ERC-20 token representation to simplify and improve user experience.
- **EIP-1559 Fee Market Mechanism** - Customize fee structures and transaction surge management with the self-regulating fee market mechanism based on [EIP-1559 fee market](https://eips.ethereum.org/EIPS/eip-1559).
- **JSON-RPC Server** - There is full control over the exposed namespaces and [JSON-RPC server](https://cosmos-docs.mintlify.app/docs/api-reference/ethereum-json-rpc). Configurable parameters include custom timeouts for EVM calls or HTTP requests, maximum block gas, open connections, and more.
- **EIP-712 Signing** - Integrate the [EIP-712 signature](https://eips.ethereum.org/EIPS/eip-712) implementation to allow Cosmos SDK messages to be signed with EVM wallets like MetaMask. This supports structured data signing for arbitrary messages.
- **Custom Improvement Proposals (Opcodes)** - Any Cosmos EVM user is provided the opportunity to customize bits of their EVM opcodes and add new ones. Read more on [custom operations here](https://cosmos-docs.mintlify.app/docs/documentation/smart-contracts/custom-improvement-proposals#custom-improvement-proposals).
### 1. Update your Git config to use private repositories

## Compatibility with Ethereum
#### SSH Instructions

Is Cosmos EVM "Ethereum equivalent"? Ethereum-equivalence describes any EVM solution that is identical in transaction execution to the Ethereum client. On the other hand, Ethereum-compatible means that the EVM implementation can run every transaction that is valid on Ethereum, while also handling divergent transactions that are not valid on Ethereum.
First, configure your machine to use SSH for Git. More details can be found here: https://docs.github.com/en/authentication/connecting-to-github-with-ssh.

We describe Cosmos EVM as **forward-compatible** with Ethereum. It can run any valid smart contract from Ethereum and also implement new features that are not yet available on the standard Ethereum VM, thus moving the standard forward.

## Getting started

To run the example `evmd` chain, run the script using `./local_node.sh`
from the root folder of the repository.

### Migrations

We provide upgrade guides [here](./docs/migrations) for upgrading your chain from various Cosmos EVM versions.

### Testing

All test scripts are found in `Makefile` in the root of the repository.
Listed below are the commands for various tests:
To use SSH in `go mod` downloads, add these lines to `~/.gitconfig`:
```md
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
```

#### Unit Testing

```bash
make test-unit
```
#### HTTPS Instructions

#### Coverage Test
If you choose to use HTTPS, please follow the instructions here: https://go.dev/doc/faq#git_https.

This generates a code coverage file `filtered_coverage.txt` and prints out the
covered code percentage for the working files.

```bash
make test-unit-cover
```
### 2. Update `go.mod`

#### Fuzz Testing
Add a `replace` directive pointing to this repository:

```bash
make test-fuzz
```go
replace github.com/cosmos/evm => github.com/cosmos/evm-sec-papyrus v0.6.x-papyrus-hotfix
```

#### Solidity Tests
Upgrade Cosmos SDK to v0.53.6:

```bash
make test-solidity
```go
github.com/cosmos/cosmos-sdk v0.53.6
```

#### Benchmark Tests
Then, tidy using the `GOPRIVATE` variable:

```bash
make benchmark
GOPRIVATE=github.com/cosmos/evm-sec-papyrus go mod tidy
```

---

## Open-source License & Credits

Cosmos EVM is fully open-source under the Apache 2.0 license. It is a fork of [evmOS](https://github.com/evmos/OS). The Interchain Foundation funded [evmOS developers](https://github.com/evmos/OS) Tharsis to open-source the original evmOS codebase. Tharsis and evmOS performed the foundational work for EVM compatibility and
interoperability in Cosmos.

## Developer Community and Support

The issue list of this repo is exclusively for bug reports and feature requests. We have active, helpful communities on Discord, Telegram, and Slack.

**| Need Help? | Support & Community: [Discord](https://discord.com/invite/interchain) - [Telegram](https://t.me/CosmosOG) - [Talk to an Expert](https://cosmos.network/interest-form) - [Join the #Cosmos-tech Slack Channel](https://forms.gle/A8jawLgB8zuL1FN36) |**


## Maintainers
[Cosmos Labs](https://cosmoslabs.io/) maintains the core components of the stack: Cosmos SDK, CometBFT, IBC, Cosmos EVM, and various developer tools and frameworks. The detailed maintenance policy can be found [here](https://github.com/cosmos/security/blob/main/POLICY.md). In addition to developing and maintaining the Cosmos Stack, Cosmos Labs provides advisory and engineering services for blockchain solutions. [Get in touch with Cosmos Labs](https://www.cosmoslabs.io/contact).

Cosmos Labs is a wholly-owned subsidiary of the [Interchain Foundation](https://interchain.io/), the Swiss nonprofit responsible for treasury management, funding public goods, and supporting governance for Cosmos.

The Cosmos Stack is supported by a robust community of open-source contributors.

## Contributing to Cosmos EVM

We welcome open source contributions and discussions! For more on contributing, read the [guide](./CONTRIBUTING.md).

### Key Contributors to Cosmos EVM
### 2. Build and Deploy

We would like to thank our key contributors at [B-Harvest](https://bharvest.io/) and
[Mantra](https://www.mantrachain.io/) for contributing to and helping us drive the development of Cosmos EVM.
For complete API-breaking changes and instructions, refer to the [migration docs](https://github.com/cosmos/evm-sec-papyrus/blob/release/v0.6.x/docs/migrations/v0.5.x_to_v0.6.0.md).

## Documentation and Resources
Rebuild your node binary using your standard process, distribute the compiled binary to validators, and perform a rolling upgrade.

### Documentation
Visit the official documentation for Cosmos EVM: [evm.cosmos.network](https://evm.cosmos.network/)
---

### Cosmos Stack Libraries
## Notes

- [Cosmos SDK](http://github.com/cosmos/cosmos-sdk) - A framework for building
applications in Golang
- [The Inter-Blockchain Communication Protocol (IBC)](https://github.com/cosmos/ibc-go/) - A blockchain interoperability protocol that allows blockchains to transfer any type of data encoded in bytes.
- [CometBFT](https://github.com/cometbft/cometbft) - High-performance, 10k+ TPS configurable BFT consensus engine.
- Do not mirror this repository to public infrastructure
- Do not copy this repository to a public Github repository
- Do not reference this fix in public changelogs or releases before disclosure
4 changes: 2 additions & 2 deletions ante/cosmos/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)

var evmCodec codec.ProtoCodecMarshaler
var evmCodec codec.Codec

func init() {
registry := codectypes.NewInterfaceRegistry()
Expand Down Expand Up @@ -177,7 +177,7 @@ func VerifySignature(
return errorsmod.Wrap(errortypes.ErrNoSignatures, "tx doesn't contain any msgs to verify signature")
}

txBytes := legacytx.StdSignBytes(
txBytes := legacytx.StdSignBytes( //nolint:staticcheck // checking legacy type
signerData.ChainID,
signerData.AccountNumber,
signerData.Sequence,
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func FeeChecker(
}

feeCoins := feeTx.GetFee()
feeAmtDec := sdkmath.LegacyNewDecFromInt(feeCoins.AmountOfNoDenomValidation(denom))
feeAmtDec := sdkmath.LegacyNewDecFromInt(feeCoins.AmountOfNoDenomValidation(denom)) //nolint:staticcheck // checking legacy type

feeCap := feeAmtDec.QuoInt(gas)
if feeCap.LT(baseFee) {
Expand Down
Loading
Loading