Skip to content

Commit

Permalink
fix(code standards): use 'sequencer' instead of 'aggregator' (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored May 15, 2024
1 parent feb40f2 commit bd3c97d
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 96 deletions.
2 changes: 1 addition & 1 deletion block/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (e *Executor) CreateBlock(height uint64, lastCommit *types.Commit, lastHead
}
copy(block.Header.LastCommitHash[:], e.getLastCommitHash(lastCommit, &block.Header))
copy(block.Header.DataHash[:], e.getDataHash(block))
copy(block.Header.AggregatorsHash[:], state.Validators.Hash())
copy(block.Header.SequencersHash[:], state.Validators.Hash())

return block
}
Expand Down
12 changes: 6 additions & 6 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ func (m *Manager) Start(ctx context.Context) error {
m.logger.Info("Starting the block manager")

// Check if proposer key matches to the one in the settlement layer
var isAggregator bool
var isSequencer bool
slProposerKey := m.SLClient.GetProposer().PublicKey.Bytes()
localProposerKey, err := m.ProposerKey.GetPublic().Raw()
if err != nil {
return fmt.Errorf("get local node public key: %w", err)
}
if bytes.Equal(slProposerKey, localProposerKey) {
m.logger.Info("Starting in aggregator mode")
isAggregator = true
m.logger.Info("Starting in sequencer mode")
isSequencer = true
} else {
m.logger.Info("Starting in non-aggregator mode")
m.logger.Info("Starting in non-sequencer mode")
}

// Check if InitChain flow is needed
Expand All @@ -151,7 +151,7 @@ func (m *Manager) Start(ctx context.Context) error {
}
}

if !isAggregator {
if !isSequencer {
go uevent.MustSubscribe(ctx, m.Pubsub, "applyGossipedBlocksLoop", p2p.EventQueryNewNewGossipedBlock, m.onNewGossipedBlock, m.logger)
}

Expand All @@ -160,7 +160,7 @@ func (m *Manager) Start(ctx context.Context) error {
return fmt.Errorf("sync block manager: %w", err)
}

if isAggregator {
if isSequencer {
// TODO: populate the accumulatedSize on startup
go m.ProduceBlockLoop(ctx)
go m.SubmitLoop(ctx)
Expand Down
2 changes: 1 addition & 1 deletion block/synctarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// SyncTargetLoop is responsible for getting real time updates about settlement batch submissions.
// For non aggregator: updating the sync target which will be used by retrieveLoop to sync until this target.
// For non sequencer: updating the sync target which will be used by retrieveLoop to sync until this target.
// It publishes new sync height targets which will then be synced by another process.
func (m *Manager) SyncTargetLoop(ctx context.Context) {
m.logger.Info("Started sync target loop")
Expand Down
6 changes: 3 additions & 3 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func AddNodeFlags(cmd *cobra.Command) {

cmd.Flags().String(FlagDALayer, def.DALayer, "Data Availability Layer Client name (mock or grpc")
cmd.Flags().String(FlagDAConfig, def.DAConfig, "Data Availability Layer Client config")
cmd.Flags().Duration(FlagBlockTime, def.BlockTime, "block time (for aggregator mode)")
cmd.Flags().Duration(FlagMaxIdleTime, def.MaxIdleTime, "max time for empty blocks (for aggregator mode)")
cmd.Flags().Duration(FlagBatchSubmitMaxTime, def.BatchSubmitMaxTime, "max time for batch submit (for aggregator mode)")
cmd.Flags().Duration(FlagBlockTime, def.BlockTime, "block time (for sequencer mode)")
cmd.Flags().Duration(FlagMaxIdleTime, def.MaxIdleTime, "max time for empty blocks (for sequencer mode)")
cmd.Flags().Duration(FlagBatchSubmitMaxTime, def.BatchSubmitMaxTime, "max time for batch submit (for sequencer mode)")
cmd.Flags().String(FlagNamespaceID, def.NamespaceID, "namespace identifies (8 bytes in hex)")
cmd.Flags().Uint64(FlagBlockBatchMaxSizeBytes, def.BlockBatchMaxSizeBytes, "block batch size in bytes")

Expand Down
2 changes: 1 addition & 1 deletion node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestStartup(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

// TODO(omritoptix): Test with and without aggregator mode.
// TODO(omritoptix): Test with and without sequencer mode.
node, err := testutil.CreateNode(false, nil)
require.NoError(err)
require.NotNil(node)
Expand Down
6 changes: 3 additions & 3 deletions proto/types/dymint/dymint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ message Header {
// Previous block info
bytes last_header_hash = 5;

// Commit from aggregator(s) from the last block
// Commit from sequencers(s) from the last block
bytes last_commit_hash = 6;

// Block.Data root aka Transactions
Expand All @@ -52,8 +52,8 @@ message Header {
// pubkey can't be recovered by the signature (e.g. ed25519).
bytes proposer_address = 11;

// Hash of block aggregator set, at a time of block creation
bytes aggregators_hash = 12;
// Hash of block sequencer set, at a time of block creation
bytes sequencers_hash = 12;

// Chain ID the block belongs to
string chain_id = 13;
Expand Down
14 changes: 7 additions & 7 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func TestTx(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

mockApp, rpc := getRPCAggregator(t)
mockApp, rpc := getRPCSequencer(t)

require.NotNil(rpc)
mockApp.On("BeginBlock", mock.Anything).Return(abci.ResponseBeginBlock{})
Expand Down Expand Up @@ -812,17 +812,17 @@ func getBlockMeta(rpc *Client, n int64) *tmtypes.BlockMeta {
return bmeta
}

// getRPC returns a mock application and a new RPC client (non-aggregator mode)
// getRPC returns a mock application and a new RPC client (non-sequencer mode)
func getRPC(t *testing.T) (*tmmocks.MockApplication, *Client) {
return getRPCInternal(t, false)
}

func getRPCAggregator(t *testing.T) (*tmmocks.MockApplication, *Client) {
func getRPCSequencer(t *testing.T) (*tmmocks.MockApplication, *Client) {
return getRPCInternal(t, true)
}

// getRPC returns a mock application and a new RPC client (non-aggregator mode)
func getRPCInternal(t *testing.T, aggregator bool) (*tmmocks.MockApplication, *Client) {
// getRPC returns a mock application and a new RPC client (non-sequencer mode)
func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *Client) {
t.Helper()
require := require.New(t)
app := &tmmocks.MockApplication{}
Expand All @@ -836,7 +836,7 @@ func getRPCInternal(t *testing.T, aggregator bool) (*tmmocks.MockApplication, *C
proposerKey := hex.EncodeToString(pubkeyBytes)
require.NoError(err)

if aggregator {
if sequencer {
localKey = slSeqKey
}

Expand Down Expand Up @@ -868,7 +868,7 @@ func getRPCInternal(t *testing.T, aggregator bool) (*tmmocks.MockApplication, *C
context.Background(),
config,
key,
localKey, // this is where aggregator mode is set. if same key as in settlement.Config, it's aggregator
localKey, // this is where sequencer mode is set. if same key as in settlement.Config, it's sequencer
proxy.NewLocalClientCreator(app),
&tmtypes.GenesisDoc{ChainID: rollappID},
log.TestingLogger(),
Expand Down
2 changes: 1 addition & 1 deletion rpc/json/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestSubscription(t *testing.T) {
assert.Contains(jsonResp.Error.Message, "subscription not found")
}

// getRPC returns a mock ABCI application and a local client. (aggregator-mode)
// getRPC returns a mock ABCI application and a local client. (sequencer-mode)
func getRPC(t *testing.T) (*tmmocks.MockApplication, *client.Client) {
t.Helper()
require := require.New(t)
Expand Down
2 changes: 1 addition & 1 deletion testutil/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/dymensionxyz/dymint/settlement"
)

func CreateNode(isAggregator bool, blockManagerConfig *config.BlockManagerConfig) (*node.Node, error) {
func CreateNode(isSequencer bool, blockManagerConfig *config.BlockManagerConfig) (*node.Node, error) {
app := GetAppMock()
key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
signingKey, pubkey, _ := crypto.GenerateEd25519Key(rand.Reader)
Expand Down
2 changes: 1 addition & 1 deletion testutil/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func generateBlock(height uint64) *types.Block {
AppHash: [32]byte{},
LastResultsHash: getEmptyLastResultsHash(),
ProposerAddress: []byte{4, 3, 2, 1},
AggregatorsHash: h[6],
SequencersHash: h[6],
},
Data: types.Data{
Txs: nil,
Expand Down
6 changes: 3 additions & 3 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Header struct {
LastHeaderHash [32]byte

// hashes of block data
LastCommitHash [32]byte // commit from aggregator(s) from the last block
LastCommitHash [32]byte // commit from sequencer(s) from the last block
DataHash [32]byte // Block.Data root aka Transactions
ConsensusHash [32]byte // consensus params for current block
AppHash [32]byte // state after applying txs from the current block
Expand All @@ -38,8 +38,8 @@ type Header struct {
// pubkey can't be recovered by the signature (e.g. ed25519).
ProposerAddress []byte // original proposer of the block

// Hash of block aggregator set, at a time of block creation
AggregatorsHash [32]byte
// Hash of block sequencer set, at a time of block creation
SequencersHash [32]byte

// The Chain ID
ChainID string
Expand Down
8 changes: 4 additions & 4 deletions types/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func ToABCIHeaderPB(header *Header) types.Header {
},
LastCommitHash: header.LastCommitHash[:],
DataHash: header.DataHash[:],
ValidatorsHash: header.AggregatorsHash[:],
NextValidatorsHash: header.AggregatorsHash[:],
ValidatorsHash: header.SequencersHash[:],
NextValidatorsHash: header.SequencersHash[:],
ConsensusHash: header.ConsensusHash[:],
AppHash: header.AppHash[:],
LastResultsHash: header.LastResultsHash[:],
Expand Down Expand Up @@ -57,8 +57,8 @@ func ToABCIHeader(header *Header) tmtypes.Header {
},
LastCommitHash: header.LastCommitHash[:],
DataHash: header.DataHash[:],
ValidatorsHash: header.AggregatorsHash[:],
NextValidatorsHash: header.AggregatorsHash[:],
ValidatorsHash: header.SequencersHash[:],
NextValidatorsHash: header.SequencersHash[:],
ConsensusHash: header.ConsensusHash[:],
AppHash: header.AppHash[:],
LastResultsHash: header.LastResultsHash[:],
Expand Down
4 changes: 2 additions & 2 deletions types/hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (h *Header) Hash() [32]byte {
},
LastCommitHash: h.LastCommitHash[:],
DataHash: h.DataHash[:],
ValidatorsHash: h.AggregatorsHash[:],
NextValidatorsHash: h.AggregatorsHash[:],
ValidatorsHash: h.SequencersHash[:],
NextValidatorsHash: h.SequencersHash[:],
ConsensusHash: h.ConsensusHash[:],
AppHash: h.AppHash[:],
LastResultsHash: h.LastResultsHash[:],
Expand Down
Loading

0 comments on commit bd3c97d

Please sign in to comment.