Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement auto-mining #4622

Merged
merged 34 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d62e97a
fix: eth_sendTransaction RPC type
Wodann Nov 24, 2023
9032106
refactor: rename EIP to Eip
Wodann Nov 24, 2023
469fdee
feat: add auto-mining for eth_sendTransaction
Wodann Nov 24, 2023
48f7131
Merge remote-tracking branch 'origin/edr/main' into edr/feat/send-tra…
Wodann Nov 27, 2023
96b165e
feat: expose helper functions from edr_evm
Wodann Nov 28, 2023
253e07d
feat: resolve default transaction fees
Wodann Nov 28, 2023
266aafc
Merge remote-tracking branch 'origin/edr/main' into edr/feat/send-tra…
Wodann Nov 28, 2023
132072f
fix: eth_sendTransaction request RPC type
Wodann Nov 28, 2023
29a2e90
feat: resolve default chain ID for eth_sendTransaction
Wodann Nov 28, 2023
a411ecc
feat: implement eth_call RPC method
Wodann Nov 29, 2023
47f1229
feat: revert to snapshot if auto-mining fails
Wodann Nov 29, 2023
58faf5a
feat: add names of unimplemented RPC methods
Wodann Nov 29, 2023
d65bd9d
Merge remote-tracking branch 'origin/edr/main' into edr/feat/send-tra…
Wodann Nov 29, 2023
52a9aee
feat: return RPC error from N-API provider
Wodann Nov 29, 2023
25884a5
fix: match EDR errors with Hardhat
Wodann Dec 1, 2023
75f7609
WIP: test: add test file
Wodann Dec 1, 2023
6aa2fb7
Merge branch 'edr/main' into edr/feat/send-transaction
agostbiro Dec 1, 2023
30d3ef6
Fix gas price too low errors
agostbiro Dec 1, 2023
5c26805
Fix failing tests with error expectations
agostbiro Dec 1, 2023
91be641
Fix nonce too low errors
agostbiro Dec 4, 2023
6b30550
Fix nonce too high errors
agostbiro Dec 4, 2023
5517d96
Add `eth_pendingTransactions` to provider
agostbiro Dec 4, 2023
8afaade
Add `hardhat_setMinGasPrice` to provider
agostbiro Dec 4, 2023
59ddb73
Fix error message when sender doesn't have funds for gas
agostbiro Dec 4, 2023
841507d
Derive debug implementation for provider config
agostbiro Dec 4, 2023
9def29f
Pass fork config to EDR provider
agostbiro Dec 4, 2023
2e6b809
Fix JS lints
agostbiro Dec 5, 2023
6963638
Review: add back todo
agostbiro Dec 5, 2023
4f2fa65
Fix lint
agostbiro Dec 5, 2023
fd8ce51
fix: overwrite genesis account nonces and code in fork mode (#4649)
agostbiro Dec 5, 2023
c50a9d7
fix: erroneous AutoMineMaxFeeTooLow
Wodann Dec 6, 2023
e3aac13
fix: 'should use the proper chain ID' test
Wodann Dec 6, 2023
d3e33a2
fix: do not revert to snapshot upon revert or halt
Wodann Dec 6, 2023
15e9ff0
refactor: remove original sendTransaction.ts
Wodann Dec 6, 2023
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
Prev Previous commit
Next Next commit
feat: add names of unimplemented RPC methods
  • Loading branch information
Wodann committed Nov 29, 2023
commit 58faf5a77653bb980a7d8a4af5741e3253076747
78 changes: 47 additions & 31 deletions crates/edr_provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,28 @@ fn handle_eth_request(
}
EthRequest::ChainId(()) => eth::handle_chain_id_request(data).and_then(to_json),
EthRequest::Coinbase(()) => eth::handle_coinbase_request(data).and_then(to_json),
EthRequest::EstimateGas(_, _) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::FeeHistory(_, _, _) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::GasPrice(()) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::EstimateGas(_, _) => {
Err(ProviderError::Unimplemented("EstimateGas".to_string()))
}
EthRequest::FeeHistory(_, _, _) => {
Err(ProviderError::Unimplemented("FeeHistory".to_string()))
}
EthRequest::GasPrice(()) => Err(ProviderError::Unimplemented("GasPrice".to_string())),
EthRequest::GetBalance(address, block_spec) => {
eth::handle_get_balance_request(data, address, block_spec).and_then(to_json)
}
EthRequest::GetBlockByNumber(_, _) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::GetBlockByHash(_, _) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::GetBlockTransactionCountByHash(_) => {
Err(ProviderError::Unimplemented("".to_string()))
EthRequest::GetBlockByNumber(_, _) => {
Err(ProviderError::Unimplemented("GetBlockByNumber".to_string()))
}
EthRequest::GetBlockTransactionCountByNumber(_) => {
Err(ProviderError::Unimplemented("".to_string()))
EthRequest::GetBlockByHash(_, _) => {
Err(ProviderError::Unimplemented("GetBlockByHash".to_string()))
}
EthRequest::GetBlockTransactionCountByHash(_) => Err(ProviderError::Unimplemented(
"GetBlockTransactionCountByHash".to_string(),
)),
EthRequest::GetBlockTransactionCountByNumber(_) => Err(ProviderError::Unimplemented(
"GetBlockTransactionCountByNumber".to_string(),
)),
EthRequest::GetCode(address, block_spec) => {
eth::handle_get_code_request(data, address, block_spec).and_then(to_json)
}
Expand All @@ -157,7 +165,7 @@ fn handle_eth_request(
EthRequest::GetFilterLogs(filter_id) => {
eth::handle_get_filter_logs_request(data, filter_id).and_then(to_json)
}
EthRequest::GetLogs(_) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::GetLogs(_) => Err(ProviderError::Unimplemented("GetLogs".to_string())),
EthRequest::GetStorageAt(address, index, block_spec) => {
eth::handle_get_storage_at_request(data, address, index, block_spec).and_then(to_json)
}
Expand All @@ -178,16 +186,20 @@ fn handle_eth_request(
EthRequest::GetTransactionReceipt(transaction_hash) => {
eth::handle_get_transaction_receipt(data, transaction_hash).and_then(to_json)
}
EthRequest::Mining(()) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::Mining(()) => Err(ProviderError::Unimplemented("Mining".to_string())),
EthRequest::NetListening(()) => eth::handle_net_listening_request().and_then(to_json),
EthRequest::NetPeerCount(()) => eth::handle_net_peer_count_request().and_then(to_json),
EthRequest::NetVersion(()) => eth::handle_net_version_request(data).and_then(to_json),
EthRequest::NewBlockFilter(()) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::NewFilter(_) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::NewBlockFilter(()) => {
Err(ProviderError::Unimplemented("NewBlockFilter".to_string()))
}
EthRequest::NewFilter(_) => Err(ProviderError::Unimplemented("NewFilter".to_string())),
EthRequest::NewPendingTransactionFilter(()) => {
eth::handle_new_pending_transaction_filter_request(data).and_then(to_json)
}
EthRequest::PendingTransactions(()) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::PendingTransactions(()) => Err(ProviderError::Unimplemented(
"PendingTransactions".to_string(),
)),
EthRequest::SendRawTransaction(raw_transaction) => {
eth::handle_send_raw_transaction_request(data, raw_transaction).and_then(to_json)
}
Expand All @@ -197,9 +209,11 @@ fn handle_eth_request(
EthRequest::Sign(address, message) => {
eth::handle_sign_request(data, address, message).and_then(to_json)
}
EthRequest::SignTypedDataV4(_, _) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::Subscribe(_) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::Syncing(()) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::SignTypedDataV4(_, _) => {
Err(ProviderError::Unimplemented("SignTypedDataV4".to_string()))
}
EthRequest::Subscribe(_) => Err(ProviderError::Unimplemented("Subscribe".to_string())),
EthRequest::Syncing(()) => Err(ProviderError::Unimplemented("Syncing".to_string())),
EthRequest::UninstallFilter(filter_id) => {
eth::handle_uninstall_filter_request(data, filter_id).and_then(to_json)
}
Expand All @@ -225,7 +239,9 @@ fn handle_eth_request(
EthRequest::EvmSetBlockGasLimit(gas_limit) => {
eth::handle_set_block_gas_limit_request(data, gas_limit).and_then(to_json)
}
EthRequest::EvmSetIntervalMining(_) => Err(ProviderError::Unimplemented("".to_string())),
EthRequest::EvmSetIntervalMining(_) => Err(ProviderError::Unimplemented(
"EvmSetIntervalMining".to_string(),
)),
EthRequest::EvmSetNextBlockTimestamp(timestamp) => {
eth::handle_set_next_block_timestamp_request(data, timestamp).and_then(to_json)
}
Expand All @@ -240,18 +256,18 @@ fn handle_hardhat_request(
// TODO: Remove the lint override once all methods have been implemented
#[allow(clippy::match_same_arms)]
match request {
rpc_hardhat::Request::AddCompilationResult(_, _, _) => {
Err(ProviderError::Unimplemented("".to_string()))
}
rpc_hardhat::Request::AddCompilationResult(_, _, _) => Err(ProviderError::Unimplemented(
"AddCompilationResult".to_string(),
)),
rpc_hardhat::Request::DropTransaction(_) => {
Err(ProviderError::Unimplemented("".to_string()))
Err(ProviderError::Unimplemented("DropTransaction".to_string()))
}
rpc_hardhat::Request::GetAutomine(()) => {
hardhat::handle_get_automine_request(data).and_then(to_json)
}
rpc_hardhat::Request::GetStackTraceFailuresCount(()) => {
Err(ProviderError::Unimplemented("".to_string()))
}
rpc_hardhat::Request::GetStackTraceFailuresCount(()) => Err(ProviderError::Unimplemented(
"GetStackTraceFailuresCount".to_string(),
)),
rpc_hardhat::Request::ImpersonateAccount(address) => {
hardhat::handle_impersonate_account_request(data, address).and_then(to_json)
}
Expand All @@ -261,8 +277,8 @@ fn handle_hardhat_request(
rpc_hardhat::Request::Metadata(()) => {
hardhat::handle_metadata_request(data).and_then(to_json)
}
rpc_hardhat::Request::Mine(_, _) => Err(ProviderError::Unimplemented("".to_string())),
rpc_hardhat::Request::Reset(_) => Err(ProviderError::Unimplemented("".to_string())),
rpc_hardhat::Request::Mine(_, _) => Err(ProviderError::Unimplemented("Mine".to_string())),
rpc_hardhat::Request::Reset(_) => Err(ProviderError::Unimplemented("Reset".to_string())),
rpc_hardhat::Request::SetBalance(address, balance) => {
hardhat::handle_set_balance(data, address, balance).and_then(to_json)
}
Expand All @@ -272,11 +288,11 @@ fn handle_hardhat_request(
rpc_hardhat::Request::SetCoinbase(coinbase) => {
hardhat::handle_set_coinbase_request(data, coinbase).and_then(to_json)
}
rpc_hardhat::Request::SetLoggingEnabled(_) => {
Err(ProviderError::Unimplemented("".to_string()))
}
rpc_hardhat::Request::SetLoggingEnabled(_) => Err(ProviderError::Unimplemented(
"SetLoggingEnabled".to_string(),
)),
rpc_hardhat::Request::SetMinGasPrice(_) => {
Err(ProviderError::Unimplemented("".to_string()))
Err(ProviderError::Unimplemented("SetMinGasPrice".to_string()))
}
rpc_hardhat::Request::SetNextBlockBaseFeePerGas(base_fee_per_gas) => {
hardhat::handle_set_next_block_base_fee_per_gas_request(data, base_fee_per_gas)
Expand Down