Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Jan 10, 2025
1 parent 180835b commit 5d08af9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sc-rpc = { workspace = true, default-features = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-arithmetic = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true }
sp-weights = { workspace = true, default-features = true }
sqlx = { version = "0.8.2", features = [
Expand Down
13 changes: 12 additions & 1 deletion substrate/frame/revive/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use jsonrpsee::{
types::{ErrorCode, ErrorObjectOwned},
};
use pallet_revive::evm::*;
use sp_arithmetic::Permill;
use sp_core::{keccak_256, H160, H256, U256};
use thiserror::Error;

Expand Down Expand Up @@ -127,7 +128,12 @@ impl EthRpcServer for EthRpcServerImpl {
transaction_hash: H256,
) -> RpcResult<Option<ReceiptInfo>> {
let receipt = self.client.receipt(&transaction_hash).await;
log::debug!(target: LOG_TARGET, "transaction_receipt for {transaction_hash:?}: {}", receipt.is_some());
log::debug!(
target: LOG_TARGET,
"transaction_receipt for {transaction_hash:?}: received: {received} - success: {success:?}",
received = receipt.is_some(),
success = receipt.as_ref().map(|r| r.status == Some(U256::one()))
);
Ok(receipt)
}

Expand Down Expand Up @@ -226,6 +232,11 @@ impl EthRpcServer for EthRpcServerImpl {
Ok(U256::from(GAS_PRICE))
}

async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> {
// TODO: Provide better estimation
Ok(U256::from(Permill::from_percent(20).mul_ceil(GAS_PRICE)))
}

async fn get_code(&self, address: H160, block: BlockNumberOrTagOrHash) -> RpcResult<Bytes> {
let code = self.client.get_contract_code(&address, block).await?;
Ok(code.into())
Expand Down
4 changes: 4 additions & 0 deletions substrate/frame/revive/rpc/src/rpc_methods_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ pub trait EthRpc {
transaction_hash: H256,
) -> RpcResult<Option<ReceiptInfo>>;

/// Returns the current maxPriorityFeePerGas per gas in wei.
#[method(name = "eth_maxPriorityFeePerGas")]
async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;

/// Submits a raw transaction. For EIP-4844 transactions, the raw form must be the network form.
/// This means it includes the blobs, KZG commitments, and KZG proofs.
#[method(name = "eth_sendRawTransaction")]
Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/revive/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ where
&HoldReason::CodeUploadDepositReserve.into(),
&self.code_info.owner,
deposit,
) .map_err(|err| { log::debug!(target: LOG_TARGET, "failed to store code for owner: {:?}: {err:?}", self.code_info.owner);
<Error<T>>::StorageDepositNotEnoughFunds
) .map_err(|err| {
log::debug!(target: LOG_TARGET, "failed to hold store code deposit {deposit:?} for owner: {:?}: {err:?}", self.code_info.owner);
<Error<T>>::StorageDepositNotEnoughFunds
})?;
}

Expand Down

0 comments on commit 5d08af9

Please sign in to comment.