Zellular Docs
  • Introduction
  • Getting Started
    • The Current Landscape
    • Zellular's Solution
    • Use Cases
      • AVS Task Management
      • AVS Database Replication
    • Core Concepts
    • Performance & Scalability
  • Page
  • Technical Documentation
    • Architecture
    • Protocol
    • SDK
    • Integration
Powered by GitBook
On this page
  • AVSs & Task Management
  • Step 1: Connecting to Zellular
  • Step 2: Posting Tasks to Zellular
  • Step 3: Getting Tasks from Zellular
  • Zellular vs. Blockchain for AVS Task Management
  • Costs and Throughput
  • Decentralization and Security
  1. Getting Started
  2. Use Cases

AVS Task Management

Zellular providing a cost-efficient and high-throughput task manager for EigenLayer AVS

PreviousUse CasesNextAVS Database Replication

Last updated 5 months ago

AVSs & Task Management

Typically, AVS developers use blockchain smart contracts to manage their tasks. However, relying on the blockchain can be expensive and slow.

Zellular, a lightweight consensus-as-a-service AVS, serves as an excellent alternative to blockchain smart contracts for AVS task management. It operates more simply, efficiently, and cost-effectively, boasting a much higher throughput. Any AVS can use Zellular as a decentralized messaging queue to share events among their nodes.

Let’s explore how to update the Incredible Squaring AVS to use Zellular instead of a blockchain for task management.

Step 1: Connecting to Zellular

First, an object needs to be built to connect to Zellular as the task manager. To do that, replace the following code block that connects to the task manager smart contract:

def __load_task_manager(self):
    web3 = Web3(Web3.HTTPProvider(self.config["eth_rpc_url"]))

    service_manager_address = 
        self.clients.avs_registry_writer.service_manager_addr
    with open("abis/IncredibleSquaringServiceManager.json") as f:
        service_manager_abi = f.read()
    service_manager = web3.eth.contract(
        address=service_manager_address, abi=service_manager_abi
    )

    task_manager_address = (
        service_manager.functions.incredibleSquaringTaskManager().call()
    )
    with open("abis/IncredibleSquaringTaskManager.json") as f:
        task_manager_abi = f.read()
    self.task_manager = web3.eth.contract(
        address=task_manager_address, abi=task_manager_abi)

with the following code block that connects to Zellular as the task manager:

def __load_zellular(self):
    operators = zellular.get_operators()
    base_url = random.choice(operators)["socket"]
    app_name = "incredible-squaring"
    self.zellular = zellular.Zellular(app_name, base_url)

Step 2: Posting Tasks to Zellular

The next step is for the task generator to post tasks to Zellular instead of a blockchain. To do so, replace the code block for posting to the blockchain:

def send_new_task(self, i):
    tx = self.task_manager.functions.createNewTask(
        i, 100, nums_to_bytes([0])
    ).build_transaction({
        "from": self.aggregator_address,
        "gas": 2000000,
        "gasPrice": self.web3.to_wei("20", "gwei"),
        "nonce": self.web3.eth.get_transaction_count(
            self.aggregator_address
        ),
        "chainId": self.web3.eth.chain_id,
    })
    signed_tx = self.web3.eth.account.sign_transaction(
        tx, private_key=self.aggregator_ecdsa_private_key
    )
    tx_hash = self.web3.eth.send_raw_transaction(
        signed_tx.rawTransaction
    )
    receipt = self.web3.eth.wait_for_transaction_receipt(tx_hash)
    event = self.task_manager.events.NewTaskCreated().process_log(
                 receipt['logs'][0])

    task_index = event['args']['taskIndex']

with the following code block for posting to Zellular:

def send_new_task(self, i):
    task = {
        "numberToBeSquared": i,
        "quorumNumbers": [0],
        "quorumThresholdPercentage": 100,
    }
    task_index = self.zellular.send([task], blocking=True)

Step 3: Getting Tasks from Zellular

The last step is to update the squaring operators to listen for NewTaskCreated events on Zellular instead of a blockchain. For that, replace the code block for listening to events emitted by the task manager contract:

def start(self):
    logger.info("Starting Operator...")
    event_filter = self.task_manager.events.NewTaskCreated.create_filter(
        fromBlock="latest"
    )
    while True:
        for event in event_filter.get_new_entries():
            logger.info(f"New task created: {event}")
            self.process_task_event(event)

with the code block that listens to Zellular for getting events:

def start(self):
    logger.info("Starting Operator...")
    index = self.zellular.get_last_finalized()["index"]

    for batch, index in self.zellular.batches(after=index):
        events = json.loads(batch)
        for i, event in enumerate(events):
            logger.info(f"New task created: {event}")
            self.process_task_event(event)

Note that what we reviewed above, about using Zellular as the task manager of incredible squaring, is not a complete working solution, but a mere example to demonstrate how an AVS integration with Zellular works out.

Zellular vs. Blockchain for AVS Task Management

Costs and Throughput

The most significant problem with using a blockchain for AVS task management is its high costs. The costs are not limited to posting transactions for emitting events. Reading events from the blockchain through third-party RPC or subgraph service providers incurs higher costs compared to sending the transactions that emit the events. This is especially true since each AVS node must pay these costs separately; having tens of nodes results in the expenses multiplying tens of times!

Costs are not the only problem with using blockchains. AVS services often need high throughput rates that are simply not possible on blockchains. Using Zellular provides far higher throughput while curbing the costs exponentially. But that’s not all!

Decentralization and Security

All nodes in an AVS typically use an RPC or subgraph service run by a third-party provider to access the blockchain. They do not run a blockchain node themselves, which introduces the risk of a single point of failure and reduces the AVS’s security.

In contrast, when events are read from Zellular instead of a blockchain, there is no need to rely on third-party providers. Events can be directly read from Zellular AVS nodes. Additionally, even though events can be received from any random Zellular node, there is always an aggregated signature on all responses, proving that the majority of Zellular nodes have verified the data’s validity. Unlike using blockchain, Zellular removes the need for trust in any individual node to read the events.

When building a decentralised service as an EigenLayer AVS, the first step is to define the tasks that validators will perform. For example, in the popular sample, nodes are responsible for calculating the square of a number provided by a task generator through a .

“Incredible Squaring AVS”
task manager contract