Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes for Arcadia #26

Merged
merged 25 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions actions/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"encoding/binary"
"fmt"

hactions "github.com/AnomalyFi/hypersdk/actions"
"github.com/AnomalyFi/hypersdk/chain"
"github.com/AnomalyFi/hypersdk/codec"
"github.com/AnomalyFi/hypersdk/consts"
Expand Down Expand Up @@ -51,7 +52,7 @@
return AuctionID
}

func (a *Auction) StateKeys(actor codec.Address, _ ids.ID) state.Keys {

Check failure on line 55 in actions/auction.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'actor' seems to be unused, consider removing or renaming it as _ (revive)
return state.Keys{
string(storage.BalanceKey(a.AuctionInfo.BuilderSEQAddress)): state.Read | state.Write,
string(storage.BalanceKey(ArcadiaFundAddress())): state.All,
Expand All @@ -60,7 +61,7 @@
}

func (*Auction) StateKeysMaxChunks() []uint16 {
return []uint16{storage.BalanceChunks, storage.BalanceChunks, storage.EpochExitsChunks}
return []uint16{storage.BalanceChunks, storage.BalanceChunks, hactions.EpochExitsChunks}
}

// This is a permissioned action, only authorized address can pass the execution.
Expand Down Expand Up @@ -92,7 +93,7 @@
msg := make([]byte, 16)
binary.BigEndian.PutUint64(msg[:8], a.AuctionInfo.EpochNumber)
binary.BigEndian.PutUint64(msg[8:], a.AuctionInfo.BidPrice)
msg = append(msg, a.BuilderPublicKey...)
msg = append(msg, a.AuctionInfo.BuilderSEQAddress[:]...)
sig, err := bls.SignatureFromBytes(a.BuilderSignature)
if err != nil {
return nil, fmt.Errorf("failed to parse signature: %w", err)
Expand Down Expand Up @@ -129,7 +130,7 @@
return AuctionComputeUnits
}

func (a *Auction) Size() int {

Check failure on line 133 in actions/auction.go

View workflow job for this annotation

GitHub Actions / Lint

unused-receiver: method receiver 'a' is not referenced in method's body, consider removing or renaming it as _ (revive)
return 2*consts.Uint64Len + bls.PublicKeyLen + bls.SignatureLen + codec.AddressLen
}

Expand Down
1 change: 0 additions & 1 deletion actions/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package actions
const (
TransferID uint8 = 0
MsgID uint8 = 1
ExitID uint8 = 2
AuctionID uint8 = 3
)

Expand Down
18 changes: 9 additions & 9 deletions actions/epoch_exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
)

type EpochExit struct {
Info storage.EpochInfo `json:"info"`
Epoch uint64 `json:"epoch"`
OpCode int `json:"opcode"`
Info hactions.EpochInfo `json:"info"`
Epoch uint64 `json:"epoch"`
OpCode int `json:"opcode"`
manojkgorle marked this conversation as resolved.
Show resolved Hide resolved
}

func (*EpochExit) GetTypeID() uint8 {
return ExitID
return hactions.EpochExitID
}

func (e *EpochExit) StateKeys(actor codec.Address, _ ids.ID) state.Keys {

Check failure on line 36 in actions/epoch_exit.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'actor' seems to be unused, consider removing or renaming it as _ (revive)
return state.Keys{
string(storage.EpochExitsKey(e.Epoch)): state.All,
string(hactions.EpochExitsKey(e.Epoch)): state.All,
string(storage.RollupInfoKey(e.Info.Namespace)): state.Read,
string(storage.RollupRegistryKey()): state.Read,
}
}

func (*EpochExit) StateKeysMaxChunks() []uint16 {
return []uint16{storage.EpochExitsChunks, hactions.RollupInfoChunks, hactions.RollupRegistryChunks}
return []uint16{hactions.EpochExitsChunks, hactions.RollupInfoChunks, hactions.RollupRegistryChunks}
}

// TODO: Add check for curr epoch > start epoch of arcadia.
Expand All @@ -50,7 +50,7 @@
ctx context.Context,
_ chain.Rules,
mu state.Mutable,
ts int64,

Check failure on line 53 in actions/epoch_exit.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'ts' seems to be unused, consider removing or renaming it as _ (revive)
_ uint64,
actor codec.Address,
_ ids.ID,
Expand Down Expand Up @@ -95,8 +95,8 @@
}
}
if !exists {
epochExits = new(storage.EpochExitInfo)
epochExits.Exits = make([]*storage.EpochInfo, 0)
epochExits = new(hactions.EpochExitInfo)
epochExits.Exits = make([]*hactions.EpochInfo, 0)
}
epochExits.Exits = append(epochExits.Exits, &e.Info)
if err := storage.SetEpochExits(ctx, mu, e.Epoch, epochExits); err != nil {
Expand Down Expand Up @@ -137,14 +137,14 @@
}

func (e *EpochExit) Marshal(p *codec.Packer) {
e.Info.Marshal(p)

Check failure on line 140 in actions/epoch_exit.go

View workflow job for this annotation

GitHub Actions / Lint

Error return value of `e.Info.Marshal` is not checked (errcheck)
p.PackUint64(e.Epoch)
p.PackInt(e.OpCode)
}

func UnmarshalEpochExit(p *codec.Packer) (chain.Action, error) {
var epoch EpochExit
info, err := storage.UnmarshalEpochInfo(p)
info, err := hactions.UnmarshalEpochInfo(p)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion actions/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ func authorizationChecks(ctx context.Context, actor codec.Address, namespaces []
}

func Epoch(blockHeight uint64, epochLength int64) uint64 {
return uint64(int64(blockHeight) / epochLength)
return blockHeight / uint64(epochLength)
}
4 changes: 2 additions & 2 deletions auth/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import "github.com/AnomalyFi/hypersdk/vm"

// Note: Registry will error during initialization if a duplicate ID is assigned. We explicitly assign IDs to avoid accidental remapping.
const (
ed25519ID uint8 = 0
Ed25519ID uint8 = 0
BLSID uint8 = 1
)

func Engines() map[uint8]vm.AuthEngine {
return map[uint8]vm.AuthEngine{
ed25519ID: &ED25519AuthEngine{},
Ed25519ID: &ED25519AuthEngine{},
}
}
4 changes: 2 additions & 2 deletions auth/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (d *ED25519) address() codec.Address {
}

func (*ED25519) GetTypeID() uint8 {
return ed25519ID
return Ed25519ID
}

func (*ED25519) ComputeUnits(chain.Rules) uint64 {
Expand Down Expand Up @@ -153,5 +153,5 @@ func (b *ED25519Batch) Done() []func() error {
}

func NewED25519Address(pk ed25519.PublicKey) codec.Address {
return codec.CreateAddress(ed25519ID, utils.ToID(pk[:]))
return codec.CreateAddress(Ed25519ID, utils.ToID(pk[:]))
}
16 changes: 9 additions & 7 deletions cmd/seq-cli/cmd/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var sequencerMsgCmd = &cobra.Command{
}

var anchorCmd = &cobra.Command{
Use: "anchor",
Use: "rollup-register",
RunE: func(*cobra.Command, []string) error {
ctx := context.Background()
_, _, factory, cli, scli, tcli, err := handler.DefaultActor()
Expand All @@ -128,15 +128,17 @@ var anchorCmd = &cobra.Command{
}

info := hactions.RollupInfo{
manojkgorle marked this conversation as resolved.
Show resolved Hide resolved
FeeRecipient: feeRecipient,
Namespace: namespace,
FeeRecipient: feeRecipient,
Namespace: namespace,
AuthoritySEQAddress: feeRecipient,
}

e, _ := cli.GetCurrentEpoch()
// Generate transaction
_, err = sendAndWait(ctx, []chain.Action{&actions.RollupRegistration{
Namespace: namespace,
Info: info,
OpCode: op,
Namespace: namespace,
Info: info,
OpCode: op,
StartEpoch: e + 4,
}}, cli, scli, tcli, factory, 0, true)
return err
},
Expand Down
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Config struct {
AnchorURL string `json:"anchorURL"`
AnchorManager string `json:"anchorManager"`

// Arcadia
ArcadiaURL string `json:"arcadiaURL"`

loaded bool
nodeID ids.NodeID
parsedExemptSponsors []codec.Address
Expand Down Expand Up @@ -149,6 +152,7 @@ func (c *Config) setDefault() {
c.ETHWSAddr = c.Config.GetETHL1WS()
c.AnchorURL = c.Config.GetAnchorURL()
c.AnchorManager = c.Config.GetAnchorManager()
c.ArcadiaURL = c.Config.GetArcadiaURL()
}

func (c *Config) GetLogLevel() logging.Level { return c.LogLevel }
Expand Down Expand Up @@ -192,6 +196,7 @@ func (c *Config) Loaded() bool { return c.loaded }
func (c *Config) GetETHL1RPC() string { return c.ETHRPCAddr }
func (c *Config) GetETHL1WS() string { return c.ETHWSAddr }
func (c *Config) GetAnchorURL() string { return c.AnchorURL }
func (c *Config) GetArcadiaURL() string { return c.ArcadiaURL }
func (c *Config) GetAnchorManager() string {
return c.AnchorManager
} // default bls pubkey for anchor manager
Expand Down
2 changes: 1 addition & 1 deletion controller/resolutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *Controller) GetRollupRegistryFromState(
func (c *Controller) GetEpochExitsFromState(
ctx context.Context,
epoch uint64,
) (*storage.EpochExitInfo, error) {
) (*hactions.EpochExitInfo, error) {
info, err := storage.GetEpochExitsFromState(ctx, c.inner.ReadState, epoch)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/AnomalyFi/nodekit-seq
go 1.21.12

require (
github.com/AnomalyFi/hypersdk v0.9.7
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.6
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0
github.com/ava-labs/avalanchego v1.11.10
github.com/ethereum/go-ethereum v1.13.14
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AnomalyFi/hypersdk v0.9.7 h1:D/a7kzR1+uScVa4qqn75kViK3JtTI4qsYIfwZZCYro8=
github.com/AnomalyFi/hypersdk v0.9.7/go.mod h1:4vquPvlEBs4i3uApYzE73Ghv/hB2GdFybf0m8fnU3DU=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.5 h1:wWmO2EL0scPPkShDWLVfTOcFWIXxSjz+oMsv0z4pblA=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.5/go.mod h1:4vquPvlEBs4i3uApYzE73Ghv/hB2GdFybf0m8fnU3DU=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.6 h1:bfT4yHJkgrri96owt4PN+hrV/tubbCC/DeAElXS/niM=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.6/go.mod h1:5MqhGibHMjO2EV3RhfvkUg5a/aJS1UOliOUsphRAkZY=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
Expand Down Expand Up @@ -70,8 +72,6 @@ github.com/ava-labs/avalanchego v1.11.10 h1:QujciF5OEp5FwAoe/RciFF/i47rxU5rkEr6f
github.com/ava-labs/avalanchego v1.11.10/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade h1:HYR7GSyVypZIhtl9t3Vqo5fiR+yThNWNH3O9sehdBDQ=
github.com/ava-labs/coreth v0.13.8-fixed-genesis-upgrade/go.mod h1:cm5c12xo5NiTgtbmeduv8i2nYdzgkczz9Wm3yiwwTRU=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
3 changes: 1 addition & 2 deletions rpc/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/AnomalyFi/hypersdk/fees"
"github.com/AnomalyFi/nodekit-seq/archiver"
"github.com/AnomalyFi/nodekit-seq/genesis"
"github.com/AnomalyFi/nodekit-seq/storage"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/trace"
"github.com/ava-labs/avalanchego/utils/logging"
Expand All @@ -25,7 +24,7 @@ type Controller interface {
Tracer() trace.Tracer
GetTransaction(context.Context, ids.ID) (bool, int64, bool, fees.Dimensions, uint64, error)
GetBalanceFromState(context.Context, codec.Address) (uint64, error)
GetEpochExitsFromState(ctx context.Context, epoch uint64) (*storage.EpochExitInfo, error)
GetEpochExitsFromState(ctx context.Context, epoch uint64) (*hactions.EpochExitInfo, error)
GetBuilderFromState(ctx context.Context, epoch uint64) ([]byte, error)
GetRollupInfoFromState(ctx context.Context, namespace []byte) (*hactions.RollupInfo, error)
GetRollupRegistryFromState(ctx context.Context) ([][]byte, error)
Expand Down
3 changes: 1 addition & 2 deletions rpc/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/AnomalyFi/nodekit-seq/consts"
"github.com/AnomalyFi/nodekit-seq/genesis"
_ "github.com/AnomalyFi/nodekit-seq/registry" // ensure registry populated
"github.com/AnomalyFi/nodekit-seq/storage"
"github.com/AnomalyFi/nodekit-seq/types"
)

Expand Down Expand Up @@ -290,7 +289,7 @@ func (cli *JSONRPCClient) GetRollupInfo(ctx context.Context, namespace []byte) (
return &resp.Info, err
}

func (cli *JSONRPCClient) GetEpochExits(ctx context.Context, epoch uint64) (*storage.EpochExitInfo, error) {
func (cli *JSONRPCClient) GetEpochExits(ctx context.Context, epoch uint64) (*hactions.EpochExitInfo, error) {
resp := new(types.EpochExitsReply)
args := &types.EpochExitsArgs{Epoch: epoch}
err := cli.requester.SendRequest(
Expand Down
6 changes: 5 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ UNLIMITED_USAGE=${UNLIMITED_USAGE:-false}
STORE_BLOCK_RESULTS_ON_DISK=${STORE_BLOCK_RESULTS_ON_DISK:-true}
ETHL1RPC=${ETHL1RPC:-http://localhost:8545}
ETHL1WS=${ETHL1WS:-ws://localhost:8546}
ARCADIA_URL=${ARCADIA_URL:-http://localhost:12345}
ADDRESS=${ADDRESS:-seq1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjlydh3t}
if [[ ${MODE} != "run" ]]; then
LOG_LEVEL=INFO
Expand All @@ -50,7 +51,7 @@ if compgen -G "$DB_PATH" > /dev/null; then
fi

WINDOW_TARGET_UNITS="40000000,450000,450000,450000,450000"
MAX_BLOCK_UNITS="1800000,15000,15000,2500,15000"
MAX_BLOCK_UNITS="1800000,15000,15000,10000,15000"
if ${UNLIMITED_USAGE}; then
WINDOW_TARGET_UNITS="${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64}"
# If we don't limit the block size, AvalancheGo will reject the block.
Expand Down Expand Up @@ -180,10 +181,13 @@ cat <<EOF > "${TMPDIR}"/seqvm.config
"streamingBacklogSize": 10000000,
"logLevel": "${LOG_LEVEL}",
"continuousProfilerDir":"${TMPDIR}/seqvm-e2e-profiles/*",
"traceEnabled":true,
"traceSampleRate":1,
"stateSyncServerDelay": ${STATESYNC_DELAY},
"storeBlockResultsOnDisk": ${STORE_BLOCK_RESULTS_ON_DISK},
"ethRPCAddr": "${ETHL1RPC}",
"ethWSAddr": "${ETHL1WS}",
"arcadiaURL": "${ARCADIA_URL}",
"archiverConfig": {
"enabled": true,
"archiverType": "sqlite",
Expand Down
Empty file modified scripts/tests.load.sh
100644 → 100755
Empty file.
10 changes: 3 additions & 7 deletions storage/arcadia.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import (
"context"
"encoding/binary"

"github.com/AnomalyFi/hypersdk/consts"
hactions "github.com/AnomalyFi/hypersdk/actions"
"github.com/AnomalyFi/hypersdk/state"
"github.com/ava-labs/avalanchego/database"
)

func ArcadiaBidKey(epoch uint64) []byte {
k := make([]byte, 1+8+consts.Uint16Len)
k[0] = ArcadiaBidPrefix
binary.BigEndian.PutUint64(k[1:], epoch)
binary.BigEndian.PutUint16(k[9:], EpochExitsChunks)
return k
return hactions.ArcadiaBidKey(epoch)
}

func StoreArcadiaBidInfo(
Expand Down Expand Up @@ -46,7 +42,7 @@ func GetArcadiaBidValue(
return binary.BigEndian.Uint64(v[:8]), nil
}

func GetArcadiaBidderInfoAndSignature(
func GetArcadiaBuilderInfoAndSignature(
ctx context.Context,
im state.Immutable,
epoch uint64,
Expand Down
Loading
Loading