diff --git a/internal/common/transaction.go b/internal/common/transaction.go index 5321091..6e58629 100644 --- a/internal/common/transaction.go +++ b/internal/common/transaction.go @@ -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 { @@ -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 { @@ -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 diff --git a/internal/rpc/serializer.go b/internal/rpc/serializer.go index 56cb1c1..3f7e7e7 100644 --- a/internal/rpc/serializer.go +++ b/internal/rpc/serializer.go @@ -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"]) diff --git a/internal/storage/clickhouse.go b/internal/storage/clickhouse.go index 2685c6a..6a78d5e 100644 --- a/internal/storage/clickhouse.go +++ b/internal/storage/clickhouse.go @@ -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", } @@ -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") @@ -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, @@ -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, diff --git a/internal/tools/clickhouse_create_insert_mvs.sql b/internal/tools/clickhouse_create_insert_mvs.sql index ebd8007..0ea2673 100644 --- a/internal/tools/clickhouse_create_insert_mvs.sql +++ b/internal/tools/clickhouse_create_insert_mvs.sql @@ -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 diff --git a/internal/tools/clickhouse_create_insert_null_table.sql b/internal/tools/clickhouse_create_insert_null_table.sql index 435af9f..25fc90e 100644 --- a/internal/tools/clickhouse_create_insert_null_table.sql +++ b/internal/tools/clickhouse_create_insert_null_table.sql @@ -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), diff --git a/internal/tools/clickhouse_create_transactions_table.sql b/internal/tools/clickhouse_create_transactions_table.sql index d6bdf6b..b5ffc56 100644 --- a/internal/tools/clickhouse_create_transactions_table.sql +++ b/internal/tools/clickhouse_create_transactions_table.sql @@ -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),