Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
149 changes: 76 additions & 73 deletions internal/common/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@ import (
)

type Transaction struct {
ChainId *big.Int `json:"chain_id" ch:"chain_id" swaggertype:"string"`
Hash string `json:"hash" ch:"hash"`
Nonce uint64 `json:"nonce" ch:"nonce"`
BlockHash string `json:"block_hash" ch:"block_hash"`
BlockNumber *big.Int `json:"block_number" ch:"block_number" swaggertype:"string"`
BlockTimestamp time.Time `json:"block_timestamp" ch:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index" ch:"transaction_index"`
FromAddress string `json:"from_address" ch:"from_address"`
ToAddress string `json:"to_address" ch:"to_address"`
Value *big.Int `json:"value" ch:"value" swaggertype:"string"`
Gas uint64 `json:"gas" ch:"gas"`
GasPrice *big.Int `json:"gas_price" ch:"gas_price" swaggertype:"string"`
Data string `json:"data" ch:"data"`
FunctionSelector string `json:"function_selector" ch:"function_selector"`
MaxFeePerGas *big.Int `json:"max_fee_per_gas" ch:"max_fee_per_gas" swaggertype:"string"`
MaxPriorityFeePerGas *big.Int `json:"max_priority_fee_per_gas" ch:"max_priority_fee_per_gas" swaggertype:"string"`
MaxFeePerBlobGas *big.Int `json:"max_fee_per_blob_gas" ch:"max_fee_per_blob_gas" swaggertype:"string"`
BlobVersionedHashes []string `json:"blob_versioned_hashes" ch:"blob_versioned_hashes"`
TransactionType uint8 `json:"transaction_type" ch:"transaction_type"`
R *big.Int `json:"r" ch:"r" swaggertype:"string"`
S *big.Int `json:"s" ch:"s" swaggertype:"string"`
V *big.Int `json:"v" ch:"v" swaggertype:"string"`
AccessListJson *string `json:"access_list_json" ch:"access_list"`
ContractAddress *string `json:"contract_address" ch:"contract_address"`
GasUsed *uint64 `json:"gas_used" ch:"gas_used"`
CumulativeGasUsed *uint64 `json:"cumulative_gas_used" ch:"cumulative_gas_used"`
EffectiveGasPrice *big.Int `json:"effective_gas_price" ch:"effective_gas_price" swaggertype:"string"`
BlobGasUsed *uint64 `json:"blob_gas_used" ch:"blob_gas_used"`
BlobGasPrice *big.Int `json:"blob_gas_price" ch:"blob_gas_price" swaggertype:"string"`
LogsBloom *string `json:"logs_bloom" ch:"logs_bloom"`
Status *uint64 `json:"status" ch:"status"`
Sign int8 `json:"sign" ch:"sign"`
InsertTimestamp time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
ChainId *big.Int `json:"chain_id" ch:"chain_id" swaggertype:"string"`
Hash string `json:"hash" ch:"hash"`
Nonce uint64 `json:"nonce" ch:"nonce"`
BlockHash string `json:"block_hash" ch:"block_hash"`
BlockNumber *big.Int `json:"block_number" ch:"block_number" swaggertype:"string"`
BlockTimestamp time.Time `json:"block_timestamp" ch:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index" ch:"transaction_index"`
FromAddress string `json:"from_address" ch:"from_address"`
ToAddress string `json:"to_address" ch:"to_address"`
Value *big.Int `json:"value" ch:"value" swaggertype:"string"`
Gas uint64 `json:"gas" ch:"gas"`
GasPrice *big.Int `json:"gas_price" ch:"gas_price" swaggertype:"string"`
Data string `json:"data" ch:"data"`
FunctionSelector string `json:"function_selector" ch:"function_selector"`
MaxFeePerGas *big.Int `json:"max_fee_per_gas" ch:"max_fee_per_gas" swaggertype:"string"`
MaxPriorityFeePerGas *big.Int `json:"max_priority_fee_per_gas" ch:"max_priority_fee_per_gas" swaggertype:"string"`
MaxFeePerBlobGas *big.Int `json:"max_fee_per_blob_gas" ch:"max_fee_per_blob_gas" swaggertype:"string"`
BlobVersionedHashes []string `json:"blob_versioned_hashes" ch:"blob_versioned_hashes"`
TransactionType uint8 `json:"transaction_type" ch:"transaction_type"`
R *big.Int `json:"r" ch:"r" swaggertype:"string"`
S *big.Int `json:"s" ch:"s" swaggertype:"string"`
V *big.Int `json:"v" ch:"v" swaggertype:"string"`
AccessListJson *string `json:"access_list_json" ch:"access_list"`
AuthorizationListJson *string `json:"authorization_list_json" ch:"authorization_list"`
ContractAddress *string `json:"contract_address" ch:"contract_address"`
GasUsed *uint64 `json:"gas_used" ch:"gas_used"`
CumulativeGasUsed *uint64 `json:"cumulative_gas_used" ch:"cumulative_gas_used"`
EffectiveGasPrice *big.Int `json:"effective_gas_price" ch:"effective_gas_price" swaggertype:"string"`
BlobGasUsed *uint64 `json:"blob_gas_used" ch:"blob_gas_used"`
BlobGasPrice *big.Int `json:"blob_gas_price" ch:"blob_gas_price" swaggertype:"string"`
LogsBloom *string `json:"logs_bloom" ch:"logs_bloom"`
Status *uint64 `json:"status" ch:"status"`
Sign int8 `json:"sign" ch:"sign"`
InsertTimestamp time.Time `json:"insert_timestamp" ch:"insert_timestamp"`
}

type DecodedTransactionData struct {
Expand All @@ -60,37 +61,38 @@ type DecodedTransaction struct {

// TransactionModel represents a simplified Transaction structure for Swagger documentation
type TransactionModel struct {
ChainId string `json:"chain_id"`
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
BlockHash string `json:"block_hash"`
BlockNumber uint64 `json:"block_number"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Value string `json:"value"`
Gas uint64 `json:"gas"`
GasPrice string `json:"gas_price"`
Data string `json:"data"`
FunctionSelector string `json:"function_selector"`
MaxFeePerGas string `json:"max_fee_per_gas"`
MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas"`
MaxFeePerBlobGas *string `json:"max_fee_per_blob_gas,omitempty"`
BlobVersionedHashes []string `json:"blob_versioned_hashes,omitempty"`
TransactionType uint8 `json:"transaction_type"`
R string `json:"r"`
S string `json:"s"`
V string `json:"v"`
AccessListJson *string `json:"access_list_json"`
ContractAddress *string `json:"contract_address"`
GasUsed *uint64 `json:"gas_used"`
CumulativeGasUsed *uint64 `json:"cumulative_gas_used"`
EffectiveGasPrice *string `json:"effective_gas_price"`
BlobGasUsed *uint64 `json:"blob_gas_used"`
BlobGasPrice *string `json:"blob_gas_price"`
LogsBloom *string `json:"logs_bloom"`
Status *uint64 `json:"status"`
ChainId string `json:"chain_id"`
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
BlockHash string `json:"block_hash"`
BlockNumber uint64 `json:"block_number"`
BlockTimestamp uint64 `json:"block_timestamp"`
TransactionIndex uint64 `json:"transaction_index"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Value string `json:"value"`
Gas uint64 `json:"gas"`
GasPrice string `json:"gas_price"`
Data string `json:"data"`
FunctionSelector string `json:"function_selector"`
MaxFeePerGas string `json:"max_fee_per_gas"`
MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas"`
MaxFeePerBlobGas *string `json:"max_fee_per_blob_gas,omitempty"`
BlobVersionedHashes []string `json:"blob_versioned_hashes,omitempty"`
TransactionType uint8 `json:"transaction_type"`
R string `json:"r"`
S string `json:"s"`
V string `json:"v"`
AccessListJson *string `json:"access_list_json"`
AuthorizationListJson *string `json:"authorization_list_json"`
ContractAddress *string `json:"contract_address"`
GasUsed *uint64 `json:"gas_used"`
CumulativeGasUsed *uint64 `json:"cumulative_gas_used"`
EffectiveGasPrice *string `json:"effective_gas_price"`
BlobGasUsed *uint64 `json:"blob_gas_used"`
BlobGasPrice *string `json:"blob_gas_price"`
LogsBloom *string `json:"logs_bloom"`
Status *uint64 `json:"status"`
}

type DecodedTransactionDataModel struct {
Expand Down Expand Up @@ -199,15 +201,16 @@ func (t *Transaction) Serialize() TransactionModel {
v := t.MaxFeePerBlobGas.String()
return &v
}(),
BlobVersionedHashes: t.BlobVersionedHashes,
TransactionType: t.TransactionType,
R: t.R.String(),
S: t.S.String(),
V: t.V.String(),
AccessListJson: t.AccessListJson,
ContractAddress: t.ContractAddress,
GasUsed: t.GasUsed,
CumulativeGasUsed: t.CumulativeGasUsed,
BlobVersionedHashes: t.BlobVersionedHashes,
TransactionType: t.TransactionType,
R: t.R.String(),
S: t.S.String(),
V: t.V.String(),
AccessListJson: t.AccessListJson,
AuthorizationListJson: t.AuthorizationListJson,
ContractAddress: t.ContractAddress,
GasUsed: t.GasUsed,
CumulativeGasUsed: t.CumulativeGasUsed,
EffectiveGasPrice: func() *string {
if t.EffectiveGasPrice == nil {
return nil
Expand Down
10 changes: 10 additions & 0 deletions internal/rpc/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ func serializeTransaction(chainId *big.Int, tx map[string]interface{}, blockTime
}
return nil
}(),
AuthorizationListJson: func() *string {
if tx["authorizationList"] != nil {
jsonString := interfaceToJsonString(tx["authorizationList"])
if jsonString == "" {
return nil
}
return &jsonString
}
return nil
}(),
ContractAddress: func() *string {
if receipt != nil {
contractAddress := interfaceToString((*receipt)["contractAddress"])
Expand Down
6 changes: 4 additions & 2 deletions internal/storage/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var defaultTransactionFields = []string{
"transaction_index", "from_address", "to_address", "value", "gas", "gas_price",
"data", "function_selector", "max_fee_per_gas", "max_priority_fee_per_gas",
"max_fee_per_blob_gas", "blob_versioned_hashes", "transaction_type", "r", "s", "v",
"access_list", "contract_address", "gas_used", "cumulative_gas_used",
"access_list", "authorization_list", "contract_address", "gas_used", "cumulative_gas_used",
"effective_gas_price", "blob_gas_used", "blob_gas_price", "logs_bloom", "status",
}

Expand Down Expand Up @@ -195,7 +195,7 @@ func (c *ClickHouseConnector) insertTransactions(txs []common.Transaction, opt I
columns := []string{
"chain_id", "hash", "nonce", "block_hash", "block_number", "block_timestamp", "transaction_index", "from_address", "to_address", "value", "gas",
"gas_price", "data", "function_selector", "max_fee_per_gas", "max_priority_fee_per_gas", "max_fee_per_blob_gas", "blob_versioned_hashes", "transaction_type", "r", "s", "v", "access_list",
"contract_address", "gas_used", "cumulative_gas_used", "effective_gas_price", "blob_gas_used", "blob_gas_price", "logs_bloom", "status", "sign",
"authorization_list", "contract_address", "gas_used", "cumulative_gas_used", "effective_gas_price", "blob_gas_used", "blob_gas_price", "logs_bloom", "status", "sign",
}
if opt.AsDeleted {
columns = append(columns, "insert_timestamp")
Expand Down Expand Up @@ -237,6 +237,7 @@ func (c *ClickHouseConnector) insertTransactions(txs []common.Transaction, opt I
tx.S,
tx.V,
tx.AccessListJson,
tx.AuthorizationListJson,
tx.ContractAddress,
tx.GasUsed,
tx.CumulativeGasUsed,
Expand Down Expand Up @@ -1220,6 +1221,7 @@ func (c *ClickHouseConnector) InsertBlockData(data []common.BlockData) error {
tx.S,
tx.V,
tx.AccessListJson,
tx.AuthorizationListJson,
tx.ContractAddress,
tx.GasUsed,
tx.CumulativeGasUsed,
Expand Down
17 changes: 9 additions & 8 deletions internal/tools/clickhouse_create_insert_mvs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ SELECT
t.20 AS s,
t.21 AS v,
t.22 AS access_list,
t.23 AS contract_address,
t.24 AS gas_used,
t.25 AS cumulative_gas_used,
t.26 AS effective_gas_price,
t.27 AS blob_gas_used,
t.28 AS blob_gas_price,
t.29 AS logs_bloom,
t.30 AS status,
t.23 AS authorization_list,
t.24 AS contract_address,
t.25 AS gas_used,
t.26 AS cumulative_gas_used,
t.27 AS effective_gas_price,
t.28 AS blob_gas_used,
t.29 AS blob_gas_price,
t.30 AS logs_bloom,
t.31 AS status,
insert_timestamp,
sign
FROM inserts_null_table
Expand Down
1 change: 1 addition & 0 deletions internal/tools/clickhouse_create_insert_null_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CREATE TABLE IF NOT EXISTS inserts_null_table (
s UInt256,
v UInt256,
access_list Nullable(String),
authorization_list Nullable(String),
contract_address Nullable(FixedString(42)),
gas_used Nullable(UInt64),
cumulative_gas_used Nullable(UInt64),
Expand Down
1 change: 1 addition & 0 deletions internal/tools/clickhouse_create_transactions_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS transactions (
`s` UInt256,
`v` UInt256,
`access_list` Nullable(String),
`authorization_list` Nullable(String),
`contract_address` Nullable(FixedString(42)),
`gas_used` Nullable(UInt64),
`cumulative_gas_used` Nullable(UInt64),
Expand Down