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

refactor: Upgrade actix-web #4268

Merged
merged 3 commits into from May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
198 changes: 88 additions & 110 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Expand Up @@ -70,8 +70,8 @@ neard = { path = "./neard"}

testlib = { path = "./test-utils/testlib" }

[replace]
"ethereum-types:0.10.0" = { path = "./patches/ethereum-types-0.10.0-to-0.11.0" }
[patch.crates-io]
ethereum-types = { path = "./patches/ethereum-types-0.10.0-to-0.11.0" }
frol marked this conversation as resolved.
Show resolved Hide resolved

[profile.release]
lto = true # Enable full link-time optimization.
Expand Down
5 changes: 3 additions & 2 deletions chain/jsonrpc/Cargo.toml
Expand Up @@ -6,8 +6,9 @@ edition = "2018"

[dependencies]
actix = "0.11.0-beta.2"
actix-web = "4.0.0-beta.3"
actix-cors = { git = "https://github.com/near/actix-extras.git", branch="actix-web-4-beta.3" }
awc = "3.0.0-beta.5"
actix-web = "4.0.0-beta.6"
actix-cors = { git = "https://github.com/near/actix-extras.git", branch="actix-web-4-beta.6" }
easy-ext = "0.2"
tokio = { version = "1.1", features = ["full"] }
futures = "0.3"
Expand Down
3 changes: 2 additions & 1 deletion chain/jsonrpc/client/Cargo.toml
Expand Up @@ -5,7 +5,8 @@ authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2018"

[dependencies]
actix-web = "4.0.0-beta.1"
awc = "3.0.0-beta.5"
actix-web = "4.0.0-beta.6"
futures = "0.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
5 changes: 2 additions & 3 deletions chain/jsonrpc/client/src/lib.rs
@@ -1,6 +1,6 @@
use std::time::Duration;

use actix_web::client::{Client, Connector};
use awc::{Client, Connector};
use futures::{future, future::LocalBoxFuture, FutureExt, TryFutureExt};
use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -260,8 +260,7 @@ fn create_client() -> Client {
.connector(
Connector::new()
.conn_lifetime(Duration::from_secs(u64::max_value()))
.conn_keep_alive(Duration::from_secs(30))
.finish(),
.conn_keep_alive(Duration::from_secs(30)),
)
.finish()
}
Expand Down
2 changes: 1 addition & 1 deletion chain/jsonrpc/tests/test_utils/mod.rs
Expand Up @@ -71,7 +71,7 @@ type RpcRequest<T> = LocalBoxFuture<'static, Result<T, near_jsonrpc_primitives::

/// Prepare a `RPCRequest` with a given client, server address, method and parameters.
pub fn call_method<R>(
client: &actix_web::client::Client,
client: &awc::Client,
server_addr: &str,
method: &str,
params: serde_json::Value,
Expand Down
7 changes: 4 additions & 3 deletions chain/rosetta-rpc/Cargo.toml
Expand Up @@ -12,17 +12,18 @@ hex = "0.4"
lazy_static = "1.4"
strum = { version = "0.20", features = ["derive"] }

awc = "3.0.0-beta.5"
actix = "0.11.0-beta.2"
actix-web = "4.0.0-beta.3"
actix-cors = { git = "https://github.com/near/actix-extras.git", branch="actix-web-4-beta.3" }
actix-web = "4.0.0-beta.6"
actix-cors = { git = "https://github.com/near/actix-extras.git", branch="actix-web-4-beta.6" }
futures = "0.3.5"
tokio = { version = "1.1", features = ["full"] }

serde = { version = "1", features = ["derive"] }
serde_json = "1"
validator = "0.12"

paperclip = { git = "https://github.com/frol/paperclip", branch = "actix-web-4-beta.3", features = ["actix"] }
paperclip = { git = "https://github.com/near/paperclip", branch = "actix-web-4-beta.6", features = ["actix"] }

near-primitives = { path = "../../core/primitives" }
near-crypto = { path = "../../core/crypto" }
Expand Down
5 changes: 2 additions & 3 deletions chain/rosetta-rpc/src/models.rs
Expand Up @@ -543,10 +543,9 @@ where
}

impl actix_web::ResponseError for Error {
fn error_response(&self) -> actix_web::HttpResponse {
fn error_response(&self) -> actix_web::BaseHttpResponse<actix_web::body::Body> {
let data = paperclip::actix::web::Json(self);
actix_web::HttpResponse::build(actix_web::http::StatusCode::INTERNAL_SERVER_ERROR)
.json(data)
actix_web::HttpResponse::InternalServerError().json(data).into()
}
}

Expand Down
3 changes: 2 additions & 1 deletion chain/telemetry/Cargo.toml
Expand Up @@ -6,7 +6,8 @@ edition = "2018"

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
actix-web = { version = "4.0.0-beta.1", features = [ "openssl" ] }
awc = "3.0.0-beta.5"
actix-web = { version = "4.0.0-beta.6", features = [ "openssl" ] }
futures = "0.3"
actix = "0.11.0-beta.2"
serde = { version = "1", features = [ "derive" ] }
Expand Down
5 changes: 2 additions & 3 deletions chain/telemetry/src/lib.rs
@@ -1,7 +1,7 @@
use std::time::Duration;

use actix::{Actor, Addr, Context, Handler, Message};
use actix_web::client::{Client, Connector};
use awc::{Client, Connector};
use futures::FutureExt;
use near_performance_metrics_macros::perf;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -49,8 +49,7 @@ impl TelemetryActor {
.connector(
Connector::new()
.conn_lifetime(Duration::from_secs(u64::max_value()))
.conn_keep_alive(Duration::from_secs(30))
.finish(),
.conn_keep_alive(Duration::from_secs(30)),
)
.finish();
Self { config, client }
Expand Down
2 changes: 1 addition & 1 deletion neard/Cargo.toml
Expand Up @@ -7,9 +7,9 @@ default-run = "neard"

[dependencies]
jemallocator = { version = "0.3" }
awc = "3.0.0-beta.5"
actix = "0.11.0-beta.2"
actix-rt = "2"
actix-web = { version = "4.0.0-beta.1", features = [ "openssl" ] }
byteorder = "1.2"
easy-ext = "0.2"
chrono = { version = "0.4.4", features = ["serde"] }
Expand Down
3 changes: 1 addition & 2 deletions neard/src/config.rs
Expand Up @@ -7,7 +7,6 @@ use std::sync::Arc;
use std::time::Duration;

use actix;
use actix_web;
use chrono::Utc;
use num_rational::Rational;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -1029,7 +1028,7 @@ pub fn download_genesis(url: &String, path: &PathBuf) {
let path = path.clone();

actix::System::new().block_on(async move {
let client = actix_web::client::Client::new();
let client = awc::Client::new();
let mut response =
client.get(url).send().await.expect("Unable to download the genesis file");

Expand Down