Skip to content

Commit

Permalink
Add dapWriter preference list
Browse files Browse the repository at this point in the history
Adds a param to the batch poster config `DAPreference` of type `[]string`, which is used to specify which DA Writers to prioritize when posting data to alt da
  • Loading branch information
Ferret-san committed Jul 2, 2024
1 parent f101345 commit 1aa14ea
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 272 deletions.
12 changes: 6 additions & 6 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
return false, nil
}

if len(b.dapWriters) != 0 {
if len(b.dapWriters) > 0 {
if !b.redisLock.AttemptLock(ctx) {
return false, errAttemptLockFailed
}
Expand All @@ -1262,20 +1262,20 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)

// attempt to store data using one of the dapWriters, if it fails and fallbacks are disabled, return a hard error
for _, writer := range b.dapWriters {

sequencerMsg, err = writer.Store(ctx, sequencerMsg, uint64(time.Now().Add(config.DASRetentionPeriod).Unix()), []byte{}, config.DisableDapFallbackStoreDataOnChain)
if err != nil {
if config.DisableDapFallbackStoreDataOnChain {
log.Error("Error while attempting to post batch and on chain fallback is disabled", "error", err)
return false, err
}
log.Error("Error when trying to store data with dapWriter", "error", err)
continue
}
// if we succesffuly posted a batch with a dapWriter, we move on and ignore the rest
break
}

if err != nil && config.DisableDapFallbackStoreDataOnChain {
log.Error("Error while attempting to post batch and on chain fallback is disabled", "error", err)
return false, err
}

}

data, kzgBlobs, err := b.encodeAddBatch(new(big.Int).SetUint64(batchPosition.NextSeqNum), batchPosition.MessageCount, b.building.msgCount, sequencerMsg, b.building.segments.delayedMsg, b.building.use4844)
Expand Down
29 changes: 22 additions & 7 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ type Config struct {
TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"`
Maintenance MaintenanceConfig `koanf:"maintenance" reload:"hot"`
ResourceMgmt resourcemanager.Config `koanf:"resource-mgmt" reload:"hot"`
Celestia celestia.CelestiaConfig `koanf:"celestia-cfg"`
DAPreference []string `koanf:"da-preference"`
// SnapSyncConfig is only used for testing purposes, these should not be configured in production.
SnapSyncTest SnapSyncConfig
Celestia celestia.CelestiaConfig `koanf:"celestia-cfg"`
}

func (c *Config) Validate() error {
Expand Down Expand Up @@ -699,17 +700,31 @@ func createNodeImpl(

var batchPoster *BatchPoster
var delayedSequencer *DelayedSequencer
// TODO (Diego) Enable multiple writers
if config.BatchPoster.Enable {
if txOptsBatchPoster == nil && config.BatchPoster.DataPoster.ExternalSigner.URL == "" {
return nil, errors.New("batchposter, but no TxOpts")
}
dapWriters := []daprovider.Writer{}
if daWriter != nil {
dapWriters = append(dapWriters, daprovider.NewWriterForDAS(daWriter))
}
if celestiaWriter != nil {
dapWriters = append(dapWriters, celestiaTypes.NewWriterForCelestia(celestiaWriter))
for _, providerName := range config.DAPreference {
nilWriter := false
switch strings.ToLower(providerName) {
case "anytrust":
if daWriter != nil {
dapWriters = append(dapWriters, daprovider.NewWriterForDAS(daWriter))
} else {
nilWriter = true
}
case "celestia":
if celestiaWriter != nil {
dapWriters = append(dapWriters, celestiaTypes.NewWriterForCelestia(celestiaWriter))
} else {
nilWriter = true
}
}

if nilWriter {
log.Error("encountered nil daWriter", "daWriter", providerName)
}
}
batchPoster, err = NewBatchPoster(ctx, &BatchPosterOpts{
DataPosterDB: rawdb.NewTable(arbDb, storage.BatchPosterPrefix),
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 56 files
+48 −0 .github/workflows/audit-ci.yml
+24 −0 .github/workflows/slither.yml
+1 −0 .prettierignore
+52 −0 audit-ci.jsonc
+8 −2 foundry.toml
+1 −1 lib/blobstream-contracts
+12 −6 package.json
+0 −263 patches/@nomiclabs+hardhat-etherscan+3.1.0.patch
+2 −1 scripts/config.ts.example
+11 −1 scripts/createERC20Rollup.ts
+10 −1 scripts/createEthRollup.ts
+6 −1 scripts/deployment.ts
+108 −50 scripts/deploymentUtils.ts
+117 −0 scripts/local-deployment/deployCreatorAndCreateRollup.ts
+221 −48 scripts/rollupCreation.ts
+7 −0 slither.config.json
+13,099 −0 slither.db.json
+0 −6 src/bridge/SequencerInbox.sol
+208 −0 src/chain/CacheManager.sol
+0 −45 src/challenge/ChallengeLib.sol
+24 −9 src/challenge/ChallengeManager.sol
+13 −0 src/challenge/IChallengeManager.sol
+52 −0 src/mocks/Benchmarks.sol
+117 −0 src/mocks/MultiCallTest.sol
+126 −0 src/mocks/Program.sol
+176 −0 src/mocks/SdkStorage.sol
+22 −0 src/mocks/SimpleCacheManager.sol
+10 −0 src/osp/IOneStepProofEntry.sol
+81 −7 src/osp/OneStepProofEntry.sol
+64 −20 src/osp/OneStepProver0.sol
+197 −2 src/osp/OneStepProverHostIo.sol
+4 −33 src/osp/OneStepProverMemory.sol
+2 −0 src/precompiles/ArbDebug.sol
+51 −9 src/precompiles/ArbOwner.sol
+119 −0 src/precompiles/ArbWasm.sol
+33 −0 src/precompiles/ArbWasmCache.sol
+88 −47 src/state/Deserialize.sol
+38 −3 src/state/Instructions.sol
+92 −15 src/state/Machine.sol
+22 −4 src/state/MerkleProof.sol
+3 −1 src/state/Module.sol
+54 −0 src/state/ModuleMemory.sol
+58 −0 src/state/MultiStack.sol
+6 −1 src/state/StackFrame.sol
+13 −1 src/state/Value.sol
+6 −1 src/state/ValueStack.sol
+11 −13 test/contract/arbRollup.spec.ts
+4 −6 test/contract/sequencerInboxForceInclude.spec.ts
+12 −8 test/contract/validatorWallet.spec.ts
+167 −0 test/foundry/CacheManager.t.sol
+107 −10 test/foundry/ChallengeManager.t.sol
+3 −1 test/signatures/ChallengeManager
+9 −0 test/signatures/OneStepProofEntry
+1 −1 test/signatures/test-sigs.bash
+1 −0 test/storage/ChallengeManager
+971 −4,604 yarn.lock
1 change: 1 addition & 0 deletions das/celestia/celestiaDasRpcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func CelestiaDAConfigAddOptions(prefix string, f *pflag.FlagSet) {
func NewCelestiaDASRPCClient(target string) (*CelestiaDASClient, error) {
clnt, err := rpc.Dial(target)
if err != nil {
log.Error("Could not dial to Celestia DAS", "err", err)
return nil, err
}
return &CelestiaDASClient{
Expand Down
11 changes: 6 additions & 5 deletions das/celestia/types/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"encoding/binary"
)


// BlobPointer contains the reference to the data blob on Celestia
type BlobPointer struct {
BlockHeight uint64
Start uint64
SharesLength uint64
TxCommitment [32]byte
DataRoot [32]byte
BlockHeight uint64 `json:"block_height"`
Start uint64 `json:"start"`
SharesLength uint64 `json:"shares_length"`
TxCommitment [32]byte `json:"tx_commitment"`
DataRoot [32]byte `json:"data_root"`
}

// MarshalBinary encodes the BlobPointer to binary
Expand Down
5 changes: 3 additions & 2 deletions das/celestia/types/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func (c *writerForCelestia) Store(ctx context.Context, message []byte, timeout u
if disableFallbackStoreDataOnChain {
return nil, errors.New("unable to batch to Celestia and fallback storing data on chain is disabled")
}
return nil, err
}

return msg, nil
message = msg
return message, nil
}
52 changes: 1 addition & 51 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.10
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.9
github.com/cavaliergopher/grab/v3 v3.0.1
github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240603174346-256ddd020a0a
github.com/celestiaorg/nmt v0.20.0
github.com/celestiaorg/rsmt2d v0.11.0
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
Expand All @@ -42,7 +41,6 @@ require (
github.com/r3labs/diff/v3 v3.0.1
github.com/rivo/tview v0.0.0-20240307173318-e804876934a1
github.com/spf13/pflag v1.0.5
github.com/succinctlabs/blobstreamx v0.0.0-20240430034910-aac0842f1705
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint v0.34.29
github.com/wasmerio/wasmer-go v1.0.4
Expand All @@ -56,7 +54,6 @@ require (
)

require (
cosmossdk.io/math v1.1.2 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
Expand All @@ -76,24 +73,17 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect
github.com/aws/smithy-go v1.15.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/celestiaorg/go-fraud v0.2.0 // indirect
github.com/celestiaorg/go-header v0.4.1 // indirect
github.com/celestiaorg/go-square v1.0.1 // indirect
github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b // indirect
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.37.2 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cosmos/gogoproto v1.4.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
Expand All @@ -106,19 +96,13 @@ require (
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/filecoin-project/go-jsonrpc v0.3.1 // indirect
github.com/fjl/memsize v0.0.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gammazero/deque v0.2.1 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/getsentry/sentry-go v0.12.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/gobwas/pool v0.2.1 // indirect
Expand All @@ -133,17 +117,12 @@ require (
github.com/google/pprof v0.0.0-20231023181126-ff6d637d2a7b // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/h2non/filetype v1.0.6 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 // indirect
github.com/juju/loggo v0.0.0-20180524022052-584905176618 // indirect
Expand All @@ -152,49 +131,29 @@ require (
github.com/klauspost/reedsolomon v1.11.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-libp2p v0.30.0 // indirect
github.com/libp2p/go-libp2p-pubsub v0.9.3 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multiaddr v0.11.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rhnvrm/simples3 v0.6.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
Expand All @@ -205,21 +164,12 @@ require (
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

Expand Down
Loading

0 comments on commit 1aa14ea

Please sign in to comment.