Last Or Popular Autonomous Agent Version Available

Hey_Monkey
Autonomous Agents powered by Obyte
4 min readOct 10, 2019

The scripts of Autonomous Agents (AA) are set in stone, once stored in the Obyte DAG, they are there forever and this is what we like with AA. But, updates can be nice too…

Note: This tutorial assumes that you are waiting the 3 to 5 minutes for transactions confirmation between each steps.

With LOPAAVA (Last Or Popular Autonomous Agent Version Available) you can register your AA.

First utility is to make your AA known from others.

Register your AA

I have an AA that I like to call ‘HOLLAA’, its address on the DAG is :

RIWHUVJMQA5DJHK3AOUK5ZBPFFYW5I3J4

I can register it in LOPAAVAby setting ‘register’ to the name chosen and ‘address’ to the AA address:

Capture of the ‘send’ tab of the GUI wallet

Will appear in the state of LOPAAVAin the DAG:

Capture of the AA address properties in the DAG explorer

The provided address has been defined as the version 1 of the given AA name. Now, are publicly visible: the AA address, its registration date, the number of ‘dislikes’ and ‘likes’ it received, the address of the last voter, the number of the last version available (version 1 is the only version for the moment) and the number of the most popular version (version 1 as well). The owner is also stored to avoid anyone to add fake new version using the same name.

Vote for AA version

Now we hope that someone willing to help or in need of this HOLLAA will review the code and vote with a ‘like’ if nothing problematic is detected.

This nice guy will then use:

‘like’ = ‘HOLLAA’

and will be prompt to add the version number:

A user that is not confident in code review can now feel safer to use the address of the version 1 as it has 1 ‘like’ and no ‘dislike’.

Another AA can use the reviewed version 1 by accessing the state of LOPAAVAlike this:

$HOLLAA_address = var[$LOPAAVA_address]['HOLLAA_1_address'];

The advantage compare to use directly the address like this:

$HOLLAA_address = 'RIWHUVJMQA5DJHK3AOUK5ZBPFFYW5I3J4';

Is to show to the primary AA reviewer that the secondary AA has been reviewed and to link him directly to its score in LOPAAVA.

The voters are added in a secondary AA list to forbid them to vote twice. They cannot use several different addresses as you need to be attested to vote (real name attestation i.e).

Update your AA

Now, comes the day when HOLLAA needs an update from its creator.

The creator will register the address of the new version the same way he did the first time:

And the state of LOPAAVAwill become:

The last version number has been update.

The most popular is still the version 1. Because its difference ‘likes’ - ‘dislike’ is bigger than for the version 2. The new version will need 2 ‘likes’ to become the most popular (if the version 1 does not get ‘dislikes’).

Select version to use

Now the developer of a primary AA that needs HOLLAA as secondary AA has several choices:

  • He can force the use of the version that he has personally reviewed :
$HOLLAA_addr = var[$LOPAAVA_addr]['HOLLAA_1_address'];
  • He can decide to always use the last version available without having to deploy a new version of its primary AA:
$l_version = var[$LOPAAVA_addr]['HOLLAA_last_version_number'];
$HOLLAA_addr = var[$LOPAAVA_addr]['HOLLAA_'||$l_version||'_addr];
  • Or to use the most popular version:
$p_version = var[$LOPAAVA_address]['HOLLAA_popular_version_number'];
$HOLLAA_addr = var[$LOPAAVA_addr]['HOLLAA_'||$p_version||'_address];

Of course, LOPAAVAis not to be used with sensitive AA when security is important, because it can change the behavior of the primary AA if the Secondary one change drastically.

Using the last version can be done with no safety issue for the developer if he is the creator of both the primary and secondary AA. If not he must be aware that his primary AA could act differently in the future).

Depending on the security level needed, the developer could also put conditions on the selection of the version:

// last version
$v_num = var[$LOPAAVA_addr]['HOLLAA_last_version_number'];
$l_version = 'HOLLAA_'||$v_num;
$l_addr = var[$LOPAAVA_addr][$l_version||'_address];
$likes = var[$LOPAAVA_addr][$l_version||'_likes];
$dislikes = var[$LOPAAVA_addr][$l_version||'_dislikes];
// popular version
$p_version = var[$LOPAAVA_addr]['HOLLAA_popular_version_number'];
$p_addr = var[$LOPAAVA_addr]['HOLLAA_'||$p_version||'_address];
// version selection
$HOLLAA_addr = ($dislikes = 0 and $likes > 4) ?
$l_addr : $p_addr;

Be careful

In summary, be careful with LOPAAVAuse as it can annihilate the most important AA property: immutability.

But still, enjoy AA coding.

--

--