Skip to content

Commit

Permalink
store tx type
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Mar 13, 2024
1 parent 72dc32a commit 152ba69
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 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/gofumpt@v0.6.0

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.6
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.7

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.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
56 changes: 31 additions & 25 deletions common/txsummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,37 @@ var TxSummaryEntryCSVHeader = []string{
"included_at_block_height",
"included_block_timestamp_ms",
"inclusion_delay_ms",
"tx_type",
}

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"`
// 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"`
// ChainID string `parquet:"name=chainId, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN"`
// TxType int64 `parquet:"name=txType, type=INT64"`

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"`
// 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"`

DataSize int64 `parquet:"name=dataSize, type=INT64"`
Data4Bytes string `parquet:"name=data4Bytes, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
// 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"`

Sources []string `parquet:"name=sources, type=MAP, convertedtype=LIST, valuetype=BYTE_ARRAY, valueconvertedtype=UTF8"`
// DataSize int64 `parquet:"name=dataSize, type=INT64"`
// Data4Bytes string `parquet:"name=data4Bytes, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`

// 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"`
}
// 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"`
// }

// TxSummaryEntry is a struct that represents a single transaction in the summary CSV and Parquet file
// see also https://github.com/xitongsys/parquet-go for more details on parquet tags
Expand All @@ -67,10 +70,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"`

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 +133,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 152ba69

Please sign in to comment.