-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from AnomalyFi/arcadia-rollup
Arcadia rollup
- Loading branch information
Showing
14 changed files
with
270 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import ( | |
"fmt" | ||
"net/http" | ||
|
||
hactions "github.com/AnomalyFi/hypersdk/actions" | ||
Check failure on line 11 in controller/controller.go GitHub Actions / seq-e2e-tests
Check failure on line 11 in controller/controller.go GitHub Actions / seq-e2e-tests
|
||
|
||
"github.com/AnomalyFi/hypersdk/builder" | ||
Check failure on line 13 in controller/controller.go GitHub Actions / seq-e2e-tests
Check failure on line 13 in controller/controller.go GitHub Actions / seq-e2e-tests
|
||
"github.com/AnomalyFi/hypersdk/chain" | ||
"github.com/AnomalyFi/hypersdk/fees" | ||
Check failure on line 15 in controller/controller.go GitHub Actions / seq-e2e-tests
Check failure on line 15 in controller/controller.go GitHub Actions / seq-e2e-tests
|
||
|
@@ -26,6 +28,7 @@ import ( | |
"github.com/AnomalyFi/nodekit-seq/config" | ||
"github.com/AnomalyFi/nodekit-seq/consts" | ||
"github.com/AnomalyFi/nodekit-seq/genesis" | ||
rollupregistry "github.com/AnomalyFi/nodekit-seq/rollup_registry" | ||
"github.com/AnomalyFi/nodekit-seq/rpc" | ||
"github.com/AnomalyFi/nodekit-seq/storage" | ||
"github.com/AnomalyFi/nodekit-seq/version" | ||
|
@@ -41,8 +44,9 @@ type Controller struct { | |
config *config.Config | ||
stateManager *StateManager | ||
|
||
jsonRPCServer *rpc.JSONRPCServer | ||
archiver *archiver.ORMArchiver | ||
jsonRPCServer *rpc.JSONRPCServer | ||
archiver *archiver.ORMArchiver | ||
rollupRegistry *rollupregistry.RollupRegistry | ||
|
||
metrics *metrics | ||
|
||
|
@@ -134,6 +138,8 @@ func (c *Controller) Initialize( | |
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err | ||
} | ||
|
||
c.rollupRegistry = rollupregistry.NewRollupRegistr() | ||
|
||
apis[rpc.JSONRPCEndpoint] = jsonRPCHandler | ||
|
||
// Create builder and gossiper | ||
|
@@ -199,6 +205,7 @@ func (c *Controller) Accepted(ctx context.Context, blk *chain.StatelessBlock) er | |
} | ||
}() | ||
|
||
rollups := make([]*hactions.RollupInfo, 0) | ||
results := blk.Results() | ||
for i, tx := range blk.Txs { | ||
result := results[i] | ||
|
@@ -223,10 +230,15 @@ func (c *Controller) Accepted(ctx context.Context, blk *chain.StatelessBlock) er | |
c.metrics.transfer.Inc() | ||
case *actions.SequencerMsg: | ||
c.metrics.sequencerMsg.Inc() | ||
case *actions.RollupRegistration: | ||
reg := act.(*actions.RollupRegistration) | ||
rollups = append(rollups, ®.Info) | ||
} | ||
} | ||
} | ||
} | ||
currentEpoch := blk.Hght / uint64(c.inner.Rules(blk.Tmstmp).GetEpochLength()) | ||
c.rollupRegistry.Update(currentEpoch, rollups) | ||
return batch.Write() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package rollupregistry | ||
|
||
import ( | ||
"maps" | ||
"sync" | ||
|
||
hactions "github.com/AnomalyFi/hypersdk/actions" | ||
"github.com/ava-labs/avalanchego/ids" | ||
) | ||
|
||
type RollupRegistryOnlyRead interface { | ||
RollupsValidAtEpoch(epoch uint64) []*hactions.RollupInfo | ||
} | ||
|
||
type RollupRegistryAllPerm interface { | ||
RollupRegistryOnlyRead | ||
Update(currentEpoch uint64, rollups []*hactions.RollupInfo) | ||
} | ||
|
||
var _ RollupRegistryAllPerm = (*RollupRegistry)(nil) | ||
|
||
type RollupRegistry struct { | ||
rollups map[ids.ID]*hactions.RollupInfo | ||
rollupsL sync.RWMutex | ||
} | ||
|
||
func NewRollupRegistr() *RollupRegistry { | ||
return &RollupRegistry{ | ||
rollups: make(map[ids.ID]*hactions.RollupInfo), | ||
} | ||
} | ||
|
||
func (r *RollupRegistry) RollupsValidAtEpoch(epoch uint64) []*hactions.RollupInfo { | ||
r.rollupsL.RLock() | ||
defer r.rollupsL.RUnlock() | ||
|
||
ret := make([]*hactions.RollupInfo, 0) | ||
for _, rollup := range r.rollups { | ||
if !rollup.ValidAtEpoch(epoch) { | ||
continue | ||
} | ||
|
||
ret = append(ret, rollup) | ||
} | ||
|
||
return ret | ||
} | ||
|
||
func (r *RollupRegistry) Update(currentEpoch uint64, rollups []*hactions.RollupInfo) { | ||
r.rollupsL.Lock() | ||
defer r.rollupsL.Unlock() | ||
|
||
for _, rollup := range rollups { | ||
r.rollups[rollup.ID()] = rollup | ||
} | ||
|
||
maps.DeleteFunc(r.rollups, func(_ ids.ID, rollup *hactions.RollupInfo) bool { | ||
return rollup.Exited(currentEpoch) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.