Task assignment in Amara: Prototyping distribution of scarce resources models with blockchain

As explained previously, we have been working on task assignment models for Amara on Demand. Today we wanted to share the final result of our work with this community, the Tasks Allocation Prototype v2.0. This is a new iteration of the prototype that will simplify architecture (therefore maintenance and scalability), integrate multiple models in a unique web app, ease the process of testing new algorithms for task allocation within the community and implement an extended version of the Round Robin. In this post we introduce the architecture of the prototype and detail its features and upgrades, so let’s dive into it!

Technology Stack

The main frameworks and libraries used in this prototype are:

Frontend

–   React.js: this project was bootstrapped with Create React App.

–   Material-UI: for UI components.

–   Web3.js: for web3 interactions.

–   Apollo client: to interact with The Graph network and our backend.

–   GraphQL: as the data transfer layer replacing traditional REST APIs.

Backend

–   The Graph: decentralized service for indexing and post-processing complex events in the blockchain.

Blockchain

–   Ethereum: Blockchain 2.0 network.

–   Solidity: a programming language for developing smart contracts in the Ethereum blockchain.

–   Hardhat: development tools to develop, test and deploy smart contracts.

–   Waffle: testing library for smart contracts.

Overview

The previous version of the prototype used a different architecture, explained in detail in the article Task assignment in Amara. Prototyping Round Robin with blockchain (I). In this new version of the prototype, the architecture has been simplified.

At the frontend level the web app has been extended adding several views:

  • Configuration view: allows the admin to configure a URL that can be shared with the user so that the correct user and model are set for the test.
  • User view: this view employs URL parameters to configure the model used. A new model has been introduced, the round robin + calendar, which lets the user set an availability calendar so the algorithm considers it when assigning new tasks.
  • Admin view: the new admin view lets the admin manage all the models, one at a time, providing a user-friendly interface that simplifies all actions: restarting the prototype and starting and stopping the manager. Several information tables have been added so that the state of the process is easier to track.

At the back-end level, the task manager server has been removed, now the client app (in the admin view) manages the reallocation of tasks using timeouts instead of cron jobs. Therefore, a tab with the admin view has to be opened when the prototype is being used. The main reason for this change is to ease the experimentation process allowing our team to set up the test environment in a few clicks (rather than connecting to a server and running the manager script and other operations that require technical knowledge).

Moreover, Aragon has been removed from the stack. Therefore, the underlying DAO that used to operate the task allocation app has been removed. Now each model consists of an independent smart contract and a subgraph that keeps track of the current state of each instance thus reducing inner complexity to achieve similar results.

Finally, at the blockchain level, the only changes introduced have been the creation of the new model alongside the tests of most features.

Implemented models

As described in the full report of the case study:

“The “first-come, first-served” logic embedded in the platform is the main component of task allocation. This policy creates a competitive dynamic between workers in assigning tasks to themselves. As a result, some linguists find themselves continually checking for work, […]”

This flaw of the platform, identified by the workers in workshops, led us to design and implement alternative models that could embrace the fair distribution of scarce resources. 

First Come First Served

At the start of the research, ‘first come first served’ was the method by which workers received tasks, therefore we have used it as a reference in the different experiments of the research. 

In this model, users have a feed of available tasks. The first user to successfully send a confirmation transaction will have the task assigned. Therefore, there will be many transactions that will resolve as errors when a late request arrives. Once a task has been assigned to the user the feed is hidden and only the selected task is shown.

User page for the first comes first served model
User page for the first comes first served model

Round Robin

The Round Robin algorithm is commonly used in operative systems to fairly distribute the CPU usage between the active processes. In this scenario the scarce resources are tasks and they are distributed to registered translators. This approach improves the task allocation process since all translators will receive a task at some point and they don’t have to compete with their colleagues for tasks, therefore improving economic distribution and workers’ well-being.

In this model, the users have a feed of assigned tasks. Tasks are assigned, for a short period, to one user at a time. During this period the user can ignore, accept or reject the task. If the user ignores the task (let’s say she doesn’t see the task whilst it is assigned to her) the task is assigned to the next user. Only if the rest of the users ignore or reject the task, it could be reassigned to the same user. If the user rejects the task it won’t be assigned to her again. If all users reject the task, it will change its state to rejected in the admin view. If the user accepts the task it is assigned to her and she can start working.

User view for the round robin model, no tasks assigned.
User view for the round robin model, no tasks assigned.
User view for the round robin model, a task has been assigned
User view for the round robin model, a task has been assigned

Round Robin with availability calendar

This model adds an important feature to the previous one to solve a problem detected by workers in the workshops. Due to the different time zones and working routines, translators missed a lot of tasks that were assigned to them while they were not available and a lot of tasks were left waiting for absent users. To solve this issue an availability calendar has been implemented. Now, the users have to set their working hours on a calendar, this availability calendar will be taken into account when the smart contract assigns the tasks. Since users only receive tasks when they are available, they have fewer tasks assigned and therefore higher priority to receive tasks when they are connected than those who have been connected for longer periods.

User view for the round robin with availability calendar model, setting availability.
User view for the round robin with availability calendar model, setting availability.
User view for the round robin with availability calendar model, no tasks assigned.
User view for the round robin with availability calendar model, no tasks assigned.

Conclusions

As can be seen, the prototype has evolved thanks to the community, empowering it with the tools it needs. This is one of the main points learned throughout the process, by using mixed-methods research based on Human-centered design, communities can be empowered by research and tech developer teams. 

Moreover, the use of blockchain to implement task allocation algorithms opens a world of possibilities by adding traceability, immutability, and transparency to the core processes of businesses, allowing platform workers from the collaborative economy to audit algorithms to ensure workers’ rights and fair organizational models. 

In this article we have covered the technical aspects of the implementation, which can be extended in the documentation to be published in the coming days (also the repos; frontend, backend, and smart contracts and documentation, are public and free software licensed) A full report of the case study is available and academic papers are been written so, stay tuned!

AUTHOR

Luis H. Porras

Luis H. Porras

Code Craftsperson

Authorship is by Luis H. Porras, but this content has been made thanks to the whole P2P Models team

Designs are by Elena Martinez

Copy editing by Tabitha Whittall

Samer Hassan and Genoveva López make everything possible

You may also like