Skip to content

Latest commit

 

History

History
417 lines (325 loc) · 13.3 KB

mapping.md

File metadata and controls

417 lines (325 loc) · 13.3 KB

Ethereum RPC Reference

For reference,

In the table below all the methods required to be exposed are grouped into 5 categories, with the expected implementation difficulty descending from the top group to the bottom one.

method description comments
x Group 1: calls    
x call dry-run a contract call via pallet_evm::Runner:call(); Major problems: Caling conventions,
    basically this is what pallet_contracts::bare_call() does; ABI compatibility
x send_raw_transaction submits on-chain transaction call by sending tx via pallet_ethereum dispatchable  
    expects raw bytes of the encoded signed tx  
    this is the core thing to implement so that it calls pallet_contracts dispatchable  
    see this SE for perfect explanation on call and send difference;  
x send_transaction sign and submit a tx; same as above but expects (unsigned) tx Object  
    (instead of raw data) and implies signing the tx on the node side  
    (by in-node stored signer)  
x estimate_gas basically make a dry-run and get the gas consumed, or system::dry_run()  
x Group 2: blocks    
x block_by_hash get Eth block by its hash Major question:
x block_by_number same by block number Should we store Eth block to
x block_transaction_count_by_hash same but returns number of txs in the block storage as well, or is it possible to
x block_transaction_count_by_number same but returns number of txs in the block emulate it on the fly?
  Group 3: transactions    
  transaction_by_hash we’d need to transform the tx data so that is looks like Eth tx Tx data should be easily translateable
  transaction_by_block_hash_and_index same between Eth and Substrate formats
  transaction_by_block_number_and_index same  
x transaction_receipt   See this fn on how to build a receipt
  Group 4: state    
  author in Eth RPC it’s coinbase address, but fc_rpc just sends current block beneficiary Mehods in this group are expected to be
x balance get the balance of an account easily provided by the pallet_contracts
x transaction_count bascially returns account’s nonce; do-able via frame_system::pallet::account_nonce() existing means, with some possible data
x chain_id handled by pallet_evm_chain_id, this is a constant defined in runtime transformations where needed.
  version protocl version, mocked with constant  
  code_at uses pallet_evm, we could impl the same or just return code_hash  
x block_number get the current block number; basically we pass the substrate’s one  
  gas_price can return this with tx_payment_rpc::query_weight_to_fee()  
  storage_at uses pallet_evm; we can do it with ContractInfo::read()  
x accounts accounts owned by the client, stored in fc_rpc::Eth.signers, Vec<EthSigner> This relates to node and not to chain state,
x syncing gets it from sc_network_sync::service::chain_sync::SyncingService just keeping it here for now
  Group 5: misc    
  fee_history can be mocked with a constant, at least in PoC Methods in this group apparently could be
  is_mining I think we can mock it with const false, at least at PoC stage just mocked
  max_priority_fee_per_gas weird calc based on historic block rewards, probably can always return 0  
  hashrate just returns 0  
  protocol_version just returns 1  
  net_version    
  submit_hashrate just returns false  
  submit_work just returns false  
  block_uncles_count_by_number just returns 0  
  block_uncles_count_by_hash just returns 0  
  uncle_by_block_hash_and_index just returns None  
  uncle_by_block_number_and_index just returns None  
  work just returns constant default