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

Add raw transactions #121

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add raw transactions #121

wants to merge 3 commits into from

Conversation

Andrei-Dolgolev
Copy link
Contributor

@Andrei-Dolgolev Andrei-Dolgolev commented Jan 16, 2025

This pull request introduces changes to the DecodeProtoEntireBlockToLabels function across multiple files to include RawTransaction data in the output. The changes ensure that raw transaction data is collected and returned alongside event and transaction labels.

Depend on change on database:

moonstream-to/api#1138

example of table specification:

                                           Table "public.ethereum_transactions"
          Column          |           Type           | Collation | Nullable |                   Default
--------------------------+--------------------------+-----------+----------+----------------------------------------------
 hash                     | character varying(256)   |           | not null |
 block_number             | bigint                   |           | not null |
 block_timestamp          | bigint                   |           | not null |
 block_hash               | character varying(256)   |           | not null |
 from_address             | bytea                    |           |          |
 to_address               | bytea                    |           |          |
 gas                      | numeric(78,0)            |           |          |
 gas_price                | numeric(78,0)            |           |          |
 max_fee_per_gas          | numeric(78,0)            |           |          |
 max_priority_fee_per_gas | numeric(78,0)            |           |          |
 input                    | text                     |           |          |
 nonce                    | character varying(256)   |           |          |
 transaction_index        | bigint                   |           |          |
 transaction_type         | integer                  |           |          |
 value                    | numeric(78,0)            |           |          |
 indexed_at               | timestamp with time zone |           | not null | timezone('utc'::text, statement_timestamp())
Indexes:
    "pk_ethereum_transactions" PRIMARY KEY, btree (hash)
    "ix_ethereum_transactions_block_hash" btree (block_hash)
    "ix_ethereum_transactions_block_number" btree (block_number)
    "ix_ethereum_transactions_block_timestamp" btree (block_timestamp)
    "ix_ethereum_transactions_from_address" btree (from_address)
    "ix_ethereum_transactions_gas" btree (gas)
    "ix_ethereum_transactions_gas_price" btree (gas_price)
    "ix_ethereum_transactions_hash" UNIQUE, btree (hash)
    "ix_ethereum_transactions_to_address" btree (to_address)
    "ix_ethereum_transactions_value" btree (value)

Key changes include:

Addition of RawTransaction Data:

type RawTransaction struct {
	// Required fields
	Hash           string `json:"hash"`
	BlockHash      string `json:"blockHash"`
	BlockTimestamp uint64 `json:"block_timestamp"`
	BlockNumber    uint64 `json:"blockNumber"`
	FromAddress    string `json:"from"`
	ToAddress      string `json:"to"`
	Gas            string `json:"gas"`
	GasPrice       string `json:"gasPrice"`
	Input          string `json:"input"`
	Nonce          string `json:"nonce"`
	Value          string `json:"value"`

	// Optional fields that might be zero/empty
	MaxFeePerGas         string `json:"maxFeePerGas,omitempty"`
	MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas,omitempty"`
	TransactionIndex     uint64 `json:"transactionIndex"`
	TransactionType      uint64 `json:"transactionType,omitempty"`

	// Chain-specific optional fields
	L1BlockNumber *uint64 `json:"l1BlockNumber,omitempty"` // L2 chains only
}

Test Locally

To run your synchronizer or historical-sync with Seer:

  1. Clone the Seer repo:
    git clone [email protected]:G7DAO/seer.git
  2. Navigate to the Seer directory (if needed), then run:
    go run *.go synchronizer --chain arbitrum_one --customer-db-uri <your-local-database-uri>
    Replace with the same type of connection string you used in Alembic’s config. If you don’t provide --customer-db-uri, it will default to the production database, which you most likely don’t want when testing locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant