Skip to content

Commit

Permalink
store tx type (#36)
Browse files Browse the repository at this point in the history
## 📝 Summary

Add Transaction Type (int) to CSV and Parquet output files. In
particular interesting to analyze the amount of blob transactions that
are going to be incoming after the Mainnet Dencun upgrade today.

---

## ✅ I have run these commands

* [x] `make lint`
* [x] `make test`
* [x] `go mod tidy`
  • Loading branch information
metachris authored Mar 13, 2024
1 parent 72dc32a commit 94065de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
run: go install mvdan.cc/[email protected]

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/[email protected].6
run: go install honnef.co/go/tools/cmd/[email protected].7

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/[email protected].1
run: go install github.com/golangci/golangci-lint/cmd/[email protected].2

- name: Lint
run: make lint
Expand Down
4 changes: 3 additions & 1 deletion common/txsfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ func ParseTx(timestampMs int64, rawTxHex string) (TxSummaryEntry, *types.Transac
Timestamp: timestampMs,
Hash: tx.Hash().Hex(),

ChainID: tx.ChainId().String(),
ChainID: tx.ChainId().String(),
TxType: int64(tx.Type()),

From: strings.ToLower(from.Hex()),
To: strings.ToLower(to),
Value: tx.Value().String(),
Expand Down
39 changes: 8 additions & 31 deletions common/txsummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,7 @@ var TxSummaryEntryCSVHeader = []string{
"included_at_block_height",
"included_block_timestamp_ms",
"inclusion_delay_ms",
}

type TxSummaryEntryNoRaw struct {
// The fields are written to CSV, and the order shouldn't change (for backwards compatibility)
Timestamp int64 `parquet:"name=timestamp, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
Hash string `parquet:"name=hash, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`

ChainID string `parquet:"name=chainId, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN"`
From string `parquet:"name=from, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
To string `parquet:"name=to, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
Value string `parquet:"name=value, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
Nonce string `parquet:"name=nonce, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`

Gas string `parquet:"name=gas, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
GasPrice string `parquet:"name=gasPrice, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
GasTipCap string `parquet:"name=gasTipCap, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
GasFeeCap string `parquet:"name=gasFeeCap, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`

DataSize int64 `parquet:"name=dataSize, type=INT64"`
Data4Bytes string `parquet:"name=data4Bytes, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`

Sources []string `parquet:"name=sources, type=MAP, convertedtype=LIST, valuetype=BYTE_ARRAY, valueconvertedtype=UTF8"`

// Inclusion stats
IncludedAtBlockHeight int64 `parquet:"name=includedAtBlockHeight, type=INT64"`
IncludedBlockTimestamp int64 `parquet:"name=includedBlockTimestamp, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
InclusionDelayMs int64 `parquet:"name=inclusionDelayMs, type=INT64"`
"tx_type",
}

// TxSummaryEntry is a struct that represents a single transaction in the summary CSV and Parquet file
Expand All @@ -67,10 +41,12 @@ type TxSummaryEntry struct {
Hash string `parquet:"name=hash, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`

ChainID string `parquet:"name=chainId, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN"`
From string `parquet:"name=from, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
To string `parquet:"name=to, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
Value string `parquet:"name=value, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
Nonce string `parquet:"name=nonce, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
TxType int64 `parquet:"name=txType, type=INT64, encoding=PLAIN_DICTIONARY"`

From string `parquet:"name=from, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
To string `parquet:"name=to, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
Value string `parquet:"name=value, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
Nonce string `parquet:"name=nonce, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`

Gas string `parquet:"name=gas, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
GasPrice string `parquet:"name=gasPrice, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN, omitstats=true"`
Expand Down Expand Up @@ -128,6 +104,7 @@ func (t *TxSummaryEntry) ToCSVRow() []string {
strconv.FormatInt(t.IncludedAtBlockHeight, 10),
strconv.FormatInt(t.IncludedBlockTimestamp, 10),
strconv.FormatInt(t.InclusionDelayMs, 10),
strconv.FormatInt(t.TxType, 10),
}
}

Expand Down

0 comments on commit 94065de

Please sign in to comment.