Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-tpu-v2-wait-for-payment-spen…
Browse files Browse the repository at this point in the history
…d' into fix-tpu-v2-wait-for-payment-spend-kickstart
  • Loading branch information
laruh committed Dec 27, 2024
2 parents d48cc25 + 869019b commit 5750415
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ RUN apt-get install -y \

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal --default-toolchain nightly-2023-06-01 -y
ENV PATH="/root/.cargo/bin:$PATH"
RUN cargo install wasm-pack --version 0.10.3
# TODO: Lock wasm-pack version
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | bash -s -- -y
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip
RUN unzip protoc-25.3-linux-x86_64.zip && mv ./include/google /usr/include/google

3 changes: 2 additions & 1 deletion .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ jobs:
rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3
# TODO: Lock wasm-pack version
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ jobs:
rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: CARGO_HOME=/root/.cargo cargo install wasm-pack --version 0.10.3
# TODO: Lock wasm-pack version
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Calculate commit hash for PR commit
if: github.event_name == 'pull_request'
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion docs/WASM_BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To build WASM binary from source, the following prerequisites are required:

1. Install `wasm-pack`
```
cargo install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
```
2. OSX specific: install `llvm`
```
Expand Down
20 changes: 10 additions & 10 deletions mm2src/coins/eth/eth_swap_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ pub(crate) enum PrepareTxDataError {
Internal(String),
}

pub(crate) struct SpendTxSearchParams<'a> {
pub(crate) swap_contract_address: Address,
pub(crate) event_name: &'a str,
pub(crate) abi_contract: &'a Contract,
pub(crate) swap_id: &'a [u8; 32],
pub(crate) from_block: u64,
pub(crate) wait_until: u64,
pub(crate) check_every: f64,
}

impl EthCoin {
/// Retrieves the payment status from a given smart contract address based on the swap ID and state type.
pub(crate) async fn payment_status_v2(
Expand Down Expand Up @@ -216,16 +226,6 @@ impl EthCoin {
}
}

pub(crate) struct SpendTxSearchParams<'a> {
pub(crate) swap_contract_address: Address,
pub(crate) event_name: &'a str,
pub(crate) abi_contract: &'a Contract,
pub(crate) swap_id: &'a [u8; 32],
pub(crate) from_block: u64,
pub(crate) wait_until: u64,
pub(crate) check_every: f64,
}

pub(crate) fn validate_payment_state(
tx: &SignedEthTx,
state: U256,
Expand Down
18 changes: 8 additions & 10 deletions mm2src/coins/eth/web3_transport/websocket_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub struct WebsocketTransport {

#[derive(Debug)]
struct ControllerChannel {
tx: Arc<AsyncMutex<UnboundedSender<ControllerMessage>>>,
rx: Arc<AsyncMutex<UnboundedReceiver<ControllerMessage>>>,
tx: UnboundedSender<ControllerMessage>,
rx: AsyncMutex<UnboundedReceiver<ControllerMessage>>,
}

enum ControllerMessage {
Expand Down Expand Up @@ -86,11 +86,10 @@ impl WebsocketTransport {
node,
event_handlers,
request_id: Arc::new(AtomicUsize::new(1)),
controller_channel: ControllerChannel {
tx: Arc::new(AsyncMutex::new(req_tx)),
rx: Arc::new(AsyncMutex::new(req_rx)),
}
.into(),
controller_channel: Arc::new(ControllerChannel {
tx: req_tx,
rx: AsyncMutex::new(req_rx),
}),
connection_guard: Arc::new(AsyncMutex::new(())),
proxy_sign_keypair: None,
last_request_failed: Arc::new(AtomicBool::new(false)),
Expand Down Expand Up @@ -298,7 +297,7 @@ impl WebsocketTransport {
}

pub(crate) async fn stop_connection_loop(&self) {
let mut tx = self.controller_channel.tx.lock().await;
let mut tx = self.controller_channel.tx.clone();
tx.send(ControllerMessage::Close)
.await
.expect("receiver channel must be alive");
Expand Down Expand Up @@ -357,12 +356,11 @@ async fn send_request(
serialized_request = serde_json::to_string(&wrapper)?;
}

let mut tx = transport.controller_channel.tx.lock().await;

let (notification_sender, notification_receiver) = oneshot::channel::<Vec<u8>>();

event_handlers.on_outgoing_request(&request_bytes);

let mut tx = transport.controller_channel.tx.clone();
tx.send(ControllerMessage::Request(WsRequest {
request_id,
serialized_request,
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/tendermint/rpc/tendermint_wasm_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod tests {

#[wasm_bindgen_test]
async fn test_get_abci_info() {
let client = HttpClient::new("https://rpc.sentry-02.theta-testnet.polypore.xyz", None).unwrap();
let client = HttpClient::new("http://34.80.202.172:26657", None).unwrap();
client.abci_info().await.unwrap();
}
}
2 changes: 1 addition & 1 deletion mm2src/mm2_p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tokio = { version = "1.20", default-features = false }
futures-rustls = "0.22"
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.11", default-features = false, features = ["identify", "floodsub", "noise", "gossipsub", "ping", "request-response", "secp256k1", "wasm-ext", "wasm-ext-websocket", "macros", "yamux"] }
timed-map = { version = "1.1.1", features = ["rustc-hash"] }
timed-map = { version = "1.1.1", features = ["rustc-hash", "wasm"] }

[dev-dependencies]
async-std = "1.6.2"
Expand Down

0 comments on commit 5750415

Please sign in to comment.