Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
84da0c5
add large files example
bdemann Feb 21, 2024
0f97f8e
first pass as upload files
bdemann Feb 21, 2024
79687d9
add back end
bdemann Feb 21, 2024
9a45c2d
rename to asset uploader
bdemann Feb 21, 2024
90bf56c
Add and reorganize assets
bdemann Feb 22, 2024
45b4fc6
checkpoint
bdemann Feb 22, 2024
0aa6cad
update with broken length
bdemann Feb 23, 2024
c2d602a
upload single assets
bdemann Feb 23, 2024
e4ec925
rename to dfx entry to assets_large
bdemann Feb 23, 2024
bbd0244
create file generator
bdemann Feb 23, 2024
1e34930
update for easier size control
bdemann Feb 23, 2024
805101f
file generator does random bytes, better logs,
bdemann Feb 26, 2024
3fb943e
Add chunk write for large assets
bdemann Feb 26, 2024
b3c10ae
improve signature for upload-assets and combine with upload-asset
bdemann Feb 27, 2024
06e6d1e
add support for file generation bigger than 2GiB
bdemann Feb 27, 2024
2cd309d
remove test limit
bdemann Feb 27, 2024
7d71cf0
use read stream
bdemann Feb 27, 2024
9743423
checkpoint, up to 250GB hashing
bdemann Feb 27, 2024
448ef1e
new hashing system
bdemann Feb 28, 2024
3091b85
Add file hashing to node side
bdemann Feb 29, 2024
e88845d
set up most of the tests
bdemann Feb 29, 2024
1d2d980
try with production timing
bdemann Feb 29, 2024
348bdc6
skip generation of 0B file
bdemann Mar 1, 2024
5f4f5af
checkpoint
bdemann Mar 1, 2024
477bd3d
fix write limit to accommodate larger files, add back more tests
bdemann Mar 1, 2024
5daedb0
update Cargo.lock
bdemann Mar 7, 2024
0777d4e
stable storage checkpoint
bdemann Mar 4, 2024
9ab2ebc
clean up
bdemann Mar 4, 2024
648fcfc
clean up
bdemann Mar 4, 2024
377d1e9
kind of works checkpoint
bdemann Mar 5, 2024
0971449
works for less than 19 writing chunks
bdemann Mar 5, 2024
6bf50ed
fixup
bdemann Mar 5, 2024
5fa1e42
checkpoint
bdemann Mar 6, 2024
fbd2d53
checkpoint
bdemann Mar 6, 2024
21d3e8a
checkpoint
bdemann Mar 6, 2024
6d25b5d
fixup
bdemann Mar 6, 2024
c95f9ee
fixup
bdemann Mar 6, 2024
eb732f5
better logging
bdemann Mar 6, 2024
65b08b8
remove debugging prints
bdemann Mar 7, 2024
93dd8c1
move upload_assets to it's own mod
bdemann Mar 7, 2024
bb835a9
move temp chunks to it's own mod
bdemann Mar 7, 2024
559479a
use heap to store temp chunks
bdemann Mar 7, 2024
6fb4f31
remove curled folder
bdemann Mar 7, 2024
5a6af34
enable as many tests as will pass before running into the file limit
bdemann Mar 7, 2024
d25fc98
experiment with the test.yaml
bdemann Mar 7, 2024
f169fe9
fixup
bdemann Mar 7, 2024
9a6fff9
improved logging
bdemann Mar 7, 2024
8380d06
chmod in test.yml
bdemann Mar 7, 2024
313cb98
add err to on err
bdemann Mar 7, 2024
1e43392
fixup up into stuff with yml
bdemann Mar 7, 2024
d4f6118
make sure directories are created
bdemann Mar 7, 2024
eaa0066
fixup into file_generator
bdemann Mar 7, 2024
719eec4
fix up the audio and video example, get deployment process ready for …
lastmjs Mar 8, 2024
b704be7
Merge pull request #1694 from demergent-labs/infinite-files-mainnet
bdemann Mar 8, 2024
32438c5
checkpoint
bdemann Mar 8, 2024
a30ee2e
checkpoint before committing to createReadStream
bdemann Mar 10, 2024
282f792
pr fixes checkpoint
bdemann Mar 10, 2024
056777c
pr checkpoint
bdemann Mar 11, 2024
01446e2
pr fixes checkpoint
bdemann Mar 11, 2024
cfbc79f
pr fixes checkpoint
bdemann Mar 11, 2024
dec54f8
add authentication
bdemann Mar 18, 2024
768d4f1
finish tests
bdemann Mar 19, 2024
cc05737
rename function
bdemann Mar 19, 2024
e6ba76b
change dir name
bdemann Mar 19, 2024
fd56068
fixup
bdemann Mar 19, 2024
643c6b3
rename temp_chunks to write_chunk
bdemann Mar 19, 2024
0f60cc8
remove unused functions
bdemann Mar 19, 2024
a3c19c6
unify tests and file generation
bdemann Mar 19, 2024
ae974d6
pr fixes
bdemann Mar 19, 2024
62a1913
pr fixes
bdemann Mar 19, 2024
bff885a
Merge branch 'main' into stable-infinite-files
bdemann Mar 19, 2024
2d68941
rename upload assets
bdemann Mar 19, 2024
8040a7e
rename folder
bdemann Mar 19, 2024
5081529
fix dfx.json after name change
bdemann Mar 20, 2024
1073b36
clean up
bdemann Mar 20, 2024
241722a
make file_generator more declarative
bdemann Mar 20, 2024
c0818c9
make hash file more declarative
bdemann Mar 20, 2024
c6f976d
clean up file_uploader
bdemann Mar 20, 2024
225909f
fix assets_large
bdemann Mar 20, 2024
6c7f1a4
pr fixes
bdemann Mar 20, 2024
58d5ce2
finish ts side
bdemann Mar 20, 2024
81f24a7
fixup into ts side
bdemann Mar 20, 2024
190e2a0
update logs
bdemann Mar 20, 2024
c6fbd6c
rename version
bdemann Mar 20, 2024
2282e5c
pr fixes
bdemann Mar 20, 2024
ece2383
clean up versions
bdemann Mar 21, 2024
ec74897
make code more declarative
bdemann Mar 21, 2024
c85eecf
improved logging and hashing
bdemann Mar 21, 2024
f827135
fixup
bdemann Mar 21, 2024
d3e3cb8
Add support for 0 bytes files
bdemann Mar 21, 2024
cf132d0
await file total file upload
bdemann Mar 22, 2024
6ce6cfc
Break up file_uploader
bdemann Mar 22, 2024
abf38ec
update paths
bdemann Mar 22, 2024
2ce2b9a
remove files that weren't uploaded properly
bdemann Mar 22, 2024
1a7a1cf
quick fix
bdemann Mar 22, 2024
c28f235
pr fixes
bdemann Mar 22, 2024
44f1c1d
pr fixes
bdemann Mar 25, 2024
879d6fa
checkpoint
bdemann Mar 25, 2024
0243780
pr fixes
bdemann Mar 25, 2024
2287d0e
fixup
bdemann Mar 25, 2024
4151f1b
test
bdemann Mar 26, 2024
64d8be5
move actors into separate folder
bdemann Mar 26, 2024
e9dc676
pr fixes included adding types to actors
bdemann Mar 26, 2024
de74bbe
rename hash actor
bdemann Mar 26, 2024
3371e10
unify file methods into one actor
bdemann Mar 26, 2024
0299db2
rename actor
bdemann Mar 26, 2024
3f642b3
rename upload-files back to upload-assets
bdemann Mar 26, 2024
cdc3724
fixup into test
bdemann Mar 26, 2024
01067a8
fixup
bdemann Mar 26, 2024
a836a81
make on_before_exist more declarative
bdemann Mar 26, 2024
554b8c5
update _SERVICE types
bdemann Mar 26, 2024
c0ef78b
finish authorization tests
bdemann Mar 27, 2024
63391fd
Merge branch 'main' into stable-infinite-files
bdemann Mar 27, 2024
5637428
fix imports
bdemann Mar 27, 2024
f4d06e9
change from buffer to uint8array
bdemann Mar 27, 2024
f0e21c0
add filterAsync
bdemann Mar 27, 2024
c583f3e
better spacing
bdemann Mar 27, 2024
7264b96
add return type
bdemann Mar 27, 2024
2449615
rename and invert logic
bdemann Mar 27, 2024
edf835d
make more declarative
bdemann Mar 27, 2024
4890e4d
change let to const
bdemann Mar 27, 2024
a4a0db0
update comment
bdemann Mar 27, 2024
f8b89cb
update percentage for 0 byte files
bdemann Mar 27, 2024
d519f55
add message at end
bdemann Mar 27, 2024
9ed4da9
skip 2GiB tests
bdemann Mar 27, 2024
8367faa
fixup
bdemann Mar 27, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
"examples/inspect_message",
"examples/internet_identity",
"examples/key_value_store",
"examples/large_files",
"examples/ledger_canister",
"examples/list_of_lists",
"examples/management_canister",
Expand Down
6 changes: 4 additions & 2 deletions Cargo.lock

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

94 changes: 94 additions & 0 deletions dfx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { execSync } from 'child_process';
import { Secp256k1KeyIdentity } from '@dfinity/identity-secp256k1';
import { readFile } from 'fs/promises';
import { homedir } from 'os';
import { join } from 'path';
import { HttpAgent } from '@dfinity/agent';

export function getCanisterId(canisterName: string): string {
return execSync(
`dfx canister --network ${
process.env.DFX_NETWORK ?? 'local'
} id ${canisterName}`
)
.toString()
.trim();
}

export function getWebServerPort(): string {
return execSync(`dfx info webserver-port`).toString().trim();
}

export function getCanisterOrigin(canisterName: string): string {
return `http://${getCanisterId(
canisterName
)}.localhost:${getWebServerPort()}`;
}

export function getAgentHost(): string {
return process.env.DFX_NETWORK === 'ic'
? `https://icp-api.io`
: `http://127.0.0.1:${getWebServerPort()}`;
}

export async function createAnonymousAgent() {
const agent = new HttpAgent({
host: getAgentHost()
});

if (process.env.DFX_NETWORK !== 'ic') {
await agent.fetchRootKey();
}
}

export async function createAuthenticatedAgent(
identityName?: string
): Promise<HttpAgent> {
const agent = new HttpAgent({
host: getAgentHost(),
identity: getIdentity(identityName)
});

if (process.env.DFX_NETWORK !== 'ic') {
await agent.fetchRootKey();
}

return agent;
}

export function getIdentityName(): string {
return execSync(`dfx identity whoami`).toString().trim();
}

export function generateIdentity(name: string) {
execSync(`dfx identity new ${name} --storage-mode plaintext`);
}

export function useIdentity(name: string) {
execSync(`dfx identity use ${name}`);
}

export function getIdentities(): string[] {
const list = execSync(`dfx identity list`).toString().trim();
const identities = list.split('\n');

return identities;
}

export function removeIdentity(name: string) {
execSync(`dfx identity remove ${name}`);
}

export async function getIdentity(
identityName: string = getIdentityName()
): Promise<Secp256k1KeyIdentity> {
const identityPath = join(
homedir(),
'.config',
'dfx',
'identity',
identityName,
'identity.pem'
);
return Secp256k1KeyIdentity.fromPem(await readFile(identityPath, 'utf-8'));
}
3 changes: 2 additions & 1 deletion examples/apollo_server/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { getTests } from './tests';

const canisterId = getCanisterId('apollo_server');
Expand Down
3 changes: 2 additions & 1 deletion examples/async_await/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor } from './dfx_generated/async_await';
import { get_tests } from './tests';

Expand Down
3 changes: 3 additions & 0 deletions examples/audio_and_video/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.azle
.dfx
node_modules
src/backend/media/jordan_video_streaming_demo.mp4
src/backend/media/popeye_the_sailor_meets_sindbad_the_sailor.mp4
src/backend/media/the_memphis_belle.mp4
14 changes: 13 additions & 1 deletion examples/audio_and_video/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@
"gzip": true,
"assets": [
["src/frontend/dist", "dist"],
["src/backend/media", "media"]
["src/backend/media/audio.ogg", "media/audio.ogg"],
["src/backend/media/video.ogv", "media/video.ogv"]
],
"assets_large_commented_out": [
[
"src/backend/media/jordan_video_streaming_demo.mp4",
"media/jordan_video_streaming_demo.mp4"
],
[
"src/backend/media/popeye_the_sailor_meets_sindbad_the_sailor.mp4",
"media/popeye_the_sailor_meets_sindbad_the_sailor.mp4"
]
],
"post_install": "npx azle upload-assets backend",
"build_assets": "npm run build",
"metadata": [
{
Expand Down
96 changes: 87 additions & 9 deletions examples/audio_and_video/src/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,95 @@

<html>
<head>
<title>Audio and Video</title>
<title>ICP Video/Audio Streaming w/ Range Requests</title>
</head>

<body>
<video
src="media/video.ogv"
controls
></video>
<audio
src="media/audio.ogg"
controls
></audio>
<style>
.title {
display: flex;
flex-direction: column;
align-items: center;
}

.info {
padding-bottom: 25px;
}

.media-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.media-title {
padding: 25px;
}

video {
max-height: 75vh;
}
</style>

<div class="title">
<h1>ICP Video/Audio Streaming w/ Range Requests</h1>
<div class="info">
<div>
1.
<a
href="https://github.com/demergent-labs/azle/blob/main/examples/audio_and_video/src/backend/server.ts"
target="_blank"
>View the incredibly simple source code</a
>
</div>
<div>
2. Details on scalability are not fully known yet (consider
boundary node caching/limits + subnet/canister query limits)
</div>
<div>
3. Streaming is currently free (besides storage, upload,
etc); this will most likely change in the future
</div>
<div>
4. Very large file uploads (greater than ~20 MiB) will be
released in subsequent versions of Azle
</div>
</div>
</div>

<div class="media-container">
<video
src="media/jordan_video_streaming_demo.mp4"
controls
></video>
<div class="media-title">
Jordan Video Streaming Demo - 17.78 MiB
</div>
</div>

<div class="media-container">
<video
src="media/popeye_the_sailor_meets_sindbad_the_sailor.mp4"
controls
></video>
<div class="media-title">
<a
href="https://www.loc.gov/item/mbrs00068306"
target="_blank"
>Popeye the Sailor Meets Sindbad the Sailor - 611.98 MiB</a
>
</div>
</div>

<div class="media-container">
<audio
src="media/audio.ogg"
controls
></audio>
<div class="media-title">
Abraham Lincoln's Second Inaugural Address - 5.33 MiB
</div>
</div>
</body>
</html>
3 changes: 2 additions & 1 deletion examples/audio_and_video/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { getTests } from './tests';

const canisterId = getCanisterId('backend');
Expand Down
3 changes: 2 additions & 1 deletion examples/audio_recorder/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor } from '../test/dfx_generated/audio_recorder';
import { get_tests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/autoreload/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { getTests } from './tests';

const canisterId = getCanisterId('autoreload');
Expand Down
3 changes: 2 additions & 1 deletion examples/bitcoin/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests, Test } from 'azle/test';
import { runTests, Test } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from './dfx_generated/bitcoin';
import { wallets } from './wallets';
import { impureSetup, whileRunningBitcoinDaemon } from './setup';
Expand Down
3 changes: 2 additions & 1 deletion examples/blob_array/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from './dfx_generated/blob_array';
import { get_tests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/bytes/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from './dfx_generated/bytes_canister';
import { get_tests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/call_raw/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from '../test/dfx_generated/call_raw';
import { get_tests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/candid_encoding/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from './dfx_generated/candid_encoding';
import { get_tests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/candid_keywords/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { createActor } from './dfx_generated/candid_keywords';
import { getTests } from './tests';

Expand Down
2 changes: 1 addition & 1 deletion examples/canister/test/pretest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execSync } from 'child_process';
import { getCanisterId } from 'azle/test';
import { getCanisterId } from 'azle/dfx';

async function pretest() {
await new Promise((resolve) => setTimeout(resolve, 5000));
Expand Down
3 changes: 2 additions & 1 deletion examples/canister/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor } from './dfx_generated/canister';
import { getTests } from './tests';

Expand Down
3 changes: 2 additions & 1 deletion examples/canister/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, Test } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { Test } from 'azle/test';
import { _SERVICE } from './dfx_generated/canister/canister.did';
import { ActorSubclass } from '@dfinity/agent';
import { Principal } from '@dfinity/principal';
Expand Down
2 changes: 1 addition & 1 deletion examples/ckbtc/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActorSubclass } from '@dfinity/agent';
import { AzleResult, Test } from 'azle/test';
import { Identity } from '@dfinity/agent';
import { Ed25519KeyIdentity } from '@dfinity/identity';
import { getCanisterId } from 'azle/test';
import { getCanisterId } from 'azle/dfx';

// @ts-ignore
import { _SERVICE } from '../wallet/frontend/dfx_generated/wallet_backend/wallet_backend.did';
Expand Down
3 changes: 2 additions & 1 deletion examples/complex_init/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor as createComplexActor } from '../test/dfx_generated/complex_init';
// @ts-ignore
import { createActor as createRecActor } from '../test/dfx_generated/rec_init';
Expand Down
3 changes: 2 additions & 1 deletion examples/complex_types/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// TODO this needs to be more thoroughly tested

import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor } from '../test/dfx_generated/complex_types';
import { get_tests } from './tests';

Expand Down
2 changes: 1 addition & 1 deletion examples/composite_queries/test/pretest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCanisterId } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { execSync } from 'child_process';

async function pretest() {
Expand Down
3 changes: 2 additions & 1 deletion examples/composite_queries/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCanisterId, runTests } from 'azle/test';
import { getCanisterId } from 'azle/dfx';
import { runTests } from 'azle/test';
import { createActor } from './dfx_generated/canister1';
import { get_tests } from './tests';

Expand Down
Loading