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

update smoldot #755

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "vendor/smoldot"]
path = vendor/smoldot
url = https://github.com/ermalkaleci/smoldot.git
url = https://github.com/smol-dot/smoldot.git
56 changes: 32 additions & 24 deletions executor/Cargo.lock

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

3 changes: 3 additions & 0 deletions executor/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub struct TaskCall {
mock_signature_host: bool,
allow_unresolved_imports: bool,
runtime_log_level: u32,
storage_proof_size: u64,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -142,6 +143,8 @@ pub async fn run_task(task: TaskCall, js: crate::JsCallback) -> Result<TaskRespo
storage_main_trie_changes,
max_log_level: task.runtime_log_level,
calculate_trie_changes: false,
storage_proof_size_behavior:
runtime_call::StorageProofSizeBehavior::ConstantReturnValue(task.storage_proof_size),
});

let mut vm = match vm {
Expand Down
1 change: 1 addition & 0 deletions packages/chopsticks/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const setupContext = async (argv: Config, overrideParent = false) => {
offchainWorker: argv['offchain-worker'],
maxMemoryBlockCount: argv['max-memory-block-count'],
processQueuedMessages: argv['process-queued-messages'],
storageProofSize: argv['storage-proof-size'],
})

// load block from db
Expand Down
1 change: 1 addition & 0 deletions packages/chopsticks/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const configSchema = z.object({
description: 'Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid',
})
.optional(),
'storage-proof-size': z.number().optional(),
'max-memory-block-count': z.number().optional(),
db: z.string({ description: 'Path to database' }).optional(),
'wasm-override': z.string({ description: 'Path to wasm override' }).optional(),
Expand Down
6 changes: 6 additions & 0 deletions packages/chopsticks/src/schema/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ it('get yargs options from zod schema', () => {
"description": "Runtime maximum log level [off = 0; error = 1; warn = 2; info = 3; debug = 4; trace = 5]",
"type": "number",
},
"storage-proof-size": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "number",
},
"timestamp": {
"choices": undefined,
"demandOption": false,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/blockchain/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class Block {
mockSignatureHost: this.#chain.mockSignatureHost,
allowUnresolvedImports: this.#chain.allowUnresolvedImports,
runtimeLogLevel: this.#chain.runtimeLogLevel,
storageProofSize: this.#chain.storageProofSize,
},
taskHandler(this),
)
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/blockchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface Options {
maxMemoryBlockCount?: number
/** Whether to process queued messages */
processQueuedMessages?: boolean
/**
* Storage Proof Size passed to runtime.
* See <https://github.com/smol-dot/smoldot/blob/26dedea00eafa7073ca1d4678277272d807b3d89/lib/src/executor/host.rs#L248>
*/
storageProofSize?: number
qiweiii marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -86,6 +91,8 @@ export class Blockchain {
#runtimeLogLevel: number
/** Polkadot.js custom types registration. */
readonly registeredTypes: RegisteredTypes
/** Storage Proof Size passed to runtime. */
readonly storageProofSize?: number

readonly #txpool: TxPool
readonly #inherentProviders: InherentProvider[]
Expand Down Expand Up @@ -134,6 +141,7 @@ export class Blockchain {
header,
mockSignatureHost = false,
allowUnresolvedImports = false,
storageProofSize = 0,
runtimeLogLevel = 0,
registeredTypes = {},
offchainWorker = false,
Expand All @@ -144,6 +152,7 @@ export class Blockchain {
this.db = db
this.mockSignatureHost = mockSignatureHost
this.allowUnresolvedImports = allowUnresolvedImports
this.storageProofSize = storageProofSize
this.#runtimeLogLevel = runtimeLogLevel
this.registeredTypes = registeredTypes

Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type SetupOptions = {
offchainWorker?: boolean
maxMemoryBlockCount?: number
processQueuedMessages?: boolean
storageProofSize?: number
}

export const processOptions = async (options: SetupOptions) => {
Expand Down Expand Up @@ -92,6 +93,7 @@ export const setup = async (options: SetupOptions) => {
offchainWorker: opts.offchainWorker,
maxMemoryBlockCount: opts.maxMemoryBlockCount,
processQueuedMessages: opts.processQueuedMessages,
storageProofSize: opts.storageProofSize,
})

if (opts.genesis) {
Expand Down
23 changes: 13 additions & 10 deletions packages/core/src/wasm-executor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export type RuntimeVersion = {
stateVersion: number
}

export type TaskCall = {
wasm: HexString
calls: [string, HexString[]][]
mockSignatureHost: boolean
allowUnresolvedImports: boolean
runtimeLogLevel: number
storageProofSize?: number
}

export type RuntimeLog = {
message: string
level?: number
Expand Down Expand Up @@ -113,16 +122,10 @@ export const createProof = async (nodes: HexString[], updates: [HexString, HexSt
return { trieRootHash, nodes: newNodes }
}

export const runTask = async (
task: {
wasm: HexString
calls: [string, HexString[]][]
mockSignatureHost: boolean
allowUnresolvedImports: boolean
runtimeLogLevel: number
},
callback: JsCallback = emptyTaskHandler,
) => {
export const runTask = async (task: TaskCall, callback: JsCallback = emptyTaskHandler) => {
if (!task.storageProofSize) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let task2 = {
  ...task,
  storageProofSize: task.storageProofSize ?? 0
}

avoid modify input parameter

task.storageProofSize = 0
}
const worker = await getWorker()
logger.trace(truncate(task), 'taskRun')
const response = await worker.remote.runTask(task, Comlink.proxy(callback))
Expand Down
3 changes: 3 additions & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type SetupOption = {
runtimeLogLevel?: number
allowUnresolvedImports?: boolean
processQueuedMessages?: boolean
storageProofSize?: number
}

export type SetupConfig = Config & {
Expand All @@ -51,6 +52,7 @@ export const createConfig = ({
runtimeLogLevel,
allowUnresolvedImports,
processQueuedMessages,
storageProofSize,
}: SetupOption): SetupConfig => {
// random port if not specified
port = port ?? Math.floor(Math.random() * 10000) + 10000
Expand All @@ -68,6 +70,7 @@ export const createConfig = ({
resume: resume ?? false,
'allow-unresolved-imports': allowUnresolvedImports,
'process-queued-messages': processQueuedMessages,
'storage-proof-size': storageProofSize,
}
return config
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/smoldot
Submodule smoldot updated 43 files
+414 −387 Cargo.lock
+3 −3 full-node/Cargo.toml
+3 −0 full-node/src/consensus_service.rs
+8 −10 full-node/src/json_rpc_service.rs
+52 −63 full-node/src/json_rpc_service/chain_head_subscriptions.rs
+1 −0 full-node/src/json_rpc_service/requests_handler.rs
+3 −3 full-node/tests/author.rs
+8 −8 lib/Cargo.toml
+6 −0 lib/src/author/runtime.rs
+8 −2 lib/src/chain/async_tree.rs
+2 −0 lib/src/chain/chain_information/build.rs
+5 −0 lib/src/chain/fork_tree.rs
+89 −8 lib/src/executor/host.rs
+8 −2 lib/src/executor/host/tests.rs
+12 −2 lib/src/executor/host/tests/hash_algorithms.rs
+86 −11 lib/src/executor/host/tests/run.rs
+14 −2 lib/src/executor/runtime_call.rs
+2 −1 lib/src/executor/runtime_call/tests.rs
+21 −21 lib/src/executor/vm.rs
+9 −9 lib/src/executor/vm/interpreter.rs
+1 −0 lib/src/executor/vm/jit.rs
+17 −17 lib/src/json_rpc/methods.rs
+20 −20 lib/src/json_rpc/service/client_main_task.rs
+5 −5 lib/src/libp2p/multiaddr.rs
+2 −0 lib/src/transactions/validate/tests.rs
+936 −0 lib/src/trie/prefix_proof/test.json
+52 −14,469 lib/src/trie/prefix_proof/tests.rs
+4 −5 light-base/Cargo.toml
+64 −83 light-base/src/json_rpc_service.rs
+170 −112 light-base/src/json_rpc_service/background.rs
+1 −14 light-base/src/lib.rs
+1 −1 light-base/src/network_service.rs
+2 −0 light-base/src/runtime_service.rs
+32 −11 light-base/src/sync_service/parachain.rs
+1 −81 light-base/src/sync_service/standalone.rs
+30 −0 wasm-node/CHANGELOG.md
+769 −3,872 wasm-node/javascript/package-lock.json
+2 −2 wasm-node/javascript/package.json
+1 −1 wasm-node/javascript/src/internals/local-instance.ts
+12 −12 wasm-node/javascript/test/chainHead.mjs
+1 −0 wasm-node/javascript/tsconfig-cjs.json
+1 −0 wasm-node/javascript/tsconfig-mjs.json
+2 −2 wasm-node/rust/Cargo.toml
Loading