Skip to content

Commit e3317db

Browse files
Albertanvztor
andauthored
Add Near DA (#55)
* feat: update dockerfile * feat: update dockerfile * feat: add da flags for op-node & update dockerfile * feat: update dockerfile * feat: add category for near da * feat: add da envs for op-batcher * feat: update ci * feat: add near da client * feat: sort import * feat: add near da envs for op-node * feat: add retry for op-batcher * feat: rename * feat: update dockerfile * feat: revert * feat: rename * feat: update readme * feat: update readme * feat: bump rollup-da sdk & free near da client * feat: update DataFromEVMTransactions, support near da * feat: fix op-node cli * feat: update dockerfile * feat: update dockerfile * feat: update dockerfile * feat: update dockerfile * feat: update log * feat: check blob after finality * feat: update go.mod * feat: check blob data after finality * feat: update log * fix: fix submitBlobToNearDA * feat: update go.mod * feat: check near da cli * feat: add retry * feat: update log * feat: update defaultGetTimeout * feat: update go.mod * feat: update log * chore: update da-rpc image name * fix: use build arg OP_STACK_GO_BUILDER * chore: update da-rpc image name * fix: use build arg OP_STACK_GO_BUILDER * feat: set defaultGetTimeout 60s * feat: update log * feat: rename & update log * feat: update log * feat: update near da check * feat: add retry * feat: update rollup-da * feat: set da timeout 90s * feat: update log * feat: add elapsed time * feat: update log * feat: update log * feat: update log * feat: update go.mod & log * feat: update go.mod & fix near da crash * feat: set da attempts as 10 --------- Co-authored-by: anvztor <15998375+anvztor@users.noreply.github.com>
1 parent e407c55 commit e3317db

28 files changed

Lines changed: 524 additions & 46 deletions

File tree

.github/workflows/slither.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,3 @@ jobs:
3131
fail-on: config
3232
sarif: results.sarif
3333
slither-args: --triage-database packages/contracts-bedrock/slither.db.json
34-
35-
- name: Upload SARIF file
36-
uses: github/codeql-action/upload-sarif@v3
37-
if: always()
38-
with:
39-
sarif_file: ${{ steps.slither.outputs.sarif }}

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
<a href="https://optimism.io"><img alt="Optimism" src="https://raw.githubusercontent.com/ethereum-optimism/brand-kit/main/assets/svg/OPTIMISM-R.svg" width=600></a>
55
<br />
66
<h3><a href="https://optimism.io">Optimism</a> is Ethereum, scaled.</h3>
7+
<h3>+</h3>
8+
<a href="https://rss3.io"><img alt="RSS3 VSL" src="docs/op-stack/src/assets/docs/understand/VSL.svg" width=600></a>
9+
<h3><a href="https://rss3.io">RSS3 VSL</a> is a modularized Ethereum Layer 2, built to handle value and ownership of Open Information (social, search, AI, and beyond).</h3>
10+
<br />
711
<br />
812
</div>
913

@@ -12,6 +16,7 @@
1216
**Table of Contents**
1317

1418
- [What is Optimism?](#what-is-optimism)
19+
- [What is RSS3 VSL?](#what-is-rss3-vsl)
1520
- [Documentation](#documentation)
1621
- [Specification](#specification)
1722
- [Community](#community)
@@ -32,6 +37,26 @@
3237

3338
In this repository, you'll find numerous core components of the OP Stack, the decentralized software stack maintained by the Optimism Collective that powers Optimism and forms the backbone of blockchains like [OP Mainnet](https://explorer.optimism.io/) and [Base](https://base.org). Designed to be "aggressively open source," the OP Stack encourages you to explore, modify, extend, and test the code as needed. Although not all elements of the OP Stack are contained here, many of its essential components can be found within this repository. By collaborating on free, open software and shared standards, the Optimism Collective aims to prevent siloed software development and rapidly accelerate the development of the Ethereum ecosystem. Come contribute, build the future, and redefine power, together.
3439

40+
## What is RSS3 VSL?
41+
42+
The RSS3 VSL is a modularized Ethereum Layer 2, built to handle value and ownership of Open Information (social, search, AI, and beyond).
43+
44+
- Layer 2
45+
46+
Blockchain is the technology naturally designed to handle value and ownership with consensus. Therefore, we’ve decided to have VSL in the form of a blockchain. There are quite a few approaches to build a blockchain, and we ended up having a Ethereum layer 2: its EVM is the most widely used environment for smart contracts, it offer great potential liquidity, and $RSS3 for the current testnet is issued on Ethereum Mainnet - it will smoothly evolve as the utility token for the RSS3 Mainnet.
47+
48+
- Adjusted OP Stack
49+
50+
For Ethereum rollups, there are still the ongoing debates on what scaling solution is the best. We’ve decided that for now, the RSS3 VSL will be built based on OP Stack for its efficiency and ecosystem. As a relatively-mature solution powering multiple L2s, Optimistic rollup has been well proven. And we’ve adjusted OP Stack to best serve the purpose of VSL.
51+
52+
- Near DA
53+
54+
While being a layer 2 greatly saves transaction gas fee compared to Ethereum Mainnet, it’s not enough. As the ownership and value layer for open information, constant high frequency microtransactions are expected. Therefore, we are partnering with Near and have DA stored on the network. This further significantly lowers the transaction cost on RSS3 VSL.
55+
56+
- Gas Token
57+
58+
The RSS3 VSL will have $RSS3 as its gas token, making it the first native gas L2 with Optimistic rollup and Near DA. The sequencer will take $RSS3 and convert it into $ETH and $TIA. And if that results in sequencer revenue, it will go to public goods and ecosystem grants.
59+
3560
## Documentation
3661

3762
- If you want to build on top of OP Mainnet, refer to the [Optimism Documentation](https://docs.optimism.io)
Lines changed: 12 additions & 0 deletions
Loading

go.mod

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
1313
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
1414
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240306093353-c557df8e6f41
15-
github.com/ethereum/go-ethereum v1.13.8
15+
github.com/ethereum/go-ethereum v1.13.14
1616
github.com/fsnotify/fsnotify v1.7.0
1717
github.com/go-chi/chi/v5 v5.0.12
1818
github.com/go-chi/docgen v1.2.0
@@ -37,6 +37,7 @@ require (
3737
github.com/multiformats/go-base32 v0.1.0
3838
github.com/multiformats/go-multiaddr v0.12.2
3939
github.com/multiformats/go-multiaddr-dns v0.3.1
40+
github.com/near/rollup-data-availability v0.2.3
4041
github.com/olekukonko/tablewriter v0.0.5
4142
github.com/onsi/gomega v1.31.1
4243
github.com/pkg/errors v0.9.1
@@ -88,13 +89,13 @@ require (
8889
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
8990
github.com/fatih/color v1.13.0 // indirect
9091
github.com/felixge/fgprof v0.9.3 // indirect
91-
github.com/fjl/memsize v0.0.1 // indirect
92+
github.com/fjl/memsize v0.0.2 // indirect
9293
github.com/flynn/noise v1.0.0 // indirect
9394
github.com/francoispqt/gojay v1.2.13 // indirect
9495
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
9596
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
9697
github.com/getsentry/sentry-go v0.18.0 // indirect
97-
github.com/go-ole/go-ole v1.2.6 // indirect
98+
github.com/go-ole/go-ole v1.3.0 // indirect
9899
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
99100
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
100101
github.com/godbus/dbus/v5 v5.1.0 // indirect
@@ -114,7 +115,7 @@ require (
114115
github.com/hashicorp/go-msgpack/v2 v2.1.1 // indirect
115116
github.com/hashicorp/golang-lru v0.5.0 // indirect
116117
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect
117-
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
118+
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
118119
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
119120
github.com/huin/goupnp v1.3.0 // indirect
120121
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
@@ -217,7 +218,9 @@ require (
217218
rsc.io/tmplfunc v0.0.3 // indirect
218219
)
219220

220-
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/rss3-network/op-geth v0.0.0-20240318084011-ac750f910c66
221+
replace github.com/ethereum/go-ethereum v1.13.14 => github.com/rss3-network/op-geth v0.0.0-20240318084011-ac750f910c66
222+
223+
replace github.com/near/rollup-data-availability v0.2.3 => github.com/rss3-network/rollup-data-availability v0.0.0-20240415060515-2c91800c0de7
221224

222225
//replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain
223226
//replace github.com/ethereum/go-ethereum v1.13.8 => ../op-geth

go.sum

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
178178
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
179179
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
180180
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
181-
github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ=
182-
github.com/fjl/memsize v0.0.1/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
181+
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
182+
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
183183
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
184184
github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ=
185185
github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
@@ -218,8 +218,9 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
218218
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
219219
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
220220
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
221-
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
222221
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
222+
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
223+
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
223224
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
224225
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
225226
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
@@ -332,8 +333,8 @@ github.com/hashicorp/raft v1.6.1 h1:v/jm5fcYHvVkL0akByAp+IDdDSzCNCGhdO6VdB56HIM=
332333
github.com/hashicorp/raft v1.6.1/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0=
333334
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e h1:SK4y8oR4ZMHPvwVHryKI88kJPJda4UyWYvG5A6iEQxc=
334335
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e/go.mod h1:EMz/UIuG93P0MBeHh6CbXQAEe8ckVJLZjhD17lBzK5Q=
335-
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw=
336-
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
336+
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4=
337+
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
337338
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
338339
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
339340
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
@@ -691,6 +692,8 @@ github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OK
691692
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
692693
github.com/rss3-network/op-geth v0.0.0-20240318084011-ac750f910c66 h1:JmziXEoykS6nVOLC2MAMkUwaCIAol6Hvi3TbA/rJi5E=
693694
github.com/rss3-network/op-geth v0.0.0-20240318084011-ac750f910c66/go.mod h1:k0UbrLuOITLD8goCyA2xWebAL03n2BZUCfwos0rxz60=
695+
github.com/rss3-network/rollup-data-availability v0.0.0-20240415060515-2c91800c0de7 h1:ykN7labjXhyDRZRW6wvPhcjonJcCpvezG/DdCSRbAnY=
696+
github.com/rss3-network/rollup-data-availability v0.0.0-20240415060515-2c91800c0de7/go.mod h1:hCjAJiCD0Ng9JYavCBGIkN0nwVKVKOircQLp+0Q4cuI=
694697
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
695698
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
696699
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
@@ -946,6 +949,7 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc
946949
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
947950
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
948951
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
952+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
949953
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
950954
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
951955
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

op-batcher/Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op-stack-go:latest
1+
ARG OP_STACK_GO_BUILDER=rss3/op-stack-go:latest
22
FROM $OP_STACK_GO_BUILDER as builder
33
# See "make golang-docker" and /ops/docker/op-stack-go
44

5-
FROM alpine:3.18
5+
FROM --platform=$BUILDPLATFORM rss3/da-rpc:latest as rust
6+
7+
RUN ls /lib
8+
RUN ls /gopkg/da-rpc
9+
10+
FROM debian:bookworm-slim
11+
12+
RUN apt-get update && apt-get install -y \
13+
jq \
14+
bash \
15+
curl
616

717
COPY --from=builder /usr/local/bin/op-batcher /usr/local/bin/op-batcher
818

19+
# Copy lib from da-rpc
20+
COPY --from=rust /gopkg/da-rpc/lib/ /usr/local/lib
21+
22+
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
23+
924
CMD ["op-batcher"]

op-batcher/batcher/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/ethereum-optimism/optimism/op-batcher/compressor"
1212
"github.com/ethereum-optimism/optimism/op-batcher/flags"
13+
opnear "github.com/ethereum-optimism/optimism/op-near"
1314
plasma "github.com/ethereum-optimism/optimism/op-plasma"
1415
oplog "github.com/ethereum-optimism/optimism/op-service/log"
1516
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
@@ -77,6 +78,7 @@ type CLIConfig struct {
7778
CompressorConfig compressor.CLIConfig
7879
RPC oprpc.CLIConfig
7980
PlasmaDA plasma.CLIConfig
81+
NearDA opnear.CLIConfig
8082
}
8183

8284
func (c *CLIConfig) Check() error {
@@ -122,6 +124,10 @@ func (c *CLIConfig) Check() error {
122124
if err := c.RPC.Check(); err != nil {
123125
return err
124126
}
127+
if err := c.NearDA.Check(); err != nil {
128+
return err
129+
}
130+
125131
return nil
126132
}
127133

@@ -150,5 +156,6 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
150156
CompressorConfig: compressor.ReadCLIConfig(ctx),
151157
RPC: oprpc.ReadCLIConfig(ctx),
152158
PlasmaDA: plasma.ReadCLIConfig(ctx),
159+
NearDA: opnear.ReadCLIConfig(ctx),
153160
}
154161
}

op-batcher/batcher/driver.go

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package batcher
22

33
import (
4+
"bytes"
45
"context"
6+
"encoding/hex"
57
"errors"
68
"fmt"
79
"io"
@@ -15,6 +17,7 @@ import (
1517
"github.com/ethereum/go-ethereum/log"
1618

1719
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
20+
opnear "github.com/ethereum-optimism/optimism/op-near"
1821
"github.com/ethereum-optimism/optimism/op-node/rollup"
1922
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
2023
plasma "github.com/ethereum-optimism/optimism/op-plasma"
@@ -48,6 +51,7 @@ type DriverSetup struct {
4851
EndpointProvider dial.L2EndpointProvider
4952
ChannelConfig ChannelConfig
5053
PlasmaDA *plasma.DAClient
54+
NearDA *opnear.DAClient
5155
}
5256

5357
// BatchSubmitter encapsulates a service responsible for submitting L2 tx
@@ -264,7 +268,7 @@ func (l *BatchSubmitter) loop() {
264268
for {
265269
select {
266270
case r := <-receiptsCh:
267-
l.Log.Info("handling receipt", "id", r.ID)
271+
l.Log.Info("handling receipt", "id", r.ID.ID())
268272
l.handleReceipt(r)
269273
case <-receiptLoopDone:
270274
l.Log.Info("receipt processing loop done")
@@ -401,7 +405,10 @@ func (l *BatchSubmitter) sendTransaction(ctx context.Context, txdata txData, que
401405
return nil
402406
}
403407
}
404-
candidate = l.calldataTxCandidate(data)
408+
candidate, err = l.calldataTxCandidate(data)
409+
if err != nil {
410+
return fmt.Errorf("failed to build calldata transaction candidate: %w", err)
411+
}
405412
}
406413

407414
intrinsicGas, err := core.IntrinsicGas(candidate.TxData, nil, false, true, true, false)
@@ -432,12 +439,47 @@ func (l *BatchSubmitter) blobTxCandidate(data txData) (*txmgr.TxCandidate, error
432439
}, nil
433440
}
434441

435-
func (l *BatchSubmitter) calldataTxCandidate(data []byte) *txmgr.TxCandidate {
436-
l.Log.Info("building Calldata transaction candidate", "size", len(data))
442+
func (l *BatchSubmitter) submitBlobToNearDA(data []byte) ([]byte, error) {
443+
log.Debug("submitBlobToNearDA", "data", hex.EncodeToString(data), "size", len(data))
444+
// frameRef is the blob commitment, which is provided as [transaction_id ++ commitment]
445+
frameRef, err := l.NearDA.Submit(data)
446+
if err != nil {
447+
l.Log.Warn("failed to submit blob to near da", "err", err)
448+
return nil, err
449+
}
450+
451+
// finality is achieved which is 3 blocks (around 2-3 seconds) its not possible for a reorg to happen
452+
// check the submitted blob after finality
453+
time.Sleep(10 * time.Second)
454+
blobData, err := l.NearDA.Get(frameRef, 0)
455+
if err != nil {
456+
log.Error("failed to get blob from near da, maybe chain reorg", "id", hex.EncodeToString(data), "err", err)
457+
return nil, err
458+
}
459+
if !bytes.Equal(blobData, data) {
460+
log.Error("failed to get blob from near da, blob data mismatch", "id", hex.EncodeToString(frameRef), "expected", hex.EncodeToString(data), "got", hex.EncodeToString(blobData))
461+
return nil, fmt.Errorf("submitted blob mismatch with obtained blob, id :%s", hex.EncodeToString(frameRef))
462+
}
463+
464+
return frameRef, nil
465+
}
466+
467+
// publish blob to near da, and get the FrameRef from near da
468+
// then publish the `DerivationVersionNear + FrameRef` to ethereum
469+
func (l *BatchSubmitter) calldataTxCandidate(data []byte) (*txmgr.TxCandidate, error) {
470+
l.Log.Info("building calldata transaction candidate", "size", len(data))
471+
maybeFrameRef, err := l.submitBlobToNearDA(data)
472+
if err != nil {
473+
l.Log.Warn("unable to submit blob to near da", "err", err)
474+
return nil, err
475+
} else {
476+
l.Log.Info("blob successfully submitted to near da", "id", hex.EncodeToString(maybeFrameRef))
477+
data = append([]byte{opnear.DerivationVersionNear}, maybeFrameRef...)
478+
}
437479
return &txmgr.TxCandidate{
438480
To: &l.RollupConfig.BatchInboxAddress,
439481
TxData: data,
440-
}
482+
}, nil
441483
}
442484

443485
func (l *BatchSubmitter) handleReceipt(r txmgr.TxReceipt[txData]) {

0 commit comments

Comments
 (0)