Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed May 15, 2024
1 parent b5d0f0f commit 0b3b95e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions p2p/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ func (c *Client) setupGossiping(ctx context.Context) error {
pubsub.GossipSubHistoryGossip = c.conf.GossipCacheSize
pubsub.GossipSubHistoryLength = c.conf.GossipCacheSize

//We add WithSeenMessagesTTL (with 1 year time) option to avoid ever requesting already seen blocks
// We add WithSeenMessagesTTL (with 1 year time) option to avoid ever requesting already seen blocks
ps, err := pubsub.NewGossipSub(ctx, c.Host)
if err != nil {
return err
}

//tx gossiper receives the tx to add to the mempool through validation process, since it is a joint process
// tx gossiper receives the tx to add to the mempool through validation process, since it is a joint process
c.txGossiper, err = NewGossiper(c.Host, ps, c.getTxTopic(), nil, c.logger, WithValidator(c.txValidator))
if err != nil {
return err
Expand Down
19 changes: 9 additions & 10 deletions p2p/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ func TestValidator_TxValidator(t *testing.T) {
}

func TestValidator_BlockValidator(t *testing.T) {

//Create proposer for the block
// Create proposer for the block
proposerKey := ed25519.GenPrivKey()
//Create another key
// Create another key
attackerKey := ed25519.GenPrivKey()

tests := []struct {
Expand All @@ -120,7 +119,7 @@ func TestValidator_BlockValidator(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
logger := log.TestingLogger()

//Create Block executor
// Create Block executor
app := &tmmocks.MockApplication{}

clientCreator := proxy.NewLocalClientCreator(app)
Expand All @@ -133,17 +132,17 @@ func TestValidator_BlockValidator(t *testing.T) {
executor, err := block.NewExecutor([]byte("test address"), namespaceId, "test", mpool, proxy.NewAppConns(clientCreator), nil, logger)
assert.NoError(t, err)

//Create state
// Create state
maxBytes := uint64(100)
state := types.State{}
state.ConsensusParams.Block.MaxBytes = int64(maxBytes)
state.ConsensusParams.Block.MaxGas = 100000
state.Validators = tmtypes.NewValidatorSet(nil)

//Create empty block
// Create empty block
block := executor.CreateBlock(1, &types.Commit{}, [32]byte{}, state, maxBytes)

//Create slclient
// Create slclient
client := registry.GetClient(registry.Local)
pubsubServer := pubsub.NewServer()
err = pubsubServer.Start()
Expand All @@ -169,16 +168,16 @@ func TestValidator_BlockValidator(t *testing.T) {
Signatures: []types.Signature{signature},
}

//Create gossiped block
// Create gossiped block
gossipedBlock := p2p.GossipedBlock{Block: *block, Commit: *commit}
gossipedBlockBytes, err := gossipedBlock.MarshalBinary()
require.NoError(t, err)
var blockMsg = &p2p.GossipMessage{
blockMsg := &p2p.GossipMessage{
Data: gossipedBlockBytes,
From: peer.ID("from"),
}

//Check block validity
// Check block validity
validateBlock := p2p.NewValidator(logger, client).BlockValidator()
valid := validateBlock(blockMsg)
require.Equal(t, tt.valid, valid)
Expand Down
6 changes: 3 additions & 3 deletions settlement/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (b *BaseLayerClient) Init(config Config, pubsub *pubsub.Server, logger type
apply(b)
}

//TODO(srene): For a correct validation, sequencer list would need to be updated after a sequencer list change on the Hub.
//e.g. after receiving an event from the Hub. Right now, node will need to be restarted after a sequencer change, since it is
//only getting the sequencers list during Init.
// TODO(srene): For a correct validation, sequencer list would need to be updated after a sequencer list change on the Hub.
// e.g. after receiving an event from the Hub. Right now, node will need to be restarted after a sequencer change, since it is
// only getting the sequencers list during Init.
b.sequencersList, err = b.fetchSequencersList()
if err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions settlement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ const (

// Convenience objects

var (
EventNewBatchAcceptedList = map[string][]string{EventTypeKey: {EventNewBatchAccepted}}
)
var EventNewBatchAcceptedList = map[string][]string{EventTypeKey: {EventNewBatchAccepted}}

// Data

Expand Down

0 comments on commit 0b3b95e

Please sign in to comment.