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

feat: allow upload/retrieve of assets of arbitrary size from asset canister #1482

Merged
merged 52 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e0150aa
wip
ericswanson-dfinity Feb 16, 2021
42abc48
checkpoint stable memory ffs
ericswanson-dfinity Feb 17, 2021
38fedba
batch expiry map
ericswanson-dfinity Feb 17, 2021
0362051
create blobs compiles
ericswanson-dfinity Feb 17, 2021
4d270f0
create blobs
ericswanson-dfinity Feb 18, 2021
2d669d0
first pass writeBlob
ericswanson-dfinity Feb 18, 2021
8e6f956
motoko name conventions
ericswanson-dfinity Feb 18, 2021
c30fe2d
ugh
ericswanson-dfinity Feb 18, 2021
77de230
Word8 -> Nat8
ericswanson-dfinity Feb 18, 2021
5c6f39e
stable hash map stuff; start on first test
ericswanson-dfinity Feb 19, 2021
c4a7d87
SHM.get
ericswanson-dfinity Feb 19, 2021
8817568
wip
ericswanson-dfinity Feb 19, 2021
75d7561
wip
ericswanson-dfinity Feb 19, 2021
cf20411
first pass chunked retrieval
ericswanson-dfinity Feb 20, 2021
007260f
check write access; move set_asset_contents to non-async function
ericswanson-dfinity Feb 22, 2021
da9bc17
StableHashMap
ericswanson-dfinity Feb 23, 2021
0a1be8f
split up for commit_batch;
ericswanson-dfinity Feb 23, 2021
3efc721
adjust spacing for Motoko style guide, delete dead code, implement de…
ericswanson-dfinity Feb 23, 2021
5d4d117
wip
ericswanson-dfinity Feb 24, 2021
f8cd7fc
StableHashMap: fix divide-by-zero in remove
ericswanson-dfinity Feb 25, 2021
a32e0e5
CANISTER: fix variant names, commit_batch parameter
ericswanson-dfinity Feb 25, 2021
a964256
CANISTER: debug prints
ericswanson-dfinity Feb 25, 2021
c509998
DFX work: create batch and chunks
ericswanson-dfinity Feb 24, 2021
1fea9bf
DFX: commit batch
ericswanson-dfinity Feb 25, 2021
c02b697
DFX
ericswanson-dfinity Feb 25, 2021
c7c763e
DFX smaller async fns
ericswanson-dfinity Feb 25, 2021
2adca2b
DFX clippy
ericswanson-dfinity Feb 25, 2021
ec8c50a
DFX
ericswanson-dfinity Feb 27, 2021
e802ca0
DFX: slow, imperative upload that works
ericswanson-dfinity Mar 1, 2021
8291900
CANISTER: seperate Types.mo
ericswanson-dfinity Mar 2, 2021
43d3e5b
Remove StableHashMap:
ericswanson-dfinity Mar 2, 2021
7de6afa
expire batches
ericswanson-dfinity Mar 3, 2021
28c3948
e2e test - arbitrarily large files
ericswanson-dfinity Mar 4, 2021
2f6ea3f
dfx: comment out imports
ericswanson-dfinity Mar 4, 2021
ecba19f
canister: Batch class
ericswanson-dfinity Mar 4, 2021
4b04f3f
Move assetstorage.mo to assetstore/Main.mo
ericswanson-dfinity Mar 5, 2021
408330c
Asset.mo
ericswanson-dfinity Mar 5, 2021
c24f2a1
wip
ericswanson-dfinity Mar 8, 2021
83630e6
cleanup
ericswanson-dfinity Mar 8, 2021
3eaaf12
Update src/dfx/src/lib/installers/assets.rs
ericswanson-dfinity Mar 9, 2021
fb14c09
Use candid::Nat rather than u128
ericswanson-dfinity Mar 9, 2021
a432d2e
cargo fmt
ericswanson-dfinity Mar 9, 2021
377abbe
Add http_request method
ericswanson-dfinity Mar 9, 2021
592abae
Merge remote-tracking branch 'origin/master' into ericswanson/112-ass…
ericswanson-dfinity Mar 10, 2021
ea26fc0
Add keys() method for upgrade path; add to changelog
ericswanson-dfinity Mar 11, 2021
ab502fb
removed an extra word
ericswanson-dfinity Mar 11, 2021
6bbcb8d
Merge remote-tracking branch 'origin/master' into ericswanson/112-ass…
ericswanson-dfinity Mar 11, 2021
486eb3f
Merge remote-tracking branch 'origin/master' into ericswanson/112-ass…
ericswanson-dfinity Mar 11, 2021
d895d0b
ok maybe 25 MB was always going to take too long on CI
ericswanson-dfinity Mar 11, 2021
bd5a75b
disable large asset test on ic-ref due to wasm interpreter efficiency
ericswanson-dfinity Mar 11, 2021
d4f4ed1
serde_bytes for GetResponse
ericswanson-dfinity Mar 11, 2021
52c7d8e
Merge remote-tracking branch 'origin/master' into ericswanson/112-ass…
ericswanson-dfinity Mar 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ This commit also upgrades tokio and reqwest in order to work correctly. There ar

Renamed the `project_name` in our own generated assets to `canister_name`, for things that are generated during canister build (and not project generation).

---
== Asset Canister

=== feat: The asset canister can now store assets that exceed the message ingress limit (2 MB)

* Please note that neither the JS agent nor the HTTP server have been updated yet to server such large assets.
* The existing interface is left in place for backwards-compatibility, but deprecated:
** retrieve(): use get() and get_chunk() instead
** store(): use create_batch(), create_chunk(), and commit_batch() instead
** list(): use keys() instead

= 0.6.25

Expand Down
8 changes: 4 additions & 4 deletions distributed-canisters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ pkgs.runCommandNoCCLocal "distributed-canisters" {
} ''
mkdir -p $out

for canister_mo in ${distributed}/*.mo; do
canister_name=$(basename -s .mo $canister_mo)
for canister_dir in $(find ${distributed} -mindepth 1 -maxdepth 1 -type d); do
canister_name=$(basename $canister_dir)

build_dir=$out/$canister_name
mkdir -p $build_dir

$moc/bin/moc \
$canister_mo \
$canister_dir/Main.mo \
-o $build_dir/$canister_name.did \
--idl \
--package base $base
$moc/bin/moc \
$canister_mo \
$canister_dir/Main.mo \
-o $build_dir/$canister_name.wasm \
-c --release \
--package base $base
Expand Down
44 changes: 44 additions & 0 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,47 @@ teardown() {
it's cherry season
CHERRIES" "$stdout"
}

@test 'can store arbitrarily large files' {
[ "$USE_IC_REF" ] && skip "skip for ic-ref" # this takes too long for ic-ref's wasm interpreter

install_asset assetscanister

dfx_start
dfx canister create --all
dfx build
dfx canister install e2e_project_assets

dd if=/dev/urandom of=src/e2e_project_assets/assets/large-asset.bin bs=1000000 count=6

dfx deploy

assert_command dfx canister call --query e2e_project_assets get '(record{key="/large-asset.bin";accept_encodings=vec{"identity"}})'
assert_match 'total_length = 6_000_000'
ericswanson-dfinity marked this conversation as resolved.
Show resolved Hide resolved
assert_match 'content_type = "application/octet-stream"'
assert_match 'content_encoding = "identity"'

assert_command dfx canister call --query e2e_project_assets get_chunk '(record{key="/large-asset.bin";content_encoding="identity";index=2})'

assert_command dfx canister call --query e2e_project_assets get_chunk '(record{key="/large-asset.bin";content_encoding="identity";index=3})'
assert_command_fail dfx canister call --query e2e_project_assets get_chunk '(record{key="/large-asset.bin";content_encoding="identity";index=4})'
}

@test "list() and keys() return asset keys" {
install_asset assetscanister

dfx_start
dfx canister create --all
dfx build
dfx canister install e2e_project_assets

assert_command dfx canister call --query e2e_project_assets list
assert_match '"/binary/noise.txt"'
assert_match '"/text-with-newlines.txt"'
assert_match '"/sample-asset.txt"'

assert_command dfx canister call --query e2e_project_assets keys
assert_match '"/binary/noise.txt"'
assert_match '"/text-with-newlines.txt"'
assert_match '"/sample-asset.txt"'
}
Loading