Scroll Integration

Note: We are in the Alpha Testnet stage, so the API may undergo incompatible changes in the future. If you encounter any issues, please join our Discord to get in touch with the Nubit Team.


Overview

The existing integration sends txData of each block to the Nubit DA backend for data retrieval.

Soon, the coordinator will send execution traces and txData to Nubit DA, and the returned DA proof (including the existence proof and indexes) will be transmitted to rollup nodes and L1 contracts. This will allow users with light storage and computation resources to retrieve data from Nubit DA and verify the returned DA proofs using on-chain public inputs.

Rollup from Scroll

Scroll offers scalability for Ethereum with strong security guarantees. Its technical novelty includes efficient, trustless, and secure rollups from zero-knowledge proofs, providing easier access, faster response, and the support of more users.

In a nutshell, the Scroll rollup scheme aggregates transactions (and execution results) with succinct zero-knowledge proofs. The proof tasks are dispensed by the coordinator and are executed by provers in a trustless manner. The verification logic and proofs are stored in Ethereum smart contracts. Hence, data integrity and unforgeability are guaranteed by Ethereum with an extremely low overhead.

As a further enhancement, our integration aims to provide the data availability (DA) backend for Scroll.

Integration with Nubit DA

Current Integration

Our current integration, based on l2geth-source codes, facilitates the seamless interaction between Scroll execution nodes and the Nubit DA backend. Serialized and batched transaction data is transmitted to the backend, where it is stored and indexed via nubit-node. This integration enhances block synchronizations and consensus executions by leveraging the Nubit DA storage. Additionally, it ensures historical block data synchronization to Nubit DA and sends data of newly generated blocks for each confirmation, enhancing overall data availability and security.

For example, the SubmitBlobToNubit function aggregates transactions and submits them to the Nubit DA backend:

func (bc *BlockChain) SubmitBlobToNubit(block *types.Block) error {
	txs := [][]byte{}
	for i := 0; i < block.Transactions().Len(); i++ {
		var buf bytes.Buffer
		block.Transactions().EncodeIndex(i, &buf)
		txs = append(txs, buf.Bytes())
	}
	txs1, err := MarshalBatchData(txs)
	if err != nil {
		log.Error("πŸ†    NubitDABackend.MarshalBatchData:%s", err)
		return err
	}
	nsp, err := share.NewBlobNamespaceV0([]byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0x10})
	if nil != err {
		log.Error("πŸ†    NubitDABackend.NamespaceFromBytes:%s", "err", err)
		return err
	}
	body, err := nodeBlob.NewBlobV0(nsp, txs1)
	if nil != err {
		log.Error("πŸ†    NubitDABackend.NewBlobV0:%s", "err", err)
		return err
	}
	blockNumber, err := bc.nubit.Blob.Submit(context.TODO(), []*nodeBlob.Blob{body}, 0.01)
	if err != nil {
		log.Error("πŸ†    NubitDABackend.Submit ", "err", err, "height", blockNumber)
		return err
	}
	log.Info("πŸ†    NubitDABackend.Submit", "height", blockNumber)
	return nil
}

Future Integration Enhancements

In the next phase, we aim to further streamline the integration process. Coordinators will facilitate synchronization with the Nubit DA through adaptations like Batch.InsertBatch(). Transaction data will be batched, encoded, and sent to Nubit DA as blobTxs, with corresponding DA height, commitment, and auxiliary information returned to coordinators and then delivered to rollup nodes. This approach not only optimizes data retrieval but also ensures robust data availability.

Here’s how the SubmitBlobToNubit function might look in the next phase:

func (bc *BlockChain) SubmitBlobToNubit(block *types.Block) error {
	txs := [][]byte{}
	for i := 0; i < block.Transactions().Len(); i++ {
		var buf bytes.Buffer
		block.Transactions().EncodeIndex(i, &buf)
		txs = append(txs, buf.Bytes())
	}
	txs1, err := MarshalBatchData(txs)
	if err != nil {
		log.Error("πŸ†    NubitDABackend.MarshalBatchData:%s", err)
		return err
	}
	nsp, err := share.NewBlobNamespaceV0(createNamespaceID())
	if nil != err {
		log.Error("πŸ†    NubitDABackend.NamespaceFromBytes:%s", "err", err)
		return err
	}
	body, err := nodeBlob.NewBlobV0(nsp, txs1)
	if nil != err {
		log.Error("πŸ†    NubitDABackend.NewBlobV0:%s", "err", err)
		return err
	}
	blockNumber, err := bc.nubit.Blob.Submit(context.TODO(), []*nodeBlob.Blob{body}, 0.01)
	if err != nil {
		log.Error("πŸ†    NubitDABackend.Submit ", "err", err, "height", blockNumber)
		return err
	}
	log.Info("πŸ†    NubitDABackend.Submit", "height", blockNumber)
	return nil
}

Future Outlook

Looking ahead, our integration envisions a significant role for local storage on Scroll nodes. With the support of our DA backend, nodes will only need to store recently generated blocks locally, while historical block data will be seamlessly retrieved from the DA backend. This approach minimizes storage requirements, enhances security, and ensures data availability, providing a solid foundation for future scalability.


Run the Integration Demo

Configuration

Start a Nubit Node

Refer to the Nubit DA guideline for detailed instructions. Please contact the Nubit team to obtain enough NUB tokens. Remember to store the private key file of your Nubit address securely in your $HOME/.nubit-node directory.

Clone the Repository

Clone the integration demo repository to your local machine. Please contact Nubit team for the repo access.

cd $HOME
git clone https://github.com/RiemaLabs/nubit-scroll-integration-demo
cd nubit-scroll-integration-demo

Install the GCC Compiler

Install the required GCC compiler.

sudo apt install build-essential

Build l2geth

Build the l2geth binary.

make nccc_geth

Define a Command Alias

Create a convenient alias for the l2geth binary.

alias l2geth=./build/bin/geth

This configuration will prepare your environment for running the Nubit integration demo.

Run the Integration Demo

Start the l2geth Process

Run the l2geth process with the following command.

l2geth --scroll \
    --datadir "./l2geth-datadir" \
    --gcmode archive --cache.noprefetch \
    --http --http.addr "0.0.0.0" --http.port 8545 --http.api "eth,net,web3,debug,scroll" \
    --l1.endpoint "$L2GETH_L1_ENDPOINT" --rollup.verify

Check Logs

After a short while, you should see logs indicating successful submissions, similar to the following:

INFO [05-17|16:09:26.012] πŸ†    NubitDABackend.Submit               height=369
INFO [05-17|16:09:26.012] Imported new chain segment               blocks=1 txs=1 mgas=0.873 elapsed=3.194s mgasps=0.273 number=14 hash=692c4c..ea2054 age=7mo1w3d dirty=0.00B
INFO [05-17|16:09:37.506] πŸ†    NubitDABackend.Submit               height=370
INFO [05-17|16:09:37.506] Imported new chain segment               blocks=1 txs=1 mgas=0.021 elapsed=11.476s mgasps=0.002 number=15 hash=ca1780..fad6ca age=7mo1w3d dirty=0.00B
INFO [05-17|16:09:48.971] πŸ†    NubitDABackend.Submit               height=371
INFO [05-17|16:09:48.971] Imported new chain segment               blocks=1 txs=1 mgas=0.068 elapsed=11.464s mgasps=0.006 number=16 hash=2950bb..3d78f5 age=7mo1w3d dirty=0.00B
INFO [05-17|16:10:02.412] πŸ†    NubitDABackend.Submit               height=372
INFO [05-17|16:10:02.412] Imported new chain segment               blocks=1 txs=1 mgas=5.318 elapsed=13.441s mgasps=0.396 number=17 hash=e611fc..c33f0e age=7mo1w3d dirty=0.00B
INFO [05-17|16:10:13.863] πŸ†    NubitDABackend.Submit               height=373
INFO [05-17|16:10:13.863] Imported new chain segment               blocks=1 txs=1 mgas=0.052 elapsed=11.450s mgasps=0.005 number=18 hash=494b7d..134c7b age=7mo1w3d dirty=0.00B
INFO [05-17|16:10:25.331] πŸ†    NubitDABackend.Submit               height=374
INFO [05-17|16:10:25.332] Imported new chain segment               blocks=1 txs=1 mgas=0.035 elapsed=11.468s mgasps=0.003 number=19 hash=0d7e31..bf13af age=7mo1w3d dirty=0.00B
INFO [05-17|16:10:36.759] πŸ†    NubitDABackend.Submit               height=375
INFO [05-17|16:10:36.759] Imported new chain segment               blocks=1 txs=1 mgas=0.035 elapsed=11.427s mgasps=0.003 number=20 hash=488996..cb8363 age=7mo1w3d dirty=0.00B
INFO [05-17|16:10:48.197] πŸ†    NubitDABackend.Submit               height=376
INFO [05-17|16:10:48.197] Imported new chain segment               blocks=1 txs=1 mgas=0.035 elapsed=11.438s mgasps=0.003 number=21 hash=afbd79..5e2f97 age=7mo1w3d dirty=0.00B

Note: We have implemented the DA backend for the Scroll chain to satisfy the requirements of collaborative projects.

Last updated