Skip to content

Commit

Permalink
rollup registration, CreateRollup works for creation & update
Browse files Browse the repository at this point in the history
  • Loading branch information
bianyuanop committed Jan 8, 2025
1 parent 04688c7 commit 385d8ce
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions actions/rollup_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,25 @@ func (r *RollupRegistration) Execute(

switch r.OpCode {
case CreateRollup:
if contains(namespaces, r.Namespace) {
return nil, ErrNameSpaceAlreadyRegistered
if !contains(namespaces, r.Namespace) {
namespaces = append(namespaces, r.Namespace)
} else {
// 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: %s", err.Error())
}
}
if r.Info.StartEpoch < Epoch(hght, rules.GetEpochLength())+2 || r.Info.ExitEpoch != 0 {
return nil, fmt.Errorf("epoch number is not valid, minimum: %d, actual: %d, exit: %d", Epoch(hght, rules.GetEpochLength())+2, r.Info.StartEpoch, r.Info.ExitEpoch)
}
namespaces = append(namespaces, r.Namespace)
if r.Info.ExitEpoch != 0 {
return nil, fmt.Errorf("exit epoch not 0")
}

if err := storage.SetRollupInfo(ctx, mu, r.Namespace, &r.Info); err != nil {
return nil, fmt.Errorf("unable to set rollup info(CREATE): %s", err.Error())
}
// TODO: not useful as CreateRollup now handle both creation and update
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 {
Expand Down

0 comments on commit 385d8ce

Please sign in to comment.