Over the last few months, Session contributors have been working on a smart contract which will be used to execute network operations using the new Session Token.
The first public version of this smart contract has been released, and can now be viewed on GitHub. This is the first major milestone on the core side for the transition to Session Token. 🎉
At this stage, the contract has not yet been deployed to any blockchain. With the public release, efforts will now be directed toward third-party audits, and the community is encouraged to review the code to ensure security and robustness.
Splitting the codebase
The migration to Session Token will split the core of our codebase into two distinct parts:
- The C++ codebase: Under Oxen, this used to do everything. It will continue to be responsible for things like tracking service node uptime, calculating rewards, and some other service node duties
- Smart contract system: Consisting of the Session Token contract itself, and a rewards contract that manages nodes joining/leaving the network and paying out rewards.
Role of the smart contract system
These two halves of the codebase will still be connected in some ways. The C++ codebase will observe and track events handled by the smart contract(s):
- Node operators joining the network will call a function on the smart contract accepting their deposited stake
- This broadcasts the details of the node to the network
- Stakers leaving the network will notify the smart contract, triggering the 15 day unlock period
- Stakers claiming rewards they have earnt
The first two items aren't super complicated—the smart contract simply takes the submitted information and checks some minor things (such as whether the correct stake was deposited); and broadcasts a node’s communication details to the network.
On the other hand, reward claiming functionality does use some more interesting technology to make sure the operators are only given rewards they have earned.
Specifically, BLS signatures are utilised, which allows for multiple signatures to be aggregated into a single singature that the smart contract can validate. This way we can make sure a majority (for example, 95%) of the network agrees on the amount before it can be claimed.
The main contract, ServiceNodeRewards.sol, is not a huge file—just 440 lines. But those lines do a huge amount of work, and they will be at the centre of the Session Network going forward.
The code in the smart contract was written with the valued assistance of one of the project’s expert advisors, and has undergone internal reviews. While audits are being arranged, the work on the C++ codebase will continue, with the next step being getting the appchain to record the events happening on the smart contract side of things.
Onwards and upwards.