Skip to content

fix precompiles addresses #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged

fix precompiles addresses #3

merged 1 commit into from
Apr 3, 2025

Conversation

jeremyletang
Copy link

A previous change have introduce bug regarding the precompiles addresses:

  • kzgPointEvaluation address was changed from 0x10 to 0x4.
  • all precompile succeeding kzgPointEvaluation where shifted of -1 e.g: bls12381G1Add was set to 0x10 instead of 0x11

This PR fixes it.

Please see the references when reviewing: https://github.com/ethereum/go-ethereum/blob/v1.14.7/core/vm/contracts.go#L116-L135

Signed-off-by: Jeremy Letang <[email protected]>
@lukasz-zimnoch lukasz-zimnoch requested a review from a team April 3, 2025 07:27
@dimpar
Copy link
Collaborator

dimpar commented Apr 3, 2025

Tested on mezod by replacing go-ethereum dependency on my local machine with the local version of go-ethereum which is essentially this branch. Run 4 local nodes. Deployed Vyper contract with calling a fresh() function that were problematic.

#pragma version 0.3.10
struct PoolState:
  id               : uint256
  symbol           : String[65]
  base_token       : address
  quote_token      : address
  lp_token         : address
  base_reserves    : uint256
  quote_reserves   : uint256
  base_interest    : uint256
  quote_interest   : uint256
  base_collateral  : uint256
  quote_collateral : uint256

POOL_STORE: HashMap[uint256, PoolState]

@internal
def insert(new: PoolState) -> PoolState:
  self.POOL_STORE[new.id] = new
  return new

@external
def fresh(
  symbol     : String[65],
  base_token : address,
  quote_token: address,
  lp_token   : address
) -> PoolState:

  return self.insert(PoolState({
    id               : 1,
    symbol           : symbol,
    base_token       : base_token,
    quote_token      : quote_token,
    lp_token         : lp_token,
    base_reserves    : 0,
    quote_reserves   : 0,
    base_interest    : 0,
    quote_interest   : 0,
    base_collateral  : 0,
    quote_collateral : 0,
  }))

Checked that both contract creation and method exec txs were successful.

Screenshot 2025-04-03 at 16 43 12

This fix worked, looks good!

@dimpar dimpar merged commit 4de619b into master Apr 3, 2025
lukasz-zimnoch added a commit to mezo-org/mezod that referenced this pull request Apr 7, 2025
References:
https://linear.app/thesis-co/issue/TET-701/the-v100-rc1-matsnet-upgrade

### Introduction

Here we make the necessary preparations in order to execute the
`v1.0.0-rc1` upgrade on Mezo Matsnet. The mentioned upgrade will
introduce the following things:

- Patch for mixed precompile addresses
mezo-org/go-ethereum#3 and
#437

### Changes

The `v1.0.0-rc1` upgrade handler
The aforementioned changes introduced by `v1.0.0-rc1` are consensus
breaking and require a coordinated chain halt to be rolled out properly.
That said, we schedule an upgrade against the Upgrade precompile, which
is our EVM interface to the Cosmos SDK `x/upgrade` module. An upgrade
like that requires an upgrade handler to be created to satisfy the
Cosmos upgrade mechanism. Here we add such a handler. Although the
handler is a no-op, it is necessary so nodes can resume after the
coordinated chain halt.

### Testing

- Switch to `v1.0.0-rc0` which is the current version used on Matsnet.
- Spin up a fresh localnet using `make localnet-bin-clean && make
localnet-bin-init`.
- Start at least three nodes using `make localnet-bin-start`.
- Navigate to `/precompile/hardhat/`.
- Schedule an upgrade using `npx hardhat upgrade:submitPlan --signer
<poa-owner> --name v1.0.0-rc1 --height <height> --info ""`. Fetch
poa-owner using `npx hardhat validatorPool:owner`. As height, use your
current height + 10 blocks.
- Wait until the chain halts and stop your nodes.
- Switch to this branch `v1-fork-prep-rc1` and `make build` the new
binary.
- Restart your nodes. The chain should resume.

---

### Author's checklist

- [x] Provided the appropriate description of the pull request
- [x] Updated relevant unit and integration tests
- [x] Updated relevant documentation (`docs/`) or specification
(`x/<module>/spec/`)
- [x] Assigned myself in the `Assignees` field
- [x] Assigned `mezod-developers` in the `Reviewers` field and notified
them on Discord

### Reviewer's checklist

- [x] Confirmed all author's checklist items have been addressed
- [x] Considered security implications of the code changes
- [x] Considered performance implications of the code changes
- [x] Tested the changes and summarized covered scenarios and results in
a comment
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