Updating name pointers from Sophia language

This work happened at the beginning of September.
Reporting about it was postponed until the PR is merged.
Since we need to merge it after hardfork, for visibility, the endeavor is summarized below to avoid any further delays.

The PR 2781 adds ability to use AE Naming System update functionality from Sophia language.

We also need changes to bytecode (PR 81) and Sophia compiler (PR 155) .

AENS update transaction allows end user to set up a pointer, identified by a key, which can resolve to 4 different kinds of identifiers: account, oracle, channel or contract.

Until now, Sophia didn’t have the ability to invoke AENS.update, since it required introduction of a new type built-in to the Sophia language.

All values - account, oracle and contract - represent an address identifying a specific object in their respective state trees.

While in untyped language it would be easy to represent all types as byte arrays of length 32 bytes, such implementation would not pass the typechecker in Sophia.

The PR implements necessary support for AENS update functionality via:

1.) introducing a new type - pointee

It could be expressed as:

type pointee =
| Account(address)
| Oracle(address)
| Contract(address)

This type exists on the Sophia language level only, and as such isn’t defined in Sophia standard library.

It allows us to invoke the update function from AENS namespace:

stateful entrypoint update(owner      : address,
                           name       : string,
                           ttl        : option(Chain.ttl),
                           client_ttl : option(Chain.ttl),
                           pointers   : option(map(string, AENS.pointee))) : unit =
  AENS.update(owner, name, ttl, client_ttl, pointers)

2.) implementing supporting aens_update functionality for new FATE VM

This support doesn’t exist in legacy AEVM, so to use AENS.update we need to run Aeternity node which uses FATE VM as default (from 5.0.0 higher, but this PR in particular will land in master later)

Note that there is a slight difference between capabilities of AENS update transaction and AENS.update for Sophia.

The transaction allows user to point to a state channel, but the introduced AENS.pointee doesn’t support it, as pointing to a channel doesn’t seem to have much utility in practice.


could you also provide the ability to ask for the TTL of a certain name? this is currently not possible, right?

Hi @marc0olo,

if you do GET on names/<name-of-interest> you should get back JSON which has ttl key in it.

It’s GetNameEntryByName operation where the JSON value returns NameEntry .

yeah I know that this is possible through the node API. I thought about having this available as built-in function in sophia.

but the more I think about it I am not sure whether is makes sense and whether there would be a use case for it