[HyperSDK Build Journal]

Next up: Swaps on the TokenVM

To start, I'm just going to allow people to:
1) Create resting orders (with a fixed quantity and price)
2) Interact with resting orders (purchase some/all of the fixed quantity at a set price)
3) Cancel resting orders… twitter.com/i/web/status/1…
At @luigidemeo's suggestion, going to start tagging these with #HyperSDKJournal to make them more searchable. 🙏
Finding that I'm frequently in need of a unique ID to name things that my Actions create (like an OrderID).

There isn't a great way to do this with the current interface because Actions need to provide all StateKeys they'll touch before execution. This means we can't just use… twitter.com/i/web/status/1…
This change looks like:
Create Order is done...now working on Close Order.

Then, I'll add support for actually filling one of these resting orders.

After all that, I'll add a number of fun integration tests that should make it clear how to interact with the TokenVM.

#HyperSDKJournal
Close Order is now complete 👀: github.com/ava-labs/hyper…

You can see that most of the work of adding an Action to an existing HyperVM is to:
1) Define the on-chain representation
2) Add any missing "Storage" functions (in this case, I needed to add the ability to read orders from… twitter.com/i/web/status/1…
Added Fill Order (untested): github.com/ava-labs/hyper…

To make the output of a fill more useful, I also added a custom result marshaller that contains the result (how much you got vs how much you expected to get).

This is the first Action that uses the conditional fee logic as… twitter.com/i/web/status/1…
Added a cool in-memory order book using the Uint64Heap I wrote for the mempool: github.com/ava-labs/hyper…

This will allow the TokenVM RPC to serve an "Open Orders" endpoint (that we will test in the integration tests).

#HyperSDKJournal
We now update the in-memory order book whenever a block is accepted 🚀

Next up: testing + RPC support
Went down the numerical precision rabbit hole for WAY too long working on overfill refunds (if you attempt to purchase more than the remaining units left on a order).

It is critical to support this flow as someone else may trade at the same time as you (so the order you thought… twitter.com/i/web/status/1…
After making this change, I was able to finish all the code and tests for the "TokenVM"!

Now, I just need to add a README and it will be good to merge: github.com/ava-labs/hyper…

Implementing all Actions took 600 lines and implementing Auth only took 108 lines! You can view the… twitter.com/i/web/status/1…
If you want to check out how to mint assets and fill orders, check out the integration tests: github.com/ava-labs/hyper…

(make sure to take a look at how the integration tests make use of the in-memory order book)

#HyperSDKJournal

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Patrick “The Faucet” O'Grady 🔺

Patrick “The Faucet” O'Grady 🔺 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @_patrickogrady

Feb 23
Took ~24 hours to implement a new blockchain on top of the #Avalanche HyperSDK that allows anyone to mint, transfer, and trade user-created tokens...all on-chain.

Cleaning up the README now and expect to merge it in the morning: github.com/ava-labs/hyper…

#HyperSDKJournal
To make the trading UX more accessible, the "TokenVM" includes an in-memory order book to track all open offers on-chain (which it then serves over RPC).

Best of all? It only took a couple hundred lines of code for Actions, Auth, and Storage (other packages are boilerplate).
Core Packages:

Actions: 600 lines of code
Auth: 108 lines of code
Storage: 322 lines of code

The remainder is boilerplate stuff I need to abstract better/wrap in functions so I don't need to re-implement 😅.
Read 11 tweets
Feb 22
Token-Optimized #Avalanche HyperVM (mint and swap fungible/non-fungible tokens) work is now underway: github.com/ava-labs/hyper…

This runtime will have a simpler storage model than the IndexVM, so I expect it to be a bit more performant all else equal (no modification to HyperSDK).
1/ This TokenVM all-around should be a simpler starting point than the IndexVM for most devs.

It'll also serve as an embedded integration/e2e/load test within the HyperSDK (so I don't need to trigger the IndexVM CI to test any major changes upstream).
2/ Once the TokenVM is merged, I plan on using it as a testbed to integrate #Avalanche Warp Messaging support into the HyperSDK (which will be my next task after merging this PR).
Read 9 tweets
Feb 21
🛠️ 🛠️ #Avalanche Banff 9 is out: github.com/ava-labs/avala… 🛠️ 🛠️

This version (v1.9.9) is backwards compatible to v1.9.0. It is optional but recommended.

🔍 Release Focus: go-plugin Removal + C-Chain State Sync Default + EVM JS Tracer Re-Enabled ImageImage
1/ 🚧 Compatibility Check: VM Interface (v23) 🚧

Banff 9 modifies the VM interface to remove AvalancheGo's dependency on go-plugin (github.com/hashicorp/go-p…) for orchestrating Custom VMs.

If you are running a Custom VM, you must update it to run it with AvalancheGo@v1.9.9.
2/ The removal of go-plugin means AvalancheGo now exclusively manages VM orchestration on the host. This changes nothing for most VM developers, however, it was the last blocker preventing us from adding support for multi-host AvalancheGo configurations: Image
Read 10 tweets
Feb 21
HyperSDK: Opinionated Framework for Building Hyper-Scalable Blockchains on Avalanche

github.com/ava-labs/hyper…

(otherwise known as the secret project I've been developing over the past 6 months at @avalabsofficial) Image
1/ First off...why Hyper?

Our SDK development philosophy is **performance above all else**.

If the SDKs we build don't reach hyper-scale (10-100k+ TPS), it won't matter how easy they are to use or how quick you can launch.

Using "Hyper" is a daily reminder of the north star.
2/ We enable anyone to achieve this hyper-scale by employing Avalanche-optimized data structures and algorithms behind a strict but sufficiently generic set of mechanisms (hence the "opinionated") that can be used to implement user-defined functionality.
Read 33 tweets
Feb 1
🛠️ 🛠️ #Avalanche Banff 8 is out: github.com/ava-labs/avala… 🛠️ 🛠️

This version (v1.9.8) is backwards compatible to v1.9.0. It is optional but recommended.

🔍 Release Focus: PROXY Protocol v1/v2 Support + Optimized P-Chain Validator Lookup + P2P Network Client Helper
1/ ✅ Compatibility Check: VM Interface (v22) ✅

Banff 8 does not modify the VM interface. If you are running a Custom VM, you don't need to update it to run it with AvalancheGo@v1.9.8 if you are already running AvalancheGo@v1.9.7.
2/ PROXY Protocol v1/v2 Support

AvalancheGo now supports P2P traffic proxied via the PROXY Protocol (haproxy.org/download/1.8/d…).

This means that validators can now implement custom networking logic on the edge to shield their node from specific inbound connections or traffic. 🛡️
Read 10 tweets
Jan 11
🛠️ 🛠️ #Avalanche Banff 7 is out: github.com/ava-labs/avala… 🛠️ 🛠️

This version (v1.9.7) is backwards compatible to v1.9.0. It is optional but recommended.

🔍 Release Focus: Dynamic State Syncing Support + Improved Chit Handling + NAT-PMP Fixes
1/ 🚧 VM Interface Update (v21 -> v22) 🚧

To support Dynamic State Syncing, we had to make some small tweaks to the VM interface. If you are running a Custom VM, you'll need to update to VM@v22.

Here is the subnet-evm release: github.com/ava-labs/subne…
2/ 🚧 Breaking Config Changes 🚧

If you run a node, make sure to checkout the config changes in Banff 7 (ESPECIALLY "--PLUGIN-DIR"):
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(