arc | title | authors | discussion | topic | status | created |
---|---|---|---|---|---|---|
0039 |
Signal records, and their necessity |
Robert Horvath rob@nyar.eu |
Application |
Draft |
01/15/2024 |
Aleo blockchain is both programmable and encrypted, positioning itself as a unique platform in the increasingly crowded DeFi market. With the current market saturation, gaining traction in this space is becoming more challenging. To stand out and attract significant players from traditional financial institutions, Aleo must introduce scalability as well to its DeFi applications. This proposal aims to unlock this potential by introducing a new type of record: signal records.
Signal records are designed to provide publicly readable information while ensuring that creation and consumption are restricted to a single entity. This feature is crucial for enabling scalable, secure, and efficient operations on Aleo's platform, making it more attractive to large financial institutions.
Key Benefits of Signal Records:
- Scalability: Signal records enable high-performance management of smart contract states, ensuring that Aleo's platform can handle large-scale operations efficiently.
- Flexibility: Developers can utilize signal records for a variety of applications, including the announcement of UTC time - a necessity for DeFi, authorization, and dynamic system settings.
- Security: The design of signal records enhances privacy and ensures that sensitive data remains protected.
- Resource Efficiency: By allowing for more efficient use of Aleo's resources, signal records reduce operational costs for both users and validator operators.
This new feature has several applications, including but not limited to:
- Scalable smart contract state (both private and public)
Smart contract can create and recreate one or several signal record(s) of smart contract state. These can be used in any transition by anyone. Once the settings are updated, only the updated settings will be applicable to the next transition. - Provide UTC time
A signal record of the current UTC time can be consumed and recreated by a node everyx
minutes and read by anyone as a trusted time signal record. For DeFi apps a reliable UTC time source is a must. - Authorization
- User can be authorized to use some transitions by the Administrator. This can be done by the Administrator creating an Authorization record with the user's address in the public field. User can use this record (eventhough it is not owned by him) to access any desired transition.
- Signal records can also be used to authorize programs (by their addresses) to use any desired transitions by issuing Authorization records. Thus making the system more modular, secure, and upgradeable.
- Enable or disable transitions
The existence of a signal record can prove a transition is enabled or disabled. The Administrator can issue the signal record. - Provide token prices
A signal records public field can be the price provided by some Oracle for a token. The signal record can be updated by Oracle and read by anyone.
Signal records have two features setting them apart from current legacy records:
- Accessible public fields: Signal records' public fields can be read by any signer in a transition regardless who owns those signal records.
- Public serial numbers: Signal records' serial number is publicly visible, allowing anyone to determine whether the record has been consumed or not.
To display the difference between the current and proposed transition logic, we will use the following example of current and proposed transition logic.
Figure 1: Current Transition Logic
In Figure 1 User1 is the transition signer.
As Figure 1 shows the current transition logic:
- If the transition contains only records owned by the signer, the transition is executed.
- If any of the input records are not owned by the signer, then the transition is rejected. Even if the record has public fields that otherwise are accessible.
Figure 2: Proposed Transition Logic
In Figure 2 user 1 is the transition signer. As Figure 2 shows, the proposed transition logic is:
- If the transition contains only records owned by the signer, then the transition is executed. As is the case with the current logic.
- If the input of the transition is a mix of records owned by the signer and not owned by the signer, then:
- All the public fields of the signer's records are accessible in the transition. As in current logic.
- All the private fields of the signer's records are accessible in the transition. As in current logic.
- All the public fields of the signal record not owned by the signer are accessible in the transition.
DIFFERENT from current logic! - Accessing any private fields of the signal record that are not owned by the signer will result in an error.
- No access to fields of a signal record not owned by the signer must be allowed.
DIFFERENT from current logic!
This is needed for allowing the execution of certain transitions. The very existence of the signal record is the proof of the transition being enabled. The transition must fail if the expected record is missing.
Figure 3: Authorization process
Authorization can be executed in the following way:
- The Administrator (contract) creates an authorization record with the authorized address in the public field.
- The authorized address can access the transition using the authorization record created in (1.) and any other record can be used here that are owned by the authorized user.
- Unauthorized user can not access the transition, as there is no record that would authorize this user.
Figure 4: System Wide Settings Record
System wide settings can be created in the following way:
- Administrator (contract) creates a record with the system wide settings in the public field.
- Any transition can access the system wide settings by reading the public field of the system settings record. (User 1 can use it).
- Any transition can access the system wide settings by reading the public field of the systems settings record. (User 2 can use it as well).
- System wide settings can be changed by administrator (contract) by consuming the record and creating another one.
In their public field, time records contain the current UTC time available to all users and contracts. This is an effective mechanism because the block.height
representation is supported only in the finalize()
functions currently. If trusted time is available for UTXO logic, we can have a scalable time representation.
Time records can be created in the same way as the system-wide settings record. The only difference is that the record can be consumed and recreated by the administrator every x
minute/block. The record can be used by any transition to get the current UTC/local time. As time record can only be updated by a trusted party many can read it and use it in transitions in other contracts as well.
Figure 5: Provide trusted time as record
There are two ways to implement it:
- Administrator (contract) creates a record with the current time in the public field, but the administrator is the owner of the record. This way, administrators must provide off-chain access to the record to other contracts, because they can not access the record directly.
- Administrator (contract) creates a record with the current time in the public field, but the record is owned by a policy account whose private key is known by everyone. This way all users can access the record directly by searching for it on the blockchain.
The public field of price records works exactly the same way as time records, since only price is substituted for time.
- All records are by defaut of type legacy - itis the current records.
- Records can be defined as signal records by setting the reserved field of
record_type: 1
. This way allowing for future record types. - Users are free to explicitely define a record as legacy by issuing
record_type: 0
. - All the public fields of the signal record not owned by the signer must still be accessible from within the transition.
- No access to any fields of a signal record not owned by the signer must be allowed. Thus only the existence of the signal record is checked - if user can not provide one, the transaction must be rejected.
- All other operations of signal records are the same as of legacy record types.
To make the above possible with current system we need to find a workaround. We have failed to do so, though it is possible that we have missed something.
The records we want to create must have the following properties:
- Create by one - They must be created by one single authority (voting contract, administrator contract, single administrator). And their consumption must be controlled by the same entity.
- Read by all - None, some or all of the fields of the record must be publicly readable.
- Where none of the fields of the record are readable, the presence of the record means authorization was given to use a transition.
- Where some or all the fields of the records are publicly readable, the record can be used to store data that is readable by all transitions.
- Revoke by one - The record can be consumed at any time by the authority. If there was a copy of the record with the same credentials, they must be revoked as well. This means that the availability of the records and their public fields are controlled by the authority.
In any workaround attempt the above three points must hold.
Figure 6: Attempting Workarounds
Figure 6 displays the two basic workaround classes. It displays the simplest cases: there is a Time Record
that must be readable by all, and a Record 2
that is the input to a transition. User 1 executes the transition. There are two strategies to unify the owners of two different records:
- Change the owner of the
Record2
of User to policy address. - Change the owner of the
Time Record
to user's address.
This workaround attempts to unify record owners is done by changing the owner of the Users record to Policy Address Figure 6/1:
- Administrator updates time and assigns policy address to
owner
.
1a. Change the owner of theRecord 2
of User to policy address.
1b. Executetransition_using_trusted_time()
using theTime Record
andRecord 2
. The problem with this method is that even the private fields ofRecord 2
are accessible by anyone as Policy Address is the owner of the record. This is unacceptable in most cases. There is nothing to be done about that. Unfortunately all the arguments oftransition_using_trusted_time()
will be accessible by anyone as well, as the policy address is the signer of the transition.
This workaround attempt is done by changing the Time Record
owner to Policy Address Figure 6/2:
2. Administrator updates time and assigns policy address to owner
.
2a. Change the time record owner to the User's address.
2b. Execute transition_using_trusted_time()
using the 2a Time Record
and Record 2
.
2c. Administrator updates time.
The problem with this method is that: Time Record
resulting from (2c.) is different from the Time Record
resulting from 2a.
- There is no guarantee that the user will not use
Time Record
from 2a later than whenTime Record
is already updated. This can not be prevented. - Theoretically in (2a.) the
Record 2
could be also added as argument ofchange_owner_of_time_record()
and only allowTime Record
to be consumed withRecord 2
. But there are two issues with this solution:- Currently, it cannot be guaranteed that User will use the
Time Record
from (2a.) beforeTime Record
is updated. - If both
Time Record
andRecord 2
use the same policy address,Record 2
's private fields will be accessible by anyone. This is unacceptable in most cases.
- Currently, it cannot be guaranteed that User will use the
There is no test cases for this ARC.
Any complex protocol that wants to apply:
- Complex authorization logic.
- System wide settings.
- Trusted time over the record logic without using
finalize()
. - Trusted price over the record logic without using
finalize()
. - Expandable and upgradable system.
This ARC is backwards compatible with the current system. It does not change the current logic in any way. It only adds a new feature to the system.
This ARC provides additional security features to Aleo's record logic. It does not introduce any new security risks.
No references provided.