Skip to content

Commit

Permalink
[pallet-revive] Add metrics to eth-rpc (paritytech#6288)
Browse files Browse the repository at this point in the history
Add metrics for eth-rpc

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 2b6b696 commit 5f782a4
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 275 deletions.
129 changes: 4 additions & 125 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions prdoc/pr_6288.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: '[pallet-revive] Add metrics to eth-rpc'
doc:
- audience: Runtime Dev
description: Add metrics for eth-rpc
crates:
- name: pallet-revive-eth-rpc
bump: minor
15 changes: 15 additions & 0 deletions substrate/client/cli/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,19 @@ impl Signals {

Ok(())
}

/// Execute the future task and returns it's value if it completes before the signal.
pub async fn try_until_signal<F, T>(self, func: F) -> Result<T, ()>
where
F: Future<Output = T> + future::FusedFuture,
{
let signals = self.future().fuse();

pin_mut!(func, signals);

select! {
s = signals => Err(s),
res = func => Ok(res),
}
}
}
9 changes: 3 additions & 6 deletions substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ subxt = { workspace = true, default-features = true, features = [
tokio = { workspace = true, features = ["full"] }
codec = { workspace = true, features = ["derive"] }
log.workspace = true
tracing-subscriber.workspace = true
pallet-revive = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-weights = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }

tower.workspace = true
tower-http = { workspace = true, features = ["full"] }
hyper.workspace = true
sc-cli = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = true }
prometheus-endpoint = { workspace = true, default-features = true }

rlp = { workspace = true, optional = true }
subxt-signer = { workspace = true, optional = true, features = [
Expand All @@ -73,7 +71,6 @@ secp256k1 = { workspace = true, optional = true, features = ["recovery"] }
env_logger = { workspace = true }

[features]
dev = []
example = ["hex", "hex-literal", "rlp", "secp256k1", "subxt-signer"]
riscv = ["pallet-revive/riscv"]

Expand Down
11 changes: 9 additions & 2 deletions substrate/frame/revive/rpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM rust AS builder

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
protobuf-compiler
protobuf-compiler \
clang libclang-dev

WORKDIR /polkadot
COPY . /polkadot
Expand All @@ -19,5 +20,11 @@ RUN useradd -m -u 1001 -U -s /bin/sh -d /polkadot polkadot && \
/usr/local/bin/eth-rpc --help

USER polkadot
EXPOSE 8545

# 8545 is the default port for the RPC server
# 9616 is the default port for the prometheus metrics
EXPOSE 8545 9616
ENTRYPOINT ["/usr/local/bin/eth-rpc"]

# We call the help by default
CMD ["--help"]
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/examples/js/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function str_to_bytes(str: string): Uint8Array {
async function deploy() {
console.log(`Deploying Contract...`);

const bytecode = readFileSync("rpc_demo.polkavm");
const bytecode = readFileSync("../rpc_demo.polkavm");
const contractFactory = new ContractFactory(
[
"constructor(bytes memory _data)",
Expand Down
Loading

0 comments on commit 5f782a4

Please sign in to comment.