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

store tx type #36

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
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"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should have dictionary encoding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice thanks. done


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
Loading