Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More useful ideas #464

Open
Keith-CY opened this issue Sep 7, 2023 · 3 comments
Open

More useful ideas #464

Keith-CY opened this issue Sep 7, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Keith-CY
Copy link
Member

Keith-CY commented Sep 7, 2023

I've got these thoughts during reading https://mirror.xyz/vanishk.eth/MTwltQDrHZenEPaFB9YsnScHVREmA3EWfLW-r9VguXs

It's just a TODOs now, and I will enrich each one ASAP.


What we have, but can be better

  • State synchronization
  • Message relaying
  • General purpose indexer
  • Plugin system
  • Expressive query language

What we can add

  • Development Dashboard: I've used similar functions in Elixir, https://github.com/phoenixframework/phoenix_live_dashboard, it's useful to locate performance bottlenecks and debug on production/development environments.
  • Hot reloading: Enable hot-reloading in development mode, as https://docs.nestjs.com/recipes/hot-reload
  • Type generation
  • Built-in account abstraction: as discussed in wallet-connect protocol, there are two types of account, 1 from the perspective of a wallet, and 1 from the perspective from a dapp. For project built by kuai, we may consider supporting account from dapp perspective natively. The key point is how to map a bundle of addresses to an account in the backend natively.
  • Local tx simulation: Dump the state and run tx sequentially to rehearse the actions on-chain
@Keith-CY Keith-CY added the documentation Improvements or additions to documentation label Sep 7, 2023
@Keith-CY Keith-CY self-assigned this Sep 7, 2023
@Keith-CY
Copy link
Member Author

Extension for built-in account abstract:

Built-in account abstraction: as discussed in wallet-connect protocol, there are two types of account, 1 from the perspective of a wallet, and 1 from the perspective from a dapp. For project built by kuai, we may consider supporting account from dapp perspective natively. The key point is how to map a bundle of addresses to an account in the backend natively.

Here's a concrete implementation

Sync account between frontend and backend

sequenceDiagram
    participant Frontend
	participant Backend
    Frontend ->> Backend: sync_account(10 addresses)
    Backend ->> Backend: store 10 addresses to account_id
    Backend ->> Frontend: account_id
    Frontend ->> Backend: get_balance(account_id, latest_address_in_frontend)
    Backend ->> Backend: compare_latest_addresses(latest_address_in_frontend, latest_address_in_backend)
    alt is false
    Backend ->> Frontend: account_info_out_of_date(latest_address_in_backend)
    Frontend ->> Backend: sync_account(addresses_diff_between_frontend_and_backend)
    Frontend ->> Backend: get_balance(account_id, latest_address_in_frontend)
    end
    Backend ->> Frontend: balance_of_address_from_address_0_to_latest_address    
Loading

The latest_address_in_frontend works as a session token that will be verified in backend with latest_address_in_backend, and time the session token out if latest_addresses in frontend and backend don't match.

@Keith-CY
Copy link
Member Author

Keith-CY commented Oct 25, 2023

There's another strategy to calibrate the address set without binding to an account.

sequenceDiagram
    participant Frontend
	participant Backend
    loop
    Frontend ->> Frontend: H = Hash(Address set)
    Frontend ->> Backend: get_balance(H)
    Backend ->> Frontend: H is not found
    Frontend ->> Backend: subscribe_address_set(address set)
    Backend ->> Backend: H = Hash(Address set)
    Frontend ->> Backend: get_balance(H)
    Backend ->> Frontend: balance of address set H
    Frontend ->> Frontend: address set grows to address set'
    Frontend ->> Frontend: H' = Hash(Address set')
    end
Loading

By this idea, account id can be avoided and epherel address set will be registered in backend with its hash

@Keith-CY
Copy link
Member Author

Keith-CY commented Nov 1, 2023

There's another strategy to calibrate the address set without binding to an account.

sequenceDiagram
    participant Frontend
	participant Backend
    loop
    Frontend ->> Frontend: H = Hash(Address set)
    Frontend ->> Backend: get_balance(H)
    Backend ->> Frontend: H is not found
    Frontend ->> Backend: subscribe_address_set(address set)
    Backend ->> Backend: H = Hash(Address set)
    Frontend ->> Backend: get_balance(H)
    Backend ->> Frontend: balance of address set H
    Frontend ->> Frontend: address set grows to address set'
    Frontend ->> Frontend: H' = Hash(Address set')
    end
Loading

By this idea, account id can be avoided and epherel address set will be registered in backend with its hash

Solution confirmed, technical details available at #554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant