From 68d31a663ef93b072e1535e25efc193c86bc1ce4 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Tue, 30 Jul 2024 08:31:09 +0800 Subject: [PATCH] fix: force revert (#603) Co-authored-by: nulnut <151493716+nulnut@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- x/evm/keeper/state_transition.go | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70912559f..4f6738c8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Change log +## [v6.1.0] + +* Fix: precompile contract revert issue + +--- + ## [v6.0.0] ### Features diff --git a/go.mod b/go.mod index b71f67d3c..3a4868c6a 100644 --- a/go.mod +++ b/go.mod @@ -210,5 +210,5 @@ replace ( // use for precompile replace ( github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc1 - github.com/evmos/ethermint => github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2 + github.com/evmos/ethermint => github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2.0.20240701110919-286276c8a9bd ) diff --git a/go.sum b/go.sum index 71b541445..2739c6b46 100644 --- a/go.sum +++ b/go.sum @@ -513,8 +513,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2 h1:Nd8qs+f/z9QFDYa2gEM9Hobq+0jCEYMMO+YBXj8FsQo= -github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2/go.mod h1:56iaMZDPOeBb1CA219jbZ8PttNFj/yrGKDqljLDSn64= +github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2.0.20240701110919-286276c8a9bd h1:tZDGwwYhAqUlzCUIIeV/EOSV444yhCr73Y9AR0yBGsE= +github.com/functionx/ethermint v0.22.0-fxcore-precompile-rc2.0.20240701110919-286276c8a9bd/go.mod h1:56iaMZDPOeBb1CA219jbZ8PttNFj/yrGKDqljLDSn64= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index b670cc599..3fe2a4916 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -238,6 +238,11 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, temporaryGasUsed := msg.Gas() - leftoverGas leftoverGas += evmkeeper.GasToRefund(stateDB.GetRefund(), temporaryGasUsed, refundQuotient) + // force revert error + if vmErr == nil && stateDB.ForceRevert() { + vmErr = types.ErrExecutionForceReverted + } + // EVM execution error needs to be available for the JSON-RPC client var vmError string if vmErr != nil {