Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 058d09f

Browse files
tests passing
1 parent 546c59c commit 058d09f

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

chain/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func DefaultGenesis() *Genesis {
8787
BlockTarget: 1, // 1 Block per Second
8888
TargetUnits: 10 * 512 * 60, // 5012 Units Per Block (~1.2MB of SetTx)
8989
MinPrice: 1, // (50 for easiest claim)
90-
MinBlockCost: 1, // Minimum Unit Overhead
90+
MinBlockCost: 0, // Minimum Unit Overhead
9191
}
9292
}
9393

cmd/quarkcli/cmd/genesis.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"os"
1010
"path/filepath"
11+
"strconv"
1112

1213
"github.com/fatih/color"
1314
"github.com/spf13/cobra"
@@ -23,6 +24,8 @@ var (
2324
claimReward int64
2425
lifelineUnitReward int64
2526
beneficiaryReward int64
27+
28+
magic uint64
2629
)
2730

2831
func init() {
@@ -65,19 +68,30 @@ func init() {
6568
}
6669

6770
var genesisCmd = &cobra.Command{
68-
Use: "genesis [options]",
71+
Use: "genesis [magic] [allocations file] [options]",
6972
Short: "Creates a new genesis in the default location",
7073
PreRunE: func(cmd *cobra.Command, args []string) error {
71-
if len(args) == 0 {
72-
return errors.New("missing allocations file")
74+
if len(args) != 2 {
75+
return errors.New("invalid args")
76+
}
77+
78+
m, err := strconv.ParseUint(args[0], 10, 64)
79+
if err != nil {
80+
return err
7381
}
82+
magic = m
83+
if magic == 0 {
84+
return chain.ErrInvalidMagic
85+
}
86+
7487
return nil
7588
},
7689
RunE: genesisFunc,
7790
}
7891

7992
func genesisFunc(cmd *cobra.Command, args []string) error {
8093
genesis := chain.DefaultGenesis()
94+
genesis.Magic = magic
8195
if minPrice >= 0 {
8296
genesis.MinPrice = uint64(minPrice)
8397
}
@@ -94,7 +108,7 @@ func genesisFunc(cmd *cobra.Command, args []string) error {
94108
genesis.BeneficiaryReward = uint64(beneficiaryReward)
95109
}
96110

97-
a, err := os.ReadFile(args[0])
111+
a, err := os.ReadFile(args[1])
98112
if err != nil {
99113
return err
100114
}
@@ -105,7 +119,7 @@ func genesisFunc(cmd *cobra.Command, args []string) error {
105119
// Store hash instead
106120
genesis.Allocations = allocs
107121

108-
b, err := chain.Marshal(genesis)
122+
b, err := json.Marshal(genesis)
109123
if err != nil {
110124
return err
111125
}

scripts/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ go build -v -o /tmp/quark-cli ./cmd/quarkcli
6868
echo "creating allocations file"
6969
cat <<EOF > /tmp/allocations.json
7070
[{
71-
"address":"0xa6273", "balance":100000
71+
"address":"0xF9370fa73846393798C2d23aa2a4aBA7489d9810", "balance":100000
7272
}]
7373
EOF
7474

7575
echo "creating VM genesis file"
7676
rm -f /tmp/quarkvm.genesis
77-
/tmp/quark-cli genesis /tmp/allocations.json --genesis-file /tmp/quarkvm.genesis
77+
/tmp/quark-cli genesis 1 /tmp/allocations.json --genesis-file /tmp/quarkvm.genesis
7878

7979
echo "building runner"
8080
pushd ./tests/runner

tests/e2e/e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type instance struct {
7474

7575
var _ = ginkgo.BeforeSuite(func() {
7676
var err error
77-
priv, err = crypto.GenerateKey()
77+
priv, err = crypto.HexToECDSA("a1c0bd71ff64aebd666b04db0531d61479c2c031e4de38410de0609cbd6e66f0")
7878
gomega.Ω(err).Should(gomega.BeNil())
7979
sender = crypto.PubkeyToAddress(priv.PublicKey)
8080

tests/integration/integration_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package integration_test
77
import (
88
"context"
99
"crypto/ecdsa"
10+
"encoding/hex"
11+
"encoding/json"
1012
"flag"
1113
"math/rand"
1214
"net/http/httptest"
@@ -23,6 +25,7 @@ import (
2325
ecommon "github.com/ethereum/go-ethereum/common"
2426
"github.com/ethereum/go-ethereum/crypto"
2527
"github.com/fatih/color"
28+
log "github.com/inconshreveable/log15"
2629
ginkgo "github.com/onsi/ginkgo/v2"
2730
"github.com/onsi/gomega"
2831

@@ -99,6 +102,8 @@ var _ = ginkgo.BeforeSuite(func() {
99102
gomega.Ω(err).Should(gomega.BeNil())
100103
sender = crypto.PubkeyToAddress(priv.PublicKey)
101104

105+
log.Debug("generated key", "addr", sender, "priv", hex.EncodeToString(crypto.FromECDSA(priv)))
106+
102107
// create embedded VMs
103108
instances = make([]instance, vms)
104109

@@ -116,7 +121,7 @@ var _ = ginkgo.BeforeSuite(func() {
116121
Balance: 10000000,
117122
},
118123
}
119-
genesisBytes, err = chain.Marshal(genesis)
124+
genesisBytes, err = json.Marshal(genesis)
120125
gomega.Ω(err).Should(gomega.BeNil())
121126

122127
networkID := uint32(1)

vm/vm.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,16 @@ func (vm *VM) Initialize(
139139

140140
// Parse genesis data
141141
vm.genesis = new(chain.Genesis)
142-
if _, err := chain.Unmarshal(genesisBytes, vm.genesis); err != nil {
142+
if err := ejson.Unmarshal(genesisBytes, vm.genesis); err != nil {
143143
log.Error("could not unmarshal genesis bytes")
144144
return err
145145
}
146146
if err := vm.genesis.Verify(); err != nil {
147147
log.Error("genesis is invalid")
148148
return err
149149
}
150+
log.Debug("loaded genesis", "genesis", string(genesisBytes))
151+
150152
vm.mempool = mempool.New(vm.genesis, vm.config.MempoolSize)
151153

152154
if has { //nolint:nestif

0 commit comments

Comments
 (0)