├── .cargo └── config.toml ├── .dockerignore ├── .editorconfig ├── .envrc ├── .gcloudignore ├── .git-blame-ignore-revs ├── .github ├── pull_request_template.md └── workflows │ ├── benchmarks.yml │ ├── docker-compose.yml │ ├── docker_image.yml │ ├── documentation.yml │ ├── dynamodb.yml │ ├── explorer.yml │ ├── long_faucet_chain_test.yml │ ├── performance_summary.yml │ ├── release.yml │ ├── rust.yml │ └── scylladb.yml ├── .gitignore ├── .taplo.toml ├── CLI.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── INSTALL.md ├── LICENSE ├── README.md ├── clippy.toml ├── configuration └── compose │ └── validator.toml ├── default.nix ├── docker ├── Dockerfile ├── compose-proxy-entrypoint.sh ├── compose-server-entrypoint.sh ├── compose-server-init.sh ├── compose.sh ├── dashboards │ └── linera-general.json ├── docker-compose.yml ├── prometheus.yml ├── provisioning │ └── dashboards │ │ └── dashboards.yml ├── proxy-entrypoint.sh ├── proxy-init.sh ├── server-entrypoint.sh └── server-init.sh ├── examples ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── agent │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── main.rs ├── amm │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs ├── call-evm-counter │ ├── Cargo.toml │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ └── service.rs ├── counter-no-graphql │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs ├── counter │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ ├── tests │ │ └── single_chain.rs │ └── web-frontend │ │ ├── .gitignore │ │ ├── .prettierignore │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── GraphQLProvider.js │ │ ├── index.css │ │ └── index.js │ │ └── tailwind.config.js ├── crowd-funding │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ └── tests │ │ └── campaign_lifecycle.rs ├── ethereum-tracker │ ├── Cargo.toml │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs ├── fungible │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ ├── tests │ │ └── cross_chain.rs │ └── web-frontend │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codegen.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── manifest.json │ │ └── robots.txt │ │ ├── src │ │ ├── App.css │ │ ├── App.tsx │ │ ├── GraphQLProvider.js │ │ ├── assets │ │ │ ├── icons │ │ │ │ ├── Error.tsx │ │ │ │ ├── Loader.tsx │ │ │ │ └── Success.tsx │ │ │ └── images │ │ │ │ └── logo.png │ │ ├── components │ │ │ ├── DialogSuccess.tsx │ │ │ ├── ErrorMessage.tsx │ │ │ └── Header.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── qql │ │ │ ├── fragment-masking.ts │ │ │ ├── gql.ts │ │ │ ├── graphql.ts │ │ │ └── index.ts │ │ └── react-app-env.d.ts │ │ ├── tailwind.config.js │ │ └── tsconfig.json ├── gen-nft │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── model.rs │ │ ├── random.rs │ │ ├── service.rs │ │ ├── state.rs │ │ └── token.rs │ └── web-frontend │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── GraphQLProvider.js │ │ ├── Loader.js │ │ ├── index.css │ │ ├── index.js │ │ └── logo.svg │ │ └── tailwind.config.js ├── hex-game │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ └── tests │ │ └── hex_game.rs ├── how-to │ └── perform-http-requests │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ ├── test_http_server.rs │ │ └── unit_tests │ │ │ ├── contract.rs │ │ │ └── service.rs │ │ └── tests │ │ ├── http_requests.rs │ │ └── http_server │ │ └── mod.rs ├── llm │ ├── .cargo │ │ └── config.toml │ ├── .gitignore │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── random.rs │ │ ├── service.rs │ │ └── token.rs │ └── web-frontend │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── Chat.js │ │ ├── GraphQLProvider.js │ │ ├── index.css │ │ ├── index.js │ │ └── logo.svg │ │ └── tailwind.config.js ├── matching-engine │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ └── tests │ │ └── transaction.rs ├── meta-counter │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ └── service.rs ├── native-fungible │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ └── service.rs │ └── tests │ │ └── transfers.rs ├── non-fungible │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs │ └── web-frontend │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── GraphQLProvider.js │ │ ├── index.css │ │ ├── index.js │ │ └── logo.svg │ │ └── tailwind.config.js ├── rfq │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── contract.rs │ │ ├── lib.rs │ │ ├── service.rs │ │ └── state.rs ├── rust-toolchain.toml └── social │ ├── Cargo.toml │ ├── README.md │ ├── src │ ├── contract.rs │ ├── lib.rs │ ├── service.rs │ └── state.rs │ ├── tests │ └── cross_chain.rs │ └── web-frontend │ ├── .env │ ├── .gitignore │ ├── README.md │ ├── codegen.ts │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── public │ ├── index.html │ └── linera.png │ ├── src │ ├── App.tsx │ ├── GraphQLProvider.jsx │ ├── __generated__ │ │ ├── fragment-masking.ts │ │ ├── gql.ts │ │ ├── graphql.ts │ │ └── index.ts │ ├── assets │ │ ├── linera.png │ │ └── uploadimage.png │ ├── components │ │ ├── LeftSideMenu.tsx │ │ ├── Navbar.tsx │ │ ├── NewPost.tsx │ │ └── PostCard.tsx │ ├── images.d.ts │ ├── index.css │ ├── index.tsx │ ├── input.css │ └── utils │ │ └── time.ts │ ├── tailwind.config.js │ ├── tsconfig.json │ └── vite.config.ts ├── flake.lock ├── flake.nix ├── kubernetes └── linera-validator │ ├── .helmignore │ ├── Chart.lock │ ├── Chart.yaml │ ├── README.md │ ├── charts │ ├── kube-prometheus-stack-51.0.3.tgz │ └── loki-stack-2.8.9.tgz │ ├── grafana-dashboards │ ├── linera │ │ ├── execution.json │ │ ├── general.json │ │ ├── storage.json │ │ ├── views.json │ │ └── vms │ │ │ └── ethereum.json │ ├── scylla-manager │ │ └── scylla-manager.3.4.json │ └── scylla │ │ ├── scylla-advanced.6.2.json │ │ ├── scylla-alternator.6.2.json │ │ ├── scylla-cql.6.2.json │ │ ├── scylla-detailed.6.2.json │ │ ├── scylla-ks.6.2.json │ │ ├── scylla-os.6.2.json │ │ └── scylla-overview.6.2.json │ ├── helmfile.yaml │ ├── scylla-manager.values.yaml │ ├── scylla-operator.values.yaml │ ├── scylla-setup │ ├── gke-daemonset-raid-disks.yaml │ ├── local-csi-driver │ │ ├── 00_namespace.yaml │ │ ├── 10_csidriver.yaml │ │ ├── 10_driver_serviceaccount.yaml │ │ ├── 10_provisioner_clusterrole.yaml │ │ ├── 20_provisioner_clusterrolebinding.yaml │ │ └── 50_daemonset.yaml │ └── local-ssd-sc.yaml │ ├── scylla.values.yaml.gotmpl │ ├── templates │ ├── NOTES.txt │ ├── config.yaml │ ├── grafana-cloud-auth-secret.yaml │ ├── grafana-linera-dashboards-config.yaml │ ├── grafana-linera-vms-dashboards-config.yaml │ ├── grafana-scylla-dashboards-config-0.yaml │ ├── grafana-scylla-dashboards-config-1.yaml │ ├── grafana-scylla-manager-dashboards-config.yaml │ ├── ingress.yaml │ ├── prometheus.yaml │ ├── proxy.yaml │ ├── scylla-config.yaml │ ├── scylla-recording-rules.yaml │ └── shards.yaml │ ├── values-local.yaml.gotmpl │ └── working │ └── .placeholder ├── linera-base ├── Cargo.toml ├── README.md ├── build.rs ├── src │ ├── abi.rs │ ├── command.rs │ ├── crypto │ │ ├── ed25519.rs │ │ ├── hash.rs │ │ ├── mod.rs │ │ ├── secp256k1 │ │ │ ├── evm.rs │ │ │ └── mod.rs │ │ └── signer.rs │ ├── data_types.rs │ ├── dyn_convert.rs │ ├── graphql.rs │ ├── hashed.rs │ ├── http.rs │ ├── identifiers.rs │ ├── lib.rs │ ├── limited_writer.rs │ ├── ownership.rs │ ├── port.rs │ ├── prometheus_util.rs │ ├── task.rs │ ├── time.rs │ ├── tracing.rs │ ├── tracing_web.rs │ ├── unit_tests.rs │ └── vm.rs └── tests │ └── command_tests.rs ├── linera-chain ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── block.rs │ ├── block_tracker.rs │ ├── certificate │ ├── confirmed.rs │ ├── generic.rs │ ├── lite.rs │ ├── mod.rs │ ├── timeout.rs │ └── validated.rs │ ├── chain.rs │ ├── data_types.rs │ ├── inbox.rs │ ├── lib.rs │ ├── manager.rs │ ├── outbox.rs │ ├── pending_blobs.rs │ ├── test │ ├── http_server.rs │ └── mod.rs │ └── unit_tests │ ├── chain_tests.rs │ ├── data_types_tests.rs │ ├── inbox_tests.rs │ └── outbox_tests.rs ├── linera-client ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── benchmark.rs │ ├── chain_listener.rs │ ├── client_context.rs │ ├── client_options.rs │ ├── config.rs │ ├── error.rs │ ├── lib.rs │ ├── unit_tests │ ├── chain_listener.rs │ ├── mod.rs │ ├── util.rs │ └── wallet.rs │ ├── util.rs │ └── wallet.rs ├── linera-core ├── Cargo.toml ├── README.md ├── benches │ ├── client_benchmarks.rs │ ├── hashing_benchmarks.rs │ └── recorder.rs ├── build.rs └── src │ ├── chain_worker │ ├── actor.rs │ ├── config.rs │ ├── delivery_notifier.rs │ ├── mod.rs │ └── state │ │ ├── attempted_changes.rs │ │ ├── mod.rs │ │ └── temporary_changes.rs │ ├── client │ ├── chain_client_state.rs │ └── mod.rs │ ├── data_types.rs │ ├── environment.rs │ ├── join_set_ext.rs │ ├── lib.rs │ ├── local_node.rs │ ├── node.rs │ ├── notifier.rs │ ├── remote_node.rs │ ├── unit_tests │ ├── client_tests.rs │ ├── test_helpers.rs │ ├── test_utils.rs │ ├── value_cache_tests.rs │ ├── wasm_client_tests.rs │ ├── wasm_worker_tests.rs │ └── worker_tests.rs │ ├── updater.rs │ ├── value_cache.rs │ └── worker.rs ├── linera-ethereum ├── Cargo.toml ├── README.md ├── build.rs ├── contracts │ ├── EventNumerics.json │ ├── SimpleToken.json │ ├── event_numerics.sol │ └── simple_token.sol ├── src │ ├── client.rs │ ├── common.rs │ ├── lib.rs │ ├── provider.rs │ └── test_utils │ │ └── mod.rs └── tests │ └── ethereum_test.rs ├── linera-execution ├── Cargo.toml ├── README.md ├── build.rs ├── solidity │ ├── Linera.sol │ └── LineraTypes.sol ├── src │ ├── bin │ │ └── wit_generator.rs │ ├── committee.rs │ ├── evm │ │ ├── database.rs │ │ ├── mod.rs │ │ └── revm.rs │ ├── execution.rs │ ├── execution_state_actor.rs │ ├── graphql.rs │ ├── lib.rs │ ├── policy.rs │ ├── resources.rs │ ├── runtime.rs │ ├── system.rs │ ├── test_utils │ │ ├── mock_application.rs │ │ ├── mod.rs │ │ ├── solidity.rs │ │ └── system_execution_state.rs │ ├── transaction_tracker.rs │ ├── unit_tests │ │ ├── applications_tests.rs │ │ ├── runtime_tests.rs │ │ └── system_tests.rs │ ├── util │ │ ├── mod.rs │ │ └── sync_response.rs │ └── wasm │ │ ├── entrypoints.rs │ │ ├── mod.rs │ │ ├── module_cache.rs │ │ ├── runtime_api.rs │ │ ├── wasmer.rs │ │ └── wasmtime.rs ├── tests │ ├── contract_runtime_apis.rs │ ├── fee_consumption.rs │ ├── fixtures │ │ ├── counter_contract.wasm │ │ ├── counter_service.wasm │ │ ├── evm_example_counter.sol │ │ └── evm_too_long_service.sol │ ├── revm.rs │ ├── service_runtime_apis.rs │ ├── test_execution.rs │ ├── test_system_execution.rs │ └── wasm.rs └── update_wasm_fixtures.sh ├── linera-explorer ├── .gitignore ├── Cargo.toml ├── README.md ├── codegen_indexer.ts ├── codegen_operations.ts ├── codegen_service.ts ├── index.html ├── package-lock.json ├── package.json ├── rust-toolchain.toml ├── src │ ├── components │ │ ├── App.test.ts │ │ ├── App.vue │ │ ├── Application.test.ts │ │ ├── Application.vue │ │ ├── Applications.test.ts │ │ ├── Applications.vue │ │ ├── Block.test.ts │ │ ├── Block.vue │ │ ├── Blocks.test.ts │ │ ├── Blocks.vue │ │ ├── Chain.vue │ │ ├── Entrypoint.test.ts │ │ ├── Entrypoint.vue │ │ ├── InputType.test.ts │ │ ├── InputType.vue │ │ ├── Json.test.ts │ │ ├── Json.vue │ │ ├── Op.test.ts │ │ ├── Op.vue │ │ ├── Operation.test.ts │ │ ├── Operation.vue │ │ ├── Operations.test.ts │ │ ├── Operations.vue │ │ ├── OutputType.test.ts │ │ ├── OutputType.vue │ │ ├── Plugin.test.ts │ │ ├── Plugin.vue │ │ └── utils.ts │ ├── entrypoint.rs │ ├── graphql.rs │ ├── input_type.rs │ ├── js_utils.rs │ ├── lib.rs │ ├── main.ts │ ├── types.ts │ └── types │ │ └── json-formatter-js.d.ts ├── tsconfig.json └── vite.config.ts ├── linera-faucet ├── client │ ├── Cargo.toml │ ├── README.md │ └── src │ │ └── lib.rs └── server │ ├── Cargo.toml │ ├── README.md │ └── src │ ├── lib.rs │ └── tests.rs ├── linera-indexer ├── example │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ └── main.rs │ └── tests │ │ └── test.rs ├── graphql-client │ ├── Cargo.toml │ ├── README.md │ ├── gql │ │ ├── indexer_requests.graphql │ │ ├── indexer_schema.graphql │ │ ├── operations_requests.graphql │ │ └── operations_schema.graphql │ ├── src │ │ ├── indexer.rs │ │ ├── lib.rs │ │ └── operations.rs │ └── tests │ │ └── test.rs ├── lib │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── common.rs │ │ ├── indexer.rs │ │ ├── lib.rs │ │ ├── plugin.rs │ │ ├── rocks_db.rs │ │ ├── runner.rs │ │ ├── scylla_db.rs │ │ └── service.rs └── plugins │ ├── Cargo.toml │ ├── README.md │ └── src │ ├── lib.rs │ ├── operations.rs │ └── template.rs ├── linera-persistent ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── dirty.rs │ ├── file.rs │ ├── indexed_db.rs │ ├── lib.rs │ └── memory.rs ├── linera-protocol.code-workspace ├── linera-rpc ├── Cargo.toml ├── README.md ├── binary_formats.yaml ├── build.rs ├── proto │ └── rpc.proto ├── src │ ├── client.rs │ ├── config.rs │ ├── cross_chain_message_queue.rs │ ├── grpc │ │ ├── client.rs │ │ ├── conversions.rs │ │ ├── mod.rs │ │ ├── node_provider.rs │ │ ├── pool.rs │ │ ├── server.rs │ │ └── transport.rs │ ├── lib.rs │ ├── message.rs │ ├── node_provider.rs │ └── simple │ │ ├── client.rs │ │ ├── codec.rs │ │ ├── mod.rs │ │ ├── node_provider.rs │ │ ├── server.rs │ │ └── transport.rs └── tests │ ├── format.rs │ ├── snapshots │ └── format__format.yaml.snap │ └── transport.rs ├── linera-sdk-derive ├── Cargo.toml ├── README.md └── src │ ├── lib.rs │ └── utils.rs ├── linera-sdk ├── Cargo.toml ├── README.md ├── build.rs ├── src │ ├── abis │ │ ├── evm.rs │ │ ├── fungible.rs │ │ └── mod.rs │ ├── base │ │ ├── conversions_from_wit.rs │ │ ├── conversions_to_wit.rs │ │ └── mod.rs │ ├── contract │ │ ├── conversions_from_wit.rs │ │ ├── conversions_to_wit.rs │ │ ├── mod.rs │ │ ├── runtime.rs │ │ ├── test_runtime.rs │ │ └── wit.rs │ ├── ethereum.rs │ ├── extensions.rs │ ├── graphql.rs │ ├── lib.rs │ ├── linera_base_types.rs │ ├── log.rs │ ├── service │ │ ├── conversions_to_wit.rs │ │ ├── mod.rs │ │ ├── runtime.rs │ │ ├── test_runtime.rs │ │ └── wit.rs │ ├── test │ │ ├── block.rs │ │ ├── chain.rs │ │ ├── mock_stubs.rs │ │ ├── mod.rs │ │ └── validator.rs │ ├── util.rs │ └── views │ │ ├── aliases.rs │ │ ├── mock_key_value_store.rs │ │ ├── mod.rs │ │ └── system_api.rs └── wit │ ├── README.md │ ├── base-runtime-api.wit │ ├── contract-entrypoints.wit │ ├── contract-runtime-api.wit │ ├── contract.wit │ ├── service-entrypoints.wit │ ├── service-runtime-api.wit │ └── service.wit ├── linera-service-graphql-client ├── Cargo.toml ├── README.md ├── gql │ ├── service_requests.graphql │ └── service_schema.graphql ├── src │ ├── lib.rs │ ├── service.rs │ └── utils.rs └── tests │ ├── test.rs │ └── test_check_service_schema.rs ├── linera-service ├── Cargo.toml ├── README.md ├── benches │ └── transfers.rs ├── build.rs ├── src │ ├── benchmark.rs │ ├── cli │ │ ├── command.rs │ │ ├── main.rs │ │ ├── mod.rs │ │ └── net_up_utils.rs │ ├── cli_wrappers │ │ ├── docker.rs │ │ ├── helmfile.rs │ │ ├── kind.rs │ │ ├── kubectl.rs │ │ ├── local_kubernetes_net.rs │ │ ├── local_net.rs │ │ ├── mod.rs │ │ ├── remote_net.rs │ │ ├── util.rs │ │ └── wallet.rs │ ├── lib.rs │ ├── linera-exporter │ │ ├── exporter_service.rs │ │ ├── main.rs │ │ └── state.rs │ ├── node_service.rs │ ├── project.rs │ ├── prometheus_server.rs │ ├── proxy │ │ ├── grpc.rs │ │ └── main.rs │ ├── schema_export.rs │ ├── server.rs │ ├── storage.rs │ ├── util.rs │ └── wallet.rs ├── template │ ├── Cargo.toml.template │ ├── contract.rs.template │ ├── lib.rs.template │ ├── linera_net_helper.sh │ ├── rust-toolchain.toml.template │ ├── service.rs.template │ ├── state.rs.template │ └── tests │ │ └── single_chain.rs.template └── tests │ ├── common │ └── mod.rs │ ├── fixtures │ ├── evm_basic_check.sol │ ├── evm_call_evm_example_counter.sol │ ├── evm_call_wasm_example_counter.sol │ ├── evm_example_counter.sol │ ├── evm_example_empty_instantiate.sol │ ├── evm_example_execute_message.sol │ ├── evm_example_log.sol │ └── evm_test_linera_features.sol │ ├── guard │ └── mod.rs │ ├── linera_net_tests.rs │ ├── local.rs │ ├── local_net_tests.rs │ └── readme_test.rs ├── linera-storage-service ├── Cargo.toml ├── README.md ├── benches │ └── store.rs ├── build.rs ├── proto │ └── key_value_store.proto ├── src │ ├── child.rs │ ├── client.rs │ ├── common.rs │ ├── lib.rs │ └── server.rs └── tests │ └── store_test.rs ├── linera-storage ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── db_storage.rs │ └── lib.rs ├── linera-summary ├── Cargo.toml ├── README.md └── src │ ├── ci_runtime_comparison.rs │ ├── github.rs │ ├── lib.rs │ ├── main.rs │ ├── performance_summary.rs │ └── summary_options.rs ├── linera-version ├── Cargo.toml ├── README.md ├── api-hashes.json ├── build.rs ├── src │ ├── lib.rs │ ├── main.rs │ ├── serde_pretty │ │ ├── mod.rs │ │ └── type.rs │ └── version_info │ │ ├── mod.rs │ │ └── type.rs └── tests │ └── up_to_date.rs ├── linera-views-derive ├── Cargo.toml ├── README.md └── src │ ├── lib.rs │ └── snapshots │ ├── linera_views_derive__tests__generate_clonable_view_code-2.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-3.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-4.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-5.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-6.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-7.snap │ ├── linera_views_derive__tests__generate_clonable_view_code-8.snap │ ├── linera_views_derive__tests__generate_clonable_view_code.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-2.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-3.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-4.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-5.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-6.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-7.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code-8.snap │ ├── linera_views_derive__tests__generate_crypto_hash_code.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_C.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_C_with_where.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_CustomContext.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_CustomContext_with_where.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_custom__GenericContext_T_.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_custom__GenericContext_T__with_where.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_custom__path__to__ContextType.snap │ ├── linera_views_derive__tests__test_generate_hash_view_code_custom__path__to__ContextType_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_C.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_C_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_CustomContext.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_CustomContext_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_custom__GenericContext_T_.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_custom__GenericContext_T__with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_custom__path__to__ContextType.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_custom__path__to__ContextType_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_C.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_C_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_CustomContext.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_CustomContext_with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_custom__GenericContext_T_.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_custom__GenericContext_T__with_where.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_custom__path__to__ContextType.snap │ ├── linera_views_derive__tests__test_generate_root_view_code_metrics_custom__path__to__ContextType_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_C.snap │ ├── linera_views_derive__tests__test_generate_view_code_C_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_CustomContext.snap │ ├── linera_views_derive__tests__test_generate_view_code_CustomContext_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_custom__GenericContext_T_.snap │ ├── linera_views_derive__tests__test_generate_view_code_custom__GenericContext_T__with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_custom__path__to__ContextType.snap │ ├── linera_views_derive__tests__test_generate_view_code_custom__path__to__ContextType_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_C.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_C_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_CustomContext.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_CustomContext_with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_custom__GenericContext_T_.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_custom__GenericContext_T__with_where.snap │ ├── linera_views_derive__tests__test_generate_view_code_metrics_custom__path__to__ContextType.snap │ └── linera_views_derive__tests__test_generate_view_code_metrics_custom__path__to__ContextType_with_where.snap ├── linera-views ├── Cargo.toml ├── DESIGN.md ├── README.md ├── benches │ ├── queue_view.rs │ ├── reentrant_collection_view.rs │ └── stores.rs ├── build.rs ├── src │ ├── backends │ │ ├── dual.rs │ │ ├── dynamo_db.rs │ │ ├── indexed_db.rs │ │ ├── journaling.rs │ │ ├── lru_caching.rs │ │ ├── memory.rs │ │ ├── metering.rs │ │ ├── mod.rs │ │ ├── rocks_db.rs │ │ ├── scylla_db.rs │ │ └── value_splitting.rs │ ├── batch.rs │ ├── common.rs │ ├── context.rs │ ├── error.rs │ ├── graphql.rs │ ├── lib.rs │ ├── metrics.rs │ ├── random.rs │ ├── store.rs │ ├── test_utils │ │ ├── mod.rs │ │ ├── performance.rs │ │ └── test_views.rs │ └── views │ │ ├── bucket_queue_view.rs │ │ ├── collection_view.rs │ │ ├── hashable_wrapper.rs │ │ ├── key_value_store_view.rs │ │ ├── log_view.rs │ │ ├── map_view.rs │ │ ├── mod.rs │ │ ├── queue_view.rs │ │ ├── reentrant_collection_view.rs │ │ ├── register_view.rs │ │ ├── set_view.rs │ │ └── unit_tests │ │ └── views.rs └── tests │ ├── admin_tests.rs │ ├── hashable_tests.rs │ ├── random_container_tests.rs │ ├── store_tests.rs │ └── views_tests.rs ├── linera-web ├── .cargo │ └── config.toml ├── .gitignore ├── Cargo.toml ├── build.bash ├── package.json └── src │ └── lib.rs ├── linera-witty-macros ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── lib.rs │ ├── unit_tests │ ├── specialization.rs │ ├── wit_load.rs │ ├── wit_store.rs │ └── wit_type.rs │ ├── util │ ├── fields.rs │ ├── mod.rs │ └── specialization.rs │ ├── wit_export │ ├── caller_type_parameter.rs │ ├── function_information.rs │ └── mod.rs │ ├── wit_import.rs │ ├── wit_interface.rs │ ├── wit_load.rs │ ├── wit_store.rs │ └── wit_type.rs ├── linera-witty ├── Cargo.toml ├── README.md ├── build.rs ├── src │ ├── exported_function_interface │ │ ├── guest_interface.rs │ │ ├── mod.rs │ │ └── result_storage.rs │ ├── imported_function_interface │ │ ├── mod.rs │ │ ├── parameters.rs │ │ └── results.rs │ ├── lib.rs │ ├── macro_utils.rs │ ├── memory_layout │ │ ├── element.rs │ │ ├── flat_layout.rs │ │ ├── join_flat_layouts.rs │ │ ├── layout.rs │ │ └── mod.rs │ ├── primitive_types │ │ ├── array.rs │ │ ├── flat_type.rs │ │ ├── join_flat_types.rs │ │ ├── maybe_flat_type.rs │ │ ├── mod.rs │ │ └── simple_type.rs │ ├── runtime │ │ ├── borrowed_instance.rs │ │ ├── error.rs │ │ ├── memory.rs │ │ ├── mod.rs │ │ ├── test.rs │ │ ├── traits.rs │ │ ├── unit_tests │ │ │ └── memory.rs │ │ ├── wasmer │ │ │ ├── export_function.rs │ │ │ ├── function.rs │ │ │ ├── memory.rs │ │ │ ├── mod.rs │ │ │ ├── parameters.rs │ │ │ └── results.rs │ │ └── wasmtime │ │ │ ├── export_function.rs │ │ │ ├── function.rs │ │ │ ├── memory.rs │ │ │ ├── mod.rs │ │ │ ├── parameters.rs │ │ │ └── results.rs │ ├── test.rs │ ├── type_traits │ │ ├── implementations │ │ │ ├── custom_types.rs │ │ │ ├── frunk.rs │ │ │ ├── log.rs │ │ │ ├── mod.rs │ │ │ ├── std │ │ │ │ ├── box.rs │ │ │ │ ├── collections.rs │ │ │ │ ├── floats.rs │ │ │ │ ├── integers.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── option.rs │ │ │ │ ├── phantom_data.rs │ │ │ │ ├── primitives.rs │ │ │ │ ├── rc.rs │ │ │ │ ├── result.rs │ │ │ │ ├── slices.rs │ │ │ │ ├── string.rs │ │ │ │ ├── sync.rs │ │ │ │ ├── time.rs │ │ │ │ ├── tuples.rs │ │ │ │ └── vec.rs │ │ │ └── tests.rs │ │ ├── mod.rs │ │ └── register_wit_types.rs │ ├── util │ │ ├── merge.rs │ │ ├── mod.rs │ │ ├── split.rs │ │ └── zero_extend.rs │ └── wit_generation │ │ ├── mod.rs │ │ └── stub_instance.rs ├── test-modules │ ├── Cargo.toml │ ├── src │ │ ├── export │ │ │ ├── getters.rs │ │ │ ├── operations.rs │ │ │ ├── setters.rs │ │ │ └── simple_function.rs │ │ ├── import │ │ │ ├── getters.rs │ │ │ ├── operations.rs │ │ │ ├── setters.rs │ │ │ └── simple_function.rs │ │ └── reentrancy │ │ │ ├── getters.rs │ │ │ ├── global_state.rs │ │ │ ├── operations.rs │ │ │ ├── setters.rs │ │ │ └── simple_function.rs │ └── wit │ │ ├── entrypoint.wit │ │ ├── export.wit │ │ ├── getters.wit │ │ ├── global-state.wit │ │ ├── import.wit │ │ ├── operations.wit │ │ ├── reentrancy.wit │ │ ├── setters.wit │ │ └── simple-function.wit └── tests │ ├── common │ ├── test_instance.rs │ ├── types.rs │ └── wit_interface_test.rs │ ├── reentrancy.rs │ ├── snapshots │ ├── reentrancy__entrypoint.snap │ ├── reentrancy__getters.snap │ ├── reentrancy__operations.snap │ ├── reentrancy__setters.snap │ ├── reentrancy__simple_function.snap │ ├── reentrancy__wit_world_file.snap │ ├── wit_export__entrypoint.snap │ ├── wit_export__getters.snap │ ├── wit_export__operations.snap │ ├── wit_export__setters.snap │ ├── wit_export__simple-function.snap │ ├── wit_export__wit_world_file.snap │ ├── wit_import__getters.snap │ ├── wit_import__operations.snap │ ├── wit_import__setters.snap │ ├── wit_import__simple-function.snap │ └── wit_import__wit_world_file.snap │ ├── wit_export.rs │ ├── wit_import.rs │ ├── wit_load.rs │ ├── wit_store.rs │ └── wit_type.rs ├── packages.txt ├── rust-toolchain.toml ├── rustfmt.toml ├── scripts ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── check_chain_loads.sh ├── check_copyright_header │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── deploy-validator.sh ├── install_hooks.sh ├── linera_net_helper.sh ├── owner.sh ├── publish.sh ├── test_publish.sh └── yank.sh ├── shell.nix ├── spellcheck-cfg.toml ├── spellcheck-dictionary.txt └── toolchains ├── nightly └── rust-toolchain.toml └── stable └── rust-toolchain.toml /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.aarch64-unknown-linux-gnu] 2 | linker = "aarch64-linux-gnu-gcc" 3 | 4 | [build] 5 | # We allow redundant explicit links because `cargo rdme` doesn't know how to resolve implicit intra-crate links. 6 | rustdocflags = ["-Arustdoc::redundant_explicit_links"] 7 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------------* 2 | # This will prevent your local modules and debug logs from being copied onto your 3 | # Docker image and possibly overwriting modules installed within your image. 4 | # ---------------------------------------------------------------------------------* 5 | node_modules 6 | *.log 7 | # ignore .git and .cache folders 8 | .git 9 | .cache 10 | # ignore all markdown files (md) beside all README*.md other than README-secret.md 11 | *.md 12 | !README*.md 13 | README-secret.md 14 | # github related files 15 | .github/ 16 | scripts/target 17 | examples/target 18 | Dockerfile 19 | .dockerignore 20 | .gitignore 21 | .gcloudignore 22 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.rs] 8 | indent_style = space 9 | indent_size = 4 10 | trim_trailing_whitespace = true 11 | max_line_length = 90 12 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.gcloudignore: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------------* 2 | # This will prevent your local modules and debug logs from being copied onto your 3 | # Docker image and possibly overwriting modules installed within your image. 4 | # ---------------------------------------------------------------------------------* 5 | node_modules 6 | npm-debug.log 7 | # ignore .git and .cache folders 8 | .git 9 | .cache 10 | # ignore all markdown files (md) beside all README*.md other than README-secret.md 11 | *.md 12 | !README*.md 13 | README-secret.md 14 | # github related files 15 | .github/ 16 | target 17 | scripts/target 18 | examples/target 19 | .gitignore 20 | .gcloudignore 21 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make `git blame` ignore the following commits. 2 | 3 | # upload node_modules 4 | f0a4fad16b59fdf726f03eed9d523dbabd610402 5 | # remove node_modules 6 | 359c74a60671e54cd017eda7b0622e3c4a5c6c0b 7 | -------------------------------------------------------------------------------- /.github/workflows/benchmarks.yml: -------------------------------------------------------------------------------- 1 | name: Benchmarks 2 | 3 | on: 4 | push: 5 | branches: [ main, 'devnet_*', 'testnet_*' ] 6 | workflow_dispatch: 7 | 8 | env: 9 | CARGO_TERM_COLOR: always 10 | CARGO_NET_RETRY: 10 11 | 12 | jobs: 13 | benchmark: 14 | runs-on: ubuntu-latest 15 | timeout-minutes: 40 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: actions-rust-lang/setup-rust-toolchain@v1 20 | - name: Clear up some space 21 | run: | 22 | sudo rm -rf /usr/share/dotnet 23 | sudo rm -rf /opt/ghc 24 | sudo rm -rf "/usr/local/share/boost" 25 | sudo rm -rf "$AGENT_TOOLSDIRECTORY" 26 | - name: Install Protoc 27 | uses: arduino/setup-protoc@v1 28 | with: 29 | repo-token: ${{ secrets.GITHUB_TOKEN }} 30 | - name: Run benchmarks 31 | run: | 32 | cargo bench -p linera-service 33 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create Network Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'testnet-*-v[0-9]+.[0-9]+.[0-9]+' 7 | - 'devnet-*-v[0-9]+.[0-9]+.[0-9]+' 8 | 9 | jobs: 10 | release: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Extract Tag Name 16 | id: tag 17 | run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT 18 | 19 | - name: Create GitHub Release 20 | uses: softprops/action-gh-release@v2 21 | with: 22 | tag_name: ${{ steps.tag.outputs.TAG_NAME }} 23 | name: ${{ steps.tag.outputs.TAG_NAME }} 24 | generate_release_notes: false 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # These are backup files generated by rustfmt 6 | **/*.rs.bk 7 | 8 | # emacs 9 | *~ 10 | 11 | # vim 12 | *.swp 13 | 14 | # idea 15 | *.iml 16 | .idea/ 17 | 18 | # VSCode 19 | .vscode 20 | /.direnv 21 | 22 | # Cursor 23 | .cursor 24 | 25 | # Helm 26 | kubernetes/linera-validator/working/* 27 | node_modules 28 | -------------------------------------------------------------------------------- /.taplo.toml: -------------------------------------------------------------------------------- 1 | include = ["**/Cargo.toml"] 2 | 3 | [formatting] 4 | reorder_keys = false 5 | indent_string = " " 6 | 7 | [[rule]] 8 | keys = ["dependencies", "workspace.dependencies", "dev-dependencies"] 9 | 10 | [rule.formatting] 11 | reorder_keys = true 12 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | future-size-threshold = 7000 2 | -------------------------------------------------------------------------------- /configuration/compose/validator.toml: -------------------------------------------------------------------------------- 1 | # This is the configuration file for running 2 | # a single validator in Docker Compose. 3 | # In Docker Compose, the hostname of a service 4 | # is the name of the service. 5 | 6 | server_config_path = "server.json" 7 | host = "127.0.0.1" 8 | port = 19100 9 | metrics_port = 21100 10 | internal_host = "proxy" 11 | internal_port = 20100 12 | [external_protocol] 13 | Grpc = "ClearText" 14 | [internal_protocol] 15 | Grpc = "ClearText" 16 | 17 | [[shards]] 18 | host = "docker-shard-1" 19 | port = 19100 20 | metrics_port = 21100 21 | 22 | [[shards]] 23 | host = "docker-shard-2" 24 | port = 19100 25 | metrics_port = 21100 26 | 27 | [[shards]] 28 | host = "docker-shard-3" 29 | port = 19100 30 | metrics_port = 21100 31 | 32 | [[shards]] 33 | host = "docker-shard-4" 34 | port = 19100 35 | metrics_port = 21100 36 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { crane, pkgs, rust-toolchain, libclang, rocksdb, git }: 2 | ((crane.mkLib pkgs).overrideToolchain rust-toolchain).buildPackage { 3 | pname = "linera"; 4 | src = ./.; 5 | cargoExtraArgs = "-p linera-service"; 6 | nativeBuildInputs = with pkgs; [ 7 | clang 8 | pkg-config 9 | rocksdb 10 | protobufc 11 | ]; 12 | buildInputs = with pkgs; [ 13 | clang.cc.lib 14 | libiconv 15 | nodejs 16 | openssl 17 | protobuf 18 | git 19 | wasm-bindgen-cli 20 | pnpm 21 | ]; 22 | checkInputs = with pkgs; [ 23 | # for native testing 24 | jq 25 | kubernetes-helm 26 | kind 27 | kubectl 28 | 29 | # for Wasm testing 30 | chromium 31 | chromedriver 32 | ]; 33 | passthru = { inherit rust-toolchain; }; 34 | RUST_SRC_PATH = rust-toolchain.availableComponents.rust-src; 35 | LIBCLANG_PATH = "${libclang.lib}/lib"; 36 | ROCKSDB_LIB_DIR = "${rocksdb}/lib"; 37 | } 38 | -------------------------------------------------------------------------------- /docker/compose-proxy-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage_replication_factor=$1 4 | 5 | exec ./linera-proxy \ 6 | --storage scylladb:tcp:scylla:9042 \ 7 | --genesis /config/genesis.json \ 8 | --storage-replication-factor $storage_replication_factor \ 9 | /config/server.json 10 | -------------------------------------------------------------------------------- /docker/compose-server-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage=$1 4 | storage_replication_factor=$2 5 | 6 | exec ./linera-server run \ 7 | --storage $storage \ 8 | --server /config/server.json \ 9 | --shard 0 \ 10 | --genesis /config/genesis.json \ 11 | --storage-replication-factor $storage_replication_factor 12 | -------------------------------------------------------------------------------- /docker/compose-server-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage=$1 4 | 5 | while true; do 6 | ./linera storage check-existence --storage $storage 7 | status=$? 8 | 9 | if [ $status -eq 0 ]; then 10 | echo "Database already exists, no need to initialize." 11 | exit 0 12 | elif [ $status -eq 1 ]; then 13 | echo "Database does not exist, attempting to initialize..." 14 | if ./linera-server initialize \ 15 | --storage $storage \ 16 | --genesis /config/genesis.json; then 17 | echo "Initialization successful." 18 | exit 0 19 | else 20 | echo "Initialization failed, retrying in 5 seconds..." 21 | sleep 5 22 | fi 23 | else 24 | echo "An unexpected error occurred (status: $status), retrying in 5 seconds..." 25 | sleep 5 26 | fi 27 | done 28 | -------------------------------------------------------------------------------- /docker/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s 3 | 4 | scrape_configs: 5 | - job_name: 'metrics-server' 6 | static_configs: 7 | - targets: ['proxy:21100', 'shard:21100'] 8 | -------------------------------------------------------------------------------- /docker/provisioning/dashboards/dashboards.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | providers: 4 | - name: 'linera' 5 | orgId: 1 6 | folder: '' 7 | type: file 8 | disableDeletion: false 9 | updateIntervalSeconds: 10 10 | options: 11 | path: /var/lib/grafana/dashboards 12 | -------------------------------------------------------------------------------- /docker/proxy-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage_replication_factor=$1 4 | 5 | exec ./linera-proxy \ 6 | --storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \ 7 | --genesis /config/genesis.json \ 8 | --storage-replication-factor $storage_replication_factor \ 9 | /config/server.json 10 | -------------------------------------------------------------------------------- /docker/proxy-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do 4 | ./linera storage check-existence --storage "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042" 5 | status=$? 6 | 7 | if [ "$status" -eq 0 ]; then 8 | echo "Database already exists, no need to initialize." 9 | exit 0 10 | else 11 | # We rely on the shards to initialize the database, so just wait here 12 | if [ "$status" -eq 1 ]; then 13 | echo "Database does not exist, retrying in 5 seconds..." 14 | else 15 | echo "An unexpected error occurred (status: $status), retrying in 5 seconds..." 16 | fi 17 | sleep 5 18 | fi 19 | done 20 | -------------------------------------------------------------------------------- /docker/server-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage=$1 4 | storage_replication_factor=$2 5 | 6 | # Extract the ordinal number from the pod hostname 7 | ORDINAL="${HOSTNAME##*-}" 8 | 9 | exec ./linera-server run \ 10 | --storage $storage \ 11 | --server /config/server.json \ 12 | --shard $ORDINAL \ 13 | --genesis /config/genesis.json \ 14 | --storage-replication-factor $storage_replication_factor 15 | -------------------------------------------------------------------------------- /docker/server-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | storage=$1 4 | storage_replication_factor=$2 5 | 6 | while true; do 7 | ./linera storage check-existence --storage $storage 8 | status=$? 9 | 10 | if [ $status -eq 0 ]; then 11 | echo "Database already exists, no need to initialize." 12 | exit 0 13 | elif [ $status -eq 1 ]; then 14 | echo "Database does not exist, attempting to initialize..." 15 | if ./linera-server initialize \ 16 | --storage $storage \ 17 | --genesis /config/genesis.json \ 18 | --storage-replication-factor $storage_replication_factor; then 19 | echo "Initialization successful." 20 | exit 0 21 | else 22 | echo "Initialization failed, retrying in 5 seconds..." 23 | sleep 5 24 | fi 25 | else 26 | echo "An unexpected error occurred (status: $status), retrying in 5 seconds..." 27 | sleep 5 28 | fi 29 | done 30 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /examples/agent/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /examples/agent/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | [package] 3 | name = "agent" 4 | version = "0.1.0" 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "1.0.95" 9 | clap = { version = "4.5.26", features = ["derive"] } 10 | reqwest = { version = "0.11.24", default-features = false, features = [ 11 | "rustls-tls", 12 | "json", 13 | ] } 14 | rig-core = "0.12.0" 15 | serde = { version = "1.0.152", features = ["derive"] } 16 | serde_json = "1.0.93" 17 | tokio = { version = "1.25.0", features = ["macros", "rt-multi-thread"] } 18 | url = "2.4" 19 | 20 | [package.metadata.cargo-machete] 21 | ignored = ["rig-core"] 22 | -------------------------------------------------------------------------------- /examples/amm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "amm" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | fungible.workspace = true 10 | linera-sdk.workspace = true 11 | matching-engine.workspace = true 12 | num-bigint.workspace = true 13 | num-traits.workspace = true 14 | serde.workspace = true 15 | 16 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 17 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 18 | tokio = { workspace = true, features = ["rt", "sync"] } 19 | 20 | [[bin]] 21 | name = "amm_contract" 22 | path = "src/contract.rs" 23 | 24 | [[bin]] 25 | name = "amm_service" 26 | path = "src/service.rs" 27 | -------------------------------------------------------------------------------- /examples/amm/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use fungible::Account; 5 | use linera_sdk::{ 6 | linera_base_types::Amount, 7 | views::{linera_views, MapView, RegisterView, RootView, ViewStorageContext}, 8 | }; 9 | 10 | #[derive(RootView, async_graphql::SimpleObject)] 11 | #[view(context = ViewStorageContext)] 12 | pub struct AmmState { 13 | pub shares: MapView, 14 | pub total_shares_supply: RegisterView, 15 | } 16 | -------------------------------------------------------------------------------- /examples/call-evm-counter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "call-evm-counter" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | alloy-primitives.workspace = true 9 | alloy-sol-types.workspace = true 10 | linera-sdk.workspace = true 11 | serde.workspace = true 12 | 13 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 14 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 15 | tokio = { workspace = true, features = ["rt", "sync"] } 16 | 17 | [dev-dependencies] 18 | assert_matches.workspace = true 19 | linera-sdk = { workspace = true, features = ["test"] } 20 | 21 | [[bin]] 22 | name = "call_evm_counter_contract" 23 | path = "src/contract.rs" 24 | 25 | [[bin]] 26 | name = "call_evm_counter_service" 27 | path = "src/service.rs" 28 | -------------------------------------------------------------------------------- /examples/call-evm-counter/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! ABI of the Counter Example Application that does not use GraphQL */ 5 | 6 | use linera_sdk::linera_base_types::{ContractAbi, ServiceAbi}; 7 | use serde::{Deserialize, Serialize}; 8 | 9 | pub struct CallCounterAbi; 10 | 11 | impl ContractAbi for CallCounterAbi { 12 | type Operation = CallCounterOperation; 13 | type Response = u64; 14 | } 15 | 16 | impl ServiceAbi for CallCounterAbi { 17 | type Query = CallCounterRequest; 18 | type QueryResponse = u64; 19 | } 20 | 21 | #[derive(Debug, Serialize, Deserialize)] 22 | pub enum CallCounterRequest { 23 | Query, 24 | Increment(u64), 25 | } 26 | 27 | #[derive(Debug, Serialize, Deserialize)] 28 | pub enum CallCounterOperation { 29 | Increment(u64), 30 | } 31 | -------------------------------------------------------------------------------- /examples/counter-no-graphql/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "counter-no-graphql" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | futures.workspace = true 9 | linera-sdk.workspace = true 10 | serde.workspace = true 11 | 12 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 13 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 14 | tokio = { workspace = true, features = ["rt", "sync"] } 15 | 16 | [dev-dependencies] 17 | assert_matches.workspace = true 18 | linera-sdk = { workspace = true, features = ["test"] } 19 | 20 | [[bin]] 21 | name = "counter_no_graphql_contract" 22 | path = "src/contract.rs" 23 | 24 | [[bin]] 25 | name = "counter_no_graphql_service" 26 | path = "src/service.rs" 27 | -------------------------------------------------------------------------------- /examples/counter-no-graphql/README.md: -------------------------------------------------------------------------------- 1 | # Counter No GraphQL Example Application 2 | 3 | This example application implements a simple counter contract, it is initialized with an 4 | unsigned integer that can be increased by the `increment` operation. In contrast with the 5 | counter application, it works without GraphQL. 6 | 7 | ## How It Works 8 | 9 | It is a simple Linera application, which is initialized by a `u64` which can be incremented 10 | by a `u64`. 11 | 12 | For example, if the contract was initialized with 1, querying the contract would give us 1. Now if we want to 13 | `increment` it by 3, we will have to perform an operation with the parameter being 3. Now querying the 14 | application would give us 4 (1+3 = 4). 15 | 16 | ## Usage 17 | -------------------------------------------------------------------------------- /examples/counter-no-graphql/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! ABI of the Counter Example Application that does not use GraphQL */ 5 | 6 | use linera_sdk::linera_base_types::{ContractAbi, ServiceAbi}; 7 | use serde::{Deserialize, Serialize}; 8 | 9 | pub struct CounterNoGraphQlAbi; 10 | 11 | impl ContractAbi for CounterNoGraphQlAbi { 12 | type Operation = CounterOperation; 13 | type Response = u64; 14 | } 15 | 16 | impl ServiceAbi for CounterNoGraphQlAbi { 17 | type Query = CounterRequest; 18 | type QueryResponse = u64; 19 | } 20 | 21 | #[derive(Debug, Serialize, Deserialize)] 22 | pub enum CounterRequest { 23 | Query, 24 | Increment(u64), 25 | } 26 | 27 | #[derive(Debug, Serialize, Deserialize)] 28 | pub enum CounterOperation { 29 | Increment(u64), 30 | } 31 | -------------------------------------------------------------------------------- /examples/counter-no-graphql/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use linera_sdk::views::{linera_views, RegisterView, RootView, ViewStorageContext}; 5 | 6 | /// The application state. 7 | #[derive(RootView)] 8 | #[view(context = ViewStorageContext)] 9 | pub struct CounterState { 10 | pub value: RegisterView, 11 | } 12 | -------------------------------------------------------------------------------- /examples/counter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "counter" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | futures.workspace = true 10 | linera-sdk.workspace = true 11 | serde_json.workspace = true 12 | 13 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 14 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 15 | tokio = { workspace = true, features = ["rt", "sync"] } 16 | 17 | [dev-dependencies] 18 | assert_matches.workspace = true 19 | linera-sdk = { workspace = true, features = ["test"] } 20 | 21 | [[bin]] 22 | name = "counter_contract" 23 | path = "src/contract.rs" 24 | 25 | [[bin]] 26 | name = "counter_service" 27 | path = "src/service.rs" 28 | -------------------------------------------------------------------------------- /examples/counter/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! ABI of the Counter Example Application */ 5 | 6 | use async_graphql::{Request, Response}; 7 | use linera_sdk::linera_base_types::{ContractAbi, ServiceAbi}; 8 | 9 | pub struct CounterAbi; 10 | 11 | impl ContractAbi for CounterAbi { 12 | type Operation = u64; 13 | type Response = u64; 14 | } 15 | 16 | impl ServiceAbi for CounterAbi { 17 | type Query = Request; 18 | type QueryResponse = Response; 19 | } 20 | -------------------------------------------------------------------------------- /examples/counter/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use linera_sdk::views::{linera_views, RegisterView, RootView, ViewStorageContext}; 5 | 6 | /// The application state. 7 | #[derive(RootView)] 8 | #[view(context = ViewStorageContext)] 9 | pub struct CounterState { 10 | pub value: RegisterView, 11 | } 12 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/.prettierignore: -------------------------------------------------------------------------------- 1 | build 2 | coverage 3 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web-frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@apollo/client": "^3.7.10", 7 | "graphql": "^16.6.0", 8 | "graphql-ws": "^5.12.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-router-dom": "^6.9.0", 12 | "react-scripts": "^5.0.1" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app" 23 | ] 24 | }, 25 | "browserslist": { 26 | "production": [ 27 | ">0.2%", 28 | "not dead", 29 | "not op_mini all" 30 | ], 31 | "development": [ 32 | "last 1 chrome version", 33 | "last 1 firefox version", 34 | "last 1 safari version" 35 | ] 36 | }, 37 | "devDependencies": { 38 | "prettier": "2.8.4", 39 | "tailwindcss": "^3.2.7" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/counter/web-frontend/public/favicon.ico -------------------------------------------------------------------------------- /examples/counter/web-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Linera Counter Demo 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-header { 6 | background-color: #282c34; 7 | min-height: 100vh; 8 | display: flex; 9 | flex-direction: column; 10 | align-items: center; 11 | justify-content: center; 12 | font-size: calc(10px + 2vmin); 13 | color: white; 14 | } 15 | 16 | .increment { 17 | @apply font-medium focus:outline-none focus:ring active:bg-blue-700 bg-blue-500 my-10 hover:bg-blue-600 text-white px-2 py-2 rounded-full py-2 px-4; 18 | } 19 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /examples/counter/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./src/**/*.{js,jsx,ts,tsx}"], 4 | theme: { 5 | fontFamily: { 6 | sans: ['"PT Sans"', "sans-serif"], 7 | }, 8 | }, 9 | plugins: [], 10 | }; 11 | -------------------------------------------------------------------------------- /examples/crowd-funding/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "crowd-funding" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | fungible.workspace = true 10 | linera-sdk.workspace = true 11 | serde.workspace = true 12 | serde_json.workspace = true 13 | 14 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 15 | fungible = { workspace = true, features = ["test"] } 16 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 17 | tokio.workspace = true 18 | 19 | [[bin]] 20 | name = "crowd_funding_contract" 21 | path = "src/contract.rs" 22 | 23 | [[bin]] 24 | name = "crowd_funding_service" 25 | path = "src/service.rs" 26 | -------------------------------------------------------------------------------- /examples/ethereum-tracker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ethereum-tracker" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | alloy-primitives.workspace = true 9 | async-graphql.workspace = true 10 | linera-sdk = { workspace = true, features = ["ethereum"] } 11 | serde.workspace = true 12 | 13 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 14 | linera-sdk = { workspace = true, features = ["test", "wasmer", "ethereum"] } 15 | tokio = { workspace = true, features = ["rt", "sync"] } 16 | 17 | [dev-dependencies] 18 | assert_matches.workspace = true 19 | linera-sdk = { workspace = true, features = ["test", "ethereum"] } 20 | 21 | [[bin]] 22 | name = "ethereum_tracker_contract" 23 | path = "src/contract.rs" 24 | 25 | [[bin]] 26 | name = "ethereum_tracker_service" 27 | path = "src/service.rs" 28 | -------------------------------------------------------------------------------- /examples/ethereum-tracker/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use ethereum_tracker::U256Cont; 5 | use linera_sdk::views::{linera_views, MapView, RegisterView, RootView, ViewStorageContext}; 6 | 7 | /// The application state. 8 | #[derive(RootView, async_graphql::SimpleObject)] 9 | #[view(context = ViewStorageContext)] 10 | pub struct EthereumTrackerState { 11 | pub ethereum_endpoint: RegisterView, 12 | pub contract_address: RegisterView, 13 | pub start_block: RegisterView, 14 | pub accounts: MapView, 15 | } 16 | -------------------------------------------------------------------------------- /examples/fungible/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fungible" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [features] 8 | test = [] 9 | 10 | [dependencies] 11 | async-graphql.workspace = true 12 | futures.workspace = true 13 | linera-sdk.workspace = true 14 | serde.workspace = true 15 | 16 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 17 | fungible = { workspace = true, features = ["test"] } 18 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 19 | tokio.workspace = true 20 | 21 | [[bin]] 22 | name = "fungible_contract" 23 | path = "src/contract.rs" 24 | 25 | [[bin]] 26 | name = "fungible_service" 27 | path = "src/service.rs" 28 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/codegen.ts: -------------------------------------------------------------------------------- 1 | import { CodegenConfig } from '@graphql-codegen/cli'; 2 | 3 | 4 | const port = 8080; 5 | const chainId = "aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8"; 6 | const appId = "4855b92a65ca13ccf487f1a8f0225b49d9423c03be41996b582d96b5d1df28b2e97939c7631f353e08f6308f702abe2f1b4dd2c7b6358b22cf39bf331b76446faee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8010000000000000000000000" 7 | 8 | 9 | const config: CodegenConfig = { 10 | schema: `http://localhost:${port}/chains/${chainId}/applications/${appId}`, 11 | // this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure 12 | documents: ['src/**/*.{ts,tsx}'], 13 | generates: { 14 | './src/qql/': { 15 | preset: 'client', 16 | plugins: [], 17 | } 18 | }, 19 | ignoreNoDocuments: true, 20 | }; 21 | 22 | export default config; -------------------------------------------------------------------------------- /examples/fungible/web-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/fungible/web-frontend/public/favicon.ico -------------------------------------------------------------------------------- /examples/fungible/web-frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/assets/icons/Error.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function IconError() { 4 | return ( 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/assets/icons/Loader.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function IconLoader() { 4 | return ( 5 | 6 | 7 | 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/assets/icons/Success.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function IconSuccess() { 4 | return ( 5 | 6 | 7 | 8 | 9 | ); 10 | }; 11 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/fungible/web-frontend/src/assets/images/logo.png -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/components/ErrorMessage.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { IconError } from "../assets/icons/Error"; 3 | 4 | type ErrorMessageProps = { 5 | msg: string 6 | } 7 | 8 | 9 | function ErrorMessage({ msg }: ErrorMessageProps) { 10 | return ( 11 |
12 | 13 |

{msg}

14 |
15 | ); 16 | } 17 | 18 | export default ErrorMessage; 19 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/components/Header.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LogoImage from '../assets/images/logo.png'; 3 | 4 | function Header() { 5 | return ( 6 |
7 |
8 | logo 9 |

Linera Pay

10 |
11 |
12 |
13 | ) 14 | } 15 | 16 | export default Header; 17 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/qql/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./fragment-masking"; 2 | export * from "./gql"; -------------------------------------------------------------------------------- /examples/fungible/web-frontend/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./src/**/*.{js,jsx,ts,tsx}", 5 | ], 6 | theme: { 7 | extend: {}, 8 | }, 9 | plugins: [], 10 | }; 11 | -------------------------------------------------------------------------------- /examples/fungible/web-frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "preserve" 22 | }, 23 | "include": [ 24 | "src" 25 | ], 26 | "exclude": [ 27 | "dist", 28 | "build", 29 | "node_modules" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/gen-nft/.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | tokenizer.json 3 | *.gguf 4 | -------------------------------------------------------------------------------- /examples/gen-nft/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gen-nft" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [features] 8 | test = [] 9 | 10 | [dependencies] 11 | async-graphql.workspace = true 12 | base64.workspace = true 13 | bcs.workspace = true 14 | candle-core.workspace = true 15 | candle-transformers.workspace = true 16 | fungible.workspace = true 17 | getrandom.workspace = true 18 | linera-sdk.workspace = true 19 | log.workspace = true 20 | rand.workspace = true 21 | serde.workspace = true 22 | sha3.workspace = true 23 | tokenizers.workspace = true 24 | 25 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 26 | fungible = { workspace = true, features = ["test"] } 27 | non-fungible = { workspace = true, features = ["test"] } 28 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 29 | tokio.workspace = true 30 | 31 | [[bin]] 32 | name = "gen_nft_contract" 33 | path = "src/contract.rs" 34 | 35 | [[bin]] 36 | name = "gen_nft_service" 37 | path = "src/service.rs" 38 | -------------------------------------------------------------------------------- /examples/gen-nft/src/random.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::sync::{Mutex, OnceLock}; 5 | 6 | use rand::{rngs::StdRng, Rng, SeedableRng}; 7 | 8 | static RNG: OnceLock> = OnceLock::new(); 9 | 10 | fn custom_getrandom(buf: &mut [u8]) -> Result<(), getrandom::Error> { 11 | let seed = [0u8; 32]; 12 | RNG.get_or_init(|| Mutex::new(StdRng::from_seed(seed))) 13 | .lock() 14 | .expect("failed to get RNG lock") 15 | .fill(buf); 16 | Ok(()) 17 | } 18 | 19 | getrandom::register_custom_getrandom!(custom_getrandom); 20 | -------------------------------------------------------------------------------- /examples/gen-nft/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::collections::BTreeSet; 5 | 6 | use async_graphql::SimpleObject; 7 | use gen_nft::{Nft, TokenId}; 8 | use linera_sdk::{ 9 | linera_base_types::AccountOwner, 10 | views::{linera_views, MapView, RegisterView, RootView, ViewStorageContext}, 11 | }; 12 | 13 | /// The application state. 14 | #[derive(RootView, SimpleObject)] 15 | #[view(context = ViewStorageContext)] 16 | pub struct GenNftState { 17 | // Map from token ID to the NFT data 18 | pub nfts: MapView, 19 | // Map from owners to the set of NFT token IDs they own 20 | pub owned_token_ids: MapView>, 21 | // Counter of NFTs minted in this chain, used for hash uniqueness 22 | pub num_minted_nfts: RegisterView, 23 | } 24 | -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/gen-nft/web-frontend/public/favicon.ico -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Linera NFT 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/src/Loader.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Loader = () => { 4 | const spinnerStyle = { 5 | border: '4px solid #f3f3f3', // Light grey background 6 | borderTop: '4px solid #3498db', // Blue spinner 7 | borderRadius: '50%', 8 | width: '40px', 9 | height: '40px', 10 | animation: 'spin 2s linear infinite' 11 | }; 12 | 13 | const keyframes = ` 14 | @keyframes spin { 15 | 0% { transform: rotate(0deg); } 16 | 100% { transform: rotate(360deg); } 17 | } 18 | `; 19 | 20 | return ( 21 | <> 22 | 23 |
24 | 25 | ); 26 | }; 27 | 28 | export default Loader; -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/gen-nft/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./src/**/*.{html,js}"], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | }; 9 | -------------------------------------------------------------------------------- /examples/hex-game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hex-game" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | bcs.workspace = true 10 | linera-sdk.workspace = true 11 | log.workspace = true 12 | serde.workspace = true 13 | 14 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 15 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 16 | tokio = { workspace = true, features = ["rt", "sync"] } 17 | 18 | [dev-dependencies] 19 | linera-sdk = { workspace = true, features = ["test"] } 20 | serde_json.workspace = true 21 | test-log.workspace = true 22 | 23 | [[bin]] 24 | name = "hex_game_contract" 25 | path = "src/contract.rs" 26 | 27 | [[bin]] 28 | name = "hex_game_service" 29 | path = "src/service.rs" 30 | -------------------------------------------------------------------------------- /examples/how-to/perform-http-requests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "how-to-perform-http-requests" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | linera-sdk.workspace = true 10 | serde.workspace = true 11 | 12 | [target.'cfg(not(target_arch = "wasm32"))'.dependencies] 13 | anyhow.workspace = true 14 | axum.workspace = true 15 | tokio.workspace = true 16 | 17 | [dev-dependencies] 18 | assert_matches.workspace = true 19 | linera-sdk = { workspace = true, features = ["test"] } 20 | 21 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 22 | futures.workspace = true 23 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 24 | test-log.workspace = true 25 | 26 | [[bin]] 27 | name = "how_to_perform_http_requests_contract" 28 | path = "src/contract.rs" 29 | 30 | [[bin]] 31 | name = "how_to_perform_http_requests_service" 32 | path = "src/service.rs" 33 | 34 | [[bin]] 35 | name = "test_http_server" 36 | path = "src/test_http_server.rs" 37 | -------------------------------------------------------------------------------- /examples/llm/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-unknown-unknown" 3 | -------------------------------------------------------------------------------- /examples/llm/.gitignore: -------------------------------------------------------------------------------- 1 | *.bin 2 | tokenizer.json 3 | *.gguf 4 | -------------------------------------------------------------------------------- /examples/llm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "llm" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | async-graphql.workspace = true 8 | candle-core.workspace = true 9 | candle-transformers.workspace = true 10 | getrandom.workspace = true 11 | linera-sdk.workspace = true 12 | log.workspace = true 13 | rand.workspace = true 14 | sha3.workspace = true 15 | tokenizers.workspace = true 16 | 17 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 18 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 19 | tokio = { workspace = true, features = ["rt", "sync"] } 20 | 21 | [[bin]] 22 | name = "llm_contract" 23 | path = "src/contract.rs" 24 | 25 | [[bin]] 26 | name = "llm_service" 27 | path = "src/service.rs" 28 | -------------------------------------------------------------------------------- /examples/llm/src/contract.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #![cfg_attr(target_arch = "wasm32", no_main)] 5 | 6 | use linera_sdk::{linera_base_types::WithContractAbi, Contract, ContractRuntime}; 7 | 8 | pub struct LlmContract; 9 | 10 | linera_sdk::contract!(LlmContract); 11 | 12 | impl WithContractAbi for LlmContract { 13 | type Abi = llm::LlmAbi; 14 | } 15 | 16 | impl Contract for LlmContract { 17 | type Message = (); 18 | type InstantiationArgument = (); 19 | type Parameters = (); 20 | type EventValue = (); 21 | 22 | async fn load(_runtime: ContractRuntime) -> Self { 23 | LlmContract 24 | } 25 | 26 | async fn instantiate(&mut self, _value: ()) {} 27 | 28 | async fn execute_operation(&mut self, _operation: ()) -> Self::Response {} 29 | 30 | async fn execute_message(&mut self, _message: ()) { 31 | panic!("Llm application doesn't support any cross-chain messages"); 32 | } 33 | 34 | async fn store(self) {} 35 | } 36 | -------------------------------------------------------------------------------- /examples/llm/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! ABI of the LLM Example Application */ 5 | 6 | use async_graphql::{Request, Response}; 7 | use linera_sdk::linera_base_types::{ContractAbi, ServiceAbi}; 8 | 9 | pub struct LlmAbi; 10 | 11 | impl ContractAbi for LlmAbi { 12 | type Operation = (); 13 | type Response = (); 14 | } 15 | 16 | impl ServiceAbi for LlmAbi { 17 | type Query = Request; 18 | type QueryResponse = Response; 19 | } 20 | -------------------------------------------------------------------------------- /examples/llm/src/random.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::sync::{Mutex, OnceLock}; 5 | 6 | use rand::{rngs::StdRng, Rng, SeedableRng}; 7 | 8 | static RNG: OnceLock> = OnceLock::new(); 9 | 10 | fn custom_getrandom(buf: &mut [u8]) -> Result<(), getrandom::Error> { 11 | let seed = [0u8; 32]; 12 | RNG.get_or_init(|| Mutex::new(StdRng::from_seed(seed))) 13 | .lock() 14 | .expect("failed to get RNG lock") 15 | .fill(buf); 16 | Ok(()) 17 | } 18 | 19 | getrandom::register_custom_getrandom!(custom_getrandom); 20 | -------------------------------------------------------------------------------- /examples/llm/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/llm/web-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/llm/web-frontend/public/favicon.ico -------------------------------------------------------------------------------- /examples/llm/web-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Linera Stories 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/llm/web-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | margin: 0; 7 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 8 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 9 | sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | 14 | code { 15 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 16 | monospace; 17 | } 18 | -------------------------------------------------------------------------------- /examples/llm/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./src/**/*.{html,js}"], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | }; 9 | -------------------------------------------------------------------------------- /examples/matching-engine/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "matching-engine" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | bcs.workspace = true 10 | fungible.workspace = true 11 | linera-sdk.workspace = true 12 | serde.workspace = true 13 | 14 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 15 | fungible = { workspace = true, features = ["test"] } 16 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 17 | tokio.workspace = true 18 | 19 | [[bin]] 20 | name = "matching_engine_contract" 21 | path = "src/contract.rs" 22 | 23 | [[bin]] 24 | name = "matching_engine_service" 25 | path = "src/service.rs" 26 | -------------------------------------------------------------------------------- /examples/meta-counter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "meta-counter" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | counter.workspace = true 10 | linera-sdk.workspace = true 11 | log.workspace = true 12 | serde.workspace = true 13 | 14 | [dev-dependencies] 15 | linera-sdk = { workspace = true, features = ["test"] } 16 | 17 | [[bin]] 18 | name = "meta_counter_contract" 19 | path = "src/contract.rs" 20 | 21 | [[bin]] 22 | name = "meta_counter_service" 23 | path = "src/service.rs" 24 | -------------------------------------------------------------------------------- /examples/meta-counter/README.md: -------------------------------------------------------------------------------- 1 | # Meta-Counter Example Application 2 | 3 | This application is only used for testing cross-application calls and oracles. 4 | 5 | -------------------------------------------------------------------------------- /examples/meta-counter/src/service.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #![cfg_attr(target_arch = "wasm32", no_main)] 5 | 6 | use async_graphql::{Request, Response}; 7 | use linera_sdk::{ 8 | linera_base_types::{ApplicationId, WithServiceAbi}, 9 | Service, ServiceRuntime, 10 | }; 11 | 12 | pub struct MetaCounterService { 13 | runtime: ServiceRuntime, 14 | } 15 | 16 | linera_sdk::service!(MetaCounterService); 17 | 18 | impl WithServiceAbi for MetaCounterService { 19 | type Abi = meta_counter::MetaCounterAbi; 20 | } 21 | 22 | impl Service for MetaCounterService { 23 | type Parameters = ApplicationId; 24 | 25 | async fn new(runtime: ServiceRuntime) -> Self { 26 | MetaCounterService { runtime } 27 | } 28 | 29 | async fn handle_query(&self, request: Request) -> Response { 30 | let counter_id = self.runtime.application_parameters(); 31 | self.runtime.query_application(counter_id, &request) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/native-fungible/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "native-fungible" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [features] 8 | test = [] 9 | 10 | [dependencies] 11 | async-graphql.workspace = true 12 | fungible.workspace = true 13 | linera-sdk.workspace = true 14 | serde.workspace = true 15 | 16 | [dev-dependencies] 17 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 18 | native-fungible = { workspace = true, features = ["test"] } 19 | test-log.workspace = true 20 | 21 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 22 | tokio = { workspace = true } 23 | 24 | [[bin]] 25 | name = "native_fungible_contract" 26 | path = "src/contract.rs" 27 | 28 | [[bin]] 29 | name = "native_fungible_service" 30 | path = "src/service.rs" 31 | -------------------------------------------------------------------------------- /examples/native-fungible/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! ABI of the Native Fungible Token Example Application */ 5 | 6 | use async_graphql::SimpleObject; 7 | use linera_sdk::linera_base_types::{AccountOwner, Amount}; 8 | use serde::{Deserialize, Serialize}; 9 | 10 | pub const TICKER_SYMBOL: &str = "NAT"; 11 | 12 | #[derive(Deserialize, SimpleObject)] 13 | pub struct AccountEntry { 14 | pub key: AccountOwner, 15 | pub value: Amount, 16 | } 17 | 18 | #[derive(Debug, Deserialize, Serialize)] 19 | pub enum Message { 20 | Notify, 21 | } 22 | -------------------------------------------------------------------------------- /examples/non-fungible/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "non-fungible" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [features] 8 | test = [] 9 | 10 | [dependencies] 11 | async-graphql.workspace = true 12 | base64.workspace = true 13 | bcs.workspace = true 14 | fungible.workspace = true 15 | linera-sdk.workspace = true 16 | serde.workspace = true 17 | sha3.workspace = true 18 | 19 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 20 | fungible = { workspace = true, features = ["test"] } 21 | non-fungible = { workspace = true, features = ["test"] } 22 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 23 | tokio.workspace = true 24 | 25 | [[bin]] 26 | name = "non_fungible_contract" 27 | path = "src/contract.rs" 28 | 29 | [[bin]] 30 | name = "non_fungible_service" 31 | path = "src/service.rs" 32 | -------------------------------------------------------------------------------- /examples/non-fungible/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::collections::BTreeSet; 5 | 6 | use async_graphql::SimpleObject; 7 | use linera_sdk::{ 8 | linera_base_types::AccountOwner, 9 | views::{linera_views, MapView, RegisterView, RootView, ViewStorageContext}, 10 | }; 11 | use non_fungible::{Nft, TokenId}; 12 | 13 | /// The application state. 14 | #[derive(RootView, SimpleObject)] 15 | #[view(context = ViewStorageContext)] 16 | pub struct NonFungibleTokenState { 17 | // Map from token ID to the NFT data 18 | pub nfts: MapView, 19 | // Map from owners to the set of NFT token IDs they own 20 | pub owned_token_ids: MapView>, 21 | // Counter of NFTs minted in this chain, used for hash uniqueness 22 | pub num_minted_nfts: RegisterView, 23 | } 24 | -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/non-fungible/web-frontend/public/favicon.ico -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Linera NFT 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/non-fungible/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./src/**/*.{html,js}"], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | }; 9 | -------------------------------------------------------------------------------- /examples/rfq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rfq" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | fungible.workspace = true 10 | linera-sdk.workspace = true 11 | serde.workspace = true 12 | 13 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 14 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 15 | tokio = { workspace = true, features = ["rt", "sync"] } 16 | 17 | [[bin]] 18 | name = "rfq_contract" 19 | path = "src/contract.rs" 20 | 21 | [[bin]] 22 | name = "rfq_service" 23 | path = "src/service.rs" 24 | -------------------------------------------------------------------------------- /examples/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | ../rust-toolchain.toml -------------------------------------------------------------------------------- /examples/social/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "social" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | async-graphql.workspace = true 9 | bcs.workspace = true 10 | linera-sdk.workspace = true 11 | serde.workspace = true 12 | 13 | [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] 14 | linera-sdk = { workspace = true, features = ["test", "wasmer"] } 15 | tokio = { workspace = true, features = ["rt", "sync"] } 16 | 17 | [[bin]] 18 | name = "social_contract" 19 | path = "src/contract.rs" 20 | 21 | [[bin]] 22 | name = "social_service" 23 | path = "src/service.rs" 24 | -------------------------------------------------------------------------------- /examples/social/src/state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use linera_sdk::views::{linera_views, CustomMapView, LogView, RootView, ViewStorageContext}; 5 | use social::{Key, OwnPost, Post}; 6 | 7 | /// The application state. 8 | #[derive(RootView, async_graphql::SimpleObject)] 9 | #[view(context = ViewStorageContext)] 10 | pub struct SocialState { 11 | /// Our posts. 12 | pub own_posts: LogView, 13 | /// Posts we received from authors we subscribed to. 14 | pub received_posts: CustomMapView, 15 | } 16 | -------------------------------------------------------------------------------- /examples/social/web-frontend/.env: -------------------------------------------------------------------------------- 1 | APP=3a59ba793926405c84b8db4e3a2cddaeb202fa1a914580bfad37055eea1b68ea 2 | PORT=8080 3 | CHAIN_ID=b6f098ac296e4819f651be0d7a93f4bf3841a9c9a33b4b06a089fc614cc418d7 4 | 5 | -------------------------------------------------------------------------------- /examples/social/web-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .env 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | -------------------------------------------------------------------------------- /examples/social/web-frontend/codegen.ts: -------------------------------------------------------------------------------- 1 | import { CodegenConfig } from '@graphql-codegen/cli' 2 | import 'dotenv/config' 3 | 4 | /** 5 | Make sure you set the correct chainId, app, and port in your .env file. 6 | 7 | This assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure 8 | */ 9 | const app = 10 | import.meta.env.APP || 11 | '3a59ba793926405c84b8db4e3a2cddaeb202fa1a914580bfad37055eea1b68e' 12 | const port = import.meta.env.PORT || 8080 13 | const chainId = 14 | import.meta.env.CHAIN_ID || 15 | 'b6f098ac296e4819f651be0d7a93f4bf3841a9c9a33b4b06a089fc614cc418d7' 16 | 17 | const config: CodegenConfig = { 18 | schema: `http://localhost:${port}/chains/${chainId}/applications/${app}`, 19 | documents: ['src/**/*.{ts,tsx}'], 20 | generates: { 21 | './src/__generated__/': { 22 | preset: 'client', 23 | plugins: [], 24 | presetConfig: { 25 | gqlTagName: 'gql', 26 | }, 27 | }, 28 | }, 29 | ignoreNoDocuments: true, 30 | } 31 | 32 | export default config 33 | -------------------------------------------------------------------------------- /examples/social/web-frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | My App 7 | 8 | 9 |
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/social/web-frontend/public/linera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/social/web-frontend/public/linera.png -------------------------------------------------------------------------------- /examples/social/web-frontend/src/__generated__/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./fragment-masking"; 2 | export * from "./gql"; -------------------------------------------------------------------------------- /examples/social/web-frontend/src/assets/linera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/social/web-frontend/src/assets/linera.png -------------------------------------------------------------------------------- /examples/social/web-frontend/src/assets/uploadimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/examples/social/web-frontend/src/assets/uploadimage.png -------------------------------------------------------------------------------- /examples/social/web-frontend/src/images.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.png' { 2 | const value: string 3 | export default value 4 | } 5 | 6 | declare module '*.jpg' { 7 | const value: string 8 | export default value 9 | } 10 | 11 | declare module '*.jpeg' { 12 | const value: string 13 | export default value 14 | } 15 | 16 | declare module '*.gif' { 17 | const value: string 18 | export default value 19 | } 20 | 21 | declare module '*.svg' { 22 | import * as React from 'react' 23 | export const ReactComponent: React.FunctionComponent< 24 | React.SVGProps 25 | > 26 | const src: string 27 | export default src 28 | } 29 | -------------------------------------------------------------------------------- /examples/social/web-frontend/src/input.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /examples/social/web-frontend/src/utils/time.ts: -------------------------------------------------------------------------------- 1 | export function convertMicrosToDateTime(microseconds: number) { 2 | const milliseconds = microseconds / 1000 3 | 4 | const date = new Date(milliseconds) 5 | 6 | const year = date.getFullYear() 7 | const month = String(date.getMonth() + 1).padStart(2, '0') 8 | const day = String(date.getDate()).padStart(2, '0') 9 | 10 | let hours = date.getHours() 11 | const minutes = String(date.getMinutes()).padStart(2, '0') 12 | 13 | const ampm = hours >= 12 ? 'PM' : 'AM' 14 | hours = hours % 12 15 | hours = hours ? hours : 12 // the hour '0' should be '12' 16 | const formattedHours = String(hours).padStart(2, '0') 17 | 18 | const formattedDate = `${year}-${month}-${day}` 19 | const formattedTime = `${formattedHours}:${minutes} ${ampm}` 20 | 21 | return { formattedDate, formattedTime } 22 | } 23 | -------------------------------------------------------------------------------- /examples/social/web-frontend/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ['./src/**/*.{html,js}'], 4 | theme: { 5 | extend: {}, 6 | }, 7 | plugins: [], 8 | } 9 | -------------------------------------------------------------------------------- /examples/social/web-frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "preserve" 22 | }, 23 | "include": [ 24 | "./src/**/*.tsx", 25 | "**/*.d.ts" 26 | ], 27 | "exclude": [ 28 | "dist", 29 | "build", 30 | "node_modules" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /examples/social/web-frontend/vite.config.ts: -------------------------------------------------------------------------------- 1 | // vite.config.ts 2 | import { defineConfig } from 'vite' 3 | import react from '@vitejs/plugin-react' 4 | 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/Chart.lock: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: kube-prometheus-stack 3 | repository: https://prometheus-community.github.io/helm-charts 4 | version: 51.0.3 5 | - name: loki-stack 6 | repository: https://grafana.github.io/helm-charts 7 | version: 2.8.9 8 | digest: sha256:da3a8808fb9479bdd183b307e70d7855794739cafc1796047bde8febc78d539c 9 | generated: "2023-11-30T17:19:14.544457977Z" 10 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/charts/kube-prometheus-stack-51.0.3.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/kubernetes/linera-validator/charts/kube-prometheus-stack-51.0.3.tgz -------------------------------------------------------------------------------- /kubernetes/linera-validator/charts/loki-stack-2.8.9.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/kubernetes/linera-validator/charts/loki-stack-2.8.9.tgz -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-manager.values.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | requests: 3 | cpu: 100m 4 | memory: 200Mi 5 | # Resources allocated to Scylla Manager pods 6 | controllerResources: 7 | requests: 8 | cpu: 100m 9 | memory: 200Mi 10 | 11 | scylla: 12 | developerMode: true 13 | scyllaImage: 14 | tag: 6.2.1 15 | agentImage: 16 | tag: 3.4.1 17 | datacenter: validator 18 | racks: 19 | - name: manager-rack 20 | members: 1 21 | storage: 22 | capacity: 5Gi 23 | resources: 24 | limits: 25 | cpu: 1 26 | memory: 2Gi 27 | requests: 28 | cpu: 1 29 | memory: 2Gi 30 | serviceMonitor: 31 | create: true 32 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-operator.values.yaml: -------------------------------------------------------------------------------- 1 | webhook: 2 | createSelfSignedCertificate: true 3 | certificateSecretName: "" 4 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-setup/local-csi-driver/00_namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: local-csi-driver 5 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-setup/local-csi-driver/10_csidriver.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: storage.k8s.io/v1 2 | kind: CSIDriver 3 | metadata: 4 | name: local.csi.scylladb.com 5 | spec: 6 | attachRequired: false 7 | storageCapacity: true 8 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-setup/local-csi-driver/10_driver_serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: local-csi-driver 5 | namespace: local-csi-driver 6 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-setup/local-csi-driver/20_provisioner_clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: scylladb:csi-external-provisioner 5 | subjects: 6 | - kind: ServiceAccount 7 | name: local-csi-driver 8 | namespace: local-csi-driver 9 | roleRef: 10 | kind: ClusterRole 11 | name: scylladb:csi-external-provisioner 12 | apiGroup: rbac.authorization.k8s.io 13 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla-setup/local-ssd-sc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: storage.k8s.io/v1 2 | kind: StorageClass 3 | metadata: 4 | name: nvme-ssd-block 5 | provisioner: local.csi.scylladb.com 6 | volumeBindingMode: WaitForFirstConsumer 7 | reclaimPolicy: Delete 8 | allowVolumeExpansion: false 9 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/scylla.values.yaml.gotmpl: -------------------------------------------------------------------------------- 1 | developerMode: true 2 | sysctls: 3 | - "fs.aio-max-nr=4082080" 4 | datacenter: validator 5 | racks: 6 | - name: rack 7 | members: {{ env "LINERA_HELMFILE_SET_STORAGE_REPLICATION_FACTOR" | default 1 }} 8 | scyllaConfig: "scylla-config" 9 | storage: 10 | capacity: 2Gi 11 | resources: 12 | limits: 13 | cpu: 1 14 | memory: 2Gi 15 | requests: 16 | cpu: 1 17 | memory: 2Gi 18 | serviceMonitor: 19 | create: true 20 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/NOTES.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/kubernetes/linera-validator/templates/NOTES.txt -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: validator-config 5 | data: 6 | serverConfig: {{ .Files.Get .Values.validator.serverConfig | quote | indent 4 }} 7 | genesisConfig: {{ .Files.Get .Values.validator.genesisConfig | quote | indent 4 }} 8 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-cloud-auth-secret.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.writeToGrafanaCloud }} 2 | apiVersion: v1 3 | kind: Secret 4 | metadata: 5 | name: grafana-cloud-auth-secret 6 | type: kubernetes.io/basic-auth 7 | stringData: 8 | username: {{ .Values.grafanaCloudUsername | quote }} 9 | password: {{ .Values.grafanaCloudAPIToken | quote }} 10 | {{- end }} 11 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-linera-dashboards-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: grafana-linera-dashboards-config 5 | labels: 6 | grafana_dashboard: "1" 7 | annotations: 8 | grafana_folder: "Linera" 9 | data: 10 | linera_general.json: {{ .Files.Get "grafana-dashboards/linera/general.json" | quote | indent 4 }} 11 | linera_execution.json: {{ .Files.Get "grafana-dashboards/linera/execution.json" | quote | indent 4 }} 12 | linera_storage.json: {{ .Files.Get "grafana-dashboards/linera/storage.json" | quote | indent 4 }} 13 | linera_views.json: {{ .Files.Get "grafana-dashboards/linera/views.json" | quote | indent 4 }} 14 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-linera-vms-dashboards-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: grafana-linera-vms-dashboards-config 5 | labels: 6 | grafana_dashboard: "1" 7 | annotations: 8 | grafana_folder: "Linera/VMs" 9 | data: 10 | linera_vms_ethereum.json: {{ .Files.Get "grafana-dashboards/linera/vms/ethereum.json" | quote | indent 4 }} 11 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-scylla-dashboards-config-0.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: scylla-dashboards-config-0 5 | labels: 6 | grafana_dashboard: "1" 7 | annotations: 8 | grafana_folder: "Scylla" 9 | data: 10 | # ConfigMaps can't be bigger than 1048576 bytes, so we need to split the dashboards into multiple ConfigMaps 11 | scylla-advanced.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-advanced.6.2.json" | quote | indent 4 }} 12 | scylla-alternator.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-alternator.6.2.json" | quote | indent 4 }} 13 | scylla-cql.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-cql.6.2.json" | quote | indent 4 }} 14 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-scylla-dashboards-config-1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: scylla-dashboards-config-1 5 | labels: 6 | grafana_dashboard: "1" 7 | annotations: 8 | grafana_folder: "Scylla" 9 | data: 10 | # ConfigMaps can't be bigger than 1048576 bytes, so we need to split the dashboards into multiple ConfigMaps 11 | scylla-detailed.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-detailed.6.2.json" | quote | indent 4 }} 12 | scylla-ks.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-ks.6.2.json" | quote | indent 4 }} 13 | scylla-os.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-os.6.2.json" | quote | indent 4 }} 14 | scylla-overview.6.2.json: {{ .Files.Get "grafana-dashboards/scylla/scylla-overview.6.2.json" | quote | indent 4 }} 15 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/grafana-scylla-manager-dashboards-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: scylla-manager-dashboards-config 5 | labels: 6 | grafana_dashboard: "1" 7 | annotations: 8 | grafana_folder: "Scylla Manager" 9 | data: 10 | scylla-manager.3.4.json: {{ .Files.Get "grafana-dashboards/scylla-manager/scylla-manager.3.4.json" | quote | indent 4 }} 11 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if eq .Values.environment "GCP" }} 2 | apiVersion: networking.k8s.io/v1 3 | kind: Ingress 4 | metadata: 5 | name: validator-ingress 6 | annotations: 7 | cloud.google.com/backend-config: '{"default":"proxy-backend-config"}' 8 | kubernetes.io/ingress.global-static-ip-name: {{ .Values.staticIpGcpName }} 9 | networking.gke.io/managed-certificates: managed-cert 10 | spec.ingressClassName: "gce" 11 | spec: 12 | defaultBackend: 13 | service: 14 | name: proxy 15 | port: 16 | number: 443 17 | 18 | --- 19 | 20 | apiVersion: networking.gke.io/v1 21 | kind: ManagedCertificate 22 | metadata: 23 | name: managed-cert 24 | spec: 25 | domains: 26 | - {{ .Values.validatorDomainName }} 27 | 28 | --- 29 | 30 | apiVersion: cloud.google.com/v1 31 | kind: BackendConfig 32 | metadata: 33 | name: proxy-backend-config 34 | spec: 35 | timeoutSec: 2147483647 # Maximum possible value 36 | 37 | {{- end }} 38 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/templates/scylla-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: scylla-config 5 | namespace: scylla 6 | data: 7 | scylla.yaml: | 8 | query_tombstone_page_limit: 200000 9 | -------------------------------------------------------------------------------- /kubernetes/linera-validator/working/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/kubernetes/linera-validator/working/.placeholder -------------------------------------------------------------------------------- /linera-base/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides a common set of types and library functions that are shared 4 | between the Linera protocol (compiled from Rust to native code) and Linera 5 | applications (compiled from Rust to Wasm). 6 | 7 | 8 | 9 | ## Contributing 10 | 11 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 12 | 13 | ## License 14 | 15 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 16 | -------------------------------------------------------------------------------- /linera-base/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | chain: { all(target_arch = "wasm32", not(web)) }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | with_reqwest: { feature = "reqwest" }, 10 | with_testing: { any(test, feature = "test") }, 11 | with_revm: { any(test, feature = "revm") }, 12 | 13 | // the old version of `getrandom` we pin here is available on all targets, but 14 | // using it will panic if no suitable source of entropy is found 15 | with_getrandom: { any(web, not(target_arch = "wasm32")) }, 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /linera-base/src/dyn_convert.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! 5 | Object-safe conversion traits. 6 | */ 7 | 8 | /// An object-safe version of `std::convert::Into`. 9 | pub trait DynInto { 10 | /// Converts a boxed object into the target type. 11 | fn into_box(self: Box) -> To; 12 | } 13 | 14 | impl> DynInto for From { 15 | fn into_box(self: Box) -> To { 16 | (*self).into() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linera-base/src/port.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Functionality for obtaining some free port. 5 | 6 | use anyhow::{bail, Result}; 7 | use port_selector::random_free_tcp_port; 8 | 9 | use crate::time::Duration; 10 | 11 | /// Provides a port that is currently not used 12 | pub async fn get_free_port() -> Result { 13 | for i in 1..10 { 14 | let port = random_free_tcp_port(); 15 | if let Some(port) = port { 16 | return Ok(port); 17 | } 18 | crate::time::timer::sleep(Duration::from_secs(i)).await; 19 | } 20 | bail!("Failed to obtain a port"); 21 | } 22 | 23 | /// Provides a local endpoint that is currently available 24 | pub async fn get_free_endpoint() -> Result { 25 | let port = get_free_port().await?; 26 | Ok(format!("127.0.0.1:{}", port)) 27 | } 28 | -------------------------------------------------------------------------------- /linera-base/src/time.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! 5 | Abstractions over time that can be used natively or on the Web. 6 | */ 7 | 8 | cfg_if::cfg_if! { 9 | if #[cfg(web)] { 10 | pub use web_time::*; 11 | pub use wasmtimer::tokio as timer; 12 | } else { 13 | pub use std::time::*; 14 | pub use tokio::time as timer; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /linera-base/src/tracing_web.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This module provides unified handling for tracing subscribers within Linera binaries. 5 | 6 | use tracing_subscriber::{ 7 | prelude::__tracing_subscriber_SubscriberExt as _, util::SubscriberInitExt as _, 8 | }; 9 | 10 | /// Initializes tracing for the browser, sending messages to the developer console and 11 | /// span events to the [Performance 12 | /// API](https://developer.mozilla.org/en-US/docs/Web/API/Performance). 13 | pub fn init() { 14 | tracing_subscriber::registry() 15 | .with( 16 | tracing_subscriber::fmt::layer() 17 | .with_ansi(false) 18 | .without_time() 19 | .with_writer(tracing_web::MakeWebConsoleWriter::new()), 20 | ) 21 | .with( 22 | tracing_web::performance_layer() 23 | .with_details_from_fields(tracing_subscriber::fmt::format::Pretty::default()), 24 | ) 25 | .init(); 26 | } 27 | -------------------------------------------------------------------------------- /linera-chain/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module manages the state of a Linera chain, including cross-chain communication. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-chain/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | with_graphql: { not(web) }, 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /linera-client/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides a convenient library for writing a Linera client application. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-client/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /linera-client/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This module provides a convenient library for writing a Linera client application. 5 | 6 | #![recursion_limit = "256"] 7 | #![deny(clippy::large_futures)] 8 | #![allow(async_fn_in_trait)] 9 | 10 | pub mod chain_listener; 11 | pub mod client_context; 12 | pub mod client_options; 13 | pub mod config; 14 | mod error; 15 | pub mod util; 16 | pub mod wallet; 17 | 18 | #[cfg(feature = "benchmark")] 19 | pub mod benchmark; 20 | 21 | #[cfg(test)] 22 | mod unit_tests; 23 | 24 | pub use error::Error; 25 | -------------------------------------------------------------------------------- /linera-client/src/unit_tests/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | mod chain_listener; 5 | mod util; 6 | #[cfg(feature = "fs")] 7 | mod wallet; 8 | -------------------------------------------------------------------------------- /linera-core/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module defines the core Linera protocol. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-core/benches/hashing_benchmarks.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use alloy_primitives::Keccak256; 5 | use criterion::{black_box, criterion_group, criterion_main, Criterion}; 6 | use sha3::{Digest, Sha3_256}; 7 | 8 | fn keccak(i: u8) { 9 | let mut hasher = Keccak256::new(); 10 | hasher.update([i; 32]); 11 | hasher.finalize(); 12 | } 13 | 14 | fn sha256(i: u8) { 15 | let mut hasher = Sha3_256::new(); 16 | hasher.update([i; 32]); 17 | hasher.finalize(); 18 | } 19 | 20 | fn keccak_benchmark(c: &mut Criterion) { 21 | c.bench_function("keccak", |b| b.iter(|| keccak(black_box(20)))); 22 | } 23 | 24 | fn sha256_benchmark(c: &mut Criterion) { 25 | c.bench_function("sha256", |b| b.iter(|| sha256(black_box(20)))); 26 | } 27 | 28 | criterion_group!(benches, keccak_benchmark, sha256_benchmark); 29 | criterion_main!(benches); 30 | -------------------------------------------------------------------------------- /linera-core/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | 10 | // the old version of `getrandom` we pin here is available on all targets, but 11 | // using it will panic if no suitable source of entropy is found 12 | with_getrandom: { any(web, not(target_arch = "wasm32")) }, 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /linera-core/src/chain_worker/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! A worker to handle a single chain. 5 | 6 | mod actor; 7 | mod config; 8 | mod delivery_notifier; 9 | mod state; 10 | 11 | pub(super) use self::delivery_notifier::DeliveryNotifier; 12 | #[cfg(test)] 13 | pub(crate) use self::state::CrossChainUpdateHelper; 14 | pub use self::{ 15 | actor::{ChainWorkerActor, ChainWorkerRequest}, 16 | config::ChainWorkerConfig, 17 | state::ChainWorkerState, 18 | }; 19 | -------------------------------------------------------------------------------- /linera-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | // Copyright (c) Zefchain Labs, Inc. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | //! This module defines the core Linera protocol. 6 | 7 | #![recursion_limit = "256"] 8 | #![deny(clippy::large_futures)] 9 | 10 | pub mod chain_worker; 11 | pub mod client; 12 | pub mod data_types; 13 | pub mod join_set_ext; 14 | pub mod local_node; 15 | pub mod node; 16 | pub mod notifier; 17 | pub mod remote_node; 18 | #[cfg(with_testing)] 19 | #[path = "unit_tests/test_utils.rs"] 20 | pub mod test_utils; 21 | pub mod worker; 22 | 23 | pub(crate) mod updater; 24 | pub(crate) mod value_cache; 25 | 26 | pub use updater::DEFAULT_GRACE_PERIOD; 27 | 28 | pub use crate::join_set_ext::{JoinSetExt, TaskHandle}; 29 | 30 | pub mod environment; 31 | pub use environment::Environment; 32 | -------------------------------------------------------------------------------- /linera-ethereum/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides functionalities for accessing an Ethereum blockchain node. 4 | Enabling the `ethereum` allows to make the tests work. This requires installing 5 | the `anvil` from [FOUNDRY] and the [SOLC] compiler version 0.8.25 6 | 7 | [FOUNDRY]: https://book.getfoundry.sh/ 8 | [SOLC]: https://soliditylang.org/ 9 | 10 | 11 | 12 | ## Contributing 13 | 14 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 15 | 16 | ## License 17 | 18 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 19 | -------------------------------------------------------------------------------- /linera-ethereum/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_testing: { any(test, feature = "test") }, 7 | }; 8 | } 9 | -------------------------------------------------------------------------------- /linera-ethereum/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This module provides functionalities for accessing an Ethereum blockchain node. 5 | //! Enabling the `ethereum` allows to make the tests work. This requires installing 6 | //! the `anvil` from [FOUNDRY] and the [SOLC] compiler version 0.8.25 7 | //! 8 | //! [FOUNDRY]: https://book.getfoundry.sh/ 9 | //! [SOLC]: https://soliditylang.org/ 10 | 11 | pub mod client; 12 | pub mod common; 13 | 14 | #[cfg(not(target_arch = "wasm32"))] 15 | pub mod provider; 16 | 17 | /// Helper types for tests and similar purposes. 18 | #[cfg(not(target_arch = "wasm32"))] 19 | pub mod test_utils; 20 | -------------------------------------------------------------------------------- /linera-execution/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module manages the execution of the system application and the user applications in a 4 | Linera chain. 5 | 6 | 7 | 8 | ## Contributing 9 | 10 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 11 | 12 | ## License 13 | 14 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 15 | -------------------------------------------------------------------------------- /linera-execution/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | 8 | with_fs: { all(not(target_arch = "wasm32"), feature = "fs") }, 9 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 10 | with_graphql: { not(web) }, 11 | with_testing: { any(test, feature = "test") }, 12 | with_tokio_multi_thread: { not(target_arch = "wasm32") }, 13 | with_wasmer: { feature = "wasmer" }, 14 | with_revm: { feature = "revm" }, 15 | with_wasmtime: { all(not(target_arch = "wasm32"), feature = "wasmtime") }, 16 | 17 | // If you change this, don't forget to update `WasmRuntime` and 18 | // `WasmRuntime::default_with_sanitizer` 19 | with_wasm_runtime: { any(with_wasmer, with_wasmtime) }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-execution/src/wasm/entrypoints.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Wasm entrypoints for contracts and services. 5 | 6 | use linera_base::data_types::StreamUpdate; 7 | use linera_witty::wit_import; 8 | 9 | /// WIT entrypoints for application contracts. 10 | #[wit_import(package = "linera:app")] 11 | pub trait ContractEntrypoints { 12 | fn instantiate(argument: Vec); 13 | fn execute_operation(operation: Vec) -> Vec; 14 | fn execute_message(message: Vec); 15 | fn process_streams(streams: Vec); 16 | fn finalize(); 17 | } 18 | 19 | /// WIT entrypoints for application services. 20 | #[wit_import(package = "linera:app")] 21 | pub trait ServiceEntrypoints { 22 | fn handle_query(argument: Vec) -> Vec; 23 | } 24 | -------------------------------------------------------------------------------- /linera-execution/tests/fixtures/counter_contract.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/linera-execution/tests/fixtures/counter_contract.wasm -------------------------------------------------------------------------------- /linera-execution/tests/fixtures/counter_service.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linera-io/linera-protocol/125bb6bc70010c694587a831e270f9659c92bd5f/linera-execution/tests/fixtures/counter_service.wasm -------------------------------------------------------------------------------- /linera-execution/tests/fixtures/evm_example_counter.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract ExampleCounter { 6 | uint64 value; 7 | 8 | constructor(uint64 start_value) { 9 | value = start_value; 10 | } 11 | 12 | function increment(uint64 input) external returns (uint64) { 13 | value = value + input; 14 | return value; 15 | } 16 | 17 | function get_value() external view returns (uint64) { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /linera-execution/tests/fixtures/evm_too_long_service.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract ExampleLongService { 6 | constructor(uint64 start_value) { 7 | } 8 | 9 | // An operation that costs more than 20.000.000 gas fuel. 10 | function too_long_run() external view returns (uint256) { 11 | uint256 v = 0; 12 | for (uint256 i=0; i<500; i++) { 13 | for (uint256 j=0; j<500; j++) { 14 | v = v + i + j; 15 | } 16 | } 17 | return v; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /linera-execution/update_wasm_fixtures.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | cd `dirname $0`/.. 4 | 5 | (cd examples && cargo build --release) 6 | 7 | cp examples/target/wasm32-unknown-unknown/release/counter_{contract,service}.wasm linera-execution/tests/fixtures 8 | -------------------------------------------------------------------------------- /linera-explorer/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | pkg 3 | dist 4 | gql 5 | -------------------------------------------------------------------------------- /linera-explorer/README.md: -------------------------------------------------------------------------------- 1 | # Linera Explorer 2 | 3 | 4 | 5 | This module provides web files to run a block explorer from Linera service node and Linera indexer. 6 | 7 | 8 | 9 | ## Build instructions 10 | 11 | ```bash 12 | npm install 13 | ``` 14 | and then 15 | ```bash 16 | npm run full 17 | ``` 18 | 19 | Then, to serve the web application on a local server, run: 20 | ```bash 21 | npm run serve 22 | ``` 23 | 24 | The URL to access the Block Explorer will be printed. 25 | 26 | ## Contributing 27 | 28 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 29 | 30 | ## License 31 | 32 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 33 | -------------------------------------------------------------------------------- /linera-explorer/codegen_indexer.ts: -------------------------------------------------------------------------------- 1 | import type { CodegenConfig } from '@graphql-codegen/cli' 2 | 3 | const config: CodegenConfig = { 4 | overwrite: true, 5 | schema: "../linera-indexer/graphql-client/gql/indexer_schema.graphql", 6 | documents: "../linera-indexer/graphql-client/gql/indexer_requests.graphql", 7 | generates: { 8 | "gql/indexer.d.ts": { 9 | plugins: ['typescript'] 10 | }, 11 | } 12 | } 13 | 14 | export default config; 15 | -------------------------------------------------------------------------------- /linera-explorer/codegen_operations.ts: -------------------------------------------------------------------------------- 1 | import type { CodegenConfig } from '@graphql-codegen/cli' 2 | 3 | const config: CodegenConfig = { 4 | overwrite: true, 5 | schema: "../linera-indexer/graphql-client/gql/operations_schema.graphql", 6 | documents: "../linera-indexer/graphql-client/gql/operations_requests.graphql", 7 | generates: { 8 | "gql/operations.d.ts": { 9 | plugins: ['typescript'] 10 | }, 11 | } 12 | } 13 | export default config 14 | -------------------------------------------------------------------------------- /linera-explorer/codegen_service.ts: -------------------------------------------------------------------------------- 1 | import type { CodegenConfig } from '@graphql-codegen/cli' 2 | 3 | const config: CodegenConfig = { 4 | overwrite: true, 5 | schema: "../linera-service-graphql-client/gql/service_schema.graphql", 6 | documents: "../linera-service-graphql-client/gql/service_requests.graphql", 7 | generates: { 8 | "gql/service.d.ts": { 9 | plugins: ['typescript'] 10 | }, 11 | } 12 | } 13 | export default config 14 | -------------------------------------------------------------------------------- /linera-explorer/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Linera Explorer 6 | 7 | 8 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /linera-explorer/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | ../toolchains/stable/rust-toolchain.toml -------------------------------------------------------------------------------- /linera-explorer/src/components/App.test.ts: -------------------------------------------------------------------------------- 1 | import { set_test_config } from './utils' 2 | import { mount } from '@vue/test-utils' 3 | import App from './App.vue' 4 | 5 | test('App mounting', () => { 6 | set_test_config().then(() => { 7 | mount(App) 8 | }) 9 | }) 10 | -------------------------------------------------------------------------------- /linera-explorer/src/components/InputType.test.ts: -------------------------------------------------------------------------------- 1 | import { set_test_config } from './utils' 2 | import { mount } from '@vue/test-utils' 3 | import InputType from './InputType.vue' 4 | 5 | test('InputType mounting', () => { 6 | set_test_config().then(() => { 7 | mount(InputType, { 8 | props: { 9 | elt: { 10 | kind: 'SCALAR', 11 | name: 'AccountOwner' 12 | }, offset: false 13 | }, 14 | }) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /linera-explorer/src/components/Json.test.ts: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import Json from './Json.vue' 3 | 4 | test('Json mounting', () => { 5 | mount(Json, { 6 | props: { data: { foo: 42, bar: 'foo' } }, 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /linera-explorer/src/components/Json.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 17 | -------------------------------------------------------------------------------- /linera-explorer/src/components/Op.test.ts: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import Op from './Op.vue' 3 | 4 | test('Op mounting', () => { 5 | mount(Op, { 6 | props: { 7 | id: 'op', 8 | op: { 9 | System: { 10 | PublishModule: { 11 | contract: { 12 | bytes:"0061..7874" 13 | }, 14 | service: { 15 | bytes:"0061..7874" 16 | } 17 | } 18 | } 19 | } 20 | }, 21 | }) 22 | }) 23 | -------------------------------------------------------------------------------- /linera-explorer/src/components/OutputType.test.ts: -------------------------------------------------------------------------------- 1 | import { mount } from '@vue/test-utils' 2 | import OutputType from './OutputType.vue' 3 | 4 | test('OutputType mounting', () => { 5 | mount(OutputType, { 6 | props: { 7 | elt: { 8 | kind: 'SCALAR', 9 | name: 'Amount', 10 | _include: true, 11 | }, 12 | name: 'accountOwner', 13 | depth: 0, 14 | }, 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /linera-explorer/src/components/Plugin.test.ts: -------------------------------------------------------------------------------- 1 | import { set_test_config } from './utils' 2 | import { mount } from '@vue/test-utils' 3 | import Plugin from './Plugin.vue' 4 | 5 | test('Plugin mounting', () => { 6 | set_test_config().then(() => { 7 | mount(Plugin, { 8 | props: { 9 | plugin: { 10 | name: "operations", 11 | link: "http://localhost:8081/operations", 12 | queries: [], 13 | } 14 | }, 15 | }) 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /linera-explorer/src/components/Plugin.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | -------------------------------------------------------------------------------- /linera-explorer/src/input_type.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use wasm_bindgen::prelude::*; 5 | 6 | use super::js_utils::{getf, unproxy}; 7 | 8 | /// Adds an input line for lists. 9 | #[wasm_bindgen] 10 | pub fn append_input(component: JsValue) { 11 | let element = getf(&component, "elt"); 12 | let input: js_sys::Array = getf(&element, "_input").into(); 13 | let child = unproxy(&getf(&element, "ofType")); 14 | input.splice(input.length(), 0, &child); 15 | } 16 | 17 | /// Removes an input line. 18 | #[wasm_bindgen] 19 | pub fn remove_input(component: JsValue, index: u32) { 20 | let element = getf(&component, "elt"); 21 | let input: js_sys::Array = getf(&element, "_input").into(); 22 | input.splice(index, 1, &JsValue::undefined()); 23 | } 24 | -------------------------------------------------------------------------------- /linera-explorer/src/types/json-formatter-js.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'json-formatter-js' { 2 | export default class JSONFormatter { 3 | constructor(json: any, open?: number, config?: { theme?: string }); 4 | render(): HTMLElement; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /linera-explorer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | 23 | "esModuleInterop": true, 24 | "forceConsistentCasingInFileNames": true, 25 | 26 | "types": [ "vitest/globals" ] 27 | }, 28 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "pkg/*.d.ts", "pkg/*.js", "pkg/*.wasm", "gql/*.d.ts", "vite.config.ts"] 29 | } 30 | -------------------------------------------------------------------------------- /linera-explorer/vite.config.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { defineConfig } from 'vite' 3 | import vue from '@vitejs/plugin-vue' 4 | 5 | export default defineConfig({ 6 | plugins: [ vue() ], 7 | test: { 8 | globals: true, 9 | environment: 'jsdom', 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /linera-faucet/client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-faucet-client" 3 | description = "The client component of the Linera faucet." 4 | readme = "README.md" 5 | documentation = "https://docs.rs/linera-faucet-client/latest/linera_faucet_client/" 6 | 7 | version.workspace = true 8 | authors.workspace = true 9 | repository.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | edition.workspace = true 13 | 14 | [dependencies] 15 | linera-base.workspace = true 16 | linera-client.workspace = true 17 | linera-version.workspace = true 18 | reqwest.workspace = true 19 | serde.workspace = true 20 | serde_json.workspace = true 21 | thiserror.workspace = true 22 | thiserror-context.workspace = true 23 | -------------------------------------------------------------------------------- /linera-faucet/client/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides the executables needed to operate a Linera service, including a placeholder wallet acting as a GraphQL service for user interfaces. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-faucet/server/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides the executables needed to operate a Linera service, including a placeholder wallet acting as a GraphQL service for user interfaces. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-indexer/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | An example of an indexer with the operations plugin. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-indexer/example/src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! An example of an indexer with the operations plugin. 5 | 6 | use linera_indexer::{common::IndexerError, plugin::Plugin, rocks_db::RocksDbRunner}; 7 | use linera_indexer_plugins::operations::OperationsPlugin; 8 | 9 | #[tokio::main] 10 | async fn main() -> Result<(), IndexerError> { 11 | let env_filter = tracing_subscriber::EnvFilter::builder() 12 | .with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into()) 13 | .from_env_lossy(); 14 | tracing_subscriber::fmt() 15 | .with_writer(std::io::stderr) 16 | .with_env_filter(env_filter) 17 | .init(); 18 | 19 | let mut runner = RocksDbRunner::load().await?; 20 | runner 21 | .add_plugin(OperationsPlugin::load(runner.store.clone()).await?) 22 | .await?; 23 | runner.run().await 24 | } 25 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-indexer-graphql-client" 3 | description = "GraphQL client for the indexer" 4 | readme = "README.md" 5 | 6 | authors.workspace = true 7 | edition.workspace = true 8 | homepage.workspace = true 9 | license.workspace = true 10 | repository.workspace = true 11 | version.workspace = true 12 | 13 | [dependencies] 14 | graphql_client = { version = "0.13", features = ["reqwest-rustls"] } 15 | linera-base.workspace = true 16 | serde = { workspace = true, features = ["derive"] } 17 | serde_json.workspace = true 18 | 19 | [target.'cfg(not(target_arch = "wasm32"))'.dependencies] 20 | linera-execution.workspace = true 21 | 22 | [dev-dependencies] 23 | linera-base = { workspace = true, features = ["test"] } 24 | linera-service.workspace = true 25 | tempfile.workspace = true 26 | test-log = { workspace = true, features = ["trace"] } 27 | tokio = { workspace = true, features = ["full", "test-util"] } 28 | tracing.workspace = true 29 | tracing-subscriber = { workspace = true, features = ["fmt"] } 30 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/README.md: -------------------------------------------------------------------------------- 1 | # Linera indexer GraphQL client 2 | 3 | 4 | 5 | A GraphQL client for the indexer. 6 | 7 | 8 | 9 | ## Generate schema 10 | 11 | To generate the indexer GraphQL schema: 12 | ```bash 13 | cargo run --bin linera-indexer schema > linera-indexer/graphql-client/gql/indexer_schema.graphql 14 | ``` 15 | 16 | To generate the indexer operations GraphQL schema: 17 | ```bash 18 | cargo run --bin linera-indexer schema operations > linera-indexer/graphql-client/gql/operations_schema.graphql 19 | ``` 20 | 21 | ## Contributing 22 | 23 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 24 | 25 | ## License 26 | 27 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 28 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/gql/indexer_requests.graphql: -------------------------------------------------------------------------------- 1 | query Plugins { 2 | plugins 3 | } 4 | 5 | query State { 6 | state { 7 | chain 8 | block 9 | height 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/gql/operations_requests.graphql: -------------------------------------------------------------------------------- 1 | query Operations($from: OperationKeyKind!, $limit: Int) { 2 | operations(from: $from, limit: $limit) { 3 | key 4 | previousOperation 5 | index 6 | block 7 | content 8 | } 9 | } 10 | 11 | query OperationsCount($chainId: ChainId!) { 12 | count(chainId: $chainId) 13 | } 14 | 15 | query LastOperation($chainId: ChainId!) { 16 | last(chainId: $chainId) 17 | } 18 | 19 | query GetOperation($key: OperationKeyKind!) { 20 | operation(key: $key) { 21 | key 22 | previousOperation 23 | index 24 | block 25 | content 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/src/indexer.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use graphql_client::GraphQLQuery; 5 | use linera_base::{crypto::CryptoHash, data_types::BlockHeight, identifiers::ChainId}; 6 | 7 | #[derive(GraphQLQuery)] 8 | #[graphql( 9 | schema_path = "gql/indexer_schema.graphql", 10 | query_path = "gql/indexer_requests.graphql", 11 | response_derives = "Debug, Serialize, Clone" 12 | )] 13 | pub struct Plugins; 14 | 15 | #[derive(GraphQLQuery)] 16 | #[graphql( 17 | schema_path = "gql/indexer_schema.graphql", 18 | query_path = "gql/indexer_requests.graphql", 19 | response_derives = "Debug, Serialize, Clone" 20 | )] 21 | pub struct State; 22 | -------------------------------------------------------------------------------- /linera-indexer/graphql-client/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! A GraphQL client for the indexer. 5 | 6 | pub mod indexer; 7 | pub mod operations; 8 | -------------------------------------------------------------------------------- /linera-indexer/lib/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module defines the linera-indexer library including: 4 | - the indexer connection to the node service (service.rs) 5 | - the block processing (indexer.rs) 6 | - the generic plugin trait (plugin.rs) 7 | - the runner struct (runner.rs) 8 | 9 | 10 | 11 | ## Contributing 12 | 13 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 14 | 15 | ## License 16 | 17 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 18 | -------------------------------------------------------------------------------- /linera-indexer/lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This module defines the linera-indexer library including: 5 | //! - the indexer connection to the node service (service.rs) 6 | //! - the block processing (indexer.rs) 7 | //! - the generic plugin trait (plugin.rs) 8 | //! - the runner struct (runner.rs) 9 | 10 | pub mod common; 11 | pub mod indexer; 12 | pub mod plugin; 13 | pub mod runner; 14 | pub mod service; 15 | 16 | #[cfg(feature = "rocksdb")] 17 | pub mod rocks_db; 18 | #[cfg(feature = "scylladb")] 19 | pub mod scylla_db; 20 | -------------------------------------------------------------------------------- /linera-indexer/plugins/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Plugins for Linera indexer. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-indexer/plugins/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Plugins for Linera indexer. 5 | 6 | pub mod operations; 7 | -------------------------------------------------------------------------------- /linera-persistent/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This crate handles persisting data types to disk with a variety of backends. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-persistent/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | with_indexed_db: { all(web, feature = "indexed-db") }, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /linera-persistent/src/dirty.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #[derive(Clone, Debug, Default, PartialEq, Eq, derive_more::Deref, derive_more::DerefMut)] 5 | pub struct Dirty( 6 | #[deref] 7 | #[deref_mut] 8 | bool, 9 | ); 10 | 11 | impl Dirty { 12 | pub fn new(dirty: bool) -> Self { 13 | Self(dirty) 14 | } 15 | } 16 | 17 | impl Drop for Dirty { 18 | fn drop(&mut self) { 19 | if self.0 { 20 | tracing::error!("object dropped while dirty"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /linera-persistent/src/memory.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use super::{Dirty, Persist}; 5 | 6 | pub type Error = std::convert::Infallible; 7 | 8 | /// A dummy [`Persist`] implementation that doesn't persist anything, but holds the value 9 | /// in memory. 10 | #[derive(Default, derive_more::Deref)] 11 | pub struct Memory { 12 | #[deref] 13 | value: T, 14 | dirty: Dirty, 15 | } 16 | 17 | impl Memory { 18 | pub fn new(value: T) -> Self { 19 | Self { 20 | value, 21 | dirty: Dirty::new(true), 22 | } 23 | } 24 | } 25 | 26 | impl Persist for Memory { 27 | type Error = Error; 28 | 29 | fn as_mut(&mut self) -> &mut T { 30 | *self.dirty = true; 31 | &mut self.value 32 | } 33 | 34 | fn into_value(self) -> T { 35 | self.value 36 | } 37 | 38 | async fn persist(&mut self) -> Result<(), Error> { 39 | *self.dirty = false; 40 | Ok(()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /linera-protocol.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | }, 6 | { 7 | "path": "examples" 8 | } 9 | ], 10 | "settings": { 11 | "rust-analyzer.showUnlinkedFileNotification": false 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linera-rpc/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides network abstractions and the data schemas for remote procedure 4 | calls (RPCs) in the Linera protocol. 5 | 6 | 7 | 8 | ## Contributing 9 | 10 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 11 | 12 | ## License 13 | 14 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 15 | -------------------------------------------------------------------------------- /linera-rpc/binary_formats.yaml: -------------------------------------------------------------------------------- 1 | tests/snapshots/format__format.yaml.snap -------------------------------------------------------------------------------- /linera-rpc/src/simple/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | mod client; 5 | mod codec; 6 | mod node_provider; 7 | #[cfg(with_server)] 8 | mod server; 9 | mod transport; 10 | 11 | pub use client::*; 12 | pub use codec::*; 13 | pub use node_provider::*; 14 | #[cfg(with_server)] 15 | pub use server::*; 16 | pub use transport::*; 17 | -------------------------------------------------------------------------------- /linera-sdk-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-sdk-derive" 3 | description = "The procedural macros for the crate `linera-sdk`" 4 | 5 | authors.workspace = true 6 | edition.workspace = true 7 | homepage.workspace = true 8 | license.workspace = true 9 | repository.workspace = true 10 | version.workspace = true 11 | 12 | [lib] 13 | proc-macro = true 14 | 15 | [dependencies] 16 | convert_case = "0.6.0" 17 | proc-macro2.workspace = true 18 | syn = { workspace = true, features = ["full", "extra-traits"] } 19 | -------------------------------------------------------------------------------- /linera-sdk-derive/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The procedural macros for the crate `linera-sdk`. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-sdk/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_testing: { any(test, feature = "test") }, 7 | with_wasm_runtime: { any(feature = "wasmer", feature = "wasmtime") }, 8 | with_integration_testing: { 9 | all(not(target_arch = "wasm32"), with_testing, with_wasm_runtime) 10 | }, 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /linera-sdk/src/abis/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Common ABIs that may have multiple implementations. 5 | 6 | pub mod evm; 7 | pub mod fungible; 8 | -------------------------------------------------------------------------------- /linera-sdk/src/base/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Types and macros for the base runtime. 5 | 6 | mod conversions_from_wit; 7 | mod conversions_to_wit; 8 | -------------------------------------------------------------------------------- /linera-sdk/src/contract/wit.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Internal module with code generated by [`wit-bindgen`](https://github.com/jvff/wit-bindgen). 5 | 6 | #![allow(missing_docs)] 7 | 8 | // Export the contract interface. 9 | wit_bindgen::generate!({ 10 | world: "contract", 11 | export_macro_name: "export_contract", 12 | pub_export_macro: true, 13 | }); 14 | 15 | pub use self::linera::app::{base_runtime_api, contract_runtime_api}; 16 | -------------------------------------------------------------------------------- /linera-sdk/src/graphql.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! GraphQL traits for generating interfaces into applications. 5 | 6 | use std::sync::Arc; 7 | 8 | /// Re-exports the derive macro for [`GraphQLMutationRoot`]. 9 | pub use linera_sdk_derive::GraphQLMutationRoot; 10 | 11 | use crate::{Service, ServiceRuntime}; 12 | 13 | /// An object associated with a GraphQL mutation root. Those are typically used to build 14 | /// an [`async_graphql::Schema`] object. 15 | pub trait GraphQLMutationRoot 16 | where 17 | Application: Service, 18 | { 19 | /// The type of the mutation root. 20 | type MutationRoot: async_graphql::ObjectType; 21 | 22 | /// Returns the mutation root of the object. 23 | fn mutation_root(runtime: Arc>) -> Self::MutationRoot; 24 | } 25 | -------------------------------------------------------------------------------- /linera-sdk/src/linera_base_types.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Types reexported from [`linera_base`]. 5 | 6 | pub use linera_base::{ 7 | abi::*, crypto::*, data_types::*, identifiers::*, ownership::*, vm::EvmQuery, BcsHexParseError, 8 | }; 9 | -------------------------------------------------------------------------------- /linera-sdk/src/service/conversions_to_wit.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Conversions from types declared in [`linera-sdk`] to types generated by [`wit-bindgen`]. 5 | 6 | use linera_base::{crypto::CryptoHash, identifiers::ApplicationId}; 7 | 8 | use super::wit::service_runtime_api as wit_service_api; 9 | 10 | impl From for wit_service_api::CryptoHash { 11 | fn from(hash_value: CryptoHash) -> Self { 12 | let parts = <[u64; 4]>::from(hash_value); 13 | 14 | wit_service_api::CryptoHash { 15 | part1: parts[0], 16 | part2: parts[1], 17 | part3: parts[2], 18 | part4: parts[3], 19 | } 20 | } 21 | } 22 | 23 | impl From for wit_service_api::ApplicationId { 24 | fn from(application_id: ApplicationId) -> Self { 25 | wit_service_api::ApplicationId { 26 | application_description_hash: application_id.application_description_hash.into(), 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /linera-sdk/src/service/wit.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Internal module with code generated by [`wit-bindgen`](https://github.com/jvff/wit-bindgen). 5 | 6 | #![allow(missing_docs)] 7 | 8 | // Export the service interface. 9 | wit_bindgen::generate!({ 10 | world: "service", 11 | export_macro_name: "export_service", 12 | pub_export_macro: true, 13 | }); 14 | 15 | pub use self::linera::app::{base_runtime_api, service_runtime_api}; 16 | -------------------------------------------------------------------------------- /linera-sdk/src/views/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper types for using [`linera_views`] to store application state. 5 | 6 | mod aliases; 7 | #[cfg(with_testing)] 8 | mod mock_key_value_store; 9 | mod system_api; 10 | 11 | pub use linera_views::{ 12 | self, 13 | common::CustomSerialize, 14 | views::{RootView, View}, 15 | ViewError, 16 | }; 17 | 18 | pub use self::{ 19 | aliases::{ 20 | ByteCollectionView, ByteMapView, ByteSetView, CollectionView, CustomCollectionView, 21 | CustomMapView, CustomSetView, LogView, MapView, QueueView, ReadGuardedView, RegisterView, 22 | SetView, 23 | }, 24 | system_api::{KeyValueStore, ViewStorageContext}, 25 | }; 26 | -------------------------------------------------------------------------------- /linera-sdk/wit/contract.wit: -------------------------------------------------------------------------------- 1 | package linera:app; 2 | 3 | world contract { 4 | import contract-runtime-api; 5 | import base-runtime-api; 6 | 7 | export contract-entrypoints; 8 | } 9 | -------------------------------------------------------------------------------- /linera-sdk/wit/service-entrypoints.wit: -------------------------------------------------------------------------------- 1 | package linera:app; 2 | 3 | interface service-entrypoints { 4 | handle-query: func(argument: list) -> list; 5 | } 6 | -------------------------------------------------------------------------------- /linera-sdk/wit/service-runtime-api.wit: -------------------------------------------------------------------------------- 1 | package linera:app; 2 | 3 | interface service-runtime-api { 4 | schedule-operation: func(operation: list); 5 | try-query-application: func(application: application-id, argument: list) -> list; 6 | check-execution-time: func(fuel-consumed: u64); 7 | 8 | record application-id { 9 | application-description-hash: crypto-hash, 10 | } 11 | 12 | record crypto-hash { 13 | part1: u64, 14 | part2: u64, 15 | part3: u64, 16 | part4: u64, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linera-sdk/wit/service.wit: -------------------------------------------------------------------------------- 1 | package linera:app; 2 | 3 | world service { 4 | import service-runtime-api; 5 | import base-runtime-api; 6 | 7 | export service-entrypoints; 8 | } 9 | -------------------------------------------------------------------------------- /linera-service-graphql-client/README.md: -------------------------------------------------------------------------------- 1 | # Linera service GraphQL client 2 | 3 | 4 | 5 | A GraphQL client for the node service. 6 | 7 | 8 | 9 | ## Generate schema 10 | 11 | To generate the linera service GraphQL schema, a binary `linera-export-schema` is available: 12 | ```bash 13 | cargo run --bin linera-schema-export > linera-service-graphql-client/gql/service_schema.graphql 14 | ``` 15 | 16 | ## Contributing 17 | 18 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 19 | 20 | ## License 21 | 22 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 23 | -------------------------------------------------------------------------------- /linera-service-graphql-client/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! A GraphQL client for the node service. 5 | 6 | mod service; 7 | pub mod utils; 8 | 9 | pub use service::*; 10 | pub use utils::*; 11 | -------------------------------------------------------------------------------- /linera-service/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides the executables needed to operate a Linera service, including a placeholder wallet acting as a GraphQL service for user interfaces. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-service/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_revm: { feature = "revm" }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /linera-service/src/cli/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper module for the Linera CLI binary. 5 | 6 | #![deny(clippy::large_futures)] 7 | 8 | pub mod command; 9 | pub mod net_up_utils; 10 | -------------------------------------------------------------------------------- /linera-service/src/cli_wrappers/util.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::path::PathBuf; 5 | 6 | use anyhow::Result; 7 | use linera_base::command::CommandExt; 8 | use tokio::process::Command; 9 | 10 | pub async fn get_github_root() -> Result { 11 | let github_root = Command::new("git") 12 | .arg("rev-parse") 13 | .arg("--show-toplevel") 14 | .spawn_and_wait_for_stdout() 15 | .await?; 16 | Ok(PathBuf::from( 17 | github_root 18 | .strip_suffix('\n') 19 | .expect("Stripping suffix should not fail") 20 | .to_string(), 21 | )) 22 | } 23 | -------------------------------------------------------------------------------- /linera-service/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Facebook, Inc. and its affiliates. 2 | // Copyright (c) Zefchain Labs, Inc. 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | //! This module provides the executables needed to operate a Linera service, including a placeholder wallet acting as a GraphQL service for user interfaces. 6 | 7 | #![deny(clippy::large_futures)] 8 | 9 | pub mod cli; 10 | pub mod cli_wrappers; 11 | pub mod node_service; 12 | pub mod project; 13 | #[cfg(with_metrics)] 14 | pub mod prometheus_server; 15 | pub mod storage; 16 | pub mod util; 17 | pub mod wallet; 18 | -------------------------------------------------------------------------------- /linera-service/template/Cargo.toml.template: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "{project_name}" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | async-graphql = {{ version = "=7.0.17", default-features = false }} 8 | {linera_sdk_dep} 9 | futures = {{ version = "0.3 "}} 10 | serde = {{ version = "1.0", features = ["derive"] }} 11 | serde_json = {{ version = "1.0" }} 12 | 13 | [dev-dependencies] 14 | {linera_sdk_dev_dep} 15 | tokio = {{ version = "1.40", features = ["rt", "sync"] }} 16 | 17 | [[bin]] 18 | name = "{contract_binary_name}" 19 | path = "src/contract.rs" 20 | 21 | [[bin]] 22 | name = "{service_binary_name}" 23 | path = "src/service.rs" 24 | 25 | [profile.release] 26 | debug = true 27 | lto = true 28 | opt-level = 'z' 29 | strip = 'debuginfo' 30 | -------------------------------------------------------------------------------- /linera-service/template/lib.rs.template: -------------------------------------------------------------------------------- 1 | use async_graphql::{{Request, Response}}; 2 | use linera_sdk::{{ 3 | graphql::GraphQLMutationRoot, 4 | linera_base_types::{{ContractAbi, ServiceAbi}}, 5 | }}; 6 | use serde::{{Deserialize, Serialize}}; 7 | 8 | pub struct {project_name}Abi; 9 | 10 | impl ContractAbi for {project_name}Abi {{ 11 | type Operation = Operation; 12 | type Response = (); 13 | }} 14 | 15 | impl ServiceAbi for {project_name}Abi {{ 16 | type Query = Request; 17 | type QueryResponse = Response; 18 | }} 19 | 20 | #[derive(Debug, Deserialize, Serialize, GraphQLMutationRoot)] 21 | pub enum Operation {{ 22 | Increment {{ value: u64 }}, 23 | }} 24 | -------------------------------------------------------------------------------- /linera-service/template/linera_net_helper.sh: -------------------------------------------------------------------------------- 1 | ../../scripts/linera_net_helper.sh -------------------------------------------------------------------------------- /linera-service/template/rust-toolchain.toml.template: -------------------------------------------------------------------------------- 1 | ../../rust-toolchain.toml -------------------------------------------------------------------------------- /linera-service/template/state.rs.template: -------------------------------------------------------------------------------- 1 | use linera_sdk::views::{{linera_views, RegisterView, RootView, ViewStorageContext}}; 2 | 3 | #[derive(RootView, async_graphql::SimpleObject)] 4 | #[view(context = ViewStorageContext)] 5 | pub struct {project_name}State {{ 6 | pub value: RegisterView, 7 | // Add fields here. 8 | }} 9 | -------------------------------------------------------------------------------- /linera-service/tests/common/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::env; 5 | 6 | /// Restores the `RUSTFLAGS` environment variable to make warnings fail as errors. 7 | pub struct RestoreVarOnDrop; 8 | 9 | impl Drop for RestoreVarOnDrop { 10 | fn drop(&mut self) { 11 | env::set_var("RUSTFLAGS", "-D warnings"); 12 | } 13 | } 14 | 15 | /// Clears the `RUSTFLAGS` environment variable, if it was configured to make warnings fail as 16 | /// errors. 17 | /// 18 | /// The returned [`RestoreVarOnDrop`] restores the environment variable to its original value when 19 | /// it is dropped. 20 | pub fn override_disable_warnings_as_errors() -> Option { 21 | if matches!(env::var("RUSTFLAGS"), Ok(value) if value == "-D warnings") { 22 | env::set_var("RUSTFLAGS", ""); 23 | Some(RestoreVarOnDrop) 24 | } else { 25 | None 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /linera-service/tests/fixtures/evm_basic_check.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract BasicCheck { 6 | 7 | function failing_function() external view returns (uint64) { 8 | require(false); 9 | return 0; 10 | } 11 | 12 | function test_precompile_sha256() external view returns (uint64) { 13 | bytes memory v; 14 | bytes32 ret_zero; 15 | bytes32 ret_val = sha256(v); 16 | require(ret_zero != ret_val); 17 | return 0; 18 | } 19 | 20 | function check_contract_address(address address2) external view returns (uint64) { 21 | address address1 = address(this); 22 | require(address1 == address2); 23 | return 49; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /linera-service/tests/fixtures/evm_call_evm_example_counter.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | interface IExternalContract { 6 | function increment(uint64 value) external returns (uint64); 7 | function get_value() external returns (uint64); 8 | } 9 | 10 | contract ExampleCallEvmCounter { 11 | address evm_address; 12 | 13 | constructor(address _evm_address) { 14 | evm_address = _evm_address; 15 | } 16 | 17 | function nest_increment(uint64 input) external returns (uint64) { 18 | IExternalContract externalContract = IExternalContract(evm_address); 19 | return externalContract.increment(input); 20 | } 21 | 22 | function nest_get_value() external returns (uint64) { 23 | IExternalContract externalContract = IExternalContract(evm_address); 24 | return externalContract.get_value(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /linera-service/tests/fixtures/evm_example_counter.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract ExampleCounter { 6 | uint64 value; 7 | 8 | constructor(uint64 start_value) { 9 | value = start_value; 10 | } 11 | 12 | function increment(uint64 input) external returns (uint64) { 13 | value = value + input; 14 | return value; 15 | } 16 | 17 | function get_value() external view returns (uint64) { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /linera-service/tests/fixtures/evm_example_empty_instantiate.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract ExampleExecuteMessage { 6 | uint64 value; 7 | 8 | constructor() { 9 | value = 37; 10 | } 11 | 12 | function instantiate(bytes memory input) external { 13 | require(input.length == 0); 14 | value = 42; 15 | } 16 | 17 | function get_value() external view returns (uint64) { 18 | return value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /linera-service/tests/fixtures/evm_example_log.sol: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | pragma solidity ^0.8.0; 4 | 5 | contract ExampleEvent { 6 | uint64 value; 7 | event Start(uint64 value); 8 | event Increment(uint64 input, uint64 value); 9 | 10 | constructor(uint64 start_value) { 11 | value = start_value; 12 | emit Start(start_value); 13 | } 14 | 15 | function increment(uint64 input) external { 16 | value = value + input; 17 | emit Increment(input, value); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /linera-service/tests/guard/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use std::sync::LazyLock; 5 | 6 | use tokio::sync::Mutex; 7 | 8 | /// A static lock to prevent integration tests from running in parallel. 9 | pub static INTEGRATION_TEST_GUARD: LazyLock> = LazyLock::new(|| Mutex::new(())); 10 | -------------------------------------------------------------------------------- /linera-storage-service/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module provides a shared key-value store server based on the RocksDB store and the in-memory store of `linera-views`. 4 | The corresponding client implements the `KeyValueStore` and `AdminKeyValueStore` traits. 5 | 6 | 7 | 8 | ## Contributing 9 | 10 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 11 | 12 | ## License 13 | 14 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 15 | -------------------------------------------------------------------------------- /linera-storage-service/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() -> Result<(), Box> { 5 | cfg_aliases::cfg_aliases! { 6 | with_rocksdb: { all(feature = "rocksdb") }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | }; 10 | let no_includes: &[&str] = &[]; 11 | tonic_build::configure() 12 | .protoc_arg("--experimental_allow_proto3_optional") 13 | .compile_protos(&["proto/key_value_store.proto"], no_includes)?; 14 | Ok(()) 15 | } 16 | -------------------------------------------------------------------------------- /linera-storage-service/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This module provides a shared key-value store server based on the RocksDB store and the in-memory store of `linera-views`. 5 | //! The corresponding client implements the `KeyValueStore` and `AdminKeyValueStore` traits. 6 | 7 | #![deny(clippy::large_futures)] 8 | 9 | pub mod key_value_store { 10 | tonic::include_proto!("key_value_store.v1"); 11 | } 12 | 13 | pub mod child; 14 | pub mod client; 15 | pub mod common; 16 | -------------------------------------------------------------------------------- /linera-storage/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This module defines the storage abstractions for individual chains and certificates. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-storage/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_testing: { any(test, feature = "test") }, 7 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 8 | with_wasmer: { all(any(feature = "web", not(target_arch = "wasm32")), feature = "wasmer") }, 9 | with_wasmtime: { all(not(target_arch = "wasm32"), feature = "wasmtime") }, 10 | with_wasm_runtime: { any(with_wasmer, with_wasmtime) }, 11 | with_revm: { feature = "revm" }, 12 | web: { all(target_arch = "wasm32", feature = "web") }, 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /linera-summary/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-summary" 3 | version = "0.1.0" 4 | description = "Executable for performance summary generation." 5 | readme = "README.md" 6 | publish = false 7 | 8 | authors.workspace = true 9 | repository.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | edition.workspace = true 13 | 14 | [dependencies] 15 | anyhow.workspace = true 16 | clap.workspace = true 17 | git2.workspace = true 18 | humantime.workspace = true 19 | linera-base.workspace = true 20 | linera-version.workspace = true 21 | octocrab.workspace = true 22 | serde.workspace = true 23 | tokio.workspace = true 24 | tracing.workspace = true 25 | 26 | [[bin]] 27 | name = "linera-summary" 28 | path = "src/main.rs" 29 | -------------------------------------------------------------------------------- /linera-summary/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This crate provides the internal tool to summarize performance changes in PRs. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-summary/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! This crate provides the internal tool to summarize performance changes in PRs. 5 | 6 | #![deny(clippy::large_futures)] 7 | #![allow(missing_docs)] 8 | 9 | pub mod ci_runtime_comparison; 10 | pub mod github; 11 | pub mod performance_summary; 12 | pub mod summary_options; 13 | -------------------------------------------------------------------------------- /linera-version/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This crate is in charge of extracting version information from the Linera build, for 5 | troubleshooting information and version compatibility checks. 6 | 7 | 8 | 9 | ## Contributing 10 | 11 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 12 | 13 | ## License 14 | 15 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 16 | -------------------------------------------------------------------------------- /linera-version/api-hashes.json: -------------------------------------------------------------------------------- 1 | { 2 | "rpc": "K9p3m/MsIPZL32CYddAqlG6PHKprJvMjei5cIiqFgDY", 3 | "graphql": "RmwcE5swpH/HkjbetY/YyD6ebNQFS9oeU6ayEAvDjEQ", 4 | "wit": "0X+I4jeHCdpD2M0R+OVodI4pH+dF9rt0K/iHENVcnug" 5 | } 6 | -------------------------------------------------------------------------------- /linera-version/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | /*! 5 | 6 | This crate is in charge of extracting version information from the Linera build, for 7 | troubleshooting information and version compatibility checks. 8 | 9 | */ 10 | 11 | mod serde_pretty; 12 | pub use serde_pretty::*; 13 | 14 | mod version_info; 15 | pub use version_info::*; 16 | -------------------------------------------------------------------------------- /linera-version/src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use linera_version::VersionInfo; 5 | 6 | fn main() -> anyhow::Result<()> { 7 | serde_json::to_writer_pretty(std::io::stdout(), &VersionInfo::get()?.api_hashes())?; 8 | 9 | Ok(()) 10 | } 11 | -------------------------------------------------------------------------------- /linera-version/src/serde_pretty/type.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 5 | pub struct Pretty { 6 | pub value: T, 7 | _phantom: std::marker::PhantomData Repr>, 8 | } 9 | 10 | impl Pretty { 11 | pub const fn new(value: T) -> Self { 12 | Pretty { 13 | value, 14 | _phantom: std::marker::PhantomData, 15 | } 16 | } 17 | 18 | pub fn repr(self) -> Repr 19 | where 20 | Repr: From, 21 | { 22 | Repr::from(self.value) 23 | } 24 | } 25 | 26 | impl std::fmt::Display for Pretty 27 | where 28 | T: Clone, 29 | Repr: std::fmt::Display + From, 30 | { 31 | fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { 32 | write!(formatter, "{}", Repr::from(self.value.clone())) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /linera-version/tests/up_to_date.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | use linera_version::VersionInfo; 5 | 6 | #[test] 7 | fn up_to_date() { 8 | assert_eq!( 9 | VersionInfo::get().unwrap().api_hashes(), 10 | VersionInfo::default().api_hashes(), 11 | "`linera-version` API hash cache out of date.\n\ 12 | Please update `linera-version/api-hashes.json` by running:\n\ 13 | $ cargo run -p linera-version > linera-version/api-hashes.json" 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /linera-views-derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-views-derive" 3 | description = "The procedural macros for the crate `linera-views`" 4 | 5 | authors.workspace = true 6 | edition.workspace = true 7 | homepage.workspace = true 8 | license.workspace = true 9 | repository.workspace = true 10 | version.workspace = true 11 | 12 | [features] 13 | metrics = [] 14 | 15 | [lib] 16 | proc-macro = true 17 | 18 | [dependencies] 19 | deluxe.workspace = true 20 | proc-macro2.workspace = true 21 | quote.workspace = true 22 | syn = { workspace = true, features = ["full", "extra-traits"] } 23 | 24 | [dev-dependencies] 25 | insta.workspace = true 26 | prettyplease.workspace = true 27 | 28 | [build-dependencies] 29 | cfg_aliases.workspace = true 30 | -------------------------------------------------------------------------------- /linera-views-derive/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The procedural macros for the crate `linera-views`. 4 | 5 | 6 | 7 | ## Contributing 8 | 9 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 10 | 11 | ## License 12 | 13 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 14 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | RegisterView: ClonableView, 9 | CollectionView>: ClonableView, 10 | Self: linera_views::views::View + Sync, 11 | { 12 | fn clone_unchecked(&mut self) -> Result { 13 | Ok(Self { 14 | register: self.register.clone_unchecked()?, 15 | collection: self.collection.clone_unchecked()?, 16 | }) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | RegisterView: ClonableView, 8 | CollectionView< 9 | CustomContext, 10 | usize, 11 | RegisterView, 12 | >: ClonableView, 13 | Self: linera_views::views::View + Sync, 14 | { 15 | fn clone_unchecked(&mut self) -> Result { 16 | Ok(Self { 17 | register: self.register.clone_unchecked()?, 18 | collection: self.collection.clone_unchecked()?, 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | RegisterView: ClonableView, 9 | CollectionView< 10 | CustomContext, 11 | usize, 12 | RegisterView, 13 | >: ClonableView, 14 | Self: linera_views::views::View + Sync, 15 | { 16 | fn clone_unchecked(&mut self) -> Result { 17 | Ok(Self { 18 | register: self.register.clone_unchecked()?, 19 | collection: self.collection.clone_unchecked()?, 20 | }) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | RegisterView: ClonableView, 8 | CollectionView< 9 | custom::path::to::ContextType, 10 | usize, 11 | RegisterView, 12 | >: ClonableView, 13 | Self: linera_views::views::View + Sync, 14 | { 15 | fn clone_unchecked(&mut self) -> Result { 16 | Ok(Self { 17 | register: self.register.clone_unchecked()?, 18 | collection: self.collection.clone_unchecked()?, 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | RegisterView: ClonableView, 9 | CollectionView< 10 | custom::path::to::ContextType, 11 | usize, 12 | RegisterView, 13 | >: ClonableView, 14 | Self: linera_views::views::View + Sync, 15 | { 16 | fn clone_unchecked(&mut self) -> Result { 17 | Ok(Self { 18 | register: self.register.clone_unchecked()?, 19 | collection: self.collection.clone_unchecked()?, 20 | }) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | RegisterView, usize>: ClonableView, 8 | CollectionView< 9 | custom::GenericContext, 10 | usize, 11 | RegisterView, usize>, 12 | >: ClonableView, 13 | Self: linera_views::views::View + Sync, 14 | { 15 | fn clone_unchecked(&mut self) -> Result { 16 | Ok(Self { 17 | register: self.register.clone_unchecked()?, 18 | collection: self.collection.clone_unchecked()?, 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code-8.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | RegisterView, usize>: ClonableView, 9 | CollectionView< 10 | custom::GenericContext, 11 | usize, 12 | RegisterView, usize>, 13 | >: ClonableView, 14 | Self: linera_views::views::View + Sync, 15 | { 16 | fn clone_unchecked(&mut self) -> Result { 17 | Ok(Self { 18 | register: self.register.clone_unchecked()?, 19 | collection: self.collection.clone_unchecked()?, 20 | }) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__generate_clonable_view_code.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_clonable_view_code(input)) 4 | --- 5 | impl linera_views::views::ClonableView for TestView 6 | where 7 | RegisterView: ClonableView, 8 | CollectionView>: ClonableView, 9 | Self: linera_views::views::View + Sync, 10 | { 11 | fn clone_unchecked(&mut self) -> Result { 12 | Ok(Self { 13 | register: self.register.clone_unchecked()?, 14 | collection: self.collection.clone_unchecked()?, 15 | }) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_C.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | let mut batch = Batch::new(); 15 | self.flush(&mut batch)?; 16 | if !batch.is_empty() { 17 | self.context().store().write_batch(batch).await?; 18 | } 19 | Ok(()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_C_with_where.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | Self: linera_views::views::View + Sync, 9 | { 10 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 11 | use linera_views::{ 12 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 13 | views::View, 14 | }; 15 | let mut batch = Batch::new(); 16 | self.flush(&mut batch)?; 17 | if !batch.is_empty() { 18 | self.context().store().write_batch(batch).await?; 19 | } 20 | Ok(()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_CustomContext.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | let mut batch = Batch::new(); 15 | self.flush(&mut batch)?; 16 | if !batch.is_empty() { 17 | self.context().store().write_batch(batch).await?; 18 | } 19 | Ok(()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_CustomContext_with_where.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | Self: linera_views::views::View + Sync, 9 | { 10 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 11 | use linera_views::{ 12 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 13 | views::View, 14 | }; 15 | let mut batch = Batch::new(); 16 | self.flush(&mut batch)?; 17 | if !batch.is_empty() { 18 | self.context().store().write_batch(batch).await?; 19 | } 20 | Ok(()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_custom__GenericContext_T_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | let mut batch = Batch::new(); 15 | self.flush(&mut batch)?; 16 | if !batch.is_empty() { 17 | self.context().store().write_batch(batch).await?; 18 | } 19 | Ok(()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_custom__GenericContext_T__with_where.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | Self: linera_views::views::View + Sync, 9 | { 10 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 11 | use linera_views::{ 12 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 13 | views::View, 14 | }; 15 | let mut batch = Batch::new(); 16 | self.flush(&mut batch)?; 17 | if !batch.is_empty() { 18 | self.context().store().write_batch(batch).await?; 19 | } 20 | Ok(()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_custom__path__to__ContextType.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | let mut batch = Batch::new(); 15 | self.flush(&mut batch)?; 16 | if !batch.is_empty() { 17 | self.context().store().write_batch(batch).await?; 18 | } 19 | Ok(()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_custom__path__to__ContextType_with_where.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | MyParam: Send + Sync + 'static, 8 | Self: linera_views::views::View + Sync, 9 | { 10 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 11 | use linera_views::{ 12 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 13 | views::View, 14 | }; 15 | let mut batch = Batch::new(); 16 | self.flush(&mut batch)?; 17 | if !batch.is_empty() { 18 | self.context().store().write_batch(batch).await?; 19 | } 20 | Ok(()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_metrics_C.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | #[cfg(not(target_arch = "wasm32"))] 15 | linera_views::metrics::increment_counter( 16 | &linera_views::metrics::SAVE_VIEW_COUNTER, 17 | stringify!(TestView), 18 | &self.context().base_key().bytes, 19 | ); 20 | let mut batch = Batch::new(); 21 | self.flush(&mut batch)?; 22 | if !batch.is_empty() { 23 | self.context().store().write_batch(batch).await?; 24 | } 25 | Ok(()) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_metrics_CustomContext.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | #[cfg(not(target_arch = "wasm32"))] 15 | linera_views::metrics::increment_counter( 16 | &linera_views::metrics::SAVE_VIEW_COUNTER, 17 | stringify!(TestView), 18 | &self.context().base_key().bytes, 19 | ); 20 | let mut batch = Batch::new(); 21 | self.flush(&mut batch)?; 22 | if !batch.is_empty() { 23 | self.context().store().write_batch(batch).await?; 24 | } 25 | Ok(()) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /linera-views-derive/src/snapshots/linera_views_derive__tests__test_generate_root_view_code_metrics_custom__GenericContext_T_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-views-derive/src/lib.rs 3 | expression: pretty(generate_root_view_code(input)) 4 | --- 5 | impl linera_views::views::RootView for TestView 6 | where 7 | Self: linera_views::views::View + Sync, 8 | { 9 | async fn save(&mut self) -> Result<(), linera_views::ViewError> { 10 | use linera_views::{ 11 | context::Context, batch::Batch, store::WritableKeyValueStore as _, 12 | views::View, 13 | }; 14 | #[cfg(not(target_arch = "wasm32"))] 15 | linera_views::metrics::increment_counter( 16 | &linera_views::metrics::SAVE_VIEW_COUNTER, 17 | stringify!(TestView), 18 | &self.context().base_key().bytes, 19 | ); 20 | let mut batch = Batch::new(); 21 | self.flush(&mut batch)?; 22 | if !batch.is_empty() { 23 | self.context().store().write_batch(batch).await?; 24 | } 25 | Ok(()) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /linera-views/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | web: { all(target_arch = "wasm32", feature = "web") }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_metrics: { all(not(target_arch = "wasm32"), feature = "metrics") }, 9 | with_dynamodb: { all(not(target_arch = "wasm32"), feature = "dynamodb") }, 10 | with_indexeddb: { all(web, feature = "indexeddb") }, 11 | with_rocksdb: { all(not(target_arch = "wasm32"), feature = "rocksdb") }, 12 | with_scylladb: { all(not(target_arch = "wasm32"), feature = "scylladb") }, 13 | with_graphql: { not(web) }, 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /linera-views/src/backends/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | pub mod journaling; 5 | 6 | #[cfg(with_metrics)] 7 | pub mod metering; 8 | 9 | pub mod value_splitting; 10 | 11 | pub mod memory; 12 | 13 | pub mod lru_caching; 14 | 15 | pub mod dual; 16 | 17 | #[cfg(with_scylladb)] 18 | pub mod scylla_db; 19 | 20 | #[cfg(with_rocksdb)] 21 | pub mod rocks_db; 22 | 23 | #[cfg(with_dynamodb)] 24 | pub mod dynamo_db; 25 | 26 | #[cfg(with_indexeddb)] 27 | pub mod indexed_db; 28 | -------------------------------------------------------------------------------- /linera-web/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.wasm32-unknown-unknown] 2 | rustflags = [ 3 | # support threading 4 | "-C", "target-feature=+atomics,+bulk-memory,+mutable-globals", 5 | # allow linking C code (for `rust_secp256k1`) 6 | "--cfg=web_sys_unstable_apis", 7 | "-Z", "wasm_c_abi=spec", 8 | ] 9 | 10 | [unstable] 11 | build-std = ["panic_abort", "std"] 12 | 13 | [build] 14 | target = "wasm32-unknown-unknown" 15 | -------------------------------------------------------------------------------- /linera-web/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /pkg 3 | -------------------------------------------------------------------------------- /linera-web/build.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | cd $(dirname -- "${BASH_SOURCE[0]}") 6 | 7 | wasm_bindgen_cli_version=$(wasm-bindgen --version) 8 | wasm_bindgen_cli_version=${wasm_bindgen_cli_version##* } 9 | 10 | wasm_bindgen_cargo_version=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "wasm-bindgen").version') 11 | target_dir=$(cargo metadata --format-version 1 | jq -r .target_directory) 12 | 13 | if [[ "$wasm_bindgen_cargo_version" != "$wasm_bindgen_cli_version" ]] 14 | then 15 | cargo update --package wasm-bindgen --precise "$wasm_bindgen_cli_version" 16 | fi 17 | 18 | if [ "${1-}" = "--release" ] 19 | then 20 | profile_flag=--release 21 | profile_dir=release 22 | else 23 | profile_flag= 24 | profile_dir=debug 25 | fi 26 | 27 | cargo build --lib --target wasm32-unknown-unknown $profile_flag 28 | 29 | wasm-bindgen \ 30 | "$target_dir"/wasm32-unknown-unknown/$profile_dir/linera_web.wasm \ 31 | --out-dir dist \ 32 | --typescript \ 33 | --target web \ 34 | --split-linked-modules 35 | -------------------------------------------------------------------------------- /linera-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@linera/client", 3 | "version": "0.14.0", 4 | "description": "Web client for the Linera blockchain", 5 | "main": "dist/linera_web.js", 6 | "types": "dist/linera_web.d.ts", 7 | "files": [ "dist" ], 8 | "type": "module", 9 | "scripts": { 10 | "install": "true", 11 | "build": "bash build.bash --release", 12 | "prepare": "pnpm build", 13 | "lint": "cargo fmt --check && cargo clippy -- -W clippy::pedantic", 14 | "ci": "pnpm lint" 15 | }, 16 | "keywords": [], 17 | "author": "Linera ", 18 | "license": "Apache-2.0", 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/linera-io/linera-web.git" 22 | }, 23 | "bugs": { 24 | "url": "https://github.com/linera-io/linera-web/issues" 25 | }, 26 | "homepage": "https://github.com/linera-io/linera-web#readme" 27 | } 28 | -------------------------------------------------------------------------------- /linera-witty-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linera-witty-macros" 3 | description = "Procedural macros for generation of WIT compatible host code from Rust code" 4 | readme = "README.md" 5 | documentation = "https://docs.rs/linera-witty-macros/latest/linera_witty_macros/" 6 | 7 | authors.workspace = true 8 | edition.workspace = true 9 | homepage.workspace = true 10 | license.workspace = true 11 | repository.workspace = true 12 | version.workspace = true 13 | 14 | [lib] 15 | proc-macro = true 16 | 17 | [features] 18 | test = ["syn/extra-traits"] 19 | wasmer = ["syn/extra-traits"] 20 | wasmtime = ["syn/extra-traits"] 21 | 22 | [dependencies] 23 | heck.workspace = true 24 | proc-macro-error.workspace = true 25 | proc-macro2.workspace = true 26 | quote.workspace = true 27 | syn = { workspace = true, features = ["full"] } 28 | 29 | [build-dependencies] 30 | cfg_aliases.workspace = true 31 | -------------------------------------------------------------------------------- /linera-witty-macros/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Linera Witty Macros 4 | 5 | This crate contains the procedural macros used by the `linera-witty` crate. 6 | 7 | 8 | 9 | ## Contributing 10 | 11 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 12 | 13 | ## License 14 | 15 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 16 | -------------------------------------------------------------------------------- /linera-witty-macros/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_testing: { feature = "test" }, 7 | with_wasmer: { feature = "wasmer" }, 8 | with_wasmtime: { feature = "wasmtime" }, 9 | with_wit_export: { 10 | any(feature = "test", feature = "wasmer", feature = "wasmtime") 11 | }, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /linera-witty/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Linera Witty 4 | 5 | This crate allows generating [WIT] files and host side code to interface with WebAssembly guests 6 | that adhere to the [WIT] interface format. The source of truth for the generated code and WIT 7 | files is the Rust source code. 8 | 9 | [WIT]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md 10 | 11 | 12 | 13 | ## Contributing 14 | 15 | See the [CONTRIBUTING](../CONTRIBUTING.md) file for how to help out. 16 | 17 | ## License 18 | 19 | This project is available under the terms of the [Apache 2.0 license](../LICENSE). 20 | -------------------------------------------------------------------------------- /linera-witty/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | fn main() { 5 | cfg_aliases::cfg_aliases! { 6 | with_log: { feature = "log" }, 7 | with_testing: { any(test, feature = "test") }, 8 | with_wasmer: { feature = "wasmer" }, 9 | with_wasmtime: { feature = "wasmtime" }, 10 | with_macros: { feature = "macros" }, 11 | with_wit_export: { 12 | all( 13 | feature = "macros", 14 | any(feature = "test", feature = "wasmer", feature = "wasmtime") 15 | ) 16 | }, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /linera-witty/src/memory_layout/flat_layout.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Representation of the layout of complex types as a sequence of native WebAssembly types. 5 | 6 | use frunk::{HCons, HNil}; 7 | 8 | use super::Layout; 9 | use crate::primitive_types::FlatType; 10 | 11 | /// Representation of the layout of complex types as a sequence of native WebAssembly types. 12 | /// 13 | /// This allows laying out complex types as a sequence of WebAssembly types that can represent the 14 | /// parameters or the return list of a function. WIT uses this as an optimization to pass complex 15 | /// types as multiple native WebAssembly parameters. 16 | pub trait FlatLayout: Default + Layout {} 17 | 18 | impl FlatLayout for HNil {} 19 | 20 | impl FlatLayout for HCons 21 | where 22 | Head: FlatType, 23 | Tail: FlatLayout, 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /linera-witty/src/memory_layout/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Memory layout of non-fundamental WIT types. 5 | //! 6 | //! Complex WIT types are stored in memory as a sequence of fundamental types. The [`Layout`] type 7 | //! allows representing the memory layout as a type, a heterogeneous list ([`frunk::hlist::HList`]) 8 | //! of fundamental types. 9 | 10 | mod element; 11 | mod flat_layout; 12 | mod join_flat_layouts; 13 | mod layout; 14 | 15 | pub use self::{flat_layout::FlatLayout, join_flat_layouts::JoinFlatLayouts, layout::Layout}; 16 | -------------------------------------------------------------------------------- /linera-witty/src/primitive_types/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Primitive WebAssembly and WIT types. 5 | 6 | mod array; 7 | mod flat_type; 8 | mod join_flat_types; 9 | mod maybe_flat_type; 10 | mod simple_type; 11 | 12 | pub use self::{ 13 | flat_type::FlatType, join_flat_types::JoinFlatTypes, maybe_flat_type::MaybeFlatType, 14 | simple_type::SimpleType, 15 | }; 16 | -------------------------------------------------------------------------------- /linera-witty/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Code to interface with different runtimes. 5 | 6 | mod borrowed_instance; 7 | mod error; 8 | mod memory; 9 | #[cfg(with_testing)] 10 | mod test; 11 | mod traits; 12 | #[cfg(with_wasmer)] 13 | pub mod wasmer; 14 | #[cfg(with_wasmtime)] 15 | pub mod wasmtime; 16 | 17 | #[cfg(with_testing)] 18 | pub use self::test::{MockExportedFunction, MockInstance, MockResults, MockRuntime}; 19 | pub use self::{ 20 | error::RuntimeError, 21 | memory::{GuestPointer, Memory, RuntimeMemory}, 22 | traits::{Instance, InstanceWithFunction, InstanceWithMemory, Runtime}, 23 | }; 24 | -------------------------------------------------------------------------------- /linera-witty/src/runtime/unit_tests/memory.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Unit tests for guest Wasm module memory manipulation. 5 | 6 | use super::GuestPointer; 7 | 8 | /// Test aligning memory addresses. 9 | /// 10 | /// Checks that the resulting address is aligned and that it never advances more than the alignment 11 | /// amount. 12 | #[test] 13 | fn align_guest_pointer() { 14 | for alignment_bits in 0..3 { 15 | let alignment = 1 << alignment_bits; 16 | let alignment_mask = alignment - 1; 17 | 18 | for start_offset in 0..32 { 19 | let address = GuestPointer(start_offset).aligned_at(alignment); 20 | 21 | assert_eq!(address.0 & alignment_mask, 0); 22 | assert!(address.0 - start_offset < alignment); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /linera-witty/src/type_traits/implementations/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Implementations of the custom traits for existing types. 5 | 6 | mod custom_types; 7 | mod frunk; 8 | #[cfg(with_log)] 9 | mod log; 10 | mod std; 11 | #[cfg(test)] 12 | mod tests; 13 | -------------------------------------------------------------------------------- /linera-witty/src/type_traits/implementations/std/box.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Implementations of the custom traits for the [`Box`] type. 5 | 6 | impl_for_wrapper_type!(Box); 7 | -------------------------------------------------------------------------------- /linera-witty/src/type_traits/implementations/std/rc.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Implementations of the custom traits for the [`Rc`] type. 5 | 6 | use std::rc::Rc; 7 | 8 | impl_for_wrapper_type!(Rc); 9 | -------------------------------------------------------------------------------- /linera-witty/src/type_traits/implementations/std/sync.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Implementations of the custom traits for types from [`std::sync`]. 5 | 6 | use std::sync::Arc; 7 | 8 | impl_for_wrapper_type!(Arc); 9 | -------------------------------------------------------------------------------- /linera-witty/src/util/mod.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper types and functions that aren't specific to WIT or WebAssembly. 5 | 6 | mod merge; 7 | mod split; 8 | mod zero_extend; 9 | 10 | pub use self::{merge::Merge, split::Split, zero_extend::ZeroExtend}; 11 | -------------------------------------------------------------------------------- /linera-witty/src/util/zero_extend.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Conversions with zero-extension. 5 | 6 | /// Converts from a type into a wider `Target` type by zero-extending the most significant bits. 7 | pub trait ZeroExtend { 8 | /// Converts into the `Target` type by zero-extending the most significant bits. 9 | fn zero_extend(self) -> Target; 10 | } 11 | 12 | impl ZeroExtend for i32 { 13 | fn zero_extend(self) -> i64 { 14 | self as u32 as u64 as i64 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /linera-witty/test-modules/src/export/simple_function.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper Wasm module with a minimal function without parameters or return values. 5 | 6 | #![cfg_attr(target_arch = "wasm32", no_main)] 7 | 8 | wit_bindgen::generate!("export-simple-function"); 9 | 10 | export_export_simple_function!(Implementation); 11 | 12 | use self::exports::witty_macros::test_modules::simple_function::SimpleFunction; 13 | 14 | struct Implementation; 15 | 16 | impl SimpleFunction for Implementation { 17 | fn simple() {} 18 | } 19 | 20 | #[cfg(not(target_arch = "wasm32"))] 21 | fn main() {} 22 | -------------------------------------------------------------------------------- /linera-witty/test-modules/src/import/setters.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper Wasm module that calls some functions that have one parameter and no return values. 5 | 6 | #![cfg_attr(target_arch = "wasm32", no_main)] 7 | 8 | wit_bindgen::generate!("import-setters"); 9 | 10 | export_import_setters!(Implementation); 11 | 12 | use self::{ 13 | exports::witty_macros::test_modules::entrypoint::Entrypoint, 14 | witty_macros::test_modules::setters::*, 15 | }; 16 | 17 | struct Implementation; 18 | 19 | impl Entrypoint for Implementation { 20 | fn entrypoint() { 21 | set_bool(false); 22 | set_s8(-100); 23 | set_u8(201); 24 | set_s16(-20_000); 25 | set_u16(50_000); 26 | set_s32(-2_000_000); 27 | set_u32(4_000_000); 28 | set_float32(10.4); 29 | set_float64(-0.000_08); 30 | } 31 | } 32 | 33 | #[cfg(not(target_arch = "wasm32"))] 34 | fn main() {} 35 | -------------------------------------------------------------------------------- /linera-witty/test-modules/src/import/simple_function.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper Wasm module that calls a minimal function without parameters or return values. 5 | 6 | #![cfg_attr(target_arch = "wasm32", no_main)] 7 | 8 | wit_bindgen::generate!("import-simple-function"); 9 | 10 | export_import_simple_function!(Implementation); 11 | 12 | use self::{ 13 | exports::witty_macros::test_modules::entrypoint::Entrypoint, 14 | witty_macros::test_modules::simple_function::*, 15 | }; 16 | 17 | struct Implementation; 18 | 19 | impl Entrypoint for Implementation { 20 | fn entrypoint() { 21 | simple(); 22 | } 23 | } 24 | 25 | #[cfg(not(target_arch = "wasm32"))] 26 | fn main() {} 27 | -------------------------------------------------------------------------------- /linera-witty/test-modules/src/reentrancy/global_state.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper Wasm module for reentrancy tests with a global state, to check that it is persisted 5 | //! across reentrant calls. 6 | 7 | #![cfg_attr(target_arch = "wasm32", no_main)] 8 | 9 | wit_bindgen::generate!("reentrant-global-state"); 10 | 11 | export_reentrant_global_state!(Implementation); 12 | 13 | use self::{ 14 | exports::witty_macros::test_modules::global_state::GlobalState, 15 | witty_macros::test_modules::get_host_value::*, 16 | }; 17 | 18 | static mut GLOBAL_STATE: u32 = 0; 19 | 20 | struct Implementation; 21 | 22 | impl GlobalState for Implementation { 23 | fn entrypoint(value: u32) -> u32 { 24 | unsafe { GLOBAL_STATE = value }; 25 | get_host_value() 26 | } 27 | 28 | fn get_global_state() -> u32 { 29 | unsafe { GLOBAL_STATE } 30 | } 31 | } 32 | 33 | #[cfg(not(target_arch = "wasm32"))] 34 | fn main() {} 35 | -------------------------------------------------------------------------------- /linera-witty/test-modules/src/reentrancy/simple_function.rs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Zefchain Labs, Inc. 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | //! Helper Wasm module for reentrancy tests with a simple function that has no parameters nor 5 | //! returns values. 6 | 7 | #![cfg_attr(target_arch = "wasm32", no_main)] 8 | 9 | wit_bindgen::generate!("reentrant-simple-function"); 10 | 11 | export_reentrant_simple_function!(Implementation); 12 | 13 | use self::{ 14 | exports::witty_macros::test_modules::{ 15 | entrypoint::Entrypoint, simple_function::SimpleFunction, 16 | }, 17 | witty_macros::test_modules::simple_function::*, 18 | }; 19 | 20 | struct Implementation; 21 | 22 | impl Entrypoint for Implementation { 23 | fn entrypoint() { 24 | simple(); 25 | } 26 | } 27 | 28 | impl SimpleFunction for Implementation { 29 | fn simple() {} 30 | } 31 | 32 | #[cfg(not(target_arch = "wasm32"))] 33 | fn main() {} 34 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/entrypoint.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface entrypoint { 4 | entrypoint: func() 5 | } 6 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/export.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | world export-simple-function { 4 | export simple-function 5 | } 6 | 7 | world export-getters { 8 | export getters 9 | } 10 | 11 | world export-setters { 12 | export setters 13 | } 14 | 15 | world export-operations { 16 | export operations 17 | } 18 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/getters.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface getters { 4 | get-true: func() -> bool 5 | get-false: func() -> bool 6 | get-s8: func() -> s8 7 | get-u8: func() -> u8 8 | get-s16: func() -> s16 9 | get-u16: func() -> u16 10 | get-s32: func() -> s32 11 | get-u32: func() -> u32 12 | get-s64: func() -> s64 13 | get-u64: func() -> u64 14 | get-float32: func() -> float32 15 | get-float64: func() -> float64 16 | } 17 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/global-state.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface global-state { 4 | entrypoint: func(value: u32) -> u32 5 | get-global-state: func() -> u32 6 | } 7 | 8 | interface get-host-value { 9 | get-host-value: func() -> u32 10 | } 11 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/import.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | world import-simple-function { 4 | import simple-function 5 | export entrypoint 6 | } 7 | 8 | world import-getters { 9 | import getters 10 | export entrypoint 11 | } 12 | 13 | world import-setters { 14 | import setters 15 | export entrypoint 16 | } 17 | 18 | world import-operations { 19 | import operations 20 | export entrypoint 21 | } 22 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/operations.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface operations { 4 | and-bool: func(first: bool, second: bool) -> bool 5 | add-s8: func(first: s8, second: s8) -> s8 6 | add-u8: func(first: u8, second: u8) -> u8 7 | add-s16: func(first: s16, second: s16) -> s16 8 | add-u16: func(first: u16, second: u16) -> u16 9 | add-s32: func(first: s32, second: s32) -> s32 10 | add-u32: func(first: u32, second: u32) -> u32 11 | add-s64: func(first: s64, second: s64) -> s64 12 | add-u64: func(first: u64, second: u64) -> u64 13 | add-float32: func(first: float32, second: float32) -> float32 14 | add-float64: func(first: float64, second: float64) -> float64 15 | } 16 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/reentrancy.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | world reentrant-simple-function { 4 | import simple-function 5 | export simple-function 6 | export entrypoint 7 | } 8 | 9 | world reentrant-getters { 10 | import getters 11 | export getters 12 | export entrypoint 13 | } 14 | 15 | world reentrant-setters { 16 | import setters 17 | export setters 18 | export entrypoint 19 | } 20 | 21 | world reentrant-operations { 22 | import operations 23 | export operations 24 | export entrypoint 25 | } 26 | 27 | world reentrant-global-state { 28 | import get-host-value 29 | export global-state 30 | } 31 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/setters.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface setters { 4 | set-bool: func(value: bool) 5 | set-s8: func(value: s8) 6 | set-u8: func(value: u8) 7 | set-s16: func(value: s16) 8 | set-u16: func(value: u16) 9 | set-s32: func(value: s32) 10 | set-u32: func(value: u32) 11 | set-s64: func(value: s64) 12 | set-u64: func(value: u64) 13 | set-float32: func(value: float32) 14 | set-float64: func(value: float64) 15 | } 16 | -------------------------------------------------------------------------------- /linera-witty/test-modules/wit/simple-function.wit: -------------------------------------------------------------------------------- 1 | package witty-macros:test-modules 2 | 3 | interface simple-function { 4 | simple: func() 5 | } 6 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__entrypoint.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface entrypoint { 8 | entrypoint: func(); 9 | } 10 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__getters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface getters { 8 | get-true: func() -> bool; 9 | get-false: func() -> bool; 10 | get-s8: func() -> s8; 11 | get-u8: func() -> u8; 12 | get-s16: func() -> s16; 13 | get-u16: func() -> u16; 14 | get-s32: func() -> s32; 15 | get-u32: func() -> u32; 16 | get-s64: func() -> s64; 17 | get-u64: func() -> u64; 18 | get-float32: func() -> float32; 19 | get-float64: func() -> float64; 20 | } 21 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__operations.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface operations { 8 | and-bool: func(first: bool, second: bool) -> bool; 9 | add-s8: func(first: s8, second: s8) -> s8; 10 | add-u8: func(first: u8, second: u8) -> u8; 11 | add-s16: func(first: s16, second: s16) -> s16; 12 | add-u16: func(first: u16, second: u16) -> u16; 13 | add-s32: func(first: s32, second: s32) -> s32; 14 | add-u32: func(first: u32, second: u32) -> u32; 15 | add-s64: func(first: s64, second: s64) -> s64; 16 | add-u64: func(first: u64, second: u64) -> u64; 17 | add-float32: func(first: float32, second: float32) -> float32; 18 | add-float64: func(first: float64, second: float64) -> float64; 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__setters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface setters { 8 | set-bool: func(value: bool); 9 | set-s8: func(value: s8); 10 | set-u8: func(value: u8); 11 | set-s16: func(value: s16); 12 | set-u16: func(value: u16); 13 | set-s32: func(value: s32); 14 | set-u32: func(value: u32); 15 | set-s64: func(value: s64); 16 | set-u64: func(value: u64); 17 | set-float32: func(value: float32); 18 | set-float64: func(value: float64); 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__simple_function.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface simple-function { 8 | simple: func(); 9 | } 10 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/reentrancy__wit_world_file.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/reentrancy.rs 3 | expression: "WitWorldWriter::new(\"witty-macros:test-modules\",\n \"test-world\").export::>>().export::>>().export::>>().export::>>().export::>>().import::().import::>>().import::>>().import::>>().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | world test-world { 8 | import simple-function; 9 | import getters; 10 | import setters; 11 | import operations; 12 | 13 | export entrypoint; 14 | export simple-function; 15 | export getters; 16 | export setters; 17 | export operations; 18 | } 19 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__entrypoint.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface entrypoint { 8 | entrypoint: func(); 9 | } 10 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__getters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface getters { 8 | get-true: func() -> bool; 9 | get-false: func() -> bool; 10 | get-s8: func() -> s8; 11 | get-u8: func() -> u8; 12 | get-s16: func() -> s16; 13 | get-u16: func() -> u16; 14 | get-s32: func() -> s32; 15 | get-u32: func() -> u32; 16 | get-s64: func() -> s64; 17 | get-u64: func() -> u64; 18 | get-float32: func() -> float32; 19 | get-float64: func() -> float64; 20 | } 21 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__operations.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface operations { 8 | and-bool: func(first: bool, second: bool) -> bool; 9 | add-s8: func(first: s8, second: s8) -> s8; 10 | add-u8: func(first: u8, second: u8) -> u8; 11 | add-s16: func(first: s16, second: s16) -> s16; 12 | add-u16: func(first: u16, second: u16) -> u16; 13 | add-s32: func(first: s32, second: s32) -> s32; 14 | add-u32: func(first: u32, second: u32) -> u32; 15 | add-s64: func(first: s64, second: s64) -> s64; 16 | add-u64: func(first: u64, second: u64) -> u64; 17 | add-float32: func(first: float32, second: float32) -> float32; 18 | add-float64: func(first: float64, second: float64) -> float64; 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__setters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface setters { 8 | set-bool: func(value: bool); 9 | set-s8: func(value: s8); 10 | set-u8: func(value: u8); 11 | set-s16: func(value: s16); 12 | set-u16: func(value: u16); 13 | set-s32: func(value: s32); 14 | set-u32: func(value: u32); 15 | set-s64: func(value: s64); 16 | set-u64: func(value: u64); 17 | set-float32: func(value: float32); 18 | set-float64: func(value: float64); 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__simple-function.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface simple-function { 8 | simple: func(); 9 | } 10 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_export__wit_world_file.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_export.rs 3 | expression: "WitWorldWriter::new(\"witty-macros:test-modules\",\n \"test-world\").export::>>().import::().import::().import::().import::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | world test-world { 8 | import simple-function; 9 | import getters; 10 | import setters; 11 | import operations; 12 | 13 | export entrypoint; 14 | } 15 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_import__getters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_import.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface getters { 8 | get-true: func() -> bool; 9 | get-false: func() -> bool; 10 | get-s8: func() -> s8; 11 | get-u8: func() -> u8; 12 | get-s16: func() -> s16; 13 | get-u16: func() -> u16; 14 | get-s32: func() -> s32; 15 | get-u32: func() -> u32; 16 | get-s64: func() -> s64; 17 | get-u64: func() -> u64; 18 | get-float32: func() -> float32; 19 | get-float64: func() -> float64; 20 | } 21 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_import__operations.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_import.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface operations { 8 | and-bool: func(first: bool, second: bool) -> bool; 9 | add-s8: func(first: s8, second: s8) -> s8; 10 | add-u8: func(first: u8, second: u8) -> u8; 11 | add-s16: func(first: s16, second: s16) -> s16; 12 | add-u16: func(first: u16, second: u16) -> u16; 13 | add-s32: func(first: s32, second: s32) -> s32; 14 | add-u32: func(first: u32, second: u32) -> u32; 15 | add-s64: func(first: s64, second: s64) -> s64; 16 | add-u64: func(first: u64, second: u64) -> u64; 17 | add-float32: func(first: float32, second: float32) -> float32; 18 | add-float64: func(first: float64, second: float64) -> float64; 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_import__setters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_import.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface setters { 8 | set-bool: func(value: bool); 9 | set-s8: func(value: s8); 10 | set-u8: func(value: u8); 11 | set-s16: func(value: s16); 12 | set-u16: func(value: u16); 13 | set-s32: func(value: s32); 14 | set-u32: func(value: u32); 15 | set-s64: func(value: s64); 16 | set-u64: func(value: u64); 17 | set-float32: func(value: float32); 18 | set-float64: func(value: float64); 19 | } 20 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_import__simple-function.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_import.rs 3 | expression: "WitInterfaceWriter::new::().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | interface simple-function { 8 | simple: func(); 9 | } 10 | -------------------------------------------------------------------------------- /linera-witty/tests/snapshots/wit_import__wit_world_file.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: linera-witty/tests/wit_import.rs 3 | expression: "WitWorldWriter::new(\"witty-macros:test-modules\",\n \"test-world\").export::>>().export::>>().export::>>().export::>>().generate_file_contents().collect::()" 4 | --- 5 | package witty-macros:test-modules; 6 | 7 | world test-world { 8 | export simple-function; 9 | export getters; 10 | export setters; 11 | export operations; 12 | } 13 | -------------------------------------------------------------------------------- /packages.txt: -------------------------------------------------------------------------------- 1 | # List of packages to be published on `crates.io`, in this order. 2 | # - Specific arguments for cargo publish or cargo package may be added at the end, on the same line. 3 | # - See scripts/publish.sh and scripts/test_publish.sh for usage. 4 | linera-version --no-verify 5 | linera-persistent 6 | linera-witty-macros 7 | linera-witty 8 | linera-base 9 | linera-views-derive 10 | linera-views 11 | linera-execution 12 | linera-chain 13 | linera-storage-service 14 | linera-storage 15 | linera-core 16 | linera-ethereum 17 | linera-sdk-derive 18 | linera-sdk 19 | linera-rpc 20 | linera-client 21 | linera-faucet-client 22 | linera-faucet-server 23 | linera-service 24 | linera-service-graphql-client 25 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | toolchains/stable/rust-toolchain.toml -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | unstable_features = true 2 | imports_granularity = "Crate" 3 | group_imports = "StdExternalCrate" 4 | edition = "2021" 5 | format_code_in_doc_comments = true 6 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /scripts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = ["check_copyright_header"] 4 | 5 | [workspace.dependencies] 6 | thiserror = "1.0.38" 7 | 8 | check_copyright_header = { path = "./check_copyright_header" } 9 | -------------------------------------------------------------------------------- /scripts/check_copyright_header/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /scripts/check_copyright_header/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "check_copyright_header" 3 | version = "0.1.0" 4 | authors = ["Linera "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | thiserror.workspace = true 9 | 10 | [[bin]] 11 | name = "check_copyright_header" 12 | path = "src/main.rs" 13 | -------------------------------------------------------------------------------- /scripts/install_hooks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd ) 4 | 5 | if cat < $ROOT_DIR/.git/hooks/pre-push 6 | #!/bin/sh 7 | # 8 | # This pre-push hook runs a cargo-clippy and cargo +nightly fmt before pushing code to remote. 9 | # This is to prevent commits being pushed which will fail CI. 10 | 11 | cargo clippy --all-targets || { echo "Error: clippy did not pass - aborting push. Please run 'cargo clippy --all-targets'." ; exit 1 ; } 12 | 13 | trap "ln -sf toolchains/stable/rust-toolchain.toml" EXIT 14 | ln -sf toolchains/nightly/rust-toolchain.toml 15 | cargo fmt -- --check --config unstable_features=true --config imports_granularity=Crate || { echo "Error: format check failed - aborting push. Please run 'cargo +nightly fmt'." ; exit 1 ; } 16 | 17 | cargo machete || { echo "Error: dependency check failed - aborting push." ; exit 1 ; } 18 | EOF 19 | then 20 | chmod +x $ROOT_DIR/.git/hooks/pre-push 21 | else 22 | echo "Failed to write pre-push hook" 23 | exit 1 24 | fi 25 | -------------------------------------------------------------------------------- /scripts/owner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Run cargo owner on the current workspace. 4 | # 5 | # Usage: scripts/owner.sh packages.txt ARGS.. 6 | 7 | set -e 8 | 9 | PACKAGES="$1" 10 | shift 11 | 12 | echo "Type 'yes' to run the following command on every crate: cargo owner $@" 13 | read INPUT 14 | if [ "$INPUT" != "yes" ]; then exit 0; fi 15 | 16 | grep -v '^#' "$PACKAGES" | while read LINE; do 17 | LINE=($LINE) 18 | NAME="${LINE[0]}" 19 | ( 20 | set -x; 21 | cargo owner "$@" "$NAME" 22 | ) 23 | done 24 | -------------------------------------------------------------------------------- /scripts/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Publish crates from the current workspace. 4 | # 5 | # Usage: scripts/publish.sh packages.txt 6 | 7 | set -x -e 8 | 9 | # Publish the given packages. 10 | grep -v '^#' "$1" | while read LINE; do 11 | cargo publish -p $LINE 12 | done 13 | -------------------------------------------------------------------------------- /scripts/yank.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Yank crates from the current workspace. 4 | # 5 | # Usage: scripts/yank.sh VERSION packages.txt 6 | 7 | set -e 8 | 9 | # Yank the given packages. 10 | grep -v '^#' "$2" | while read LINE; do 11 | LINE=($LINE) 12 | NAME="${LINE[0]}" 13 | ( 14 | set -x; 15 | cargo yank "$NAME"@"$1" 16 | ) 17 | done 18 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | (builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default 2 | -------------------------------------------------------------------------------- /toolchains/nightly/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly-2025-03-21" 3 | components = [ "clippy", "rustfmt", "rust-src" ] 4 | targets = [ "wasm32-unknown-unknown" ] 5 | profile = "minimal" 6 | -------------------------------------------------------------------------------- /toolchains/stable/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.86.0" 3 | components = [ "clippy", "rustfmt", "rust-src" ] 4 | targets = [ "wasm32-unknown-unknown" ] 5 | profile = "minimal" 6 | --------------------------------------------------------------------------------