Skip to content

Commit

Permalink
Merge branch 'master' into fix-inboxreader-dupbatcheshandling
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 authored Nov 21, 2023
2 parents 4af7991 + c8972cf commit 44a15af
Show file tree
Hide file tree
Showing 16 changed files with 425 additions and 347 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ COPY ./scripts/download-machine.sh .
RUN ./download-machine.sh consensus-v10 0x6b94a7fc388fd8ef3def759297828dc311761e88d8179c7ee8d3887dc554f3c3
RUN ./download-machine.sh consensus-v10.1 0xda4e3ad5e7feacb817c21c8d0220da7650fe9051ece68a3f0b1c5d38bbb27b21
RUN ./download-machine.sh consensus-v10.2 0x0754e09320c381566cc0449904c377a52bd34a6b9404432e80afd573b67f7b17
RUN ./download-machine.sh consensus-v10.3 0xf559b6d4fa869472dabce70fe1c15221bdda837533dfd891916836975b434dec

FROM golang:1.20-bullseye as node-builder
WORKDIR /workspace
Expand Down
288 changes: 15 additions & 273 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
Expand All @@ -37,11 +36,8 @@ import (
"github.com/offchainlabs/nitro/execution"
"github.com/offchainlabs/nitro/execution/gethexec"
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/solgen/go/challengegen"
"github.com/offchainlabs/nitro/solgen/go/ospgen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen"
"github.com/offchainlabs/nitro/staker"
"github.com/offchainlabs/nitro/staker/validatorwallet"
"github.com/offchainlabs/nitro/util/contracts"
Expand All @@ -51,215 +47,6 @@ import (
"github.com/offchainlabs/nitro/wsbroadcastserver"
)

func andTxSucceeded(ctx context.Context, l1Reader *headerreader.HeaderReader, tx *types.Transaction, err error) error {
if err != nil {
return fmt.Errorf("error submitting tx: %w", err)
}
_, err = l1Reader.WaitForTxApproval(ctx, tx)
if err != nil {
return fmt.Errorf("error executing tx: %w", err)
}
return nil
}

func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (common.Address, error) {
client := l1Reader.Client()

/// deploy eth based templates
bridgeTemplate, tx, _, err := bridgegen.DeployBridge(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge deploy error: %w", err)
}

seqInboxTemplate, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("sequencer inbox deploy error: %w", err)
}

inboxTemplate, tx, _, err := bridgegen.DeployInbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("inbox deploy error: %w", err)
}

rollupEventBridgeTemplate, tx, _, err := rollupgen.DeployRollupEventInbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("rollup event bridge deploy error: %w", err)
}

outboxTemplate, tx, _, err := bridgegen.DeployOutbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}

ethBasedTemplates := rollupgen.BridgeCreatorBridgeContracts{
Bridge: bridgeTemplate,
SequencerInbox: seqInboxTemplate,
Inbox: inboxTemplate,
RollupEventInbox: rollupEventBridgeTemplate,
Outbox: outboxTemplate,
}

/// deploy ERC20 based templates
erc20BridgeTemplate, tx, _, err := bridgegen.DeployERC20Bridge(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge deploy error: %w", err)
}

erc20InboxTemplate, tx, _, err := bridgegen.DeployERC20Inbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("inbox deploy error: %w", err)
}

erc20RollupEventBridgeTemplate, tx, _, err := rollupgen.DeployERC20RollupEventInbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("rollup event bridge deploy error: %w", err)
}

erc20OutboxTemplate, tx, _, err := bridgegen.DeployERC20Outbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}

erc20BasedTemplates := rollupgen.BridgeCreatorBridgeContracts{
Bridge: erc20BridgeTemplate,
SequencerInbox: seqInboxTemplate,
Inbox: erc20InboxTemplate,
RollupEventInbox: erc20RollupEventBridgeTemplate,
Outbox: erc20OutboxTemplate,
}

bridgeCreatorAddr, tx, _, err := rollupgen.DeployBridgeCreator(auth, client, ethBasedTemplates, erc20BasedTemplates)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}

return bridgeCreatorAddr, nil
}

func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts) (common.Address, common.Address, error) {
client := l1Reader.Client()
osp0, tx, _, err := ospgen.DeployOneStepProver0(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("osp0 deploy error: %w", err)
}

ospMem, _, _, err := ospgen.DeployOneStepProverMemory(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospMemory deploy error: %w", err)
}

ospMath, _, _, err := ospgen.DeployOneStepProverMath(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospMath deploy error: %w", err)
}

ospHostIo, _, _, err := ospgen.DeployOneStepProverHostIo(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospHostIo deploy error: %w", err)
}

ospEntryAddr, tx, _, err := ospgen.DeployOneStepProofEntry(auth, client, osp0, ospMem, ospMath, ospHostIo)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospEntry deploy error: %w", err)
}

challengeManagerAddr, tx, _, err := challengegen.DeployChallengeManager(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospEntry deploy error: %w", err)
}

return ospEntryAddr, challengeManagerAddr, nil
}

func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth, maxDataSize)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}

ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, l1Reader, auth)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, err
}

rollupAdminLogic, tx, _, err := rollupgen.DeployRollupAdminLogic(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup admin logic deploy error: %w", err)
}

rollupUserLogic, tx, _, err := rollupgen.DeployRollupUserLogic(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup user logic deploy error: %w", err)
}

rollupCreatorAddress, tx, rollupCreator, err := rollupgen.DeployRollupCreator(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup creator deploy error: %w", err)
}

upgradeExecutor, tx, _, err := upgrade_executorgen.DeployUpgradeExecutor(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("upgrade executor deploy error: %w", err)
}

validatorUtils, tx, _, err := rollupgen.DeployValidatorUtils(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("validator utils deploy error: %w", err)
}

validatorWalletCreator, tx, _, err := rollupgen.DeployValidatorWalletCreator(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("validator wallet creator deploy error: %w", err)
}

l2FactoriesDeployHelper, tx, _, err := rollupgen.DeployDeployHelper(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("deploy helper creator deploy error: %w", err)
}

tx, err = rollupCreator.SetTemplates(
auth,
bridgeCreator,
ospEntryAddr,
challengeManagerAddr,
rollupAdminLogic,
rollupUserLogic,
upgradeExecutor,
validatorUtils,
validatorWalletCreator,
l2FactoriesDeployHelper,
)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup set template error: %w", err)
}

return rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, nil
}

func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner common.Address, chainConfig *params.ChainConfig, serializedChainConfig []byte, loserStakeEscrow common.Address) rollupgen.Config {
var confirmPeriod uint64
if prod {
Expand Down Expand Up @@ -287,60 +74,6 @@ func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner com
}
}

func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPoster common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int) (*chaininfo.RollupAddresses, error) {
if config.WasmModuleRoot == (common.Hash{}) {
return nil, errors.New("no machine specified")
}

rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}

var validatorAddrs []common.Address
for i := uint64(1); i <= authorizeValidators; i++ {
validatorAddrs = append(validatorAddrs, crypto.CreateAddress(validatorWalletCreator, i))
}

deployParams := rollupgen.RollupCreatorRollupDeploymentParams{
Config: config,
BatchPoster: batchPoster,
Validators: validatorAddrs,
MaxDataSize: maxDataSize,
NativeToken: nativeToken,
DeployFactoriesToL2: false,
MaxFeePerGasForRetryables: big.NewInt(0), // needed when utility factories are deployed
}

tx, err := rollupCreator.CreateRollup(
deployAuth,
deployParams,
)
if err != nil {
return nil, fmt.Errorf("error submitting create rollup tx: %w", err)
}
receipt, err := parentChainReader.WaitForTxApproval(ctx, tx)
if err != nil {
return nil, fmt.Errorf("error executing create rollup tx: %w", err)
}
info, err := rollupCreator.ParseRollupCreated(*receipt.Logs[len(receipt.Logs)-1])
if err != nil {
return nil, fmt.Errorf("error parsing rollup created log: %w", err)
}

return &chaininfo.RollupAddresses{
Bridge: info.Bridge,
Inbox: info.InboxAddress,
SequencerInbox: info.SequencerInbox,
DeployedAt: receipt.BlockNumber.Uint64(),
Rollup: info.RollupAddress,
NativeToken: nativeToken,
UpgradeExecutor: info.UpgradeExecutor,
ValidatorUtils: validatorUtils,
ValidatorWalletCreator: validatorWalletCreator,
}, nil
}

type Config struct {
Sequencer bool `koanf:"sequencer"`
ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"`
Expand Down Expand Up @@ -1053,8 +786,23 @@ func (n *Node) Start(ctx context.Context) error {
return fmt.Errorf("error starting inbox reader: %w", err)
}
}
// must init broadcast server before trying to sequence anything
if n.BroadcastServer != nil {
err = n.BroadcastServer.Start(ctx)
if err != nil {
return fmt.Errorf("error starting feed broadcast server: %w", err)
}
}
if n.SeqCoordinator != nil {
n.SeqCoordinator.Start(ctx)
} else {
if n.DelayedSequencer != nil {
err := n.DelayedSequencer.ForceSequenceDelayed(ctx)
if err != nil {
return fmt.Errorf("error initially sequencing delayed instructions: %w", err)
}
}
n.Execution.Activate()
}
if n.MaintenanceRunner != nil {
n.MaintenanceRunner.Start(ctx)
Expand Down Expand Up @@ -1101,12 +849,6 @@ func (n *Node) Start(ctx context.Context) error {
if n.L1Reader != nil {
n.L1Reader.Start(ctx)
}
if n.BroadcastServer != nil {
err = n.BroadcastServer.Start(ctx)
if err != nil {
return fmt.Errorf("error starting feed broadcast server: %w", err)
}
}
if n.BroadcastClients != nil {
go func() {
if n.InboxReader != nil {
Expand Down
3 changes: 0 additions & 3 deletions arbnode/seq_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ func NewSeqCoordinator(
config: config,
signer: signer,
}
if sequencer != nil {
sequencer.Pause()
}
streamer.SetSeqCoordinator(coordinator)
return coordinator, nil
}
Expand Down
8 changes: 6 additions & 2 deletions broadcastclients/broadcastclients.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ func (bcs *BroadcastClients) Start(ctx context.Context) {
continue
}
lastConfirmed = cs
bcs.primaryRouter.forwardConfirmationChan <- cs
if bcs.primaryRouter.forwardConfirmationChan != nil {
bcs.primaryRouter.forwardConfirmationChan <- cs
}

// Secondary Feeds
case msg := <-bcs.secondaryRouter.messageChan:
Expand All @@ -187,7 +189,9 @@ func (bcs *BroadcastClients) Start(ctx context.Context) {
continue
}
lastConfirmed = cs
bcs.secondaryRouter.forwardConfirmationChan <- cs
if bcs.secondaryRouter.forwardConfirmationChan != nil {
bcs.secondaryRouter.forwardConfirmationChan <- cs
}

// Cycle buckets to get rid of old entries
case <-recentFeedItemsCleanup.C:
Expand Down
4 changes: 0 additions & 4 deletions cmd/datool/datool.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func parseClientStoreConfig(args []string) (*ClientStoreConfig, error) {
f.String("signing-wallet", "", "wallet containing ecdsa key to sign the message with")
f.String("signing-wallet-password", genericconf.PASSWORD_NOT_SET, "password to unlock the wallet, if not specified the user is prompted for the password")
f.Duration("das-retention-period", 24*time.Hour, "The period which DASes are requested to retain the stored batches.")
genericconf.ConfConfigAddOptions("conf", f)

k, err := confighelpers.BeginCommonParse(f, args)
if err != nil {
Expand Down Expand Up @@ -204,8 +203,6 @@ func parseRESTClientGetByHashConfig(args []string) (*RESTClientGetByHashConfig,
f.String("url", "http://localhost:9877", "URL of DAS server to connect to.")
f.String("data-hash", "", "hash of the message to retrieve, if starts with '0x' it's treated as hex encoded, otherwise base64 encoded")

genericconf.ConfConfigAddOptions("conf", f)

k, err := confighelpers.BeginCommonParse(f, args)
if err != nil {
return nil, err
Expand Down Expand Up @@ -267,7 +264,6 @@ func parseKeyGenConfig(args []string) (*KeyGenConfig, error) {
f.String("dir", "", "the directory to generate the keys in")
f.Bool("ecdsa", false, "generate an ECDSA keypair instead of BLS")
f.Bool("wallet", false, "generate the ECDSA keypair in a wallet file")
genericconf.ConfConfigAddOptions("conf", f)

k, err := confighelpers.BeginCommonParse(f, args)
if err != nil {
Expand Down
Loading

0 comments on commit 44a15af

Please sign in to comment.