Skip to content

Commit

Permalink
fix(mimicry): blob nill pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid committed Mar 11, 2024
1 parent 0c0cf1a commit 1586dc3
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 7 deletions.
128 changes: 128 additions & 0 deletions deploy/migrations/clickhouse/027_blob_txn.down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,131 @@ ALTER TABLE canonical_beacon_blob_sidecar_local on cluster '{cluster}'

ALTER TABLE canonical_beacon_blob_sidecar on cluster '{cluster}'
DROP COLUMN blob_empty_size;

ALTER TABLE block_native_mempool_transaction_local on cluster '{cluster}'
COMMENT COLUMN unique_key '',
COMMENT COLUMN updated_date_time '',
COMMENT COLUMN detecttime '',
COMMENT COLUMN hash '',
COMMENT COLUMN status '',
COMMENT COLUMN region '',
COMMENT COLUMN reorg '',
COMMENT COLUMN replace '',
COMMENT COLUMN curblocknumber '',
COMMENT COLUMN failurereason '',
COMMENT COLUMN blockspending '',
COMMENT COLUMN timepending '',
COMMENT COLUMN nonce '',
COMMENT COLUMN gas '',
COMMENT COLUMN gasprice '',
COMMENT COLUMN value '',
COMMENT COLUMN toaddress '',
COMMENT COLUMN fromaddress '',
COMMENT COLUMN datasize '',
COMMENT COLUMN data4bytes '',
COMMENT COLUMN network '',
COMMENT COLUMN type '',
COMMENT COLUMN maxpriorityfeepergas '',
COMMENT COLUMN maxfeepergas '',
COMMENT COLUMN basefeepergas '',
COMMENT COLUMN dropreason '',
COMMENT COLUMN rejectionreason '',
COMMENT COLUMN stuck '',
COMMENT COLUMN gasused '';

ALTER TABLE block_native_mempool_transaction on cluster '{cluster}'
COMMENT COLUMN unique_key '',
COMMENT COLUMN updated_date_time '',
COMMENT COLUMN detecttime '',
COMMENT COLUMN hash '',
COMMENT COLUMN status '',
COMMENT COLUMN region '',
COMMENT COLUMN reorg '',
COMMENT COLUMN replace '',
COMMENT COLUMN curblocknumber '',
COMMENT COLUMN failurereason '',
COMMENT COLUMN blockspending '',
COMMENT COLUMN timepending '',
COMMENT COLUMN nonce '',
COMMENT COLUMN gas '',
COMMENT COLUMN gasprice '',
COMMENT COLUMN value '',
COMMENT COLUMN toaddress '',
COMMENT COLUMN fromaddress '',
COMMENT COLUMN datasize '',
COMMENT COLUMN data4bytes '',
COMMENT COLUMN network '',
COMMENT COLUMN type '',
COMMENT COLUMN maxpriorityfeepergas '',
COMMENT COLUMN maxfeepergas '',
COMMENT COLUMN basefeepergas '',
COMMENT COLUMN dropreason '',
COMMENT COLUMN rejectionreason '',
COMMENT COLUMN stuck '',
COMMENT COLUMN gasused '';

ALTER TABLE canonical_beacon_proposer_duty_local on cluster '{cluster}'
COMMENT COLUMN unique_key '',
COMMENT COLUMN updated_date_time '',
COMMENT COLUMN event_date_time '',
COMMENT COLUMN slot '',
COMMENT COLUMN slot_start_date_time '',
COMMENT COLUMN epoch '',
COMMENT COLUMN epoch_start_date_time '',
COMMENT COLUMN proposer_validator_index '',
COMMENT COLUMN proposer_pubkey '',
COMMENT COLUMN meta_client_name '',
COMMENT COLUMN meta_client_id '',
COMMENT COLUMN meta_client_version '',
COMMENT COLUMN meta_client_implementation '',
COMMENT COLUMN meta_client_os '',
COMMENT COLUMN meta_client_ip '',
COMMENT COLUMN meta_client_geo_city '',
COMMENT COLUMN meta_client_geo_country '',
COMMENT COLUMN meta_client_geo_country_code '',
COMMENT COLUMN meta_client_geo_continent_code '',
COMMENT COLUMN meta_client_geo_longitude '',
COMMENT COLUMN meta_client_geo_latitude '',
COMMENT COLUMN meta_client_geo_autonomous_system_number '',
COMMENT COLUMN meta_client_geo_autonomous_system_organization '',
COMMENT COLUMN meta_network_id '',
COMMENT COLUMN meta_network_name '',
COMMENT COLUMN meta_consensus_version '',
COMMENT COLUMN meta_consensus_version_major '',
COMMENT COLUMN meta_consensus_version_minor '',
COMMENT COLUMN meta_consensus_version_patch '',
COMMENT COLUMN meta_consensus_implementation '',
COMMENT COLUMN meta_labels '';

ALTER TABLE canonical_beacon_proposer_duty on cluster '{cluster}'
COMMENT COLUMN unique_key '',
COMMENT COLUMN updated_date_time '',
COMMENT COLUMN event_date_time '',
COMMENT COLUMN slot '',
COMMENT COLUMN slot_start_date_time '',
COMMENT COLUMN epoch '',
COMMENT COLUMN epoch_start_date_time '',
COMMENT COLUMN proposer_validator_index '',
COMMENT COLUMN proposer_pubkey '',
COMMENT COLUMN meta_client_name '',
COMMENT COLUMN meta_client_id '',
COMMENT COLUMN meta_client_version '',
COMMENT COLUMN meta_client_implementation '',
COMMENT COLUMN meta_client_os '',
COMMENT COLUMN meta_client_ip '',
COMMENT COLUMN meta_client_geo_city '',
COMMENT COLUMN meta_client_geo_country '',
COMMENT COLUMN meta_client_geo_country_code '',
COMMENT COLUMN meta_client_geo_continent_code '',
COMMENT COLUMN meta_client_geo_longitude '',
COMMENT COLUMN meta_client_geo_latitude '',
COMMENT COLUMN meta_client_geo_autonomous_system_number '',
COMMENT COLUMN meta_client_geo_autonomous_system_organization '',
COMMENT COLUMN meta_network_id '',
COMMENT COLUMN meta_network_name '',
COMMENT COLUMN meta_consensus_version '',
COMMENT COLUMN meta_consensus_version_major '',
COMMENT COLUMN meta_consensus_version_minor '',
COMMENT COLUMN meta_consensus_version_patch '',
COMMENT COLUMN meta_consensus_implementation '',
COMMENT COLUMN meta_labels '';
128 changes: 128 additions & 0 deletions deploy/migrations/clickhouse/027_blob_txn.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,131 @@ COMMENT COLUMN blob_empty_size 'The total empty size of the blob in bytes';
ALTER TABLE canonical_beacon_blob_sidecar on cluster '{cluster}'
ADD COLUMN blob_empty_size Nullable(UInt32) Codec(ZSTD(1)) AFTER blob_size,
COMMENT COLUMN blob_empty_size 'The total empty size of the blob in bytes';

ALTER TABLE block_native_mempool_transaction_local on cluster '{cluster}'
COMMENT COLUMN unique_key 'Unique key for the row',
COMMENT COLUMN updated_date_time 'When this row was last updated',
COMMENT COLUMN detecttime 'Timestamp that the transaction was detected in mempool',
COMMENT COLUMN hash 'Unique identifier hash for a given transaction',
COMMENT COLUMN status 'Status of the transaction',
COMMENT COLUMN region 'The geographic region for the node that detected the transaction',
COMMENT COLUMN reorg 'If there was a reorg, refers to the blockhash of the reorg',
COMMENT COLUMN replace 'If the transaction was replaced (speedup/cancel), the transaction hash of the replacement',
COMMENT COLUMN curblocknumber 'The block number the event was detected in',
COMMENT COLUMN failurereason 'If a transaction failed, this field provides contextual information',
COMMENT COLUMN blockspending 'If a transaction was finalized (confirmed, failed), this refers to the number of blocks that the transaction was waiting to get on-chain',
COMMENT COLUMN timepending 'If a transaction was finalized (confirmed, failed), this refers to the time in milliseconds that the transaction was waiting to get on-chain',
COMMENT COLUMN nonce 'A unique number which counts the number of transactions sent from a given address',
COMMENT COLUMN gas 'The maximum number of gas units allowed for the transaction',
COMMENT COLUMN gasprice 'The price offered to the miner/validator per unit of gas. Denominated in wei',
COMMENT COLUMN value 'The amount of ETH transferred or sent to contract. Denominated in wei',
COMMENT COLUMN toaddress 'The destination of a given transaction',
COMMENT COLUMN fromaddress 'The source/initiator of a given transaction',
COMMENT COLUMN datasize 'The size of the call data of the transaction in bytes',
COMMENT COLUMN data4bytes 'The first 4 bytes of the call data of the transaction',
COMMENT COLUMN network 'The specific Ethereum network used',
COMMENT COLUMN type '"Post EIP-1559, this indicates how the gas parameters are submitted to the network: - type 0 - legacy - type 1 - usage of access lists according to EIP-2930 - type 2 - using maxpriorityfeepergas and maxfeepergas"',
COMMENT COLUMN maxpriorityfeepergas 'The maximum value for a tip offered to the miner/validator per unit of gas. The actual tip paid can be lower if (maxfee - basefee) < maxpriorityfee. Denominated in wei',
COMMENT COLUMN maxfeepergas 'The maximum value for the transaction fee (including basefee and tip) offered to the miner/validator per unit of gas. Denominated in wei',
COMMENT COLUMN basefeepergas 'The fee per unit of gas paid and burned for the curblocknumber. This fee is algorithmically determined. Denominated in wei',
COMMENT COLUMN dropreason 'If the transaction was dropped from the mempool, this describes the contextual reason for the drop',
COMMENT COLUMN rejectionreason 'If the transaction was rejected from the mempool, this describes the contextual reason for the rejection',
COMMENT COLUMN stuck 'A transaction was detected in the queued area of the mempool and is not eligible for inclusion in a block',
COMMENT COLUMN gasused 'If the transaction was published on-chain, this value indicates the amount of gas that was actually consumed. Denominated in wei';

ALTER TABLE block_native_mempool_transaction on cluster '{cluster}'
COMMENT COLUMN unique_key 'Unique key for the row',
COMMENT COLUMN updated_date_time 'When this row was last updated',
COMMENT COLUMN detecttime 'Timestamp that the transaction was detected in mempool',
COMMENT COLUMN hash 'Unique identifier hash for a given transaction',
COMMENT COLUMN status 'Status of the transaction',
COMMENT COLUMN region 'The geographic region for the node that detected the transaction',
COMMENT COLUMN reorg 'If there was a reorg, refers to the blockhash of the reorg',
COMMENT COLUMN replace 'If the transaction was replaced (speedup/cancel), the transaction hash of the replacement',
COMMENT COLUMN curblocknumber 'The block number the event was detected in',
COMMENT COLUMN failurereason 'If a transaction failed, this field provides contextual information',
COMMENT COLUMN blockspending 'If a transaction was finalized (confirmed, failed), this refers to the number of blocks that the transaction was waiting to get on-chain',
COMMENT COLUMN timepending 'If a transaction was finalized (confirmed, failed), this refers to the time in milliseconds that the transaction was waiting to get on-chain',
COMMENT COLUMN nonce 'A unique number which counts the number of transactions sent from a given address',
COMMENT COLUMN gas 'The maximum number of gas units allowed for the transaction',
COMMENT COLUMN gasprice 'The price offered to the miner/validator per unit of gas. Denominated in wei',
COMMENT COLUMN value 'The amount of ETH transferred or sent to contract. Denominated in wei',
COMMENT COLUMN toaddress 'The destination of a given transaction',
COMMENT COLUMN fromaddress 'The source/initiator of a given transaction',
COMMENT COLUMN datasize 'The size of the call data of the transaction in bytes',
COMMENT COLUMN data4bytes 'The first 4 bytes of the call data of the transaction',
COMMENT COLUMN network 'The specific Ethereum network used',
COMMENT COLUMN type '"Post EIP-1559, this indicates how the gas parameters are submitted to the network: - type 0 - legacy - type 1 - usage of access lists according to EIP-2930 - type 2 - using maxpriorityfeepergas and maxfeepergas"',
COMMENT COLUMN maxpriorityfeepergas 'The maximum value for a tip offered to the miner/validator per unit of gas. The actual tip paid can be lower if (maxfee - basefee) < maxpriorityfee. Denominated in wei',
COMMENT COLUMN maxfeepergas 'The maximum value for the transaction fee (including basefee and tip) offered to the miner/validator per unit of gas. Denominated in wei',
COMMENT COLUMN basefeepergas 'The fee per unit of gas paid and burned for the curblocknumber. This fee is algorithmically determined. Denominated in wei',
COMMENT COLUMN dropreason 'If the transaction was dropped from the mempool, this describes the contextual reason for the drop',
COMMENT COLUMN rejectionreason 'If the transaction was rejected from the mempool, this describes the contextual reason for the rejection',
COMMENT COLUMN stuck 'A transaction was detected in the queued area of the mempool and is not eligible for inclusion in a block',
COMMENT COLUMN gasused 'If the transaction was published on-chain, this value indicates the amount of gas that was actually consumed. Denominated in wei';

ALTER TABLE canonical_beacon_proposer_duty_local on cluster '{cluster}'
COMMENT COLUMN unique_key 'Unique key for the row',
COMMENT COLUMN updated_date_time 'When this row was last updated',
COMMENT COLUMN event_date_time 'When the client fetched the proposer duty information from a beacon node',
COMMENT COLUMN slot 'The slot number for which the proposer duty is assigned',
COMMENT COLUMN slot_start_date_time 'The wall clock time when the slot started',
COMMENT COLUMN epoch 'The epoch number containing the slot',
COMMENT COLUMN epoch_start_date_time 'The wall clock time when the epoch started',
COMMENT COLUMN proposer_validator_index 'The validator index of the proposer for the slot',
COMMENT COLUMN proposer_pubkey 'The public key of the validator proposer',
COMMENT COLUMN meta_client_name 'Name of the client that generated the event',
COMMENT COLUMN meta_client_id 'Unique Session ID of the client that generated the event. This changes every time the client is restarted.',
COMMENT COLUMN meta_client_version 'Version of the client that generated the event',
COMMENT COLUMN meta_client_implementation 'Implementation of the client that generated the event',
COMMENT COLUMN meta_client_os 'Operating system of the client that generated the event',
COMMENT COLUMN meta_client_ip 'IP address of the client that generated the event',
COMMENT COLUMN meta_client_geo_city 'City of the client that generated the event',
COMMENT COLUMN meta_client_geo_country 'Country of the client that generated the event',
COMMENT COLUMN meta_client_geo_country_code 'Country code of the client that generated the event',
COMMENT COLUMN meta_client_geo_continent_code 'Continent code of the client that generated the event',
COMMENT COLUMN meta_client_geo_longitude 'Longitude of the client that generated the event',
COMMENT COLUMN meta_client_geo_latitude 'Latitude of the client that generated the event',
COMMENT COLUMN meta_client_geo_autonomous_system_number 'Autonomous system number of the client that generated the event',
COMMENT COLUMN meta_client_geo_autonomous_system_organization 'Autonomous system organization of the client that generated the event',
COMMENT COLUMN meta_network_id 'Ethereum network ID',
COMMENT COLUMN meta_network_name 'Ethereum network name',
COMMENT COLUMN meta_consensus_version 'Ethereum consensus client version that generated the event',
COMMENT COLUMN meta_consensus_version_major 'Ethereum consensus client major version that generated the event',
COMMENT COLUMN meta_consensus_version_minor 'Ethereum consensus client minor version that generated the event',
COMMENT COLUMN meta_consensus_version_patch 'Ethereum consensus client patch version that generated the event',
COMMENT COLUMN meta_consensus_implementation 'Ethereum consensus client implementation that generated the event',
COMMENT COLUMN meta_labels 'Labels associated with the even';

ALTER TABLE canonical_beacon_proposer_duty on cluster '{cluster}'
COMMENT COLUMN unique_key 'Unique key for the row',
COMMENT COLUMN updated_date_time 'When this row was last updated',
COMMENT COLUMN event_date_time 'When the client fetched the proposer duty information from a beacon node',
COMMENT COLUMN slot 'The slot number for which the proposer duty is assigned',
COMMENT COLUMN slot_start_date_time 'The wall clock time when the slot started',
COMMENT COLUMN epoch 'The epoch number containing the slot',
COMMENT COLUMN epoch_start_date_time 'The wall clock time when the epoch started',
COMMENT COLUMN proposer_validator_index 'The validator index of the proposer for the slot',
COMMENT COLUMN proposer_pubkey 'The public key of the validator proposer',
COMMENT COLUMN meta_client_name 'Name of the client that generated the event',
COMMENT COLUMN meta_client_id 'Unique Session ID of the client that generated the event. This changes every time the client is restarted.',
COMMENT COLUMN meta_client_version 'Version of the client that generated the event',
COMMENT COLUMN meta_client_implementation 'Implementation of the client that generated the event',
COMMENT COLUMN meta_client_os 'Operating system of the client that generated the event',
COMMENT COLUMN meta_client_ip 'IP address of the client that generated the event',
COMMENT COLUMN meta_client_geo_city 'City of the client that generated the event',
COMMENT COLUMN meta_client_geo_country 'Country of the client that generated the event',
COMMENT COLUMN meta_client_geo_country_code 'Country code of the client that generated the event',
COMMENT COLUMN meta_client_geo_continent_code 'Continent code of the client that generated the event',
COMMENT COLUMN meta_client_geo_longitude 'Longitude of the client that generated the event',
COMMENT COLUMN meta_client_geo_latitude 'Latitude of the client that generated the event',
COMMENT COLUMN meta_client_geo_autonomous_system_number 'Autonomous system number of the client that generated the event',
COMMENT COLUMN meta_client_geo_autonomous_system_organization 'Autonomous system organization of the client that generated the event',
COMMENT COLUMN meta_network_id 'Ethereum network ID',
COMMENT COLUMN meta_network_name 'Ethereum network name',
COMMENT COLUMN meta_consensus_version 'Ethereum consensus client version that generated the event',
COMMENT COLUMN meta_consensus_version_major 'Ethereum consensus client major version that generated the event',
COMMENT COLUMN meta_consensus_version_minor 'Ethereum consensus client minor version that generated the event',
COMMENT COLUMN meta_consensus_version_patch 'Ethereum consensus client patch version that generated the event',
COMMENT COLUMN meta_consensus_implementation 'Ethereum consensus client implementation that generated the event',
COMMENT COLUMN meta_labels 'Labels associated with the even';
21 changes: 14 additions & 7 deletions pkg/mimicry/p2p/execution/event_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction,
}

if event.Type() == 3 {
blobHashes := make([]string, len(event.BlobHashes()))
hashes := event.BlobHashes()
blobHashes := make([]string, len(hashes))

for i := 0; i < len(event.BlobHashes()); i++ {
hash := event.BlobHashes()[i]
for i := 0; i < len(hashes); i++ {
hash := hashes[i]
blobHashes[i] = hash.String()
}

Expand All @@ -102,10 +103,16 @@ func (p *Peer) getTransactionData(ctx context.Context, event *types.Transaction,
sidecarsEmptySize := 0
sidecarsSize := 0

for i := 0; i < len(event.BlobTxSidecar().Blobs); i++ {
sidecar := event.BlobTxSidecar().Blobs[i][:]
sidecarsSize += len(sidecar)
sidecarsEmptySize += ethereum.CountConsecutiveEmptyBytes(sidecar, 4)
sidecars := event.BlobTxSidecar()

if sidecars != nil {
for i := 0; i < len(sidecars.Blobs); i++ {
sidecars := sidecars.Blobs[i][:]
sidecarsSize += len(sidecars)
sidecarsEmptySize += ethereum.CountConsecutiveEmptyBytes(sidecars, 4)
}
} else {
p.log.WithField("versioned hash", event.Hash().String()).WithField("transaction", event.Hash().String()).Warn("no sidecars found for a type 3 transaction")
}

extra.BlobSidecarsSize = fmt.Sprint(sidecarsSize)
Expand Down

0 comments on commit 1586dc3

Please sign in to comment.