From 376a997246f529fb138a3c49f6d85742b5837044 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Thu, 8 Jun 2023 06:12:36 -0700 Subject: [PATCH 1/3] test: update canister_http test for transform with context See also: https://github.com/dfinity/examples/pull/357 --- e2e/assets/canister_http/main.mo | 14 ++++++++++---- e2e/assets/canister_http/types.mo | 15 ++++++++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/e2e/assets/canister_http/main.mo b/e2e/assets/canister_http/main.mo index c604359466..37f3804847 100644 --- a/e2e/assets/canister_http/main.mo +++ b/e2e/assets/canister_http/main.mo @@ -15,13 +15,19 @@ shared actor class HttpQuery() = this { { name = "User-Agent"; value = "sdk-e2e-test" }, ]; + let transform_context : Types.TransformContext = { + function = transform; + context = Blob.fromArray([]); + }; + + let request : Types.CanisterHttpRequestArgs = { url = url; max_response_bytes = ?MAX_RESPONSE_BYTES; headers = request_headers; body = null; method = #get; - transform = ?(#function(transform)); + transform = ?transform_context; }; Cycles.add(CYCLES_TO_PAY); @@ -34,10 +40,10 @@ shared actor class HttpQuery() = this { result }; - public query func transform(raw : Types.CanisterHttpResponsePayload) : async Types.CanisterHttpResponsePayload { + public query func transform(raw : Types.TransformArgs) : async Types.CanisterHttpResponsePayload { let transformed : Types.CanisterHttpResponsePayload = { - status = raw.status; - body = raw.body; + status = raw.response.status; + body = raw.response.body; headers = []; }; transformed; diff --git a/e2e/assets/canister_http/types.mo b/e2e/assets/canister_http/types.mo index e7d74f2e35..7bfbd85c28 100644 --- a/e2e/assets/canister_http/types.mo +++ b/e2e/assets/canister_http/types.mo @@ -1,3 +1,4 @@ +import Blob "mo:base/Blob"; import HashMap "mo:base/HashMap"; import Principal "mo:base/Principal"; @@ -26,8 +27,14 @@ module Types { #head; }; - public type TransformType = { - #function : shared CanisterHttpResponsePayload -> async CanisterHttpResponsePayload; + public type TransformArgs = { + response : CanisterHttpResponsePayload; + context : Blob; + }; + + public type TransformContext = { + function : shared query TransformArgs -> async CanisterHttpResponsePayload; + context : Blob; }; public type CanisterHttpRequestArgs = { @@ -36,9 +43,7 @@ module Types { headers : [HttpHeader]; body : ?[Nat8]; method : HttpMethod; - transform : ?{ - #function : shared query CanisterHttpResponsePayload -> async CanisterHttpResponsePayload; - }; + transform : ?TransformContext; }; public type CanisterHttpResponsePayload = { From 723febac29855a2c05526cc8aa9e9db2d04683f3 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Thu, 8 Jun 2023 06:30:11 -0700 Subject: [PATCH 2/3] Get icx-proxy binaries from the same place as all of the others --- nix/sources.json | 18 ++++++++---------- scripts/update-replica.sh | 2 ++ src/dfx/assets/dfx-asset-sources.toml | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index fe85e1ea75..c2560de450 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -142,21 +142,19 @@ }, "icx-proxy-x86_64-darwin": { "builtin": false, - "rev": "594b6c81cde6da4e08faee8aa8e5a2e6ae815602", - "sha256": "09rxh6kjwy7qfsvvsy6xjzyn4r4zlb78k1qipi4k3x0w0ajvp0sp", - "tag": "rev-c312760", + "rev": "794fc5b9341fa8f6a0e8f219201c35f0b5727ab9", + "sha256": "0k5h2xanhd7hqvgkdr05wqw7nswgwqc1xgk3n9abwk076n658n8g", "type": "file", - "url": "https://github.com/dfinity/icx-proxy/releases/download/rev-c312760/binaries-macos.tar.gz", - "url_template": "https://github.com/dfinity/icx-proxy/releases/download//binaries-macos.tar.gz" + "url": "https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-darwin/icx-proxy.gz", + "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-darwin/icx-proxy.gz" }, "icx-proxy-x86_64-linux": { "builtin": false, - "rev": "594b6c81cde6da4e08faee8aa8e5a2e6ae815602", - "sha256": "18czg11v5hiczqrahr962wmjig3gcafplqiprlnx44kmzfhi4mks", - "tag": "rev-c312760", + "rev": "794fc5b9341fa8f6a0e8f219201c35f0b5727ab9", + "sha256": "1fym7b8vnd32jz4pvf28vydhka8zzk6b1l4gm85y2v5lsvj17w49", "type": "file", - "url": "https://github.com/dfinity/icx-proxy/releases/download/rev-c312760/binaries-linux.tar.gz", - "url_template": "https://github.com/dfinity/icx-proxy/releases/download//binaries-linux.tar.gz" + "url": "https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-linux/icx-proxy.gz", + "url_template": "https://download.dfinity.systems/ic//openssl-static-binaries/x86_64-linux/icx-proxy.gz" }, "motoko-base": { "builtin": false, diff --git a/scripts/update-replica.sh b/scripts/update-replica.sh index 2df26a8e1f..ed1319faf7 100755 --- a/scripts/update-replica.sh +++ b/scripts/update-replica.sh @@ -20,6 +20,8 @@ niv update ic-nns-init-x86_64-darwin -a rev=$SHA niv update ic-nns-init-x86_64-linux -a rev=$SHA niv update ic-starter-x86_64-darwin -a rev=$SHA niv update ic-starter-x86_64-linux -a rev=$SHA +niv update icx-proxy-x86_64-darwin -a rev=$SHA +niv update icx-proxy-x86_64-linux -a rev=$SHA niv update replica-x86_64-darwin -a rev=$SHA niv update replica-x86_64-linux -a rev=$SHA niv update canister_sandbox-x86_64-darwin -a rev=$SHA diff --git a/src/dfx/assets/dfx-asset-sources.toml b/src/dfx/assets/dfx-asset-sources.toml index 84a87aeea5..878622c2e1 100644 --- a/src/dfx/assets/dfx-asset-sources.toml +++ b/src/dfx/assets/dfx-asset-sources.toml @@ -6,8 +6,8 @@ url = 'https://download.dfinity.systems/ic-ref/ic-ref-0.0.1-a9f73dba-x86_64-darw sha256 = 'e1c1694579f46d544aa87f6387d7e5a4b096fe65015b1609a459efcbaf15890f' [x86_64-darwin.icx-proxy] -url = 'https://github.com/dfinity/icx-proxy/releases/download/rev-c312760/binaries-macos.tar.gz' -sha256 = '5783bba5021cf43149bc118789cea29f6462fd97dd78bdb776f8782ea7813d27' +url = 'https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-darwin/icx-proxy.gz' +sha256 = '0f59548c35074cbe54b263be1e18e68f6b7b38e605e436dfc6f034685517b04c' [x86_64-darwin.ic-admin] url = 'https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-darwin/ic-admin.gz' @@ -64,8 +64,8 @@ url = 'https://download.dfinity.systems/ic-ref/ic-ref-0.0.1-a9f73dba-x86_64-linu sha256 = '5c4967764e87d1b2945b1db027422633b48f08cd01d96ba2f622753fcb62c2a4' [x86_64-linux.icx-proxy] -url = 'https://github.com/dfinity/icx-proxy/releases/download/rev-c312760/binaries-linux.tar.gz' -sha256 = '7a5612a1fb7512d22dcd37627a9d626fbc282b172665a832fe2cc2b243789fa1' +url = 'https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-linux/icx-proxy.gz' +sha256 = '89f013e4d6b46ce10baa8fd0b0ccfc1fa9099bdf48b87dc9976234bbd13ad5bb' [x86_64-linux.ic-admin] url = 'https://download.dfinity.systems/ic/794fc5b9341fa8f6a0e8f219201c35f0b5727ab9/openssl-static-binaries/x86_64-linux/ic-admin.gz' From a0eaa5047d949994cbd81fbacb30bfe0c13985bb Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Thu, 8 Jun 2023 07:03:11 -0700 Subject: [PATCH 3/3] fix prepare assets --- src/dfx/assets/prepare_assets.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dfx/assets/prepare_assets.rs b/src/dfx/assets/prepare_assets.rs index 64a8268a3d..6bcfe46385 100644 --- a/src/dfx/assets/prepare_assets.rs +++ b/src/dfx/assets/prepare_assets.rs @@ -113,7 +113,7 @@ fn write_binary_cache( Compression::new(6), )); for (path, bin) in bins.into_iter().chain( - ["icx-proxy", "ic-ref", "moc", "mo-doc", "mo-ide"] + ["ic-ref", "moc", "mo-doc", "mo-ide"] .map(|bin| (bin.into(), bin_tars.remove(Path::new(bin)).unwrap())), ) { let mut header = Header::new_gnu(); @@ -167,6 +167,7 @@ async fn download_binaries( "ic-btc-adapter", "ic-https-outcalls-adapter", "ic-nns-init", + "icx-proxy", "replica", "canister_sandbox", "sandbox_launcher", @@ -204,13 +205,13 @@ async fn download_bin_tarballs( sources: Arc>, ) -> HashMap { let mut map = HashMap::new(); - let [motoko, icx_proxy, ic_ref] = ["motoko", "icx-proxy", "ic-ref"].map(|pkg| { + let [motoko, ic_ref] = ["motoko", "ic-ref"].map(|pkg| { let client = client.clone(); let source = sources[pkg].clone(); spawn(download_and_check_sha(client, source)) }); - let (motoko, icx_proxy, ic_ref) = tokio::try_join!(motoko, icx_proxy, ic_ref).unwrap(); - for tar in [motoko, icx_proxy, ic_ref] { + let (motoko, ic_ref) = tokio::try_join!(motoko, ic_ref).unwrap(); + for tar in [motoko, ic_ref] { tar_xzf(&tar, |path, content| { map.insert(path, content); });