Skip to content

Firehose EVM tracer addition #1344

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

Open
wants to merge 133 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
e73963a
Firehose tracer addition
maoueh Apr 10, 2024
aa512a8
Merge tag 'v5.1.2' into release/firehose
maoueh May 2, 2024
e6bdc65
Merge tag 'v5.2.0' into release/firehose
maoueh May 3, 2024
e05ef46
Firehose tracer addition
maoueh Apr 10, 2024
ad9f914
Merge tag 'v5.5.2' into feature/firehose-tracer
maoueh May 27, 2024
16f73c4
Merge branch 'feature/firehose-tracer' into release/firehose
maoueh May 27, 2024
cccdf48
Improved panic handling ensuring we always print a stack trace when F…
maoueh Jun 12, 2024
ab01128
Improved caller reporting when there is an invalid state
maoueh Jun 12, 2024
67bd0af
Fixed bug with system call not correctly wired leading to panics when…
maoueh Jun 12, 2024
8418897
The tracing in `precompiles/bank/bank.go` needs to use `GetEVMAddress…
maoueh Jun 13, 2024
a13290a
Dockerfile to build Docker version for StreamingFast version
maoueh Jun 19, 2024
ec72741
Merge tag 'v5.5.5' into feature/firehose-tracer
maoueh Jun 19, 2024
f7dee2a
Merge branch 'feature/firehose-tracer' into release/firehose
maoueh Jun 19, 2024
60c3ad3
Improved Docker to pull `libwasmvm` dependency
maoueh Jun 19, 2024
9128e48
Added StreamingFast readme
maoueh Jun 20, 2024
a03050c
Adjusted a bit the instructions
maoueh Jun 20, 2024
bb6f115
Use v5.5.6 everywhere
maoueh Jun 21, 2024
98994b7
Fix seidb default config value for KeepLastVersion
yzang2019 Jul 3, 2024
9612ef1
Fix unit test
yzang2019 Jul 3, 2024
9dd002e
Update go mod
yzang2019 Jul 3, 2024
6bad612
Add upgrade handler for v5.6.2
udpatil Jul 8, 2024
2cc7a28
Merge tag 'v5.6.2' into feature/firehose-tracer-at-latest-release-tag
maoueh Jul 9, 2024
e7096af
Fixed a bug on parallel execution
maoueh Jul 9, 2024
ebbaa2e
Fixed missing handling of some system calls when running using the pa…
maoueh Jul 10, 2024
dbd9193
Fixed bug when re-ordering multiple system calls
maoueh Jul 10, 2024
8a8244d
Go mod tidy
maoueh Jul 10, 2024
c8c9246
Enabling Docker package building (trying at least)
maoueh Jul 10, 2024
6ba8ea3
More fixed to caching and general build
maoueh Jul 10, 2024
9612038
Fixed GitHub Actions tag push
maoueh Jul 10, 2024
7ae491f
GitHub release allow for any tags
maoueh Jul 10, 2024
7780d40
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Jul 10, 2024
92ee5ae
Add v5.7.0 upgrade
philipsu522 Jul 22, 2024
ca362fd
Merge remote-tracking branch 'origin/v5.7.0-release' into feature/fir…
maoueh Jul 24, 2024
e41491b
First pass in supporting new logs/receipt added on some transaction
maoueh Jul 26, 2024
05a0e9a
Merge tag 'v5.7.1' into feature/firehose-tracer-at-latest-release-tag
maoueh Jul 26, 2024
0349552
Added integration tests to simulate multiple CW20 synthetic logs
maoueh Jul 26, 2024
25caefc
Removed leftover debugging statements
maoueh Jul 26, 2024
7d79e0a
Fix seidb default config value for KeepLastVersion
yzang2019 Jul 3, 2024
50d87a5
Fix unit test
yzang2019 Jul 3, 2024
fead719
remove serialize/deserialize for accesslist
codchen May 26, 2024
e3f67a0
disable accesslist
codchen May 27, 2024
93b3431
Revert "disable accesslist"
codchen May 27, 2024
fd2aade
optimize
codchen May 27, 2024
c2ff353
add cleanup
codchen Jun 10, 2024
d531f88
rebase
codchen Jun 10, 2024
83f9ec5
remove excess line
udpatil Aug 6, 2024
7e7a9ce
v5.7.5 release
udpatil Aug 6, 2024
8a92aa9
Fix log index on synthetic receipt (#1784)
codchen Jul 26, 2024
020f5be
Added possibility in `seid tx evm deploy` to pass constructor's payload
maoueh Jul 26, 2024
d6ece2c
Fixed ERC/CW bridge for both EVM and CoWasm cases and added Firehose …
maoueh Jul 29, 2024
fee9a06
Merge tag 'v5.7.5' into feature/firehose-tracer-at-latest-release-tag
maoueh Aug 7, 2024
cf1d6b5
Updated how the instance is detected to be ready
maoueh Aug 7, 2024
c08751e
Removed CoWasm signature extraction when creating corresponding EVM t…
maoueh Aug 7, 2024
118555e
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Aug 7, 2024
f7d899d
Bump tendermint for high gas patch
yzang2019 Aug 8, 2024
5b43a0b
Fixed when transaction is processed on synchronous algorithm and has …
maoueh Aug 9, 2024
80e74b4
Fixed previous fix by ensuring we do not tweak the state in serial ex…
maoueh Aug 9, 2024
dd69edd
Fixed Firehose integration to catch the bug that happened when OCC (p…
maoueh Aug 9, 2024
ec7dabb
Added Cosmvisor to built Docker image
maoueh Aug 9, 2024
d1ee82f
Fixed when transaction is processed on synchronous algorithm and has …
maoueh Aug 9, 2024
af0daed
Fixed previous fix by ensuring we do not tweak the state in serial ex…
maoueh Aug 9, 2024
a565f91
Fixed Firehose integration to catch the bug that happened when OCC (p…
maoueh Aug 9, 2024
ea58032
Fixed `OnSeiPostTxCosmosEvents` when EVM transaction but it was actua…
maoueh Aug 10, 2024
6859793
Bump seidb to fix receipt missing on restart issue (#1817)
yzang2019 Aug 19, 2024
740bfe8
Merge tag 'v5.6.3' into feature/firehose-tracer-at-latest-release-tag
maoueh Sep 13, 2024
b58ab5d
Merge tag 'v5.7.6' into feature/firehose-tracer-at-latest-release-tag
maoueh Sep 13, 2024
08963c6
Merge tag 'v5.8.0' into feature/firehose-tracer-at-latest-release-tag
maoueh Sep 13, 2024
1c8055f
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Sep 13, 2024
887fa1e
Fixed parallel execution tracing
maoueh Sep 13, 2024
8c2d04e
Updated to WASMVM 1.5.4
maoueh Sep 16, 2024
771d7da
Fix broken CoWasm interop tracing
maoueh Sep 17, 2024
2304d5e
v5.9.0-release changelog
philipsu522 Sep 24, 2024
aae700c
Add upgrade version
philipsu522 Sep 24, 2024
e742d5e
fix tx byte arr in synthetic endpoints (#1872)
jewei1997 Sep 26, 2024
f3e5fdf
Exclude only shell receipts from eth endpoints v5.9.0 (#1879)
jewei1997 Oct 1, 2024
58b6724
Merge tag 'v5.9.0' into feature/firehose-tracer-at-latest-release-tag
maoueh Oct 1, 2024
895159d
use infinite gas meter for wasm query context
udpatil Oct 3, 2024
7343a09
Merge tag 'v5.9.0-hotfix' into release/firehose
maoueh Oct 4, 2024
63b4f3c
Re-worked Dockerfile.sf to download `libwasmvm` as defined in `go.mod…
maoueh Oct 4, 2024
0c4d398
Merge tag 'v6.0.0' into feature/firehose-tracer-at-latest-release-tag
maoueh Nov 12, 2024
04bd71c
Fixed test and improved `bootstrap.sh` script
maoueh Nov 12, 2024
74bc411
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Nov 12, 2024
b13818b
v6.0.1 release
philipsu522 Nov 26, 2024
221b19e
Add upgrade
philipsu522 Nov 26, 2024
129a0ee
Fix max base fee upgrade (#1965)
jewei1997 Nov 26, 2024
04f19a2
revert: 150% gasUsed refund limit policy (#1967)
blindchaser Nov 27, 2024
bd696e9
Merge branch 'main' into v6.0.1-release
philipsu522 Nov 27, 2024
a5aba95
Ignore Version during Set Earliest Version (#1968)
Kbhat1 Nov 27, 2024
710256a
Merge branch 'main' into v6.0.1-release
philipsu522 Nov 27, 2024
c936a98
Merge tag 'v6.0.1' into feature/firehose-tracer-at-latest-release-tag
maoueh Dec 6, 2024
20ebfbc
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Dec 6, 2024
341e626
Fixed tracing adding billable gas to transaction which would have led…
maoueh Dec 6, 2024
f0d1173
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
maoueh Dec 6, 2024
1c87c2b
Fixed two more location where we could have consumed gas when tracing
maoueh Dec 10, 2024
d080d7a
Correctly handle out of gas panics leading to problem in defer
maoueh Dec 10, 2024
f65257d
Remove panic that was used for testing
maoueh Dec 10, 2024
6e9df77
Force a fake receipt for recovered panic
maoueh Dec 10, 2024
458a8cd
Remove the panic
maoueh Dec 10, 2024
9e69395
Fixed failed receipt to fit with RCP output
maoueh Dec 10, 2024
a592801
Preparing for re-starting Sei sync
maoueh Dec 10, 2024
ce76d86
Fixed complete transaction on failed trx via panic
maoueh Dec 10, 2024
adef7fb
Remove panic preparing for release
maoueh Dec 10, 2024
c3a5d5e
Last quick verification
maoueh Dec 10, 2024
b52c826
Getting ready for re-sync, fingers crossed for this time
maoueh Dec 10, 2024
ff362ca
Tweaked again to show block output
maoueh Dec 10, 2024
ef82a26
Preparing for release (sic)
maoueh Dec 10, 2024
7dee649
fix race condition
codchen Dec 30, 2024
d7575be
rebase
philipsu522 Jan 6, 2025
9289f1d
Add changelog
philipsu522 Jan 6, 2025
fe7f265
Bump tm
philipsu522 Jan 6, 2025
7bf5478
Fix 1155 events ctx
philipsu522 Jan 8, 2025
d9d6b08
Revert "Fix 1155 events ctx"
philipsu522 Jan 8, 2025
067ab50
Revert "Pointers contracts: support for ERC1155 and CW1155 contracts …
philipsu522 Jan 8, 2025
f17ec67
fix changelog
philipsu522 Jan 8, 2025
8a46488
Merge tag 'v6.0.2' into feature/firehose-tracer-at-latest-release-tag
maoueh Jan 13, 2025
233d4bd
Add v6.0.3 upgrade
philipsu522 Jan 24, 2025
b15ca2c
Changelog
philipsu522 Jan 24, 2025
47e2778
Properly encode ERC1155 translated batch event data
codchen Jan 27, 2025
de5a748
update changelog
philipsu522 Jan 27, 2025
dba2420
Avoid panic tx error message in debug trace (#2057)
jewei1997 Jan 27, 2025
0de12b3
Revert "fix changelog"
maoueh Feb 4, 2025
1c582b9
Reapply "Pointers contracts: support for ERC1155 and CW1155 contracts…
maoueh Feb 4, 2025
0742c87
Reapply "Fix 1155 events ctx"
maoueh Feb 4, 2025
dd289be
Revert "Fix 1155 events ctx"
maoueh Feb 4, 2025
ccf20c1
Revert "Bump tm"
maoueh Feb 4, 2025
46d4e8e
Revert "Add changelog"
maoueh Feb 4, 2025
b651afe
Revert "rebase"
maoueh Feb 4, 2025
70ddbd8
Revert "fix race condition"
maoueh Feb 4, 2025
810eff4
Merge tag 'v6.0.3' into HEAD
maoueh Feb 4, 2025
42eff8a
Fixed detection of Firehose being ready
maoueh Feb 4, 2025
f73d927
Merge tag 'v6.0.4' into feature/firehose-tracer-at-latest-release-tag
maoueh Mar 11, 2025
7e55a4a
Re-write how we run Firehose test reducing bootstrap problem and re-u…
maoueh Mar 11, 2025
ffb9e34
Merge tag 'v6.0.5' into feature/firehose-tracer-at-latest-release-tag
maoueh Mar 31, 2025
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ release/
build/
cache/

/seid-*
/libwasmvm.x86_64.so

# Local .terraform directories
**/.terraform

Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sei-tendermint
* [#263](https://github.com/sei-protocol/sei-tendermint/pull/263) Update ReapMaxBytesMaxGas to include estimated gas
* [#259](https://github.com/sei-protocol/sei-tendermint/pull/259) Add simulate flag to RequestBeginBlock
* [#258](https://github.com/sei-protocol/sei-tendermint/pull/258) Add utils to get RequestBeginBlock

## v6.0.3
sei-chain
* [#2057](https://github.com/sei-protocol/sei-chain/pull/2057) Avoid panic tx error message in debug trace
Expand Down Expand Up @@ -159,7 +159,7 @@ sei-tendermint

sei-db
* [#75](https://github.com/sei-protocol/sei-db/pull/75) Online archive node migration

## v5.9.0
sei-chain
* [#1867](https://github.com/sei-protocol/sei-chain/pull/1867) Add synthetic events in separate sei endpoints
Expand Down
63 changes: 63 additions & 0 deletions Dockerfile.sf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:22.04 AS base

WORKDIR /app

RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg tar jq vim wget

RUN curl -LO https://github.com/chmln/sd/releases/download/v1.0.0/sd-v1.0.0-x86_64-unknown-linux-gnu.tar.gz \
&& tar -xzf sd-v1.0.0-x86_64-unknown-linux-gnu.tar.gz \
&& cp sd-v1.0.0-x86_64-unknown-linux-gnu/sd /usr/local/bin/sd \
&& rm -rf sd-v1.0.0-x86_64-unknown-linux-gnu sd-v1.0.0-x86_64-unknown-linux-gnu.tar.gz

ENV PATH="/app:${PATH}"

FROM base AS fireeth_download

ARG FIREETH="v2.6.7"

# Download and extract the binary file
RUN curl -LO https://github.com/streamingfast/firehose-ethereum/releases/download/${FIREETH}/firehose-ethereum_linux_x86_64.tar.gz \
&& tar -xzf firehose-ethereum_linux_x86_64.tar.gz \
&& rm firehose-ethereum_linux_x86_64.tar.gz

FROM golang:1.22-alpine AS libwasmvm_download

COPY ./go.mod /work/go.mod
COPY ./go.sum /work/go.sum

# FIXME: Handle multi-arch build, for now we have hard-coded the x86_64 part, but we should be able to build for arm64 as well
RUN apk add --no-cache wget && cd /work; \
export ARCH=$(uname -m); \
export WASM_VERSION="$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}')"; \
wget -O "/lib/libwasmvm.x86_64.${WASM_VERSION}.so" https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm.x86_64.so && \
printf "${WASM_VERSION}" > /lib/libwasmvm.x86_64.so.version

FROM base AS cosmovisor_download

ARG COSMOVISOR="v1.5.0"

# Download and extract the binary file
RUN curl -LO https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2F${COSMOVISOR}/cosmovisor-${COSMOVISOR}-linux-amd64.tar.gz \
&& tar -xzf cosmovisor-${COSMOVISOR}-linux-amd64.tar.gz \
&& rm cosmovisor-${COSMOVISOR}-linux-amd64.tar.gz

FROM base AS base_with_gcloud

RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \
&& apt-get update -y \
&& apt-get install google-cloud-sdk -y

FROM base_with_gcloud

ARG SEID_BIN="seid"

COPY --from=fireeth_download /app/fireeth /app/fireeth
COPY --from=libwasmvm_download /lib/libwasmvm.x86_64.*.so /lib/
COPY --from=libwasmvm_download /lib/libwasmvm.x86_64.so.version /lib/

COPY ./${SEID_BIN} /app/seid

RUN chmod +x /app/fireeth && \
export WASM_VERSION=$(cat /lib/libwasmvm.x86_64.so.version) && \
ln -s /lib/libwasmvm.x86_64.${WASM_VERSION}.so /lib/libwasmvm.x86_64.so
76 changes: 76 additions & 0 deletions README.sf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## StreamingFast Sei Fork Notes

### Remotes & Branches

```bash
git remote set-url origin https://github.com/sei-protocol/sei-chain.git
git remote add sf git@github.com:streamingfast/sei-chain.git
```

We maintain 3 branches:

- `feature/firehose-tracer`
- `feature/firehose-tracer-at-latest-release-tag`
- `release/firehose`

The `release/firehose` contains Dockerfile and instructions how to build images, this is the branch that should be used to make releases.

The `feature/firehose-tracer` is the PR branch that tracks `origin/main` branch, `feature/firehose-tracer-at-latest-release-tag` is the same as `feature/firehose-tracer` but tracks the latest release tag, which as of time of writing is `v5.5.5`.

### Bumping to new version

```bash
git fetch origin

# Found correct tag to bump to, we will use `v5.5.6`
export VERSION=v5.5.6

git checkout feature/firehose-tracer-at-latest-release-tag
git pull

git merge "${VERSION:?}"
# Fix any conflicts
go test ./...
git commit

git checkout release/firehose
git pull

git merge feature/firehose-tracer-at-latest-release-tag
# Fix any conflicts and merge, but there is usually no conflicts in this step

git tag "${VERSION:?}-fh3.0"

git push feature/firehose-tracer-at-latest-release-tag release/firehose "${VERSION:?}-fh3.0"
```

#### Building Binary & Docker

Built manually for now on the GCP VM, here the commands we use to build it in our VM.

> [!IMPORTANT]
> The instructions below **must** be run on the VM itself and not on your developer's machine.

```bash
export SEID_REF=v5.5.6-fh3.0 \
&& sudo -u sei git -C /data/build/seid/ fetch origin \
&& sudo -u sei git -C /data/build/seid/ checkout "${SEID_REF:?}" \
&& sudo -u sei bash -c 'source /etc/profile.d/02-golang.sh && cd /data/build/seid && make install' \
&& sudo cp /home/sei/go/bin/seid /usr/local/bin/seid-"${SEID_REF:?}"
```

Then from your developer machine now, run the following commands which download from the VM the binary locally and then build a Docker image from it.

Adjust the `TAG` export to use a repository you control, the `SEID_REF` to fit with the correct version.

```
# Assumed to be in `sei-chain` root folder, replace `sei0` in scp command to fit your own machine's name

export SEID_REF=v5.5.6-fh3.0 \
&& export FIREETH=v2.6.2 \
&& export TAG="ghcr.io/streamingfast/firehose-ethereum:${FIREETH:?}-sei-${SEID_REF:?}" \
&& scp sei0:/usr/local/bin/seid-${SEID_REF:?} . \
&& docker build --platform=linux/amd64 --build-arg="FIREETH=${FIREETH:?}" --build-arg="SEID_BIN=seid-${SEID_REF:?}" -t "${TAG:?}" -f Dockerfile.sf . \
&& docker run --platform=linux/amd64 --rm -it "${TAG:?}" seid version \
&& docker push "${TAG:?}"
```
81 changes: 77 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"math"
"math/big"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -102,6 +103,9 @@ import (
ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ethcommon "github.com/ethereum/go-ethereum/common"
ethhexutil "github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
ethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/gorilla/mux"
Expand All @@ -126,6 +130,8 @@ import (
evmkeeper "github.com/sei-protocol/sei-chain/x/evm/keeper"
"github.com/sei-protocol/sei-chain/x/evm/querier"
"github.com/sei-protocol/sei-chain/x/evm/replay"
evmtracers "github.com/sei-protocol/sei-chain/x/evm/tracers"
"github.com/sei-protocol/sei-chain/x/evm/tracing"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
"github.com/sei-protocol/sei-chain/x/mint"
mintclient "github.com/sei-protocol/sei-chain/x/mint/client/cli"
Expand Down Expand Up @@ -370,6 +376,7 @@ type App struct {

encodingConfig appparams.EncodingConfig
evmRPCConfig evmrpc.Config
evmTracer *tracing.Hooks
lightInvarianceConfig LightInvarianceConfig

genesisImportConfig genesistypes.GenesisImportConfig
Expand Down Expand Up @@ -979,6 +986,15 @@ func New(

app.RegisterDeliverTxHook(app.AddCosmosEventsToEVMReceiptIfApplicable)

if app.evmRPCConfig.LiveEVMTracer != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's put this config under either https://github.com/sei-protocol/sei-chain/blob/main/x/evm/querier/config.go or a new config section, since it's used in the actual processing and not an RPC-side thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about:

...

[evm_tracing]
live_tracer = <name>

...

Does that sounds good?

chainConfig := evmtypes.DefaultChainConfig().EthereumConfig(app.EvmKeeper.ChainID(app.GetCheckCtx()))
evmTracer, err := evmtracers.NewBlockchainTracer(evmtracers.GlobalLiveTracerRegistry, app.evmRPCConfig.LiveEVMTracer, chainConfig)
if err != nil {
panic(fmt.Sprintf("error creating EVM tracer due to %s", err))
}
app.evmTracer = evmTracer
}

return app
}

Expand Down Expand Up @@ -1464,11 +1480,20 @@ func (app *App) ExecuteTxsConcurrently(ctx sdk.Context, txs [][]byte, typedTxs [
}

func (app *App) GetDeliverTxEntry(ctx sdk.Context, txIndex int, absoluateIndex int, bz []byte, tx sdk.Tx) (res *sdk.DeliverTxEntry) {
var txTracer sdk.TxTracer
if app.evmTracer != nil {
txTracer = app.evmTracer
if app.evmTracer.GetTxTracer != nil {
txTracer = app.evmTracer.GetTxTracer(absoluateIndex)
}
}

res = &sdk.DeliverTxEntry{
Request: abci.RequestDeliverTx{Tx: bz},
SdkTx: tx,
Checksum: sha256.Sum256(bz),
AbsoluteIndex: absoluateIndex,
TxTracer: txTracer,
}
if tx == nil {
return
Expand Down Expand Up @@ -1553,10 +1578,14 @@ func (app *App) BuildDependenciesAndRunTxs(ctx sdk.Context, txs [][]byte, typedT
return app.ProcessBlockSynchronous(ctx, txs, typedTxs, absoluteTxIndices), ctx
}

func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequest, lastCommit abci.CommitInfo, simulate bool) ([]abci.Event, []*abci.ExecTxResult, abci.ResponseEndBlock, error) {
func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequest, lastCommit abci.CommitInfo, simulate bool) (events []abci.Event, txResults []*abci.ExecTxResult, endBlockResp abci.ResponseEndBlock, err error) {
ctx = ctx.WithIsOCCEnabled(app.OccEnabled())

events := []abci.Event{}
if app.evmTracer != nil {
ctx = evmtracers.SetCtxBlockchainTracer(ctx, app.evmTracer)
}

events = []abci.Event{}
beginBlockReq := abci.RequestBeginBlock{
Hash: req.GetHash(),
ByzantineValidators: utils.Map(req.GetByzantineValidators(), func(mis abci.Misbehavior) abci.Evidence {
Expand All @@ -1583,9 +1612,16 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
events = append(events, beginBlockResp.Events...)

evmTxs := make([]*evmtypes.MsgEVMTransaction, len(txs)) // nil for non-EVM txs
txResults := make([]*abci.ExecTxResult, len(txs))
txResults = make([]*abci.ExecTxResult, len(txs))
typedTxs := app.DecodeTransactionsConcurrently(ctx, txs)

if app.evmTracer != nil {
header := ctx.BlockHeader()
app.evmTracer.OnSeiBlockStart(req.GetHash(), uint64(header.Size()), TmBlockHeaderToEVM(ctx, header, &app.EvmKeeper))
defer func() {
app.evmTracer.OnSeiBlockEnd(err)
}()
}
prioritizedTxs, otherTxs, prioritizedTypedTxs, otherTypedTxs, prioritizedIndices, otherIndices := app.PartitionPrioritizedTxs(ctx, txs, typedTxs)

// run the prioritized txs
Expand Down Expand Up @@ -1622,7 +1658,7 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
}
}

endBlockResp := app.EndBlock(ctx, abci.RequestEndBlock{
endBlockResp = app.EndBlock(ctx, abci.RequestEndBlock{
Height: req.GetHeight(),
BlockGasUsed: evmTotalGasUsed,
})
Expand Down Expand Up @@ -2038,3 +2074,40 @@ func init() {
// override max wasm size to 2MB
wasmtypes.MaxWasmSize = 2 * 1024 * 1024
}

func TmBlockHeaderToEVM(
ctx sdk.Context,
block tmproto.Header,
k *evmkeeper.Keeper,
) (header *ethtypes.Header) {
noGasBillingCtx := ctx.WithGasMeter(storetypes.NewNoConsumptionInfiniteGasMeter())

number := big.NewInt(block.Height)
lastHash := ethcommon.BytesToHash(block.LastBlockId.Hash)
appHash := ethcommon.BytesToHash(block.AppHash)
txHash := ethcommon.BytesToHash(block.DataHash)
resultHash := ethcommon.BytesToHash(block.LastResultsHash)
miner := ethcommon.BytesToAddress(block.ProposerAddress)
gasLimit, gasWanted := uint64(0), uint64(0)

header = &ethtypes.Header{
Number: number,
ParentHash: lastHash,
Nonce: ethtypes.BlockNonce{}, // inapplicable to Sei
MixDigest: ethcommon.Hash{}, // inapplicable to Sei
UncleHash: ethtypes.EmptyUncleHash, // inapplicable to Sei
Bloom: k.GetBlockBloom(noGasBillingCtx),
Root: appHash,
Coinbase: miner,
Difficulty: big.NewInt(0), // inapplicable to Sei
Extra: ethhexutil.Bytes{}, // inapplicable to Sei
GasLimit: gasLimit,
GasUsed: gasWanted,
Time: uint64(block.Time.Unix()),
TxHash: txHash,
ReceiptHash: resultHash,
BaseFee: k.GetBaseFeePerGas(noGasBillingCtx).RoundInt().BigInt(),
}

return
}
4 changes: 2 additions & 2 deletions app/eth_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
ethcore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/tracing"
ethtracing "github.com/ethereum/go-ethereum/core/tracing"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
ethtests "github.com/ethereum/go-ethereum/tests"
Expand Down Expand Up @@ -85,7 +85,7 @@ func Replay(a *App) {
for _, w := range b.Withdrawals() {
amount := new(big.Int).SetUint64(w.Amount)
amount = amount.Mul(amount, big.NewInt(params.GWei))
s.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal)
s.AddBalance(w.Address, amount, ethtracing.BalanceIncreaseWithdrawal)
}
_, _ = s.Finalize()
for _, tx := range b.Txs {
Expand Down
Loading