Skip to content

Commit 7a7579f

Browse files
authored
Merge pull request #6 from InjectiveLabs/f/reverting-evm-msg
Feat: reverting EVM messages
2 parents 695bba7 + 7044f2e commit 7a7579f

26 files changed

+592
-688
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
cleanup-runs:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: rokroskar/workflow-run-cleanup-action@master
16-
env:
17-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18-
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/develop'"
19-
2012
build:
2113
runs-on: ubuntu-latest
2214
steps:

.github/workflows/deploy-contract.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,14 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
cleanup-runs:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: rokroskar/workflow-run-cleanup-action@master
16-
env:
17-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18-
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/develop'"
19-
2012
deploy:
2113
runs-on: ubuntu-latest
2214
steps:
2315
- uses: actions/checkout@v3
2416
- name: Use Node.js
2517
uses: actions/setup-node@v3
2618
with:
27-
node-version: '12.x'
19+
node-version: "12.x"
2820
- name: Install dependencies
2921
run: npm install
3022
- uses: technote-space/[email protected]

.github/workflows/test.yml

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
cleanup-runs:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: rokroskar/workflow-run-cleanup-action@master
18-
env:
19-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
20-
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
21-
2214
test-unit-cover:
2315
runs-on: ubuntu-latest
2416
steps:
@@ -38,192 +30,3 @@ jobs:
3830
run: |
3931
make test-unit-cover
4032
if: env.GIT_DIFF
41-
- uses: codecov/codecov-action@v4
42-
with:
43-
file: ./coverage.txt
44-
fail_ci_if_error: true
45-
token: ${{ secrets.CODECOV_TOKEN }}
46-
if: env.GIT_DIFF
47-
48-
test-importer:
49-
runs-on: ubuntu-latest
50-
timeout-minutes: 10
51-
steps:
52-
- uses: actions/setup-go@v4
53-
with:
54-
go-version: 1.21
55-
check-latest: true
56-
- uses: actions/checkout@v3
57-
- uses: technote-space/[email protected]
58-
id: git_diff
59-
with:
60-
PATTERNS: |
61-
**/**.go
62-
go.mod
63-
go.sum
64-
- name: test-importer
65-
run: |
66-
make test-import
67-
if: env.GIT_DIFF
68-
69-
test-rpc:
70-
runs-on: ubuntu-latest
71-
timeout-minutes: 30
72-
steps:
73-
- uses: actions/setup-go@v4
74-
with:
75-
go-version: 1.21
76-
check-latest: true
77-
- uses: actions/checkout@v3
78-
- uses: technote-space/[email protected]
79-
with:
80-
PATTERNS: |
81-
**/**.sol
82-
**/**.go
83-
go.mod
84-
go.sum
85-
- name: Test rpc endpoint
86-
run: |
87-
make test-rpc
88-
if: env.GIT_DIFF
89-
90-
integration_tests:
91-
runs-on: ubuntu-latest
92-
timeout-minutes: 60
93-
strategy:
94-
matrix:
95-
tests: [unmarked, upgrade, filter]
96-
env:
97-
TESTS_TO_RUN: ${{ matrix.tests }}
98-
steps:
99-
- uses: actions/checkout@v3
100-
- uses: cachix/install-nix-action@v26
101-
with:
102-
nix_path: nixpkgs=channel:nixos-23.11
103-
extra_nix_config: |
104-
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
105-
- uses: cachix/cachix-action@v14
106-
with:
107-
name: crypto-ethermint
108-
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
109-
- uses: technote-space/[email protected]
110-
with:
111-
PATTERNS: |
112-
**/**.sol
113-
**/**.go
114-
go.mod
115-
go.sum
116-
tests/integration_tests/**
117-
- name: Run integration tests
118-
run: make run-integration-tests
119-
if: env.GIT_DIFF
120-
- name: 'Tar debug files'
121-
if: failure()
122-
run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner .
123-
- uses: actions/upload-artifact@v3
124-
if: failure()
125-
with:
126-
name: debug-files
127-
path: debug_files.tar.gz
128-
if-no-files-found: ignore
129-
130-
upload-cache:
131-
if: github.event_name == 'push'
132-
needs: ["integration_tests"]
133-
strategy:
134-
matrix:
135-
os: [macos-latest]
136-
runs-on: ${{ matrix.os }}
137-
steps:
138-
- uses: actions/checkout@v3
139-
- uses: cachix/install-nix-action@v26
140-
with:
141-
nix_path: nixpkgs=channel:nixos-23.11
142-
extra_nix_config: |
143-
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
144-
- uses: cachix/cachix-action@v14
145-
with:
146-
name: crypto-ethermint
147-
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
148-
- name: 'instantiate integration test env'
149-
run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix)
150-
151-
test-sim-nondeterminism:
152-
runs-on: ubuntu-latest
153-
timeout-minutes: 120
154-
steps:
155-
- uses: actions/setup-go@v3
156-
with:
157-
go-version: 1.21
158-
check-latest: true
159-
- uses: actions/checkout@v3
160-
- uses: technote-space/[email protected]
161-
with:
162-
PATTERNS: |
163-
**/**.go
164-
go.mod
165-
go.sum
166-
- name: Test simulation nondeterminism
167-
run: |
168-
make test-sim-nondeterminism
169-
if: env.GIT_DIFF
170-
171-
test-sim-random-genesis-fast:
172-
runs-on: ubuntu-latest
173-
timeout-minutes: 120
174-
steps:
175-
- uses: actions/setup-go@v3
176-
with:
177-
go-version: 1.21
178-
check-latest: true
179-
- uses: actions/checkout@v3
180-
- uses: technote-space/[email protected]
181-
with:
182-
PATTERNS: |
183-
**/**.go
184-
go.mod
185-
go.sum
186-
- name: Test simulation with random genesis
187-
run: |
188-
make test-sim-random-genesis-fast
189-
if: env.GIT_DIFF
190-
191-
test-sim-import-export:
192-
runs-on: ubuntu-latest
193-
timeout-minutes: 120
194-
steps:
195-
- uses: actions/setup-go@v3
196-
with:
197-
go-version: 1.21
198-
check-latest: true
199-
- uses: actions/checkout@v3
200-
- uses: technote-space/[email protected]
201-
with:
202-
PATTERNS: |
203-
**/**.go
204-
go.mod
205-
go.sum
206-
- name: Simulation of import and export genesis
207-
run: |
208-
make test-sim-import-export
209-
if: env.GIT_DIFF
210-
211-
test-sim-after-import:
212-
runs-on: ubuntu-latest
213-
timeout-minutes: 120
214-
steps:
215-
- uses: actions/setup-go@v3
216-
with:
217-
go-version: 1.21
218-
check-latest: true
219-
- uses: actions/checkout@v3
220-
- uses: technote-space/[email protected]
221-
with:
222-
PATTERNS: |
223-
**/**.go
224-
go.mod
225-
go.sum
226-
- name: Test simulation after import
227-
run: |
228-
make test-sim-after-import
229-
if: env.GIT_DIFF

indexer/kv_indexer.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,20 @@ func NewKVIndexer(db dbm.DB, logger log.Logger, clientCtx client.Context) *KVInd
6161
// - Parses eth Tx infos from cosmos-sdk events for every TxResult
6262
// - Iterates over all the messages of the Tx
6363
// - Builds and stores a indexer.TxResult based on parsed events for every message
64-
func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxResult) error {
65-
height := block.Height
64+
func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxResult) (err error) {
65+
defer func(err *error) {
66+
if e := recover(); e != nil {
67+
kv.logger.Debug("panic during parsing block results", "error", e)
68+
69+
if ee, ok := e.(error); ok {
70+
*err = ee
71+
} else {
72+
*err = fmt.Errorf("panic during parsing block results: %v", e)
73+
}
74+
}
75+
}(&err)
76+
77+
kv.logger.Debug("(KVIndexer) IndexBlock", "height", block.Height, "txns:", len(block.Txs))
6678

6779
batch := kv.db.NewBatch()
6880
defer batch.Close()
@@ -71,13 +83,10 @@ func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxRe
7183
var ethTxIndex int32
7284
for txIndex, tx := range block.Txs {
7385
result := txResults[txIndex]
74-
if !rpctypes.TxSuccessOrExceedsBlockGasLimit(result) {
75-
continue
76-
}
7786

7887
tx, err := kv.clientCtx.TxConfig.TxDecoder()(tx)
7988
if err != nil {
80-
kv.logger.Error("Fail to decode tx", "err", err, "block", height, "txIndex", txIndex)
89+
kv.logger.Error("Fail to decode tx", "err", err, "block", block.Height, "txIndex", txIndex)
8190
continue
8291
}
8392

@@ -87,7 +96,7 @@ func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxRe
8796

8897
txs, err := rpctypes.ParseTxResult(result, tx)
8998
if err != nil {
90-
kv.logger.Error("Fail to parse event", "err", err, "block", height, "txIndex", txIndex)
99+
kv.logger.Error("Fail to parse event", "err", err, "block", block.Height, "txIndex", txIndex)
91100
continue
92101
}
93102

@@ -97,21 +106,23 @@ func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxRe
97106
var txHash common.Hash
98107

99108
txResult := ethermint.TxResult{
100-
Height: height,
109+
Height: block.Height,
101110
TxIndex: uint32(txIndex),
102111
MsgIndex: uint32(msgIndex),
103112
EthTxIndex: ethTxIndex,
104113
}
105-
if result.Code != abci.CodeTypeOK {
114+
if result.Code != abci.CodeTypeOK && result.Codespace != evmtypes.ModuleName {
106115
// exceeds block gas limit scenario, set gas used to gas limit because that's what's charged by ante handler.
107116
// some old versions don't emit any events, so workaround here directly.
108117
txResult.GasUsed = ethMsg.GetGas()
109118
txResult.Failed = true
110119
txHash = ethMsg.Hash()
111120
} else {
121+
// success or fail due to VM error
122+
112123
parsedTx := txs.GetTxByMsgIndex(msgIndex)
113124
if parsedTx == nil {
114-
kv.logger.Error("msg index not found in events", "msgIndex", msgIndex)
125+
kv.logger.Error("msg index not found in results", "msgIndex", msgIndex)
115126
continue
116127
}
117128
if parsedTx.EthTxIndex >= 0 && parsedTx.EthTxIndex != ethTxIndex {
@@ -127,7 +138,7 @@ func (kv *KVIndexer) IndexBlock(block *tmtypes.Block, txResults []*abci.ExecTxRe
127138
ethTxIndex++
128139

129140
if err := saveTxResult(kv.clientCtx.Codec, batch, txHash, &txResult); err != nil {
130-
return errorsmod.Wrapf(err, "IndexBlock %d", height)
141+
return errorsmod.Wrapf(err, "IndexBlock %d", block.Height)
131142
}
132143
}
133144
}

0 commit comments

Comments
 (0)