Alexander Kjeldaas
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ## Discussion notes 2021-07-26 ### Transactions, Txids and wrapping #### Should signatures be native or not? Prior art: Ethereum has signature checks built-in. Bitcoin does not, but has "standard transactions" that are are similar. Both might have the ability to change, and disregarding the very conservative stance Bitcoin has, it could probably change more easily than Ethereum. There are many issues wrt signatures: - Signatures could be tied to L1 keys - There are light clients that need to sign, and piggy-back servers that need to sign. - We have L1 representations and L2 representations of the data we embed, and we need to decide what payload to sign. Issue: Having the signature as part of the transaction could be a problem If you need to sign a transaction that does not exist (yet). ### The case for non-native signatures This is how it could potentially look In this example we have an incoming transaction tx0, likely coming from a piggy-back server. The piggy-back will put multiple CW transactions into its own transaction. - `txN` (N=1..3) are simply DATA actions (no code) that contain the to-be-unwrapped transaction (code). - `txN_sig` (N=1..3) contain signatures for the txN DATA actions, however, the XCO in `tx1` and `tx2` were issued by the "standard" `check_sig` contract, while XCO spent by `tx3` is owned by a more expensive private ZK contract. - 3 x send actions sending the pairs (`txN`, `txN_sig`) (N=1..3) to `check_sig_contract` ```mermaid flowchart TB subgraph tx0 [ Original Tx received from L1 ] direction TB foo[" "] subgraph tx1 [ tx1 - $0 ] %% direction LR out1_1[Send: 2.99 XCO to 'check_sig'<br/>AGG: *] info1_1[DATA: for Alice ] utxo1_1[DATA: Spend 1 XCO from Bob] utxo2_1[DATA: Spend 2 XCO from Anthony] end style tx1 fill:#f9f,stroke:#333,stroke-width:4px subgraph tx1_sig [ tx1_sig - $1 ] sig1_1[Bob signature for tx1] sig2_1[Anthony signature for tx1] end tx1 --> sig1_1[Bob signature for tx1] tx1 --> sig2_1[Anthony signature for tx1] subgraph tx2 [ tx2 - $2 ] %% direction LR out1[Send: 2.99 XCO to 'check_sig'] info1_2[for Alice ] utxo1_2[DATA: Spend 1 XCO, another, from Bob] utxo2_2[DATA: Spend 2 XCO from Mark] end subgraph tx2_sig [ tx2_sig - $3 ] sig1[Bob signature for tx1] sig2[Mark signature for tx1] end subgraph tx3 [ tx3 - $4 ] %% direction LR out1_3[Send: 2.99 XCO to 'check_sig'] info1_3[for Alice ] utxo1_3[DATA: Spend 1 XCO from Oscar] utxo2_3[DATA: Spend 2 XCO from Helen] end subgraph tx3_sig [ tx3_sig - $5 ] zero_knowledge_proof end tx3 --> tx3_sig tx2 --> sig1[Bob signature for tx1] tx2 --> sig2[Mark signature for tx1] other1[send: to check_sig_contract with some gas<br/>agg: tx_to_unpack: $1<br/>tx_sig: $2<br/>is_lead: $row == 0 ] other2[send: to check_sig_contract with some gas<br/>agg: ...] other3[send: to check_private_contract with some gas<br/>agg: ...] other4[send: to check_sig_contract with some gas<br/>agg: tx_to_unpack: $1<br/>tx_sig: $2<br/>is_lead: $row == 0 ] xco_utxo[spend: XCO from piggyback server] end subgraph tx1_output out1_out[Send: 2.99 XCO to check_sig] info2_1[for Alice ] utxo1_out[DATA: Spend 1 XCO from Bob] utxo2_out[DATA: Spend 2 XCO from Mark] end subgraph tx2_output out1_out2[Send: 2.99 XCO to check_sig] info2_2[for Alice ] utxo1_out2[DATA: Spend 1 XCO from Bob] utxo2_out2[DATA: Spend 2 XCO from Mark] end subgraph tx3_output out1_out3[Send: 2.99 XCO to check_sig] info2_3[for Alice ] utxo1_out3[DATA: Spend 1 XCO from Bob] utxo2_out3[DATA: Spend 2 XCO from Mark] end l1_raw_data --> parsing_contract --> tx0 other1 --> check_sig_contract --> tx1_output --> check_sig_contract3 other2 --> check_sig_contract --> tx2_output --> check_sig_contract3 other3 --> check_private_contract --> tx3_output --> check_sig_contract3 check_sig_contract3[check_sig] --> store[Create claim Alice has 8.7 XCO] %% three --> two %% XXY --> xxx2 ``` ```mermaid flowchart TB subgraph tx0 [ Original Tx received from L1 ] direction TB tx1[Transfer<br/> -1.00 XCO from Bob<br/>-2.00 XCO from Anthony<br/>+2.99 Alice] tx1_sig[Signatures for tx1<br/>Bob<br/>Anthony] tx1 --> tx1_sig tx2[Transfer<br/>-1.00 XCO from Bob<br/>-2.00 XCO from Mark<br/>+2.99 Alice] tx2_sig[Signatures for tx2<br/>Bob<br/>Mark] tx2 --> tx2_sig subgraph tx3 %% direction LR out1_3[Send: 2.99 XCO to 'check_sig'] info1_3[for Alice ] utxo1_3[DATA: Spend 1 XCO from Oscar] utxo2_3[DATA: Spend 2 XCO from Helen] end subgraph tx3_sig zero_knowledge_proof end tx3 --> tx3_sig tx2 --> sig1[Bob signature for tx1] tx2 --> sig2[Mark signature for tx1] other1[send: to check_sig_contract with some gas] other2[send: to check_sig_contract with some gas] other3[send: to check_private_contract with some gas] xco_utxo[spend: XCO from piggyback server] end l1_parsed_raw_tree_or_even_raw_bytestring --> parsing_contract parsing_contract --> rx0 subgraph tx1_output out1_out[Send: 2.99 XCO to check_sig] info2_1[for Alice ] utxo1_out[DATA: Spend 1 XCO from Bob] utxo2_out[DATA: Spend 2 XCO from Mark] end subgraph tx2_output out1_out2[Send: 2.99 XCO to check_sig] info2_2[for Alice ] utxo1_out2[DATA: Spend 1 XCO from Bob] utxo2_out2[DATA: Spend 2 XCO from Mark] end subgraph tx3_output out1_out3[Send: 2.99 XCO to check_sig] info2_3[for Alice ] utxo1_out3[DATA: Spend 1 XCO from Bob] utxo2_out3[DATA: Spend 2 XCO from Mark] end other1 --> check_sig_contract --> tx1_output --> check_sig_contract3 other2 --> check_sig_contract --> tx2_output --> check_sig_contract3 other3 --> check_private_contract --> tx3_output --> check_sig_contract3 check_sig_contract3[check_sig] --> store[Create claim Alice has 8.7 XCO] %% three --> two %% XXY --> xxx2 ``` Problem: For complex signature checks, (ZK and others), or actually all signature checks, the "unwrapping" needs to happen before any gas payments happen, so we don't know beforehand whether there is enough gas. We already have that claims are owned by the code that create them. This means, that the XCO spent by Oscar, Anthony, Bob, and Helen were created by the `check_sig_contract` contract, and thus they can only be spent using the same contract. We introduce a primitive smart contract called `bitcoin_xco So if Oscar has XCO claims create by a ZK contract, Quote: "claim owned by ZK-contract foo" #### Compression ### Actions: - Read action will have one or more flags to indicate whether they should block on read. If there's no value to be returned, a block read will suspend the whole transaction till there's a value to be returned, or a maximum number of steps has passed. When there are several block reads, it would be possible to specify some sort and-or-tree behaviour. The max number of steps to wait will be part of the action arguments (i.e, one willing to wait longer will cost more). - Though the cost of each defined actions is possible to be determined statically; Scan like queries (like regex) will be allowed by specifiying the number or max rows to scan and the offset where start scanning. - The read actions will be flexible enough to allow regex filters, combine with some sort of sorting (like sort by the beginning of the key of the key-value-pair). - On the aggregation expression language would be able ### Governance: #### Burning rate: To update a parameter, an smartcontract would need to burn: $$ previous\_wining\_bind · histeresis · deprecition^{current\_block - wining\_bind\_block} $$ The idea is that the campaigner for a gobernance change(s) would make a contract where people will send xco to, after a time period, the contract will either reach the required amount to introduce the change(s) [meaning the xco will be burnt] or will return the accumulated xco to their owners. Having relative big values for the hysteresis parameters and for the inverse of depreciation parameter (i.e $1/deprecition$) would prevent the expected time required to change a value, to depend less on the XCO price fluctuation. This means we can get as close as we want to have a periodic auction on the gobernance parameter change. For economists we could explain this as a [Dutch auction](https://en.wikipedia.org/wiki/Dutch_auction) that gets restarted with a premium (i.e histeresis). We can also use "target" and "accuracy (of target time)" as concepts. The whole process is like a Dutch auction, but where the price reductions are exponential. This means that "the real" dutch auction happens around approximately the target time, but whether it is exactly at this time is governed by the accuracy of the target time. #### Burning rationale: (see quotes) ### Quotes "we're not using staking when nothing is at stake". "no representation without taxation^Wburning". "prevents changes to be tweeter pouplarity contests". "prevents power centralization". #### Compilation Assuming the following ```javascript async function foo(arg1): Promise<undefined> { console.log(1) await undefined; console.log(2) await undefined; console.log(3) } ``` is converted into ```javascript function foo(idx: number = 0, arg1) { switch (idx) { case 0: console.log(1); return Promise.resolve(undefined).then(() => foo(1, arg1)) case 1: console.log(2); return Promise.resolve(undefined).then(() => foo(2, arg1)) case 2: console.log(2); return Promise.resolve(undefined); } } ``` ```javascript async function foo(arg1) { console.log(1) await undefined; console.log(2) await undefined; console.log(3) } ``` ```javascript foo() { console.log(1); return Promise( () => { console.log(2) return Promise( () => { console.log(3) } ) } ) ``` From https://babeljs.io/docs/en/babel-plugin-transform-regenerator ```javascript= // Make 2 fetch calls from our API to get a user's messages async function getUserMessages(username) { // fetch to endpoint that has our users const userResults = await fetch('/users'); // find the user's id from the username input const userObject = userResults.find( user => user.username === username); // Make another fetch call to get the user's messages const userMessages = await fetch(`/messages/${userObject.id}`); // Return that user's messages return userMessages; } ``` ```javascript= var userResults, userId, userMessages; return regeneratorRuntime.wrap( function _callee$(_context) { while (1) { switch ((_context.prev = _context.next)) { case 0: _context.next = 2; return fetch("/users"); case 2: userResults = _context.sent; userId = userResults.find(function(user) { return user.username === username; }); _context.next = 6; return fetch("/messages/" + userId); case 6: userMessages = _context.sent; return _context.abrupt("return", userMessages); case 8: case "end": return _context.stop(); } } }, _callee, this ); ``` #### The library problem 1. How to deduplicate code used in two contracts 2. How to upgrade a library without paying too much 3. How to organize libraries (tree vs big blob) 4. How does the module system in WASM work (can you have multiple versions of the same symbol included from different modules (javascript-style), or a global symbol table where there are collisions if multiple versions are used) #### Numbers you should know 100 EVM GAS = 0.01 EUR (40 GWei gas price) - 0.1 EUR (400 GWei gas price) #### What if we have a driver that gets the list of transactions? (This flowchart is not finished, just a copy) ```mermaid flowchart TB subgraph tx0 [ Original Tx received from L1 ] direction TB tx1[Transfer<br/> -1.00 XCO from Bob<br/>-2.00 XCO from Anthony<br/>+2.99 Alice] tx1_sig[Signatures for tx1<br/>Bob<br/>Anthony] tx1 --> tx1_sig tx2[Transfer<br/>-1.00 XCO from Bob<br/>-2.00 XCO from Mark<br/>+2.99 Alice] tx2_sig[Signatures for tx2<br/>Bob<br/>Mark] tx2 --> tx2_sig subgraph tx3 %% direction LR out1_3[Send: 2.99 XCO to 'check_sig'] info1_3[for Alice ] utxo1_3[DATA: Spend 1 XCO from Oscar] utxo2_3[DATA: Spend 2 XCO from Helen] end subgraph tx3_sig zero_knowledge_proof end tx3 --> tx3_sig tx2 --> sig1[Bob signature for tx1] tx2 --> sig2[Mark signature for tx1] other1[send: to check_sig_contract with some gas] other2[send: to check_sig_contract with some gas] other3[send: to check_private_contract with some gas] xco_utxo[spend: XCO from piggyback server] end l1_parsed_raw_tree_or_even_raw_bytestring --> parsing_contract parsing_contract --> rx0 subgraph tx1_output out1_out[Send: 2.99 XCO to check_sig] info2_1[for Alice ] utxo1_out[DATA: Spend 1 XCO from Bob] utxo2_out[DATA: Spend 2 XCO from Mark] end subgraph tx2_output out1_out2[Send: 2.99 XCO to check_sig] info2_2[for Alice ] utxo1_out2[DATA: Spend 1 XCO from Bob] utxo2_out2[DATA: Spend 2 XCO from Mark] end subgraph tx3_output out1_out3[Send: 2.99 XCO to check_sig] info2_3[for Alice ] utxo1_out3[DATA: Spend 1 XCO from Bob] utxo2_out3[DATA: Spend 2 XCO from Mark] end other1 --> check_sig_contract --> tx1_output --> check_sig_contract3 other2 --> check_sig_contract --> tx2_output --> check_sig_contract3 other3 --> check_private_contract --> tx3_output --> check_sig_contract3 check_sig_contract3[check_sig] --> store[Create claim Alice has 8.7 XCO] %% three --> two %% XXY --> xxx2 ``` ### Problem: When mapping over data, some stragglers might need many steps Solution: Add a `wait` aggregator. `wait[x](y, z)` will wait a maximum x rounds, while y is false, and then return z. Imagine a map over 200 elements, but some take more time Some options: ```yaml result: {{ array_agg(x) }} thread_completed: {{ sum(1) }} Iam_driver: min(row()) = row() _: wait[12](count() = 33) ``` ```python identity[l] check( True # False for not row() === 0 , wait[l]( count() == 200 , array_agg(x) ) ) ``` ### Problem: Aggregators that aggregate over all step results When aggregations happen over all results from all steps, it means we cannot schedule a subset of the transactions, but all have to be scheduled at the same time. A GPU for example, will schedule a pack of pixels at the same time, as wide as the hardware can allow. However, if it required processing the first step of all pixels before going to the next pipeline step, it would be slow. Our aggregators are like something that can aggregate over all pixels on the screen after the first graphics pipeline stage. We need a way to limit the aggregation, and make it statically know what the limit is. This way we can process a subset of the "pixels" and keep the working memory usage reasonably low. #### Idea 1 Let steps be represented by symbols. A step is associated with a smart contract invocation and it is sticks to that invocation and is inherited by any send_message until all "leaf invocations" emit that symbol as a "Step symbol action". A set of step symbols are initially used when a block starts, and then processing proceeds until all active smart contract invocations have emitted their "Step symbol action". A step is "open" until all active smart contracts have emitted their "step symbol action". When a step is open, no aggregation can happen as it would be scheduler-dependent. An aggregation expression specifies which steps it will aggregate over. This should remove the need for `wait` in the aggregation expression, but requires in principle the programmer to specify when an aggregation can begin. The idea is to be able to schedule only code related to a "Step symbol ", and then being able to proceed with aggregations that are only needing those step symbols. Differences and similarities: - This is quite similar to just putting all the code in one big smart contract - However,

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully