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

Arcadia devnet fixes #30

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 15 additions & 5 deletions actions/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"context"
"crypto/sha256"
"encoding/binary"
"fmt"

Expand All @@ -25,6 +26,14 @@
BuilderSEQAddress codec.Address `json:"builderSEQAddress"`
}

func (a *AuctionInfo) HashAuctionInfo() ([32]byte, error) {

Check failure on line 29 in actions/auction.go

View workflow job for this annotation

GitHub Actions / Lint

ST1016: methods on the same type should have the same receiver name (seen 1x "a", 1x "info") (stylecheck)
msg := binary.BigEndian.AppendUint64(nil, a.EpochNumber)
msg = binary.BigEndian.AppendUint64(msg, a.BidPrice)
msg = append(msg, a.BuilderSEQAddress[:]...)
hash := sha256.Sum256(msg)
return hash, nil
}

func (info *AuctionInfo) Marshal(p *codec.Packer) {
p.PackUint64(info.EpochNumber)
p.PackUint64(info.BidPrice)
Expand Down Expand Up @@ -90,17 +99,18 @@
return nil, fmt.Errorf("failed to parse public key: %w", err)
}

msg := make([]byte, 16)
binary.BigEndian.PutUint64(msg[:8], a.AuctionInfo.EpochNumber)
binary.BigEndian.PutUint64(msg[8:], a.AuctionInfo.BidPrice)
msg = append(msg, a.AuctionInfo.BuilderSEQAddress[:]...)
digest, err := a.AuctionInfo.HashAuctionInfo()
if err != nil {
return nil, fmt.Errorf("unable to hash auction info")
}

sig, err := bls.SignatureFromBytes(a.BuilderSignature)
if err != nil {
return nil, fmt.Errorf("failed to parse signature: %w", err)
}

// Verify the signature.
if !bls.Verify(msg, pubkey, sig) {
if !bls.Verify(digest[:], pubkey, sig) {
return nil, ErrInvalidBidderSignature
}

Expand Down
14 changes: 11 additions & 3 deletions actions/rollup_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,21 @@

switch r.OpCode {
case CreateRollup:
if contains(namespaces, r.Namespace) {
return nil, ErrNameSpaceAlreadyRegistered
if !contains(namespaces, r.Namespace) {
manojkgorle marked this conversation as resolved.
Show resolved Hide resolved
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())

Check failure on line 78 in actions/rollup_register.go

View workflow job for this annotation

GitHub Actions / Lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
}
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): %w", 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-arcadia.14
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.15
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
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ 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-arcadia.13 h1:jZJXZpW6gQkfH0draUp5fQLwCfKzRYhNLHDxz33ncOs=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.13/go.mod h1:0Vj2PdwSFN7pat4Sno39IfmtOiv/gO9mxZXyRKnoKtI=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.14 h1:mDlxazNtWWHV4sb+j9G/Aw6DW4WA1zcNLM2B6ZoYA8s=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.14/go.mod h1:0Vj2PdwSFN7pat4Sno39IfmtOiv/gO9mxZXyRKnoKtI=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.15 h1:GKRJZn4O4+1HZID5uLzkUCSmfQ/he4zrQ3drPhuVfWQ=
github.com/AnomalyFi/hypersdk v0.9.7-arcadia.15/go.mod h1:0Vj2PdwSFN7pat4Sno39IfmtOiv/gO9mxZXyRKnoKtI=
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
4 changes: 4 additions & 0 deletions rpc/jsonrpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ func (j *JSONRPCServer) GetRollupInfo(req *http.Request, args *types.GetRollupIn
if err != nil {
return err
}
if info == nil {
return fmt.Errorf("not such rollup in state")
}

reply.Info = *info
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ find "${TMPDIR}"/avalanchego-"${VERSION}"
# if you are starting your own devnet (otherwise anyone can access
# funds using the included demo.pk)
# Sum of balances should be less than max uint64.
# builder address: seq1qxg2p2au72mweweuyu3dx8dhla6gyky630azwsvnc69tvg0m6qx9uqms9wx
# opnode address: seq1qy94dndd0wzru9gvq3ayw52ngcd2fuhyptt58f4a3eppjzpx573qg9cr7sm
echo "creating allocations file"
cat <<EOF > "${TMPDIR}"/allocations.json
[
{"address":"${ADDRESS}", "balance":1000000000000000000},
{"address":"seq1qy94dndd0wzru9gvq3ayw52ngcd2fuhyptt58f4a3eppjzpx573qg9cr7sm", "balance":1000000000000000000}
{"address":"seq1qy94dndd0wzru9gvq3ayw52ngcd2fuhyptt58f4a3eppjzpx573qg9cr7sm", "balance":1000000000000000000},
{"address":"seq1qxg2p2au72mweweuyu3dx8dhla6gyky630azwsvnc69tvg0m6qx9uqms9wx", "balance":1000000000000000000}
]
EOF

Expand Down
Loading