Gibt es eine Möglichkeit, den Bytecode eines bereitgestellten Vertrags aus leveldb zu lesen? Soweit ich weiß, gibt es in jedem Konto im Zustandsbaum die Nonce, das Gleichgewicht, den Codehash und die Speicherwurzel. Zeigt der Codehash auf die Stelle in leveldb, wo der Vertrags-Bytecode gespeichert ist?
Und ist es richtig zu sagen, dass der in leveldb gespeicherte Vertrags-Bytecode nur der Hauptteil des Vertrags und nicht der Init/Konstruktor-Bytecode ist?
Sie können Vertrags-Bytecode in diesem öffentlichen BigQuery-Dataset https://medium.com/@medvedev1088/more-blockchain-analysis-on-bigquery-92a863137f01 abfragen . Zusätzlich können Sie Blöcke, Transaktionen, Quittungen, Protokolle, erc20_transfers abfragen:
### contracts.csv
Column | Type |
-----------------------------|-------------|
contract_address | address |
contract_bytecode | hex_string |
### blocks.csv
Column | Type |
------------------------|--------------------|
block_number | bigint |
block_hash | hex_string |
block_parent_hash | hex_string |
block_nonce | hex_string |
block_sha3_uncles | hex_string |
block_logs_bloom | hex_string |
block_transactions_root | hex_string |
block_state_root | hex_string |
block_miner | address |
block_difficulty | numeric |
block_total_difficulty | numeric |
block_size | bigint |
block_extra_data | hex_string |
block_gas_limit | bigint |
block_gas_used | bigint |
block_timestamp | bigint |
block_transaction_count | bigint |
### transactions.csv
Column | Type |
--------------------|-------------|
tx_hash | hex_string |
tx_nonce | bigint |
tx_block_hash | hex_string |
tx_block_number | bigint |
tx_index | bigint |
tx_from | address |
tx_to | address |
tx_value | numeric |
tx_gas | bigint |
tx_gas_price | bigint |
tx_input | hex_string |
### erc20_transfers.csv
Column | Type |
--------------------|-------------|
erc20_token | address |
erc20_from | address |
erc20_to | address |
erc20_value | numeric |
erc20_tx_hash | hex_string |
erc20_log_index | bigint |
erc20_block_number | bigint |
### receipts.csv
Column | Type |
-----------------------------|-------------|
receipt_transaction_hash | hex_string |
receipt_transaction_index | bigint |
receipt_block_hash | hex_string |
receipt_block_number | bigint |
receipt_cumulative_gas_used | bigint |
receipt_gas_used | bigint |
receipt_contract_address | address |
receipt_root | hex_string |
receipt_status | bigint |
### logs.csv
Column | Type |
-----------------------------|-------------|
log_index | bigint |
log_transaction_hash | hex_string |
log_transaction_index | bigint |
log_block_hash
Das Tool, das ich zum Exportieren der Daten verwendet habe https://github.com/medvedev1088/ethereum-etl
Gibt es eine Möglichkeit, den Bytecode eines bereitgestellten Vertrags aus leveldb zu lesen?
Ja, es gibt sicherlich einen Weg, weil (z. B. geth) JSON RPC die Funktion eth_getcode verfügbar macht , die den mit einem Konto verknüpften Code zurückgibt. Unter der Haube liest es die Statusdatenbank (die im Fall des Geth-Clients eine leveldb-Datenbank ist).
Soweit ich weiß, gibt es in jedem Konto im Zustandsbaum die Nonce, das Gleichgewicht, den Codehash und die Speicherwurzel. Zeigt der Codehash auf die Stelle in leveldb, wo der Vertrags-Bytecode gespeichert ist?
Gemäß dem Yellow Paper , das die formale Spezifikation von Ethereum darstellt (Abschnitt 4.1), ja:
Und ist es richtig zu sagen, dass der in leveldb gespeicherte Vertrags-Bytecode nur der Hauptteil des Vertrags und nicht der Init/Konstruktor-Bytecode ist?
Ja es ist so. Wenn Sie sich Abschnitt 7 des Ethereum Yellow Paper ansehen . Dort heißt es:
Daher i
wird ausgeführt, und wenn die gesamte Ausführung erfolgreich ist, wird der Hauptteil des Codes o erzeugt. Der Hash des Körpers KEC(o) wird im Kontostatus gespeichert. Und o wird in der Datenbank für einen späteren Abruf im Falle des Vertragsaufrufs (dh des Nachrichtenaufrufs) gespeichert.