Skip to content

Commit

Permalink
Revert "Use BoLD contracts to test delay buffer"
Browse files Browse the repository at this point in the history
This reverts commit b0d586c.
  • Loading branch information
gligneul committed Nov 26, 2024
1 parent 9d64847 commit b203a3d
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 509 deletions.
3 changes: 2 additions & 1 deletion arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"

"github.com/offchainlabs/bold/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/arbnode/dataposter"
"github.com/offchainlabs/nitro/arbnode/dataposter/storage"
"github.com/offchainlabs/nitro/arbnode/redislock"
Expand All @@ -45,6 +44,7 @@ import (
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/cmd/genericconf"
"github.com/offchainlabs/nitro/execution"
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/util"
"github.com/offchainlabs/nitro/util/arbmath"
"github.com/offchainlabs/nitro/util/blobs"
Expand Down Expand Up @@ -317,6 +317,7 @@ func NewBatchPoster(ctx context.Context, opts *BatchPosterOpts) (*BatchPoster, e
if err = opts.Config().Validate(); err != nil {
return nil, err
}
// TODO(delaybuffer) use new bridgegen
seqInboxABI, err := bridgegen.SequencerInboxMetaData.GetAbi()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion arbnode/delay_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/offchainlabs/bold/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/arbos/arbostypes"
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/util/headerreader"
)

Expand Down
37 changes: 37 additions & 0 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/offchainlabs/nitro/execution/gethexec"
"github.com/offchainlabs/nitro/solgen/go/bridgegen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/staker"
boldstaker "github.com/offchainlabs/nitro/staker/bold"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
Expand All @@ -52,6 +53,42 @@ import (
"github.com/offchainlabs/nitro/wsbroadcastserver"
)

func DefaultBufferConfig() rollupgen.BufferConfig {
return rollupgen.BufferConfig{
Threshold: 600, // 1 hour of blocks
Max: 14400, // 2 days of blocks
ReplenishRateInBasis: 500, // 5%
}
}

func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner common.Address, chainConfig *params.ChainConfig, serializedChainConfig []byte, loserStakeEscrow common.Address, bufferConfig rollupgen.BufferConfig) rollupgen.Config {
var confirmPeriod uint64
if prod {
confirmPeriod = 45818
} else {
confirmPeriod = 20
}
return rollupgen.Config{
ConfirmPeriodBlocks: confirmPeriod,
ExtraChallengeTimeBlocks: 200,
StakeToken: common.Address{},
BaseStake: big.NewInt(params.Ether),
WasmModuleRoot: wasmModuleRoot,
Owner: rollupOwner,
LoserStakeEscrow: loserStakeEscrow,
ChainId: chainConfig.ChainID,
// TODO could the ChainConfig be just []byte?
ChainConfig: string(serializedChainConfig),
SequencerInboxMaxTimeVariation: rollupgen.ISequencerInboxMaxTimeVariation{
DelayBlocks: big.NewInt(60 * 60 * 24 / 15),
FutureBlocks: big.NewInt(12),
DelaySeconds: big.NewInt(60 * 60 * 24),
FutureSeconds: big.NewInt(60 * 60),
},
BufferConfig: bufferConfig,
}
}

type Config struct {
Sequencer bool `koanf:"sequencer"`
ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"`
Expand Down
12 changes: 10 additions & 2 deletions cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/cmd/genericconf"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/util/headerreader"
"github.com/offchainlabs/nitro/validator/server_common"

Expand All @@ -25,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/cmd/util"
deploycode "github.com/offchainlabs/nitro/deploy"
)
Expand Down Expand Up @@ -60,6 +62,7 @@ func main() {
authorizevalidators := flag.Uint64("authorizevalidators", 0, "Number of validators to preemptively authorize")
txTimeout := flag.Duration("txtimeout", 10*time.Minute, "Timeout when waiting for a transaction to be included in a block")
prod := flag.Bool("prod", false, "Whether to configure the rollup for production or testing")
isDelayBufferable := flag.Bool("delayBufferable", false, "Whether the sequencer-inbox delay buffer is enabled")
flag.Parse()
l1ChainId := new(big.Int).SetUint64(*l1ChainIdUint)
maxDataSize := new(big.Int).SetUint64(*maxDataSizeUint)
Expand Down Expand Up @@ -169,6 +172,11 @@ func main() {
panic(fmt.Errorf("failed to deserialize chain config: %w", err))
}

var bufferConfig rollupgen.BufferConfig
if *isDelayBufferable {
bufferConfig = arbnode.DefaultBufferConfig()
}

arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, l1client)
l1Reader, err := headerreader.New(ctx, l1client, func() *headerreader.Config { return &headerReaderConfig }, arbSys)
if err != nil {
Expand All @@ -178,14 +186,14 @@ func main() {
defer l1Reader.StopAndWait()

nativeToken := common.HexToAddress(*nativeTokenAddressString)
deployedAddresses, err := deploycode.DeployLegacyOnParentChain(
deployedAddresses, err := deploycode.DeployOnParentChain(
ctx,
l1Reader,
l1TransactionOpts,
batchPosters,
batchPosterManagerAddress,
*authorizevalidators,
deploycode.GenerateLegacyRollupConfig(*prod, moduleRoot, ownerAddress, &chainConfig, chainConfigJson, loserEscrowAddress),
arbnode.GenerateRollupConfig(*prod, moduleRoot, ownerAddress, &chainConfig, chainConfigJson, loserEscrowAddress, bufferConfig),
nativeToken,
maxDataSize,
true,
Expand Down
117 changes: 26 additions & 91 deletions deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,16 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/offchainlabs/bold/solgen/go/bridgegen"
"github.com/offchainlabs/bold/solgen/go/challengeV2gen"
"github.com/offchainlabs/bold/solgen/go/ospgen"
"github.com/offchainlabs/bold/solgen/go/rollupgen"
"github.com/offchainlabs/bold/solgen/go/yulgen"
"github.com/offchainlabs/nitro/cmd/chaininfo"
"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/rollupgen"
"github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen"
"github.com/offchainlabs/nitro/solgen/go/yulgen"
"github.com/offchainlabs/nitro/util/headerreader"
)

// lint:require-exhaustive-initialization
type RollupConfigOpts struct {
Prod bool
WasmModuleRoot common.Hash
RollupOwner common.Address
ChainConfig *params.ChainConfig
SerializedChainConfig []byte
LoserStakeEscrow common.Address
MiniStakeValues []*big.Int
StakeToken common.Address
GenesisExecutionState rollupgen.AssertionState
GenesisInboxCount *big.Int
AnyTrustFastConfirmer common.Address
LayerZeroBlockEdgeHeight uint64
LayerZeroBigStepEdgeHeight uint64
LayerZeroSmallStepEdgeHeight uint64
NumBigStepLevel uint8
BufferConfig rollupgen.BufferConfig
}

func DefaultBufferConfig() rollupgen.BufferConfig {
return rollupgen.BufferConfig{
Threshold: 600, // 1 hour of blocks
Max: 14400, // 2 days of blocks
ReplenishRateInBasis: 500, // 5%
}
}

func GenerateRollupConfig(opts *RollupConfigOpts) rollupgen.Config {
var confirmPeriod uint64
if opts.Prod {
confirmPeriod = 45818
} else {
confirmPeriod = 25
}

var gracePeriod uint64
if opts.Prod {
gracePeriod = 14400
} else {
gracePeriod = 3
}

cfg := rollupgen.Config{
ConfirmPeriodBlocks: confirmPeriod,
StakeToken: opts.StakeToken,
BaseStake: big.NewInt(1),
WasmModuleRoot: opts.WasmModuleRoot,
Owner: opts.RollupOwner,
LoserStakeEscrow: opts.LoserStakeEscrow,
ChainId: opts.ChainConfig.ChainID,
ChainConfig: string(opts.SerializedChainConfig),
MiniStakeValues: opts.MiniStakeValues,
SequencerInboxMaxTimeVariation: rollupgen.ISequencerInboxMaxTimeVariation{
DelayBlocks: big.NewInt(60 * 60 * 24 / 15),
FutureBlocks: big.NewInt(12),
DelaySeconds: big.NewInt(60 * 60 * 24),
FutureSeconds: big.NewInt(60 * 60),
},
LayerZeroBlockEdgeHeight: new(big.Int).SetUint64(opts.LayerZeroBlockEdgeHeight),
LayerZeroBigStepEdgeHeight: new(big.Int).SetUint64(opts.LayerZeroBigStepEdgeHeight),
LayerZeroSmallStepEdgeHeight: new(big.Int).SetUint64(opts.LayerZeroSmallStepEdgeHeight),
GenesisAssertionState: opts.GenesisExecutionState,
GenesisInboxCount: opts.GenesisInboxCount,
AnyTrustFastConfirmer: opts.AnyTrustFastConfirmer,
NumBigStepLevel: opts.NumBigStepLevel,
ChallengeGracePeriodBlocks: gracePeriod,
BufferConfig: opts.BufferConfig,
}
return cfg
}

func andTxSucceeded(ctx context.Context, parentChainReader *headerreader.HeaderReader, tx *types.Transaction, err error) error {
if err != nil {
return fmt.Errorf("error submitting tx: %w", err)
Expand Down Expand Up @@ -240,7 +167,7 @@ func deployChallengeFactory(ctx context.Context, parentChainReader *headerreader
return common.Address{}, common.Address{}, fmt.Errorf("ospHostIo deploy error: %w", err)
}

challengeManagerAddr, tx, _, err := challengeV2gen.DeployEdgeChallengeManager(auth, client)
challengeManagerAddr, tx, _, err := challengegen.DeployChallengeManager(auth, client)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("challenge manager deploy error: %w", err)
Expand All @@ -255,51 +182,57 @@ func deployChallengeFactory(ctx context.Context, parentChainReader *headerreader
return ospEntryAddr, challengeManagerAddr, nil
}

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

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

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

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

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

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

validatorUtils, tx, _, err := rollupgen.DeployValidatorUtils(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, 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, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, fmt.Errorf("validator wallet creator deploy error: %w", err)
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("validator wallet creator deploy error: %w", err)
}

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

tx, err = rollupCreator.SetTemplates(
Expand All @@ -310,23 +243,24 @@ func deployRollupCreator(ctx context.Context, parentChainReader *headerreader.He
rollupAdminLogic,
rollupUserLogic,
upgradeExecutor,
validatorUtils,
validatorWalletCreator,
l2FactoriesDeployHelper,
)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, fmt.Errorf("rollup set template error: %w", err)
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup set template error: %w", err)
}

return rollupCreator, rollupCreatorAddress, validatorWalletCreator, nil
return rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, nil
}

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

rollupCreator, _, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, chainSupportsBlobs)
rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, chainSupportsBlobs)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}
Expand Down Expand Up @@ -371,6 +305,7 @@ func DeployOnParentChain(ctx context.Context, parentChainReader *headerreader.He
Rollup: info.RollupAddress,
NativeToken: nativeToken,
UpgradeExecutor: info.UpgradeExecutor,
ValidatorUtils: validatorUtils,
ValidatorWalletCreator: validatorWalletCreator,
}, nil
}
Loading

0 comments on commit b203a3d

Please sign in to comment.