Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manojkgorle committed Jan 8, 2025
1 parent 5d493a9 commit 13adad4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
16 changes: 8 additions & 8 deletions actions/rollup_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *RollupRegistration) Execute(

namespaces, err := storage.GetRollupRegistry(ctx, mu)
if err != nil {
return nil, fmt.Errorf("unable to get namespaces: %w", err.Error())
return nil, fmt.Errorf("unable to get namespaces: %w", err)
}

switch r.OpCode {
Expand All @@ -78,33 +78,33 @@ func (r *RollupRegistration) Execute(
}
namespaces = append(namespaces, r.Namespace)
if err := storage.SetRollupInfo(ctx, mu, r.Namespace, &r.Info); err != nil {
return nil, fmt.Errorf("unable to set rollup info(CREATE): %w", err.Error())
return nil, fmt.Errorf("unable to set rollup info(CREATE): %w", err)
}
case UpdateRollup:
// only allow modifing informations that are not related to ExitEpoch or StartEpoch
if err := authorizationChecks(ctx, actor, namespaces, r.Namespace, mu); err != nil {
return nil, fmt.Errorf("authorization failed(UPDATE): %w", err.Error())
return nil, fmt.Errorf("authorization failed(UPDATE): %w", err)
}

rollupInfoExists, err := storage.GetRollupInfo(ctx, mu, r.Namespace)
if err != nil {
return nil, fmt.Errorf("unable to get existing rollup info(UPDATE): %w", err.Error())
return nil, fmt.Errorf("unable to get existing rollup info(UPDATE): %w", err)
}

// rewrite epoch info
r.Info.ExitEpoch = rollupInfoExists.ExitEpoch
r.Info.StartEpoch = rollupInfoExists.StartEpoch

if err := storage.SetRollupInfo(ctx, mu, r.Namespace, &r.Info); err != nil {
return nil, fmt.Errorf("unable to set rollup info(UPDATE): %w", err.Error())
return nil, fmt.Errorf("unable to set rollup info(UPDATE): %w", err)
}
case ExitRollup:
if err := authorizationChecks(ctx, actor, namespaces, r.Namespace, mu); err != nil {
return nil, fmt.Errorf("unable to set rollup info(EXIT): %w", err.Error())
return nil, fmt.Errorf("unable to set rollup info(EXIT): %w", err)
}
rollupInfoExists, err := storage.GetRollupInfo(ctx, mu, r.Namespace)
if err != nil {
return nil, fmt.Errorf("unable to get existing rollup info(UPDATE): %w", err.Error())
return nil, fmt.Errorf("unable to get existing rollup info(UPDATE): %w", err)
}
if r.Info.ExitEpoch < rollupInfoExists.StartEpoch || r.Info.ExitEpoch < Epoch(hght, rules.GetEpochLength())+2 {
return nil, fmt.Errorf("(EXIT)epoch number is not valid, minimum: %d, actual: %d, start: %d", Epoch(hght, rules.GetEpochLength())+2, r.Info.ExitEpoch, rollupInfoExists.StartEpoch)
Expand All @@ -114,7 +114,7 @@ func (r *RollupRegistration) Execute(
r.Info.StartEpoch = rollupInfoExists.StartEpoch

if err := storage.SetRollupInfo(ctx, mu, r.Namespace, &r.Info); err != nil {
return nil, fmt.Errorf("unable to set rollup info(EXIT): %w", err.Error())
return nil, fmt.Errorf("unable to set rollup info(EXIT): %w", err)
}
default:
return nil, fmt.Errorf("op code(%d) not supported", r.OpCode)
Expand Down
5 changes: 2 additions & 3 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,19 @@ func (c *Controller) Accepted(ctx context.Context, blk *chain.StatelessBlock) er
}
if result.Success {
for _, act := range tx.Actions {
switch act.(type) {
switch act.(type) { //nolint:gocritic

Check failure on line 228 in controller/controller.go

View workflow job for this annotation

GitHub Actions / Lint

S1034: assigning the result of this type assertion to a variable (switch act := act.(type)) could eliminate type assertions in switch cases (gosimple)
case *actions.Transfer:
c.metrics.transfer.Inc()
case *actions.SequencerMsg:
c.metrics.sequencerMsg.Inc()
case *actions.Auction:
c.metrics.auction.Inc()
case *actions.RollupRegistration:
reg := act.(*actions.RollupRegistration)
reg := act.(*actions.RollupRegistration) //nolint:gosimple
rollups = append(rollups, &reg.Info)
c.metrics.rollupRegister.Inc()
case *actions.EpochExit:
c.metrics.epochExit.Inc()

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ find "${TMPDIR}"/avalanchego-"${VERSION}"
# Make sure to replace this address with your own address
# if you are starting your own devnet (otherwise anyone can access
# funds using the included demo.pk)
# total stake can allocate: 10000000000000000000, make sure it is below this or genesis won't load
# Sum of balances should be less than max uint64.
echo "creating allocations file"
cat <<EOF > "${TMPDIR}"/allocations.json
[
Expand Down
10 changes: 9 additions & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
)

const (
startAmount = uint64(10000000000000000000)
startAmount = uint64(1000000000000000000)
sendAmount = uint64(5000)

healthPollInterval = 10 * time.Second
Expand Down Expand Up @@ -903,6 +903,14 @@ var _ = ginkgo.Describe("[Test]", func() {

err = instances[0].wsCli.RegisterTx(tx)
require.NoError(err)
err = instances[1].wsCli.RegisterTx(tx)
require.NoError(err)
err = instances[2].wsCli.RegisterTx(tx)
require.NoError(err)
err = instances[3].wsCli.RegisterTx(tx)
require.NoError(err)
err = instances[4].wsCli.RegisterTx(tx)
require.NoError(err)
txID, txErr, result, err := instances[0].wsCli.ListenTx(ctx)
require.Equal(tx.ID(), txID)
require.NoError(err)
Expand Down

0 comments on commit 13adad4

Please sign in to comment.