Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refac!: renaming about proposer #221

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bindings/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ bindings: basefee-vault-bindings \
l2-output-oracle-bindings \
l2-standard-bridge-bindings \
l2-to-l1-message-passer-bindings \
proposer-fee-vault-bindings \
proxy-admin-bindings \
proxy-bindings \
security-council-bindings \
Expand All @@ -31,6 +30,7 @@ bindings: basefee-vault-bindings \
timelock-bindings \
upgrade-governor-bindings \
validator-pool-bindings \
validator-reward-vault-bindings \
weth9-bindings \
zk-merkle-trie-bindings \
zk-verifier-bindings
Expand Down Expand Up @@ -113,7 +113,7 @@ l1-erc721-bridge-bindings: compile
bash ./gen_bindings.sh contracts/L1/L1ERC721Bridge.sol:L1ERC721Bridge $(pkg)

l1-fee-vault-bindings: compile
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
bash ./gen_bindings.sh contracts/L2/ProposerRewardVault.sol:ProposerRewardVault $(pkg)
bash ./gen_bindings.sh contracts/L2/L1FeeVault.sol:L1FeeVault $(pkg)

l1-standard-bridge-bindings: compile
bash ./gen_bindings.sh contracts/L1/L1StandardBridge.sol:L1StandardBridge $(pkg)
Expand All @@ -133,9 +133,6 @@ l2-standard-bridge-bindings: compile
l2-to-l1-message-passer-bindings: compile
bash ./gen_bindings.sh contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser $(pkg)

proposer-fee-vault-bindings: compile
bash ./gen_bindings.sh contracts/L2/ValidatorRewardVault.sol:ValidatorRewardVault $(pkg)

proxy-admin-bindings: compile
bash ./gen_bindings.sh contracts/universal/ProxyAdmin.sol:ProxyAdmin $(pkg)

Expand All @@ -160,6 +157,9 @@ upgrade-governor-bindings: compile
validator-pool-bindings: compile
bash ./gen_bindings.sh contracts/L1/ValidatorPool.sol:ValidatorPool $(pkg)

validator-reward-vault-bindings: compile
bash ./gen_bindings.sh contracts/L2/ValidatorRewardVault.sol:ValidatorRewardVault $(pkg)

weth9-bindings: compile
bash ./gen_bindings.sh contracts/vendor/WETH9.sol:WETH9 $(pkg)

Expand Down

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bindings/predeploys/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
L2CrossDomainMessenger = "0x4200000000000000000000000000000000000004"
GasPriceOracle = "0x4200000000000000000000000000000000000005"
ProtocolVault = "0x4200000000000000000000000000000000000006"
ProposerRewardVault = "0x4200000000000000000000000000000000000007"
L1FeeVault = "0x4200000000000000000000000000000000000007"
ValidatorRewardVault = "0x4200000000000000000000000000000000000008"
L2StandardBridge = "0x4200000000000000000000000000000000000009"
L2ERC721Bridge = "0x420000000000000000000000000000000000000A"
Expand All @@ -26,7 +26,7 @@ var (
L2CrossDomainMessengerAddr = common.HexToAddress(L2CrossDomainMessenger)
GasPriceOracleAddr = common.HexToAddress(GasPriceOracle)
ProtocolVaultAddr = common.HexToAddress(ProtocolVault)
ProposerRewardVaultAddr = common.HexToAddress(ProposerRewardVault)
L1FeeVaultAddr = common.HexToAddress(L1FeeVault)
ValidatorRewardVaultAddr = common.HexToAddress(ValidatorRewardVault)
L2StandardBridgeAddr = common.HexToAddress(L2StandardBridge)
L2ERC721BridgeAddr = common.HexToAddress(L2ERC721Bridge)
Expand All @@ -44,7 +44,7 @@ func init() {
Predeploys["L2CrossDomainMessenger"] = &L2CrossDomainMessengerAddr
Predeploys["GasPriceOracle"] = &GasPriceOracleAddr
Predeploys["ProtocolVault"] = &ProtocolVaultAddr
Predeploys["ProposerRewardVault"] = &ProposerRewardVaultAddr
Predeploys["L1FeeVault"] = &L1FeeVaultAddr
Predeploys["ValidatorRewardVault"] = &ValidatorRewardVaultAddr
Predeploys["L2StandardBridge"] = &L2StandardBridgeAddr
Predeploys["L2ERC721Bridge"] = &L2ERC721BridgeAddr
Expand Down
2 changes: 1 addition & 1 deletion components/batcher/batch_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewBatchSubmitter(cfg Config, l log.Logger, m metrics.Metricer) (*BatchSubm

// loadBlocksIntoState loads all blocks since the previous stored block
// It does the following:
// 1. Fetch the sync status of the proposer
// 1. Fetch the sync status of the sequencer
// 2. Check if the sync status is valid or if we are all the way up to date
// 3. Check if it needs to initialize state OR it is lagging (todo: lagging just means race condition?)
// 4. Load all new blocks into the local state.
Expand Down
26 changes: 13 additions & 13 deletions components/batcher/channel_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
ErrMaxFrameIndex = errors.New("max frame index reached (uint16)")
ErrMaxDurationReached = errors.New("max channel duration reached")
ErrChannelTimeoutClose = errors.New("close to channel timeout")
ErrProposerWindowClose = errors.New("close to proposer window timeout")
ErrSeqWindowClose = errors.New("close to sequencer window timeout")
ErrTerminated = errors.New("channel terminated")
)

Expand All @@ -35,9 +35,9 @@ func (e *ChannelFullError) Unwrap() error {
}

type ChannelConfig struct {
// Number of epochs (L1 blocks) per proposing window, including the epoch
// Number of epochs (L1 blocks) per sequencing window, including the epoch
// L1 origin block itself
ProposerWindowSize uint64
SeqWindowSize uint64
// The maximum number of L1 blocks that the inclusion transactions of a
// channel's frames can span.
ChannelTimeout uint64
Expand All @@ -51,7 +51,7 @@ type ChannelConfig struct {
// If 0, duration checks are disabled.
MaxChannelDuration uint64
// The batcher tx submission safety margin (in #L1-blocks) to subtract from
// a channel's timeout and proposing window, to guarantee safe inclusion of
// a channel's timeout and sequencing window, to guarantee safe inclusion of
// a channel on L1.
SubSafetyMargin uint64
// The maximum byte-size a frame can have.
Expand Down Expand Up @@ -121,7 +121,7 @@ type channelBuilder struct {
// L1 block number timeout of combined
// - channel duration timeout,
// - consensus channel timeout,
// - proposing window timeout.
// - sequencing window timeout.
// 0 if no block number timeout set yet.
timeout uint64
// reason for currently set timeout
Expand Down Expand Up @@ -217,7 +217,7 @@ func (c *channelBuilder) AddBlock(block *types.Block) (derive.L1BlockInfo, error
return l1info, fmt.Errorf("adding block to channel out: %w", err)
}
c.blocks = append(c.blocks, block)
c.updatePwTimeout(batch)
c.updateSwTimeout(batch)

if c.inputTargetReached() {
c.setFullErr(ErrInputTargetReached)
Expand All @@ -232,7 +232,7 @@ func (c *channelBuilder) AddBlock(block *types.Block) (derive.L1BlockInfo, error
// RegisterL1Block should be called whenever a new L1-block is seen.
//
// It ensures proper tracking of all possible timeouts (max channel duration,
// close to consensus channel timeout, close to end of proposing window).
// close to consensus channel timeout, close to end of sequencing window).
func (c *channelBuilder) RegisterL1Block(l1BlockNum uint64) {
c.updateDurationTimeout(l1BlockNum)
c.checkTimeout(l1BlockNum)
Expand All @@ -259,13 +259,13 @@ func (c *channelBuilder) updateDurationTimeout(l1BlockNum uint64) {
c.updateTimeout(timeout, ErrMaxDurationReached)
}

// updatePwTimeout updates the block timeout with the proposer window timeout
// updateSwTimeout updates the block timeout with the sequencer window timeout
// derived from the batch's origin L1 block. The timeout is only moved forward
// if the derived proposer window timeout is earlier than the currently set
// if the derived sequencer window timeout is earlier than the currently set
// timeout.
func (c *channelBuilder) updatePwTimeout(batch *derive.BatchData) {
timeout := uint64(batch.EpochNum) + c.cfg.ProposerWindowSize - c.cfg.SubSafetyMargin
c.updateTimeout(timeout, ErrProposerWindowClose)
func (c *channelBuilder) updateSwTimeout(batch *derive.BatchData) {
timeout := uint64(batch.EpochNum) + c.cfg.SeqWindowSize - c.cfg.SubSafetyMargin
c.updateTimeout(timeout, ErrSeqWindowClose)
}

// updateTimeout updates the timeout block to the given block number if it is
Expand Down Expand Up @@ -318,7 +318,7 @@ func (c *channelBuilder) IsFull() bool {
// (uint16),
// - ErrMaxDurationReached if the max channel duration got reached,
// - ErrChannelTimeoutClose if the consensus channel timeout got too close,
// - ErrProposerWindowClose if the end of the proposer window got too close,
// - ErrSeqWindowClose if the end of the sequencer window got too close,
// - ErrTerminated if the channel was explicitly terminated.
func (c *channelBuilder) FullErr() error {
return c.fullErr
Expand Down
34 changes: 17 additions & 17 deletions components/batcher/channel_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

var defaultTestChannelConfig = ChannelConfig{
ProposerWindowSize: 15,
SeqWindowSize: 15,
ChannelTimeout: 40,
MaxChannelDuration: 1,
SubSafetyMargin: 4,
Expand Down Expand Up @@ -302,65 +302,65 @@ func FuzzChannelZeroCloseTimeout(f *testing.F) {
})
}

// FuzzProposerWindowClose ensures that the channel builder has a [ErrProposerWindowClose]
// FuzzSeqWindowClose ensures that the channel builder has a [ErrSeqWindowClose]
// as long as the timeout constraint is met and the builder's timeout is greater than
// the calculated timeout.
func FuzzProposerWindowClose(f *testing.F) {
func FuzzSeqWindowClose(f *testing.F) {
// Set multiple seeds in case fuzzing isn't explicitly used
for i := range [10]int{} {
f.Add(uint64(i), uint64(i), uint64(i), uint64(i*5))
}
f.Fuzz(func(t *testing.T, epochNum uint64, proposerWindowSize uint64, subSafetyMargin uint64, timeout uint64) {
f.Fuzz(func(t *testing.T, epochNum uint64, seqWindowSize uint64, subSafetyMargin uint64, timeout uint64) {
// Create the channel builder
channelConfig := defaultTestChannelConfig
channelConfig.ProposerWindowSize = proposerWindowSize
channelConfig.SeqWindowSize = seqWindowSize
channelConfig.SubSafetyMargin = subSafetyMargin
cb, err := newChannelBuilder(channelConfig)
require.NoError(t, err)

// Check the timeout
cb.timeout = timeout
cb.updatePwTimeout(&derive.BatchData{
cb.updateSwTimeout(&derive.BatchData{
BatchV1: derive.BatchV1{
EpochNum: rollup.Epoch(epochNum),
},
})
calculatedTimeout := epochNum + proposerWindowSize - subSafetyMargin
calculatedTimeout := epochNum + seqWindowSize - subSafetyMargin
if timeout > calculatedTimeout && calculatedTimeout != 0 {
cb.checkTimeout(calculatedTimeout)
require.ErrorIs(t, cb.FullErr(), ErrProposerWindowClose)
require.ErrorIs(t, cb.FullErr(), ErrSeqWindowClose)
} else {
require.NoError(t, cb.FullErr())
}
})
}

// FuzzProposerWindowZeroTimeoutClose ensures that the channel builder has a [ErrProposerWindowClose]
// FuzzSeqWindowZeroTimeoutClose ensures that the channel builder has a [ErrSeqWindowClose]
// as long as the timeout constraint is met and the builder's timeout is set to zero.
func FuzzProposerWindowZeroTimeoutClose(f *testing.F) {
func FuzzSeqWindowZeroTimeoutClose(f *testing.F) {
// Set multiple seeds in case fuzzing isn't explicitly used
for i := range [10]int{} {
f.Add(uint64(i), uint64(i), uint64(i))
}
f.Fuzz(func(t *testing.T, epochNum uint64, proposerWindowSize uint64, subSafetyMargin uint64) {
f.Fuzz(func(t *testing.T, epochNum uint64, seqWindowSize uint64, subSafetyMargin uint64) {
// Create the channel builder
channelConfig := defaultTestChannelConfig
channelConfig.ProposerWindowSize = proposerWindowSize
channelConfig.SeqWindowSize = seqWindowSize
channelConfig.SubSafetyMargin = subSafetyMargin
cb, err := newChannelBuilder(channelConfig)
require.NoError(t, err)

// Check the timeout
cb.timeout = 0
cb.updatePwTimeout(&derive.BatchData{
cb.updateSwTimeout(&derive.BatchData{
BatchV1: derive.BatchV1{
EpochNum: rollup.Epoch(epochNum),
},
})
calculatedTimeout := epochNum + proposerWindowSize - subSafetyMargin
calculatedTimeout := epochNum + seqWindowSize - subSafetyMargin
cb.checkTimeout(calculatedTimeout)
if cb.timeout != 0 {
require.ErrorIs(t, cb.FullErr(), ErrProposerWindowClose, "Proposer window close should be reached")
require.ErrorIs(t, cb.FullErr(), ErrSeqWindowClose, "Sequence window close should be reached")
}
})
}
Expand Down Expand Up @@ -583,8 +583,8 @@ func TestChannelBuilder_Reset(t *testing.T) {
// Check the fields reset in the Reset function
require.Equal(t, 1, len(cb.blocks))
require.Equal(t, 0, len(cb.frames))
// Timeout should be updated in the AddBlock internal call to `updatePwTimeout`
timeout := uint64(100) + cb.cfg.ProposerWindowSize - cb.cfg.SubSafetyMargin
// Timeout should be updated in the AddBlock internal call to `updateSwTimeout`
timeout := uint64(100) + cb.cfg.SeqWindowSize - cb.cfg.SubSafetyMargin
require.Equal(t, timeout, cb.timeout)
require.NoError(t, cb.fullErr)

Expand Down
4 changes: 2 additions & 2 deletions components/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type CLIConfig struct {
MaxChannelDuration uint64

// The batcher tx submission safety margin (in #L1-blocks) to subtract from
// a channel's timeout and proposing window, to guarantee safe inclusion of
// a channel's timeout and sequencing window, to guarantee safe inclusion of
// a channel on L1.
SubSafetyMargin uint64

Expand Down Expand Up @@ -183,7 +183,7 @@ func NewBatcherConfig(cfg CLIConfig, l log.Logger, m metrics.Metricer) (*Config,
TxManager: txManager,
Rollup: rcfg,
Channel: ChannelConfig{
ProposerWindowSize: rcfg.ProposerWindowSize,
SeqWindowSize: rcfg.SeqWindowSize,
ChannelTimeout: rcfg.ChannelTimeout,
MaxChannelDuration: cfg.MaxChannelDuration,
SubSafetyMargin: cfg.SubSafetyMargin,
Expand Down
2 changes: 1 addition & 1 deletion components/batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
SubSafetyMarginFlag = &cli.Uint64Flag{
Name: "sub-safety-margin",
Usage: "The batcher tx submission safety margin (in #L1-blocks) to subtract " +
"from a channel's timeout and proposing window, to guarantee safe inclusion " +
"from a channel's timeout and sequencing window, to guarantee safe inclusion " +
"of a channel on L1.",
Required: true,
EnvVars: kservice.PrefixEnvVar(envVarPrefix, "SUB_SAFETY_MARGIN"),
Expand Down
8 changes: 4 additions & 4 deletions components/node/chaincfg/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var Mainnet = rollup.Config{
},
},
BlockTime: 2,
MaxProposerDrift: 600,
ProposerWindowSize: 3600,
MaxSequencerDrift: 600,
SeqWindowSize: 3600,
ChannelTimeout: 300,
L1ChainID: big.NewInt(1),
L2ChainID: big.NewInt(255),
Expand Down Expand Up @@ -60,8 +60,8 @@ var Sepolia = rollup.Config{
},
},
BlockTime: 2,
MaxProposerDrift: 1200,
ProposerWindowSize: 3600,
MaxSequencerDrift: 1200,
SeqWindowSize: 3600,
ChannelTimeout: 120,
L1ChainID: big.NewInt(11155111),
L2ChainID: big.NewInt(2358),
Expand Down
2 changes: 1 addition & 1 deletion components/node/eth/sync_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type SyncStatus struct {
FinalizedL1 L1BlockRef `json:"finalized_l1"`
// UnsafeL2 is the absolute tip of the L2 chain,
// pointing to block data that has not been submitted to L1 yet.
// The proposer is building this, and verifiers may also be ahead of the
// The sequencer is building this, and verifiers may also be ahead of the
// SafeL2 block if they sync blocks via p2p or other offchain sources.
UnsafeL2 L2BlockRef `json:"unsafe_l2"`
// SafeL2 points to the L2 block that was derived from the L1 chain.
Expand Down
42 changes: 21 additions & 21 deletions components/node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,27 @@ var (
Required: false,
Value: 0,
}
ProposerEnabledFlag = &cli.BoolFlag{
Name: "proposer.enabled",
Usage: "Enable proposing of new L2 blocks. A separate batch submitter has to be deployed to publish the data for syncers.",
EnvVars: prefixEnvVar("PROPOSER_ENABLED"),
}
ProposerStoppedFlag = &cli.BoolFlag{
Name: "proposer.stopped",
Usage: "Initialize the proposer in a stopped state. The proposer can be started using the admin_startProposer RPC",
EnvVars: prefixEnvVar("PROPOSER_STOPPED"),
}
ProposerMaxSafeLagFlag = &cli.Uint64Flag{
Name: "proposer.max-safe-lag",
SequencerEnabledFlag = &cli.BoolFlag{
Name: "sequencer.enabled",
Usage: "Enable sequencing of new L2 blocks. A separate batch submitter has to be deployed to publish the data for syncers.",
EnvVars: prefixEnvVar("SEQUENCER_ENABLED"),
}
SequencerStoppedFlag = &cli.BoolFlag{
Name: "sequencer.stopped",
Usage: "Initialize the sequencer in a stopped state. The sequencer can be started using the admin_startSequencer RPC",
EnvVars: prefixEnvVar("SEQUENCER_STOPPED"),
}
SequencerMaxSafeLagFlag = &cli.Uint64Flag{
Name: "sequencer.max-safe-lag",
Usage: "Maximum number of L2 blocks for restricting the distance between L2 safe and unsafe. Disabled if 0.",
EnvVars: prefixEnvVar("PROPOSER_MAX_SAFE_LAG"),
EnvVars: prefixEnvVar("SEQUENCER_MAX_SAFE_LAG"),
Required: false,
Value: 0,
}
ProposerL1Confs = &cli.Uint64Flag{
Name: "proposer.l1-confs",
Usage: "Number of L1 blocks to keep distance from the L1 head as a proposer for picking an L1 origin.",
EnvVars: prefixEnvVar("PROPOSER_L1_CONFS"),
SequencerL1Confs = &cli.Uint64Flag{
Name: "sequencer.l1-confs",
Usage: "Number of L1 blocks to keep distance from the L1 head as a sequencer for picking an L1 origin.",
EnvVars: prefixEnvVar("SEQUENCER_L1_CONFS"),
Required: false,
Value: 4,
}
Expand Down Expand Up @@ -241,10 +241,10 @@ var optionalFlags = []cli.Flag{
L1HTTPPollInterval,
L2EngineJWTSecret,
SyncerL1Confs,
ProposerEnabledFlag,
ProposerStoppedFlag,
ProposerMaxSafeLagFlag,
ProposerL1Confs,
SequencerEnabledFlag,
SequencerStoppedFlag,
SequencerMaxSafeLagFlag,
SequencerL1Confs,
L1EpochPollIntervalFlag,
RPCEnableAdmin,
MetricsEnabledFlag,
Expand Down
Loading
Loading