How to Create and Deploy a Weight-Adjustment Function

Blockless nodes run this function to determine how credible workers are

What Is a Weight-Adjustment Function?

The weight-adjustment function is used to score workers based on their revealed accuracy. It does this by altering the distribution of confidence other actors have placed in their peers. This update will typically occur by calculating the loss of a worker's inferences and then setting the new weights as a running average of those losses and the current weights.

In this page, we'll create a weight-adjustment function for our running example of building a topic for index levels. Each index level represents the relative performance of NFT collections part of the Yuga Labs brand over time.

How to Create and Deploy a Weight-Adjustment Function

To create a weight-adjustment function for your topic, follow the steps outlined in the tutorial below to create your first function on Blockless:

Blockless Quick Start Guide

Once you have installed the Blockless CLI and created your initial sample function, you must modify it to implement the logic for assigning weights to the inferences made by registered workers on your topic.

You can see the function we used for the Indexes topic as an example once it is open-sourced.

To make tests in your function, you can invoke the function locally using:

bls function invoke

The output of your function needs to follow the same output as the example above, which looks like this:

	"weights": {
		"upt16ar7k93c6razqcuvxdauzdlaz352sfjp2rpj30": "0.3176470588235294",
		"upt16ar7k93c6razqcuvxdauzdlaz352sfjp2rpj31": "0.47647058823529417",
		"upt16ar7k93c6razqcuvxdauzdlaz352sfjp2rpj32": "0.029411764705882357"

Note that the keys of the weights property are cosmos addresses of workers, and the values are the new weight values to be set.

After testing now, you can deploy your function using the following:

bls function deploy

After testing and deploying your function, save the function_id and the method (the name of the Wasm file) to use when creating your topic.