Skip to content

Commit

Permalink
account for cases where eth api says tx that exhausted block gas mete…
Browse files Browse the repository at this point in the history
…r succeeded
  • Loading branch information
galxy25 committed Dec 1, 2023
1 parent a6a4d9e commit 800a045
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BLOCKSCOUT_VERSION=v5.1.5-kava
INDEXER_CATCHUP_BLOCKS_BATCH_SIZE=1
INDEXER_CATCHUP_BLOCKS_CONCURRENCY=1
INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY=1
INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE=1
INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
INDEXER_BLOCK_REWARD_CONCURRENCY=1
INDEXER_RECEIPTS_CONCURRENCY=1
Expand Down
13 changes: 12 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,19 @@ cd /apps/indexer
mix deps.get
# compile sources for just this app
mix compile

# run the entire blockscout system
mix run

# run just a specific app
mix run indexer
```


Note that you should only run the above commands in the docker container, running them on your host may lead to conflicts in library binaries being different when installed on the host machine and the docker linux environment (if such an issue does occur, blowing away the `/_build` and `deps` in `blockscout-base/` should resolve such conflicts)

Since all dependencies and compiled artifacts are saved to the host, restarting the dev container and re-attaching vs code to it will not require re-fetching deps (unless the dependency list has changed) or re-compiling (unless the source code has changed from the last time it was compiled)

#### Indexer status

To see how far back the block explorer has indexed blocks, connect to the database and query to see what is the earliest block it has indexed, if these values change that means earlier and earlier blocks are being indexed (`refetch_needed` indicates whether the indexing was successful)
Expand Down Expand Up @@ -288,7 +299,7 @@ count
1808591
```

Query for blockscout database state for a given transaction (removing the `0x` prefix from the transaciton of interest)
Query for blockscout database state for a given transaction (removing the `0x` prefix from the transaction of interest)

```sql
select * from transactions where hash = decode('080a9c8c6bde6320dac69dd8639172aca893d357904f7a1ad37debf17bfec79f','hex');
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local:
cd blockscout && \
docker build ./ -f local.Dockerfile -t ${IMAGE_NAME}:${LOCAL_IMAGE_TAG} --build-arg BLOCKSCOUT_VERSION=${BLOCKSCOUT_DOCKER_VERSION}


.PHONY: build-db-exporter
# build the exporter image
build-db-exporter:
Expand Down Expand Up @@ -82,6 +83,7 @@ restart-postgres:
.PHONY: reset
# wipe state and restart the service and all it's dependencies
reset:
rm -rf postgres-data && \
docker compose up -d --build --remove-orphans --renew-anon-volumes --force-recreate

# wipe just the database state and restart just the database
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/apps/explorer/lib/explorer/chain/internal_transaction.ex b/apps/explorer/lib/explorer/chain/internal_transaction.ex
index c86bfa699f..1b2d0cbac6 100644
--- a/apps/explorer/lib/explorer/chain/internal_transaction.ex
+++ b/apps/explorer/lib/explorer/chain/internal_transaction.ex
@@ -3,6 +3,8 @@ defmodule Explorer.Chain.InternalTransaction do

use Explorer.Schema

+ require Logger
+
alias Explorer.Chain.{Address, Block, Data, Gas, Hash, PendingBlockOperation, Transaction, Wei}
alias Explorer.Chain.InternalTransaction.{Action, CallType, Result, Type}

@@ -502,7 +504,16 @@ defmodule Explorer.Chain.InternalTransaction do
# Validates that :call `type` changeset either has an `error` or both `gas_used` and `output`
defp validate_call_error_or_result(changeset) do
case get_field(changeset, :error) do
- nil -> validate_required(changeset, [:gas_used, :output], message: "can't be blank for successful call")
+ nil ->
+ if get_field(changeset, :gas_used) == nil && get_field(changeset, :output) == nil do
+ changeset |>
+ IO.inspect() |>
+ Ecto.Changeset.change(
+ error: "execution reverted"
+ )
+ else
+ validate_required(changeset, [:gas_used, :output], message: "can't be blank for successful call")
+ end
_ -> validate_disallowed(changeset, [:output], message: "can't be present for failed call")
end
end

0 comments on commit 800a045

Please sign in to comment.