Compare commits
2 Commits
c6f440fdad
...
critical-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89e2daf05a | ||
|
|
c62feda198 |
26
.woodpecker/server-compile.yaml
Normal file
26
.woodpecker/server-compile.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
when:
|
||||||
|
- event: pull_request
|
||||||
|
path:
|
||||||
|
include: [".woodpecker/server-*.yaml", "server/**"]
|
||||||
|
- event: push
|
||||||
|
branch: main
|
||||||
|
path:
|
||||||
|
include: [".woodpecker/server-*.yaml", "server/**"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: compile
|
||||||
|
image: jdxcode/mise:latest
|
||||||
|
directory: server
|
||||||
|
environment:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
CARGO_TARGET_DIR: /usr/local/cargo/target
|
||||||
|
CARGO_HOME: /usr/local/cargo/registry
|
||||||
|
volumes:
|
||||||
|
- cargo-target:/usr/local/cargo/target
|
||||||
|
- cargo-registry:/usr/local/cargo/registry
|
||||||
|
commands:
|
||||||
|
- apt-get update && apt-get install -y pkg-config
|
||||||
|
# Install only the necessary Rust toolchain
|
||||||
|
- mise install rust
|
||||||
|
- mise install protoc
|
||||||
|
- cargo check --all-features
|
||||||
@@ -24,4 +24,4 @@ steps:
|
|||||||
- mise install rust
|
- mise install rust
|
||||||
- mise install protoc
|
- mise install protoc
|
||||||
- mise install cargo:cargo-nextest
|
- mise install cargo:cargo-nextest
|
||||||
- mise exec cargo:cargo-nextest -- cargo nextest run --no-fail-fast --all-features
|
- mise exec cargo:cargo-nextest -- cargo nextest run --no-fail-fast
|
||||||
@@ -9,4 +9,4 @@ pub use client::{ArbiterClient, Error};
|
|||||||
pub use storage::{FileSigningKeyStorage, SigningKeyStorage, StorageError};
|
pub use storage::{FileSigningKeyStorage, SigningKeyStorage, StorageError};
|
||||||
|
|
||||||
#[cfg(feature = "evm")]
|
#[cfg(feature = "evm")]
|
||||||
pub use wallets::evm::{ArbiterEvmSignTransactionError, ArbiterEvmWallet};
|
pub use wallets::evm::ArbiterEvmWallet;
|
||||||
|
|||||||
@@ -10,48 +10,14 @@ use tokio::sync::Mutex;
|
|||||||
|
|
||||||
use arbiter_proto::proto::{
|
use arbiter_proto::proto::{
|
||||||
client::{
|
client::{
|
||||||
ClientRequest,
|
ClientRequest, client_request::Payload as ClientRequestPayload,
|
||||||
client_request::Payload as ClientRequestPayload,
|
|
||||||
client_response::Payload as ClientResponsePayload,
|
client_response::Payload as ClientResponsePayload,
|
||||||
evm::{
|
|
||||||
self as proto_evm, request::Payload as EvmRequestPayload,
|
|
||||||
response::Payload as EvmResponsePayload,
|
|
||||||
},
|
},
|
||||||
},
|
evm::evm_sign_transaction_response::Result as EvmSignTransactionResult,
|
||||||
evm::{
|
|
||||||
EvmSignTransactionRequest,
|
|
||||||
evm_sign_transaction_response::Result as EvmSignTransactionResult,
|
|
||||||
},
|
|
||||||
shared::evm::TransactionEvalError,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::transport::{ClientTransport, next_request_id};
|
use crate::transport::{ClientTransport, next_request_id};
|
||||||
|
|
||||||
/// A typed error payload returned by [`ArbiterEvmWallet`] transaction signing.
|
|
||||||
///
|
|
||||||
/// This is wrapped into `alloy::signers::Error::Other`, so consumers can downcast by [`TryFrom`] and
|
|
||||||
/// interpret the concrete policy evaluation failure instead of parsing strings.
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
#[non_exhaustive]
|
|
||||||
pub enum ArbiterEvmSignTransactionError {
|
|
||||||
#[error("transaction rejected by policy: {0:?}")]
|
|
||||||
PolicyEval(TransactionEvalError),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a Error> for &'a ArbiterEvmSignTransactionError {
|
|
||||||
type Error = ();
|
|
||||||
|
|
||||||
fn try_from(value: &'a Error) -> Result<Self, Self::Error> {
|
|
||||||
if let Error::Other(inner) = value
|
|
||||||
&& let Some(eval_error) = inner.downcast_ref()
|
|
||||||
{
|
|
||||||
Ok(eval_error)
|
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ArbiterEvmWallet {
|
pub struct ArbiterEvmWallet {
|
||||||
transport: Arc<Mutex<ClientTransport>>,
|
transport: Arc<Mutex<ClientTransport>>,
|
||||||
address: Address,
|
address: Address,
|
||||||
@@ -130,14 +96,12 @@ impl TxSigner<Signature> for ArbiterEvmWallet {
|
|||||||
transport
|
transport
|
||||||
.send(ClientRequest {
|
.send(ClientRequest {
|
||||||
request_id,
|
request_id,
|
||||||
payload: Some(ClientRequestPayload::Evm(proto_evm::Request {
|
payload: Some(ClientRequestPayload::EvmSignTransaction(
|
||||||
payload: Some(EvmRequestPayload::SignTransaction(
|
arbiter_proto::proto::evm::EvmSignTransactionRequest {
|
||||||
EvmSignTransactionRequest {
|
|
||||||
wallet_address: self.address.to_vec(),
|
wallet_address: self.address.to_vec(),
|
||||||
rlp_transaction,
|
rlp_transaction,
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
})),
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::other("failed to send evm sign transaction request"))?;
|
.map_err(|_| Error::other("failed to send evm sign transaction request"))?;
|
||||||
@@ -157,21 +121,12 @@ impl TxSigner<Signature> for ArbiterEvmWallet {
|
|||||||
.payload
|
.payload
|
||||||
.ok_or_else(|| Error::other("missing evm sign transaction response payload"))?;
|
.ok_or_else(|| Error::other("missing evm sign transaction response payload"))?;
|
||||||
|
|
||||||
let ClientResponsePayload::Evm(proto_evm::Response {
|
let ClientResponsePayload::EvmSignTransaction(response) = payload else {
|
||||||
payload: Some(payload),
|
|
||||||
}) = payload
|
|
||||||
else {
|
|
||||||
return Err(Error::other(
|
return Err(Error::other(
|
||||||
"unexpected response payload for evm sign transaction request",
|
"unexpected response payload for evm sign transaction request",
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
let EvmResponsePayload::SignTransaction(response) = payload else {
|
|
||||||
return Err(Error::other(
|
|
||||||
"unexpected evm response payload for sign transaction request",
|
|
||||||
));
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = response
|
let result = response
|
||||||
.result
|
.result
|
||||||
.ok_or_else(|| Error::other("missing evm sign transaction result"))?;
|
.ok_or_else(|| Error::other("missing evm sign transaction result"))?;
|
||||||
@@ -181,9 +136,9 @@ impl TxSigner<Signature> for ArbiterEvmWallet {
|
|||||||
Signature::try_from(signature.as_slice())
|
Signature::try_from(signature.as_slice())
|
||||||
.map_err(|_| Error::other("invalid signature returned by server"))
|
.map_err(|_| Error::other("invalid signature returned by server"))
|
||||||
}
|
}
|
||||||
EvmSignTransactionResult::EvalError(eval_error) => Err(Error::other(
|
EvmSignTransactionResult::EvalError(eval_error) => Err(Error::other(format!(
|
||||||
ArbiterEvmSignTransactionError::PolicyEval(eval_error),
|
"transaction rejected by policy: {eval_error:?}"
|
||||||
)),
|
))),
|
||||||
EvmSignTransactionResult::Error(code) => Err(Error::other(format!(
|
EvmSignTransactionResult::Error(code) => Err(Error::other(format!(
|
||||||
"server failed to sign transaction with error code {code}"
|
"server failed to sign transaction with error code {code}"
|
||||||
))),
|
))),
|
||||||
|
|||||||
Reference in New Issue
Block a user