Skip to content
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

Evm ingestion reform #255

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
38 changes: 37 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions evm/evm-data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@subsquid/evm-data",
"version": "0.0.0",
"description": "EVM data definition and fetching",
"license": "GPL-3.0-or-later",
"repository": "[email protected]:subsquid/squid.git",
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"src"
],
"main": "lib/index.js",
"scripts": {
"build": "rm -rf lib && tsc",
"test": "node lib/test.js"
},
"dependencies": {
"@subsquid/logger": "^1.3.3",
"@subsquid/util-internal": "^3.0.0",
"@subsquid/util-internal-ingest-tools": "^1.1.1",
"@subsquid/util-internal-range": "^0.2.0",
"@subsquid/util-internal-validation": "^0.3.0"
},
"peerDependencies": {
"@subsquid/rpc-client": "^4.6.0"
},
"devDependencies": {
"@subsquid/rpc-client": "^4.6.0",
"@types/node": "^18.18.14",
"typescript": "~5.3.2"
}
}
File renamed without changes.
1 change: 1 addition & 0 deletions evm/evm-data/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './base'
205 changes: 205 additions & 0 deletions evm/evm-data/src/normalization/data.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file is almost identical copy of evm.ts from evm-processor. this one has more fields marked as optional

Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import {Bytes, Bytes20, Bytes32, Bytes8} from '../base'


export interface BlockHeader {
height: number
hash: Bytes32
parentHash: Bytes32
nonce?: Bytes8
sha3Uncles?: Bytes32
logsBloom?: Bytes
transactionsRoot?: Bytes32
stateRoot?: Bytes32
receiptsRoot?: Bytes32
mixHash?: Bytes
miner?: Bytes20
difficulty?: bigint
totalDifficulty?: bigint
extraData?: Bytes
size?: bigint
gasLimit?: bigint
gasUsed?: bigint
timestamp?: number
baseFeePerGas?: bigint
/**
* This field is not supported by all currently deployed archives.
* Requesting it may cause internal error.
*/
l1BlockNumber?: number
}


export interface Transaction extends _Tx, _TxReceipt {
transactionIndex: number
sighash: Bytes
}


export interface _Tx {
hash: Bytes32
from: Bytes20
to?: Bytes20
gas?: bigint
gasPrice?: bigint
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
input: Bytes
nonce?: number
value?: bigint
v?: bigint
r?: Bytes32
s?: Bytes32
yParity?: number
chainId?: number
}


export interface _TxReceipt {
gasUsed?: bigint
cumulativeGasUsed?: bigint
effectiveGasPrice?: bigint
contractAddress?: Bytes32
type?: number
status?: number
}


export interface Log {
logIndex: number
transactionIndex: number
transactionHash: Bytes32
address: Bytes20
data: Bytes
topics: Bytes32[]
}


export interface TraceBase {
transactionIndex: number
traceAddress: number[]
subtraces: number
error: string | null
revertReason?: string
}


export interface TraceCreate extends TraceBase {
type: 'create'
action: TraceCreateAction
result?: TraceCreateResult
}


export interface TraceCreateAction {
from: Bytes20
value: bigint
gas: bigint
init: Bytes
}


export interface TraceCreateResult {
gasUsed: bigint
code: Bytes
address: Bytes20
}


export interface TraceCall extends TraceBase {
type: 'call'
action: TraceCallAction
result?: TraceCallResult
}


export interface TraceCallAction {
callType: string
from: Bytes20
to: Bytes20
value?: bigint
gas: bigint
input: Bytes
sighash: Bytes
}


export interface TraceCallResult {
gasUsed: bigint
output: Bytes
}


export interface TraceSuicide extends TraceBase {
type: 'suicide'
action: TraceSuicideAction
}


export interface TraceSuicideAction {
address: Bytes20
refundAddress: Bytes20
balance: bigint
}


export interface TraceReward extends TraceBase {
type: 'reward'
action: TraceRewardAction
}


export interface TraceRewardAction {
author: Bytes20
value: bigint
type: string
}


export type Trace = TraceCreate | TraceCall | TraceSuicide | TraceReward


export interface StateDiffBase {
transactionIndex: number
address: Bytes20
key: 'balance' | 'code' | 'nonce' | Bytes32
}


export interface StateDiffNoChange extends StateDiffBase {
kind: '='
prev?: null
next?: null
}


export interface StateDiffAdd extends StateDiffBase {
kind: '+'
prev?: null
next: Bytes
}


export interface StateDiffChange extends StateDiffBase {
kind: '*'
prev: Bytes
next: Bytes
}


export interface EvmStateDiffDelete extends StateDiffBase {
kind: '-'
prev: Bytes
next?: null
}


export type StateDiff = StateDiffNoChange | StateDiffAdd | StateDiffChange | EvmStateDiffDelete


export interface Block {
header: BlockHeader
transactions: Transaction[]
logs: Log[]
traces: Trace[]
stateDiffs: StateDiff[]
}
2 changes: 2 additions & 0 deletions evm/evm-data/src/normalization/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './data'
export * from './mapping'
Loading
Loading